pdf.worker.js 2.0 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058
  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. __w_pdfjs_require__(2);
  43. __w_pdfjs_require__(84);
  44. __w_pdfjs_require__(93);
  45. __w_pdfjs_require__(94);
  46. __w_pdfjs_require__(97);
  47. __w_pdfjs_require__(99);
  48. __w_pdfjs_require__(101);
  49. __w_pdfjs_require__(105);
  50. __w_pdfjs_require__(108);
  51. __w_pdfjs_require__(115);
  52. __w_pdfjs_require__(116);
  53. __w_pdfjs_require__(127);
  54. __w_pdfjs_require__(129);
  55. __w_pdfjs_require__(132);
  56. __w_pdfjs_require__(134);
  57. __w_pdfjs_require__(136);
  58. __w_pdfjs_require__(138);
  59. __w_pdfjs_require__(140);
  60. __w_pdfjs_require__(144);
  61. var _util = __w_pdfjs_require__(145);
  62. var _core_utils = __w_pdfjs_require__(150);
  63. var _primitives = __w_pdfjs_require__(151);
  64. var _pdf_manager = __w_pdfjs_require__(153);
  65. var _annotation = __w_pdfjs_require__(157);
  66. var _cleanup_helper = __w_pdfjs_require__(223);
  67. var _writer = __w_pdfjs_require__(217);
  68. var _message_handler = __w_pdfjs_require__(258);
  69. var _worker_stream = __w_pdfjs_require__(259);
  70. class WorkerTask {
  71. constructor(name) {
  72. this.name = name;
  73. this.terminated = false;
  74. this._capability = new _util.PromiseCapability();
  75. }
  76. get finished() {
  77. return this._capability.promise;
  78. }
  79. finish() {
  80. this._capability.resolve();
  81. }
  82. terminate() {
  83. this.terminated = true;
  84. }
  85. ensureNotTerminated() {
  86. if (this.terminated) {
  87. throw new Error("Worker task was terminated");
  88. }
  89. }
  90. }
  91. exports.WorkerTask = WorkerTask;
  92. class WorkerMessageHandler {
  93. static setup(handler, port) {
  94. let testMessageProcessed = false;
  95. handler.on("test", function (data) {
  96. if (testMessageProcessed) {
  97. return;
  98. }
  99. testMessageProcessed = true;
  100. handler.send("test", data instanceof Uint8Array);
  101. });
  102. handler.on("configure", function (data) {
  103. (0, _util.setVerbosityLevel)(data.verbosity);
  104. });
  105. handler.on("GetDocRequest", function (data) {
  106. return WorkerMessageHandler.createDocumentHandler(data, port);
  107. });
  108. }
  109. static createDocumentHandler(docParams, port) {
  110. let pdfManager;
  111. let terminated = false;
  112. let cancelXHRs = null;
  113. const WorkerTasks = new Set();
  114. const verbosity = (0, _util.getVerbosityLevel)();
  115. const {
  116. docId,
  117. apiVersion
  118. } = docParams;
  119. const workerVersion = '3.10.111';
  120. if (apiVersion !== workerVersion) {
  121. throw new Error(`The API version "${apiVersion}" does not match ` + `the Worker version "${workerVersion}".`);
  122. }
  123. const enumerableProperties = [];
  124. for (const property in []) {
  125. enumerableProperties.push(property);
  126. }
  127. if (enumerableProperties.length) {
  128. throw new Error("The `Array.prototype` contains unexpected enumerable properties: " + enumerableProperties.join(", ") + "; thus breaking e.g. `for...in` iteration of `Array`s.");
  129. }
  130. const workerHandlerName = docId + "_worker";
  131. let handler = new _message_handler.MessageHandler(workerHandlerName, docId, port);
  132. function ensureNotTerminated() {
  133. if (terminated) {
  134. throw new Error("Worker was terminated");
  135. }
  136. }
  137. function startWorkerTask(task) {
  138. WorkerTasks.add(task);
  139. }
  140. function finishWorkerTask(task) {
  141. task.finish();
  142. WorkerTasks.delete(task);
  143. }
  144. async function loadDocument(recoveryMode) {
  145. await pdfManager.ensureDoc("checkHeader");
  146. await pdfManager.ensureDoc("parseStartXRef");
  147. await pdfManager.ensureDoc("parse", [recoveryMode]);
  148. await pdfManager.ensureDoc("checkFirstPage", [recoveryMode]);
  149. await pdfManager.ensureDoc("checkLastPage", [recoveryMode]);
  150. const isPureXfa = await pdfManager.ensureDoc("isPureXfa");
  151. if (isPureXfa) {
  152. const task = new WorkerTask("loadXfaFonts");
  153. startWorkerTask(task);
  154. await Promise.all([pdfManager.loadXfaFonts(handler, task).catch(reason => {}).then(() => finishWorkerTask(task)), pdfManager.loadXfaImages()]);
  155. }
  156. const [numPages, fingerprints] = await Promise.all([pdfManager.ensureDoc("numPages"), pdfManager.ensureDoc("fingerprints")]);
  157. const htmlForXfa = isPureXfa ? await pdfManager.ensureDoc("htmlForXfa") : null;
  158. return {
  159. numPages,
  160. fingerprints,
  161. htmlForXfa
  162. };
  163. }
  164. function getPdfManager(_ref) {
  165. let {
  166. data,
  167. password,
  168. disableAutoFetch,
  169. rangeChunkSize,
  170. length,
  171. docBaseUrl,
  172. enableXfa,
  173. evaluatorOptions
  174. } = _ref;
  175. const pdfManagerArgs = {
  176. source: null,
  177. disableAutoFetch,
  178. docBaseUrl,
  179. docId,
  180. enableXfa,
  181. evaluatorOptions,
  182. handler,
  183. length,
  184. password,
  185. rangeChunkSize
  186. };
  187. const pdfManagerCapability = new _util.PromiseCapability();
  188. let newPdfManager;
  189. if (data) {
  190. try {
  191. pdfManagerArgs.source = data;
  192. newPdfManager = new _pdf_manager.LocalPdfManager(pdfManagerArgs);
  193. pdfManagerCapability.resolve(newPdfManager);
  194. } catch (ex) {
  195. pdfManagerCapability.reject(ex);
  196. }
  197. return pdfManagerCapability.promise;
  198. }
  199. let pdfStream,
  200. cachedChunks = [];
  201. try {
  202. pdfStream = new _worker_stream.PDFWorkerStream(handler);
  203. } catch (ex) {
  204. pdfManagerCapability.reject(ex);
  205. return pdfManagerCapability.promise;
  206. }
  207. const fullRequest = pdfStream.getFullReader();
  208. fullRequest.headersReady.then(function () {
  209. if (!fullRequest.isRangeSupported) {
  210. return;
  211. }
  212. pdfManagerArgs.source = pdfStream;
  213. pdfManagerArgs.length = fullRequest.contentLength;
  214. pdfManagerArgs.disableAutoFetch ||= fullRequest.isStreamingSupported;
  215. newPdfManager = new _pdf_manager.NetworkPdfManager(pdfManagerArgs);
  216. for (const chunk of cachedChunks) {
  217. newPdfManager.sendProgressiveData(chunk);
  218. }
  219. cachedChunks = [];
  220. pdfManagerCapability.resolve(newPdfManager);
  221. cancelXHRs = null;
  222. }).catch(function (reason) {
  223. pdfManagerCapability.reject(reason);
  224. cancelXHRs = null;
  225. });
  226. let loaded = 0;
  227. const flushChunks = function () {
  228. const pdfFile = (0, _core_utils.arrayBuffersToBytes)(cachedChunks);
  229. if (length && pdfFile.length !== length) {
  230. (0, _util.warn)("reported HTTP length is different from actual");
  231. }
  232. try {
  233. pdfManagerArgs.source = pdfFile;
  234. newPdfManager = new _pdf_manager.LocalPdfManager(pdfManagerArgs);
  235. pdfManagerCapability.resolve(newPdfManager);
  236. } catch (ex) {
  237. pdfManagerCapability.reject(ex);
  238. }
  239. cachedChunks = [];
  240. };
  241. new Promise(function (resolve, reject) {
  242. const readChunk = function (_ref2) {
  243. let {
  244. value,
  245. done
  246. } = _ref2;
  247. try {
  248. ensureNotTerminated();
  249. if (done) {
  250. if (!newPdfManager) {
  251. flushChunks();
  252. }
  253. cancelXHRs = null;
  254. return;
  255. }
  256. loaded += value.byteLength;
  257. if (!fullRequest.isStreamingSupported) {
  258. handler.send("DocProgress", {
  259. loaded,
  260. total: Math.max(loaded, fullRequest.contentLength || 0)
  261. });
  262. }
  263. if (newPdfManager) {
  264. newPdfManager.sendProgressiveData(value);
  265. } else {
  266. cachedChunks.push(value);
  267. }
  268. fullRequest.read().then(readChunk, reject);
  269. } catch (e) {
  270. reject(e);
  271. }
  272. };
  273. fullRequest.read().then(readChunk, reject);
  274. }).catch(function (e) {
  275. pdfManagerCapability.reject(e);
  276. cancelXHRs = null;
  277. });
  278. cancelXHRs = function (reason) {
  279. pdfStream.cancelAllRequests(reason);
  280. };
  281. return pdfManagerCapability.promise;
  282. }
  283. function setupDoc(data) {
  284. function onSuccess(doc) {
  285. ensureNotTerminated();
  286. handler.send("GetDoc", {
  287. pdfInfo: doc
  288. });
  289. }
  290. function onFailure(ex) {
  291. ensureNotTerminated();
  292. if (ex instanceof _util.PasswordException) {
  293. const task = new WorkerTask(`PasswordException: response ${ex.code}`);
  294. startWorkerTask(task);
  295. handler.sendWithPromise("PasswordRequest", ex).then(function (_ref3) {
  296. let {
  297. password
  298. } = _ref3;
  299. finishWorkerTask(task);
  300. pdfManager.updatePassword(password);
  301. pdfManagerReady();
  302. }).catch(function () {
  303. finishWorkerTask(task);
  304. handler.send("DocException", ex);
  305. });
  306. } else if (ex instanceof _util.InvalidPDFException || ex instanceof _util.MissingPDFException || ex instanceof _util.UnexpectedResponseException || ex instanceof _util.UnknownErrorException) {
  307. handler.send("DocException", ex);
  308. } else {
  309. handler.send("DocException", new _util.UnknownErrorException(ex.message, ex.toString()));
  310. }
  311. }
  312. function pdfManagerReady() {
  313. ensureNotTerminated();
  314. loadDocument(false).then(onSuccess, function (reason) {
  315. ensureNotTerminated();
  316. if (!(reason instanceof _core_utils.XRefParseException)) {
  317. onFailure(reason);
  318. return;
  319. }
  320. pdfManager.requestLoadedStream().then(function () {
  321. ensureNotTerminated();
  322. loadDocument(true).then(onSuccess, onFailure);
  323. });
  324. });
  325. }
  326. ensureNotTerminated();
  327. getPdfManager(data).then(function (newPdfManager) {
  328. if (terminated) {
  329. newPdfManager.terminate(new _util.AbortException("Worker was terminated."));
  330. throw new Error("Worker was terminated");
  331. }
  332. pdfManager = newPdfManager;
  333. pdfManager.requestLoadedStream(true).then(stream => {
  334. handler.send("DataLoaded", {
  335. length: stream.bytes.byteLength
  336. });
  337. });
  338. }).then(pdfManagerReady, onFailure);
  339. }
  340. handler.on("GetPage", function (data) {
  341. return pdfManager.getPage(data.pageIndex).then(function (page) {
  342. return Promise.all([pdfManager.ensure(page, "rotate"), pdfManager.ensure(page, "ref"), pdfManager.ensure(page, "userUnit"), pdfManager.ensure(page, "view")]).then(function (_ref4) {
  343. let [rotate, ref, userUnit, view] = _ref4;
  344. return {
  345. rotate,
  346. ref,
  347. userUnit,
  348. view
  349. };
  350. });
  351. });
  352. });
  353. handler.on("GetPageIndex", function (data) {
  354. const pageRef = _primitives.Ref.get(data.num, data.gen);
  355. return pdfManager.ensureCatalog("getPageIndex", [pageRef]);
  356. });
  357. handler.on("GetDestinations", function (data) {
  358. return pdfManager.ensureCatalog("destinations");
  359. });
  360. handler.on("GetDestination", function (data) {
  361. return pdfManager.ensureCatalog("getDestination", [data.id]);
  362. });
  363. handler.on("GetPageLabels", function (data) {
  364. return pdfManager.ensureCatalog("pageLabels");
  365. });
  366. handler.on("GetPageLayout", function (data) {
  367. return pdfManager.ensureCatalog("pageLayout");
  368. });
  369. handler.on("GetPageMode", function (data) {
  370. return pdfManager.ensureCatalog("pageMode");
  371. });
  372. handler.on("GetViewerPreferences", function (data) {
  373. return pdfManager.ensureCatalog("viewerPreferences");
  374. });
  375. handler.on("GetOpenAction", function (data) {
  376. return pdfManager.ensureCatalog("openAction");
  377. });
  378. handler.on("GetAttachments", function (data) {
  379. return pdfManager.ensureCatalog("attachments");
  380. });
  381. handler.on("GetDocJSActions", function (data) {
  382. return pdfManager.ensureCatalog("jsActions");
  383. });
  384. handler.on("GetPageJSActions", function (_ref5) {
  385. let {
  386. pageIndex
  387. } = _ref5;
  388. return pdfManager.getPage(pageIndex).then(function (page) {
  389. return pdfManager.ensure(page, "jsActions");
  390. });
  391. });
  392. handler.on("GetOutline", function (data) {
  393. return pdfManager.ensureCatalog("documentOutline");
  394. });
  395. handler.on("GetOptionalContentConfig", function (data) {
  396. return pdfManager.ensureCatalog("optionalContentConfig");
  397. });
  398. handler.on("GetPermissions", function (data) {
  399. return pdfManager.ensureCatalog("permissions");
  400. });
  401. handler.on("GetMetadata", function (data) {
  402. return Promise.all([pdfManager.ensureDoc("documentInfo"), pdfManager.ensureCatalog("metadata")]);
  403. });
  404. handler.on("GetMarkInfo", function (data) {
  405. return pdfManager.ensureCatalog("markInfo");
  406. });
  407. handler.on("GetData", function (data) {
  408. return pdfManager.requestLoadedStream().then(function (stream) {
  409. return stream.bytes;
  410. });
  411. });
  412. handler.on("GetAnnotations", function (_ref6) {
  413. let {
  414. pageIndex,
  415. intent
  416. } = _ref6;
  417. return pdfManager.getPage(pageIndex).then(function (page) {
  418. const task = new WorkerTask(`GetAnnotations: page ${pageIndex}`);
  419. startWorkerTask(task);
  420. return page.getAnnotationsData(handler, task, intent).then(data => {
  421. finishWorkerTask(task);
  422. return data;
  423. }, reason => {
  424. finishWorkerTask(task);
  425. throw reason;
  426. });
  427. });
  428. });
  429. handler.on("GetFieldObjects", function (data) {
  430. return pdfManager.ensureDoc("fieldObjects");
  431. });
  432. handler.on("HasJSActions", function (data) {
  433. return pdfManager.ensureDoc("hasJSActions");
  434. });
  435. handler.on("GetCalculationOrderIds", function (data) {
  436. return pdfManager.ensureDoc("calculationOrderIds");
  437. });
  438. handler.on("SaveDocument", async function (_ref7) {
  439. let {
  440. isPureXfa,
  441. numPages,
  442. annotationStorage,
  443. filename
  444. } = _ref7;
  445. const promises = [pdfManager.requestLoadedStream(), pdfManager.ensureCatalog("acroForm"), pdfManager.ensureCatalog("acroFormRef"), pdfManager.ensureDoc("startXRef"), pdfManager.ensureDoc("linearization")];
  446. const newAnnotationsByPage = !isPureXfa ? (0, _core_utils.getNewAnnotationsMap)(annotationStorage) : null;
  447. const xref = await pdfManager.ensureDoc("xref");
  448. if (newAnnotationsByPage) {
  449. const imagePromises = _annotation.AnnotationFactory.generateImages(annotationStorage.values(), xref, pdfManager.evaluatorOptions.isOffscreenCanvasSupported);
  450. for (const [pageIndex, annotations] of newAnnotationsByPage) {
  451. promises.push(pdfManager.getPage(pageIndex).then(page => {
  452. const task = new WorkerTask(`Save (editor): page ${pageIndex}`);
  453. return page.saveNewAnnotations(handler, task, annotations, imagePromises).finally(function () {
  454. finishWorkerTask(task);
  455. });
  456. }));
  457. }
  458. }
  459. if (isPureXfa) {
  460. promises.push(pdfManager.serializeXfaData(annotationStorage));
  461. } else {
  462. for (let pageIndex = 0; pageIndex < numPages; pageIndex++) {
  463. promises.push(pdfManager.getPage(pageIndex).then(function (page) {
  464. const task = new WorkerTask(`Save: page ${pageIndex}`);
  465. return page.save(handler, task, annotationStorage).finally(function () {
  466. finishWorkerTask(task);
  467. });
  468. }));
  469. }
  470. }
  471. return Promise.all(promises).then(function (_ref8) {
  472. let [stream, acroForm, acroFormRef, startXRef, linearization, ...refs] = _ref8;
  473. let newRefs = [];
  474. let xfaData = null;
  475. if (isPureXfa) {
  476. xfaData = refs[0];
  477. if (!xfaData) {
  478. return stream.bytes;
  479. }
  480. } else {
  481. newRefs = refs.flat(2);
  482. if (newRefs.length === 0) {
  483. return stream.bytes;
  484. }
  485. }
  486. const needAppearances = acroFormRef && acroForm instanceof _primitives.Dict && newRefs.some(ref => ref.needAppearances);
  487. const xfa = acroForm instanceof _primitives.Dict && acroForm.get("XFA") || null;
  488. let xfaDatasetsRef = null;
  489. let hasXfaDatasetsEntry = false;
  490. if (Array.isArray(xfa)) {
  491. for (let i = 0, ii = xfa.length; i < ii; i += 2) {
  492. if (xfa[i] === "datasets") {
  493. xfaDatasetsRef = xfa[i + 1];
  494. hasXfaDatasetsEntry = true;
  495. }
  496. }
  497. if (xfaDatasetsRef === null) {
  498. xfaDatasetsRef = xref.getNewTemporaryRef();
  499. }
  500. } else if (xfa) {
  501. (0, _util.warn)("Unsupported XFA type.");
  502. }
  503. let newXrefInfo = Object.create(null);
  504. if (xref.trailer) {
  505. const infoObj = Object.create(null);
  506. const xrefInfo = xref.trailer.get("Info") || null;
  507. if (xrefInfo instanceof _primitives.Dict) {
  508. xrefInfo.forEach((key, value) => {
  509. if (typeof value === "string") {
  510. infoObj[key] = (0, _util.stringToPDFString)(value);
  511. }
  512. });
  513. }
  514. newXrefInfo = {
  515. rootRef: xref.trailer.getRaw("Root") || null,
  516. encryptRef: xref.trailer.getRaw("Encrypt") || null,
  517. newRef: xref.getNewTemporaryRef(),
  518. infoRef: xref.trailer.getRaw("Info") || null,
  519. info: infoObj,
  520. fileIds: xref.trailer.get("ID") || null,
  521. startXRef: linearization ? startXRef : xref.lastXRefStreamPos ?? startXRef,
  522. filename
  523. };
  524. }
  525. return (0, _writer.incrementalUpdate)({
  526. originalData: stream.bytes,
  527. xrefInfo: newXrefInfo,
  528. newRefs,
  529. xref,
  530. hasXfa: !!xfa,
  531. xfaDatasetsRef,
  532. hasXfaDatasetsEntry,
  533. needAppearances,
  534. acroFormRef,
  535. acroForm,
  536. xfaData
  537. }).finally(() => {
  538. xref.resetNewTemporaryRef();
  539. });
  540. });
  541. });
  542. handler.on("GetOperatorList", function (data, sink) {
  543. const pageIndex = data.pageIndex;
  544. pdfManager.getPage(pageIndex).then(function (page) {
  545. const task = new WorkerTask(`GetOperatorList: page ${pageIndex}`);
  546. startWorkerTask(task);
  547. const start = verbosity >= _util.VerbosityLevel.INFOS ? Date.now() : 0;
  548. page.getOperatorList({
  549. handler,
  550. sink,
  551. task,
  552. intent: data.intent,
  553. cacheKey: data.cacheKey,
  554. annotationStorage: data.annotationStorage
  555. }).then(function (operatorListInfo) {
  556. finishWorkerTask(task);
  557. if (start) {
  558. (0, _util.info)(`page=${pageIndex + 1} - getOperatorList: time=` + `${Date.now() - start}ms, len=${operatorListInfo.length}`);
  559. }
  560. sink.close();
  561. }, function (reason) {
  562. finishWorkerTask(task);
  563. if (task.terminated) {
  564. return;
  565. }
  566. sink.error(reason);
  567. });
  568. });
  569. });
  570. handler.on("GetTextContent", function (data, sink) {
  571. const {
  572. pageIndex,
  573. includeMarkedContent,
  574. disableNormalization
  575. } = data;
  576. pdfManager.getPage(pageIndex).then(function (page) {
  577. const task = new WorkerTask("GetTextContent: page " + pageIndex);
  578. startWorkerTask(task);
  579. const start = verbosity >= _util.VerbosityLevel.INFOS ? Date.now() : 0;
  580. page.extractTextContent({
  581. handler,
  582. task,
  583. sink,
  584. includeMarkedContent,
  585. disableNormalization
  586. }).then(function () {
  587. finishWorkerTask(task);
  588. if (start) {
  589. (0, _util.info)(`page=${pageIndex + 1} - getTextContent: time=` + `${Date.now() - start}ms`);
  590. }
  591. sink.close();
  592. }, function (reason) {
  593. finishWorkerTask(task);
  594. if (task.terminated) {
  595. return;
  596. }
  597. sink.error(reason);
  598. });
  599. });
  600. });
  601. handler.on("GetStructTree", function (data) {
  602. return pdfManager.getPage(data.pageIndex).then(function (page) {
  603. return pdfManager.ensure(page, "getStructTree");
  604. });
  605. });
  606. handler.on("FontFallback", function (data) {
  607. return pdfManager.fontFallback(data.id, handler);
  608. });
  609. handler.on("Cleanup", function (data) {
  610. return pdfManager.cleanup(true);
  611. });
  612. handler.on("Terminate", function (data) {
  613. terminated = true;
  614. const waitOn = [];
  615. if (pdfManager) {
  616. pdfManager.terminate(new _util.AbortException("Worker was terminated."));
  617. const cleanupPromise = pdfManager.cleanup();
  618. waitOn.push(cleanupPromise);
  619. pdfManager = null;
  620. } else {
  621. (0, _cleanup_helper.clearGlobalCaches)();
  622. }
  623. if (cancelXHRs) {
  624. cancelXHRs(new _util.AbortException("Worker was terminated."));
  625. }
  626. for (const task of WorkerTasks) {
  627. waitOn.push(task.finished);
  628. task.terminate();
  629. }
  630. return Promise.all(waitOn).then(function () {
  631. handler.destroy();
  632. handler = null;
  633. });
  634. });
  635. handler.on("Ready", function (data) {
  636. setupDoc(docParams);
  637. docParams = null;
  638. });
  639. return workerHandlerName;
  640. }
  641. static initializeFromPort(port) {
  642. const handler = new _message_handler.MessageHandler("worker", "main", port);
  643. WorkerMessageHandler.setup(handler, port);
  644. handler.send("ready", null);
  645. }
  646. }
  647. exports.WorkerMessageHandler = WorkerMessageHandler;
  648. function isMessagePort(maybePort) {
  649. return typeof maybePort.postMessage === "function" && "onmessage" in maybePort;
  650. }
  651. if (typeof window === "undefined" && !_util.isNodeJS && typeof self !== "undefined" && isMessagePort(self)) {
  652. WorkerMessageHandler.initializeFromPort(self);
  653. }
  654. /***/ }),
  655. /* 2 */
  656. /***/ ((__unused_webpack_module, __unused_webpack_exports, __w_pdfjs_require__) => {
  657. var $ = __w_pdfjs_require__(3);
  658. var global = __w_pdfjs_require__(4);
  659. var apply = __w_pdfjs_require__(69);
  660. var wrapErrorConstructorWithCause = __w_pdfjs_require__(70);
  661. var WEB_ASSEMBLY = 'WebAssembly';
  662. var WebAssembly = global[WEB_ASSEMBLY];
  663. var FORCED = Error('e', { cause: 7 }).cause !== 7;
  664. var exportGlobalErrorCauseWrapper = function (ERROR_NAME, wrapper) {
  665. var O = {};
  666. O[ERROR_NAME] = wrapErrorConstructorWithCause(ERROR_NAME, wrapper, FORCED);
  667. $({
  668. global: true,
  669. constructor: true,
  670. arity: 1,
  671. forced: FORCED
  672. }, O);
  673. };
  674. var exportWebAssemblyErrorCauseWrapper = function (ERROR_NAME, wrapper) {
  675. if (WebAssembly && WebAssembly[ERROR_NAME]) {
  676. var O = {};
  677. O[ERROR_NAME] = wrapErrorConstructorWithCause(WEB_ASSEMBLY + '.' + ERROR_NAME, wrapper, FORCED);
  678. $({
  679. target: WEB_ASSEMBLY,
  680. stat: true,
  681. constructor: true,
  682. arity: 1,
  683. forced: FORCED
  684. }, O);
  685. }
  686. };
  687. exportGlobalErrorCauseWrapper('Error', function (init) {
  688. return function Error(message) {
  689. return apply(init, this, arguments);
  690. };
  691. });
  692. exportGlobalErrorCauseWrapper('EvalError', function (init) {
  693. return function EvalError(message) {
  694. return apply(init, this, arguments);
  695. };
  696. });
  697. exportGlobalErrorCauseWrapper('RangeError', function (init) {
  698. return function RangeError(message) {
  699. return apply(init, this, arguments);
  700. };
  701. });
  702. exportGlobalErrorCauseWrapper('ReferenceError', function (init) {
  703. return function ReferenceError(message) {
  704. return apply(init, this, arguments);
  705. };
  706. });
  707. exportGlobalErrorCauseWrapper('SyntaxError', function (init) {
  708. return function SyntaxError(message) {
  709. return apply(init, this, arguments);
  710. };
  711. });
  712. exportGlobalErrorCauseWrapper('TypeError', function (init) {
  713. return function TypeError(message) {
  714. return apply(init, this, arguments);
  715. };
  716. });
  717. exportGlobalErrorCauseWrapper('URIError', function (init) {
  718. return function URIError(message) {
  719. return apply(init, this, arguments);
  720. };
  721. });
  722. exportWebAssemblyErrorCauseWrapper('CompileError', function (init) {
  723. return function CompileError(message) {
  724. return apply(init, this, arguments);
  725. };
  726. });
  727. exportWebAssemblyErrorCauseWrapper('LinkError', function (init) {
  728. return function LinkError(message) {
  729. return apply(init, this, arguments);
  730. };
  731. });
  732. exportWebAssemblyErrorCauseWrapper('RuntimeError', function (init) {
  733. return function RuntimeError(message) {
  734. return apply(init, this, arguments);
  735. };
  736. });
  737. /***/ }),
  738. /* 3 */
  739. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  740. var global = __w_pdfjs_require__(4);
  741. var getOwnPropertyDescriptor = (__w_pdfjs_require__(5).f);
  742. var createNonEnumerableProperty = __w_pdfjs_require__(44);
  743. var defineBuiltIn = __w_pdfjs_require__(48);
  744. var defineGlobalProperty = __w_pdfjs_require__(38);
  745. var copyConstructorProperties = __w_pdfjs_require__(56);
  746. var isForced = __w_pdfjs_require__(68);
  747. module.exports = function (options, source) {
  748. var TARGET = options.target;
  749. var GLOBAL = options.global;
  750. var STATIC = options.stat;
  751. var FORCED, target, key, targetProperty, sourceProperty, descriptor;
  752. if (GLOBAL) {
  753. target = global;
  754. } else if (STATIC) {
  755. target = global[TARGET] || defineGlobalProperty(TARGET, {});
  756. } else {
  757. target = (global[TARGET] || {}).prototype;
  758. }
  759. if (target)
  760. for (key in source) {
  761. sourceProperty = source[key];
  762. if (options.dontCallGetSet) {
  763. descriptor = getOwnPropertyDescriptor(target, key);
  764. targetProperty = descriptor && descriptor.value;
  765. } else
  766. targetProperty = target[key];
  767. FORCED = isForced(GLOBAL ? key : TARGET + (STATIC ? '.' : '#') + key, options.forced);
  768. if (!FORCED && targetProperty !== undefined) {
  769. if (typeof sourceProperty == typeof targetProperty)
  770. continue;
  771. copyConstructorProperties(sourceProperty, targetProperty);
  772. }
  773. if (options.sham || targetProperty && targetProperty.sham) {
  774. createNonEnumerableProperty(sourceProperty, 'sham', true);
  775. }
  776. defineBuiltIn(target, key, sourceProperty, options);
  777. }
  778. };
  779. /***/ }),
  780. /* 4 */
  781. /***/ (function(module) {
  782. var check = function (it) {
  783. return it && it.Math === Math && it;
  784. };
  785. module.exports = check(typeof globalThis == 'object' && globalThis) || check(typeof window == 'object' && window) || check(typeof self == 'object' && self) || check(typeof global == 'object' && global) || (function () {
  786. return this;
  787. }()) || this || Function('return this')();
  788. /***/ }),
  789. /* 5 */
  790. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  791. var DESCRIPTORS = __w_pdfjs_require__(6);
  792. var call = __w_pdfjs_require__(8);
  793. var propertyIsEnumerableModule = __w_pdfjs_require__(10);
  794. var createPropertyDescriptor = __w_pdfjs_require__(11);
  795. var toIndexedObject = __w_pdfjs_require__(12);
  796. var toPropertyKey = __w_pdfjs_require__(18);
  797. var hasOwn = __w_pdfjs_require__(39);
  798. var IE8_DOM_DEFINE = __w_pdfjs_require__(42);
  799. var $getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
  800. exports.f = DESCRIPTORS ? $getOwnPropertyDescriptor : function getOwnPropertyDescriptor(O, P) {
  801. O = toIndexedObject(O);
  802. P = toPropertyKey(P);
  803. if (IE8_DOM_DEFINE)
  804. try {
  805. return $getOwnPropertyDescriptor(O, P);
  806. } catch (error) {
  807. }
  808. if (hasOwn(O, P))
  809. return createPropertyDescriptor(!call(propertyIsEnumerableModule.f, O, P), O[P]);
  810. };
  811. /***/ }),
  812. /* 6 */
  813. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  814. var fails = __w_pdfjs_require__(7);
  815. module.exports = !fails(function () {
  816. return Object.defineProperty({}, 1, {
  817. get: function () {
  818. return 7;
  819. }
  820. })[1] !== 7;
  821. });
  822. /***/ }),
  823. /* 7 */
  824. /***/ ((module) => {
  825. module.exports = function (exec) {
  826. try {
  827. return !!exec();
  828. } catch (error) {
  829. return true;
  830. }
  831. };
  832. /***/ }),
  833. /* 8 */
  834. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  835. var NATIVE_BIND = __w_pdfjs_require__(9);
  836. var call = Function.prototype.call;
  837. module.exports = NATIVE_BIND ? call.bind(call) : function () {
  838. return call.apply(call, arguments);
  839. };
  840. /***/ }),
  841. /* 9 */
  842. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  843. var fails = __w_pdfjs_require__(7);
  844. module.exports = !fails(function () {
  845. var test = function () {
  846. }.bind();
  847. return typeof test != 'function' || test.hasOwnProperty('prototype');
  848. });
  849. /***/ }),
  850. /* 10 */
  851. /***/ ((__unused_webpack_module, exports) => {
  852. var $propertyIsEnumerable = {}.propertyIsEnumerable;
  853. var getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
  854. var NASHORN_BUG = getOwnPropertyDescriptor && !$propertyIsEnumerable.call({ 1: 2 }, 1);
  855. exports.f = NASHORN_BUG ? function propertyIsEnumerable(V) {
  856. var descriptor = getOwnPropertyDescriptor(this, V);
  857. return !!descriptor && descriptor.enumerable;
  858. } : $propertyIsEnumerable;
  859. /***/ }),
  860. /* 11 */
  861. /***/ ((module) => {
  862. module.exports = function (bitmap, value) {
  863. return {
  864. enumerable: !(bitmap & 1),
  865. configurable: !(bitmap & 2),
  866. writable: !(bitmap & 4),
  867. value: value
  868. };
  869. };
  870. /***/ }),
  871. /* 12 */
  872. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  873. var IndexedObject = __w_pdfjs_require__(13);
  874. var requireObjectCoercible = __w_pdfjs_require__(16);
  875. module.exports = function (it) {
  876. return IndexedObject(requireObjectCoercible(it));
  877. };
  878. /***/ }),
  879. /* 13 */
  880. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  881. var uncurryThis = __w_pdfjs_require__(14);
  882. var fails = __w_pdfjs_require__(7);
  883. var classof = __w_pdfjs_require__(15);
  884. var $Object = Object;
  885. var split = uncurryThis(''.split);
  886. module.exports = fails(function () {
  887. return !$Object('z').propertyIsEnumerable(0);
  888. }) ? function (it) {
  889. return classof(it) === 'String' ? split(it, '') : $Object(it);
  890. } : $Object;
  891. /***/ }),
  892. /* 14 */
  893. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  894. var NATIVE_BIND = __w_pdfjs_require__(9);
  895. var FunctionPrototype = Function.prototype;
  896. var call = FunctionPrototype.call;
  897. var uncurryThisWithBind = NATIVE_BIND && FunctionPrototype.bind.bind(call, call);
  898. module.exports = NATIVE_BIND ? uncurryThisWithBind : function (fn) {
  899. return function () {
  900. return call.apply(fn, arguments);
  901. };
  902. };
  903. /***/ }),
  904. /* 15 */
  905. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  906. var uncurryThis = __w_pdfjs_require__(14);
  907. var toString = uncurryThis({}.toString);
  908. var stringSlice = uncurryThis(''.slice);
  909. module.exports = function (it) {
  910. return stringSlice(toString(it), 8, -1);
  911. };
  912. /***/ }),
  913. /* 16 */
  914. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  915. var isNullOrUndefined = __w_pdfjs_require__(17);
  916. var $TypeError = TypeError;
  917. module.exports = function (it) {
  918. if (isNullOrUndefined(it))
  919. throw $TypeError("Can't call method on " + it);
  920. return it;
  921. };
  922. /***/ }),
  923. /* 17 */
  924. /***/ ((module) => {
  925. module.exports = function (it) {
  926. return it === null || it === undefined;
  927. };
  928. /***/ }),
  929. /* 18 */
  930. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  931. var toPrimitive = __w_pdfjs_require__(19);
  932. var isSymbol = __w_pdfjs_require__(23);
  933. module.exports = function (argument) {
  934. var key = toPrimitive(argument, 'string');
  935. return isSymbol(key) ? key : key + '';
  936. };
  937. /***/ }),
  938. /* 19 */
  939. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  940. var call = __w_pdfjs_require__(8);
  941. var isObject = __w_pdfjs_require__(20);
  942. var isSymbol = __w_pdfjs_require__(23);
  943. var getMethod = __w_pdfjs_require__(30);
  944. var ordinaryToPrimitive = __w_pdfjs_require__(33);
  945. var wellKnownSymbol = __w_pdfjs_require__(34);
  946. var $TypeError = TypeError;
  947. var TO_PRIMITIVE = wellKnownSymbol('toPrimitive');
  948. module.exports = function (input, pref) {
  949. if (!isObject(input) || isSymbol(input))
  950. return input;
  951. var exoticToPrim = getMethod(input, TO_PRIMITIVE);
  952. var result;
  953. if (exoticToPrim) {
  954. if (pref === undefined)
  955. pref = 'default';
  956. result = call(exoticToPrim, input, pref);
  957. if (!isObject(result) || isSymbol(result))
  958. return result;
  959. throw $TypeError("Can't convert object to primitive value");
  960. }
  961. if (pref === undefined)
  962. pref = 'number';
  963. return ordinaryToPrimitive(input, pref);
  964. };
  965. /***/ }),
  966. /* 20 */
  967. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  968. var isCallable = __w_pdfjs_require__(21);
  969. var $documentAll = __w_pdfjs_require__(22);
  970. var documentAll = $documentAll.all;
  971. module.exports = $documentAll.IS_HTMLDDA ? function (it) {
  972. return typeof it == 'object' ? it !== null : isCallable(it) || it === documentAll;
  973. } : function (it) {
  974. return typeof it == 'object' ? it !== null : isCallable(it);
  975. };
  976. /***/ }),
  977. /* 21 */
  978. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  979. var $documentAll = __w_pdfjs_require__(22);
  980. var documentAll = $documentAll.all;
  981. module.exports = $documentAll.IS_HTMLDDA ? function (argument) {
  982. return typeof argument == 'function' || argument === documentAll;
  983. } : function (argument) {
  984. return typeof argument == 'function';
  985. };
  986. /***/ }),
  987. /* 22 */
  988. /***/ ((module) => {
  989. var documentAll = typeof document == 'object' && document.all;
  990. var IS_HTMLDDA = typeof documentAll == 'undefined' && documentAll !== undefined;
  991. module.exports = {
  992. all: documentAll,
  993. IS_HTMLDDA: IS_HTMLDDA
  994. };
  995. /***/ }),
  996. /* 23 */
  997. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  998. var getBuiltIn = __w_pdfjs_require__(24);
  999. var isCallable = __w_pdfjs_require__(21);
  1000. var isPrototypeOf = __w_pdfjs_require__(25);
  1001. var USE_SYMBOL_AS_UID = __w_pdfjs_require__(26);
  1002. var $Object = Object;
  1003. module.exports = USE_SYMBOL_AS_UID ? function (it) {
  1004. return typeof it == 'symbol';
  1005. } : function (it) {
  1006. var $Symbol = getBuiltIn('Symbol');
  1007. return isCallable($Symbol) && isPrototypeOf($Symbol.prototype, $Object(it));
  1008. };
  1009. /***/ }),
  1010. /* 24 */
  1011. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  1012. var global = __w_pdfjs_require__(4);
  1013. var isCallable = __w_pdfjs_require__(21);
  1014. var aFunction = function (argument) {
  1015. return isCallable(argument) ? argument : undefined;
  1016. };
  1017. module.exports = function (namespace, method) {
  1018. return arguments.length < 2 ? aFunction(global[namespace]) : global[namespace] && global[namespace][method];
  1019. };
  1020. /***/ }),
  1021. /* 25 */
  1022. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  1023. var uncurryThis = __w_pdfjs_require__(14);
  1024. module.exports = uncurryThis({}.isPrototypeOf);
  1025. /***/ }),
  1026. /* 26 */
  1027. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  1028. var NATIVE_SYMBOL = __w_pdfjs_require__(27);
  1029. module.exports = NATIVE_SYMBOL && !Symbol.sham && typeof Symbol.iterator == 'symbol';
  1030. /***/ }),
  1031. /* 27 */
  1032. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  1033. var V8_VERSION = __w_pdfjs_require__(28);
  1034. var fails = __w_pdfjs_require__(7);
  1035. var global = __w_pdfjs_require__(4);
  1036. var $String = global.String;
  1037. module.exports = !!Object.getOwnPropertySymbols && !fails(function () {
  1038. var symbol = Symbol('symbol detection');
  1039. return !$String(symbol) || !(Object(symbol) instanceof Symbol) || !Symbol.sham && V8_VERSION && V8_VERSION < 41;
  1040. });
  1041. /***/ }),
  1042. /* 28 */
  1043. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  1044. var global = __w_pdfjs_require__(4);
  1045. var userAgent = __w_pdfjs_require__(29);
  1046. var process = global.process;
  1047. var Deno = global.Deno;
  1048. var versions = process && process.versions || Deno && Deno.version;
  1049. var v8 = versions && versions.v8;
  1050. var match, version;
  1051. if (v8) {
  1052. match = v8.split('.');
  1053. version = match[0] > 0 && match[0] < 4 ? 1 : +(match[0] + match[1]);
  1054. }
  1055. if (!version && userAgent) {
  1056. match = userAgent.match(/Edge\/(\d+)/);
  1057. if (!match || match[1] >= 74) {
  1058. match = userAgent.match(/Chrome\/(\d+)/);
  1059. if (match)
  1060. version = +match[1];
  1061. }
  1062. }
  1063. module.exports = version;
  1064. /***/ }),
  1065. /* 29 */
  1066. /***/ ((module) => {
  1067. module.exports = typeof navigator != 'undefined' && String(navigator.userAgent) || '';
  1068. /***/ }),
  1069. /* 30 */
  1070. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  1071. var aCallable = __w_pdfjs_require__(31);
  1072. var isNullOrUndefined = __w_pdfjs_require__(17);
  1073. module.exports = function (V, P) {
  1074. var func = V[P];
  1075. return isNullOrUndefined(func) ? undefined : aCallable(func);
  1076. };
  1077. /***/ }),
  1078. /* 31 */
  1079. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  1080. var isCallable = __w_pdfjs_require__(21);
  1081. var tryToString = __w_pdfjs_require__(32);
  1082. var $TypeError = TypeError;
  1083. module.exports = function (argument) {
  1084. if (isCallable(argument))
  1085. return argument;
  1086. throw $TypeError(tryToString(argument) + ' is not a function');
  1087. };
  1088. /***/ }),
  1089. /* 32 */
  1090. /***/ ((module) => {
  1091. var $String = String;
  1092. module.exports = function (argument) {
  1093. try {
  1094. return $String(argument);
  1095. } catch (error) {
  1096. return 'Object';
  1097. }
  1098. };
  1099. /***/ }),
  1100. /* 33 */
  1101. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  1102. var call = __w_pdfjs_require__(8);
  1103. var isCallable = __w_pdfjs_require__(21);
  1104. var isObject = __w_pdfjs_require__(20);
  1105. var $TypeError = TypeError;
  1106. module.exports = function (input, pref) {
  1107. var fn, val;
  1108. if (pref === 'string' && isCallable(fn = input.toString) && !isObject(val = call(fn, input)))
  1109. return val;
  1110. if (isCallable(fn = input.valueOf) && !isObject(val = call(fn, input)))
  1111. return val;
  1112. if (pref !== 'string' && isCallable(fn = input.toString) && !isObject(val = call(fn, input)))
  1113. return val;
  1114. throw $TypeError("Can't convert object to primitive value");
  1115. };
  1116. /***/ }),
  1117. /* 34 */
  1118. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  1119. var global = __w_pdfjs_require__(4);
  1120. var shared = __w_pdfjs_require__(35);
  1121. var hasOwn = __w_pdfjs_require__(39);
  1122. var uid = __w_pdfjs_require__(41);
  1123. var NATIVE_SYMBOL = __w_pdfjs_require__(27);
  1124. var USE_SYMBOL_AS_UID = __w_pdfjs_require__(26);
  1125. var Symbol = global.Symbol;
  1126. var WellKnownSymbolsStore = shared('wks');
  1127. var createWellKnownSymbol = USE_SYMBOL_AS_UID ? Symbol['for'] || Symbol : Symbol && Symbol.withoutSetter || uid;
  1128. module.exports = function (name) {
  1129. if (!hasOwn(WellKnownSymbolsStore, name)) {
  1130. WellKnownSymbolsStore[name] = NATIVE_SYMBOL && hasOwn(Symbol, name) ? Symbol[name] : createWellKnownSymbol('Symbol.' + name);
  1131. }
  1132. return WellKnownSymbolsStore[name];
  1133. };
  1134. /***/ }),
  1135. /* 35 */
  1136. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  1137. var IS_PURE = __w_pdfjs_require__(36);
  1138. var store = __w_pdfjs_require__(37);
  1139. (module.exports = function (key, value) {
  1140. return store[key] || (store[key] = value !== undefined ? value : {});
  1141. })('versions', []).push({
  1142. version: '3.32.1',
  1143. mode: IS_PURE ? 'pure' : 'global',
  1144. copyright: '© 2014-2023 Denis Pushkarev (zloirock.ru)',
  1145. license: 'https://github.com/zloirock/core-js/blob/v3.32.1/LICENSE',
  1146. source: 'https://github.com/zloirock/core-js'
  1147. });
  1148. /***/ }),
  1149. /* 36 */
  1150. /***/ ((module) => {
  1151. module.exports = false;
  1152. /***/ }),
  1153. /* 37 */
  1154. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  1155. var global = __w_pdfjs_require__(4);
  1156. var defineGlobalProperty = __w_pdfjs_require__(38);
  1157. var SHARED = '__core-js_shared__';
  1158. var store = global[SHARED] || defineGlobalProperty(SHARED, {});
  1159. module.exports = store;
  1160. /***/ }),
  1161. /* 38 */
  1162. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  1163. var global = __w_pdfjs_require__(4);
  1164. var defineProperty = Object.defineProperty;
  1165. module.exports = function (key, value) {
  1166. try {
  1167. defineProperty(global, key, {
  1168. value: value,
  1169. configurable: true,
  1170. writable: true
  1171. });
  1172. } catch (error) {
  1173. global[key] = value;
  1174. }
  1175. return value;
  1176. };
  1177. /***/ }),
  1178. /* 39 */
  1179. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  1180. var uncurryThis = __w_pdfjs_require__(14);
  1181. var toObject = __w_pdfjs_require__(40);
  1182. var hasOwnProperty = uncurryThis({}.hasOwnProperty);
  1183. module.exports = Object.hasOwn || function hasOwn(it, key) {
  1184. return hasOwnProperty(toObject(it), key);
  1185. };
  1186. /***/ }),
  1187. /* 40 */
  1188. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  1189. var requireObjectCoercible = __w_pdfjs_require__(16);
  1190. var $Object = Object;
  1191. module.exports = function (argument) {
  1192. return $Object(requireObjectCoercible(argument));
  1193. };
  1194. /***/ }),
  1195. /* 41 */
  1196. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  1197. var uncurryThis = __w_pdfjs_require__(14);
  1198. var id = 0;
  1199. var postfix = Math.random();
  1200. var toString = uncurryThis(1.0.toString);
  1201. module.exports = function (key) {
  1202. return 'Symbol(' + (key === undefined ? '' : key) + ')_' + toString(++id + postfix, 36);
  1203. };
  1204. /***/ }),
  1205. /* 42 */
  1206. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  1207. var DESCRIPTORS = __w_pdfjs_require__(6);
  1208. var fails = __w_pdfjs_require__(7);
  1209. var createElement = __w_pdfjs_require__(43);
  1210. module.exports = !DESCRIPTORS && !fails(function () {
  1211. return Object.defineProperty(createElement('div'), 'a', {
  1212. get: function () {
  1213. return 7;
  1214. }
  1215. }).a !== 7;
  1216. });
  1217. /***/ }),
  1218. /* 43 */
  1219. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  1220. var global = __w_pdfjs_require__(4);
  1221. var isObject = __w_pdfjs_require__(20);
  1222. var document = global.document;
  1223. var EXISTS = isObject(document) && isObject(document.createElement);
  1224. module.exports = function (it) {
  1225. return EXISTS ? document.createElement(it) : {};
  1226. };
  1227. /***/ }),
  1228. /* 44 */
  1229. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  1230. var DESCRIPTORS = __w_pdfjs_require__(6);
  1231. var definePropertyModule = __w_pdfjs_require__(45);
  1232. var createPropertyDescriptor = __w_pdfjs_require__(11);
  1233. module.exports = DESCRIPTORS ? function (object, key, value) {
  1234. return definePropertyModule.f(object, key, createPropertyDescriptor(1, value));
  1235. } : function (object, key, value) {
  1236. object[key] = value;
  1237. return object;
  1238. };
  1239. /***/ }),
  1240. /* 45 */
  1241. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  1242. var DESCRIPTORS = __w_pdfjs_require__(6);
  1243. var IE8_DOM_DEFINE = __w_pdfjs_require__(42);
  1244. var V8_PROTOTYPE_DEFINE_BUG = __w_pdfjs_require__(46);
  1245. var anObject = __w_pdfjs_require__(47);
  1246. var toPropertyKey = __w_pdfjs_require__(18);
  1247. var $TypeError = TypeError;
  1248. var $defineProperty = Object.defineProperty;
  1249. var $getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
  1250. var ENUMERABLE = 'enumerable';
  1251. var CONFIGURABLE = 'configurable';
  1252. var WRITABLE = 'writable';
  1253. exports.f = DESCRIPTORS ? V8_PROTOTYPE_DEFINE_BUG ? function defineProperty(O, P, Attributes) {
  1254. anObject(O);
  1255. P = toPropertyKey(P);
  1256. anObject(Attributes);
  1257. if (typeof O === 'function' && P === 'prototype' && 'value' in Attributes && WRITABLE in Attributes && !Attributes[WRITABLE]) {
  1258. var current = $getOwnPropertyDescriptor(O, P);
  1259. if (current && current[WRITABLE]) {
  1260. O[P] = Attributes.value;
  1261. Attributes = {
  1262. configurable: CONFIGURABLE in Attributes ? Attributes[CONFIGURABLE] : current[CONFIGURABLE],
  1263. enumerable: ENUMERABLE in Attributes ? Attributes[ENUMERABLE] : current[ENUMERABLE],
  1264. writable: false
  1265. };
  1266. }
  1267. }
  1268. return $defineProperty(O, P, Attributes);
  1269. } : $defineProperty : function defineProperty(O, P, Attributes) {
  1270. anObject(O);
  1271. P = toPropertyKey(P);
  1272. anObject(Attributes);
  1273. if (IE8_DOM_DEFINE)
  1274. try {
  1275. return $defineProperty(O, P, Attributes);
  1276. } catch (error) {
  1277. }
  1278. if ('get' in Attributes || 'set' in Attributes)
  1279. throw $TypeError('Accessors not supported');
  1280. if ('value' in Attributes)
  1281. O[P] = Attributes.value;
  1282. return O;
  1283. };
  1284. /***/ }),
  1285. /* 46 */
  1286. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  1287. var DESCRIPTORS = __w_pdfjs_require__(6);
  1288. var fails = __w_pdfjs_require__(7);
  1289. module.exports = DESCRIPTORS && fails(function () {
  1290. return Object.defineProperty(function () {
  1291. }, 'prototype', {
  1292. value: 42,
  1293. writable: false
  1294. }).prototype !== 42;
  1295. });
  1296. /***/ }),
  1297. /* 47 */
  1298. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  1299. var isObject = __w_pdfjs_require__(20);
  1300. var $String = String;
  1301. var $TypeError = TypeError;
  1302. module.exports = function (argument) {
  1303. if (isObject(argument))
  1304. return argument;
  1305. throw $TypeError($String(argument) + ' is not an object');
  1306. };
  1307. /***/ }),
  1308. /* 48 */
  1309. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  1310. var isCallable = __w_pdfjs_require__(21);
  1311. var definePropertyModule = __w_pdfjs_require__(45);
  1312. var makeBuiltIn = __w_pdfjs_require__(49);
  1313. var defineGlobalProperty = __w_pdfjs_require__(38);
  1314. module.exports = function (O, key, value, options) {
  1315. if (!options)
  1316. options = {};
  1317. var simple = options.enumerable;
  1318. var name = options.name !== undefined ? options.name : key;
  1319. if (isCallable(value))
  1320. makeBuiltIn(value, name, options);
  1321. if (options.global) {
  1322. if (simple)
  1323. O[key] = value;
  1324. else
  1325. defineGlobalProperty(key, value);
  1326. } else {
  1327. try {
  1328. if (!options.unsafe)
  1329. delete O[key];
  1330. else if (O[key])
  1331. simple = true;
  1332. } catch (error) {
  1333. }
  1334. if (simple)
  1335. O[key] = value;
  1336. else
  1337. definePropertyModule.f(O, key, {
  1338. value: value,
  1339. enumerable: false,
  1340. configurable: !options.nonConfigurable,
  1341. writable: !options.nonWritable
  1342. });
  1343. }
  1344. return O;
  1345. };
  1346. /***/ }),
  1347. /* 49 */
  1348. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  1349. var uncurryThis = __w_pdfjs_require__(14);
  1350. var fails = __w_pdfjs_require__(7);
  1351. var isCallable = __w_pdfjs_require__(21);
  1352. var hasOwn = __w_pdfjs_require__(39);
  1353. var DESCRIPTORS = __w_pdfjs_require__(6);
  1354. var CONFIGURABLE_FUNCTION_NAME = (__w_pdfjs_require__(50).CONFIGURABLE);
  1355. var inspectSource = __w_pdfjs_require__(51);
  1356. var InternalStateModule = __w_pdfjs_require__(52);
  1357. var enforceInternalState = InternalStateModule.enforce;
  1358. var getInternalState = InternalStateModule.get;
  1359. var $String = String;
  1360. var defineProperty = Object.defineProperty;
  1361. var stringSlice = uncurryThis(''.slice);
  1362. var replace = uncurryThis(''.replace);
  1363. var join = uncurryThis([].join);
  1364. var CONFIGURABLE_LENGTH = DESCRIPTORS && !fails(function () {
  1365. return defineProperty(function () {
  1366. }, 'length', { value: 8 }).length !== 8;
  1367. });
  1368. var TEMPLATE = String(String).split('String');
  1369. var makeBuiltIn = module.exports = function (value, name, options) {
  1370. if (stringSlice($String(name), 0, 7) === 'Symbol(') {
  1371. name = '[' + replace($String(name), /^Symbol\(([^)]*)\)/, '$1') + ']';
  1372. }
  1373. if (options && options.getter)
  1374. name = 'get ' + name;
  1375. if (options && options.setter)
  1376. name = 'set ' + name;
  1377. if (!hasOwn(value, 'name') || CONFIGURABLE_FUNCTION_NAME && value.name !== name) {
  1378. if (DESCRIPTORS)
  1379. defineProperty(value, 'name', {
  1380. value: name,
  1381. configurable: true
  1382. });
  1383. else
  1384. value.name = name;
  1385. }
  1386. if (CONFIGURABLE_LENGTH && options && hasOwn(options, 'arity') && value.length !== options.arity) {
  1387. defineProperty(value, 'length', { value: options.arity });
  1388. }
  1389. try {
  1390. if (options && hasOwn(options, 'constructor') && options.constructor) {
  1391. if (DESCRIPTORS)
  1392. defineProperty(value, 'prototype', { writable: false });
  1393. } else if (value.prototype)
  1394. value.prototype = undefined;
  1395. } catch (error) {
  1396. }
  1397. var state = enforceInternalState(value);
  1398. if (!hasOwn(state, 'source')) {
  1399. state.source = join(TEMPLATE, typeof name == 'string' ? name : '');
  1400. }
  1401. return value;
  1402. };
  1403. Function.prototype.toString = makeBuiltIn(function toString() {
  1404. return isCallable(this) && getInternalState(this).source || inspectSource(this);
  1405. }, 'toString');
  1406. /***/ }),
  1407. /* 50 */
  1408. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  1409. var DESCRIPTORS = __w_pdfjs_require__(6);
  1410. var hasOwn = __w_pdfjs_require__(39);
  1411. var FunctionPrototype = Function.prototype;
  1412. var getDescriptor = DESCRIPTORS && Object.getOwnPropertyDescriptor;
  1413. var EXISTS = hasOwn(FunctionPrototype, 'name');
  1414. var PROPER = EXISTS && function something() {
  1415. }.name === 'something';
  1416. var CONFIGURABLE = EXISTS && (!DESCRIPTORS || DESCRIPTORS && getDescriptor(FunctionPrototype, 'name').configurable);
  1417. module.exports = {
  1418. EXISTS: EXISTS,
  1419. PROPER: PROPER,
  1420. CONFIGURABLE: CONFIGURABLE
  1421. };
  1422. /***/ }),
  1423. /* 51 */
  1424. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  1425. var uncurryThis = __w_pdfjs_require__(14);
  1426. var isCallable = __w_pdfjs_require__(21);
  1427. var store = __w_pdfjs_require__(37);
  1428. var functionToString = uncurryThis(Function.toString);
  1429. if (!isCallable(store.inspectSource)) {
  1430. store.inspectSource = function (it) {
  1431. return functionToString(it);
  1432. };
  1433. }
  1434. module.exports = store.inspectSource;
  1435. /***/ }),
  1436. /* 52 */
  1437. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  1438. var NATIVE_WEAK_MAP = __w_pdfjs_require__(53);
  1439. var global = __w_pdfjs_require__(4);
  1440. var isObject = __w_pdfjs_require__(20);
  1441. var createNonEnumerableProperty = __w_pdfjs_require__(44);
  1442. var hasOwn = __w_pdfjs_require__(39);
  1443. var shared = __w_pdfjs_require__(37);
  1444. var sharedKey = __w_pdfjs_require__(54);
  1445. var hiddenKeys = __w_pdfjs_require__(55);
  1446. var OBJECT_ALREADY_INITIALIZED = 'Object already initialized';
  1447. var TypeError = global.TypeError;
  1448. var WeakMap = global.WeakMap;
  1449. var set, get, has;
  1450. var enforce = function (it) {
  1451. return has(it) ? get(it) : set(it, {});
  1452. };
  1453. var getterFor = function (TYPE) {
  1454. return function (it) {
  1455. var state;
  1456. if (!isObject(it) || (state = get(it)).type !== TYPE) {
  1457. throw TypeError('Incompatible receiver, ' + TYPE + ' required');
  1458. }
  1459. return state;
  1460. };
  1461. };
  1462. if (NATIVE_WEAK_MAP || shared.state) {
  1463. var store = shared.state || (shared.state = new WeakMap());
  1464. store.get = store.get;
  1465. store.has = store.has;
  1466. store.set = store.set;
  1467. set = function (it, metadata) {
  1468. if (store.has(it))
  1469. throw TypeError(OBJECT_ALREADY_INITIALIZED);
  1470. metadata.facade = it;
  1471. store.set(it, metadata);
  1472. return metadata;
  1473. };
  1474. get = function (it) {
  1475. return store.get(it) || {};
  1476. };
  1477. has = function (it) {
  1478. return store.has(it);
  1479. };
  1480. } else {
  1481. var STATE = sharedKey('state');
  1482. hiddenKeys[STATE] = true;
  1483. set = function (it, metadata) {
  1484. if (hasOwn(it, STATE))
  1485. throw TypeError(OBJECT_ALREADY_INITIALIZED);
  1486. metadata.facade = it;
  1487. createNonEnumerableProperty(it, STATE, metadata);
  1488. return metadata;
  1489. };
  1490. get = function (it) {
  1491. return hasOwn(it, STATE) ? it[STATE] : {};
  1492. };
  1493. has = function (it) {
  1494. return hasOwn(it, STATE);
  1495. };
  1496. }
  1497. module.exports = {
  1498. set: set,
  1499. get: get,
  1500. has: has,
  1501. enforce: enforce,
  1502. getterFor: getterFor
  1503. };
  1504. /***/ }),
  1505. /* 53 */
  1506. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  1507. var global = __w_pdfjs_require__(4);
  1508. var isCallable = __w_pdfjs_require__(21);
  1509. var WeakMap = global.WeakMap;
  1510. module.exports = isCallable(WeakMap) && /native code/.test(String(WeakMap));
  1511. /***/ }),
  1512. /* 54 */
  1513. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  1514. var shared = __w_pdfjs_require__(35);
  1515. var uid = __w_pdfjs_require__(41);
  1516. var keys = shared('keys');
  1517. module.exports = function (key) {
  1518. return keys[key] || (keys[key] = uid(key));
  1519. };
  1520. /***/ }),
  1521. /* 55 */
  1522. /***/ ((module) => {
  1523. module.exports = {};
  1524. /***/ }),
  1525. /* 56 */
  1526. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  1527. var hasOwn = __w_pdfjs_require__(39);
  1528. var ownKeys = __w_pdfjs_require__(57);
  1529. var getOwnPropertyDescriptorModule = __w_pdfjs_require__(5);
  1530. var definePropertyModule = __w_pdfjs_require__(45);
  1531. module.exports = function (target, source, exceptions) {
  1532. var keys = ownKeys(source);
  1533. var defineProperty = definePropertyModule.f;
  1534. var getOwnPropertyDescriptor = getOwnPropertyDescriptorModule.f;
  1535. for (var i = 0; i < keys.length; i++) {
  1536. var key = keys[i];
  1537. if (!hasOwn(target, key) && !(exceptions && hasOwn(exceptions, key))) {
  1538. defineProperty(target, key, getOwnPropertyDescriptor(source, key));
  1539. }
  1540. }
  1541. };
  1542. /***/ }),
  1543. /* 57 */
  1544. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  1545. var getBuiltIn = __w_pdfjs_require__(24);
  1546. var uncurryThis = __w_pdfjs_require__(14);
  1547. var getOwnPropertyNamesModule = __w_pdfjs_require__(58);
  1548. var getOwnPropertySymbolsModule = __w_pdfjs_require__(67);
  1549. var anObject = __w_pdfjs_require__(47);
  1550. var concat = uncurryThis([].concat);
  1551. module.exports = getBuiltIn('Reflect', 'ownKeys') || function ownKeys(it) {
  1552. var keys = getOwnPropertyNamesModule.f(anObject(it));
  1553. var getOwnPropertySymbols = getOwnPropertySymbolsModule.f;
  1554. return getOwnPropertySymbols ? concat(keys, getOwnPropertySymbols(it)) : keys;
  1555. };
  1556. /***/ }),
  1557. /* 58 */
  1558. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  1559. var internalObjectKeys = __w_pdfjs_require__(59);
  1560. var enumBugKeys = __w_pdfjs_require__(66);
  1561. var hiddenKeys = enumBugKeys.concat('length', 'prototype');
  1562. exports.f = Object.getOwnPropertyNames || function getOwnPropertyNames(O) {
  1563. return internalObjectKeys(O, hiddenKeys);
  1564. };
  1565. /***/ }),
  1566. /* 59 */
  1567. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  1568. var uncurryThis = __w_pdfjs_require__(14);
  1569. var hasOwn = __w_pdfjs_require__(39);
  1570. var toIndexedObject = __w_pdfjs_require__(12);
  1571. var indexOf = (__w_pdfjs_require__(60).indexOf);
  1572. var hiddenKeys = __w_pdfjs_require__(55);
  1573. var push = uncurryThis([].push);
  1574. module.exports = function (object, names) {
  1575. var O = toIndexedObject(object);
  1576. var i = 0;
  1577. var result = [];
  1578. var key;
  1579. for (key in O)
  1580. !hasOwn(hiddenKeys, key) && hasOwn(O, key) && push(result, key);
  1581. while (names.length > i)
  1582. if (hasOwn(O, key = names[i++])) {
  1583. ~indexOf(result, key) || push(result, key);
  1584. }
  1585. return result;
  1586. };
  1587. /***/ }),
  1588. /* 60 */
  1589. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  1590. var toIndexedObject = __w_pdfjs_require__(12);
  1591. var toAbsoluteIndex = __w_pdfjs_require__(61);
  1592. var lengthOfArrayLike = __w_pdfjs_require__(64);
  1593. var createMethod = function (IS_INCLUDES) {
  1594. return function ($this, el, fromIndex) {
  1595. var O = toIndexedObject($this);
  1596. var length = lengthOfArrayLike(O);
  1597. var index = toAbsoluteIndex(fromIndex, length);
  1598. var value;
  1599. if (IS_INCLUDES && el !== el)
  1600. while (length > index) {
  1601. value = O[index++];
  1602. if (value !== value)
  1603. return true;
  1604. }
  1605. else
  1606. for (; length > index; index++) {
  1607. if ((IS_INCLUDES || index in O) && O[index] === el)
  1608. return IS_INCLUDES || index || 0;
  1609. }
  1610. return !IS_INCLUDES && -1;
  1611. };
  1612. };
  1613. module.exports = {
  1614. includes: createMethod(true),
  1615. indexOf: createMethod(false)
  1616. };
  1617. /***/ }),
  1618. /* 61 */
  1619. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  1620. var toIntegerOrInfinity = __w_pdfjs_require__(62);
  1621. var max = Math.max;
  1622. var min = Math.min;
  1623. module.exports = function (index, length) {
  1624. var integer = toIntegerOrInfinity(index);
  1625. return integer < 0 ? max(integer + length, 0) : min(integer, length);
  1626. };
  1627. /***/ }),
  1628. /* 62 */
  1629. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  1630. var trunc = __w_pdfjs_require__(63);
  1631. module.exports = function (argument) {
  1632. var number = +argument;
  1633. return number !== number || number === 0 ? 0 : trunc(number);
  1634. };
  1635. /***/ }),
  1636. /* 63 */
  1637. /***/ ((module) => {
  1638. var ceil = Math.ceil;
  1639. var floor = Math.floor;
  1640. module.exports = Math.trunc || function trunc(x) {
  1641. var n = +x;
  1642. return (n > 0 ? floor : ceil)(n);
  1643. };
  1644. /***/ }),
  1645. /* 64 */
  1646. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  1647. var toLength = __w_pdfjs_require__(65);
  1648. module.exports = function (obj) {
  1649. return toLength(obj.length);
  1650. };
  1651. /***/ }),
  1652. /* 65 */
  1653. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  1654. var toIntegerOrInfinity = __w_pdfjs_require__(62);
  1655. var min = Math.min;
  1656. module.exports = function (argument) {
  1657. return argument > 0 ? min(toIntegerOrInfinity(argument), 0x1FFFFFFFFFFFFF) : 0;
  1658. };
  1659. /***/ }),
  1660. /* 66 */
  1661. /***/ ((module) => {
  1662. module.exports = [
  1663. 'constructor',
  1664. 'hasOwnProperty',
  1665. 'isPrototypeOf',
  1666. 'propertyIsEnumerable',
  1667. 'toLocaleString',
  1668. 'toString',
  1669. 'valueOf'
  1670. ];
  1671. /***/ }),
  1672. /* 67 */
  1673. /***/ ((__unused_webpack_module, exports) => {
  1674. exports.f = Object.getOwnPropertySymbols;
  1675. /***/ }),
  1676. /* 68 */
  1677. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  1678. var fails = __w_pdfjs_require__(7);
  1679. var isCallable = __w_pdfjs_require__(21);
  1680. var replacement = /#|\.prototype\./;
  1681. var isForced = function (feature, detection) {
  1682. var value = data[normalize(feature)];
  1683. return value === POLYFILL ? true : value === NATIVE ? false : isCallable(detection) ? fails(detection) : !!detection;
  1684. };
  1685. var normalize = isForced.normalize = function (string) {
  1686. return String(string).replace(replacement, '.').toLowerCase();
  1687. };
  1688. var data = isForced.data = {};
  1689. var NATIVE = isForced.NATIVE = 'N';
  1690. var POLYFILL = isForced.POLYFILL = 'P';
  1691. module.exports = isForced;
  1692. /***/ }),
  1693. /* 69 */
  1694. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  1695. var NATIVE_BIND = __w_pdfjs_require__(9);
  1696. var FunctionPrototype = Function.prototype;
  1697. var apply = FunctionPrototype.apply;
  1698. var call = FunctionPrototype.call;
  1699. module.exports = typeof Reflect == 'object' && Reflect.apply || (NATIVE_BIND ? call.bind(apply) : function () {
  1700. return call.apply(apply, arguments);
  1701. });
  1702. /***/ }),
  1703. /* 70 */
  1704. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  1705. var getBuiltIn = __w_pdfjs_require__(24);
  1706. var hasOwn = __w_pdfjs_require__(39);
  1707. var createNonEnumerableProperty = __w_pdfjs_require__(44);
  1708. var isPrototypeOf = __w_pdfjs_require__(25);
  1709. var setPrototypeOf = __w_pdfjs_require__(71);
  1710. var copyConstructorProperties = __w_pdfjs_require__(56);
  1711. var proxyAccessor = __w_pdfjs_require__(74);
  1712. var inheritIfRequired = __w_pdfjs_require__(75);
  1713. var normalizeStringArgument = __w_pdfjs_require__(76);
  1714. var installErrorCause = __w_pdfjs_require__(80);
  1715. var installErrorStack = __w_pdfjs_require__(81);
  1716. var DESCRIPTORS = __w_pdfjs_require__(6);
  1717. var IS_PURE = __w_pdfjs_require__(36);
  1718. module.exports = function (FULL_NAME, wrapper, FORCED, IS_AGGREGATE_ERROR) {
  1719. var STACK_TRACE_LIMIT = 'stackTraceLimit';
  1720. var OPTIONS_POSITION = IS_AGGREGATE_ERROR ? 2 : 1;
  1721. var path = FULL_NAME.split('.');
  1722. var ERROR_NAME = path[path.length - 1];
  1723. var OriginalError = getBuiltIn.apply(null, path);
  1724. if (!OriginalError)
  1725. return;
  1726. var OriginalErrorPrototype = OriginalError.prototype;
  1727. if (!IS_PURE && hasOwn(OriginalErrorPrototype, 'cause'))
  1728. delete OriginalErrorPrototype.cause;
  1729. if (!FORCED)
  1730. return OriginalError;
  1731. var BaseError = getBuiltIn('Error');
  1732. var WrappedError = wrapper(function (a, b) {
  1733. var message = normalizeStringArgument(IS_AGGREGATE_ERROR ? b : a, undefined);
  1734. var result = IS_AGGREGATE_ERROR ? new OriginalError(a) : new OriginalError();
  1735. if (message !== undefined)
  1736. createNonEnumerableProperty(result, 'message', message);
  1737. installErrorStack(result, WrappedError, result.stack, 2);
  1738. if (this && isPrototypeOf(OriginalErrorPrototype, this))
  1739. inheritIfRequired(result, this, WrappedError);
  1740. if (arguments.length > OPTIONS_POSITION)
  1741. installErrorCause(result, arguments[OPTIONS_POSITION]);
  1742. return result;
  1743. });
  1744. WrappedError.prototype = OriginalErrorPrototype;
  1745. if (ERROR_NAME !== 'Error') {
  1746. if (setPrototypeOf)
  1747. setPrototypeOf(WrappedError, BaseError);
  1748. else
  1749. copyConstructorProperties(WrappedError, BaseError, { name: true });
  1750. } else if (DESCRIPTORS && STACK_TRACE_LIMIT in OriginalError) {
  1751. proxyAccessor(WrappedError, OriginalError, STACK_TRACE_LIMIT);
  1752. proxyAccessor(WrappedError, OriginalError, 'prepareStackTrace');
  1753. }
  1754. copyConstructorProperties(WrappedError, OriginalError);
  1755. if (!IS_PURE)
  1756. try {
  1757. if (OriginalErrorPrototype.name !== ERROR_NAME) {
  1758. createNonEnumerableProperty(OriginalErrorPrototype, 'name', ERROR_NAME);
  1759. }
  1760. OriginalErrorPrototype.constructor = WrappedError;
  1761. } catch (error) {
  1762. }
  1763. return WrappedError;
  1764. };
  1765. /***/ }),
  1766. /* 71 */
  1767. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  1768. var uncurryThisAccessor = __w_pdfjs_require__(72);
  1769. var anObject = __w_pdfjs_require__(47);
  1770. var aPossiblePrototype = __w_pdfjs_require__(73);
  1771. module.exports = Object.setPrototypeOf || ('__proto__' in {} ? (function () {
  1772. var CORRECT_SETTER = false;
  1773. var test = {};
  1774. var setter;
  1775. try {
  1776. setter = uncurryThisAccessor(Object.prototype, '__proto__', 'set');
  1777. setter(test, []);
  1778. CORRECT_SETTER = test instanceof Array;
  1779. } catch (error) {
  1780. }
  1781. return function setPrototypeOf(O, proto) {
  1782. anObject(O);
  1783. aPossiblePrototype(proto);
  1784. if (CORRECT_SETTER)
  1785. setter(O, proto);
  1786. else
  1787. O.__proto__ = proto;
  1788. return O;
  1789. };
  1790. }()) : undefined);
  1791. /***/ }),
  1792. /* 72 */
  1793. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  1794. var uncurryThis = __w_pdfjs_require__(14);
  1795. var aCallable = __w_pdfjs_require__(31);
  1796. module.exports = function (object, key, method) {
  1797. try {
  1798. return uncurryThis(aCallable(Object.getOwnPropertyDescriptor(object, key)[method]));
  1799. } catch (error) {
  1800. }
  1801. };
  1802. /***/ }),
  1803. /* 73 */
  1804. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  1805. var isCallable = __w_pdfjs_require__(21);
  1806. var $String = String;
  1807. var $TypeError = TypeError;
  1808. module.exports = function (argument) {
  1809. if (typeof argument == 'object' || isCallable(argument))
  1810. return argument;
  1811. throw $TypeError("Can't set " + $String(argument) + ' as a prototype');
  1812. };
  1813. /***/ }),
  1814. /* 74 */
  1815. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  1816. var defineProperty = (__w_pdfjs_require__(45).f);
  1817. module.exports = function (Target, Source, key) {
  1818. key in Target || defineProperty(Target, key, {
  1819. configurable: true,
  1820. get: function () {
  1821. return Source[key];
  1822. },
  1823. set: function (it) {
  1824. Source[key] = it;
  1825. }
  1826. });
  1827. };
  1828. /***/ }),
  1829. /* 75 */
  1830. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  1831. var isCallable = __w_pdfjs_require__(21);
  1832. var isObject = __w_pdfjs_require__(20);
  1833. var setPrototypeOf = __w_pdfjs_require__(71);
  1834. module.exports = function ($this, dummy, Wrapper) {
  1835. var NewTarget, NewTargetPrototype;
  1836. if (setPrototypeOf && isCallable(NewTarget = dummy.constructor) && NewTarget !== Wrapper && isObject(NewTargetPrototype = NewTarget.prototype) && NewTargetPrototype !== Wrapper.prototype)
  1837. setPrototypeOf($this, NewTargetPrototype);
  1838. return $this;
  1839. };
  1840. /***/ }),
  1841. /* 76 */
  1842. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  1843. var toString = __w_pdfjs_require__(77);
  1844. module.exports = function (argument, $default) {
  1845. return argument === undefined ? arguments.length < 2 ? '' : $default : toString(argument);
  1846. };
  1847. /***/ }),
  1848. /* 77 */
  1849. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  1850. var classof = __w_pdfjs_require__(78);
  1851. var $String = String;
  1852. module.exports = function (argument) {
  1853. if (classof(argument) === 'Symbol')
  1854. throw TypeError('Cannot convert a Symbol value to a string');
  1855. return $String(argument);
  1856. };
  1857. /***/ }),
  1858. /* 78 */
  1859. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  1860. var TO_STRING_TAG_SUPPORT = __w_pdfjs_require__(79);
  1861. var isCallable = __w_pdfjs_require__(21);
  1862. var classofRaw = __w_pdfjs_require__(15);
  1863. var wellKnownSymbol = __w_pdfjs_require__(34);
  1864. var TO_STRING_TAG = wellKnownSymbol('toStringTag');
  1865. var $Object = Object;
  1866. var CORRECT_ARGUMENTS = classofRaw((function () {
  1867. return arguments;
  1868. }())) === 'Arguments';
  1869. var tryGet = function (it, key) {
  1870. try {
  1871. return it[key];
  1872. } catch (error) {
  1873. }
  1874. };
  1875. module.exports = TO_STRING_TAG_SUPPORT ? classofRaw : function (it) {
  1876. var O, tag, result;
  1877. return it === undefined ? 'Undefined' : it === null ? 'Null' : typeof (tag = tryGet(O = $Object(it), TO_STRING_TAG)) == 'string' ? tag : CORRECT_ARGUMENTS ? classofRaw(O) : (result = classofRaw(O)) === 'Object' && isCallable(O.callee) ? 'Arguments' : result;
  1878. };
  1879. /***/ }),
  1880. /* 79 */
  1881. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  1882. var wellKnownSymbol = __w_pdfjs_require__(34);
  1883. var TO_STRING_TAG = wellKnownSymbol('toStringTag');
  1884. var test = {};
  1885. test[TO_STRING_TAG] = 'z';
  1886. module.exports = String(test) === '[object z]';
  1887. /***/ }),
  1888. /* 80 */
  1889. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  1890. var isObject = __w_pdfjs_require__(20);
  1891. var createNonEnumerableProperty = __w_pdfjs_require__(44);
  1892. module.exports = function (O, options) {
  1893. if (isObject(options) && 'cause' in options) {
  1894. createNonEnumerableProperty(O, 'cause', options.cause);
  1895. }
  1896. };
  1897. /***/ }),
  1898. /* 81 */
  1899. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  1900. var createNonEnumerableProperty = __w_pdfjs_require__(44);
  1901. var clearErrorStack = __w_pdfjs_require__(82);
  1902. var ERROR_STACK_INSTALLABLE = __w_pdfjs_require__(83);
  1903. var captureStackTrace = Error.captureStackTrace;
  1904. module.exports = function (error, C, stack, dropEntries) {
  1905. if (ERROR_STACK_INSTALLABLE) {
  1906. if (captureStackTrace)
  1907. captureStackTrace(error, C);
  1908. else
  1909. createNonEnumerableProperty(error, 'stack', clearErrorStack(stack, dropEntries));
  1910. }
  1911. };
  1912. /***/ }),
  1913. /* 82 */
  1914. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  1915. var uncurryThis = __w_pdfjs_require__(14);
  1916. var $Error = Error;
  1917. var replace = uncurryThis(''.replace);
  1918. var TEST = function (arg) {
  1919. return String($Error(arg).stack);
  1920. }('zxcasd');
  1921. var V8_OR_CHAKRA_STACK_ENTRY = /\n\s*at [^:]*:[^\n]*/;
  1922. var IS_V8_OR_CHAKRA_STACK = V8_OR_CHAKRA_STACK_ENTRY.test(TEST);
  1923. module.exports = function (stack, dropEntries) {
  1924. if (IS_V8_OR_CHAKRA_STACK && typeof stack == 'string' && !$Error.prepareStackTrace) {
  1925. while (dropEntries--)
  1926. stack = replace(stack, V8_OR_CHAKRA_STACK_ENTRY, '');
  1927. }
  1928. return stack;
  1929. };
  1930. /***/ }),
  1931. /* 83 */
  1932. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  1933. var fails = __w_pdfjs_require__(7);
  1934. var createPropertyDescriptor = __w_pdfjs_require__(11);
  1935. module.exports = !fails(function () {
  1936. var error = Error('a');
  1937. if (!('stack' in error))
  1938. return true;
  1939. Object.defineProperty(error, 'stack', createPropertyDescriptor(1, 7));
  1940. return error.stack !== 7;
  1941. });
  1942. /***/ }),
  1943. /* 84 */
  1944. /***/ ((__unused_webpack_module, __unused_webpack_exports, __w_pdfjs_require__) => {
  1945. var ArrayBufferViewCore = __w_pdfjs_require__(85);
  1946. var $findLast = (__w_pdfjs_require__(90).findLast);
  1947. var aTypedArray = ArrayBufferViewCore.aTypedArray;
  1948. var exportTypedArrayMethod = ArrayBufferViewCore.exportTypedArrayMethod;
  1949. exportTypedArrayMethod('findLast', function findLast(predicate) {
  1950. return $findLast(aTypedArray(this), predicate, arguments.length > 1 ? arguments[1] : undefined);
  1951. });
  1952. /***/ }),
  1953. /* 85 */
  1954. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  1955. var NATIVE_ARRAY_BUFFER = __w_pdfjs_require__(86);
  1956. var DESCRIPTORS = __w_pdfjs_require__(6);
  1957. var global = __w_pdfjs_require__(4);
  1958. var isCallable = __w_pdfjs_require__(21);
  1959. var isObject = __w_pdfjs_require__(20);
  1960. var hasOwn = __w_pdfjs_require__(39);
  1961. var classof = __w_pdfjs_require__(78);
  1962. var tryToString = __w_pdfjs_require__(32);
  1963. var createNonEnumerableProperty = __w_pdfjs_require__(44);
  1964. var defineBuiltIn = __w_pdfjs_require__(48);
  1965. var defineBuiltInAccessor = __w_pdfjs_require__(87);
  1966. var isPrototypeOf = __w_pdfjs_require__(25);
  1967. var getPrototypeOf = __w_pdfjs_require__(88);
  1968. var setPrototypeOf = __w_pdfjs_require__(71);
  1969. var wellKnownSymbol = __w_pdfjs_require__(34);
  1970. var uid = __w_pdfjs_require__(41);
  1971. var InternalStateModule = __w_pdfjs_require__(52);
  1972. var enforceInternalState = InternalStateModule.enforce;
  1973. var getInternalState = InternalStateModule.get;
  1974. var Int8Array = global.Int8Array;
  1975. var Int8ArrayPrototype = Int8Array && Int8Array.prototype;
  1976. var Uint8ClampedArray = global.Uint8ClampedArray;
  1977. var Uint8ClampedArrayPrototype = Uint8ClampedArray && Uint8ClampedArray.prototype;
  1978. var TypedArray = Int8Array && getPrototypeOf(Int8Array);
  1979. var TypedArrayPrototype = Int8ArrayPrototype && getPrototypeOf(Int8ArrayPrototype);
  1980. var ObjectPrototype = Object.prototype;
  1981. var TypeError = global.TypeError;
  1982. var TO_STRING_TAG = wellKnownSymbol('toStringTag');
  1983. var TYPED_ARRAY_TAG = uid('TYPED_ARRAY_TAG');
  1984. var TYPED_ARRAY_CONSTRUCTOR = 'TypedArrayConstructor';
  1985. var NATIVE_ARRAY_BUFFER_VIEWS = NATIVE_ARRAY_BUFFER && !!setPrototypeOf && classof(global.opera) !== 'Opera';
  1986. var TYPED_ARRAY_TAG_REQUIRED = false;
  1987. var NAME, Constructor, Prototype;
  1988. var TypedArrayConstructorsList = {
  1989. Int8Array: 1,
  1990. Uint8Array: 1,
  1991. Uint8ClampedArray: 1,
  1992. Int16Array: 2,
  1993. Uint16Array: 2,
  1994. Int32Array: 4,
  1995. Uint32Array: 4,
  1996. Float32Array: 4,
  1997. Float64Array: 8
  1998. };
  1999. var BigIntArrayConstructorsList = {
  2000. BigInt64Array: 8,
  2001. BigUint64Array: 8
  2002. };
  2003. var isView = function isView(it) {
  2004. if (!isObject(it))
  2005. return false;
  2006. var klass = classof(it);
  2007. return klass === 'DataView' || hasOwn(TypedArrayConstructorsList, klass) || hasOwn(BigIntArrayConstructorsList, klass);
  2008. };
  2009. var getTypedArrayConstructor = function (it) {
  2010. var proto = getPrototypeOf(it);
  2011. if (!isObject(proto))
  2012. return;
  2013. var state = getInternalState(proto);
  2014. return state && hasOwn(state, TYPED_ARRAY_CONSTRUCTOR) ? state[TYPED_ARRAY_CONSTRUCTOR] : getTypedArrayConstructor(proto);
  2015. };
  2016. var isTypedArray = function (it) {
  2017. if (!isObject(it))
  2018. return false;
  2019. var klass = classof(it);
  2020. return hasOwn(TypedArrayConstructorsList, klass) || hasOwn(BigIntArrayConstructorsList, klass);
  2021. };
  2022. var aTypedArray = function (it) {
  2023. if (isTypedArray(it))
  2024. return it;
  2025. throw TypeError('Target is not a typed array');
  2026. };
  2027. var aTypedArrayConstructor = function (C) {
  2028. if (isCallable(C) && (!setPrototypeOf || isPrototypeOf(TypedArray, C)))
  2029. return C;
  2030. throw TypeError(tryToString(C) + ' is not a typed array constructor');
  2031. };
  2032. var exportTypedArrayMethod = function (KEY, property, forced, options) {
  2033. if (!DESCRIPTORS)
  2034. return;
  2035. if (forced)
  2036. for (var ARRAY in TypedArrayConstructorsList) {
  2037. var TypedArrayConstructor = global[ARRAY];
  2038. if (TypedArrayConstructor && hasOwn(TypedArrayConstructor.prototype, KEY))
  2039. try {
  2040. delete TypedArrayConstructor.prototype[KEY];
  2041. } catch (error) {
  2042. try {
  2043. TypedArrayConstructor.prototype[KEY] = property;
  2044. } catch (error2) {
  2045. }
  2046. }
  2047. }
  2048. if (!TypedArrayPrototype[KEY] || forced) {
  2049. defineBuiltIn(TypedArrayPrototype, KEY, forced ? property : NATIVE_ARRAY_BUFFER_VIEWS && Int8ArrayPrototype[KEY] || property, options);
  2050. }
  2051. };
  2052. var exportTypedArrayStaticMethod = function (KEY, property, forced) {
  2053. var ARRAY, TypedArrayConstructor;
  2054. if (!DESCRIPTORS)
  2055. return;
  2056. if (setPrototypeOf) {
  2057. if (forced)
  2058. for (ARRAY in TypedArrayConstructorsList) {
  2059. TypedArrayConstructor = global[ARRAY];
  2060. if (TypedArrayConstructor && hasOwn(TypedArrayConstructor, KEY))
  2061. try {
  2062. delete TypedArrayConstructor[KEY];
  2063. } catch (error) {
  2064. }
  2065. }
  2066. if (!TypedArray[KEY] || forced) {
  2067. try {
  2068. return defineBuiltIn(TypedArray, KEY, forced ? property : NATIVE_ARRAY_BUFFER_VIEWS && TypedArray[KEY] || property);
  2069. } catch (error) {
  2070. }
  2071. } else
  2072. return;
  2073. }
  2074. for (ARRAY in TypedArrayConstructorsList) {
  2075. TypedArrayConstructor = global[ARRAY];
  2076. if (TypedArrayConstructor && (!TypedArrayConstructor[KEY] || forced)) {
  2077. defineBuiltIn(TypedArrayConstructor, KEY, property);
  2078. }
  2079. }
  2080. };
  2081. for (NAME in TypedArrayConstructorsList) {
  2082. Constructor = global[NAME];
  2083. Prototype = Constructor && Constructor.prototype;
  2084. if (Prototype)
  2085. enforceInternalState(Prototype)[TYPED_ARRAY_CONSTRUCTOR] = Constructor;
  2086. else
  2087. NATIVE_ARRAY_BUFFER_VIEWS = false;
  2088. }
  2089. for (NAME in BigIntArrayConstructorsList) {
  2090. Constructor = global[NAME];
  2091. Prototype = Constructor && Constructor.prototype;
  2092. if (Prototype)
  2093. enforceInternalState(Prototype)[TYPED_ARRAY_CONSTRUCTOR] = Constructor;
  2094. }
  2095. if (!NATIVE_ARRAY_BUFFER_VIEWS || !isCallable(TypedArray) || TypedArray === Function.prototype) {
  2096. TypedArray = function TypedArray() {
  2097. throw TypeError('Incorrect invocation');
  2098. };
  2099. if (NATIVE_ARRAY_BUFFER_VIEWS)
  2100. for (NAME in TypedArrayConstructorsList) {
  2101. if (global[NAME])
  2102. setPrototypeOf(global[NAME], TypedArray);
  2103. }
  2104. }
  2105. if (!NATIVE_ARRAY_BUFFER_VIEWS || !TypedArrayPrototype || TypedArrayPrototype === ObjectPrototype) {
  2106. TypedArrayPrototype = TypedArray.prototype;
  2107. if (NATIVE_ARRAY_BUFFER_VIEWS)
  2108. for (NAME in TypedArrayConstructorsList) {
  2109. if (global[NAME])
  2110. setPrototypeOf(global[NAME].prototype, TypedArrayPrototype);
  2111. }
  2112. }
  2113. if (NATIVE_ARRAY_BUFFER_VIEWS && getPrototypeOf(Uint8ClampedArrayPrototype) !== TypedArrayPrototype) {
  2114. setPrototypeOf(Uint8ClampedArrayPrototype, TypedArrayPrototype);
  2115. }
  2116. if (DESCRIPTORS && !hasOwn(TypedArrayPrototype, TO_STRING_TAG)) {
  2117. TYPED_ARRAY_TAG_REQUIRED = true;
  2118. defineBuiltInAccessor(TypedArrayPrototype, TO_STRING_TAG, {
  2119. configurable: true,
  2120. get: function () {
  2121. return isObject(this) ? this[TYPED_ARRAY_TAG] : undefined;
  2122. }
  2123. });
  2124. for (NAME in TypedArrayConstructorsList)
  2125. if (global[NAME]) {
  2126. createNonEnumerableProperty(global[NAME], TYPED_ARRAY_TAG, NAME);
  2127. }
  2128. }
  2129. module.exports = {
  2130. NATIVE_ARRAY_BUFFER_VIEWS: NATIVE_ARRAY_BUFFER_VIEWS,
  2131. TYPED_ARRAY_TAG: TYPED_ARRAY_TAG_REQUIRED && TYPED_ARRAY_TAG,
  2132. aTypedArray: aTypedArray,
  2133. aTypedArrayConstructor: aTypedArrayConstructor,
  2134. exportTypedArrayMethod: exportTypedArrayMethod,
  2135. exportTypedArrayStaticMethod: exportTypedArrayStaticMethod,
  2136. getTypedArrayConstructor: getTypedArrayConstructor,
  2137. isView: isView,
  2138. isTypedArray: isTypedArray,
  2139. TypedArray: TypedArray,
  2140. TypedArrayPrototype: TypedArrayPrototype
  2141. };
  2142. /***/ }),
  2143. /* 86 */
  2144. /***/ ((module) => {
  2145. module.exports = typeof ArrayBuffer != 'undefined' && typeof DataView != 'undefined';
  2146. /***/ }),
  2147. /* 87 */
  2148. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  2149. var makeBuiltIn = __w_pdfjs_require__(49);
  2150. var defineProperty = __w_pdfjs_require__(45);
  2151. module.exports = function (target, name, descriptor) {
  2152. if (descriptor.get)
  2153. makeBuiltIn(descriptor.get, name, { getter: true });
  2154. if (descriptor.set)
  2155. makeBuiltIn(descriptor.set, name, { setter: true });
  2156. return defineProperty.f(target, name, descriptor);
  2157. };
  2158. /***/ }),
  2159. /* 88 */
  2160. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  2161. var hasOwn = __w_pdfjs_require__(39);
  2162. var isCallable = __w_pdfjs_require__(21);
  2163. var toObject = __w_pdfjs_require__(40);
  2164. var sharedKey = __w_pdfjs_require__(54);
  2165. var CORRECT_PROTOTYPE_GETTER = __w_pdfjs_require__(89);
  2166. var IE_PROTO = sharedKey('IE_PROTO');
  2167. var $Object = Object;
  2168. var ObjectPrototype = $Object.prototype;
  2169. module.exports = CORRECT_PROTOTYPE_GETTER ? $Object.getPrototypeOf : function (O) {
  2170. var object = toObject(O);
  2171. if (hasOwn(object, IE_PROTO))
  2172. return object[IE_PROTO];
  2173. var constructor = object.constructor;
  2174. if (isCallable(constructor) && object instanceof constructor) {
  2175. return constructor.prototype;
  2176. }
  2177. return object instanceof $Object ? ObjectPrototype : null;
  2178. };
  2179. /***/ }),
  2180. /* 89 */
  2181. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  2182. var fails = __w_pdfjs_require__(7);
  2183. module.exports = !fails(function () {
  2184. function F() {
  2185. }
  2186. F.prototype.constructor = null;
  2187. return Object.getPrototypeOf(new F()) !== F.prototype;
  2188. });
  2189. /***/ }),
  2190. /* 90 */
  2191. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  2192. var bind = __w_pdfjs_require__(91);
  2193. var IndexedObject = __w_pdfjs_require__(13);
  2194. var toObject = __w_pdfjs_require__(40);
  2195. var lengthOfArrayLike = __w_pdfjs_require__(64);
  2196. var createMethod = function (TYPE) {
  2197. var IS_FIND_LAST_INDEX = TYPE === 1;
  2198. return function ($this, callbackfn, that) {
  2199. var O = toObject($this);
  2200. var self = IndexedObject(O);
  2201. var boundFunction = bind(callbackfn, that);
  2202. var index = lengthOfArrayLike(self);
  2203. var value, result;
  2204. while (index-- > 0) {
  2205. value = self[index];
  2206. result = boundFunction(value, index, O);
  2207. if (result)
  2208. switch (TYPE) {
  2209. case 0:
  2210. return value;
  2211. case 1:
  2212. return index;
  2213. }
  2214. }
  2215. return IS_FIND_LAST_INDEX ? -1 : undefined;
  2216. };
  2217. };
  2218. module.exports = {
  2219. findLast: createMethod(0),
  2220. findLastIndex: createMethod(1)
  2221. };
  2222. /***/ }),
  2223. /* 91 */
  2224. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  2225. var uncurryThis = __w_pdfjs_require__(92);
  2226. var aCallable = __w_pdfjs_require__(31);
  2227. var NATIVE_BIND = __w_pdfjs_require__(9);
  2228. var bind = uncurryThis(uncurryThis.bind);
  2229. module.exports = function (fn, that) {
  2230. aCallable(fn);
  2231. return that === undefined ? fn : NATIVE_BIND ? bind(fn, that) : function () {
  2232. return fn.apply(that, arguments);
  2233. };
  2234. };
  2235. /***/ }),
  2236. /* 92 */
  2237. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  2238. var classofRaw = __w_pdfjs_require__(15);
  2239. var uncurryThis = __w_pdfjs_require__(14);
  2240. module.exports = function (fn) {
  2241. if (classofRaw(fn) === 'Function')
  2242. return uncurryThis(fn);
  2243. };
  2244. /***/ }),
  2245. /* 93 */
  2246. /***/ ((__unused_webpack_module, __unused_webpack_exports, __w_pdfjs_require__) => {
  2247. var ArrayBufferViewCore = __w_pdfjs_require__(85);
  2248. var $findLastIndex = (__w_pdfjs_require__(90).findLastIndex);
  2249. var aTypedArray = ArrayBufferViewCore.aTypedArray;
  2250. var exportTypedArrayMethod = ArrayBufferViewCore.exportTypedArrayMethod;
  2251. exportTypedArrayMethod('findLastIndex', function findLastIndex(predicate) {
  2252. return $findLastIndex(aTypedArray(this), predicate, arguments.length > 1 ? arguments[1] : undefined);
  2253. });
  2254. /***/ }),
  2255. /* 94 */
  2256. /***/ ((__unused_webpack_module, __unused_webpack_exports, __w_pdfjs_require__) => {
  2257. var global = __w_pdfjs_require__(4);
  2258. var call = __w_pdfjs_require__(8);
  2259. var ArrayBufferViewCore = __w_pdfjs_require__(85);
  2260. var lengthOfArrayLike = __w_pdfjs_require__(64);
  2261. var toOffset = __w_pdfjs_require__(95);
  2262. var toIndexedObject = __w_pdfjs_require__(40);
  2263. var fails = __w_pdfjs_require__(7);
  2264. var RangeError = global.RangeError;
  2265. var Int8Array = global.Int8Array;
  2266. var Int8ArrayPrototype = Int8Array && Int8Array.prototype;
  2267. var $set = Int8ArrayPrototype && Int8ArrayPrototype.set;
  2268. var aTypedArray = ArrayBufferViewCore.aTypedArray;
  2269. var exportTypedArrayMethod = ArrayBufferViewCore.exportTypedArrayMethod;
  2270. var WORKS_WITH_OBJECTS_AND_GENERIC_ON_TYPED_ARRAYS = !fails(function () {
  2271. var array = new Uint8ClampedArray(2);
  2272. call($set, array, {
  2273. length: 1,
  2274. 0: 3
  2275. }, 1);
  2276. return array[1] !== 3;
  2277. });
  2278. var TO_OBJECT_BUG = WORKS_WITH_OBJECTS_AND_GENERIC_ON_TYPED_ARRAYS && ArrayBufferViewCore.NATIVE_ARRAY_BUFFER_VIEWS && fails(function () {
  2279. var array = new Int8Array(2);
  2280. array.set(1);
  2281. array.set('2', 1);
  2282. return array[0] !== 0 || array[1] !== 2;
  2283. });
  2284. exportTypedArrayMethod('set', function set(arrayLike) {
  2285. aTypedArray(this);
  2286. var offset = toOffset(arguments.length > 1 ? arguments[1] : undefined, 1);
  2287. var src = toIndexedObject(arrayLike);
  2288. if (WORKS_WITH_OBJECTS_AND_GENERIC_ON_TYPED_ARRAYS)
  2289. return call($set, this, src, offset);
  2290. var length = this.length;
  2291. var len = lengthOfArrayLike(src);
  2292. var index = 0;
  2293. if (len + offset > length)
  2294. throw RangeError('Wrong length');
  2295. while (index < len)
  2296. this[offset + index] = src[index++];
  2297. }, !WORKS_WITH_OBJECTS_AND_GENERIC_ON_TYPED_ARRAYS || TO_OBJECT_BUG);
  2298. /***/ }),
  2299. /* 95 */
  2300. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  2301. var toPositiveInteger = __w_pdfjs_require__(96);
  2302. var $RangeError = RangeError;
  2303. module.exports = function (it, BYTES) {
  2304. var offset = toPositiveInteger(it);
  2305. if (offset % BYTES)
  2306. throw $RangeError('Wrong offset');
  2307. return offset;
  2308. };
  2309. /***/ }),
  2310. /* 96 */
  2311. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  2312. var toIntegerOrInfinity = __w_pdfjs_require__(62);
  2313. var $RangeError = RangeError;
  2314. module.exports = function (it) {
  2315. var result = toIntegerOrInfinity(it);
  2316. if (result < 0)
  2317. throw $RangeError("The argument can't be less than 0");
  2318. return result;
  2319. };
  2320. /***/ }),
  2321. /* 97 */
  2322. /***/ ((__unused_webpack_module, __unused_webpack_exports, __w_pdfjs_require__) => {
  2323. var arrayToReversed = __w_pdfjs_require__(98);
  2324. var ArrayBufferViewCore = __w_pdfjs_require__(85);
  2325. var aTypedArray = ArrayBufferViewCore.aTypedArray;
  2326. var exportTypedArrayMethod = ArrayBufferViewCore.exportTypedArrayMethod;
  2327. var getTypedArrayConstructor = ArrayBufferViewCore.getTypedArrayConstructor;
  2328. exportTypedArrayMethod('toReversed', function toReversed() {
  2329. return arrayToReversed(aTypedArray(this), getTypedArrayConstructor(this));
  2330. });
  2331. /***/ }),
  2332. /* 98 */
  2333. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  2334. var lengthOfArrayLike = __w_pdfjs_require__(64);
  2335. module.exports = function (O, C) {
  2336. var len = lengthOfArrayLike(O);
  2337. var A = new C(len);
  2338. var k = 0;
  2339. for (; k < len; k++)
  2340. A[k] = O[len - k - 1];
  2341. return A;
  2342. };
  2343. /***/ }),
  2344. /* 99 */
  2345. /***/ ((__unused_webpack_module, __unused_webpack_exports, __w_pdfjs_require__) => {
  2346. var ArrayBufferViewCore = __w_pdfjs_require__(85);
  2347. var uncurryThis = __w_pdfjs_require__(14);
  2348. var aCallable = __w_pdfjs_require__(31);
  2349. var arrayFromConstructorAndList = __w_pdfjs_require__(100);
  2350. var aTypedArray = ArrayBufferViewCore.aTypedArray;
  2351. var getTypedArrayConstructor = ArrayBufferViewCore.getTypedArrayConstructor;
  2352. var exportTypedArrayMethod = ArrayBufferViewCore.exportTypedArrayMethod;
  2353. var sort = uncurryThis(ArrayBufferViewCore.TypedArrayPrototype.sort);
  2354. exportTypedArrayMethod('toSorted', function toSorted(compareFn) {
  2355. if (compareFn !== undefined)
  2356. aCallable(compareFn);
  2357. var O = aTypedArray(this);
  2358. var A = arrayFromConstructorAndList(getTypedArrayConstructor(O), O);
  2359. return sort(A, compareFn);
  2360. });
  2361. /***/ }),
  2362. /* 100 */
  2363. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  2364. var lengthOfArrayLike = __w_pdfjs_require__(64);
  2365. module.exports = function (Constructor, list) {
  2366. var index = 0;
  2367. var length = lengthOfArrayLike(list);
  2368. var result = new Constructor(length);
  2369. while (length > index)
  2370. result[index] = list[index++];
  2371. return result;
  2372. };
  2373. /***/ }),
  2374. /* 101 */
  2375. /***/ ((__unused_webpack_module, __unused_webpack_exports, __w_pdfjs_require__) => {
  2376. var arrayWith = __w_pdfjs_require__(102);
  2377. var ArrayBufferViewCore = __w_pdfjs_require__(85);
  2378. var isBigIntArray = __w_pdfjs_require__(103);
  2379. var toIntegerOrInfinity = __w_pdfjs_require__(62);
  2380. var toBigInt = __w_pdfjs_require__(104);
  2381. var aTypedArray = ArrayBufferViewCore.aTypedArray;
  2382. var getTypedArrayConstructor = ArrayBufferViewCore.getTypedArrayConstructor;
  2383. var exportTypedArrayMethod = ArrayBufferViewCore.exportTypedArrayMethod;
  2384. var PROPER_ORDER = !!(function () {
  2385. try {
  2386. new Int8Array(1)['with'](2, {
  2387. valueOf: function () {
  2388. throw 8;
  2389. }
  2390. });
  2391. } catch (error) {
  2392. return error === 8;
  2393. }
  2394. }());
  2395. exportTypedArrayMethod('with', {
  2396. 'with': function (index, value) {
  2397. var O = aTypedArray(this);
  2398. var relativeIndex = toIntegerOrInfinity(index);
  2399. var actualValue = isBigIntArray(O) ? toBigInt(value) : +value;
  2400. return arrayWith(O, getTypedArrayConstructor(O), relativeIndex, actualValue);
  2401. }
  2402. }['with'], !PROPER_ORDER);
  2403. /***/ }),
  2404. /* 102 */
  2405. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  2406. var lengthOfArrayLike = __w_pdfjs_require__(64);
  2407. var toIntegerOrInfinity = __w_pdfjs_require__(62);
  2408. var $RangeError = RangeError;
  2409. module.exports = function (O, C, index, value) {
  2410. var len = lengthOfArrayLike(O);
  2411. var relativeIndex = toIntegerOrInfinity(index);
  2412. var actualIndex = relativeIndex < 0 ? len + relativeIndex : relativeIndex;
  2413. if (actualIndex >= len || actualIndex < 0)
  2414. throw $RangeError('Incorrect index');
  2415. var A = new C(len);
  2416. var k = 0;
  2417. for (; k < len; k++)
  2418. A[k] = k === actualIndex ? value : O[k];
  2419. return A;
  2420. };
  2421. /***/ }),
  2422. /* 103 */
  2423. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  2424. var classof = __w_pdfjs_require__(78);
  2425. module.exports = function (it) {
  2426. var klass = classof(it);
  2427. return klass === 'BigInt64Array' || klass === 'BigUint64Array';
  2428. };
  2429. /***/ }),
  2430. /* 104 */
  2431. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  2432. var toPrimitive = __w_pdfjs_require__(19);
  2433. var $TypeError = TypeError;
  2434. module.exports = function (argument) {
  2435. var prim = toPrimitive(argument, 'number');
  2436. if (typeof prim == 'number')
  2437. throw $TypeError("Can't convert number to bigint");
  2438. return BigInt(prim);
  2439. };
  2440. /***/ }),
  2441. /* 105 */
  2442. /***/ ((__unused_webpack_module, __unused_webpack_exports, __w_pdfjs_require__) => {
  2443. var DESCRIPTORS = __w_pdfjs_require__(6);
  2444. var defineBuiltInAccessor = __w_pdfjs_require__(87);
  2445. var isDetached = __w_pdfjs_require__(106);
  2446. var ArrayBufferPrototype = ArrayBuffer.prototype;
  2447. if (DESCRIPTORS && !('detached' in ArrayBufferPrototype)) {
  2448. defineBuiltInAccessor(ArrayBufferPrototype, 'detached', {
  2449. configurable: true,
  2450. get: function detached() {
  2451. return isDetached(this);
  2452. }
  2453. });
  2454. }
  2455. /***/ }),
  2456. /* 106 */
  2457. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  2458. var uncurryThis = __w_pdfjs_require__(14);
  2459. var arrayBufferByteLength = __w_pdfjs_require__(107);
  2460. var slice = uncurryThis(ArrayBuffer.prototype.slice);
  2461. module.exports = function (O) {
  2462. if (arrayBufferByteLength(O) !== 0)
  2463. return false;
  2464. try {
  2465. slice(O, 0, 0);
  2466. return false;
  2467. } catch (error) {
  2468. return true;
  2469. }
  2470. };
  2471. /***/ }),
  2472. /* 107 */
  2473. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  2474. var uncurryThisAccessor = __w_pdfjs_require__(72);
  2475. var classof = __w_pdfjs_require__(15);
  2476. var $TypeError = TypeError;
  2477. module.exports = uncurryThisAccessor(ArrayBuffer.prototype, 'byteLength', 'get') || function (O) {
  2478. if (classof(O) !== 'ArrayBuffer')
  2479. throw $TypeError('ArrayBuffer expected');
  2480. return O.byteLength;
  2481. };
  2482. /***/ }),
  2483. /* 108 */
  2484. /***/ ((__unused_webpack_module, __unused_webpack_exports, __w_pdfjs_require__) => {
  2485. var $ = __w_pdfjs_require__(3);
  2486. var $transfer = __w_pdfjs_require__(109);
  2487. if ($transfer)
  2488. $({
  2489. target: 'ArrayBuffer',
  2490. proto: true
  2491. }, {
  2492. transfer: function transfer() {
  2493. return $transfer(this, arguments.length ? arguments[0] : undefined, true);
  2494. }
  2495. });
  2496. /***/ }),
  2497. /* 109 */
  2498. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  2499. var global = __w_pdfjs_require__(4);
  2500. var uncurryThis = __w_pdfjs_require__(14);
  2501. var uncurryThisAccessor = __w_pdfjs_require__(72);
  2502. var toIndex = __w_pdfjs_require__(110);
  2503. var isDetached = __w_pdfjs_require__(106);
  2504. var arrayBufferByteLength = __w_pdfjs_require__(107);
  2505. var PROPER_TRANSFER = __w_pdfjs_require__(111);
  2506. var TypeError = global.TypeError;
  2507. var structuredClone = global.structuredClone;
  2508. var ArrayBuffer = global.ArrayBuffer;
  2509. var DataView = global.DataView;
  2510. var min = Math.min;
  2511. var ArrayBufferPrototype = ArrayBuffer.prototype;
  2512. var DataViewPrototype = DataView.prototype;
  2513. var slice = uncurryThis(ArrayBufferPrototype.slice);
  2514. var isResizable = uncurryThisAccessor(ArrayBufferPrototype, 'resizable', 'get');
  2515. var maxByteLength = uncurryThisAccessor(ArrayBufferPrototype, 'maxByteLength', 'get');
  2516. var getInt8 = uncurryThis(DataViewPrototype.getInt8);
  2517. var setInt8 = uncurryThis(DataViewPrototype.setInt8);
  2518. module.exports = PROPER_TRANSFER && function (arrayBuffer, newLength, preserveResizability) {
  2519. var byteLength = arrayBufferByteLength(arrayBuffer);
  2520. var newByteLength = newLength === undefined ? byteLength : toIndex(newLength);
  2521. var fixedLength = !isResizable || !isResizable(arrayBuffer);
  2522. if (isDetached(arrayBuffer))
  2523. throw TypeError('ArrayBuffer is detached');
  2524. var newBuffer = structuredClone(arrayBuffer, { transfer: [arrayBuffer] });
  2525. if (byteLength === newByteLength && (preserveResizability || fixedLength))
  2526. return newBuffer;
  2527. if (byteLength >= newByteLength && (!preserveResizability || fixedLength))
  2528. return slice(newBuffer, 0, newByteLength);
  2529. var options = preserveResizability && !fixedLength && maxByteLength ? { maxByteLength: maxByteLength(newBuffer) } : undefined;
  2530. var newNewBuffer = new ArrayBuffer(newByteLength, options);
  2531. var a = new DataView(newBuffer);
  2532. var b = new DataView(newNewBuffer);
  2533. var copyLength = min(newByteLength, byteLength);
  2534. for (var i = 0; i < copyLength; i++)
  2535. setInt8(b, i, getInt8(a, i));
  2536. return newNewBuffer;
  2537. };
  2538. /***/ }),
  2539. /* 110 */
  2540. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  2541. var toIntegerOrInfinity = __w_pdfjs_require__(62);
  2542. var toLength = __w_pdfjs_require__(65);
  2543. var $RangeError = RangeError;
  2544. module.exports = function (it) {
  2545. if (it === undefined)
  2546. return 0;
  2547. var number = toIntegerOrInfinity(it);
  2548. var length = toLength(number);
  2549. if (number !== length)
  2550. throw $RangeError('Wrong length or index');
  2551. return length;
  2552. };
  2553. /***/ }),
  2554. /* 111 */
  2555. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  2556. var global = __w_pdfjs_require__(4);
  2557. var fails = __w_pdfjs_require__(7);
  2558. var V8 = __w_pdfjs_require__(28);
  2559. var IS_BROWSER = __w_pdfjs_require__(112);
  2560. var IS_DENO = __w_pdfjs_require__(113);
  2561. var IS_NODE = __w_pdfjs_require__(114);
  2562. var structuredClone = global.structuredClone;
  2563. module.exports = !!structuredClone && !fails(function () {
  2564. if (IS_DENO && V8 > 92 || IS_NODE && V8 > 94 || IS_BROWSER && V8 > 97)
  2565. return false;
  2566. var buffer = new ArrayBuffer(8);
  2567. var clone = structuredClone(buffer, { transfer: [buffer] });
  2568. return buffer.byteLength !== 0 || clone.byteLength !== 8;
  2569. });
  2570. /***/ }),
  2571. /* 112 */
  2572. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  2573. var IS_DENO = __w_pdfjs_require__(113);
  2574. var IS_NODE = __w_pdfjs_require__(114);
  2575. module.exports = !IS_DENO && !IS_NODE && typeof window == 'object' && typeof document == 'object';
  2576. /***/ }),
  2577. /* 113 */
  2578. /***/ ((module) => {
  2579. module.exports = typeof Deno == 'object' && Deno && typeof Deno.version == 'object';
  2580. /***/ }),
  2581. /* 114 */
  2582. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  2583. var global = __w_pdfjs_require__(4);
  2584. var classof = __w_pdfjs_require__(15);
  2585. module.exports = classof(global.process) === 'process';
  2586. /***/ }),
  2587. /* 115 */
  2588. /***/ ((__unused_webpack_module, __unused_webpack_exports, __w_pdfjs_require__) => {
  2589. var $ = __w_pdfjs_require__(3);
  2590. var $transfer = __w_pdfjs_require__(109);
  2591. if ($transfer)
  2592. $({
  2593. target: 'ArrayBuffer',
  2594. proto: true
  2595. }, {
  2596. transferToFixedLength: function transferToFixedLength() {
  2597. return $transfer(this, arguments.length ? arguments[0] : undefined, false);
  2598. }
  2599. });
  2600. /***/ }),
  2601. /* 116 */
  2602. /***/ ((__unused_webpack_module, __unused_webpack_exports, __w_pdfjs_require__) => {
  2603. var $ = __w_pdfjs_require__(3);
  2604. var difference = __w_pdfjs_require__(117);
  2605. var setMethodAcceptSetLike = __w_pdfjs_require__(126);
  2606. $({
  2607. target: 'Set',
  2608. proto: true,
  2609. real: true,
  2610. forced: !setMethodAcceptSetLike('difference')
  2611. }, { difference: difference });
  2612. /***/ }),
  2613. /* 117 */
  2614. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  2615. var aSet = __w_pdfjs_require__(118);
  2616. var SetHelpers = __w_pdfjs_require__(119);
  2617. var clone = __w_pdfjs_require__(120);
  2618. var size = __w_pdfjs_require__(123);
  2619. var getSetRecord = __w_pdfjs_require__(124);
  2620. var iterateSet = __w_pdfjs_require__(121);
  2621. var iterateSimple = __w_pdfjs_require__(122);
  2622. var has = SetHelpers.has;
  2623. var remove = SetHelpers.remove;
  2624. module.exports = function difference(other) {
  2625. var O = aSet(this);
  2626. var otherRec = getSetRecord(other);
  2627. var result = clone(O);
  2628. if (size(O) <= otherRec.size)
  2629. iterateSet(O, function (e) {
  2630. if (otherRec.includes(e))
  2631. remove(result, e);
  2632. });
  2633. else
  2634. iterateSimple(otherRec.getIterator(), function (e) {
  2635. if (has(O, e))
  2636. remove(result, e);
  2637. });
  2638. return result;
  2639. };
  2640. /***/ }),
  2641. /* 118 */
  2642. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  2643. var has = (__w_pdfjs_require__(119).has);
  2644. module.exports = function (it) {
  2645. has(it);
  2646. return it;
  2647. };
  2648. /***/ }),
  2649. /* 119 */
  2650. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  2651. var uncurryThis = __w_pdfjs_require__(14);
  2652. var SetPrototype = Set.prototype;
  2653. module.exports = {
  2654. Set: Set,
  2655. add: uncurryThis(SetPrototype.add),
  2656. has: uncurryThis(SetPrototype.has),
  2657. remove: uncurryThis(SetPrototype['delete']),
  2658. proto: SetPrototype
  2659. };
  2660. /***/ }),
  2661. /* 120 */
  2662. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  2663. var SetHelpers = __w_pdfjs_require__(119);
  2664. var iterate = __w_pdfjs_require__(121);
  2665. var Set = SetHelpers.Set;
  2666. var add = SetHelpers.add;
  2667. module.exports = function (set) {
  2668. var result = new Set();
  2669. iterate(set, function (it) {
  2670. add(result, it);
  2671. });
  2672. return result;
  2673. };
  2674. /***/ }),
  2675. /* 121 */
  2676. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  2677. var uncurryThis = __w_pdfjs_require__(14);
  2678. var iterateSimple = __w_pdfjs_require__(122);
  2679. var SetHelpers = __w_pdfjs_require__(119);
  2680. var Set = SetHelpers.Set;
  2681. var SetPrototype = SetHelpers.proto;
  2682. var forEach = uncurryThis(SetPrototype.forEach);
  2683. var keys = uncurryThis(SetPrototype.keys);
  2684. var next = keys(new Set()).next;
  2685. module.exports = function (set, fn, interruptible) {
  2686. return interruptible ? iterateSimple({
  2687. iterator: keys(set),
  2688. next: next
  2689. }, fn) : forEach(set, fn);
  2690. };
  2691. /***/ }),
  2692. /* 122 */
  2693. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  2694. var call = __w_pdfjs_require__(8);
  2695. module.exports = function (record, fn, ITERATOR_INSTEAD_OF_RECORD) {
  2696. var iterator = ITERATOR_INSTEAD_OF_RECORD ? record : record.iterator;
  2697. var next = record.next;
  2698. var step, result;
  2699. while (!(step = call(next, iterator)).done) {
  2700. result = fn(step.value);
  2701. if (result !== undefined)
  2702. return result;
  2703. }
  2704. };
  2705. /***/ }),
  2706. /* 123 */
  2707. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  2708. var uncurryThisAccessor = __w_pdfjs_require__(72);
  2709. var SetHelpers = __w_pdfjs_require__(119);
  2710. module.exports = uncurryThisAccessor(SetHelpers.proto, 'size', 'get') || function (set) {
  2711. return set.size;
  2712. };
  2713. /***/ }),
  2714. /* 124 */
  2715. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  2716. var aCallable = __w_pdfjs_require__(31);
  2717. var anObject = __w_pdfjs_require__(47);
  2718. var call = __w_pdfjs_require__(8);
  2719. var toIntegerOrInfinity = __w_pdfjs_require__(62);
  2720. var getIteratorDirect = __w_pdfjs_require__(125);
  2721. var INVALID_SIZE = 'Invalid size';
  2722. var $RangeError = RangeError;
  2723. var $TypeError = TypeError;
  2724. var max = Math.max;
  2725. var SetRecord = function (set, size, has, keys) {
  2726. this.set = set;
  2727. this.size = size;
  2728. this.has = has;
  2729. this.keys = keys;
  2730. };
  2731. SetRecord.prototype = {
  2732. getIterator: function () {
  2733. return getIteratorDirect(anObject(call(this.keys, this.set)));
  2734. },
  2735. includes: function (it) {
  2736. return call(this.has, this.set, it);
  2737. }
  2738. };
  2739. module.exports = function (obj) {
  2740. anObject(obj);
  2741. var numSize = +obj.size;
  2742. if (numSize !== numSize)
  2743. throw $TypeError(INVALID_SIZE);
  2744. var intSize = toIntegerOrInfinity(numSize);
  2745. if (intSize < 0)
  2746. throw $RangeError(INVALID_SIZE);
  2747. return new SetRecord(obj, max(intSize, 0), aCallable(obj.has), aCallable(obj.keys));
  2748. };
  2749. /***/ }),
  2750. /* 125 */
  2751. /***/ ((module) => {
  2752. module.exports = function (obj) {
  2753. return {
  2754. iterator: obj,
  2755. next: obj.next,
  2756. done: false
  2757. };
  2758. };
  2759. /***/ }),
  2760. /* 126 */
  2761. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  2762. var getBuiltIn = __w_pdfjs_require__(24);
  2763. var createSetLike = function (size) {
  2764. return {
  2765. size: size,
  2766. has: function () {
  2767. return false;
  2768. },
  2769. keys: function () {
  2770. return {
  2771. next: function () {
  2772. return { done: true };
  2773. }
  2774. };
  2775. }
  2776. };
  2777. };
  2778. module.exports = function (name) {
  2779. var Set = getBuiltIn('Set');
  2780. try {
  2781. new Set()[name](createSetLike(0));
  2782. try {
  2783. new Set()[name](createSetLike(-1));
  2784. return false;
  2785. } catch (error2) {
  2786. return true;
  2787. }
  2788. } catch (error) {
  2789. return false;
  2790. }
  2791. };
  2792. /***/ }),
  2793. /* 127 */
  2794. /***/ ((__unused_webpack_module, __unused_webpack_exports, __w_pdfjs_require__) => {
  2795. var $ = __w_pdfjs_require__(3);
  2796. var fails = __w_pdfjs_require__(7);
  2797. var intersection = __w_pdfjs_require__(128);
  2798. var setMethodAcceptSetLike = __w_pdfjs_require__(126);
  2799. var INCORRECT = !setMethodAcceptSetLike('intersection') || fails(function () {
  2800. return Array.from(new Set([
  2801. 1,
  2802. 2,
  2803. 3
  2804. ]).intersection(new Set([
  2805. 3,
  2806. 2
  2807. ]))) !== '3,2';
  2808. });
  2809. $({
  2810. target: 'Set',
  2811. proto: true,
  2812. real: true,
  2813. forced: INCORRECT
  2814. }, { intersection: intersection });
  2815. /***/ }),
  2816. /* 128 */
  2817. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  2818. var aSet = __w_pdfjs_require__(118);
  2819. var SetHelpers = __w_pdfjs_require__(119);
  2820. var size = __w_pdfjs_require__(123);
  2821. var getSetRecord = __w_pdfjs_require__(124);
  2822. var iterateSet = __w_pdfjs_require__(121);
  2823. var iterateSimple = __w_pdfjs_require__(122);
  2824. var Set = SetHelpers.Set;
  2825. var add = SetHelpers.add;
  2826. var has = SetHelpers.has;
  2827. module.exports = function intersection(other) {
  2828. var O = aSet(this);
  2829. var otherRec = getSetRecord(other);
  2830. var result = new Set();
  2831. if (size(O) > otherRec.size) {
  2832. iterateSimple(otherRec.getIterator(), function (e) {
  2833. if (has(O, e))
  2834. add(result, e);
  2835. });
  2836. } else {
  2837. iterateSet(O, function (e) {
  2838. if (otherRec.includes(e))
  2839. add(result, e);
  2840. });
  2841. }
  2842. return result;
  2843. };
  2844. /***/ }),
  2845. /* 129 */
  2846. /***/ ((__unused_webpack_module, __unused_webpack_exports, __w_pdfjs_require__) => {
  2847. var $ = __w_pdfjs_require__(3);
  2848. var isDisjointFrom = __w_pdfjs_require__(130);
  2849. var setMethodAcceptSetLike = __w_pdfjs_require__(126);
  2850. $({
  2851. target: 'Set',
  2852. proto: true,
  2853. real: true,
  2854. forced: !setMethodAcceptSetLike('isDisjointFrom')
  2855. }, { isDisjointFrom: isDisjointFrom });
  2856. /***/ }),
  2857. /* 130 */
  2858. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  2859. var aSet = __w_pdfjs_require__(118);
  2860. var has = (__w_pdfjs_require__(119).has);
  2861. var size = __w_pdfjs_require__(123);
  2862. var getSetRecord = __w_pdfjs_require__(124);
  2863. var iterateSet = __w_pdfjs_require__(121);
  2864. var iterateSimple = __w_pdfjs_require__(122);
  2865. var iteratorClose = __w_pdfjs_require__(131);
  2866. module.exports = function isDisjointFrom(other) {
  2867. var O = aSet(this);
  2868. var otherRec = getSetRecord(other);
  2869. if (size(O) <= otherRec.size)
  2870. return iterateSet(O, function (e) {
  2871. if (otherRec.includes(e))
  2872. return false;
  2873. }, true) !== false;
  2874. var iterator = otherRec.getIterator();
  2875. return iterateSimple(iterator, function (e) {
  2876. if (has(O, e))
  2877. return iteratorClose(iterator, 'normal', false);
  2878. }) !== false;
  2879. };
  2880. /***/ }),
  2881. /* 131 */
  2882. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  2883. var call = __w_pdfjs_require__(8);
  2884. var anObject = __w_pdfjs_require__(47);
  2885. var getMethod = __w_pdfjs_require__(30);
  2886. module.exports = function (iterator, kind, value) {
  2887. var innerResult, innerError;
  2888. anObject(iterator);
  2889. try {
  2890. innerResult = getMethod(iterator, 'return');
  2891. if (!innerResult) {
  2892. if (kind === 'throw')
  2893. throw value;
  2894. return value;
  2895. }
  2896. innerResult = call(innerResult, iterator);
  2897. } catch (error) {
  2898. innerError = true;
  2899. innerResult = error;
  2900. }
  2901. if (kind === 'throw')
  2902. throw value;
  2903. if (innerError)
  2904. throw innerResult;
  2905. anObject(innerResult);
  2906. return value;
  2907. };
  2908. /***/ }),
  2909. /* 132 */
  2910. /***/ ((__unused_webpack_module, __unused_webpack_exports, __w_pdfjs_require__) => {
  2911. var $ = __w_pdfjs_require__(3);
  2912. var isSubsetOf = __w_pdfjs_require__(133);
  2913. var setMethodAcceptSetLike = __w_pdfjs_require__(126);
  2914. $({
  2915. target: 'Set',
  2916. proto: true,
  2917. real: true,
  2918. forced: !setMethodAcceptSetLike('isSubsetOf')
  2919. }, { isSubsetOf: isSubsetOf });
  2920. /***/ }),
  2921. /* 133 */
  2922. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  2923. var aSet = __w_pdfjs_require__(118);
  2924. var size = __w_pdfjs_require__(123);
  2925. var iterate = __w_pdfjs_require__(121);
  2926. var getSetRecord = __w_pdfjs_require__(124);
  2927. module.exports = function isSubsetOf(other) {
  2928. var O = aSet(this);
  2929. var otherRec = getSetRecord(other);
  2930. if (size(O) > otherRec.size)
  2931. return false;
  2932. return iterate(O, function (e) {
  2933. if (!otherRec.includes(e))
  2934. return false;
  2935. }, true) !== false;
  2936. };
  2937. /***/ }),
  2938. /* 134 */
  2939. /***/ ((__unused_webpack_module, __unused_webpack_exports, __w_pdfjs_require__) => {
  2940. var $ = __w_pdfjs_require__(3);
  2941. var isSupersetOf = __w_pdfjs_require__(135);
  2942. var setMethodAcceptSetLike = __w_pdfjs_require__(126);
  2943. $({
  2944. target: 'Set',
  2945. proto: true,
  2946. real: true,
  2947. forced: !setMethodAcceptSetLike('isSupersetOf')
  2948. }, { isSupersetOf: isSupersetOf });
  2949. /***/ }),
  2950. /* 135 */
  2951. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  2952. var aSet = __w_pdfjs_require__(118);
  2953. var has = (__w_pdfjs_require__(119).has);
  2954. var size = __w_pdfjs_require__(123);
  2955. var getSetRecord = __w_pdfjs_require__(124);
  2956. var iterateSimple = __w_pdfjs_require__(122);
  2957. var iteratorClose = __w_pdfjs_require__(131);
  2958. module.exports = function isSupersetOf(other) {
  2959. var O = aSet(this);
  2960. var otherRec = getSetRecord(other);
  2961. if (size(O) < otherRec.size)
  2962. return false;
  2963. var iterator = otherRec.getIterator();
  2964. return iterateSimple(iterator, function (e) {
  2965. if (!has(O, e))
  2966. return iteratorClose(iterator, 'normal', false);
  2967. }) !== false;
  2968. };
  2969. /***/ }),
  2970. /* 136 */
  2971. /***/ ((__unused_webpack_module, __unused_webpack_exports, __w_pdfjs_require__) => {
  2972. var $ = __w_pdfjs_require__(3);
  2973. var symmetricDifference = __w_pdfjs_require__(137);
  2974. var setMethodAcceptSetLike = __w_pdfjs_require__(126);
  2975. $({
  2976. target: 'Set',
  2977. proto: true,
  2978. real: true,
  2979. forced: !setMethodAcceptSetLike('symmetricDifference')
  2980. }, { symmetricDifference: symmetricDifference });
  2981. /***/ }),
  2982. /* 137 */
  2983. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  2984. var aSet = __w_pdfjs_require__(118);
  2985. var SetHelpers = __w_pdfjs_require__(119);
  2986. var clone = __w_pdfjs_require__(120);
  2987. var getSetRecord = __w_pdfjs_require__(124);
  2988. var iterateSimple = __w_pdfjs_require__(122);
  2989. var add = SetHelpers.add;
  2990. var has = SetHelpers.has;
  2991. var remove = SetHelpers.remove;
  2992. module.exports = function symmetricDifference(other) {
  2993. var O = aSet(this);
  2994. var keysIter = getSetRecord(other).getIterator();
  2995. var result = clone(O);
  2996. iterateSimple(keysIter, function (e) {
  2997. if (has(O, e))
  2998. remove(result, e);
  2999. else
  3000. add(result, e);
  3001. });
  3002. return result;
  3003. };
  3004. /***/ }),
  3005. /* 138 */
  3006. /***/ ((__unused_webpack_module, __unused_webpack_exports, __w_pdfjs_require__) => {
  3007. var $ = __w_pdfjs_require__(3);
  3008. var union = __w_pdfjs_require__(139);
  3009. var setMethodAcceptSetLike = __w_pdfjs_require__(126);
  3010. $({
  3011. target: 'Set',
  3012. proto: true,
  3013. real: true,
  3014. forced: !setMethodAcceptSetLike('union')
  3015. }, { union: union });
  3016. /***/ }),
  3017. /* 139 */
  3018. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  3019. var aSet = __w_pdfjs_require__(118);
  3020. var add = (__w_pdfjs_require__(119).add);
  3021. var clone = __w_pdfjs_require__(120);
  3022. var getSetRecord = __w_pdfjs_require__(124);
  3023. var iterateSimple = __w_pdfjs_require__(122);
  3024. module.exports = function union(other) {
  3025. var O = aSet(this);
  3026. var keysIter = getSetRecord(other).getIterator();
  3027. var result = clone(O);
  3028. iterateSimple(keysIter, function (it) {
  3029. add(result, it);
  3030. });
  3031. return result;
  3032. };
  3033. /***/ }),
  3034. /* 140 */
  3035. /***/ ((__unused_webpack_module, __unused_webpack_exports, __w_pdfjs_require__) => {
  3036. var $ = __w_pdfjs_require__(3);
  3037. var toObject = __w_pdfjs_require__(40);
  3038. var lengthOfArrayLike = __w_pdfjs_require__(64);
  3039. var setArrayLength = __w_pdfjs_require__(141);
  3040. var doesNotExceedSafeInteger = __w_pdfjs_require__(143);
  3041. var fails = __w_pdfjs_require__(7);
  3042. var INCORRECT_TO_LENGTH = fails(function () {
  3043. return [].push.call({ length: 0x100000000 }, 1) !== 4294967297;
  3044. });
  3045. var properErrorOnNonWritableLength = function () {
  3046. try {
  3047. Object.defineProperty([], 'length', { writable: false }).push();
  3048. } catch (error) {
  3049. return error instanceof TypeError;
  3050. }
  3051. };
  3052. var FORCED = INCORRECT_TO_LENGTH || !properErrorOnNonWritableLength();
  3053. $({
  3054. target: 'Array',
  3055. proto: true,
  3056. arity: 1,
  3057. forced: FORCED
  3058. }, {
  3059. push: function push(item) {
  3060. var O = toObject(this);
  3061. var len = lengthOfArrayLike(O);
  3062. var argCount = arguments.length;
  3063. doesNotExceedSafeInteger(len + argCount);
  3064. for (var i = 0; i < argCount; i++) {
  3065. O[len] = arguments[i];
  3066. len++;
  3067. }
  3068. setArrayLength(O, len);
  3069. return len;
  3070. }
  3071. });
  3072. /***/ }),
  3073. /* 141 */
  3074. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  3075. var DESCRIPTORS = __w_pdfjs_require__(6);
  3076. var isArray = __w_pdfjs_require__(142);
  3077. var $TypeError = TypeError;
  3078. var getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
  3079. var SILENT_ON_NON_WRITABLE_LENGTH_SET = DESCRIPTORS && !(function () {
  3080. if (this !== undefined)
  3081. return true;
  3082. try {
  3083. Object.defineProperty([], 'length', { writable: false }).length = 1;
  3084. } catch (error) {
  3085. return error instanceof TypeError;
  3086. }
  3087. }());
  3088. module.exports = SILENT_ON_NON_WRITABLE_LENGTH_SET ? function (O, length) {
  3089. if (isArray(O) && !getOwnPropertyDescriptor(O, 'length').writable) {
  3090. throw $TypeError('Cannot set read only .length');
  3091. }
  3092. return O.length = length;
  3093. } : function (O, length) {
  3094. return O.length = length;
  3095. };
  3096. /***/ }),
  3097. /* 142 */
  3098. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  3099. var classof = __w_pdfjs_require__(15);
  3100. module.exports = Array.isArray || function isArray(argument) {
  3101. return classof(argument) === 'Array';
  3102. };
  3103. /***/ }),
  3104. /* 143 */
  3105. /***/ ((module) => {
  3106. var $TypeError = TypeError;
  3107. var MAX_SAFE_INTEGER = 0x1FFFFFFFFFFFFF;
  3108. module.exports = function (it) {
  3109. if (it > MAX_SAFE_INTEGER)
  3110. throw $TypeError('Maximum allowed index exceeded');
  3111. return it;
  3112. };
  3113. /***/ }),
  3114. /* 144 */
  3115. /***/ ((__unused_webpack_module, __unused_webpack_exports, __w_pdfjs_require__) => {
  3116. var $ = __w_pdfjs_require__(3);
  3117. var global = __w_pdfjs_require__(4);
  3118. var defineBuiltInAccessor = __w_pdfjs_require__(87);
  3119. var DESCRIPTORS = __w_pdfjs_require__(6);
  3120. var $TypeError = TypeError;
  3121. var defineProperty = Object.defineProperty;
  3122. var INCORRECT_VALUE = global.self !== global;
  3123. try {
  3124. if (DESCRIPTORS) {
  3125. var descriptor = Object.getOwnPropertyDescriptor(global, 'self');
  3126. if (INCORRECT_VALUE || !descriptor || !descriptor.get || !descriptor.enumerable) {
  3127. defineBuiltInAccessor(global, 'self', {
  3128. get: function self() {
  3129. return global;
  3130. },
  3131. set: function self(value) {
  3132. if (this !== global)
  3133. throw $TypeError('Illegal invocation');
  3134. defineProperty(global, 'self', {
  3135. value: value,
  3136. writable: true,
  3137. configurable: true,
  3138. enumerable: true
  3139. });
  3140. },
  3141. configurable: true,
  3142. enumerable: true
  3143. });
  3144. }
  3145. } else
  3146. $({
  3147. global: true,
  3148. simple: true,
  3149. forced: INCORRECT_VALUE
  3150. }, { self: global });
  3151. } catch (error) {
  3152. }
  3153. /***/ }),
  3154. /* 145 */
  3155. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  3156. Object.defineProperty(exports, "__esModule", ({
  3157. value: true
  3158. }));
  3159. 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;
  3160. exports.assert = assert;
  3161. exports.bytesToString = bytesToString;
  3162. exports.createValidAbsoluteUrl = createValidAbsoluteUrl;
  3163. exports.getModificationDate = getModificationDate;
  3164. exports.getUuid = getUuid;
  3165. exports.getVerbosityLevel = getVerbosityLevel;
  3166. exports.info = info;
  3167. exports.isArrayBuffer = isArrayBuffer;
  3168. exports.isArrayEqual = isArrayEqual;
  3169. exports.isNodeJS = void 0;
  3170. exports.normalizeUnicode = normalizeUnicode;
  3171. exports.objectFromMap = objectFromMap;
  3172. exports.objectSize = objectSize;
  3173. exports.setVerbosityLevel = setVerbosityLevel;
  3174. exports.shadow = shadow;
  3175. exports.string32 = string32;
  3176. exports.stringToBytes = stringToBytes;
  3177. exports.stringToPDFString = stringToPDFString;
  3178. exports.stringToUTF8String = stringToUTF8String;
  3179. exports.unreachable = unreachable;
  3180. exports.utf8StringToString = utf8StringToString;
  3181. exports.warn = warn;
  3182. __w_pdfjs_require__(2);
  3183. __w_pdfjs_require__(146);
  3184. __w_pdfjs_require__(148);
  3185. __w_pdfjs_require__(149);
  3186. __w_pdfjs_require__(140);
  3187. __w_pdfjs_require__(84);
  3188. __w_pdfjs_require__(93);
  3189. __w_pdfjs_require__(94);
  3190. __w_pdfjs_require__(97);
  3191. __w_pdfjs_require__(99);
  3192. __w_pdfjs_require__(101);
  3193. __w_pdfjs_require__(105);
  3194. __w_pdfjs_require__(108);
  3195. __w_pdfjs_require__(115);
  3196. const isNodeJS = typeof process === "object" && process + "" === "[object process]" && !process.versions.nw && !(process.versions.electron && process.type && process.type !== "browser");
  3197. exports.isNodeJS = isNodeJS;
  3198. const IDENTITY_MATRIX = [1, 0, 0, 1, 0, 0];
  3199. exports.IDENTITY_MATRIX = IDENTITY_MATRIX;
  3200. const FONT_IDENTITY_MATRIX = [0.001, 0, 0, 0.001, 0, 0];
  3201. exports.FONT_IDENTITY_MATRIX = FONT_IDENTITY_MATRIX;
  3202. const MAX_IMAGE_SIZE_TO_CACHE = 10e6;
  3203. exports.MAX_IMAGE_SIZE_TO_CACHE = MAX_IMAGE_SIZE_TO_CACHE;
  3204. const LINE_FACTOR = 1.35;
  3205. exports.LINE_FACTOR = LINE_FACTOR;
  3206. const LINE_DESCENT_FACTOR = 0.35;
  3207. exports.LINE_DESCENT_FACTOR = LINE_DESCENT_FACTOR;
  3208. const BASELINE_FACTOR = LINE_DESCENT_FACTOR / LINE_FACTOR;
  3209. exports.BASELINE_FACTOR = BASELINE_FACTOR;
  3210. const RenderingIntentFlag = {
  3211. ANY: 0x01,
  3212. DISPLAY: 0x02,
  3213. PRINT: 0x04,
  3214. SAVE: 0x08,
  3215. ANNOTATIONS_FORMS: 0x10,
  3216. ANNOTATIONS_STORAGE: 0x20,
  3217. ANNOTATIONS_DISABLE: 0x40,
  3218. OPLIST: 0x100
  3219. };
  3220. exports.RenderingIntentFlag = RenderingIntentFlag;
  3221. const AnnotationMode = {
  3222. DISABLE: 0,
  3223. ENABLE: 1,
  3224. ENABLE_FORMS: 2,
  3225. ENABLE_STORAGE: 3
  3226. };
  3227. exports.AnnotationMode = AnnotationMode;
  3228. const AnnotationEditorPrefix = "pdfjs_internal_editor_";
  3229. exports.AnnotationEditorPrefix = AnnotationEditorPrefix;
  3230. const AnnotationEditorType = {
  3231. DISABLE: -1,
  3232. NONE: 0,
  3233. FREETEXT: 3,
  3234. STAMP: 13,
  3235. INK: 15
  3236. };
  3237. exports.AnnotationEditorType = AnnotationEditorType;
  3238. const AnnotationEditorParamsType = {
  3239. RESIZE: 1,
  3240. CREATE: 2,
  3241. FREETEXT_SIZE: 11,
  3242. FREETEXT_COLOR: 12,
  3243. FREETEXT_OPACITY: 13,
  3244. INK_COLOR: 21,
  3245. INK_THICKNESS: 22,
  3246. INK_OPACITY: 23
  3247. };
  3248. exports.AnnotationEditorParamsType = AnnotationEditorParamsType;
  3249. const PermissionFlag = {
  3250. PRINT: 0x04,
  3251. MODIFY_CONTENTS: 0x08,
  3252. COPY: 0x10,
  3253. MODIFY_ANNOTATIONS: 0x20,
  3254. FILL_INTERACTIVE_FORMS: 0x100,
  3255. COPY_FOR_ACCESSIBILITY: 0x200,
  3256. ASSEMBLE: 0x400,
  3257. PRINT_HIGH_QUALITY: 0x800
  3258. };
  3259. exports.PermissionFlag = PermissionFlag;
  3260. const TextRenderingMode = {
  3261. FILL: 0,
  3262. STROKE: 1,
  3263. FILL_STROKE: 2,
  3264. INVISIBLE: 3,
  3265. FILL_ADD_TO_PATH: 4,
  3266. STROKE_ADD_TO_PATH: 5,
  3267. FILL_STROKE_ADD_TO_PATH: 6,
  3268. ADD_TO_PATH: 7,
  3269. FILL_STROKE_MASK: 3,
  3270. ADD_TO_PATH_FLAG: 4
  3271. };
  3272. exports.TextRenderingMode = TextRenderingMode;
  3273. const ImageKind = {
  3274. GRAYSCALE_1BPP: 1,
  3275. RGB_24BPP: 2,
  3276. RGBA_32BPP: 3
  3277. };
  3278. exports.ImageKind = ImageKind;
  3279. const AnnotationType = {
  3280. TEXT: 1,
  3281. LINK: 2,
  3282. FREETEXT: 3,
  3283. LINE: 4,
  3284. SQUARE: 5,
  3285. CIRCLE: 6,
  3286. POLYGON: 7,
  3287. POLYLINE: 8,
  3288. HIGHLIGHT: 9,
  3289. UNDERLINE: 10,
  3290. SQUIGGLY: 11,
  3291. STRIKEOUT: 12,
  3292. STAMP: 13,
  3293. CARET: 14,
  3294. INK: 15,
  3295. POPUP: 16,
  3296. FILEATTACHMENT: 17,
  3297. SOUND: 18,
  3298. MOVIE: 19,
  3299. WIDGET: 20,
  3300. SCREEN: 21,
  3301. PRINTERMARK: 22,
  3302. TRAPNET: 23,
  3303. WATERMARK: 24,
  3304. THREED: 25,
  3305. REDACT: 26
  3306. };
  3307. exports.AnnotationType = AnnotationType;
  3308. const AnnotationReplyType = {
  3309. GROUP: "Group",
  3310. REPLY: "R"
  3311. };
  3312. exports.AnnotationReplyType = AnnotationReplyType;
  3313. const AnnotationFlag = {
  3314. INVISIBLE: 0x01,
  3315. HIDDEN: 0x02,
  3316. PRINT: 0x04,
  3317. NOZOOM: 0x08,
  3318. NOROTATE: 0x10,
  3319. NOVIEW: 0x20,
  3320. READONLY: 0x40,
  3321. LOCKED: 0x80,
  3322. TOGGLENOVIEW: 0x100,
  3323. LOCKEDCONTENTS: 0x200
  3324. };
  3325. exports.AnnotationFlag = AnnotationFlag;
  3326. const AnnotationFieldFlag = {
  3327. READONLY: 0x0000001,
  3328. REQUIRED: 0x0000002,
  3329. NOEXPORT: 0x0000004,
  3330. MULTILINE: 0x0001000,
  3331. PASSWORD: 0x0002000,
  3332. NOTOGGLETOOFF: 0x0004000,
  3333. RADIO: 0x0008000,
  3334. PUSHBUTTON: 0x0010000,
  3335. COMBO: 0x0020000,
  3336. EDIT: 0x0040000,
  3337. SORT: 0x0080000,
  3338. FILESELECT: 0x0100000,
  3339. MULTISELECT: 0x0200000,
  3340. DONOTSPELLCHECK: 0x0400000,
  3341. DONOTSCROLL: 0x0800000,
  3342. COMB: 0x1000000,
  3343. RICHTEXT: 0x2000000,
  3344. RADIOSINUNISON: 0x2000000,
  3345. COMMITONSELCHANGE: 0x4000000
  3346. };
  3347. exports.AnnotationFieldFlag = AnnotationFieldFlag;
  3348. const AnnotationBorderStyleType = {
  3349. SOLID: 1,
  3350. DASHED: 2,
  3351. BEVELED: 3,
  3352. INSET: 4,
  3353. UNDERLINE: 5
  3354. };
  3355. exports.AnnotationBorderStyleType = AnnotationBorderStyleType;
  3356. const AnnotationActionEventType = {
  3357. E: "Mouse Enter",
  3358. X: "Mouse Exit",
  3359. D: "Mouse Down",
  3360. U: "Mouse Up",
  3361. Fo: "Focus",
  3362. Bl: "Blur",
  3363. PO: "PageOpen",
  3364. PC: "PageClose",
  3365. PV: "PageVisible",
  3366. PI: "PageInvisible",
  3367. K: "Keystroke",
  3368. F: "Format",
  3369. V: "Validate",
  3370. C: "Calculate"
  3371. };
  3372. exports.AnnotationActionEventType = AnnotationActionEventType;
  3373. const DocumentActionEventType = {
  3374. WC: "WillClose",
  3375. WS: "WillSave",
  3376. DS: "DidSave",
  3377. WP: "WillPrint",
  3378. DP: "DidPrint"
  3379. };
  3380. exports.DocumentActionEventType = DocumentActionEventType;
  3381. const PageActionEventType = {
  3382. O: "PageOpen",
  3383. C: "PageClose"
  3384. };
  3385. exports.PageActionEventType = PageActionEventType;
  3386. const VerbosityLevel = {
  3387. ERRORS: 0,
  3388. WARNINGS: 1,
  3389. INFOS: 5
  3390. };
  3391. exports.VerbosityLevel = VerbosityLevel;
  3392. const CMapCompressionType = {
  3393. NONE: 0,
  3394. BINARY: 1
  3395. };
  3396. exports.CMapCompressionType = CMapCompressionType;
  3397. const OPS = {
  3398. dependency: 1,
  3399. setLineWidth: 2,
  3400. setLineCap: 3,
  3401. setLineJoin: 4,
  3402. setMiterLimit: 5,
  3403. setDash: 6,
  3404. setRenderingIntent: 7,
  3405. setFlatness: 8,
  3406. setGState: 9,
  3407. save: 10,
  3408. restore: 11,
  3409. transform: 12,
  3410. moveTo: 13,
  3411. lineTo: 14,
  3412. curveTo: 15,
  3413. curveTo2: 16,
  3414. curveTo3: 17,
  3415. closePath: 18,
  3416. rectangle: 19,
  3417. stroke: 20,
  3418. closeStroke: 21,
  3419. fill: 22,
  3420. eoFill: 23,
  3421. fillStroke: 24,
  3422. eoFillStroke: 25,
  3423. closeFillStroke: 26,
  3424. closeEOFillStroke: 27,
  3425. endPath: 28,
  3426. clip: 29,
  3427. eoClip: 30,
  3428. beginText: 31,
  3429. endText: 32,
  3430. setCharSpacing: 33,
  3431. setWordSpacing: 34,
  3432. setHScale: 35,
  3433. setLeading: 36,
  3434. setFont: 37,
  3435. setTextRenderingMode: 38,
  3436. setTextRise: 39,
  3437. moveText: 40,
  3438. setLeadingMoveText: 41,
  3439. setTextMatrix: 42,
  3440. nextLine: 43,
  3441. showText: 44,
  3442. showSpacedText: 45,
  3443. nextLineShowText: 46,
  3444. nextLineSetSpacingShowText: 47,
  3445. setCharWidth: 48,
  3446. setCharWidthAndBounds: 49,
  3447. setStrokeColorSpace: 50,
  3448. setFillColorSpace: 51,
  3449. setStrokeColor: 52,
  3450. setStrokeColorN: 53,
  3451. setFillColor: 54,
  3452. setFillColorN: 55,
  3453. setStrokeGray: 56,
  3454. setFillGray: 57,
  3455. setStrokeRGBColor: 58,
  3456. setFillRGBColor: 59,
  3457. setStrokeCMYKColor: 60,
  3458. setFillCMYKColor: 61,
  3459. shadingFill: 62,
  3460. beginInlineImage: 63,
  3461. beginImageData: 64,
  3462. endInlineImage: 65,
  3463. paintXObject: 66,
  3464. markPoint: 67,
  3465. markPointProps: 68,
  3466. beginMarkedContent: 69,
  3467. beginMarkedContentProps: 70,
  3468. endMarkedContent: 71,
  3469. beginCompat: 72,
  3470. endCompat: 73,
  3471. paintFormXObjectBegin: 74,
  3472. paintFormXObjectEnd: 75,
  3473. beginGroup: 76,
  3474. endGroup: 77,
  3475. beginAnnotation: 80,
  3476. endAnnotation: 81,
  3477. paintImageMaskXObject: 83,
  3478. paintImageMaskXObjectGroup: 84,
  3479. paintImageXObject: 85,
  3480. paintInlineImageXObject: 86,
  3481. paintInlineImageXObjectGroup: 87,
  3482. paintImageXObjectRepeat: 88,
  3483. paintImageMaskXObjectRepeat: 89,
  3484. paintSolidColorImageMask: 90,
  3485. constructPath: 91
  3486. };
  3487. exports.OPS = OPS;
  3488. const PasswordResponses = {
  3489. NEED_PASSWORD: 1,
  3490. INCORRECT_PASSWORD: 2
  3491. };
  3492. exports.PasswordResponses = PasswordResponses;
  3493. let verbosity = VerbosityLevel.WARNINGS;
  3494. function setVerbosityLevel(level) {
  3495. if (Number.isInteger(level)) {
  3496. verbosity = level;
  3497. }
  3498. }
  3499. function getVerbosityLevel() {
  3500. return verbosity;
  3501. }
  3502. function info(msg) {
  3503. if (verbosity >= VerbosityLevel.INFOS) {
  3504. console.log(`Info: ${msg}`);
  3505. }
  3506. }
  3507. function warn(msg) {
  3508. if (verbosity >= VerbosityLevel.WARNINGS) {
  3509. console.log(`Warning: ${msg}`);
  3510. }
  3511. }
  3512. function unreachable(msg) {
  3513. throw new Error(msg);
  3514. }
  3515. function assert(cond, msg) {
  3516. if (!cond) {
  3517. unreachable(msg);
  3518. }
  3519. }
  3520. function _isValidProtocol(url) {
  3521. switch (url?.protocol) {
  3522. case "http:":
  3523. case "https:":
  3524. case "ftp:":
  3525. case "mailto:":
  3526. case "tel:":
  3527. return true;
  3528. default:
  3529. return false;
  3530. }
  3531. }
  3532. function createValidAbsoluteUrl(url) {
  3533. let baseUrl = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  3534. let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
  3535. if (!url) {
  3536. return null;
  3537. }
  3538. try {
  3539. if (options && typeof url === "string") {
  3540. if (options.addDefaultProtocol && url.startsWith("www.")) {
  3541. const dots = url.match(/\./g);
  3542. if (dots?.length >= 2) {
  3543. url = `http://${url}`;
  3544. }
  3545. }
  3546. if (options.tryConvertEncoding) {
  3547. try {
  3548. url = stringToUTF8String(url);
  3549. } catch {}
  3550. }
  3551. }
  3552. const absoluteUrl = baseUrl ? new URL(url, baseUrl) : new URL(url);
  3553. if (_isValidProtocol(absoluteUrl)) {
  3554. return absoluteUrl;
  3555. }
  3556. } catch {}
  3557. return null;
  3558. }
  3559. function shadow(obj, prop, value) {
  3560. let nonSerializable = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
  3561. Object.defineProperty(obj, prop, {
  3562. value,
  3563. enumerable: !nonSerializable,
  3564. configurable: true,
  3565. writable: false
  3566. });
  3567. return value;
  3568. }
  3569. const BaseException = function BaseExceptionClosure() {
  3570. function BaseException(message, name) {
  3571. if (this.constructor === BaseException) {
  3572. unreachable("Cannot initialize BaseException.");
  3573. }
  3574. this.message = message;
  3575. this.name = name;
  3576. }
  3577. BaseException.prototype = new Error();
  3578. BaseException.constructor = BaseException;
  3579. return BaseException;
  3580. }();
  3581. exports.BaseException = BaseException;
  3582. class PasswordException extends BaseException {
  3583. constructor(msg, code) {
  3584. super(msg, "PasswordException");
  3585. this.code = code;
  3586. }
  3587. }
  3588. exports.PasswordException = PasswordException;
  3589. class UnknownErrorException extends BaseException {
  3590. constructor(msg, details) {
  3591. super(msg, "UnknownErrorException");
  3592. this.details = details;
  3593. }
  3594. }
  3595. exports.UnknownErrorException = UnknownErrorException;
  3596. class InvalidPDFException extends BaseException {
  3597. constructor(msg) {
  3598. super(msg, "InvalidPDFException");
  3599. }
  3600. }
  3601. exports.InvalidPDFException = InvalidPDFException;
  3602. class MissingPDFException extends BaseException {
  3603. constructor(msg) {
  3604. super(msg, "MissingPDFException");
  3605. }
  3606. }
  3607. exports.MissingPDFException = MissingPDFException;
  3608. class UnexpectedResponseException extends BaseException {
  3609. constructor(msg, status) {
  3610. super(msg, "UnexpectedResponseException");
  3611. this.status = status;
  3612. }
  3613. }
  3614. exports.UnexpectedResponseException = UnexpectedResponseException;
  3615. class FormatError extends BaseException {
  3616. constructor(msg) {
  3617. super(msg, "FormatError");
  3618. }
  3619. }
  3620. exports.FormatError = FormatError;
  3621. class AbortException extends BaseException {
  3622. constructor(msg) {
  3623. super(msg, "AbortException");
  3624. }
  3625. }
  3626. exports.AbortException = AbortException;
  3627. function bytesToString(bytes) {
  3628. if (typeof bytes !== "object" || bytes?.length === undefined) {
  3629. unreachable("Invalid argument for bytesToString");
  3630. }
  3631. const length = bytes.length;
  3632. const MAX_ARGUMENT_COUNT = 8192;
  3633. if (length < MAX_ARGUMENT_COUNT) {
  3634. return String.fromCharCode.apply(null, bytes);
  3635. }
  3636. const strBuf = [];
  3637. for (let i = 0; i < length; i += MAX_ARGUMENT_COUNT) {
  3638. const chunkEnd = Math.min(i + MAX_ARGUMENT_COUNT, length);
  3639. const chunk = bytes.subarray(i, chunkEnd);
  3640. strBuf.push(String.fromCharCode.apply(null, chunk));
  3641. }
  3642. return strBuf.join("");
  3643. }
  3644. function stringToBytes(str) {
  3645. if (typeof str !== "string") {
  3646. unreachable("Invalid argument for stringToBytes");
  3647. }
  3648. const length = str.length;
  3649. const bytes = new Uint8Array(length);
  3650. for (let i = 0; i < length; ++i) {
  3651. bytes[i] = str.charCodeAt(i) & 0xff;
  3652. }
  3653. return bytes;
  3654. }
  3655. function string32(value) {
  3656. return String.fromCharCode(value >> 24 & 0xff, value >> 16 & 0xff, value >> 8 & 0xff, value & 0xff);
  3657. }
  3658. function objectSize(obj) {
  3659. return Object.keys(obj).length;
  3660. }
  3661. function objectFromMap(map) {
  3662. const obj = Object.create(null);
  3663. for (const [key, value] of map) {
  3664. obj[key] = value;
  3665. }
  3666. return obj;
  3667. }
  3668. function isLittleEndian() {
  3669. const buffer8 = new Uint8Array(4);
  3670. buffer8[0] = 1;
  3671. const view32 = new Uint32Array(buffer8.buffer, 0, 1);
  3672. return view32[0] === 1;
  3673. }
  3674. function isEvalSupported() {
  3675. try {
  3676. new Function("");
  3677. return true;
  3678. } catch {
  3679. return false;
  3680. }
  3681. }
  3682. class FeatureTest {
  3683. static get isLittleEndian() {
  3684. return shadow(this, "isLittleEndian", isLittleEndian());
  3685. }
  3686. static get isEvalSupported() {
  3687. return shadow(this, "isEvalSupported", isEvalSupported());
  3688. }
  3689. static get isOffscreenCanvasSupported() {
  3690. return shadow(this, "isOffscreenCanvasSupported", typeof OffscreenCanvas !== "undefined");
  3691. }
  3692. static get platform() {
  3693. if (typeof navigator === "undefined") {
  3694. return shadow(this, "platform", {
  3695. isWin: false,
  3696. isMac: false
  3697. });
  3698. }
  3699. return shadow(this, "platform", {
  3700. isWin: navigator.platform.includes("Win"),
  3701. isMac: navigator.platform.includes("Mac")
  3702. });
  3703. }
  3704. static get isCSSRoundSupported() {
  3705. return shadow(this, "isCSSRoundSupported", globalThis.CSS?.supports?.("width: round(1.5px, 1px)"));
  3706. }
  3707. }
  3708. exports.FeatureTest = FeatureTest;
  3709. const hexNumbers = [...Array(256).keys()].map(n => n.toString(16).padStart(2, "0"));
  3710. class Util {
  3711. static makeHexColor(r, g, b) {
  3712. return `#${hexNumbers[r]}${hexNumbers[g]}${hexNumbers[b]}`;
  3713. }
  3714. static scaleMinMax(transform, minMax) {
  3715. let temp;
  3716. if (transform[0]) {
  3717. if (transform[0] < 0) {
  3718. temp = minMax[0];
  3719. minMax[0] = minMax[1];
  3720. minMax[1] = temp;
  3721. }
  3722. minMax[0] *= transform[0];
  3723. minMax[1] *= transform[0];
  3724. if (transform[3] < 0) {
  3725. temp = minMax[2];
  3726. minMax[2] = minMax[3];
  3727. minMax[3] = temp;
  3728. }
  3729. minMax[2] *= transform[3];
  3730. minMax[3] *= transform[3];
  3731. } else {
  3732. temp = minMax[0];
  3733. minMax[0] = minMax[2];
  3734. minMax[2] = temp;
  3735. temp = minMax[1];
  3736. minMax[1] = minMax[3];
  3737. minMax[3] = temp;
  3738. if (transform[1] < 0) {
  3739. temp = minMax[2];
  3740. minMax[2] = minMax[3];
  3741. minMax[3] = temp;
  3742. }
  3743. minMax[2] *= transform[1];
  3744. minMax[3] *= transform[1];
  3745. if (transform[2] < 0) {
  3746. temp = minMax[0];
  3747. minMax[0] = minMax[1];
  3748. minMax[1] = temp;
  3749. }
  3750. minMax[0] *= transform[2];
  3751. minMax[1] *= transform[2];
  3752. }
  3753. minMax[0] += transform[4];
  3754. minMax[1] += transform[4];
  3755. minMax[2] += transform[5];
  3756. minMax[3] += transform[5];
  3757. }
  3758. static transform(m1, m2) {
  3759. 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]];
  3760. }
  3761. static applyTransform(p, m) {
  3762. const xt = p[0] * m[0] + p[1] * m[2] + m[4];
  3763. const yt = p[0] * m[1] + p[1] * m[3] + m[5];
  3764. return [xt, yt];
  3765. }
  3766. static applyInverseTransform(p, m) {
  3767. const d = m[0] * m[3] - m[1] * m[2];
  3768. const xt = (p[0] * m[3] - p[1] * m[2] + m[2] * m[5] - m[4] * m[3]) / d;
  3769. const yt = (-p[0] * m[1] + p[1] * m[0] + m[4] * m[1] - m[5] * m[0]) / d;
  3770. return [xt, yt];
  3771. }
  3772. static getAxialAlignedBoundingBox(r, m) {
  3773. const p1 = this.applyTransform(r, m);
  3774. const p2 = this.applyTransform(r.slice(2, 4), m);
  3775. const p3 = this.applyTransform([r[0], r[3]], m);
  3776. const p4 = this.applyTransform([r[2], r[1]], m);
  3777. 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])];
  3778. }
  3779. static inverseTransform(m) {
  3780. const d = m[0] * m[3] - m[1] * m[2];
  3781. 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];
  3782. }
  3783. static singularValueDecompose2dScale(m) {
  3784. const transpose = [m[0], m[2], m[1], m[3]];
  3785. const a = m[0] * transpose[0] + m[1] * transpose[2];
  3786. const b = m[0] * transpose[1] + m[1] * transpose[3];
  3787. const c = m[2] * transpose[0] + m[3] * transpose[2];
  3788. const d = m[2] * transpose[1] + m[3] * transpose[3];
  3789. const first = (a + d) / 2;
  3790. const second = Math.sqrt((a + d) ** 2 - 4 * (a * d - c * b)) / 2;
  3791. const sx = first + second || 1;
  3792. const sy = first - second || 1;
  3793. return [Math.sqrt(sx), Math.sqrt(sy)];
  3794. }
  3795. static normalizeRect(rect) {
  3796. const r = rect.slice(0);
  3797. if (rect[0] > rect[2]) {
  3798. r[0] = rect[2];
  3799. r[2] = rect[0];
  3800. }
  3801. if (rect[1] > rect[3]) {
  3802. r[1] = rect[3];
  3803. r[3] = rect[1];
  3804. }
  3805. return r;
  3806. }
  3807. static intersect(rect1, rect2) {
  3808. const xLow = Math.max(Math.min(rect1[0], rect1[2]), Math.min(rect2[0], rect2[2]));
  3809. const xHigh = Math.min(Math.max(rect1[0], rect1[2]), Math.max(rect2[0], rect2[2]));
  3810. if (xLow > xHigh) {
  3811. return null;
  3812. }
  3813. const yLow = Math.max(Math.min(rect1[1], rect1[3]), Math.min(rect2[1], rect2[3]));
  3814. const yHigh = Math.min(Math.max(rect1[1], rect1[3]), Math.max(rect2[1], rect2[3]));
  3815. if (yLow > yHigh) {
  3816. return null;
  3817. }
  3818. return [xLow, yLow, xHigh, yHigh];
  3819. }
  3820. static bezierBoundingBox(x0, y0, x1, y1, x2, y2, x3, y3) {
  3821. const tvalues = [],
  3822. bounds = [[], []];
  3823. let a, b, c, t, t1, t2, b2ac, sqrtb2ac;
  3824. for (let i = 0; i < 2; ++i) {
  3825. if (i === 0) {
  3826. b = 6 * x0 - 12 * x1 + 6 * x2;
  3827. a = -3 * x0 + 9 * x1 - 9 * x2 + 3 * x3;
  3828. c = 3 * x1 - 3 * x0;
  3829. } else {
  3830. b = 6 * y0 - 12 * y1 + 6 * y2;
  3831. a = -3 * y0 + 9 * y1 - 9 * y2 + 3 * y3;
  3832. c = 3 * y1 - 3 * y0;
  3833. }
  3834. if (Math.abs(a) < 1e-12) {
  3835. if (Math.abs(b) < 1e-12) {
  3836. continue;
  3837. }
  3838. t = -c / b;
  3839. if (0 < t && t < 1) {
  3840. tvalues.push(t);
  3841. }
  3842. continue;
  3843. }
  3844. b2ac = b * b - 4 * c * a;
  3845. sqrtb2ac = Math.sqrt(b2ac);
  3846. if (b2ac < 0) {
  3847. continue;
  3848. }
  3849. t1 = (-b + sqrtb2ac) / (2 * a);
  3850. if (0 < t1 && t1 < 1) {
  3851. tvalues.push(t1);
  3852. }
  3853. t2 = (-b - sqrtb2ac) / (2 * a);
  3854. if (0 < t2 && t2 < 1) {
  3855. tvalues.push(t2);
  3856. }
  3857. }
  3858. let j = tvalues.length,
  3859. mt;
  3860. const jlen = j;
  3861. while (j--) {
  3862. t = tvalues[j];
  3863. mt = 1 - t;
  3864. bounds[0][j] = mt * mt * mt * x0 + 3 * mt * mt * t * x1 + 3 * mt * t * t * x2 + t * t * t * x3;
  3865. bounds[1][j] = mt * mt * mt * y0 + 3 * mt * mt * t * y1 + 3 * mt * t * t * y2 + t * t * t * y3;
  3866. }
  3867. bounds[0][jlen] = x0;
  3868. bounds[1][jlen] = y0;
  3869. bounds[0][jlen + 1] = x3;
  3870. bounds[1][jlen + 1] = y3;
  3871. bounds[0].length = bounds[1].length = jlen + 2;
  3872. return [Math.min(...bounds[0]), Math.min(...bounds[1]), Math.max(...bounds[0]), Math.max(...bounds[1])];
  3873. }
  3874. }
  3875. exports.Util = Util;
  3876. 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];
  3877. function stringToPDFString(str) {
  3878. if (str[0] >= "\xEF") {
  3879. let encoding;
  3880. if (str[0] === "\xFE" && str[1] === "\xFF") {
  3881. encoding = "utf-16be";
  3882. } else if (str[0] === "\xFF" && str[1] === "\xFE") {
  3883. encoding = "utf-16le";
  3884. } else if (str[0] === "\xEF" && str[1] === "\xBB" && str[2] === "\xBF") {
  3885. encoding = "utf-8";
  3886. }
  3887. if (encoding) {
  3888. try {
  3889. const decoder = new TextDecoder(encoding, {
  3890. fatal: true
  3891. });
  3892. const buffer = stringToBytes(str);
  3893. return decoder.decode(buffer);
  3894. } catch (ex) {
  3895. warn(`stringToPDFString: "${ex}".`);
  3896. }
  3897. }
  3898. }
  3899. const strBuf = [];
  3900. for (let i = 0, ii = str.length; i < ii; i++) {
  3901. const code = PDFStringTranslateTable[str.charCodeAt(i)];
  3902. strBuf.push(code ? String.fromCharCode(code) : str.charAt(i));
  3903. }
  3904. return strBuf.join("");
  3905. }
  3906. function stringToUTF8String(str) {
  3907. return decodeURIComponent(escape(str));
  3908. }
  3909. function utf8StringToString(str) {
  3910. return unescape(encodeURIComponent(str));
  3911. }
  3912. function isArrayBuffer(v) {
  3913. return typeof v === "object" && v?.byteLength !== undefined;
  3914. }
  3915. function isArrayEqual(arr1, arr2) {
  3916. if (arr1.length !== arr2.length) {
  3917. return false;
  3918. }
  3919. for (let i = 0, ii = arr1.length; i < ii; i++) {
  3920. if (arr1[i] !== arr2[i]) {
  3921. return false;
  3922. }
  3923. }
  3924. return true;
  3925. }
  3926. function getModificationDate() {
  3927. let date = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : new Date();
  3928. 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")];
  3929. return buffer.join("");
  3930. }
  3931. class PromiseCapability {
  3932. #settled = false;
  3933. constructor() {
  3934. this.promise = new Promise((resolve, reject) => {
  3935. this.resolve = data => {
  3936. this.#settled = true;
  3937. resolve(data);
  3938. };
  3939. this.reject = reason => {
  3940. this.#settled = true;
  3941. reject(reason);
  3942. };
  3943. });
  3944. }
  3945. get settled() {
  3946. return this.#settled;
  3947. }
  3948. }
  3949. exports.PromiseCapability = PromiseCapability;
  3950. let NormalizeRegex = null;
  3951. let NormalizationMap = null;
  3952. function normalizeUnicode(str) {
  3953. if (!NormalizeRegex) {
  3954. 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;
  3955. NormalizationMap = new Map([["ſt", "ſt"]]);
  3956. }
  3957. return str.replaceAll(NormalizeRegex, (_, p1, p2) => {
  3958. return p1 ? p1.normalize("NFKC") : NormalizationMap.get(p2);
  3959. });
  3960. }
  3961. function getUuid() {
  3962. if (typeof crypto !== "undefined" && typeof crypto?.randomUUID === "function") {
  3963. return crypto.randomUUID();
  3964. }
  3965. const buf = new Uint8Array(32);
  3966. if (typeof crypto !== "undefined" && typeof crypto?.getRandomValues === "function") {
  3967. crypto.getRandomValues(buf);
  3968. } else {
  3969. for (let i = 0; i < 32; i++) {
  3970. buf[i] = Math.floor(Math.random() * 255);
  3971. }
  3972. }
  3973. return bytesToString(buf);
  3974. }
  3975. /***/ }),
  3976. /* 146 */
  3977. /***/ ((__unused_webpack_module, __unused_webpack_exports, __w_pdfjs_require__) => {
  3978. var defineBuiltIn = __w_pdfjs_require__(48);
  3979. var uncurryThis = __w_pdfjs_require__(14);
  3980. var toString = __w_pdfjs_require__(77);
  3981. var validateArgumentsLength = __w_pdfjs_require__(147);
  3982. var $URLSearchParams = URLSearchParams;
  3983. var URLSearchParamsPrototype = $URLSearchParams.prototype;
  3984. var append = uncurryThis(URLSearchParamsPrototype.append);
  3985. var $delete = uncurryThis(URLSearchParamsPrototype['delete']);
  3986. var forEach = uncurryThis(URLSearchParamsPrototype.forEach);
  3987. var push = uncurryThis([].push);
  3988. var params = new $URLSearchParams('a=1&a=2&b=3');
  3989. params['delete']('a', 1);
  3990. params['delete']('b', undefined);
  3991. if (params + '' !== 'a=2') {
  3992. defineBuiltIn(URLSearchParamsPrototype, 'delete', function (name) {
  3993. var length = arguments.length;
  3994. var $value = length < 2 ? undefined : arguments[1];
  3995. if (length && $value === undefined)
  3996. return $delete(this, name);
  3997. var entries = [];
  3998. forEach(this, function (v, k) {
  3999. push(entries, {
  4000. key: k,
  4001. value: v
  4002. });
  4003. });
  4004. validateArgumentsLength(length, 1);
  4005. var key = toString(name);
  4006. var value = toString($value);
  4007. var index = 0;
  4008. var dindex = 0;
  4009. var found = false;
  4010. var entriesLength = entries.length;
  4011. var entry;
  4012. while (index < entriesLength) {
  4013. entry = entries[index++];
  4014. if (found || entry.key === key) {
  4015. found = true;
  4016. $delete(this, entry.key);
  4017. } else
  4018. dindex++;
  4019. }
  4020. while (dindex < entriesLength) {
  4021. entry = entries[dindex++];
  4022. if (!(entry.key === key && entry.value === value))
  4023. append(this, entry.key, entry.value);
  4024. }
  4025. }, {
  4026. enumerable: true,
  4027. unsafe: true
  4028. });
  4029. }
  4030. /***/ }),
  4031. /* 147 */
  4032. /***/ ((module) => {
  4033. var $TypeError = TypeError;
  4034. module.exports = function (passed, required) {
  4035. if (passed < required)
  4036. throw $TypeError('Not enough arguments');
  4037. return passed;
  4038. };
  4039. /***/ }),
  4040. /* 148 */
  4041. /***/ ((__unused_webpack_module, __unused_webpack_exports, __w_pdfjs_require__) => {
  4042. var defineBuiltIn = __w_pdfjs_require__(48);
  4043. var uncurryThis = __w_pdfjs_require__(14);
  4044. var toString = __w_pdfjs_require__(77);
  4045. var validateArgumentsLength = __w_pdfjs_require__(147);
  4046. var $URLSearchParams = URLSearchParams;
  4047. var URLSearchParamsPrototype = $URLSearchParams.prototype;
  4048. var getAll = uncurryThis(URLSearchParamsPrototype.getAll);
  4049. var $has = uncurryThis(URLSearchParamsPrototype.has);
  4050. var params = new $URLSearchParams('a=1');
  4051. if (params.has('a', 2) || !params.has('a', undefined)) {
  4052. defineBuiltIn(URLSearchParamsPrototype, 'has', function has(name) {
  4053. var length = arguments.length;
  4054. var $value = length < 2 ? undefined : arguments[1];
  4055. if (length && $value === undefined)
  4056. return $has(this, name);
  4057. var values = getAll(this, name);
  4058. validateArgumentsLength(length, 1);
  4059. var value = toString($value);
  4060. var index = 0;
  4061. while (index < values.length) {
  4062. if (values[index++] === value)
  4063. return true;
  4064. }
  4065. return false;
  4066. }, {
  4067. enumerable: true,
  4068. unsafe: true
  4069. });
  4070. }
  4071. /***/ }),
  4072. /* 149 */
  4073. /***/ ((__unused_webpack_module, __unused_webpack_exports, __w_pdfjs_require__) => {
  4074. var DESCRIPTORS = __w_pdfjs_require__(6);
  4075. var uncurryThis = __w_pdfjs_require__(14);
  4076. var defineBuiltInAccessor = __w_pdfjs_require__(87);
  4077. var URLSearchParamsPrototype = URLSearchParams.prototype;
  4078. var forEach = uncurryThis(URLSearchParamsPrototype.forEach);
  4079. if (DESCRIPTORS && !('size' in URLSearchParamsPrototype)) {
  4080. defineBuiltInAccessor(URLSearchParamsPrototype, 'size', {
  4081. get: function size() {
  4082. var count = 0;
  4083. forEach(this, function () {
  4084. count++;
  4085. });
  4086. return count;
  4087. },
  4088. configurable: true,
  4089. enumerable: true
  4090. });
  4091. }
  4092. /***/ }),
  4093. /* 150 */
  4094. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  4095. Object.defineProperty(exports, "__esModule", ({
  4096. value: true
  4097. }));
  4098. exports.XRefParseException = exports.XRefEntryException = exports.ParserEOFException = exports.PDF_VERSION_REGEXP = exports.MissingDataException = void 0;
  4099. exports.arrayBuffersToBytes = arrayBuffersToBytes;
  4100. exports.collectActions = collectActions;
  4101. exports.encodeToXmlString = encodeToXmlString;
  4102. exports.escapePDFName = escapePDFName;
  4103. exports.escapeString = escapeString;
  4104. exports.getInheritableProperty = getInheritableProperty;
  4105. exports.getLookupTableFactory = getLookupTableFactory;
  4106. exports.getNewAnnotationsMap = getNewAnnotationsMap;
  4107. exports.getRotationMatrix = getRotationMatrix;
  4108. exports.isAscii = isAscii;
  4109. exports.isWhiteSpace = isWhiteSpace;
  4110. exports.log2 = log2;
  4111. exports.numberToString = numberToString;
  4112. exports.parseXFAPath = parseXFAPath;
  4113. exports.readInt8 = readInt8;
  4114. exports.readUint16 = readUint16;
  4115. exports.readUint32 = readUint32;
  4116. exports.recoverJsURL = recoverJsURL;
  4117. exports.stringToUTF16HexString = stringToUTF16HexString;
  4118. exports.stringToUTF16String = stringToUTF16String;
  4119. exports.toRomanNumerals = toRomanNumerals;
  4120. exports.validateCSSFont = validateCSSFont;
  4121. exports.validateFontName = validateFontName;
  4122. __w_pdfjs_require__(84);
  4123. __w_pdfjs_require__(93);
  4124. __w_pdfjs_require__(94);
  4125. __w_pdfjs_require__(97);
  4126. __w_pdfjs_require__(99);
  4127. __w_pdfjs_require__(101);
  4128. __w_pdfjs_require__(105);
  4129. __w_pdfjs_require__(108);
  4130. __w_pdfjs_require__(115);
  4131. __w_pdfjs_require__(140);
  4132. __w_pdfjs_require__(116);
  4133. __w_pdfjs_require__(127);
  4134. __w_pdfjs_require__(129);
  4135. __w_pdfjs_require__(132);
  4136. __w_pdfjs_require__(134);
  4137. __w_pdfjs_require__(136);
  4138. __w_pdfjs_require__(138);
  4139. __w_pdfjs_require__(2);
  4140. var _util = __w_pdfjs_require__(145);
  4141. var _primitives = __w_pdfjs_require__(151);
  4142. var _base_stream = __w_pdfjs_require__(152);
  4143. const PDF_VERSION_REGEXP = /^[1-9]\.\d$/;
  4144. exports.PDF_VERSION_REGEXP = PDF_VERSION_REGEXP;
  4145. function getLookupTableFactory(initializer) {
  4146. let lookup;
  4147. return function () {
  4148. if (initializer) {
  4149. lookup = Object.create(null);
  4150. initializer(lookup);
  4151. initializer = null;
  4152. }
  4153. return lookup;
  4154. };
  4155. }
  4156. class MissingDataException extends _util.BaseException {
  4157. constructor(begin, end) {
  4158. super(`Missing data [${begin}, ${end})`, "MissingDataException");
  4159. this.begin = begin;
  4160. this.end = end;
  4161. }
  4162. }
  4163. exports.MissingDataException = MissingDataException;
  4164. class ParserEOFException extends _util.BaseException {
  4165. constructor(msg) {
  4166. super(msg, "ParserEOFException");
  4167. }
  4168. }
  4169. exports.ParserEOFException = ParserEOFException;
  4170. class XRefEntryException extends _util.BaseException {
  4171. constructor(msg) {
  4172. super(msg, "XRefEntryException");
  4173. }
  4174. }
  4175. exports.XRefEntryException = XRefEntryException;
  4176. class XRefParseException extends _util.BaseException {
  4177. constructor(msg) {
  4178. super(msg, "XRefParseException");
  4179. }
  4180. }
  4181. exports.XRefParseException = XRefParseException;
  4182. function arrayBuffersToBytes(arr) {
  4183. const length = arr.length;
  4184. if (length === 0) {
  4185. return new Uint8Array(0);
  4186. }
  4187. if (length === 1) {
  4188. return new Uint8Array(arr[0]);
  4189. }
  4190. let dataLength = 0;
  4191. for (let i = 0; i < length; i++) {
  4192. dataLength += arr[i].byteLength;
  4193. }
  4194. const data = new Uint8Array(dataLength);
  4195. let pos = 0;
  4196. for (let i = 0; i < length; i++) {
  4197. const item = new Uint8Array(arr[i]);
  4198. data.set(item, pos);
  4199. pos += item.byteLength;
  4200. }
  4201. return data;
  4202. }
  4203. function getInheritableProperty(_ref) {
  4204. let {
  4205. dict,
  4206. key,
  4207. getArray = false,
  4208. stopWhenFound = true
  4209. } = _ref;
  4210. let values;
  4211. const visited = new _primitives.RefSet();
  4212. while (dict instanceof _primitives.Dict && !(dict.objId && visited.has(dict.objId))) {
  4213. if (dict.objId) {
  4214. visited.put(dict.objId);
  4215. }
  4216. const value = getArray ? dict.getArray(key) : dict.get(key);
  4217. if (value !== undefined) {
  4218. if (stopWhenFound) {
  4219. return value;
  4220. }
  4221. (values ||= []).push(value);
  4222. }
  4223. dict = dict.get("Parent");
  4224. }
  4225. return values;
  4226. }
  4227. 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"];
  4228. function toRomanNumerals(number) {
  4229. let lowerCase = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  4230. (0, _util.assert)(Number.isInteger(number) && number > 0, "The number should be a positive integer.");
  4231. const romanBuf = [];
  4232. let pos;
  4233. while (number >= 1000) {
  4234. number -= 1000;
  4235. romanBuf.push("M");
  4236. }
  4237. pos = number / 100 | 0;
  4238. number %= 100;
  4239. romanBuf.push(ROMAN_NUMBER_MAP[pos]);
  4240. pos = number / 10 | 0;
  4241. number %= 10;
  4242. romanBuf.push(ROMAN_NUMBER_MAP[10 + pos]);
  4243. romanBuf.push(ROMAN_NUMBER_MAP[20 + number]);
  4244. const romanStr = romanBuf.join("");
  4245. return lowerCase ? romanStr.toLowerCase() : romanStr;
  4246. }
  4247. function log2(x) {
  4248. if (x <= 0) {
  4249. return 0;
  4250. }
  4251. return Math.ceil(Math.log2(x));
  4252. }
  4253. function readInt8(data, offset) {
  4254. return data[offset] << 24 >> 24;
  4255. }
  4256. function readUint16(data, offset) {
  4257. return data[offset] << 8 | data[offset + 1];
  4258. }
  4259. function readUint32(data, offset) {
  4260. return (data[offset] << 24 | data[offset + 1] << 16 | data[offset + 2] << 8 | data[offset + 3]) >>> 0;
  4261. }
  4262. function isWhiteSpace(ch) {
  4263. return ch === 0x20 || ch === 0x09 || ch === 0x0d || ch === 0x0a;
  4264. }
  4265. function parseXFAPath(path) {
  4266. const positionPattern = /(.+)\[(\d+)\]$/;
  4267. return path.split(".").map(component => {
  4268. const m = component.match(positionPattern);
  4269. if (m) {
  4270. return {
  4271. name: m[1],
  4272. pos: parseInt(m[2], 10)
  4273. };
  4274. }
  4275. return {
  4276. name: component,
  4277. pos: 0
  4278. };
  4279. });
  4280. }
  4281. function escapePDFName(str) {
  4282. const buffer = [];
  4283. let start = 0;
  4284. for (let i = 0, ii = str.length; i < ii; i++) {
  4285. const char = str.charCodeAt(i);
  4286. 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) {
  4287. if (start < i) {
  4288. buffer.push(str.substring(start, i));
  4289. }
  4290. buffer.push(`#${char.toString(16)}`);
  4291. start = i + 1;
  4292. }
  4293. }
  4294. if (buffer.length === 0) {
  4295. return str;
  4296. }
  4297. if (start < str.length) {
  4298. buffer.push(str.substring(start, str.length));
  4299. }
  4300. return buffer.join("");
  4301. }
  4302. function escapeString(str) {
  4303. return str.replaceAll(/([()\\\n\r])/g, match => {
  4304. if (match === "\n") {
  4305. return "\\n";
  4306. } else if (match === "\r") {
  4307. return "\\r";
  4308. }
  4309. return `\\${match}`;
  4310. });
  4311. }
  4312. function _collectJS(entry, xref, list, parents) {
  4313. if (!entry) {
  4314. return;
  4315. }
  4316. let parent = null;
  4317. if (entry instanceof _primitives.Ref) {
  4318. if (parents.has(entry)) {
  4319. return;
  4320. }
  4321. parent = entry;
  4322. parents.put(parent);
  4323. entry = xref.fetch(entry);
  4324. }
  4325. if (Array.isArray(entry)) {
  4326. for (const element of entry) {
  4327. _collectJS(element, xref, list, parents);
  4328. }
  4329. } else if (entry instanceof _primitives.Dict) {
  4330. if ((0, _primitives.isName)(entry.get("S"), "JavaScript")) {
  4331. const js = entry.get("JS");
  4332. let code;
  4333. if (js instanceof _base_stream.BaseStream) {
  4334. code = js.getString();
  4335. } else if (typeof js === "string") {
  4336. code = js;
  4337. }
  4338. code &&= (0, _util.stringToPDFString)(code).replaceAll("\x00", "");
  4339. if (code) {
  4340. list.push(code);
  4341. }
  4342. }
  4343. _collectJS(entry.getRaw("Next"), xref, list, parents);
  4344. }
  4345. if (parent) {
  4346. parents.remove(parent);
  4347. }
  4348. }
  4349. function collectActions(xref, dict, eventType) {
  4350. const actions = Object.create(null);
  4351. const additionalActionsDicts = getInheritableProperty({
  4352. dict,
  4353. key: "AA",
  4354. stopWhenFound: false
  4355. });
  4356. if (additionalActionsDicts) {
  4357. for (let i = additionalActionsDicts.length - 1; i >= 0; i--) {
  4358. const additionalActions = additionalActionsDicts[i];
  4359. if (!(additionalActions instanceof _primitives.Dict)) {
  4360. continue;
  4361. }
  4362. for (const key of additionalActions.getKeys()) {
  4363. const action = eventType[key];
  4364. if (!action) {
  4365. continue;
  4366. }
  4367. const actionDict = additionalActions.getRaw(key);
  4368. const parents = new _primitives.RefSet();
  4369. const list = [];
  4370. _collectJS(actionDict, xref, list, parents);
  4371. if (list.length > 0) {
  4372. actions[action] = list;
  4373. }
  4374. }
  4375. }
  4376. }
  4377. if (dict.has("A")) {
  4378. const actionDict = dict.get("A");
  4379. const parents = new _primitives.RefSet();
  4380. const list = [];
  4381. _collectJS(actionDict, xref, list, parents);
  4382. if (list.length > 0) {
  4383. actions.Action = list;
  4384. }
  4385. }
  4386. return (0, _util.objectSize)(actions) > 0 ? actions : null;
  4387. }
  4388. const XMLEntities = {
  4389. 0x3c: "&lt;",
  4390. 0x3e: "&gt;",
  4391. 0x26: "&amp;",
  4392. 0x22: "&quot;",
  4393. 0x27: "&apos;"
  4394. };
  4395. function encodeToXmlString(str) {
  4396. const buffer = [];
  4397. let start = 0;
  4398. for (let i = 0, ii = str.length; i < ii; i++) {
  4399. const char = str.codePointAt(i);
  4400. if (0x20 <= char && char <= 0x7e) {
  4401. const entity = XMLEntities[char];
  4402. if (entity) {
  4403. if (start < i) {
  4404. buffer.push(str.substring(start, i));
  4405. }
  4406. buffer.push(entity);
  4407. start = i + 1;
  4408. }
  4409. } else {
  4410. if (start < i) {
  4411. buffer.push(str.substring(start, i));
  4412. }
  4413. buffer.push(`&#x${char.toString(16).toUpperCase()};`);
  4414. if (char > 0xd7ff && (char < 0xe000 || char > 0xfffd)) {
  4415. i++;
  4416. }
  4417. start = i + 1;
  4418. }
  4419. }
  4420. if (buffer.length === 0) {
  4421. return str;
  4422. }
  4423. if (start < str.length) {
  4424. buffer.push(str.substring(start, str.length));
  4425. }
  4426. return buffer.join("");
  4427. }
  4428. function validateFontName(fontFamily) {
  4429. let mustWarn = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  4430. const m = /^("|').*("|')$/.exec(fontFamily);
  4431. if (m && m[1] === m[2]) {
  4432. const re = new RegExp(`[^\\\\]${m[1]}`);
  4433. if (re.test(fontFamily.slice(1, -1))) {
  4434. if (mustWarn) {
  4435. (0, _util.warn)(`FontFamily contains unescaped ${m[1]}: ${fontFamily}.`);
  4436. }
  4437. return false;
  4438. }
  4439. } else {
  4440. for (const ident of fontFamily.split(/[ \t]+/)) {
  4441. if (/^(\d|(-(\d|-)))/.test(ident) || !/^[\w-\\]+$/.test(ident)) {
  4442. if (mustWarn) {
  4443. (0, _util.warn)(`FontFamily contains invalid <custom-ident>: ${fontFamily}.`);
  4444. }
  4445. return false;
  4446. }
  4447. }
  4448. }
  4449. return true;
  4450. }
  4451. function validateCSSFont(cssFontInfo) {
  4452. const DEFAULT_CSS_FONT_OBLIQUE = "14";
  4453. const DEFAULT_CSS_FONT_WEIGHT = "400";
  4454. const CSS_FONT_WEIGHT_VALUES = new Set(["100", "200", "300", "400", "500", "600", "700", "800", "900", "1000", "normal", "bold", "bolder", "lighter"]);
  4455. const {
  4456. fontFamily,
  4457. fontWeight,
  4458. italicAngle
  4459. } = cssFontInfo;
  4460. if (!validateFontName(fontFamily, true)) {
  4461. return false;
  4462. }
  4463. const weight = fontWeight ? fontWeight.toString() : "";
  4464. cssFontInfo.fontWeight = CSS_FONT_WEIGHT_VALUES.has(weight) ? weight : DEFAULT_CSS_FONT_WEIGHT;
  4465. const angle = parseFloat(italicAngle);
  4466. cssFontInfo.italicAngle = isNaN(angle) || angle < -90 || angle > 90 ? DEFAULT_CSS_FONT_OBLIQUE : italicAngle.toString();
  4467. return true;
  4468. }
  4469. function recoverJsURL(str) {
  4470. const URL_OPEN_METHODS = ["app.launchURL", "window.open", "xfa.host.gotoURL"];
  4471. const regex = new RegExp("^\\s*(" + URL_OPEN_METHODS.join("|").replaceAll(".", "\\.") + ")\\((?:'|\")([^'\"]*)(?:'|\")(?:,\\s*(\\w+)\\)|\\))", "i");
  4472. const jsUrl = regex.exec(str);
  4473. if (jsUrl?.[2]) {
  4474. const url = jsUrl[2];
  4475. let newWindow = false;
  4476. if (jsUrl[3] === "true" && jsUrl[1] === "app.launchURL") {
  4477. newWindow = true;
  4478. }
  4479. return {
  4480. url,
  4481. newWindow
  4482. };
  4483. }
  4484. return null;
  4485. }
  4486. function numberToString(value) {
  4487. if (Number.isInteger(value)) {
  4488. return value.toString();
  4489. }
  4490. const roundedValue = Math.round(value * 100);
  4491. if (roundedValue % 100 === 0) {
  4492. return (roundedValue / 100).toString();
  4493. }
  4494. if (roundedValue % 10 === 0) {
  4495. return value.toFixed(1);
  4496. }
  4497. return value.toFixed(2);
  4498. }
  4499. function getNewAnnotationsMap(annotationStorage) {
  4500. if (!annotationStorage) {
  4501. return null;
  4502. }
  4503. const newAnnotationsByPage = new Map();
  4504. for (const [key, value] of annotationStorage) {
  4505. if (!key.startsWith(_util.AnnotationEditorPrefix)) {
  4506. continue;
  4507. }
  4508. let annotations = newAnnotationsByPage.get(value.pageIndex);
  4509. if (!annotations) {
  4510. annotations = [];
  4511. newAnnotationsByPage.set(value.pageIndex, annotations);
  4512. }
  4513. annotations.push(value);
  4514. }
  4515. return newAnnotationsByPage.size > 0 ? newAnnotationsByPage : null;
  4516. }
  4517. function isAscii(str) {
  4518. return /^[\x00-\x7F]*$/.test(str);
  4519. }
  4520. function stringToUTF16HexString(str) {
  4521. const buf = [];
  4522. for (let i = 0, ii = str.length; i < ii; i++) {
  4523. const char = str.charCodeAt(i);
  4524. buf.push((char >> 8 & 0xff).toString(16).padStart(2, "0"), (char & 0xff).toString(16).padStart(2, "0"));
  4525. }
  4526. return buf.join("");
  4527. }
  4528. function stringToUTF16String(str) {
  4529. let bigEndian = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  4530. const buf = [];
  4531. if (bigEndian) {
  4532. buf.push("\xFE\xFF");
  4533. }
  4534. for (let i = 0, ii = str.length; i < ii; i++) {
  4535. const char = str.charCodeAt(i);
  4536. buf.push(String.fromCharCode(char >> 8 & 0xff), String.fromCharCode(char & 0xff));
  4537. }
  4538. return buf.join("");
  4539. }
  4540. function getRotationMatrix(rotation, width, height) {
  4541. switch (rotation) {
  4542. case 90:
  4543. return [0, 1, -1, 0, width, 0];
  4544. case 180:
  4545. return [-1, 0, 0, -1, width, height];
  4546. case 270:
  4547. return [0, -1, 1, 0, 0, height];
  4548. default:
  4549. throw new Error("Invalid rotation");
  4550. }
  4551. }
  4552. /***/ }),
  4553. /* 151 */
  4554. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  4555. Object.defineProperty(exports, "__esModule", ({
  4556. value: true
  4557. }));
  4558. exports.RefSetCache = exports.RefSet = exports.Ref = exports.Name = exports.EOF = exports.Dict = exports.Cmd = exports.CIRCULAR_REF = void 0;
  4559. exports.clearPrimitiveCaches = clearPrimitiveCaches;
  4560. exports.isCmd = isCmd;
  4561. exports.isDict = isDict;
  4562. exports.isName = isName;
  4563. exports.isRefsEqual = isRefsEqual;
  4564. __w_pdfjs_require__(140);
  4565. __w_pdfjs_require__(116);
  4566. __w_pdfjs_require__(127);
  4567. __w_pdfjs_require__(129);
  4568. __w_pdfjs_require__(132);
  4569. __w_pdfjs_require__(134);
  4570. __w_pdfjs_require__(136);
  4571. __w_pdfjs_require__(138);
  4572. var _util = __w_pdfjs_require__(145);
  4573. const CIRCULAR_REF = Symbol("CIRCULAR_REF");
  4574. exports.CIRCULAR_REF = CIRCULAR_REF;
  4575. const EOF = Symbol("EOF");
  4576. exports.EOF = EOF;
  4577. let CmdCache = Object.create(null);
  4578. let NameCache = Object.create(null);
  4579. let RefCache = Object.create(null);
  4580. function clearPrimitiveCaches() {
  4581. CmdCache = Object.create(null);
  4582. NameCache = Object.create(null);
  4583. RefCache = Object.create(null);
  4584. }
  4585. class Name {
  4586. constructor(name) {
  4587. this.name = name;
  4588. }
  4589. static get(name) {
  4590. return NameCache[name] ||= new Name(name);
  4591. }
  4592. }
  4593. exports.Name = Name;
  4594. class Cmd {
  4595. constructor(cmd) {
  4596. this.cmd = cmd;
  4597. }
  4598. static get(cmd) {
  4599. return CmdCache[cmd] ||= new Cmd(cmd);
  4600. }
  4601. }
  4602. exports.Cmd = Cmd;
  4603. const nonSerializable = function nonSerializableClosure() {
  4604. return nonSerializable;
  4605. };
  4606. class Dict {
  4607. constructor() {
  4608. let xref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
  4609. this._map = Object.create(null);
  4610. this.xref = xref;
  4611. this.objId = null;
  4612. this.suppressEncryption = false;
  4613. this.__nonSerializable__ = nonSerializable;
  4614. }
  4615. assignXref(newXref) {
  4616. this.xref = newXref;
  4617. }
  4618. get size() {
  4619. return Object.keys(this._map).length;
  4620. }
  4621. get(key1, key2, key3) {
  4622. let value = this._map[key1];
  4623. if (value === undefined && key2 !== undefined) {
  4624. value = this._map[key2];
  4625. if (value === undefined && key3 !== undefined) {
  4626. value = this._map[key3];
  4627. }
  4628. }
  4629. if (value instanceof Ref && this.xref) {
  4630. return this.xref.fetch(value, this.suppressEncryption);
  4631. }
  4632. return value;
  4633. }
  4634. async getAsync(key1, key2, key3) {
  4635. let value = this._map[key1];
  4636. if (value === undefined && key2 !== undefined) {
  4637. value = this._map[key2];
  4638. if (value === undefined && key3 !== undefined) {
  4639. value = this._map[key3];
  4640. }
  4641. }
  4642. if (value instanceof Ref && this.xref) {
  4643. return this.xref.fetchAsync(value, this.suppressEncryption);
  4644. }
  4645. return value;
  4646. }
  4647. getArray(key1, key2, key3) {
  4648. let value = this._map[key1];
  4649. if (value === undefined && key2 !== undefined) {
  4650. value = this._map[key2];
  4651. if (value === undefined && key3 !== undefined) {
  4652. value = this._map[key3];
  4653. }
  4654. }
  4655. if (value instanceof Ref && this.xref) {
  4656. value = this.xref.fetch(value, this.suppressEncryption);
  4657. }
  4658. if (Array.isArray(value)) {
  4659. value = value.slice();
  4660. for (let i = 0, ii = value.length; i < ii; i++) {
  4661. if (value[i] instanceof Ref && this.xref) {
  4662. value[i] = this.xref.fetch(value[i], this.suppressEncryption);
  4663. }
  4664. }
  4665. }
  4666. return value;
  4667. }
  4668. getRaw(key) {
  4669. return this._map[key];
  4670. }
  4671. getKeys() {
  4672. return Object.keys(this._map);
  4673. }
  4674. getRawValues() {
  4675. return Object.values(this._map);
  4676. }
  4677. set(key, value) {
  4678. this._map[key] = value;
  4679. }
  4680. has(key) {
  4681. return this._map[key] !== undefined;
  4682. }
  4683. forEach(callback) {
  4684. for (const key in this._map) {
  4685. callback(key, this.get(key));
  4686. }
  4687. }
  4688. static get empty() {
  4689. const emptyDict = new Dict(null);
  4690. emptyDict.set = (key, value) => {
  4691. (0, _util.unreachable)("Should not call `set` on the empty dictionary.");
  4692. };
  4693. return (0, _util.shadow)(this, "empty", emptyDict);
  4694. }
  4695. static merge(_ref) {
  4696. let {
  4697. xref,
  4698. dictArray,
  4699. mergeSubDicts = false
  4700. } = _ref;
  4701. const mergedDict = new Dict(xref),
  4702. properties = new Map();
  4703. for (const dict of dictArray) {
  4704. if (!(dict instanceof Dict)) {
  4705. continue;
  4706. }
  4707. for (const [key, value] of Object.entries(dict._map)) {
  4708. let property = properties.get(key);
  4709. if (property === undefined) {
  4710. property = [];
  4711. properties.set(key, property);
  4712. } else if (!mergeSubDicts || !(value instanceof Dict)) {
  4713. continue;
  4714. }
  4715. property.push(value);
  4716. }
  4717. }
  4718. for (const [name, values] of properties) {
  4719. if (values.length === 1 || !(values[0] instanceof Dict)) {
  4720. mergedDict._map[name] = values[0];
  4721. continue;
  4722. }
  4723. const subDict = new Dict(xref);
  4724. for (const dict of values) {
  4725. for (const [key, value] of Object.entries(dict._map)) {
  4726. if (subDict._map[key] === undefined) {
  4727. subDict._map[key] = value;
  4728. }
  4729. }
  4730. }
  4731. if (subDict.size > 0) {
  4732. mergedDict._map[name] = subDict;
  4733. }
  4734. }
  4735. properties.clear();
  4736. return mergedDict.size > 0 ? mergedDict : Dict.empty;
  4737. }
  4738. }
  4739. exports.Dict = Dict;
  4740. class Ref {
  4741. constructor(num, gen) {
  4742. this.num = num;
  4743. this.gen = gen;
  4744. }
  4745. toString() {
  4746. if (this.gen === 0) {
  4747. return `${this.num}R`;
  4748. }
  4749. return `${this.num}R${this.gen}`;
  4750. }
  4751. static fromString(str) {
  4752. const ref = RefCache[str];
  4753. if (ref) {
  4754. return ref;
  4755. }
  4756. const m = /^(\d+)R(\d*)$/.exec(str);
  4757. if (!m || m[1] === "0") {
  4758. return null;
  4759. }
  4760. return RefCache[str] = new Ref(parseInt(m[1]), !m[2] ? 0 : parseInt(m[2]));
  4761. }
  4762. static get(num, gen) {
  4763. const key = gen === 0 ? `${num}R` : `${num}R${gen}`;
  4764. return RefCache[key] ||= new Ref(num, gen);
  4765. }
  4766. }
  4767. exports.Ref = Ref;
  4768. class RefSet {
  4769. constructor() {
  4770. let parent = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
  4771. this._set = new Set(parent?._set);
  4772. }
  4773. has(ref) {
  4774. return this._set.has(ref.toString());
  4775. }
  4776. put(ref) {
  4777. this._set.add(ref.toString());
  4778. }
  4779. remove(ref) {
  4780. this._set.delete(ref.toString());
  4781. }
  4782. [Symbol.iterator]() {
  4783. return this._set.values();
  4784. }
  4785. clear() {
  4786. this._set.clear();
  4787. }
  4788. }
  4789. exports.RefSet = RefSet;
  4790. class RefSetCache {
  4791. constructor() {
  4792. this._map = new Map();
  4793. }
  4794. get size() {
  4795. return this._map.size;
  4796. }
  4797. get(ref) {
  4798. return this._map.get(ref.toString());
  4799. }
  4800. has(ref) {
  4801. return this._map.has(ref.toString());
  4802. }
  4803. put(ref, obj) {
  4804. this._map.set(ref.toString(), obj);
  4805. }
  4806. putAlias(ref, aliasRef) {
  4807. this._map.set(ref.toString(), this.get(aliasRef));
  4808. }
  4809. [Symbol.iterator]() {
  4810. return this._map.values();
  4811. }
  4812. clear() {
  4813. this._map.clear();
  4814. }
  4815. }
  4816. exports.RefSetCache = RefSetCache;
  4817. function isName(v, name) {
  4818. return v instanceof Name && (name === undefined || v.name === name);
  4819. }
  4820. function isCmd(v, cmd) {
  4821. return v instanceof Cmd && (cmd === undefined || v.cmd === cmd);
  4822. }
  4823. function isDict(v, type) {
  4824. return v instanceof Dict && (type === undefined || isName(v.get("Type"), type));
  4825. }
  4826. function isRefsEqual(v1, v2) {
  4827. return v1.num === v2.num && v1.gen === v2.gen;
  4828. }
  4829. /***/ }),
  4830. /* 152 */
  4831. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  4832. Object.defineProperty(exports, "__esModule", ({
  4833. value: true
  4834. }));
  4835. exports.BaseStream = void 0;
  4836. var _util = __w_pdfjs_require__(145);
  4837. class BaseStream {
  4838. constructor() {
  4839. if (this.constructor === BaseStream) {
  4840. (0, _util.unreachable)("Cannot initialize BaseStream.");
  4841. }
  4842. }
  4843. get length() {
  4844. (0, _util.unreachable)("Abstract getter `length` accessed");
  4845. }
  4846. get isEmpty() {
  4847. (0, _util.unreachable)("Abstract getter `isEmpty` accessed");
  4848. }
  4849. get isDataLoaded() {
  4850. return (0, _util.shadow)(this, "isDataLoaded", true);
  4851. }
  4852. getByte() {
  4853. (0, _util.unreachable)("Abstract method `getByte` called");
  4854. }
  4855. getBytes(length) {
  4856. (0, _util.unreachable)("Abstract method `getBytes` called");
  4857. }
  4858. peekByte() {
  4859. const peekedByte = this.getByte();
  4860. if (peekedByte !== -1) {
  4861. this.pos--;
  4862. }
  4863. return peekedByte;
  4864. }
  4865. peekBytes(length) {
  4866. const bytes = this.getBytes(length);
  4867. this.pos -= bytes.length;
  4868. return bytes;
  4869. }
  4870. getUint16() {
  4871. const b0 = this.getByte();
  4872. const b1 = this.getByte();
  4873. if (b0 === -1 || b1 === -1) {
  4874. return -1;
  4875. }
  4876. return (b0 << 8) + b1;
  4877. }
  4878. getInt32() {
  4879. const b0 = this.getByte();
  4880. const b1 = this.getByte();
  4881. const b2 = this.getByte();
  4882. const b3 = this.getByte();
  4883. return (b0 << 24) + (b1 << 16) + (b2 << 8) + b3;
  4884. }
  4885. getByteRange(begin, end) {
  4886. (0, _util.unreachable)("Abstract method `getByteRange` called");
  4887. }
  4888. getString(length) {
  4889. return (0, _util.bytesToString)(this.getBytes(length));
  4890. }
  4891. skip(n) {
  4892. this.pos += n || 1;
  4893. }
  4894. reset() {
  4895. (0, _util.unreachable)("Abstract method `reset` called");
  4896. }
  4897. moveStart() {
  4898. (0, _util.unreachable)("Abstract method `moveStart` called");
  4899. }
  4900. makeSubStream(start, length) {
  4901. let dict = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
  4902. (0, _util.unreachable)("Abstract method `makeSubStream` called");
  4903. }
  4904. getBaseStreams() {
  4905. return null;
  4906. }
  4907. }
  4908. exports.BaseStream = BaseStream;
  4909. /***/ }),
  4910. /* 153 */
  4911. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  4912. Object.defineProperty(exports, "__esModule", ({
  4913. value: true
  4914. }));
  4915. exports.NetworkPdfManager = exports.LocalPdfManager = void 0;
  4916. var _util = __w_pdfjs_require__(145);
  4917. var _chunked_stream = __w_pdfjs_require__(154);
  4918. var _core_utils = __w_pdfjs_require__(150);
  4919. var _document = __w_pdfjs_require__(156);
  4920. var _stream = __w_pdfjs_require__(155);
  4921. function parseDocBaseUrl(url) {
  4922. if (url) {
  4923. const absoluteUrl = (0, _util.createValidAbsoluteUrl)(url);
  4924. if (absoluteUrl) {
  4925. return absoluteUrl.href;
  4926. }
  4927. (0, _util.warn)(`Invalid absolute docBaseUrl: "${url}".`);
  4928. }
  4929. return null;
  4930. }
  4931. class BasePdfManager {
  4932. constructor(args) {
  4933. if (this.constructor === BasePdfManager) {
  4934. (0, _util.unreachable)("Cannot initialize BasePdfManager.");
  4935. }
  4936. this._docBaseUrl = parseDocBaseUrl(args.docBaseUrl);
  4937. this._docId = args.docId;
  4938. this._password = args.password;
  4939. this.enableXfa = args.enableXfa;
  4940. args.evaluatorOptions.isOffscreenCanvasSupported &&= _util.FeatureTest.isOffscreenCanvasSupported;
  4941. this.evaluatorOptions = args.evaluatorOptions;
  4942. }
  4943. get docId() {
  4944. return this._docId;
  4945. }
  4946. get password() {
  4947. return this._password;
  4948. }
  4949. get docBaseUrl() {
  4950. const catalog = this.pdfDocument.catalog;
  4951. return (0, _util.shadow)(this, "docBaseUrl", catalog.baseUrl || this._docBaseUrl);
  4952. }
  4953. ensureDoc(prop, args) {
  4954. return this.ensure(this.pdfDocument, prop, args);
  4955. }
  4956. ensureXRef(prop, args) {
  4957. return this.ensure(this.pdfDocument.xref, prop, args);
  4958. }
  4959. ensureCatalog(prop, args) {
  4960. return this.ensure(this.pdfDocument.catalog, prop, args);
  4961. }
  4962. getPage(pageIndex) {
  4963. return this.pdfDocument.getPage(pageIndex);
  4964. }
  4965. fontFallback(id, handler) {
  4966. return this.pdfDocument.fontFallback(id, handler);
  4967. }
  4968. loadXfaFonts(handler, task) {
  4969. return this.pdfDocument.loadXfaFonts(handler, task);
  4970. }
  4971. loadXfaImages() {
  4972. return this.pdfDocument.loadXfaImages();
  4973. }
  4974. serializeXfaData(annotationStorage) {
  4975. return this.pdfDocument.serializeXfaData(annotationStorage);
  4976. }
  4977. cleanup() {
  4978. let manuallyTriggered = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  4979. return this.pdfDocument.cleanup(manuallyTriggered);
  4980. }
  4981. async ensure(obj, prop, args) {
  4982. (0, _util.unreachable)("Abstract method `ensure` called");
  4983. }
  4984. requestRange(begin, end) {
  4985. (0, _util.unreachable)("Abstract method `requestRange` called");
  4986. }
  4987. requestLoadedStream() {
  4988. let noFetch = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  4989. (0, _util.unreachable)("Abstract method `requestLoadedStream` called");
  4990. }
  4991. sendProgressiveData(chunk) {
  4992. (0, _util.unreachable)("Abstract method `sendProgressiveData` called");
  4993. }
  4994. updatePassword(password) {
  4995. this._password = password;
  4996. }
  4997. terminate(reason) {
  4998. (0, _util.unreachable)("Abstract method `terminate` called");
  4999. }
  5000. }
  5001. class LocalPdfManager extends BasePdfManager {
  5002. constructor(args) {
  5003. super(args);
  5004. const stream = new _stream.Stream(args.source);
  5005. this.pdfDocument = new _document.PDFDocument(this, stream);
  5006. this._loadedStreamPromise = Promise.resolve(stream);
  5007. }
  5008. async ensure(obj, prop, args) {
  5009. const value = obj[prop];
  5010. if (typeof value === "function") {
  5011. return value.apply(obj, args);
  5012. }
  5013. return value;
  5014. }
  5015. requestRange(begin, end) {
  5016. return Promise.resolve();
  5017. }
  5018. requestLoadedStream() {
  5019. let noFetch = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  5020. return this._loadedStreamPromise;
  5021. }
  5022. terminate(reason) {}
  5023. }
  5024. exports.LocalPdfManager = LocalPdfManager;
  5025. class NetworkPdfManager extends BasePdfManager {
  5026. constructor(args) {
  5027. super(args);
  5028. this.streamManager = new _chunked_stream.ChunkedStreamManager(args.source, {
  5029. msgHandler: args.handler,
  5030. length: args.length,
  5031. disableAutoFetch: args.disableAutoFetch,
  5032. rangeChunkSize: args.rangeChunkSize
  5033. });
  5034. this.pdfDocument = new _document.PDFDocument(this, this.streamManager.getStream());
  5035. }
  5036. async ensure(obj, prop, args) {
  5037. try {
  5038. const value = obj[prop];
  5039. if (typeof value === "function") {
  5040. return value.apply(obj, args);
  5041. }
  5042. return value;
  5043. } catch (ex) {
  5044. if (!(ex instanceof _core_utils.MissingDataException)) {
  5045. throw ex;
  5046. }
  5047. await this.requestRange(ex.begin, ex.end);
  5048. return this.ensure(obj, prop, args);
  5049. }
  5050. }
  5051. requestRange(begin, end) {
  5052. return this.streamManager.requestRange(begin, end);
  5053. }
  5054. requestLoadedStream() {
  5055. let noFetch = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  5056. return this.streamManager.requestAllChunks(noFetch);
  5057. }
  5058. sendProgressiveData(chunk) {
  5059. this.streamManager.onReceiveData({
  5060. chunk
  5061. });
  5062. }
  5063. terminate(reason) {
  5064. this.streamManager.abort(reason);
  5065. }
  5066. }
  5067. exports.NetworkPdfManager = NetworkPdfManager;
  5068. /***/ }),
  5069. /* 154 */
  5070. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  5071. Object.defineProperty(exports, "__esModule", ({
  5072. value: true
  5073. }));
  5074. exports.ChunkedStreamManager = exports.ChunkedStream = void 0;
  5075. __w_pdfjs_require__(84);
  5076. __w_pdfjs_require__(93);
  5077. __w_pdfjs_require__(94);
  5078. __w_pdfjs_require__(97);
  5079. __w_pdfjs_require__(99);
  5080. __w_pdfjs_require__(101);
  5081. __w_pdfjs_require__(105);
  5082. __w_pdfjs_require__(108);
  5083. __w_pdfjs_require__(115);
  5084. __w_pdfjs_require__(116);
  5085. __w_pdfjs_require__(127);
  5086. __w_pdfjs_require__(129);
  5087. __w_pdfjs_require__(132);
  5088. __w_pdfjs_require__(134);
  5089. __w_pdfjs_require__(136);
  5090. __w_pdfjs_require__(138);
  5091. __w_pdfjs_require__(140);
  5092. __w_pdfjs_require__(2);
  5093. var _core_utils = __w_pdfjs_require__(150);
  5094. var _util = __w_pdfjs_require__(145);
  5095. var _stream = __w_pdfjs_require__(155);
  5096. class ChunkedStream extends _stream.Stream {
  5097. constructor(length, chunkSize, manager) {
  5098. super(new Uint8Array(length), 0, length, null);
  5099. this.chunkSize = chunkSize;
  5100. this._loadedChunks = new Set();
  5101. this.numChunks = Math.ceil(length / chunkSize);
  5102. this.manager = manager;
  5103. this.progressiveDataLength = 0;
  5104. this.lastSuccessfulEnsureByteChunk = -1;
  5105. }
  5106. getMissingChunks() {
  5107. const chunks = [];
  5108. for (let chunk = 0, n = this.numChunks; chunk < n; ++chunk) {
  5109. if (!this._loadedChunks.has(chunk)) {
  5110. chunks.push(chunk);
  5111. }
  5112. }
  5113. return chunks;
  5114. }
  5115. get numChunksLoaded() {
  5116. return this._loadedChunks.size;
  5117. }
  5118. get isDataLoaded() {
  5119. return this.numChunksLoaded === this.numChunks;
  5120. }
  5121. onReceiveData(begin, chunk) {
  5122. const chunkSize = this.chunkSize;
  5123. if (begin % chunkSize !== 0) {
  5124. throw new Error(`Bad begin offset: ${begin}`);
  5125. }
  5126. const end = begin + chunk.byteLength;
  5127. if (end % chunkSize !== 0 && end !== this.bytes.length) {
  5128. throw new Error(`Bad end offset: ${end}`);
  5129. }
  5130. this.bytes.set(new Uint8Array(chunk), begin);
  5131. const beginChunk = Math.floor(begin / chunkSize);
  5132. const endChunk = Math.floor((end - 1) / chunkSize) + 1;
  5133. for (let curChunk = beginChunk; curChunk < endChunk; ++curChunk) {
  5134. this._loadedChunks.add(curChunk);
  5135. }
  5136. }
  5137. onReceiveProgressiveData(data) {
  5138. let position = this.progressiveDataLength;
  5139. const beginChunk = Math.floor(position / this.chunkSize);
  5140. this.bytes.set(new Uint8Array(data), position);
  5141. position += data.byteLength;
  5142. this.progressiveDataLength = position;
  5143. const endChunk = position >= this.end ? this.numChunks : Math.floor(position / this.chunkSize);
  5144. for (let curChunk = beginChunk; curChunk < endChunk; ++curChunk) {
  5145. this._loadedChunks.add(curChunk);
  5146. }
  5147. }
  5148. ensureByte(pos) {
  5149. if (pos < this.progressiveDataLength) {
  5150. return;
  5151. }
  5152. const chunk = Math.floor(pos / this.chunkSize);
  5153. if (chunk > this.numChunks) {
  5154. return;
  5155. }
  5156. if (chunk === this.lastSuccessfulEnsureByteChunk) {
  5157. return;
  5158. }
  5159. if (!this._loadedChunks.has(chunk)) {
  5160. throw new _core_utils.MissingDataException(pos, pos + 1);
  5161. }
  5162. this.lastSuccessfulEnsureByteChunk = chunk;
  5163. }
  5164. ensureRange(begin, end) {
  5165. if (begin >= end) {
  5166. return;
  5167. }
  5168. if (end <= this.progressiveDataLength) {
  5169. return;
  5170. }
  5171. const beginChunk = Math.floor(begin / this.chunkSize);
  5172. if (beginChunk > this.numChunks) {
  5173. return;
  5174. }
  5175. const endChunk = Math.min(Math.floor((end - 1) / this.chunkSize) + 1, this.numChunks);
  5176. for (let chunk = beginChunk; chunk < endChunk; ++chunk) {
  5177. if (!this._loadedChunks.has(chunk)) {
  5178. throw new _core_utils.MissingDataException(begin, end);
  5179. }
  5180. }
  5181. }
  5182. nextEmptyChunk(beginChunk) {
  5183. const numChunks = this.numChunks;
  5184. for (let i = 0; i < numChunks; ++i) {
  5185. const chunk = (beginChunk + i) % numChunks;
  5186. if (!this._loadedChunks.has(chunk)) {
  5187. return chunk;
  5188. }
  5189. }
  5190. return null;
  5191. }
  5192. hasChunk(chunk) {
  5193. return this._loadedChunks.has(chunk);
  5194. }
  5195. getByte() {
  5196. const pos = this.pos;
  5197. if (pos >= this.end) {
  5198. return -1;
  5199. }
  5200. if (pos >= this.progressiveDataLength) {
  5201. this.ensureByte(pos);
  5202. }
  5203. return this.bytes[this.pos++];
  5204. }
  5205. getBytes(length) {
  5206. const bytes = this.bytes;
  5207. const pos = this.pos;
  5208. const strEnd = this.end;
  5209. if (!length) {
  5210. if (strEnd > this.progressiveDataLength) {
  5211. this.ensureRange(pos, strEnd);
  5212. }
  5213. return bytes.subarray(pos, strEnd);
  5214. }
  5215. let end = pos + length;
  5216. if (end > strEnd) {
  5217. end = strEnd;
  5218. }
  5219. if (end > this.progressiveDataLength) {
  5220. this.ensureRange(pos, end);
  5221. }
  5222. this.pos = end;
  5223. return bytes.subarray(pos, end);
  5224. }
  5225. getByteRange(begin, end) {
  5226. if (begin < 0) {
  5227. begin = 0;
  5228. }
  5229. if (end > this.end) {
  5230. end = this.end;
  5231. }
  5232. if (end > this.progressiveDataLength) {
  5233. this.ensureRange(begin, end);
  5234. }
  5235. return this.bytes.subarray(begin, end);
  5236. }
  5237. makeSubStream(start, length) {
  5238. let dict = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
  5239. if (length) {
  5240. if (start + length > this.progressiveDataLength) {
  5241. this.ensureRange(start, start + length);
  5242. }
  5243. } else if (start >= this.progressiveDataLength) {
  5244. this.ensureByte(start);
  5245. }
  5246. function ChunkedStreamSubstream() {}
  5247. ChunkedStreamSubstream.prototype = Object.create(this);
  5248. ChunkedStreamSubstream.prototype.getMissingChunks = function () {
  5249. const chunkSize = this.chunkSize;
  5250. const beginChunk = Math.floor(this.start / chunkSize);
  5251. const endChunk = Math.floor((this.end - 1) / chunkSize) + 1;
  5252. const missingChunks = [];
  5253. for (let chunk = beginChunk; chunk < endChunk; ++chunk) {
  5254. if (!this._loadedChunks.has(chunk)) {
  5255. missingChunks.push(chunk);
  5256. }
  5257. }
  5258. return missingChunks;
  5259. };
  5260. Object.defineProperty(ChunkedStreamSubstream.prototype, "isDataLoaded", {
  5261. get() {
  5262. if (this.numChunksLoaded === this.numChunks) {
  5263. return true;
  5264. }
  5265. return this.getMissingChunks().length === 0;
  5266. },
  5267. configurable: true
  5268. });
  5269. const subStream = new ChunkedStreamSubstream();
  5270. subStream.pos = subStream.start = start;
  5271. subStream.end = start + length || this.end;
  5272. subStream.dict = dict;
  5273. return subStream;
  5274. }
  5275. getBaseStreams() {
  5276. return [this];
  5277. }
  5278. }
  5279. exports.ChunkedStream = ChunkedStream;
  5280. class ChunkedStreamManager {
  5281. constructor(pdfNetworkStream, args) {
  5282. this.length = args.length;
  5283. this.chunkSize = args.rangeChunkSize;
  5284. this.stream = new ChunkedStream(this.length, this.chunkSize, this);
  5285. this.pdfNetworkStream = pdfNetworkStream;
  5286. this.disableAutoFetch = args.disableAutoFetch;
  5287. this.msgHandler = args.msgHandler;
  5288. this.currRequestId = 0;
  5289. this._chunksNeededByRequest = new Map();
  5290. this._requestsByChunk = new Map();
  5291. this._promisesByRequest = new Map();
  5292. this.progressiveDataLength = 0;
  5293. this.aborted = false;
  5294. this._loadedStreamCapability = new _util.PromiseCapability();
  5295. }
  5296. sendRequest(begin, end) {
  5297. const rangeReader = this.pdfNetworkStream.getRangeReader(begin, end);
  5298. if (!rangeReader.isStreamingSupported) {
  5299. rangeReader.onProgress = this.onProgress.bind(this);
  5300. }
  5301. let chunks = [],
  5302. loaded = 0;
  5303. return new Promise((resolve, reject) => {
  5304. const readChunk = _ref => {
  5305. let {
  5306. value,
  5307. done
  5308. } = _ref;
  5309. try {
  5310. if (done) {
  5311. const chunkData = (0, _core_utils.arrayBuffersToBytes)(chunks);
  5312. chunks = null;
  5313. resolve(chunkData);
  5314. return;
  5315. }
  5316. loaded += value.byteLength;
  5317. if (rangeReader.isStreamingSupported) {
  5318. this.onProgress({
  5319. loaded
  5320. });
  5321. }
  5322. chunks.push(value);
  5323. rangeReader.read().then(readChunk, reject);
  5324. } catch (e) {
  5325. reject(e);
  5326. }
  5327. };
  5328. rangeReader.read().then(readChunk, reject);
  5329. }).then(data => {
  5330. if (this.aborted) {
  5331. return;
  5332. }
  5333. this.onReceiveData({
  5334. chunk: data,
  5335. begin
  5336. });
  5337. });
  5338. }
  5339. requestAllChunks() {
  5340. let noFetch = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  5341. if (!noFetch) {
  5342. const missingChunks = this.stream.getMissingChunks();
  5343. this._requestChunks(missingChunks);
  5344. }
  5345. return this._loadedStreamCapability.promise;
  5346. }
  5347. _requestChunks(chunks) {
  5348. const requestId = this.currRequestId++;
  5349. const chunksNeeded = new Set();
  5350. this._chunksNeededByRequest.set(requestId, chunksNeeded);
  5351. for (const chunk of chunks) {
  5352. if (!this.stream.hasChunk(chunk)) {
  5353. chunksNeeded.add(chunk);
  5354. }
  5355. }
  5356. if (chunksNeeded.size === 0) {
  5357. return Promise.resolve();
  5358. }
  5359. const capability = new _util.PromiseCapability();
  5360. this._promisesByRequest.set(requestId, capability);
  5361. const chunksToRequest = [];
  5362. for (const chunk of chunksNeeded) {
  5363. let requestIds = this._requestsByChunk.get(chunk);
  5364. if (!requestIds) {
  5365. requestIds = [];
  5366. this._requestsByChunk.set(chunk, requestIds);
  5367. chunksToRequest.push(chunk);
  5368. }
  5369. requestIds.push(requestId);
  5370. }
  5371. if (chunksToRequest.length > 0) {
  5372. const groupedChunksToRequest = this.groupChunks(chunksToRequest);
  5373. for (const groupedChunk of groupedChunksToRequest) {
  5374. const begin = groupedChunk.beginChunk * this.chunkSize;
  5375. const end = Math.min(groupedChunk.endChunk * this.chunkSize, this.length);
  5376. this.sendRequest(begin, end).catch(capability.reject);
  5377. }
  5378. }
  5379. return capability.promise.catch(reason => {
  5380. if (this.aborted) {
  5381. return;
  5382. }
  5383. throw reason;
  5384. });
  5385. }
  5386. getStream() {
  5387. return this.stream;
  5388. }
  5389. requestRange(begin, end) {
  5390. end = Math.min(end, this.length);
  5391. const beginChunk = this.getBeginChunk(begin);
  5392. const endChunk = this.getEndChunk(end);
  5393. const chunks = [];
  5394. for (let chunk = beginChunk; chunk < endChunk; ++chunk) {
  5395. chunks.push(chunk);
  5396. }
  5397. return this._requestChunks(chunks);
  5398. }
  5399. requestRanges() {
  5400. let ranges = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
  5401. const chunksToRequest = [];
  5402. for (const range of ranges) {
  5403. const beginChunk = this.getBeginChunk(range.begin);
  5404. const endChunk = this.getEndChunk(range.end);
  5405. for (let chunk = beginChunk; chunk < endChunk; ++chunk) {
  5406. if (!chunksToRequest.includes(chunk)) {
  5407. chunksToRequest.push(chunk);
  5408. }
  5409. }
  5410. }
  5411. chunksToRequest.sort(function (a, b) {
  5412. return a - b;
  5413. });
  5414. return this._requestChunks(chunksToRequest);
  5415. }
  5416. groupChunks(chunks) {
  5417. const groupedChunks = [];
  5418. let beginChunk = -1;
  5419. let prevChunk = -1;
  5420. for (let i = 0, ii = chunks.length; i < ii; ++i) {
  5421. const chunk = chunks[i];
  5422. if (beginChunk < 0) {
  5423. beginChunk = chunk;
  5424. }
  5425. if (prevChunk >= 0 && prevChunk + 1 !== chunk) {
  5426. groupedChunks.push({
  5427. beginChunk,
  5428. endChunk: prevChunk + 1
  5429. });
  5430. beginChunk = chunk;
  5431. }
  5432. if (i + 1 === chunks.length) {
  5433. groupedChunks.push({
  5434. beginChunk,
  5435. endChunk: chunk + 1
  5436. });
  5437. }
  5438. prevChunk = chunk;
  5439. }
  5440. return groupedChunks;
  5441. }
  5442. onProgress(args) {
  5443. this.msgHandler.send("DocProgress", {
  5444. loaded: this.stream.numChunksLoaded * this.chunkSize + args.loaded,
  5445. total: this.length
  5446. });
  5447. }
  5448. onReceiveData(args) {
  5449. const chunk = args.chunk;
  5450. const isProgressive = args.begin === undefined;
  5451. const begin = isProgressive ? this.progressiveDataLength : args.begin;
  5452. const end = begin + chunk.byteLength;
  5453. const beginChunk = Math.floor(begin / this.chunkSize);
  5454. const endChunk = end < this.length ? Math.floor(end / this.chunkSize) : Math.ceil(end / this.chunkSize);
  5455. if (isProgressive) {
  5456. this.stream.onReceiveProgressiveData(chunk);
  5457. this.progressiveDataLength = end;
  5458. } else {
  5459. this.stream.onReceiveData(begin, chunk);
  5460. }
  5461. if (this.stream.isDataLoaded) {
  5462. this._loadedStreamCapability.resolve(this.stream);
  5463. }
  5464. const loadedRequests = [];
  5465. for (let curChunk = beginChunk; curChunk < endChunk; ++curChunk) {
  5466. const requestIds = this._requestsByChunk.get(curChunk);
  5467. if (!requestIds) {
  5468. continue;
  5469. }
  5470. this._requestsByChunk.delete(curChunk);
  5471. for (const requestId of requestIds) {
  5472. const chunksNeeded = this._chunksNeededByRequest.get(requestId);
  5473. if (chunksNeeded.has(curChunk)) {
  5474. chunksNeeded.delete(curChunk);
  5475. }
  5476. if (chunksNeeded.size > 0) {
  5477. continue;
  5478. }
  5479. loadedRequests.push(requestId);
  5480. }
  5481. }
  5482. if (!this.disableAutoFetch && this._requestsByChunk.size === 0) {
  5483. let nextEmptyChunk;
  5484. if (this.stream.numChunksLoaded === 1) {
  5485. const lastChunk = this.stream.numChunks - 1;
  5486. if (!this.stream.hasChunk(lastChunk)) {
  5487. nextEmptyChunk = lastChunk;
  5488. }
  5489. } else {
  5490. nextEmptyChunk = this.stream.nextEmptyChunk(endChunk);
  5491. }
  5492. if (Number.isInteger(nextEmptyChunk)) {
  5493. this._requestChunks([nextEmptyChunk]);
  5494. }
  5495. }
  5496. for (const requestId of loadedRequests) {
  5497. const capability = this._promisesByRequest.get(requestId);
  5498. this._promisesByRequest.delete(requestId);
  5499. capability.resolve();
  5500. }
  5501. this.msgHandler.send("DocProgress", {
  5502. loaded: this.stream.numChunksLoaded * this.chunkSize,
  5503. total: this.length
  5504. });
  5505. }
  5506. onError(err) {
  5507. this._loadedStreamCapability.reject(err);
  5508. }
  5509. getBeginChunk(begin) {
  5510. return Math.floor(begin / this.chunkSize);
  5511. }
  5512. getEndChunk(end) {
  5513. return Math.floor((end - 1) / this.chunkSize) + 1;
  5514. }
  5515. abort(reason) {
  5516. this.aborted = true;
  5517. this.pdfNetworkStream?.cancelAllRequests(reason);
  5518. for (const capability of this._promisesByRequest.values()) {
  5519. capability.reject(reason);
  5520. }
  5521. }
  5522. }
  5523. exports.ChunkedStreamManager = ChunkedStreamManager;
  5524. /***/ }),
  5525. /* 155 */
  5526. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  5527. Object.defineProperty(exports, "__esModule", ({
  5528. value: true
  5529. }));
  5530. exports.StringStream = exports.Stream = exports.NullStream = void 0;
  5531. __w_pdfjs_require__(84);
  5532. __w_pdfjs_require__(93);
  5533. __w_pdfjs_require__(94);
  5534. __w_pdfjs_require__(97);
  5535. __w_pdfjs_require__(99);
  5536. __w_pdfjs_require__(101);
  5537. __w_pdfjs_require__(105);
  5538. __w_pdfjs_require__(108);
  5539. __w_pdfjs_require__(115);
  5540. var _base_stream = __w_pdfjs_require__(152);
  5541. var _util = __w_pdfjs_require__(145);
  5542. class Stream extends _base_stream.BaseStream {
  5543. constructor(arrayBuffer, start, length, dict) {
  5544. super();
  5545. this.bytes = arrayBuffer instanceof Uint8Array ? arrayBuffer : new Uint8Array(arrayBuffer);
  5546. this.start = start || 0;
  5547. this.pos = this.start;
  5548. this.end = start + length || this.bytes.length;
  5549. this.dict = dict;
  5550. }
  5551. get length() {
  5552. return this.end - this.start;
  5553. }
  5554. get isEmpty() {
  5555. return this.length === 0;
  5556. }
  5557. getByte() {
  5558. if (this.pos >= this.end) {
  5559. return -1;
  5560. }
  5561. return this.bytes[this.pos++];
  5562. }
  5563. getBytes(length) {
  5564. const bytes = this.bytes;
  5565. const pos = this.pos;
  5566. const strEnd = this.end;
  5567. if (!length) {
  5568. return bytes.subarray(pos, strEnd);
  5569. }
  5570. let end = pos + length;
  5571. if (end > strEnd) {
  5572. end = strEnd;
  5573. }
  5574. this.pos = end;
  5575. return bytes.subarray(pos, end);
  5576. }
  5577. getByteRange(begin, end) {
  5578. if (begin < 0) {
  5579. begin = 0;
  5580. }
  5581. if (end > this.end) {
  5582. end = this.end;
  5583. }
  5584. return this.bytes.subarray(begin, end);
  5585. }
  5586. reset() {
  5587. this.pos = this.start;
  5588. }
  5589. moveStart() {
  5590. this.start = this.pos;
  5591. }
  5592. makeSubStream(start, length) {
  5593. let dict = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
  5594. return new Stream(this.bytes.buffer, start, length, dict);
  5595. }
  5596. }
  5597. exports.Stream = Stream;
  5598. class StringStream extends Stream {
  5599. constructor(str) {
  5600. super((0, _util.stringToBytes)(str));
  5601. }
  5602. }
  5603. exports.StringStream = StringStream;
  5604. class NullStream extends Stream {
  5605. constructor() {
  5606. super(new Uint8Array(0));
  5607. }
  5608. }
  5609. exports.NullStream = NullStream;
  5610. /***/ }),
  5611. /* 156 */
  5612. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  5613. Object.defineProperty(exports, "__esModule", ({
  5614. value: true
  5615. }));
  5616. exports.Page = exports.PDFDocument = void 0;
  5617. __w_pdfjs_require__(2);
  5618. __w_pdfjs_require__(140);
  5619. __w_pdfjs_require__(116);
  5620. __w_pdfjs_require__(127);
  5621. __w_pdfjs_require__(129);
  5622. __w_pdfjs_require__(132);
  5623. __w_pdfjs_require__(134);
  5624. __w_pdfjs_require__(136);
  5625. __w_pdfjs_require__(138);
  5626. __w_pdfjs_require__(84);
  5627. __w_pdfjs_require__(93);
  5628. __w_pdfjs_require__(94);
  5629. __w_pdfjs_require__(97);
  5630. __w_pdfjs_require__(99);
  5631. __w_pdfjs_require__(101);
  5632. __w_pdfjs_require__(105);
  5633. __w_pdfjs_require__(108);
  5634. __w_pdfjs_require__(115);
  5635. var _util = __w_pdfjs_require__(145);
  5636. var _annotation = __w_pdfjs_require__(157);
  5637. var _core_utils = __w_pdfjs_require__(150);
  5638. var _primitives = __w_pdfjs_require__(151);
  5639. var _xfa_fonts = __w_pdfjs_require__(202);
  5640. var _base_stream = __w_pdfjs_require__(152);
  5641. var _crypto = __w_pdfjs_require__(219);
  5642. var _catalog = __w_pdfjs_require__(221);
  5643. var _cleanup_helper = __w_pdfjs_require__(223);
  5644. var _dataset_reader = __w_pdfjs_require__(256);
  5645. var _parser = __w_pdfjs_require__(167);
  5646. var _stream = __w_pdfjs_require__(155);
  5647. var _object_loader = __w_pdfjs_require__(227);
  5648. var _operator_list = __w_pdfjs_require__(215);
  5649. var _evaluator = __w_pdfjs_require__(164);
  5650. var _decode_stream = __w_pdfjs_require__(169);
  5651. var _struct_tree = __w_pdfjs_require__(226);
  5652. var _writer = __w_pdfjs_require__(217);
  5653. var _factory = __w_pdfjs_require__(228);
  5654. var _xref = __w_pdfjs_require__(257);
  5655. const DEFAULT_USER_UNIT = 1.0;
  5656. const LETTER_SIZE_MEDIABOX = [0, 0, 612, 792];
  5657. class Page {
  5658. constructor(_ref) {
  5659. let {
  5660. pdfManager,
  5661. xref,
  5662. pageIndex,
  5663. pageDict,
  5664. ref,
  5665. globalIdFactory,
  5666. fontCache,
  5667. builtInCMapCache,
  5668. standardFontDataCache,
  5669. globalImageCache,
  5670. systemFontCache,
  5671. nonBlendModesSet,
  5672. xfaFactory
  5673. } = _ref;
  5674. this.pdfManager = pdfManager;
  5675. this.pageIndex = pageIndex;
  5676. this.pageDict = pageDict;
  5677. this.xref = xref;
  5678. this.ref = ref;
  5679. this.fontCache = fontCache;
  5680. this.builtInCMapCache = builtInCMapCache;
  5681. this.standardFontDataCache = standardFontDataCache;
  5682. this.globalImageCache = globalImageCache;
  5683. this.systemFontCache = systemFontCache;
  5684. this.nonBlendModesSet = nonBlendModesSet;
  5685. this.evaluatorOptions = pdfManager.evaluatorOptions;
  5686. this.resourcesPromise = null;
  5687. this.xfaFactory = xfaFactory;
  5688. const idCounters = {
  5689. obj: 0
  5690. };
  5691. this._localIdFactory = class extends globalIdFactory {
  5692. static createObjId() {
  5693. return `p${pageIndex}_${++idCounters.obj}`;
  5694. }
  5695. static getPageObjId() {
  5696. return `p${ref.toString()}`;
  5697. }
  5698. };
  5699. }
  5700. _getInheritableProperty(key) {
  5701. let getArray = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  5702. const value = (0, _core_utils.getInheritableProperty)({
  5703. dict: this.pageDict,
  5704. key,
  5705. getArray,
  5706. stopWhenFound: false
  5707. });
  5708. if (!Array.isArray(value)) {
  5709. return value;
  5710. }
  5711. if (value.length === 1 || !(value[0] instanceof _primitives.Dict)) {
  5712. return value[0];
  5713. }
  5714. return _primitives.Dict.merge({
  5715. xref: this.xref,
  5716. dictArray: value
  5717. });
  5718. }
  5719. get content() {
  5720. return this.pageDict.getArray("Contents");
  5721. }
  5722. get resources() {
  5723. const resources = this._getInheritableProperty("Resources");
  5724. return (0, _util.shadow)(this, "resources", resources instanceof _primitives.Dict ? resources : _primitives.Dict.empty);
  5725. }
  5726. _getBoundingBox(name) {
  5727. if (this.xfaData) {
  5728. return this.xfaData.bbox;
  5729. }
  5730. let box = this._getInheritableProperty(name, true);
  5731. if (Array.isArray(box) && box.length === 4) {
  5732. box = _util.Util.normalizeRect(box);
  5733. if (box[2] - box[0] > 0 && box[3] - box[1] > 0) {
  5734. return box;
  5735. }
  5736. (0, _util.warn)(`Empty, or invalid, /${name} entry.`);
  5737. }
  5738. return null;
  5739. }
  5740. get mediaBox() {
  5741. return (0, _util.shadow)(this, "mediaBox", this._getBoundingBox("MediaBox") || LETTER_SIZE_MEDIABOX);
  5742. }
  5743. get cropBox() {
  5744. return (0, _util.shadow)(this, "cropBox", this._getBoundingBox("CropBox") || this.mediaBox);
  5745. }
  5746. get userUnit() {
  5747. let obj = this.pageDict.get("UserUnit");
  5748. if (typeof obj !== "number" || obj <= 0) {
  5749. obj = DEFAULT_USER_UNIT;
  5750. }
  5751. return (0, _util.shadow)(this, "userUnit", obj);
  5752. }
  5753. get view() {
  5754. const {
  5755. cropBox,
  5756. mediaBox
  5757. } = this;
  5758. if (cropBox !== mediaBox && !(0, _util.isArrayEqual)(cropBox, mediaBox)) {
  5759. const box = _util.Util.intersect(cropBox, mediaBox);
  5760. if (box && box[2] - box[0] > 0 && box[3] - box[1] > 0) {
  5761. return (0, _util.shadow)(this, "view", box);
  5762. }
  5763. (0, _util.warn)("Empty /CropBox and /MediaBox intersection.");
  5764. }
  5765. return (0, _util.shadow)(this, "view", mediaBox);
  5766. }
  5767. get rotate() {
  5768. let rotate = this._getInheritableProperty("Rotate") || 0;
  5769. if (rotate % 90 !== 0) {
  5770. rotate = 0;
  5771. } else if (rotate >= 360) {
  5772. rotate %= 360;
  5773. } else if (rotate < 0) {
  5774. rotate = (rotate % 360 + 360) % 360;
  5775. }
  5776. return (0, _util.shadow)(this, "rotate", rotate);
  5777. }
  5778. _onSubStreamError(reason, objId) {
  5779. if (this.evaluatorOptions.ignoreErrors) {
  5780. (0, _util.warn)(`getContentStream - ignoring sub-stream (${objId}): "${reason}".`);
  5781. return;
  5782. }
  5783. throw reason;
  5784. }
  5785. getContentStream() {
  5786. return this.pdfManager.ensure(this, "content").then(content => {
  5787. if (content instanceof _base_stream.BaseStream) {
  5788. return content;
  5789. }
  5790. if (Array.isArray(content)) {
  5791. return new _decode_stream.StreamsSequenceStream(content, this._onSubStreamError.bind(this));
  5792. }
  5793. return new _stream.NullStream();
  5794. });
  5795. }
  5796. get xfaData() {
  5797. return (0, _util.shadow)(this, "xfaData", this.xfaFactory ? {
  5798. bbox: this.xfaFactory.getBoundingBox(this.pageIndex)
  5799. } : null);
  5800. }
  5801. #replaceIdByRef(annotations, deletedAnnotations, existingAnnotations) {
  5802. for (const annotation of annotations) {
  5803. if (annotation.id) {
  5804. const ref = _primitives.Ref.fromString(annotation.id);
  5805. if (!ref) {
  5806. (0, _util.warn)(`A non-linked annotation cannot be modified: ${annotation.id}`);
  5807. continue;
  5808. }
  5809. if (annotation.deleted) {
  5810. deletedAnnotations.put(ref);
  5811. continue;
  5812. }
  5813. existingAnnotations?.put(ref);
  5814. annotation.ref = ref;
  5815. delete annotation.id;
  5816. }
  5817. }
  5818. }
  5819. async saveNewAnnotations(handler, task, annotations, imagePromises) {
  5820. if (this.xfaFactory) {
  5821. throw new Error("XFA: Cannot save new annotations.");
  5822. }
  5823. const partialEvaluator = new _evaluator.PartialEvaluator({
  5824. xref: this.xref,
  5825. handler,
  5826. pageIndex: this.pageIndex,
  5827. idFactory: this._localIdFactory,
  5828. fontCache: this.fontCache,
  5829. builtInCMapCache: this.builtInCMapCache,
  5830. standardFontDataCache: this.standardFontDataCache,
  5831. globalImageCache: this.globalImageCache,
  5832. systemFontCache: this.systemFontCache,
  5833. options: this.evaluatorOptions
  5834. });
  5835. const deletedAnnotations = new _primitives.RefSet();
  5836. const existingAnnotations = new _primitives.RefSet();
  5837. this.#replaceIdByRef(annotations, deletedAnnotations, existingAnnotations);
  5838. const pageDict = this.pageDict;
  5839. const annotationsArray = this.annotations.filter(a => !(a instanceof _primitives.Ref && deletedAnnotations.has(a)));
  5840. const newData = await _annotation.AnnotationFactory.saveNewAnnotations(partialEvaluator, task, annotations, imagePromises);
  5841. for (const {
  5842. ref
  5843. } of newData.annotations) {
  5844. if (ref instanceof _primitives.Ref && !existingAnnotations.has(ref)) {
  5845. annotationsArray.push(ref);
  5846. }
  5847. }
  5848. const savedDict = pageDict.get("Annots");
  5849. pageDict.set("Annots", annotationsArray);
  5850. const buffer = [];
  5851. let transform = null;
  5852. if (this.xref.encrypt) {
  5853. transform = this.xref.encrypt.createCipherTransform(this.ref.num, this.ref.gen);
  5854. }
  5855. await (0, _writer.writeObject)(this.ref, pageDict, buffer, transform);
  5856. if (savedDict) {
  5857. pageDict.set("Annots", savedDict);
  5858. }
  5859. const objects = newData.dependencies;
  5860. objects.push({
  5861. ref: this.ref,
  5862. data: buffer.join("")
  5863. }, ...newData.annotations);
  5864. return objects;
  5865. }
  5866. save(handler, task, annotationStorage) {
  5867. const partialEvaluator = new _evaluator.PartialEvaluator({
  5868. xref: this.xref,
  5869. handler,
  5870. pageIndex: this.pageIndex,
  5871. idFactory: this._localIdFactory,
  5872. fontCache: this.fontCache,
  5873. builtInCMapCache: this.builtInCMapCache,
  5874. standardFontDataCache: this.standardFontDataCache,
  5875. globalImageCache: this.globalImageCache,
  5876. systemFontCache: this.systemFontCache,
  5877. options: this.evaluatorOptions
  5878. });
  5879. return this._parsedAnnotations.then(function (annotations) {
  5880. const newRefsPromises = [];
  5881. for (const annotation of annotations) {
  5882. if (!annotation.mustBePrinted(annotationStorage)) {
  5883. continue;
  5884. }
  5885. newRefsPromises.push(annotation.save(partialEvaluator, task, annotationStorage).catch(function (reason) {
  5886. (0, _util.warn)("save - ignoring annotation data during " + `"${task.name}" task: "${reason}".`);
  5887. return null;
  5888. }));
  5889. }
  5890. return Promise.all(newRefsPromises).then(function (newRefs) {
  5891. return newRefs.filter(newRef => !!newRef);
  5892. });
  5893. });
  5894. }
  5895. loadResources(keys) {
  5896. if (!this.resourcesPromise) {
  5897. this.resourcesPromise = this.pdfManager.ensure(this, "resources");
  5898. }
  5899. return this.resourcesPromise.then(() => {
  5900. const objectLoader = new _object_loader.ObjectLoader(this.resources, keys, this.xref);
  5901. return objectLoader.load();
  5902. });
  5903. }
  5904. getOperatorList(_ref2) {
  5905. let {
  5906. handler,
  5907. sink,
  5908. task,
  5909. intent,
  5910. cacheKey,
  5911. annotationStorage = null
  5912. } = _ref2;
  5913. const contentStreamPromise = this.getContentStream();
  5914. const resourcesPromise = this.loadResources(["ColorSpace", "ExtGState", "Font", "Pattern", "Properties", "Shading", "XObject"]);
  5915. const partialEvaluator = new _evaluator.PartialEvaluator({
  5916. xref: this.xref,
  5917. handler,
  5918. pageIndex: this.pageIndex,
  5919. idFactory: this._localIdFactory,
  5920. fontCache: this.fontCache,
  5921. builtInCMapCache: this.builtInCMapCache,
  5922. standardFontDataCache: this.standardFontDataCache,
  5923. globalImageCache: this.globalImageCache,
  5924. systemFontCache: this.systemFontCache,
  5925. options: this.evaluatorOptions
  5926. });
  5927. const newAnnotationsByPage = !this.xfaFactory ? (0, _core_utils.getNewAnnotationsMap)(annotationStorage) : null;
  5928. let deletedAnnotations = null;
  5929. let newAnnotationsPromise = Promise.resolve(null);
  5930. if (newAnnotationsByPage) {
  5931. let imagePromises;
  5932. const newAnnotations = newAnnotationsByPage.get(this.pageIndex);
  5933. if (newAnnotations) {
  5934. const missingBitmaps = new Set();
  5935. for (const {
  5936. bitmapId,
  5937. bitmap
  5938. } of newAnnotations) {
  5939. if (bitmapId && !bitmap && !missingBitmaps.has(bitmapId)) {
  5940. missingBitmaps.add(bitmapId);
  5941. }
  5942. }
  5943. const {
  5944. isOffscreenCanvasSupported
  5945. } = this.evaluatorOptions;
  5946. if (missingBitmaps.size > 0) {
  5947. const annotationWithBitmaps = newAnnotations.slice();
  5948. for (const [key, annotation] of annotationStorage) {
  5949. if (!key.startsWith(_util.AnnotationEditorPrefix)) {
  5950. continue;
  5951. }
  5952. if (annotation.bitmap && missingBitmaps.has(annotation.bitmapId)) {
  5953. annotationWithBitmaps.push(annotation);
  5954. }
  5955. }
  5956. imagePromises = _annotation.AnnotationFactory.generateImages(annotationWithBitmaps, this.xref, isOffscreenCanvasSupported);
  5957. } else {
  5958. imagePromises = _annotation.AnnotationFactory.generateImages(newAnnotations, this.xref, isOffscreenCanvasSupported);
  5959. }
  5960. deletedAnnotations = new _primitives.RefSet();
  5961. this.#replaceIdByRef(newAnnotations, deletedAnnotations, null);
  5962. newAnnotationsPromise = _annotation.AnnotationFactory.printNewAnnotations(partialEvaluator, task, newAnnotations, imagePromises);
  5963. }
  5964. }
  5965. const dataPromises = Promise.all([contentStreamPromise, resourcesPromise]);
  5966. const pageListPromise = dataPromises.then(_ref3 => {
  5967. let [contentStream] = _ref3;
  5968. const opList = new _operator_list.OperatorList(intent, sink);
  5969. handler.send("StartRenderPage", {
  5970. transparency: partialEvaluator.hasBlendModes(this.resources, this.nonBlendModesSet),
  5971. pageIndex: this.pageIndex,
  5972. cacheKey
  5973. });
  5974. return partialEvaluator.getOperatorList({
  5975. stream: contentStream,
  5976. task,
  5977. resources: this.resources,
  5978. operatorList: opList
  5979. }).then(function () {
  5980. return opList;
  5981. });
  5982. });
  5983. return Promise.all([pageListPromise, this._parsedAnnotations, newAnnotationsPromise]).then(function (_ref4) {
  5984. let [pageOpList, annotations, newAnnotations] = _ref4;
  5985. if (newAnnotations) {
  5986. annotations = annotations.filter(a => !(a.ref && deletedAnnotations.has(a.ref)));
  5987. for (let i = 0, ii = newAnnotations.length; i < ii; i++) {
  5988. const newAnnotation = newAnnotations[i];
  5989. if (newAnnotation.refToReplace) {
  5990. const j = annotations.findIndex(a => a.ref && (0, _primitives.isRefsEqual)(a.ref, newAnnotation.refToReplace));
  5991. if (j >= 0) {
  5992. annotations.splice(j, 1, newAnnotation);
  5993. newAnnotations.splice(i--, 1);
  5994. ii--;
  5995. }
  5996. }
  5997. }
  5998. annotations = annotations.concat(newAnnotations);
  5999. }
  6000. if (annotations.length === 0 || intent & _util.RenderingIntentFlag.ANNOTATIONS_DISABLE) {
  6001. pageOpList.flush(true);
  6002. return {
  6003. length: pageOpList.totalLength
  6004. };
  6005. }
  6006. const renderForms = !!(intent & _util.RenderingIntentFlag.ANNOTATIONS_FORMS),
  6007. intentAny = !!(intent & _util.RenderingIntentFlag.ANY),
  6008. intentDisplay = !!(intent & _util.RenderingIntentFlag.DISPLAY),
  6009. intentPrint = !!(intent & _util.RenderingIntentFlag.PRINT);
  6010. const opListPromises = [];
  6011. for (const annotation of annotations) {
  6012. if (intentAny || intentDisplay && annotation.mustBeViewed(annotationStorage, renderForms) || intentPrint && annotation.mustBePrinted(annotationStorage)) {
  6013. opListPromises.push(annotation.getOperatorList(partialEvaluator, task, intent, renderForms, annotationStorage).catch(function (reason) {
  6014. (0, _util.warn)("getOperatorList - ignoring annotation data during " + `"${task.name}" task: "${reason}".`);
  6015. return {
  6016. opList: null,
  6017. separateForm: false,
  6018. separateCanvas: false
  6019. };
  6020. }));
  6021. }
  6022. }
  6023. return Promise.all(opListPromises).then(function (opLists) {
  6024. let form = false,
  6025. canvas = false;
  6026. for (const {
  6027. opList,
  6028. separateForm,
  6029. separateCanvas
  6030. } of opLists) {
  6031. pageOpList.addOpList(opList);
  6032. form ||= separateForm;
  6033. canvas ||= separateCanvas;
  6034. }
  6035. pageOpList.flush(true, {
  6036. form,
  6037. canvas
  6038. });
  6039. return {
  6040. length: pageOpList.totalLength
  6041. };
  6042. });
  6043. });
  6044. }
  6045. extractTextContent(_ref5) {
  6046. let {
  6047. handler,
  6048. task,
  6049. includeMarkedContent,
  6050. disableNormalization,
  6051. sink
  6052. } = _ref5;
  6053. const contentStreamPromise = this.getContentStream();
  6054. const resourcesPromise = this.loadResources(["ExtGState", "Font", "Properties", "XObject"]);
  6055. const dataPromises = Promise.all([contentStreamPromise, resourcesPromise]);
  6056. return dataPromises.then(_ref6 => {
  6057. let [contentStream] = _ref6;
  6058. const partialEvaluator = new _evaluator.PartialEvaluator({
  6059. xref: this.xref,
  6060. handler,
  6061. pageIndex: this.pageIndex,
  6062. idFactory: this._localIdFactory,
  6063. fontCache: this.fontCache,
  6064. builtInCMapCache: this.builtInCMapCache,
  6065. standardFontDataCache: this.standardFontDataCache,
  6066. globalImageCache: this.globalImageCache,
  6067. systemFontCache: this.systemFontCache,
  6068. options: this.evaluatorOptions
  6069. });
  6070. return partialEvaluator.getTextContent({
  6071. stream: contentStream,
  6072. task,
  6073. resources: this.resources,
  6074. includeMarkedContent,
  6075. disableNormalization,
  6076. sink,
  6077. viewBox: this.view
  6078. });
  6079. });
  6080. }
  6081. async getStructTree() {
  6082. const structTreeRoot = await this.pdfManager.ensureCatalog("structTreeRoot");
  6083. if (!structTreeRoot) {
  6084. return null;
  6085. }
  6086. const structTree = await this.pdfManager.ensure(this, "_parseStructTree", [structTreeRoot]);
  6087. return structTree.serializable;
  6088. }
  6089. _parseStructTree(structTreeRoot) {
  6090. const tree = new _struct_tree.StructTreePage(structTreeRoot, this.pageDict);
  6091. tree.parse();
  6092. return tree;
  6093. }
  6094. async getAnnotationsData(handler, task, intent) {
  6095. const annotations = await this._parsedAnnotations;
  6096. if (annotations.length === 0) {
  6097. return [];
  6098. }
  6099. const annotationsData = [],
  6100. textContentPromises = [];
  6101. let partialEvaluator;
  6102. const intentAny = !!(intent & _util.RenderingIntentFlag.ANY),
  6103. intentDisplay = !!(intent & _util.RenderingIntentFlag.DISPLAY),
  6104. intentPrint = !!(intent & _util.RenderingIntentFlag.PRINT);
  6105. for (const annotation of annotations) {
  6106. const isVisible = intentAny || intentDisplay && annotation.viewable;
  6107. if (isVisible || intentPrint && annotation.printable) {
  6108. annotationsData.push(annotation.data);
  6109. }
  6110. if (annotation.hasTextContent && isVisible) {
  6111. partialEvaluator ||= new _evaluator.PartialEvaluator({
  6112. xref: this.xref,
  6113. handler,
  6114. pageIndex: this.pageIndex,
  6115. idFactory: this._localIdFactory,
  6116. fontCache: this.fontCache,
  6117. builtInCMapCache: this.builtInCMapCache,
  6118. standardFontDataCache: this.standardFontDataCache,
  6119. globalImageCache: this.globalImageCache,
  6120. systemFontCache: this.systemFontCache,
  6121. options: this.evaluatorOptions
  6122. });
  6123. textContentPromises.push(annotation.extractTextContent(partialEvaluator, task, [-Infinity, -Infinity, Infinity, Infinity]).catch(function (reason) {
  6124. (0, _util.warn)(`getAnnotationsData - ignoring textContent during "${task.name}" task: "${reason}".`);
  6125. }));
  6126. }
  6127. }
  6128. await Promise.all(textContentPromises);
  6129. return annotationsData;
  6130. }
  6131. get annotations() {
  6132. const annots = this._getInheritableProperty("Annots");
  6133. return (0, _util.shadow)(this, "annotations", Array.isArray(annots) ? annots : []);
  6134. }
  6135. get _parsedAnnotations() {
  6136. const parsedAnnotations = this.pdfManager.ensure(this, "annotations").then(() => {
  6137. const annotationPromises = [];
  6138. for (const annotationRef of this.annotations) {
  6139. annotationPromises.push(_annotation.AnnotationFactory.create(this.xref, annotationRef, this.pdfManager, this._localIdFactory, false).catch(function (reason) {
  6140. (0, _util.warn)(`_parsedAnnotations: "${reason}".`);
  6141. return null;
  6142. }));
  6143. }
  6144. return Promise.all(annotationPromises).then(function (annotations) {
  6145. if (annotations.length === 0) {
  6146. return annotations;
  6147. }
  6148. const sortedAnnotations = [];
  6149. let popupAnnotations;
  6150. for (const annotation of annotations) {
  6151. if (!annotation) {
  6152. continue;
  6153. }
  6154. if (annotation instanceof _annotation.PopupAnnotation) {
  6155. (popupAnnotations ||= []).push(annotation);
  6156. continue;
  6157. }
  6158. sortedAnnotations.push(annotation);
  6159. }
  6160. if (popupAnnotations) {
  6161. sortedAnnotations.push(...popupAnnotations);
  6162. }
  6163. return sortedAnnotations;
  6164. });
  6165. });
  6166. return (0, _util.shadow)(this, "_parsedAnnotations", parsedAnnotations);
  6167. }
  6168. get jsActions() {
  6169. const actions = (0, _core_utils.collectActions)(this.xref, this.pageDict, _util.PageActionEventType);
  6170. return (0, _util.shadow)(this, "jsActions", actions);
  6171. }
  6172. }
  6173. exports.Page = Page;
  6174. const PDF_HEADER_SIGNATURE = new Uint8Array([0x25, 0x50, 0x44, 0x46, 0x2d]);
  6175. const STARTXREF_SIGNATURE = new Uint8Array([0x73, 0x74, 0x61, 0x72, 0x74, 0x78, 0x72, 0x65, 0x66]);
  6176. const ENDOBJ_SIGNATURE = new Uint8Array([0x65, 0x6e, 0x64, 0x6f, 0x62, 0x6a]);
  6177. const FINGERPRINT_FIRST_BYTES = 1024;
  6178. const EMPTY_FINGERPRINT = "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00";
  6179. function find(stream, signature) {
  6180. let limit = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1024;
  6181. let backwards = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
  6182. const signatureLength = signature.length;
  6183. const scanBytes = stream.peekBytes(limit);
  6184. const scanLength = scanBytes.length - signatureLength;
  6185. if (scanLength <= 0) {
  6186. return false;
  6187. }
  6188. if (backwards) {
  6189. const signatureEnd = signatureLength - 1;
  6190. let pos = scanBytes.length - 1;
  6191. while (pos >= signatureEnd) {
  6192. let j = 0;
  6193. while (j < signatureLength && scanBytes[pos - j] === signature[signatureEnd - j]) {
  6194. j++;
  6195. }
  6196. if (j >= signatureLength) {
  6197. stream.pos += pos - signatureEnd;
  6198. return true;
  6199. }
  6200. pos--;
  6201. }
  6202. } else {
  6203. let pos = 0;
  6204. while (pos <= scanLength) {
  6205. let j = 0;
  6206. while (j < signatureLength && scanBytes[pos + j] === signature[j]) {
  6207. j++;
  6208. }
  6209. if (j >= signatureLength) {
  6210. stream.pos += pos;
  6211. return true;
  6212. }
  6213. pos++;
  6214. }
  6215. }
  6216. return false;
  6217. }
  6218. class PDFDocument {
  6219. constructor(pdfManager, stream) {
  6220. if (stream.length <= 0) {
  6221. throw new _util.InvalidPDFException("The PDF file is empty, i.e. its size is zero bytes.");
  6222. }
  6223. this.pdfManager = pdfManager;
  6224. this.stream = stream;
  6225. this.xref = new _xref.XRef(stream, pdfManager);
  6226. this._pagePromises = new Map();
  6227. this._version = null;
  6228. const idCounters = {
  6229. font: 0
  6230. };
  6231. this._globalIdFactory = class {
  6232. static getDocId() {
  6233. return `g_${pdfManager.docId}`;
  6234. }
  6235. static createFontId() {
  6236. return `f${++idCounters.font}`;
  6237. }
  6238. static createObjId() {
  6239. (0, _util.unreachable)("Abstract method `createObjId` called.");
  6240. }
  6241. static getPageObjId() {
  6242. (0, _util.unreachable)("Abstract method `getPageObjId` called.");
  6243. }
  6244. };
  6245. }
  6246. parse(recoveryMode) {
  6247. this.xref.parse(recoveryMode);
  6248. this.catalog = new _catalog.Catalog(this.pdfManager, this.xref);
  6249. }
  6250. get linearization() {
  6251. let linearization = null;
  6252. try {
  6253. linearization = _parser.Linearization.create(this.stream);
  6254. } catch (err) {
  6255. if (err instanceof _core_utils.MissingDataException) {
  6256. throw err;
  6257. }
  6258. (0, _util.info)(err);
  6259. }
  6260. return (0, _util.shadow)(this, "linearization", linearization);
  6261. }
  6262. get startXRef() {
  6263. const stream = this.stream;
  6264. let startXRef = 0;
  6265. if (this.linearization) {
  6266. stream.reset();
  6267. if (find(stream, ENDOBJ_SIGNATURE)) {
  6268. startXRef = stream.pos + 6 - stream.start;
  6269. }
  6270. } else {
  6271. const step = 1024;
  6272. const startXRefLength = STARTXREF_SIGNATURE.length;
  6273. let found = false,
  6274. pos = stream.end;
  6275. while (!found && pos > 0) {
  6276. pos -= step - startXRefLength;
  6277. if (pos < 0) {
  6278. pos = 0;
  6279. }
  6280. stream.pos = pos;
  6281. found = find(stream, STARTXREF_SIGNATURE, step, true);
  6282. }
  6283. if (found) {
  6284. stream.skip(9);
  6285. let ch;
  6286. do {
  6287. ch = stream.getByte();
  6288. } while ((0, _core_utils.isWhiteSpace)(ch));
  6289. let str = "";
  6290. while (ch >= 0x20 && ch <= 0x39) {
  6291. str += String.fromCharCode(ch);
  6292. ch = stream.getByte();
  6293. }
  6294. startXRef = parseInt(str, 10);
  6295. if (isNaN(startXRef)) {
  6296. startXRef = 0;
  6297. }
  6298. }
  6299. }
  6300. return (0, _util.shadow)(this, "startXRef", startXRef);
  6301. }
  6302. checkHeader() {
  6303. const stream = this.stream;
  6304. stream.reset();
  6305. if (!find(stream, PDF_HEADER_SIGNATURE)) {
  6306. return;
  6307. }
  6308. stream.moveStart();
  6309. stream.skip(PDF_HEADER_SIGNATURE.length);
  6310. let version = "",
  6311. ch;
  6312. while ((ch = stream.getByte()) > 0x20 && version.length < 7) {
  6313. version += String.fromCharCode(ch);
  6314. }
  6315. if (_core_utils.PDF_VERSION_REGEXP.test(version)) {
  6316. this._version = version;
  6317. } else {
  6318. (0, _util.warn)(`Invalid PDF header version: ${version}`);
  6319. }
  6320. }
  6321. parseStartXRef() {
  6322. this.xref.setStartXRef(this.startXRef);
  6323. }
  6324. get numPages() {
  6325. let num = 0;
  6326. if (this.catalog.hasActualNumPages) {
  6327. num = this.catalog.numPages;
  6328. } else if (this.xfaFactory) {
  6329. num = this.xfaFactory.getNumPages();
  6330. } else if (this.linearization) {
  6331. num = this.linearization.numPages;
  6332. } else {
  6333. num = this.catalog.numPages;
  6334. }
  6335. return (0, _util.shadow)(this, "numPages", num);
  6336. }
  6337. _hasOnlyDocumentSignatures(fields) {
  6338. let recursionDepth = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
  6339. const RECURSION_LIMIT = 10;
  6340. if (!Array.isArray(fields)) {
  6341. return false;
  6342. }
  6343. return fields.every(field => {
  6344. field = this.xref.fetchIfRef(field);
  6345. if (!(field instanceof _primitives.Dict)) {
  6346. return false;
  6347. }
  6348. if (field.has("Kids")) {
  6349. if (++recursionDepth > RECURSION_LIMIT) {
  6350. (0, _util.warn)("_hasOnlyDocumentSignatures: maximum recursion depth reached");
  6351. return false;
  6352. }
  6353. return this._hasOnlyDocumentSignatures(field.get("Kids"), recursionDepth);
  6354. }
  6355. const isSignature = (0, _primitives.isName)(field.get("FT"), "Sig");
  6356. const rectangle = field.get("Rect");
  6357. const isInvisible = Array.isArray(rectangle) && rectangle.every(value => value === 0);
  6358. return isSignature && isInvisible;
  6359. });
  6360. }
  6361. get _xfaStreams() {
  6362. const acroForm = this.catalog.acroForm;
  6363. if (!acroForm) {
  6364. return null;
  6365. }
  6366. const xfa = acroForm.get("XFA");
  6367. const entries = {
  6368. "xdp:xdp": "",
  6369. template: "",
  6370. datasets: "",
  6371. config: "",
  6372. connectionSet: "",
  6373. localeSet: "",
  6374. stylesheet: "",
  6375. "/xdp:xdp": ""
  6376. };
  6377. if (xfa instanceof _base_stream.BaseStream && !xfa.isEmpty) {
  6378. entries["xdp:xdp"] = xfa;
  6379. return entries;
  6380. }
  6381. if (!Array.isArray(xfa) || xfa.length === 0) {
  6382. return null;
  6383. }
  6384. for (let i = 0, ii = xfa.length; i < ii; i += 2) {
  6385. let name;
  6386. if (i === 0) {
  6387. name = "xdp:xdp";
  6388. } else if (i === ii - 2) {
  6389. name = "/xdp:xdp";
  6390. } else {
  6391. name = xfa[i];
  6392. }
  6393. if (!entries.hasOwnProperty(name)) {
  6394. continue;
  6395. }
  6396. const data = this.xref.fetchIfRef(xfa[i + 1]);
  6397. if (!(data instanceof _base_stream.BaseStream) || data.isEmpty) {
  6398. continue;
  6399. }
  6400. entries[name] = data;
  6401. }
  6402. return entries;
  6403. }
  6404. get xfaDatasets() {
  6405. const streams = this._xfaStreams;
  6406. if (!streams) {
  6407. return (0, _util.shadow)(this, "xfaDatasets", null);
  6408. }
  6409. for (const key of ["datasets", "xdp:xdp"]) {
  6410. const stream = streams[key];
  6411. if (!stream) {
  6412. continue;
  6413. }
  6414. try {
  6415. const str = (0, _util.stringToUTF8String)(stream.getString());
  6416. const data = {
  6417. [key]: str
  6418. };
  6419. return (0, _util.shadow)(this, "xfaDatasets", new _dataset_reader.DatasetReader(data));
  6420. } catch {
  6421. (0, _util.warn)("XFA - Invalid utf-8 string.");
  6422. break;
  6423. }
  6424. }
  6425. return (0, _util.shadow)(this, "xfaDatasets", null);
  6426. }
  6427. get xfaData() {
  6428. const streams = this._xfaStreams;
  6429. if (!streams) {
  6430. return null;
  6431. }
  6432. const data = Object.create(null);
  6433. for (const [key, stream] of Object.entries(streams)) {
  6434. if (!stream) {
  6435. continue;
  6436. }
  6437. try {
  6438. data[key] = (0, _util.stringToUTF8String)(stream.getString());
  6439. } catch {
  6440. (0, _util.warn)("XFA - Invalid utf-8 string.");
  6441. return null;
  6442. }
  6443. }
  6444. return data;
  6445. }
  6446. get xfaFactory() {
  6447. let data;
  6448. if (this.pdfManager.enableXfa && this.catalog.needsRendering && this.formInfo.hasXfa && !this.formInfo.hasAcroForm) {
  6449. data = this.xfaData;
  6450. }
  6451. return (0, _util.shadow)(this, "xfaFactory", data ? new _factory.XFAFactory(data) : null);
  6452. }
  6453. get isPureXfa() {
  6454. return this.xfaFactory ? this.xfaFactory.isValid() : false;
  6455. }
  6456. get htmlForXfa() {
  6457. return this.xfaFactory ? this.xfaFactory.getPages() : null;
  6458. }
  6459. async loadXfaImages() {
  6460. const xfaImagesDict = await this.pdfManager.ensureCatalog("xfaImages");
  6461. if (!xfaImagesDict) {
  6462. return;
  6463. }
  6464. const keys = xfaImagesDict.getKeys();
  6465. const objectLoader = new _object_loader.ObjectLoader(xfaImagesDict, keys, this.xref);
  6466. await objectLoader.load();
  6467. const xfaImages = new Map();
  6468. for (const key of keys) {
  6469. const stream = xfaImagesDict.get(key);
  6470. if (stream instanceof _base_stream.BaseStream) {
  6471. xfaImages.set(key, stream.getBytes());
  6472. }
  6473. }
  6474. this.xfaFactory.setImages(xfaImages);
  6475. }
  6476. async loadXfaFonts(handler, task) {
  6477. const acroForm = await this.pdfManager.ensureCatalog("acroForm");
  6478. if (!acroForm) {
  6479. return;
  6480. }
  6481. const resources = await acroForm.getAsync("DR");
  6482. if (!(resources instanceof _primitives.Dict)) {
  6483. return;
  6484. }
  6485. const objectLoader = new _object_loader.ObjectLoader(resources, ["Font"], this.xref);
  6486. await objectLoader.load();
  6487. const fontRes = resources.get("Font");
  6488. if (!(fontRes instanceof _primitives.Dict)) {
  6489. return;
  6490. }
  6491. const options = Object.assign(Object.create(null), this.pdfManager.evaluatorOptions);
  6492. options.useSystemFonts = false;
  6493. const partialEvaluator = new _evaluator.PartialEvaluator({
  6494. xref: this.xref,
  6495. handler,
  6496. pageIndex: -1,
  6497. idFactory: this._globalIdFactory,
  6498. fontCache: this.catalog.fontCache,
  6499. builtInCMapCache: this.catalog.builtInCMapCache,
  6500. standardFontDataCache: this.catalog.standardFontDataCache,
  6501. options
  6502. });
  6503. const operatorList = new _operator_list.OperatorList();
  6504. const pdfFonts = [];
  6505. const initialState = {
  6506. get font() {
  6507. return pdfFonts.at(-1);
  6508. },
  6509. set font(font) {
  6510. pdfFonts.push(font);
  6511. },
  6512. clone() {
  6513. return this;
  6514. }
  6515. };
  6516. const fonts = new Map();
  6517. fontRes.forEach((fontName, font) => {
  6518. fonts.set(fontName, font);
  6519. });
  6520. const promises = [];
  6521. for (const [fontName, font] of fonts) {
  6522. const descriptor = font.get("FontDescriptor");
  6523. if (!(descriptor instanceof _primitives.Dict)) {
  6524. continue;
  6525. }
  6526. let fontFamily = descriptor.get("FontFamily");
  6527. fontFamily = fontFamily.replaceAll(/[ ]+(\d)/g, "$1");
  6528. const fontWeight = descriptor.get("FontWeight");
  6529. const italicAngle = -descriptor.get("ItalicAngle");
  6530. const cssFontInfo = {
  6531. fontFamily,
  6532. fontWeight,
  6533. italicAngle
  6534. };
  6535. if (!(0, _core_utils.validateCSSFont)(cssFontInfo)) {
  6536. continue;
  6537. }
  6538. promises.push(partialEvaluator.handleSetFont(resources, [_primitives.Name.get(fontName), 1], null, operatorList, task, initialState, null, cssFontInfo).catch(function (reason) {
  6539. (0, _util.warn)(`loadXfaFonts: "${reason}".`);
  6540. return null;
  6541. }));
  6542. }
  6543. await Promise.all(promises);
  6544. const missingFonts = this.xfaFactory.setFonts(pdfFonts);
  6545. if (!missingFonts) {
  6546. return;
  6547. }
  6548. options.ignoreErrors = true;
  6549. promises.length = 0;
  6550. pdfFonts.length = 0;
  6551. const reallyMissingFonts = new Set();
  6552. for (const missing of missingFonts) {
  6553. if (!(0, _xfa_fonts.getXfaFontName)(`${missing}-Regular`)) {
  6554. reallyMissingFonts.add(missing);
  6555. }
  6556. }
  6557. if (reallyMissingFonts.size) {
  6558. missingFonts.push("PdfJS-Fallback");
  6559. }
  6560. for (const missing of missingFonts) {
  6561. if (reallyMissingFonts.has(missing)) {
  6562. continue;
  6563. }
  6564. for (const fontInfo of [{
  6565. name: "Regular",
  6566. fontWeight: 400,
  6567. italicAngle: 0
  6568. }, {
  6569. name: "Bold",
  6570. fontWeight: 700,
  6571. italicAngle: 0
  6572. }, {
  6573. name: "Italic",
  6574. fontWeight: 400,
  6575. italicAngle: 12
  6576. }, {
  6577. name: "BoldItalic",
  6578. fontWeight: 700,
  6579. italicAngle: 12
  6580. }]) {
  6581. const name = `${missing}-${fontInfo.name}`;
  6582. const dict = (0, _xfa_fonts.getXfaFontDict)(name);
  6583. promises.push(partialEvaluator.handleSetFont(resources, [_primitives.Name.get(name), 1], null, operatorList, task, initialState, dict, {
  6584. fontFamily: missing,
  6585. fontWeight: fontInfo.fontWeight,
  6586. italicAngle: fontInfo.italicAngle
  6587. }).catch(function (reason) {
  6588. (0, _util.warn)(`loadXfaFonts: "${reason}".`);
  6589. return null;
  6590. }));
  6591. }
  6592. }
  6593. await Promise.all(promises);
  6594. this.xfaFactory.appendFonts(pdfFonts, reallyMissingFonts);
  6595. }
  6596. async serializeXfaData(annotationStorage) {
  6597. return this.xfaFactory ? this.xfaFactory.serializeData(annotationStorage) : null;
  6598. }
  6599. get version() {
  6600. return this.catalog.version || this._version;
  6601. }
  6602. get formInfo() {
  6603. const formInfo = {
  6604. hasFields: false,
  6605. hasAcroForm: false,
  6606. hasXfa: false,
  6607. hasSignatures: false
  6608. };
  6609. const acroForm = this.catalog.acroForm;
  6610. if (!acroForm) {
  6611. return (0, _util.shadow)(this, "formInfo", formInfo);
  6612. }
  6613. try {
  6614. const fields = acroForm.get("Fields");
  6615. const hasFields = Array.isArray(fields) && fields.length > 0;
  6616. formInfo.hasFields = hasFields;
  6617. const xfa = acroForm.get("XFA");
  6618. formInfo.hasXfa = Array.isArray(xfa) && xfa.length > 0 || xfa instanceof _base_stream.BaseStream && !xfa.isEmpty;
  6619. const sigFlags = acroForm.get("SigFlags");
  6620. const hasSignatures = !!(sigFlags & 0x1);
  6621. const hasOnlyDocumentSignatures = hasSignatures && this._hasOnlyDocumentSignatures(fields);
  6622. formInfo.hasAcroForm = hasFields && !hasOnlyDocumentSignatures;
  6623. formInfo.hasSignatures = hasSignatures;
  6624. } catch (ex) {
  6625. if (ex instanceof _core_utils.MissingDataException) {
  6626. throw ex;
  6627. }
  6628. (0, _util.warn)(`Cannot fetch form information: "${ex}".`);
  6629. }
  6630. return (0, _util.shadow)(this, "formInfo", formInfo);
  6631. }
  6632. get documentInfo() {
  6633. const docInfo = {
  6634. PDFFormatVersion: this.version,
  6635. Language: this.catalog.lang,
  6636. EncryptFilterName: this.xref.encrypt ? this.xref.encrypt.filterName : null,
  6637. IsLinearized: !!this.linearization,
  6638. IsAcroFormPresent: this.formInfo.hasAcroForm,
  6639. IsXFAPresent: this.formInfo.hasXfa,
  6640. IsCollectionPresent: !!this.catalog.collection,
  6641. IsSignaturesPresent: this.formInfo.hasSignatures
  6642. };
  6643. let infoDict;
  6644. try {
  6645. infoDict = this.xref.trailer.get("Info");
  6646. } catch (err) {
  6647. if (err instanceof _core_utils.MissingDataException) {
  6648. throw err;
  6649. }
  6650. (0, _util.info)("The document information dictionary is invalid.");
  6651. }
  6652. if (!(infoDict instanceof _primitives.Dict)) {
  6653. return (0, _util.shadow)(this, "documentInfo", docInfo);
  6654. }
  6655. for (const key of infoDict.getKeys()) {
  6656. const value = infoDict.get(key);
  6657. switch (key) {
  6658. case "Title":
  6659. case "Author":
  6660. case "Subject":
  6661. case "Keywords":
  6662. case "Creator":
  6663. case "Producer":
  6664. case "CreationDate":
  6665. case "ModDate":
  6666. if (typeof value === "string") {
  6667. docInfo[key] = (0, _util.stringToPDFString)(value);
  6668. continue;
  6669. }
  6670. break;
  6671. case "Trapped":
  6672. if (value instanceof _primitives.Name) {
  6673. docInfo[key] = value;
  6674. continue;
  6675. }
  6676. break;
  6677. default:
  6678. let customValue;
  6679. switch (typeof value) {
  6680. case "string":
  6681. customValue = (0, _util.stringToPDFString)(value);
  6682. break;
  6683. case "number":
  6684. case "boolean":
  6685. customValue = value;
  6686. break;
  6687. default:
  6688. if (value instanceof _primitives.Name) {
  6689. customValue = value;
  6690. }
  6691. break;
  6692. }
  6693. if (customValue === undefined) {
  6694. (0, _util.warn)(`Bad value, for custom key "${key}", in Info: ${value}.`);
  6695. continue;
  6696. }
  6697. if (!docInfo.Custom) {
  6698. docInfo.Custom = Object.create(null);
  6699. }
  6700. docInfo.Custom[key] = customValue;
  6701. continue;
  6702. }
  6703. (0, _util.warn)(`Bad value, for key "${key}", in Info: ${value}.`);
  6704. }
  6705. return (0, _util.shadow)(this, "documentInfo", docInfo);
  6706. }
  6707. get fingerprints() {
  6708. function validate(data) {
  6709. return typeof data === "string" && data.length > 0 && data !== EMPTY_FINGERPRINT;
  6710. }
  6711. function hexString(hash) {
  6712. const buf = [];
  6713. for (const num of hash) {
  6714. const hex = num.toString(16);
  6715. buf.push(hex.padStart(2, "0"));
  6716. }
  6717. return buf.join("");
  6718. }
  6719. const idArray = this.xref.trailer.get("ID");
  6720. let hashOriginal, hashModified;
  6721. if (Array.isArray(idArray) && validate(idArray[0])) {
  6722. hashOriginal = (0, _util.stringToBytes)(idArray[0]);
  6723. if (idArray[1] !== idArray[0] && validate(idArray[1])) {
  6724. hashModified = (0, _util.stringToBytes)(idArray[1]);
  6725. }
  6726. } else {
  6727. hashOriginal = (0, _crypto.calculateMD5)(this.stream.getByteRange(0, FINGERPRINT_FIRST_BYTES), 0, FINGERPRINT_FIRST_BYTES);
  6728. }
  6729. return (0, _util.shadow)(this, "fingerprints", [hexString(hashOriginal), hashModified ? hexString(hashModified) : null]);
  6730. }
  6731. async _getLinearizationPage(pageIndex) {
  6732. const {
  6733. catalog,
  6734. linearization,
  6735. xref
  6736. } = this;
  6737. const ref = _primitives.Ref.get(linearization.objectNumberFirst, 0);
  6738. try {
  6739. const obj = await xref.fetchAsync(ref);
  6740. if (obj instanceof _primitives.Dict) {
  6741. let type = obj.getRaw("Type");
  6742. if (type instanceof _primitives.Ref) {
  6743. type = await xref.fetchAsync(type);
  6744. }
  6745. if ((0, _primitives.isName)(type, "Page") || !obj.has("Type") && !obj.has("Kids")) {
  6746. if (!catalog.pageKidsCountCache.has(ref)) {
  6747. catalog.pageKidsCountCache.put(ref, 1);
  6748. }
  6749. if (!catalog.pageIndexCache.has(ref)) {
  6750. catalog.pageIndexCache.put(ref, 0);
  6751. }
  6752. return [obj, ref];
  6753. }
  6754. }
  6755. throw new _util.FormatError("The Linearization dictionary doesn't point to a valid Page dictionary.");
  6756. } catch (reason) {
  6757. (0, _util.warn)(`_getLinearizationPage: "${reason.message}".`);
  6758. return catalog.getPageDict(pageIndex);
  6759. }
  6760. }
  6761. getPage(pageIndex) {
  6762. const cachedPromise = this._pagePromises.get(pageIndex);
  6763. if (cachedPromise) {
  6764. return cachedPromise;
  6765. }
  6766. const {
  6767. catalog,
  6768. linearization,
  6769. xfaFactory
  6770. } = this;
  6771. let promise;
  6772. if (xfaFactory) {
  6773. promise = Promise.resolve([_primitives.Dict.empty, null]);
  6774. } else if (linearization?.pageFirst === pageIndex) {
  6775. promise = this._getLinearizationPage(pageIndex);
  6776. } else {
  6777. promise = catalog.getPageDict(pageIndex);
  6778. }
  6779. promise = promise.then(_ref7 => {
  6780. let [pageDict, ref] = _ref7;
  6781. return new Page({
  6782. pdfManager: this.pdfManager,
  6783. xref: this.xref,
  6784. pageIndex,
  6785. pageDict,
  6786. ref,
  6787. globalIdFactory: this._globalIdFactory,
  6788. fontCache: catalog.fontCache,
  6789. builtInCMapCache: catalog.builtInCMapCache,
  6790. standardFontDataCache: catalog.standardFontDataCache,
  6791. globalImageCache: catalog.globalImageCache,
  6792. systemFontCache: catalog.systemFontCache,
  6793. nonBlendModesSet: catalog.nonBlendModesSet,
  6794. xfaFactory
  6795. });
  6796. });
  6797. this._pagePromises.set(pageIndex, promise);
  6798. return promise;
  6799. }
  6800. async checkFirstPage() {
  6801. let recoveryMode = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  6802. if (recoveryMode) {
  6803. return;
  6804. }
  6805. try {
  6806. await this.getPage(0);
  6807. } catch (reason) {
  6808. if (reason instanceof _core_utils.XRefEntryException) {
  6809. this._pagePromises.delete(0);
  6810. await this.cleanup();
  6811. throw new _core_utils.XRefParseException();
  6812. }
  6813. }
  6814. }
  6815. async checkLastPage() {
  6816. let recoveryMode = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  6817. const {
  6818. catalog,
  6819. pdfManager
  6820. } = this;
  6821. catalog.setActualNumPages();
  6822. let numPages;
  6823. try {
  6824. await Promise.all([pdfManager.ensureDoc("xfaFactory"), pdfManager.ensureDoc("linearization"), pdfManager.ensureCatalog("numPages")]);
  6825. if (this.xfaFactory) {
  6826. return;
  6827. } else if (this.linearization) {
  6828. numPages = this.linearization.numPages;
  6829. } else {
  6830. numPages = catalog.numPages;
  6831. }
  6832. if (!Number.isInteger(numPages)) {
  6833. throw new _util.FormatError("Page count is not an integer.");
  6834. } else if (numPages <= 1) {
  6835. return;
  6836. }
  6837. await this.getPage(numPages - 1);
  6838. } catch (reason) {
  6839. this._pagePromises.delete(numPages - 1);
  6840. await this.cleanup();
  6841. if (reason instanceof _core_utils.XRefEntryException && !recoveryMode) {
  6842. throw new _core_utils.XRefParseException();
  6843. }
  6844. (0, _util.warn)(`checkLastPage - invalid /Pages tree /Count: ${numPages}.`);
  6845. let pagesTree;
  6846. try {
  6847. pagesTree = await catalog.getAllPageDicts(recoveryMode);
  6848. } catch (reasonAll) {
  6849. if (reasonAll instanceof _core_utils.XRefEntryException && !recoveryMode) {
  6850. throw new _core_utils.XRefParseException();
  6851. }
  6852. catalog.setActualNumPages(1);
  6853. return;
  6854. }
  6855. for (const [pageIndex, [pageDict, ref]] of pagesTree) {
  6856. let promise;
  6857. if (pageDict instanceof Error) {
  6858. promise = Promise.reject(pageDict);
  6859. promise.catch(() => {});
  6860. } else {
  6861. promise = Promise.resolve(new Page({
  6862. pdfManager,
  6863. xref: this.xref,
  6864. pageIndex,
  6865. pageDict,
  6866. ref,
  6867. globalIdFactory: this._globalIdFactory,
  6868. fontCache: catalog.fontCache,
  6869. builtInCMapCache: catalog.builtInCMapCache,
  6870. standardFontDataCache: catalog.standardFontDataCache,
  6871. globalImageCache: catalog.globalImageCache,
  6872. systemFontCache: catalog.systemFontCache,
  6873. nonBlendModesSet: catalog.nonBlendModesSet,
  6874. xfaFactory: null
  6875. }));
  6876. }
  6877. this._pagePromises.set(pageIndex, promise);
  6878. }
  6879. catalog.setActualNumPages(pagesTree.size);
  6880. }
  6881. }
  6882. fontFallback(id, handler) {
  6883. return this.catalog.fontFallback(id, handler);
  6884. }
  6885. async cleanup() {
  6886. let manuallyTriggered = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  6887. return this.catalog ? this.catalog.cleanup(manuallyTriggered) : (0, _cleanup_helper.clearGlobalCaches)();
  6888. }
  6889. _collectFieldObjects(name, fieldRef, promises) {
  6890. const field = this.xref.fetchIfRef(fieldRef);
  6891. if (field.has("T")) {
  6892. const partName = (0, _util.stringToPDFString)(field.get("T"));
  6893. name = name === "" ? partName : `${name}.${partName}`;
  6894. }
  6895. if (!promises.has(name)) {
  6896. promises.set(name, []);
  6897. }
  6898. promises.get(name).push(_annotation.AnnotationFactory.create(this.xref, fieldRef, this.pdfManager, this._localIdFactory, true).then(annotation => annotation?.getFieldObject()).catch(function (reason) {
  6899. (0, _util.warn)(`_collectFieldObjects: "${reason}".`);
  6900. return null;
  6901. }));
  6902. if (field.has("Kids")) {
  6903. const kids = field.get("Kids");
  6904. for (const kid of kids) {
  6905. this._collectFieldObjects(name, kid, promises);
  6906. }
  6907. }
  6908. }
  6909. get fieldObjects() {
  6910. if (!this.formInfo.hasFields) {
  6911. return (0, _util.shadow)(this, "fieldObjects", Promise.resolve(null));
  6912. }
  6913. const allFields = Object.create(null);
  6914. const fieldPromises = new Map();
  6915. for (const fieldRef of this.catalog.acroForm.get("Fields")) {
  6916. this._collectFieldObjects("", fieldRef, fieldPromises);
  6917. }
  6918. const allPromises = [];
  6919. for (const [name, promises] of fieldPromises) {
  6920. allPromises.push(Promise.all(promises).then(fields => {
  6921. fields = fields.filter(field => !!field);
  6922. if (fields.length > 0) {
  6923. allFields[name] = fields;
  6924. }
  6925. }));
  6926. }
  6927. return (0, _util.shadow)(this, "fieldObjects", Promise.all(allPromises).then(() => allFields));
  6928. }
  6929. get hasJSActions() {
  6930. const promise = this.pdfManager.ensureDoc("_parseHasJSActions");
  6931. return (0, _util.shadow)(this, "hasJSActions", promise);
  6932. }
  6933. async _parseHasJSActions() {
  6934. const [catalogJsActions, fieldObjects] = await Promise.all([this.pdfManager.ensureCatalog("jsActions"), this.pdfManager.ensureDoc("fieldObjects")]);
  6935. if (catalogJsActions) {
  6936. return true;
  6937. }
  6938. if (fieldObjects) {
  6939. return Object.values(fieldObjects).some(fieldObject => fieldObject.some(object => object.actions !== null));
  6940. }
  6941. return false;
  6942. }
  6943. get calculationOrderIds() {
  6944. const acroForm = this.catalog.acroForm;
  6945. if (!acroForm?.has("CO")) {
  6946. return (0, _util.shadow)(this, "calculationOrderIds", null);
  6947. }
  6948. const calculationOrder = acroForm.get("CO");
  6949. if (!Array.isArray(calculationOrder) || calculationOrder.length === 0) {
  6950. return (0, _util.shadow)(this, "calculationOrderIds", null);
  6951. }
  6952. const ids = [];
  6953. for (const id of calculationOrder) {
  6954. if (id instanceof _primitives.Ref) {
  6955. ids.push(id.toString());
  6956. }
  6957. }
  6958. if (ids.length === 0) {
  6959. return (0, _util.shadow)(this, "calculationOrderIds", null);
  6960. }
  6961. return (0, _util.shadow)(this, "calculationOrderIds", ids);
  6962. }
  6963. }
  6964. exports.PDFDocument = PDFDocument;
  6965. /***/ }),
  6966. /* 157 */
  6967. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  6968. Object.defineProperty(exports, "__esModule", ({
  6969. value: true
  6970. }));
  6971. exports.PopupAnnotation = exports.MarkupAnnotation = exports.AnnotationFactory = exports.AnnotationBorderStyle = exports.Annotation = void 0;
  6972. exports.getQuadPoints = getQuadPoints;
  6973. __w_pdfjs_require__(140);
  6974. __w_pdfjs_require__(84);
  6975. __w_pdfjs_require__(93);
  6976. __w_pdfjs_require__(94);
  6977. __w_pdfjs_require__(97);
  6978. __w_pdfjs_require__(99);
  6979. __w_pdfjs_require__(101);
  6980. __w_pdfjs_require__(105);
  6981. __w_pdfjs_require__(108);
  6982. __w_pdfjs_require__(115);
  6983. __w_pdfjs_require__(158);
  6984. __w_pdfjs_require__(160);
  6985. var _util = __w_pdfjs_require__(145);
  6986. var _core_utils = __w_pdfjs_require__(150);
  6987. var _default_appearance = __w_pdfjs_require__(162);
  6988. var _primitives = __w_pdfjs_require__(151);
  6989. var _stream = __w_pdfjs_require__(155);
  6990. var _writer = __w_pdfjs_require__(217);
  6991. var _base_stream = __w_pdfjs_require__(152);
  6992. var _bidi = __w_pdfjs_require__(211);
  6993. var _catalog = __w_pdfjs_require__(221);
  6994. var _colorspace = __w_pdfjs_require__(163);
  6995. var _file_spec = __w_pdfjs_require__(224);
  6996. var _jpeg_stream = __w_pdfjs_require__(177);
  6997. var _object_loader = __w_pdfjs_require__(227);
  6998. var _operator_list = __w_pdfjs_require__(215);
  6999. var _factory = __w_pdfjs_require__(228);
  7000. class AnnotationFactory {
  7001. static create(xref, ref, pdfManager, idFactory, collectFields) {
  7002. return Promise.all([pdfManager.ensureCatalog("acroForm"), pdfManager.ensureCatalog("baseUrl"), pdfManager.ensureCatalog("attachments"), pdfManager.ensureDoc("xfaDatasets"), collectFields ? this._getPageIndex(xref, ref, pdfManager) : -1]).then(_ref => {
  7003. let [acroForm, baseUrl, attachments, xfaDatasets, pageIndex] = _ref;
  7004. return pdfManager.ensure(this, "_create", [xref, ref, pdfManager, idFactory, acroForm, attachments, xfaDatasets, collectFields, pageIndex]);
  7005. });
  7006. }
  7007. static _create(xref, ref, pdfManager, idFactory, acroForm) {
  7008. let attachments = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : null;
  7009. let xfaDatasets = arguments.length > 6 ? arguments[6] : undefined;
  7010. let collectFields = arguments.length > 7 ? arguments[7] : undefined;
  7011. let pageIndex = arguments.length > 8 && arguments[8] !== undefined ? arguments[8] : -1;
  7012. const dict = xref.fetchIfRef(ref);
  7013. if (!(dict instanceof _primitives.Dict)) {
  7014. return undefined;
  7015. }
  7016. const id = ref instanceof _primitives.Ref ? ref.toString() : `annot_${idFactory.createObjId()}`;
  7017. let subtype = dict.get("Subtype");
  7018. subtype = subtype instanceof _primitives.Name ? subtype.name : null;
  7019. const acroFormDict = acroForm instanceof _primitives.Dict ? acroForm : _primitives.Dict.empty;
  7020. const parameters = {
  7021. xref,
  7022. ref,
  7023. dict,
  7024. subtype,
  7025. id,
  7026. pdfManager,
  7027. acroForm: acroFormDict,
  7028. attachments,
  7029. xfaDatasets,
  7030. collectFields,
  7031. needAppearances: !collectFields && acroFormDict.get("NeedAppearances") === true,
  7032. pageIndex,
  7033. evaluatorOptions: pdfManager.evaluatorOptions
  7034. };
  7035. switch (subtype) {
  7036. case "Link":
  7037. return new LinkAnnotation(parameters);
  7038. case "Text":
  7039. return new TextAnnotation(parameters);
  7040. case "Widget":
  7041. let fieldType = (0, _core_utils.getInheritableProperty)({
  7042. dict,
  7043. key: "FT"
  7044. });
  7045. fieldType = fieldType instanceof _primitives.Name ? fieldType.name : null;
  7046. switch (fieldType) {
  7047. case "Tx":
  7048. return new TextWidgetAnnotation(parameters);
  7049. case "Btn":
  7050. return new ButtonWidgetAnnotation(parameters);
  7051. case "Ch":
  7052. return new ChoiceWidgetAnnotation(parameters);
  7053. case "Sig":
  7054. return new SignatureWidgetAnnotation(parameters);
  7055. }
  7056. (0, _util.warn)(`Unimplemented widget field type "${fieldType}", ` + "falling back to base field type.");
  7057. return new WidgetAnnotation(parameters);
  7058. case "Popup":
  7059. return new PopupAnnotation(parameters);
  7060. case "FreeText":
  7061. return new FreeTextAnnotation(parameters);
  7062. case "Line":
  7063. return new LineAnnotation(parameters);
  7064. case "Square":
  7065. return new SquareAnnotation(parameters);
  7066. case "Circle":
  7067. return new CircleAnnotation(parameters);
  7068. case "PolyLine":
  7069. return new PolylineAnnotation(parameters);
  7070. case "Polygon":
  7071. return new PolygonAnnotation(parameters);
  7072. case "Caret":
  7073. return new CaretAnnotation(parameters);
  7074. case "Ink":
  7075. return new InkAnnotation(parameters);
  7076. case "Highlight":
  7077. return new HighlightAnnotation(parameters);
  7078. case "Underline":
  7079. return new UnderlineAnnotation(parameters);
  7080. case "Squiggly":
  7081. return new SquigglyAnnotation(parameters);
  7082. case "StrikeOut":
  7083. return new StrikeOutAnnotation(parameters);
  7084. case "Stamp":
  7085. return new StampAnnotation(parameters);
  7086. case "FileAttachment":
  7087. return new FileAttachmentAnnotation(parameters);
  7088. default:
  7089. if (!collectFields) {
  7090. if (!subtype) {
  7091. (0, _util.warn)("Annotation is missing the required /Subtype.");
  7092. } else {
  7093. (0, _util.warn)(`Unimplemented annotation type "${subtype}", ` + "falling back to base annotation.");
  7094. }
  7095. }
  7096. return new Annotation(parameters);
  7097. }
  7098. }
  7099. static async _getPageIndex(xref, ref, pdfManager) {
  7100. try {
  7101. const annotDict = await xref.fetchIfRefAsync(ref);
  7102. if (!(annotDict instanceof _primitives.Dict)) {
  7103. return -1;
  7104. }
  7105. const pageRef = annotDict.getRaw("P");
  7106. if (pageRef instanceof _primitives.Ref) {
  7107. try {
  7108. const pageIndex = await pdfManager.ensureCatalog("getPageIndex", [pageRef]);
  7109. return pageIndex;
  7110. } catch (ex) {
  7111. (0, _util.info)(`_getPageIndex -- not a valid page reference: "${ex}".`);
  7112. }
  7113. }
  7114. if (annotDict.has("Kids")) {
  7115. return -1;
  7116. }
  7117. const numPages = await pdfManager.ensureDoc("numPages");
  7118. for (let pageIndex = 0; pageIndex < numPages; pageIndex++) {
  7119. const page = await pdfManager.getPage(pageIndex);
  7120. const annotations = await pdfManager.ensure(page, "annotations");
  7121. for (const annotRef of annotations) {
  7122. if (annotRef instanceof _primitives.Ref && (0, _primitives.isRefsEqual)(annotRef, ref)) {
  7123. return pageIndex;
  7124. }
  7125. }
  7126. }
  7127. } catch (ex) {
  7128. (0, _util.warn)(`_getPageIndex: "${ex}".`);
  7129. }
  7130. return -1;
  7131. }
  7132. static generateImages(annotations, xref, isOffscreenCanvasSupported) {
  7133. if (!isOffscreenCanvasSupported) {
  7134. (0, _util.warn)("generateImages: OffscreenCanvas is not supported, cannot save or print some annotations with images.");
  7135. return null;
  7136. }
  7137. let imagePromises;
  7138. for (const {
  7139. bitmapId,
  7140. bitmap
  7141. } of annotations) {
  7142. if (!bitmap) {
  7143. continue;
  7144. }
  7145. imagePromises ||= new Map();
  7146. imagePromises.set(bitmapId, StampAnnotation.createImage(bitmap, xref));
  7147. }
  7148. return imagePromises;
  7149. }
  7150. static async saveNewAnnotations(evaluator, task, annotations, imagePromises) {
  7151. const xref = evaluator.xref;
  7152. let baseFontRef;
  7153. const dependencies = [];
  7154. const promises = [];
  7155. const {
  7156. isOffscreenCanvasSupported
  7157. } = evaluator.options;
  7158. for (const annotation of annotations) {
  7159. if (annotation.deleted) {
  7160. continue;
  7161. }
  7162. switch (annotation.annotationType) {
  7163. case _util.AnnotationEditorType.FREETEXT:
  7164. if (!baseFontRef) {
  7165. const baseFont = new _primitives.Dict(xref);
  7166. baseFont.set("BaseFont", _primitives.Name.get("Helvetica"));
  7167. baseFont.set("Type", _primitives.Name.get("Font"));
  7168. baseFont.set("Subtype", _primitives.Name.get("Type1"));
  7169. baseFont.set("Encoding", _primitives.Name.get("WinAnsiEncoding"));
  7170. const buffer = [];
  7171. baseFontRef = xref.getNewTemporaryRef();
  7172. const transform = xref.encrypt ? xref.encrypt.createCipherTransform(baseFontRef.num, baseFontRef.gen) : null;
  7173. await (0, _writer.writeObject)(baseFontRef, baseFont, buffer, transform);
  7174. dependencies.push({
  7175. ref: baseFontRef,
  7176. data: buffer.join("")
  7177. });
  7178. }
  7179. promises.push(FreeTextAnnotation.createNewAnnotation(xref, annotation, dependencies, {
  7180. evaluator,
  7181. task,
  7182. baseFontRef
  7183. }));
  7184. break;
  7185. case _util.AnnotationEditorType.INK:
  7186. promises.push(InkAnnotation.createNewAnnotation(xref, annotation, dependencies));
  7187. break;
  7188. case _util.AnnotationEditorType.STAMP:
  7189. if (!isOffscreenCanvasSupported) {
  7190. break;
  7191. }
  7192. const image = await imagePromises.get(annotation.bitmapId);
  7193. if (image.imageStream) {
  7194. const {
  7195. imageStream,
  7196. smaskStream
  7197. } = image;
  7198. const buffer = [];
  7199. if (smaskStream) {
  7200. const smaskRef = xref.getNewTemporaryRef();
  7201. const transform = xref.encrypt ? xref.encrypt.createCipherTransform(smaskRef.num, smaskRef.gen) : null;
  7202. await (0, _writer.writeObject)(smaskRef, smaskStream, buffer, transform);
  7203. dependencies.push({
  7204. ref: smaskRef,
  7205. data: buffer.join("")
  7206. });
  7207. imageStream.dict.set("SMask", smaskRef);
  7208. buffer.length = 0;
  7209. }
  7210. const imageRef = image.imageRef = xref.getNewTemporaryRef();
  7211. const transform = xref.encrypt ? xref.encrypt.createCipherTransform(imageRef.num, imageRef.gen) : null;
  7212. await (0, _writer.writeObject)(imageRef, imageStream, buffer, transform);
  7213. dependencies.push({
  7214. ref: imageRef,
  7215. data: buffer.join("")
  7216. });
  7217. image.imageStream = image.smaskStream = null;
  7218. }
  7219. promises.push(StampAnnotation.createNewAnnotation(xref, annotation, dependencies, {
  7220. image
  7221. }));
  7222. break;
  7223. }
  7224. }
  7225. return {
  7226. annotations: await Promise.all(promises),
  7227. dependencies
  7228. };
  7229. }
  7230. static async printNewAnnotations(evaluator, task, annotations, imagePromises) {
  7231. if (!annotations) {
  7232. return null;
  7233. }
  7234. const {
  7235. options,
  7236. xref
  7237. } = evaluator;
  7238. const promises = [];
  7239. for (const annotation of annotations) {
  7240. if (annotation.deleted) {
  7241. continue;
  7242. }
  7243. switch (annotation.annotationType) {
  7244. case _util.AnnotationEditorType.FREETEXT:
  7245. promises.push(FreeTextAnnotation.createNewPrintAnnotation(xref, annotation, {
  7246. evaluator,
  7247. task,
  7248. evaluatorOptions: options
  7249. }));
  7250. break;
  7251. case _util.AnnotationEditorType.INK:
  7252. promises.push(InkAnnotation.createNewPrintAnnotation(xref, annotation, {
  7253. evaluatorOptions: options
  7254. }));
  7255. break;
  7256. case _util.AnnotationEditorType.STAMP:
  7257. if (!options.isOffscreenCanvasSupported) {
  7258. break;
  7259. }
  7260. const image = await imagePromises.get(annotation.bitmapId);
  7261. if (image.imageStream) {
  7262. const {
  7263. imageStream,
  7264. smaskStream
  7265. } = image;
  7266. if (smaskStream) {
  7267. imageStream.dict.set("SMask", smaskStream);
  7268. }
  7269. image.imageRef = new _jpeg_stream.JpegStream(imageStream, imageStream.length);
  7270. image.imageStream = image.smaskStream = null;
  7271. }
  7272. promises.push(StampAnnotation.createNewPrintAnnotation(xref, annotation, {
  7273. image,
  7274. evaluatorOptions: options
  7275. }));
  7276. break;
  7277. }
  7278. }
  7279. return Promise.all(promises);
  7280. }
  7281. }
  7282. exports.AnnotationFactory = AnnotationFactory;
  7283. function getRgbColor(color) {
  7284. let defaultColor = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : new Uint8ClampedArray(3);
  7285. if (!Array.isArray(color)) {
  7286. return defaultColor;
  7287. }
  7288. const rgbColor = defaultColor || new Uint8ClampedArray(3);
  7289. switch (color.length) {
  7290. case 0:
  7291. return null;
  7292. case 1:
  7293. _colorspace.ColorSpace.singletons.gray.getRgbItem(color, 0, rgbColor, 0);
  7294. return rgbColor;
  7295. case 3:
  7296. _colorspace.ColorSpace.singletons.rgb.getRgbItem(color, 0, rgbColor, 0);
  7297. return rgbColor;
  7298. case 4:
  7299. _colorspace.ColorSpace.singletons.cmyk.getRgbItem(color, 0, rgbColor, 0);
  7300. return rgbColor;
  7301. default:
  7302. return defaultColor;
  7303. }
  7304. }
  7305. function getPdfColorArray(color) {
  7306. return Array.from(color, c => c / 255);
  7307. }
  7308. function getQuadPoints(dict, rect) {
  7309. const quadPoints = dict.getArray("QuadPoints");
  7310. if (!Array.isArray(quadPoints) || quadPoints.length === 0 || quadPoints.length % 8 > 0) {
  7311. return null;
  7312. }
  7313. const quadPointsLists = [];
  7314. for (let i = 0, ii = quadPoints.length / 8; i < ii; i++) {
  7315. let minX = Infinity,
  7316. maxX = -Infinity,
  7317. minY = Infinity,
  7318. maxY = -Infinity;
  7319. for (let j = i * 8, jj = i * 8 + 8; j < jj; j += 2) {
  7320. const x = quadPoints[j];
  7321. const y = quadPoints[j + 1];
  7322. minX = Math.min(x, minX);
  7323. maxX = Math.max(x, maxX);
  7324. minY = Math.min(y, minY);
  7325. maxY = Math.max(y, maxY);
  7326. }
  7327. if (rect !== null && (minX < rect[0] || maxX > rect[2] || minY < rect[1] || maxY > rect[3])) {
  7328. return null;
  7329. }
  7330. quadPointsLists.push([{
  7331. x: minX,
  7332. y: maxY
  7333. }, {
  7334. x: maxX,
  7335. y: maxY
  7336. }, {
  7337. x: minX,
  7338. y: minY
  7339. }, {
  7340. x: maxX,
  7341. y: minY
  7342. }]);
  7343. }
  7344. return quadPointsLists;
  7345. }
  7346. function getTransformMatrix(rect, bbox, matrix) {
  7347. const [minX, minY, maxX, maxY] = _util.Util.getAxialAlignedBoundingBox(bbox, matrix);
  7348. if (minX === maxX || minY === maxY) {
  7349. return [1, 0, 0, 1, rect[0], rect[1]];
  7350. }
  7351. const xRatio = (rect[2] - rect[0]) / (maxX - minX);
  7352. const yRatio = (rect[3] - rect[1]) / (maxY - minY);
  7353. return [xRatio, 0, 0, yRatio, rect[0] - minX * xRatio, rect[1] - minY * yRatio];
  7354. }
  7355. class Annotation {
  7356. constructor(params) {
  7357. const {
  7358. dict,
  7359. xref
  7360. } = params;
  7361. this.setTitle(dict.get("T"));
  7362. this.setContents(dict.get("Contents"));
  7363. this.setModificationDate(dict.get("M"));
  7364. this.setFlags(dict.get("F"));
  7365. this.setRectangle(dict.getArray("Rect"));
  7366. this.setColor(dict.getArray("C"));
  7367. this.setBorderStyle(dict);
  7368. this.setAppearance(dict);
  7369. this.setOptionalContent(dict);
  7370. const MK = dict.get("MK");
  7371. this.setBorderAndBackgroundColors(MK);
  7372. this.setRotation(MK, dict);
  7373. this.ref = params.ref instanceof _primitives.Ref ? params.ref : null;
  7374. this._streams = [];
  7375. if (this.appearance) {
  7376. this._streams.push(this.appearance);
  7377. }
  7378. const isLocked = !!(this.flags & _util.AnnotationFlag.LOCKED);
  7379. const isContentLocked = !!(this.flags & _util.AnnotationFlag.LOCKEDCONTENTS);
  7380. this.data = {
  7381. annotationFlags: this.flags,
  7382. borderStyle: this.borderStyle,
  7383. color: this.color,
  7384. backgroundColor: this.backgroundColor,
  7385. borderColor: this.borderColor,
  7386. rotation: this.rotation,
  7387. contentsObj: this._contents,
  7388. hasAppearance: !!this.appearance,
  7389. id: params.id,
  7390. modificationDate: this.modificationDate,
  7391. rect: this.rectangle,
  7392. subtype: params.subtype,
  7393. hasOwnCanvas: false,
  7394. noRotate: !!(this.flags & _util.AnnotationFlag.NOROTATE),
  7395. noHTML: isLocked && isContentLocked
  7396. };
  7397. if (params.collectFields) {
  7398. const kids = dict.get("Kids");
  7399. if (Array.isArray(kids)) {
  7400. const kidIds = [];
  7401. for (const kid of kids) {
  7402. if (kid instanceof _primitives.Ref) {
  7403. kidIds.push(kid.toString());
  7404. }
  7405. }
  7406. if (kidIds.length !== 0) {
  7407. this.data.kidIds = kidIds;
  7408. }
  7409. }
  7410. this.data.actions = (0, _core_utils.collectActions)(xref, dict, _util.AnnotationActionEventType);
  7411. this.data.fieldName = this._constructFieldName(dict);
  7412. this.data.pageIndex = params.pageIndex;
  7413. }
  7414. this._isOffscreenCanvasSupported = params.evaluatorOptions.isOffscreenCanvasSupported;
  7415. this._fallbackFontDict = null;
  7416. this._needAppearances = false;
  7417. }
  7418. _hasFlag(flags, flag) {
  7419. return !!(flags & flag);
  7420. }
  7421. _isViewable(flags) {
  7422. return !this._hasFlag(flags, _util.AnnotationFlag.INVISIBLE) && !this._hasFlag(flags, _util.AnnotationFlag.NOVIEW);
  7423. }
  7424. _isPrintable(flags) {
  7425. return this._hasFlag(flags, _util.AnnotationFlag.PRINT) && !this._hasFlag(flags, _util.AnnotationFlag.HIDDEN) && !this._hasFlag(flags, _util.AnnotationFlag.INVISIBLE);
  7426. }
  7427. mustBeViewed(annotationStorage, _renderForms) {
  7428. const noView = annotationStorage?.get(this.data.id)?.noView;
  7429. if (noView !== undefined) {
  7430. return !noView;
  7431. }
  7432. return this.viewable && !this._hasFlag(this.flags, _util.AnnotationFlag.HIDDEN);
  7433. }
  7434. mustBePrinted(annotationStorage) {
  7435. const noPrint = annotationStorage?.get(this.data.id)?.noPrint;
  7436. if (noPrint !== undefined) {
  7437. return !noPrint;
  7438. }
  7439. return this.printable;
  7440. }
  7441. get viewable() {
  7442. if (this.data.quadPoints === null) {
  7443. return false;
  7444. }
  7445. if (this.flags === 0) {
  7446. return true;
  7447. }
  7448. return this._isViewable(this.flags);
  7449. }
  7450. get printable() {
  7451. if (this.data.quadPoints === null) {
  7452. return false;
  7453. }
  7454. if (this.flags === 0) {
  7455. return false;
  7456. }
  7457. return this._isPrintable(this.flags);
  7458. }
  7459. _parseStringHelper(data) {
  7460. const str = typeof data === "string" ? (0, _util.stringToPDFString)(data) : "";
  7461. const dir = str && (0, _bidi.bidi)(str).dir === "rtl" ? "rtl" : "ltr";
  7462. return {
  7463. str,
  7464. dir
  7465. };
  7466. }
  7467. setDefaultAppearance(params) {
  7468. const defaultAppearance = (0, _core_utils.getInheritableProperty)({
  7469. dict: params.dict,
  7470. key: "DA"
  7471. }) || params.acroForm.get("DA");
  7472. this._defaultAppearance = typeof defaultAppearance === "string" ? defaultAppearance : "";
  7473. this.data.defaultAppearanceData = (0, _default_appearance.parseDefaultAppearance)(this._defaultAppearance);
  7474. }
  7475. setTitle(title) {
  7476. this._title = this._parseStringHelper(title);
  7477. }
  7478. setContents(contents) {
  7479. this._contents = this._parseStringHelper(contents);
  7480. }
  7481. setModificationDate(modificationDate) {
  7482. this.modificationDate = typeof modificationDate === "string" ? modificationDate : null;
  7483. }
  7484. setFlags(flags) {
  7485. this.flags = Number.isInteger(flags) && flags > 0 ? flags : 0;
  7486. }
  7487. hasFlag(flag) {
  7488. return this._hasFlag(this.flags, flag);
  7489. }
  7490. setRectangle(rectangle) {
  7491. this.rectangle = Array.isArray(rectangle) && rectangle.length === 4 ? _util.Util.normalizeRect(rectangle) : [0, 0, 0, 0];
  7492. }
  7493. setColor(color) {
  7494. this.color = getRgbColor(color);
  7495. }
  7496. setLineEndings(lineEndings) {
  7497. this.lineEndings = ["None", "None"];
  7498. if (Array.isArray(lineEndings) && lineEndings.length === 2) {
  7499. for (let i = 0; i < 2; i++) {
  7500. const obj = lineEndings[i];
  7501. if (obj instanceof _primitives.Name) {
  7502. switch (obj.name) {
  7503. case "None":
  7504. continue;
  7505. case "Square":
  7506. case "Circle":
  7507. case "Diamond":
  7508. case "OpenArrow":
  7509. case "ClosedArrow":
  7510. case "Butt":
  7511. case "ROpenArrow":
  7512. case "RClosedArrow":
  7513. case "Slash":
  7514. this.lineEndings[i] = obj.name;
  7515. continue;
  7516. }
  7517. }
  7518. (0, _util.warn)(`Ignoring invalid lineEnding: ${obj}`);
  7519. }
  7520. }
  7521. }
  7522. setRotation(mk, dict) {
  7523. this.rotation = 0;
  7524. let angle = mk instanceof _primitives.Dict ? mk.get("R") || 0 : dict.get("Rotate") || 0;
  7525. if (Number.isInteger(angle) && angle !== 0) {
  7526. angle %= 360;
  7527. if (angle < 0) {
  7528. angle += 360;
  7529. }
  7530. if (angle % 90 === 0) {
  7531. this.rotation = angle;
  7532. }
  7533. }
  7534. }
  7535. setBorderAndBackgroundColors(mk) {
  7536. if (mk instanceof _primitives.Dict) {
  7537. this.borderColor = getRgbColor(mk.getArray("BC"), null);
  7538. this.backgroundColor = getRgbColor(mk.getArray("BG"), null);
  7539. } else {
  7540. this.borderColor = this.backgroundColor = null;
  7541. }
  7542. }
  7543. setBorderStyle(borderStyle) {
  7544. this.borderStyle = new AnnotationBorderStyle();
  7545. if (!(borderStyle instanceof _primitives.Dict)) {
  7546. return;
  7547. }
  7548. if (borderStyle.has("BS")) {
  7549. const dict = borderStyle.get("BS");
  7550. const dictType = dict.get("Type");
  7551. if (!dictType || (0, _primitives.isName)(dictType, "Border")) {
  7552. this.borderStyle.setWidth(dict.get("W"), this.rectangle);
  7553. this.borderStyle.setStyle(dict.get("S"));
  7554. this.borderStyle.setDashArray(dict.getArray("D"));
  7555. }
  7556. } else if (borderStyle.has("Border")) {
  7557. const array = borderStyle.getArray("Border");
  7558. if (Array.isArray(array) && array.length >= 3) {
  7559. this.borderStyle.setHorizontalCornerRadius(array[0]);
  7560. this.borderStyle.setVerticalCornerRadius(array[1]);
  7561. this.borderStyle.setWidth(array[2], this.rectangle);
  7562. if (array.length === 4) {
  7563. this.borderStyle.setDashArray(array[3], true);
  7564. }
  7565. }
  7566. } else {
  7567. this.borderStyle.setWidth(0);
  7568. }
  7569. }
  7570. setAppearance(dict) {
  7571. this.appearance = null;
  7572. const appearanceStates = dict.get("AP");
  7573. if (!(appearanceStates instanceof _primitives.Dict)) {
  7574. return;
  7575. }
  7576. const normalAppearanceState = appearanceStates.get("N");
  7577. if (normalAppearanceState instanceof _base_stream.BaseStream) {
  7578. this.appearance = normalAppearanceState;
  7579. return;
  7580. }
  7581. if (!(normalAppearanceState instanceof _primitives.Dict)) {
  7582. return;
  7583. }
  7584. const as = dict.get("AS");
  7585. if (!(as instanceof _primitives.Name) || !normalAppearanceState.has(as.name)) {
  7586. return;
  7587. }
  7588. const appearance = normalAppearanceState.get(as.name);
  7589. if (appearance instanceof _base_stream.BaseStream) {
  7590. this.appearance = appearance;
  7591. }
  7592. }
  7593. setOptionalContent(dict) {
  7594. this.oc = null;
  7595. const oc = dict.get("OC");
  7596. if (oc instanceof _primitives.Name) {
  7597. (0, _util.warn)("setOptionalContent: Support for /Name-entry is not implemented.");
  7598. } else if (oc instanceof _primitives.Dict) {
  7599. this.oc = oc;
  7600. }
  7601. }
  7602. loadResources(keys, appearance) {
  7603. return appearance.dict.getAsync("Resources").then(resources => {
  7604. if (!resources) {
  7605. return undefined;
  7606. }
  7607. const objectLoader = new _object_loader.ObjectLoader(resources, keys, resources.xref);
  7608. return objectLoader.load().then(function () {
  7609. return resources;
  7610. });
  7611. });
  7612. }
  7613. async getOperatorList(evaluator, task, intent, renderForms, annotationStorage) {
  7614. const data = this.data;
  7615. let appearance = this.appearance;
  7616. const isUsingOwnCanvas = !!(this.data.hasOwnCanvas && intent & _util.RenderingIntentFlag.DISPLAY);
  7617. if (!appearance) {
  7618. if (!isUsingOwnCanvas) {
  7619. return {
  7620. opList: new _operator_list.OperatorList(),
  7621. separateForm: false,
  7622. separateCanvas: false
  7623. };
  7624. }
  7625. appearance = new _stream.StringStream("");
  7626. appearance.dict = new _primitives.Dict();
  7627. }
  7628. const appearanceDict = appearance.dict;
  7629. const resources = await this.loadResources(["ExtGState", "ColorSpace", "Pattern", "Shading", "XObject", "Font"], appearance);
  7630. const bbox = appearanceDict.getArray("BBox") || [0, 0, 1, 1];
  7631. const matrix = appearanceDict.getArray("Matrix") || [1, 0, 0, 1, 0, 0];
  7632. const transform = getTransformMatrix(data.rect, bbox, matrix);
  7633. const opList = new _operator_list.OperatorList();
  7634. let optionalContent;
  7635. if (this.oc) {
  7636. optionalContent = await evaluator.parseMarkedContentProps(this.oc, null);
  7637. }
  7638. if (optionalContent !== undefined) {
  7639. opList.addOp(_util.OPS.beginMarkedContentProps, ["OC", optionalContent]);
  7640. }
  7641. opList.addOp(_util.OPS.beginAnnotation, [data.id, data.rect, transform, matrix, isUsingOwnCanvas]);
  7642. await evaluator.getOperatorList({
  7643. stream: appearance,
  7644. task,
  7645. resources,
  7646. operatorList: opList,
  7647. fallbackFontDict: this._fallbackFontDict
  7648. });
  7649. opList.addOp(_util.OPS.endAnnotation, []);
  7650. if (optionalContent !== undefined) {
  7651. opList.addOp(_util.OPS.endMarkedContent, []);
  7652. }
  7653. this.reset();
  7654. return {
  7655. opList,
  7656. separateForm: false,
  7657. separateCanvas: isUsingOwnCanvas
  7658. };
  7659. }
  7660. async save(evaluator, task, annotationStorage) {
  7661. return null;
  7662. }
  7663. get hasTextContent() {
  7664. return false;
  7665. }
  7666. async extractTextContent(evaluator, task, viewBox) {
  7667. if (!this.appearance) {
  7668. return;
  7669. }
  7670. const resources = await this.loadResources(["ExtGState", "Font", "Properties", "XObject"], this.appearance);
  7671. const text = [];
  7672. const buffer = [];
  7673. let firstPosition = null;
  7674. const sink = {
  7675. desiredSize: Math.Infinity,
  7676. ready: true,
  7677. enqueue(chunk, size) {
  7678. for (const item of chunk.items) {
  7679. if (item.str === undefined) {
  7680. continue;
  7681. }
  7682. firstPosition ||= item.transform.slice(-2);
  7683. buffer.push(item.str);
  7684. if (item.hasEOL) {
  7685. text.push(buffer.join(""));
  7686. buffer.length = 0;
  7687. }
  7688. }
  7689. }
  7690. };
  7691. await evaluator.getTextContent({
  7692. stream: this.appearance,
  7693. task,
  7694. resources,
  7695. includeMarkedContent: true,
  7696. sink,
  7697. viewBox
  7698. });
  7699. this.reset();
  7700. if (buffer.length) {
  7701. text.push(buffer.join(""));
  7702. }
  7703. if (text.length > 1 || text[0]) {
  7704. const appearanceDict = this.appearance.dict;
  7705. const bbox = appearanceDict.getArray("BBox") || [0, 0, 1, 1];
  7706. const matrix = appearanceDict.getArray("Matrix") || [1, 0, 0, 1, 0, 0];
  7707. const rect = this.data.rect;
  7708. const transform = getTransformMatrix(rect, bbox, matrix);
  7709. transform[4] -= rect[0];
  7710. transform[5] -= rect[1];
  7711. firstPosition = _util.Util.applyTransform(firstPosition, transform);
  7712. firstPosition = _util.Util.applyTransform(firstPosition, matrix);
  7713. this.data.textPosition = firstPosition;
  7714. this.data.textContent = text;
  7715. }
  7716. }
  7717. getFieldObject() {
  7718. if (this.data.kidIds) {
  7719. return {
  7720. id: this.data.id,
  7721. actions: this.data.actions,
  7722. name: this.data.fieldName,
  7723. strokeColor: this.data.borderColor,
  7724. fillColor: this.data.backgroundColor,
  7725. type: "",
  7726. kidIds: this.data.kidIds,
  7727. page: this.data.pageIndex,
  7728. rotation: this.rotation
  7729. };
  7730. }
  7731. return null;
  7732. }
  7733. reset() {
  7734. for (const stream of this._streams) {
  7735. stream.reset();
  7736. }
  7737. }
  7738. _constructFieldName(dict) {
  7739. if (!dict.has("T") && !dict.has("Parent")) {
  7740. (0, _util.warn)("Unknown field name, falling back to empty field name.");
  7741. return "";
  7742. }
  7743. if (!dict.has("Parent")) {
  7744. return (0, _util.stringToPDFString)(dict.get("T"));
  7745. }
  7746. const fieldName = [];
  7747. if (dict.has("T")) {
  7748. fieldName.unshift((0, _util.stringToPDFString)(dict.get("T")));
  7749. }
  7750. let loopDict = dict;
  7751. const visited = new _primitives.RefSet();
  7752. if (dict.objId) {
  7753. visited.put(dict.objId);
  7754. }
  7755. while (loopDict.has("Parent")) {
  7756. loopDict = loopDict.get("Parent");
  7757. if (!(loopDict instanceof _primitives.Dict) || loopDict.objId && visited.has(loopDict.objId)) {
  7758. break;
  7759. }
  7760. if (loopDict.objId) {
  7761. visited.put(loopDict.objId);
  7762. }
  7763. if (loopDict.has("T")) {
  7764. const t = (0, _util.stringToPDFString)(loopDict.get("T"));
  7765. if (!t.startsWith("#")) {
  7766. fieldName.unshift(t);
  7767. }
  7768. }
  7769. }
  7770. return fieldName.join(".");
  7771. }
  7772. }
  7773. exports.Annotation = Annotation;
  7774. class AnnotationBorderStyle {
  7775. constructor() {
  7776. this.width = 1;
  7777. this.style = _util.AnnotationBorderStyleType.SOLID;
  7778. this.dashArray = [3];
  7779. this.horizontalCornerRadius = 0;
  7780. this.verticalCornerRadius = 0;
  7781. }
  7782. setWidth(width) {
  7783. let rect = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [0, 0, 0, 0];
  7784. if (width instanceof _primitives.Name) {
  7785. this.width = 0;
  7786. return;
  7787. }
  7788. if (typeof width === "number") {
  7789. if (width > 0) {
  7790. const maxWidth = (rect[2] - rect[0]) / 2;
  7791. const maxHeight = (rect[3] - rect[1]) / 2;
  7792. if (maxWidth > 0 && maxHeight > 0 && (width > maxWidth || width > maxHeight)) {
  7793. (0, _util.warn)(`AnnotationBorderStyle.setWidth - ignoring width: ${width}`);
  7794. width = 1;
  7795. }
  7796. }
  7797. this.width = width;
  7798. }
  7799. }
  7800. setStyle(style) {
  7801. if (!(style instanceof _primitives.Name)) {
  7802. return;
  7803. }
  7804. switch (style.name) {
  7805. case "S":
  7806. this.style = _util.AnnotationBorderStyleType.SOLID;
  7807. break;
  7808. case "D":
  7809. this.style = _util.AnnotationBorderStyleType.DASHED;
  7810. break;
  7811. case "B":
  7812. this.style = _util.AnnotationBorderStyleType.BEVELED;
  7813. break;
  7814. case "I":
  7815. this.style = _util.AnnotationBorderStyleType.INSET;
  7816. break;
  7817. case "U":
  7818. this.style = _util.AnnotationBorderStyleType.UNDERLINE;
  7819. break;
  7820. default:
  7821. break;
  7822. }
  7823. }
  7824. setDashArray(dashArray) {
  7825. let forceStyle = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  7826. if (Array.isArray(dashArray) && dashArray.length > 0) {
  7827. let isValid = true;
  7828. let allZeros = true;
  7829. for (const element of dashArray) {
  7830. const validNumber = +element >= 0;
  7831. if (!validNumber) {
  7832. isValid = false;
  7833. break;
  7834. } else if (element > 0) {
  7835. allZeros = false;
  7836. }
  7837. }
  7838. if (isValid && !allZeros) {
  7839. this.dashArray = dashArray;
  7840. if (forceStyle) {
  7841. this.setStyle(_primitives.Name.get("D"));
  7842. }
  7843. } else {
  7844. this.width = 0;
  7845. }
  7846. } else if (dashArray) {
  7847. this.width = 0;
  7848. }
  7849. }
  7850. setHorizontalCornerRadius(radius) {
  7851. if (Number.isInteger(radius)) {
  7852. this.horizontalCornerRadius = radius;
  7853. }
  7854. }
  7855. setVerticalCornerRadius(radius) {
  7856. if (Number.isInteger(radius)) {
  7857. this.verticalCornerRadius = radius;
  7858. }
  7859. }
  7860. }
  7861. exports.AnnotationBorderStyle = AnnotationBorderStyle;
  7862. class MarkupAnnotation extends Annotation {
  7863. constructor(params) {
  7864. super(params);
  7865. const {
  7866. dict
  7867. } = params;
  7868. if (dict.has("IRT")) {
  7869. const rawIRT = dict.getRaw("IRT");
  7870. this.data.inReplyTo = rawIRT instanceof _primitives.Ref ? rawIRT.toString() : null;
  7871. const rt = dict.get("RT");
  7872. this.data.replyType = rt instanceof _primitives.Name ? rt.name : _util.AnnotationReplyType.REPLY;
  7873. }
  7874. let popupRef = null;
  7875. if (this.data.replyType === _util.AnnotationReplyType.GROUP) {
  7876. const parent = dict.get("IRT");
  7877. this.setTitle(parent.get("T"));
  7878. this.data.titleObj = this._title;
  7879. this.setContents(parent.get("Contents"));
  7880. this.data.contentsObj = this._contents;
  7881. if (!parent.has("CreationDate")) {
  7882. this.data.creationDate = null;
  7883. } else {
  7884. this.setCreationDate(parent.get("CreationDate"));
  7885. this.data.creationDate = this.creationDate;
  7886. }
  7887. if (!parent.has("M")) {
  7888. this.data.modificationDate = null;
  7889. } else {
  7890. this.setModificationDate(parent.get("M"));
  7891. this.data.modificationDate = this.modificationDate;
  7892. }
  7893. popupRef = parent.getRaw("Popup");
  7894. if (!parent.has("C")) {
  7895. this.data.color = null;
  7896. } else {
  7897. this.setColor(parent.getArray("C"));
  7898. this.data.color = this.color;
  7899. }
  7900. } else {
  7901. this.data.titleObj = this._title;
  7902. this.setCreationDate(dict.get("CreationDate"));
  7903. this.data.creationDate = this.creationDate;
  7904. popupRef = dict.getRaw("Popup");
  7905. if (!dict.has("C")) {
  7906. this.data.color = null;
  7907. }
  7908. }
  7909. this.data.popupRef = popupRef instanceof _primitives.Ref ? popupRef.toString() : null;
  7910. if (dict.has("RC")) {
  7911. this.data.richText = _factory.XFAFactory.getRichTextAsHtml(dict.get("RC"));
  7912. }
  7913. }
  7914. setCreationDate(creationDate) {
  7915. this.creationDate = typeof creationDate === "string" ? creationDate : null;
  7916. }
  7917. _setDefaultAppearance(_ref2) {
  7918. let {
  7919. xref,
  7920. extra,
  7921. strokeColor,
  7922. fillColor,
  7923. blendMode,
  7924. strokeAlpha,
  7925. fillAlpha,
  7926. pointsCallback
  7927. } = _ref2;
  7928. let minX = Number.MAX_VALUE;
  7929. let minY = Number.MAX_VALUE;
  7930. let maxX = Number.MIN_VALUE;
  7931. let maxY = Number.MIN_VALUE;
  7932. const buffer = ["q"];
  7933. if (extra) {
  7934. buffer.push(extra);
  7935. }
  7936. if (strokeColor) {
  7937. buffer.push(`${strokeColor[0]} ${strokeColor[1]} ${strokeColor[2]} RG`);
  7938. }
  7939. if (fillColor) {
  7940. buffer.push(`${fillColor[0]} ${fillColor[1]} ${fillColor[2]} rg`);
  7941. }
  7942. let pointsArray = this.data.quadPoints;
  7943. if (!pointsArray) {
  7944. pointsArray = [[{
  7945. x: this.rectangle[0],
  7946. y: this.rectangle[3]
  7947. }, {
  7948. x: this.rectangle[2],
  7949. y: this.rectangle[3]
  7950. }, {
  7951. x: this.rectangle[0],
  7952. y: this.rectangle[1]
  7953. }, {
  7954. x: this.rectangle[2],
  7955. y: this.rectangle[1]
  7956. }]];
  7957. }
  7958. for (const points of pointsArray) {
  7959. const [mX, MX, mY, MY] = pointsCallback(buffer, points);
  7960. minX = Math.min(minX, mX);
  7961. maxX = Math.max(maxX, MX);
  7962. minY = Math.min(minY, mY);
  7963. maxY = Math.max(maxY, MY);
  7964. }
  7965. buffer.push("Q");
  7966. const formDict = new _primitives.Dict(xref);
  7967. const appearanceStreamDict = new _primitives.Dict(xref);
  7968. appearanceStreamDict.set("Subtype", _primitives.Name.get("Form"));
  7969. const appearanceStream = new _stream.StringStream(buffer.join(" "));
  7970. appearanceStream.dict = appearanceStreamDict;
  7971. formDict.set("Fm0", appearanceStream);
  7972. const gsDict = new _primitives.Dict(xref);
  7973. if (blendMode) {
  7974. gsDict.set("BM", _primitives.Name.get(blendMode));
  7975. }
  7976. if (typeof strokeAlpha === "number") {
  7977. gsDict.set("CA", strokeAlpha);
  7978. }
  7979. if (typeof fillAlpha === "number") {
  7980. gsDict.set("ca", fillAlpha);
  7981. }
  7982. const stateDict = new _primitives.Dict(xref);
  7983. stateDict.set("GS0", gsDict);
  7984. const resources = new _primitives.Dict(xref);
  7985. resources.set("ExtGState", stateDict);
  7986. resources.set("XObject", formDict);
  7987. const appearanceDict = new _primitives.Dict(xref);
  7988. appearanceDict.set("Resources", resources);
  7989. const bbox = this.data.rect = [minX, minY, maxX, maxY];
  7990. appearanceDict.set("BBox", bbox);
  7991. this.appearance = new _stream.StringStream("/GS0 gs /Fm0 Do");
  7992. this.appearance.dict = appearanceDict;
  7993. this._streams.push(this.appearance, appearanceStream);
  7994. }
  7995. static async createNewAnnotation(xref, annotation, dependencies, params) {
  7996. const annotationRef = annotation.ref || xref.getNewTemporaryRef();
  7997. const ap = await this.createNewAppearanceStream(annotation, xref, params);
  7998. const buffer = [];
  7999. let annotationDict;
  8000. if (ap) {
  8001. const apRef = xref.getNewTemporaryRef();
  8002. annotationDict = this.createNewDict(annotation, xref, {
  8003. apRef
  8004. });
  8005. const transform = xref.encrypt ? xref.encrypt.createCipherTransform(apRef.num, apRef.gen) : null;
  8006. await (0, _writer.writeObject)(apRef, ap, buffer, transform);
  8007. dependencies.push({
  8008. ref: apRef,
  8009. data: buffer.join("")
  8010. });
  8011. } else {
  8012. annotationDict = this.createNewDict(annotation, xref, {});
  8013. }
  8014. buffer.length = 0;
  8015. const transform = xref.encrypt ? xref.encrypt.createCipherTransform(annotationRef.num, annotationRef.gen) : null;
  8016. await (0, _writer.writeObject)(annotationRef, annotationDict, buffer, transform);
  8017. return {
  8018. ref: annotationRef,
  8019. data: buffer.join("")
  8020. };
  8021. }
  8022. static async createNewPrintAnnotation(xref, annotation, params) {
  8023. const ap = await this.createNewAppearanceStream(annotation, xref, params);
  8024. const annotationDict = this.createNewDict(annotation, xref, {
  8025. ap
  8026. });
  8027. const newAnnotation = new this.prototype.constructor({
  8028. dict: annotationDict,
  8029. xref,
  8030. evaluatorOptions: params.evaluatorOptions
  8031. });
  8032. if (annotation.ref) {
  8033. newAnnotation.ref = newAnnotation.refToReplace = annotation.ref;
  8034. }
  8035. return newAnnotation;
  8036. }
  8037. }
  8038. exports.MarkupAnnotation = MarkupAnnotation;
  8039. class WidgetAnnotation extends Annotation {
  8040. constructor(params) {
  8041. super(params);
  8042. const {
  8043. dict,
  8044. xref
  8045. } = params;
  8046. const data = this.data;
  8047. this._needAppearances = params.needAppearances;
  8048. data.annotationType = _util.AnnotationType.WIDGET;
  8049. if (data.fieldName === undefined) {
  8050. data.fieldName = this._constructFieldName(dict);
  8051. }
  8052. if (data.actions === undefined) {
  8053. data.actions = (0, _core_utils.collectActions)(xref, dict, _util.AnnotationActionEventType);
  8054. }
  8055. let fieldValue = (0, _core_utils.getInheritableProperty)({
  8056. dict,
  8057. key: "V",
  8058. getArray: true
  8059. });
  8060. data.fieldValue = this._decodeFormValue(fieldValue);
  8061. const defaultFieldValue = (0, _core_utils.getInheritableProperty)({
  8062. dict,
  8063. key: "DV",
  8064. getArray: true
  8065. });
  8066. data.defaultFieldValue = this._decodeFormValue(defaultFieldValue);
  8067. if (fieldValue === undefined && params.xfaDatasets) {
  8068. const path = this._title.str;
  8069. if (path) {
  8070. this._hasValueFromXFA = true;
  8071. data.fieldValue = fieldValue = params.xfaDatasets.getValue(path);
  8072. }
  8073. }
  8074. if (fieldValue === undefined && data.defaultFieldValue !== null) {
  8075. data.fieldValue = data.defaultFieldValue;
  8076. }
  8077. data.alternativeText = (0, _util.stringToPDFString)(dict.get("TU") || "");
  8078. this.setDefaultAppearance(params);
  8079. data.hasAppearance ||= this._needAppearances && data.fieldValue !== undefined && data.fieldValue !== null;
  8080. const fieldType = (0, _core_utils.getInheritableProperty)({
  8081. dict,
  8082. key: "FT"
  8083. });
  8084. data.fieldType = fieldType instanceof _primitives.Name ? fieldType.name : null;
  8085. const localResources = (0, _core_utils.getInheritableProperty)({
  8086. dict,
  8087. key: "DR"
  8088. });
  8089. const acroFormResources = params.acroForm.get("DR");
  8090. const appearanceResources = this.appearance?.dict.get("Resources");
  8091. this._fieldResources = {
  8092. localResources,
  8093. acroFormResources,
  8094. appearanceResources,
  8095. mergedResources: _primitives.Dict.merge({
  8096. xref,
  8097. dictArray: [localResources, appearanceResources, acroFormResources],
  8098. mergeSubDicts: true
  8099. })
  8100. };
  8101. data.fieldFlags = (0, _core_utils.getInheritableProperty)({
  8102. dict,
  8103. key: "Ff"
  8104. });
  8105. if (!Number.isInteger(data.fieldFlags) || data.fieldFlags < 0) {
  8106. data.fieldFlags = 0;
  8107. }
  8108. data.readOnly = this.hasFieldFlag(_util.AnnotationFieldFlag.READONLY);
  8109. data.required = this.hasFieldFlag(_util.AnnotationFieldFlag.REQUIRED);
  8110. data.hidden = this._hasFlag(data.annotationFlags, _util.AnnotationFlag.HIDDEN) || this._hasFlag(data.annotationFlags, _util.AnnotationFlag.NOVIEW);
  8111. }
  8112. _decodeFormValue(formValue) {
  8113. if (Array.isArray(formValue)) {
  8114. return formValue.filter(item => typeof item === "string").map(item => (0, _util.stringToPDFString)(item));
  8115. } else if (formValue instanceof _primitives.Name) {
  8116. return (0, _util.stringToPDFString)(formValue.name);
  8117. } else if (typeof formValue === "string") {
  8118. return (0, _util.stringToPDFString)(formValue);
  8119. }
  8120. return null;
  8121. }
  8122. hasFieldFlag(flag) {
  8123. return !!(this.data.fieldFlags & flag);
  8124. }
  8125. _isViewable(flags) {
  8126. return !this._hasFlag(flags, _util.AnnotationFlag.INVISIBLE);
  8127. }
  8128. mustBeViewed(annotationStorage, renderForms) {
  8129. if (renderForms) {
  8130. return this.viewable;
  8131. }
  8132. return super.mustBeViewed(annotationStorage, renderForms) && !this._hasFlag(this.flags, _util.AnnotationFlag.NOVIEW);
  8133. }
  8134. getRotationMatrix(annotationStorage) {
  8135. let rotation = annotationStorage?.get(this.data.id)?.rotation;
  8136. if (rotation === undefined) {
  8137. rotation = this.rotation;
  8138. }
  8139. if (rotation === 0) {
  8140. return _util.IDENTITY_MATRIX;
  8141. }
  8142. const width = this.data.rect[2] - this.data.rect[0];
  8143. const height = this.data.rect[3] - this.data.rect[1];
  8144. return (0, _core_utils.getRotationMatrix)(rotation, width, height);
  8145. }
  8146. getBorderAndBackgroundAppearances(annotationStorage) {
  8147. let rotation = annotationStorage?.get(this.data.id)?.rotation;
  8148. if (rotation === undefined) {
  8149. rotation = this.rotation;
  8150. }
  8151. if (!this.backgroundColor && !this.borderColor) {
  8152. return "";
  8153. }
  8154. const width = this.data.rect[2] - this.data.rect[0];
  8155. const height = this.data.rect[3] - this.data.rect[1];
  8156. const rect = rotation === 0 || rotation === 180 ? `0 0 ${width} ${height} re` : `0 0 ${height} ${width} re`;
  8157. let str = "";
  8158. if (this.backgroundColor) {
  8159. str = `${(0, _default_appearance.getPdfColor)(this.backgroundColor, true)} ${rect} f `;
  8160. }
  8161. if (this.borderColor) {
  8162. const borderWidth = this.borderStyle.width || 1;
  8163. str += `${borderWidth} w ${(0, _default_appearance.getPdfColor)(this.borderColor, false)} ${rect} S `;
  8164. }
  8165. return str;
  8166. }
  8167. async getOperatorList(evaluator, task, intent, renderForms, annotationStorage) {
  8168. if (renderForms && !(this instanceof SignatureWidgetAnnotation) && !this.data.noHTML && !this.data.hasOwnCanvas) {
  8169. return {
  8170. opList: new _operator_list.OperatorList(),
  8171. separateForm: true,
  8172. separateCanvas: false
  8173. };
  8174. }
  8175. if (!this._hasText) {
  8176. return super.getOperatorList(evaluator, task, intent, renderForms, annotationStorage);
  8177. }
  8178. const content = await this._getAppearance(evaluator, task, intent, annotationStorage);
  8179. if (this.appearance && content === null) {
  8180. return super.getOperatorList(evaluator, task, intent, renderForms, annotationStorage);
  8181. }
  8182. const opList = new _operator_list.OperatorList();
  8183. if (!this._defaultAppearance || content === null) {
  8184. return {
  8185. opList,
  8186. separateForm: false,
  8187. separateCanvas: false
  8188. };
  8189. }
  8190. const isUsingOwnCanvas = !!(this.data.hasOwnCanvas && intent & _util.RenderingIntentFlag.DISPLAY);
  8191. const matrix = [1, 0, 0, 1, 0, 0];
  8192. const bbox = [0, 0, this.data.rect[2] - this.data.rect[0], this.data.rect[3] - this.data.rect[1]];
  8193. const transform = getTransformMatrix(this.data.rect, bbox, matrix);
  8194. let optionalContent;
  8195. if (this.oc) {
  8196. optionalContent = await evaluator.parseMarkedContentProps(this.oc, null);
  8197. }
  8198. if (optionalContent !== undefined) {
  8199. opList.addOp(_util.OPS.beginMarkedContentProps, ["OC", optionalContent]);
  8200. }
  8201. opList.addOp(_util.OPS.beginAnnotation, [this.data.id, this.data.rect, transform, this.getRotationMatrix(annotationStorage), isUsingOwnCanvas]);
  8202. const stream = new _stream.StringStream(content);
  8203. await evaluator.getOperatorList({
  8204. stream,
  8205. task,
  8206. resources: this._fieldResources.mergedResources,
  8207. operatorList: opList
  8208. });
  8209. opList.addOp(_util.OPS.endAnnotation, []);
  8210. if (optionalContent !== undefined) {
  8211. opList.addOp(_util.OPS.endMarkedContent, []);
  8212. }
  8213. return {
  8214. opList,
  8215. separateForm: false,
  8216. separateCanvas: isUsingOwnCanvas
  8217. };
  8218. }
  8219. _getMKDict(rotation) {
  8220. const mk = new _primitives.Dict(null);
  8221. if (rotation) {
  8222. mk.set("R", rotation);
  8223. }
  8224. if (this.borderColor) {
  8225. mk.set("BC", getPdfColorArray(this.borderColor));
  8226. }
  8227. if (this.backgroundColor) {
  8228. mk.set("BG", getPdfColorArray(this.backgroundColor));
  8229. }
  8230. return mk.size > 0 ? mk : null;
  8231. }
  8232. amendSavedDict(annotationStorage, dict) {}
  8233. async save(evaluator, task, annotationStorage) {
  8234. const storageEntry = annotationStorage?.get(this.data.id);
  8235. let value = storageEntry?.value,
  8236. rotation = storageEntry?.rotation;
  8237. if (value === this.data.fieldValue || value === undefined) {
  8238. if (!this._hasValueFromXFA && rotation === undefined) {
  8239. return null;
  8240. }
  8241. value ||= this.data.fieldValue;
  8242. }
  8243. 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])) {
  8244. return null;
  8245. }
  8246. if (rotation === undefined) {
  8247. rotation = this.rotation;
  8248. }
  8249. let appearance = null;
  8250. if (!this._needAppearances) {
  8251. appearance = await this._getAppearance(evaluator, task, _util.RenderingIntentFlag.SAVE, annotationStorage);
  8252. if (appearance === null) {
  8253. return null;
  8254. }
  8255. } else {}
  8256. let needAppearances = false;
  8257. if (appearance?.needAppearances) {
  8258. needAppearances = true;
  8259. appearance = null;
  8260. }
  8261. const {
  8262. xref
  8263. } = evaluator;
  8264. const originalDict = xref.fetchIfRef(this.ref);
  8265. if (!(originalDict instanceof _primitives.Dict)) {
  8266. return null;
  8267. }
  8268. const dict = new _primitives.Dict(xref);
  8269. for (const key of originalDict.getKeys()) {
  8270. if (key !== "AP") {
  8271. dict.set(key, originalDict.getRaw(key));
  8272. }
  8273. }
  8274. const xfa = {
  8275. path: this.data.fieldName,
  8276. value
  8277. };
  8278. const encoder = val => {
  8279. return (0, _core_utils.isAscii)(val) ? val : (0, _core_utils.stringToUTF16String)(val, true);
  8280. };
  8281. dict.set("V", Array.isArray(value) ? value.map(encoder) : encoder(value));
  8282. this.amendSavedDict(annotationStorage, dict);
  8283. const maybeMK = this._getMKDict(rotation);
  8284. if (maybeMK) {
  8285. dict.set("MK", maybeMK);
  8286. }
  8287. const encrypt = xref.encrypt;
  8288. const originalTransform = encrypt ? encrypt.createCipherTransform(this.ref.num, this.ref.gen) : null;
  8289. const buffer = [];
  8290. const changes = [{
  8291. ref: this.ref,
  8292. data: "",
  8293. xfa,
  8294. needAppearances
  8295. }];
  8296. if (appearance !== null) {
  8297. const newRef = xref.getNewTemporaryRef();
  8298. const AP = new _primitives.Dict(xref);
  8299. dict.set("AP", AP);
  8300. AP.set("N", newRef);
  8301. let newTransform = null;
  8302. if (encrypt) {
  8303. newTransform = encrypt.createCipherTransform(newRef.num, newRef.gen);
  8304. }
  8305. const resources = this._getSaveFieldResources(xref);
  8306. const appearanceStream = new _stream.StringStream(appearance);
  8307. const appearanceDict = appearanceStream.dict = new _primitives.Dict(xref);
  8308. appearanceDict.set("Subtype", _primitives.Name.get("Form"));
  8309. appearanceDict.set("Resources", resources);
  8310. appearanceDict.set("BBox", [0, 0, this.data.rect[2] - this.data.rect[0], this.data.rect[3] - this.data.rect[1]]);
  8311. const rotationMatrix = this.getRotationMatrix(annotationStorage);
  8312. if (rotationMatrix !== _util.IDENTITY_MATRIX) {
  8313. appearanceDict.set("Matrix", rotationMatrix);
  8314. }
  8315. await (0, _writer.writeObject)(newRef, appearanceStream, buffer, newTransform);
  8316. changes.push({
  8317. ref: newRef,
  8318. data: buffer.join(""),
  8319. xfa: null,
  8320. needAppearances: false
  8321. });
  8322. buffer.length = 0;
  8323. }
  8324. dict.set("M", `D:${(0, _util.getModificationDate)()}`);
  8325. await (0, _writer.writeObject)(this.ref, dict, buffer, originalTransform);
  8326. changes[0].data = buffer.join("");
  8327. return changes;
  8328. }
  8329. async _getAppearance(evaluator, task, intent, annotationStorage) {
  8330. const isPassword = this.hasFieldFlag(_util.AnnotationFieldFlag.PASSWORD);
  8331. if (isPassword) {
  8332. return null;
  8333. }
  8334. const storageEntry = annotationStorage?.get(this.data.id);
  8335. let value, rotation;
  8336. if (storageEntry) {
  8337. value = storageEntry.formattedValue || storageEntry.value;
  8338. rotation = storageEntry.rotation;
  8339. }
  8340. if (rotation === undefined && value === undefined && !this._needAppearances) {
  8341. if (!this._hasValueFromXFA || this.appearance) {
  8342. return null;
  8343. }
  8344. }
  8345. const colors = this.getBorderAndBackgroundAppearances(annotationStorage);
  8346. if (value === undefined) {
  8347. value = this.data.fieldValue;
  8348. if (!value) {
  8349. return `/Tx BMC q ${colors}Q EMC`;
  8350. }
  8351. }
  8352. if (Array.isArray(value) && value.length === 1) {
  8353. value = value[0];
  8354. }
  8355. (0, _util.assert)(typeof value === "string", "Expected `value` to be a string.");
  8356. value = value.trim();
  8357. if (this.data.combo) {
  8358. const option = this.data.options.find(_ref3 => {
  8359. let {
  8360. exportValue
  8361. } = _ref3;
  8362. return value === exportValue;
  8363. });
  8364. value = option?.displayValue || value;
  8365. }
  8366. if (value === "") {
  8367. return `/Tx BMC q ${colors}Q EMC`;
  8368. }
  8369. if (rotation === undefined) {
  8370. rotation = this.rotation;
  8371. }
  8372. let lineCount = -1;
  8373. let lines;
  8374. if (this.data.multiLine) {
  8375. lines = value.split(/\r\n?|\n/).map(line => line.normalize("NFC"));
  8376. lineCount = lines.length;
  8377. } else {
  8378. lines = [value.replace(/\r\n?|\n/, "").normalize("NFC")];
  8379. }
  8380. const defaultPadding = 1;
  8381. const defaultHPadding = 2;
  8382. let totalHeight = this.data.rect[3] - this.data.rect[1];
  8383. let totalWidth = this.data.rect[2] - this.data.rect[0];
  8384. if (rotation === 90 || rotation === 270) {
  8385. [totalWidth, totalHeight] = [totalHeight, totalWidth];
  8386. }
  8387. if (!this._defaultAppearance) {
  8388. this.data.defaultAppearanceData = (0, _default_appearance.parseDefaultAppearance)(this._defaultAppearance = "/Helvetica 0 Tf 0 g");
  8389. }
  8390. let font = await WidgetAnnotation._getFontData(evaluator, task, this.data.defaultAppearanceData, this._fieldResources.mergedResources);
  8391. let defaultAppearance, fontSize, lineHeight;
  8392. const encodedLines = [];
  8393. let encodingError = false;
  8394. for (const line of lines) {
  8395. const encodedString = font.encodeString(line);
  8396. if (encodedString.length > 1) {
  8397. encodingError = true;
  8398. }
  8399. encodedLines.push(encodedString.join(""));
  8400. }
  8401. if (encodingError && intent & _util.RenderingIntentFlag.SAVE) {
  8402. return {
  8403. needAppearances: true
  8404. };
  8405. }
  8406. if (encodingError && this._isOffscreenCanvasSupported) {
  8407. const fontFamily = this.data.comb ? "monospace" : "sans-serif";
  8408. const fakeUnicodeFont = new _default_appearance.FakeUnicodeFont(evaluator.xref, fontFamily);
  8409. const resources = fakeUnicodeFont.createFontResources(lines.join(""));
  8410. const newFont = resources.getRaw("Font");
  8411. if (this._fieldResources.mergedResources.has("Font")) {
  8412. const oldFont = this._fieldResources.mergedResources.get("Font");
  8413. for (const key of newFont.getKeys()) {
  8414. oldFont.set(key, newFont.getRaw(key));
  8415. }
  8416. } else {
  8417. this._fieldResources.mergedResources.set("Font", newFont);
  8418. }
  8419. const fontName = fakeUnicodeFont.fontName.name;
  8420. font = await WidgetAnnotation._getFontData(evaluator, task, {
  8421. fontName,
  8422. fontSize: 0
  8423. }, resources);
  8424. for (let i = 0, ii = encodedLines.length; i < ii; i++) {
  8425. encodedLines[i] = (0, _core_utils.stringToUTF16String)(lines[i]);
  8426. }
  8427. const savedDefaultAppearance = Object.assign(Object.create(null), this.data.defaultAppearanceData);
  8428. this.data.defaultAppearanceData.fontSize = 0;
  8429. this.data.defaultAppearanceData.fontName = fontName;
  8430. [defaultAppearance, fontSize, lineHeight] = this._computeFontSize(totalHeight - 2 * defaultPadding, totalWidth - 2 * defaultHPadding, value, font, lineCount);
  8431. this.data.defaultAppearanceData = savedDefaultAppearance;
  8432. } else {
  8433. if (!this._isOffscreenCanvasSupported) {
  8434. (0, _util.warn)("_getAppearance: OffscreenCanvas is not supported, annotation may not render correctly.");
  8435. }
  8436. [defaultAppearance, fontSize, lineHeight] = this._computeFontSize(totalHeight - 2 * defaultPadding, totalWidth - 2 * defaultHPadding, value, font, lineCount);
  8437. }
  8438. let descent = font.descent;
  8439. if (isNaN(descent)) {
  8440. descent = _util.BASELINE_FACTOR * lineHeight;
  8441. } else {
  8442. descent = Math.max(_util.BASELINE_FACTOR * lineHeight, Math.abs(descent) * fontSize);
  8443. }
  8444. const defaultVPadding = Math.min(Math.floor((totalHeight - fontSize) / 2), defaultPadding);
  8445. const alignment = this.data.textAlignment;
  8446. if (this.data.multiLine) {
  8447. return this._getMultilineAppearance(defaultAppearance, encodedLines, font, fontSize, totalWidth, totalHeight, alignment, defaultHPadding, defaultVPadding, descent, lineHeight, annotationStorage);
  8448. }
  8449. if (this.data.comb) {
  8450. return this._getCombAppearance(defaultAppearance, font, encodedLines[0], fontSize, totalWidth, totalHeight, defaultHPadding, defaultVPadding, descent, lineHeight, annotationStorage);
  8451. }
  8452. const bottomPadding = defaultVPadding + descent;
  8453. if (alignment === 0 || alignment > 2) {
  8454. 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";
  8455. }
  8456. const prevInfo = {
  8457. shift: 0
  8458. };
  8459. const renderedText = this._renderText(encodedLines[0], font, fontSize, totalWidth, alignment, prevInfo, defaultHPadding, bottomPadding);
  8460. return `/Tx BMC q ${colors}BT ` + defaultAppearance + ` 1 0 0 1 0 0 Tm ${renderedText}` + " ET Q EMC";
  8461. }
  8462. static async _getFontData(evaluator, task, appearanceData, resources) {
  8463. const operatorList = new _operator_list.OperatorList();
  8464. const initialState = {
  8465. font: null,
  8466. clone() {
  8467. return this;
  8468. }
  8469. };
  8470. const {
  8471. fontName,
  8472. fontSize
  8473. } = appearanceData;
  8474. await evaluator.handleSetFont(resources, [fontName && _primitives.Name.get(fontName), fontSize], null, operatorList, task, initialState, null);
  8475. return initialState.font;
  8476. }
  8477. _getTextWidth(text, font) {
  8478. return font.charsToGlyphs(text).reduce((width, glyph) => width + glyph.width, 0) / 1000;
  8479. }
  8480. _computeFontSize(height, width, text, font, lineCount) {
  8481. let {
  8482. fontSize
  8483. } = this.data.defaultAppearanceData;
  8484. let lineHeight = (fontSize || 12) * _util.LINE_FACTOR,
  8485. numberOfLines = Math.round(height / lineHeight);
  8486. if (!fontSize) {
  8487. const roundWithTwoDigits = x => Math.floor(x * 100) / 100;
  8488. if (lineCount === -1) {
  8489. const textWidth = this._getTextWidth(text, font);
  8490. fontSize = roundWithTwoDigits(Math.min(height / _util.LINE_FACTOR, textWidth > width ? width / textWidth : Infinity));
  8491. numberOfLines = 1;
  8492. } else {
  8493. const lines = text.split(/\r\n?|\n/);
  8494. const cachedLines = [];
  8495. for (const line of lines) {
  8496. const encoded = font.encodeString(line).join("");
  8497. const glyphs = font.charsToGlyphs(encoded);
  8498. const positions = font.getCharPositions(encoded);
  8499. cachedLines.push({
  8500. line: encoded,
  8501. glyphs,
  8502. positions
  8503. });
  8504. }
  8505. const isTooBig = fsize => {
  8506. let totalHeight = 0;
  8507. for (const cache of cachedLines) {
  8508. const chunks = this._splitLine(null, font, fsize, width, cache);
  8509. totalHeight += chunks.length * fsize;
  8510. if (totalHeight > height) {
  8511. return true;
  8512. }
  8513. }
  8514. return false;
  8515. };
  8516. numberOfLines = Math.max(numberOfLines, lineCount);
  8517. while (true) {
  8518. lineHeight = height / numberOfLines;
  8519. fontSize = roundWithTwoDigits(lineHeight / _util.LINE_FACTOR);
  8520. if (isTooBig(fontSize)) {
  8521. numberOfLines++;
  8522. continue;
  8523. }
  8524. break;
  8525. }
  8526. }
  8527. const {
  8528. fontName,
  8529. fontColor
  8530. } = this.data.defaultAppearanceData;
  8531. this._defaultAppearance = (0, _default_appearance.createDefaultAppearance)({
  8532. fontSize,
  8533. fontName,
  8534. fontColor
  8535. });
  8536. }
  8537. return [this._defaultAppearance, fontSize, height / numberOfLines];
  8538. }
  8539. _renderText(text, font, fontSize, totalWidth, alignment, prevInfo, hPadding, vPadding) {
  8540. let shift;
  8541. if (alignment === 1) {
  8542. const width = this._getTextWidth(text, font) * fontSize;
  8543. shift = (totalWidth - width) / 2;
  8544. } else if (alignment === 2) {
  8545. const width = this._getTextWidth(text, font) * fontSize;
  8546. shift = totalWidth - width - hPadding;
  8547. } else {
  8548. shift = hPadding;
  8549. }
  8550. const shiftStr = (0, _core_utils.numberToString)(shift - prevInfo.shift);
  8551. prevInfo.shift = shift;
  8552. vPadding = (0, _core_utils.numberToString)(vPadding);
  8553. return `${shiftStr} ${vPadding} Td (${(0, _core_utils.escapeString)(text)}) Tj`;
  8554. }
  8555. _getSaveFieldResources(xref) {
  8556. const {
  8557. localResources,
  8558. appearanceResources,
  8559. acroFormResources
  8560. } = this._fieldResources;
  8561. const fontName = this.data.defaultAppearanceData?.fontName;
  8562. if (!fontName) {
  8563. return localResources || _primitives.Dict.empty;
  8564. }
  8565. for (const resources of [localResources, appearanceResources]) {
  8566. if (resources instanceof _primitives.Dict) {
  8567. const localFont = resources.get("Font");
  8568. if (localFont instanceof _primitives.Dict && localFont.has(fontName)) {
  8569. return resources;
  8570. }
  8571. }
  8572. }
  8573. if (acroFormResources instanceof _primitives.Dict) {
  8574. const acroFormFont = acroFormResources.get("Font");
  8575. if (acroFormFont instanceof _primitives.Dict && acroFormFont.has(fontName)) {
  8576. const subFontDict = new _primitives.Dict(xref);
  8577. subFontDict.set(fontName, acroFormFont.getRaw(fontName));
  8578. const subResourcesDict = new _primitives.Dict(xref);
  8579. subResourcesDict.set("Font", subFontDict);
  8580. return _primitives.Dict.merge({
  8581. xref,
  8582. dictArray: [subResourcesDict, localResources],
  8583. mergeSubDicts: true
  8584. });
  8585. }
  8586. }
  8587. return localResources || _primitives.Dict.empty;
  8588. }
  8589. getFieldObject() {
  8590. return null;
  8591. }
  8592. }
  8593. class TextWidgetAnnotation extends WidgetAnnotation {
  8594. constructor(params) {
  8595. super(params);
  8596. this.data.hasOwnCanvas = this.data.readOnly && !this.data.noHTML;
  8597. this._hasText = true;
  8598. const dict = params.dict;
  8599. if (typeof this.data.fieldValue !== "string") {
  8600. this.data.fieldValue = "";
  8601. }
  8602. let alignment = (0, _core_utils.getInheritableProperty)({
  8603. dict,
  8604. key: "Q"
  8605. });
  8606. if (!Number.isInteger(alignment) || alignment < 0 || alignment > 2) {
  8607. alignment = null;
  8608. }
  8609. this.data.textAlignment = alignment;
  8610. let maximumLength = (0, _core_utils.getInheritableProperty)({
  8611. dict,
  8612. key: "MaxLen"
  8613. });
  8614. if (!Number.isInteger(maximumLength) || maximumLength < 0) {
  8615. maximumLength = 0;
  8616. }
  8617. this.data.maxLen = maximumLength;
  8618. this.data.multiLine = this.hasFieldFlag(_util.AnnotationFieldFlag.MULTILINE);
  8619. 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;
  8620. this.data.doNotScroll = this.hasFieldFlag(_util.AnnotationFieldFlag.DONOTSCROLL);
  8621. }
  8622. get hasTextContent() {
  8623. return !!this.appearance && !this._needAppearances;
  8624. }
  8625. _getCombAppearance(defaultAppearance, font, text, fontSize, width, height, hPadding, vPadding, descent, lineHeight, annotationStorage) {
  8626. const combWidth = width / this.data.maxLen;
  8627. const colors = this.getBorderAndBackgroundAppearances(annotationStorage);
  8628. const buf = [];
  8629. const positions = font.getCharPositions(text);
  8630. for (const [start, end] of positions) {
  8631. buf.push(`(${(0, _core_utils.escapeString)(text.substring(start, end))}) Tj`);
  8632. }
  8633. const renderedComb = buf.join(` ${(0, _core_utils.numberToString)(combWidth)} 0 Td `);
  8634. 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";
  8635. }
  8636. _getMultilineAppearance(defaultAppearance, lines, font, fontSize, width, height, alignment, hPadding, vPadding, descent, lineHeight, annotationStorage) {
  8637. const buf = [];
  8638. const totalWidth = width - 2 * hPadding;
  8639. const prevInfo = {
  8640. shift: 0
  8641. };
  8642. for (let i = 0, ii = lines.length; i < ii; i++) {
  8643. const line = lines[i];
  8644. const chunks = this._splitLine(line, font, fontSize, totalWidth);
  8645. for (let j = 0, jj = chunks.length; j < jj; j++) {
  8646. const chunk = chunks[j];
  8647. const vShift = i === 0 && j === 0 ? -vPadding - (lineHeight - descent) : -lineHeight;
  8648. buf.push(this._renderText(chunk, font, fontSize, width, alignment, prevInfo, hPadding, vShift));
  8649. }
  8650. }
  8651. const colors = this.getBorderAndBackgroundAppearances(annotationStorage);
  8652. const renderedText = buf.join("\n");
  8653. return `/Tx BMC q ${colors}BT ` + defaultAppearance + ` 1 0 0 1 0 ${(0, _core_utils.numberToString)(height)} Tm ${renderedText}` + " ET Q EMC";
  8654. }
  8655. _splitLine(line, font, fontSize, width) {
  8656. let cache = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {};
  8657. line = cache.line || line;
  8658. const glyphs = cache.glyphs || font.charsToGlyphs(line);
  8659. if (glyphs.length <= 1) {
  8660. return [line];
  8661. }
  8662. const positions = cache.positions || font.getCharPositions(line);
  8663. const scale = fontSize / 1000;
  8664. const chunks = [];
  8665. let lastSpacePosInStringStart = -1,
  8666. lastSpacePosInStringEnd = -1,
  8667. lastSpacePos = -1,
  8668. startChunk = 0,
  8669. currentWidth = 0;
  8670. for (let i = 0, ii = glyphs.length; i < ii; i++) {
  8671. const [start, end] = positions[i];
  8672. const glyph = glyphs[i];
  8673. const glyphWidth = glyph.width * scale;
  8674. if (glyph.unicode === " ") {
  8675. if (currentWidth + glyphWidth > width) {
  8676. chunks.push(line.substring(startChunk, start));
  8677. startChunk = start;
  8678. currentWidth = glyphWidth;
  8679. lastSpacePosInStringStart = -1;
  8680. lastSpacePos = -1;
  8681. } else {
  8682. currentWidth += glyphWidth;
  8683. lastSpacePosInStringStart = start;
  8684. lastSpacePosInStringEnd = end;
  8685. lastSpacePos = i;
  8686. }
  8687. } else if (currentWidth + glyphWidth > width) {
  8688. if (lastSpacePosInStringStart !== -1) {
  8689. chunks.push(line.substring(startChunk, lastSpacePosInStringEnd));
  8690. startChunk = lastSpacePosInStringEnd;
  8691. i = lastSpacePos + 1;
  8692. lastSpacePosInStringStart = -1;
  8693. currentWidth = 0;
  8694. } else {
  8695. chunks.push(line.substring(startChunk, start));
  8696. startChunk = start;
  8697. currentWidth = glyphWidth;
  8698. }
  8699. } else {
  8700. currentWidth += glyphWidth;
  8701. }
  8702. }
  8703. if (startChunk < line.length) {
  8704. chunks.push(line.substring(startChunk, line.length));
  8705. }
  8706. return chunks;
  8707. }
  8708. getFieldObject() {
  8709. return {
  8710. id: this.data.id,
  8711. value: this.data.fieldValue,
  8712. defaultValue: this.data.defaultFieldValue || "",
  8713. multiline: this.data.multiLine,
  8714. password: this.hasFieldFlag(_util.AnnotationFieldFlag.PASSWORD),
  8715. charLimit: this.data.maxLen,
  8716. comb: this.data.comb,
  8717. editable: !this.data.readOnly,
  8718. hidden: this.data.hidden,
  8719. name: this.data.fieldName,
  8720. rect: this.data.rect,
  8721. actions: this.data.actions,
  8722. page: this.data.pageIndex,
  8723. strokeColor: this.data.borderColor,
  8724. fillColor: this.data.backgroundColor,
  8725. rotation: this.rotation,
  8726. type: "text"
  8727. };
  8728. }
  8729. }
  8730. class ButtonWidgetAnnotation extends WidgetAnnotation {
  8731. constructor(params) {
  8732. super(params);
  8733. this.checkedAppearance = null;
  8734. this.uncheckedAppearance = null;
  8735. this.data.checkBox = !this.hasFieldFlag(_util.AnnotationFieldFlag.RADIO) && !this.hasFieldFlag(_util.AnnotationFieldFlag.PUSHBUTTON);
  8736. this.data.radioButton = this.hasFieldFlag(_util.AnnotationFieldFlag.RADIO) && !this.hasFieldFlag(_util.AnnotationFieldFlag.PUSHBUTTON);
  8737. this.data.pushButton = this.hasFieldFlag(_util.AnnotationFieldFlag.PUSHBUTTON);
  8738. this.data.isTooltipOnly = false;
  8739. if (this.data.checkBox) {
  8740. this._processCheckBox(params);
  8741. } else if (this.data.radioButton) {
  8742. this._processRadioButton(params);
  8743. } else if (this.data.pushButton) {
  8744. this.data.hasOwnCanvas = true;
  8745. this._processPushButton(params);
  8746. } else {
  8747. (0, _util.warn)("Invalid field flags for button widget annotation");
  8748. }
  8749. }
  8750. async getOperatorList(evaluator, task, intent, renderForms, annotationStorage) {
  8751. if (this.data.pushButton) {
  8752. return super.getOperatorList(evaluator, task, intent, false, annotationStorage);
  8753. }
  8754. let value = null;
  8755. let rotation = null;
  8756. if (annotationStorage) {
  8757. const storageEntry = annotationStorage.get(this.data.id);
  8758. value = storageEntry ? storageEntry.value : null;
  8759. rotation = storageEntry ? storageEntry.rotation : null;
  8760. }
  8761. if (value === null && this.appearance) {
  8762. return super.getOperatorList(evaluator, task, intent, renderForms, annotationStorage);
  8763. }
  8764. if (value === null || value === undefined) {
  8765. value = this.data.checkBox ? this.data.fieldValue === this.data.exportValue : this.data.fieldValue === this.data.buttonValue;
  8766. }
  8767. const appearance = value ? this.checkedAppearance : this.uncheckedAppearance;
  8768. if (appearance) {
  8769. const savedAppearance = this.appearance;
  8770. const savedMatrix = appearance.dict.getArray("Matrix") || _util.IDENTITY_MATRIX;
  8771. if (rotation) {
  8772. appearance.dict.set("Matrix", this.getRotationMatrix(annotationStorage));
  8773. }
  8774. this.appearance = appearance;
  8775. const operatorList = super.getOperatorList(evaluator, task, intent, renderForms, annotationStorage);
  8776. this.appearance = savedAppearance;
  8777. appearance.dict.set("Matrix", savedMatrix);
  8778. return operatorList;
  8779. }
  8780. return {
  8781. opList: new _operator_list.OperatorList(),
  8782. separateForm: false,
  8783. separateCanvas: false
  8784. };
  8785. }
  8786. async save(evaluator, task, annotationStorage) {
  8787. if (this.data.checkBox) {
  8788. return this._saveCheckbox(evaluator, task, annotationStorage);
  8789. }
  8790. if (this.data.radioButton) {
  8791. return this._saveRadioButton(evaluator, task, annotationStorage);
  8792. }
  8793. return null;
  8794. }
  8795. async _saveCheckbox(evaluator, task, annotationStorage) {
  8796. if (!annotationStorage) {
  8797. return null;
  8798. }
  8799. const storageEntry = annotationStorage.get(this.data.id);
  8800. let rotation = storageEntry?.rotation,
  8801. value = storageEntry?.value;
  8802. if (rotation === undefined) {
  8803. if (value === undefined) {
  8804. return null;
  8805. }
  8806. const defaultValue = this.data.fieldValue === this.data.exportValue;
  8807. if (defaultValue === value) {
  8808. return null;
  8809. }
  8810. }
  8811. const dict = evaluator.xref.fetchIfRef(this.ref);
  8812. if (!(dict instanceof _primitives.Dict)) {
  8813. return null;
  8814. }
  8815. if (rotation === undefined) {
  8816. rotation = this.rotation;
  8817. }
  8818. if (value === undefined) {
  8819. value = this.data.fieldValue === this.data.exportValue;
  8820. }
  8821. const xfa = {
  8822. path: this.data.fieldName,
  8823. value: value ? this.data.exportValue : ""
  8824. };
  8825. const name = _primitives.Name.get(value ? this.data.exportValue : "Off");
  8826. dict.set("V", name);
  8827. dict.set("AS", name);
  8828. dict.set("M", `D:${(0, _util.getModificationDate)()}`);
  8829. const maybeMK = this._getMKDict(rotation);
  8830. if (maybeMK) {
  8831. dict.set("MK", maybeMK);
  8832. }
  8833. const encrypt = evaluator.xref.encrypt;
  8834. let originalTransform = null;
  8835. if (encrypt) {
  8836. originalTransform = encrypt.createCipherTransform(this.ref.num, this.ref.gen);
  8837. }
  8838. const buffer = [`${this.ref.num} ${this.ref.gen} obj\n`];
  8839. await (0, _writer.writeDict)(dict, buffer, originalTransform);
  8840. buffer.push("\nendobj\n");
  8841. return [{
  8842. ref: this.ref,
  8843. data: buffer.join(""),
  8844. xfa
  8845. }];
  8846. }
  8847. async _saveRadioButton(evaluator, task, annotationStorage) {
  8848. if (!annotationStorage) {
  8849. return null;
  8850. }
  8851. const storageEntry = annotationStorage.get(this.data.id);
  8852. let rotation = storageEntry?.rotation,
  8853. value = storageEntry?.value;
  8854. if (rotation === undefined) {
  8855. if (value === undefined) {
  8856. return null;
  8857. }
  8858. const defaultValue = this.data.fieldValue === this.data.buttonValue;
  8859. if (defaultValue === value) {
  8860. return null;
  8861. }
  8862. }
  8863. const dict = evaluator.xref.fetchIfRef(this.ref);
  8864. if (!(dict instanceof _primitives.Dict)) {
  8865. return null;
  8866. }
  8867. if (value === undefined) {
  8868. value = this.data.fieldValue === this.data.buttonValue;
  8869. }
  8870. if (rotation === undefined) {
  8871. rotation = this.rotation;
  8872. }
  8873. const xfa = {
  8874. path: this.data.fieldName,
  8875. value: value ? this.data.buttonValue : ""
  8876. };
  8877. const name = _primitives.Name.get(value ? this.data.buttonValue : "Off");
  8878. let parentBuffer = null;
  8879. const encrypt = evaluator.xref.encrypt;
  8880. if (value) {
  8881. if (this.parent instanceof _primitives.Ref) {
  8882. const parent = evaluator.xref.fetch(this.parent);
  8883. let parentTransform = null;
  8884. if (encrypt) {
  8885. parentTransform = encrypt.createCipherTransform(this.parent.num, this.parent.gen);
  8886. }
  8887. parent.set("V", name);
  8888. parentBuffer = [`${this.parent.num} ${this.parent.gen} obj\n`];
  8889. await (0, _writer.writeDict)(parent, parentBuffer, parentTransform);
  8890. parentBuffer.push("\nendobj\n");
  8891. } else if (this.parent instanceof _primitives.Dict) {
  8892. this.parent.set("V", name);
  8893. }
  8894. }
  8895. dict.set("AS", name);
  8896. dict.set("M", `D:${(0, _util.getModificationDate)()}`);
  8897. const maybeMK = this._getMKDict(rotation);
  8898. if (maybeMK) {
  8899. dict.set("MK", maybeMK);
  8900. }
  8901. let originalTransform = null;
  8902. if (encrypt) {
  8903. originalTransform = encrypt.createCipherTransform(this.ref.num, this.ref.gen);
  8904. }
  8905. const buffer = [`${this.ref.num} ${this.ref.gen} obj\n`];
  8906. await (0, _writer.writeDict)(dict, buffer, originalTransform);
  8907. buffer.push("\nendobj\n");
  8908. const newRefs = [{
  8909. ref: this.ref,
  8910. data: buffer.join(""),
  8911. xfa
  8912. }];
  8913. if (parentBuffer !== null) {
  8914. newRefs.push({
  8915. ref: this.parent,
  8916. data: parentBuffer.join(""),
  8917. xfa: null
  8918. });
  8919. }
  8920. return newRefs;
  8921. }
  8922. _getDefaultCheckedAppearance(params, type) {
  8923. const width = this.data.rect[2] - this.data.rect[0];
  8924. const height = this.data.rect[3] - this.data.rect[1];
  8925. const bbox = [0, 0, width, height];
  8926. const FONT_RATIO = 0.8;
  8927. const fontSize = Math.min(width, height) * FONT_RATIO;
  8928. let metrics, char;
  8929. if (type === "check") {
  8930. metrics = {
  8931. width: 0.755 * fontSize,
  8932. height: 0.705 * fontSize
  8933. };
  8934. char = "\x33";
  8935. } else if (type === "disc") {
  8936. metrics = {
  8937. width: 0.791 * fontSize,
  8938. height: 0.705 * fontSize
  8939. };
  8940. char = "\x6C";
  8941. } else {
  8942. (0, _util.unreachable)(`_getDefaultCheckedAppearance - unsupported type: ${type}`);
  8943. }
  8944. const xShift = (0, _core_utils.numberToString)((width - metrics.width) / 2);
  8945. const yShift = (0, _core_utils.numberToString)((height - metrics.height) / 2);
  8946. const appearance = `q BT /PdfJsZaDb ${fontSize} Tf 0 g ${xShift} ${yShift} Td (${char}) Tj ET Q`;
  8947. const appearanceStreamDict = new _primitives.Dict(params.xref);
  8948. appearanceStreamDict.set("FormType", 1);
  8949. appearanceStreamDict.set("Subtype", _primitives.Name.get("Form"));
  8950. appearanceStreamDict.set("Type", _primitives.Name.get("XObject"));
  8951. appearanceStreamDict.set("BBox", bbox);
  8952. appearanceStreamDict.set("Matrix", [1, 0, 0, 1, 0, 0]);
  8953. appearanceStreamDict.set("Length", appearance.length);
  8954. const resources = new _primitives.Dict(params.xref);
  8955. const font = new _primitives.Dict(params.xref);
  8956. font.set("PdfJsZaDb", this.fallbackFontDict);
  8957. resources.set("Font", font);
  8958. appearanceStreamDict.set("Resources", resources);
  8959. this.checkedAppearance = new _stream.StringStream(appearance);
  8960. this.checkedAppearance.dict = appearanceStreamDict;
  8961. this._streams.push(this.checkedAppearance);
  8962. }
  8963. _processCheckBox(params) {
  8964. const customAppearance = params.dict.get("AP");
  8965. if (!(customAppearance instanceof _primitives.Dict)) {
  8966. return;
  8967. }
  8968. const normalAppearance = customAppearance.get("N");
  8969. if (!(normalAppearance instanceof _primitives.Dict)) {
  8970. return;
  8971. }
  8972. const asValue = this._decodeFormValue(params.dict.get("AS"));
  8973. if (typeof asValue === "string") {
  8974. this.data.fieldValue = asValue;
  8975. }
  8976. const yes = this.data.fieldValue !== null && this.data.fieldValue !== "Off" ? this.data.fieldValue : "Yes";
  8977. const exportValues = normalAppearance.getKeys();
  8978. if (exportValues.length === 0) {
  8979. exportValues.push("Off", yes);
  8980. } else if (exportValues.length === 1) {
  8981. if (exportValues[0] === "Off") {
  8982. exportValues.push(yes);
  8983. } else {
  8984. exportValues.unshift("Off");
  8985. }
  8986. } else if (exportValues.includes(yes)) {
  8987. exportValues.length = 0;
  8988. exportValues.push("Off", yes);
  8989. } else {
  8990. const otherYes = exportValues.find(v => v !== "Off");
  8991. exportValues.length = 0;
  8992. exportValues.push("Off", otherYes);
  8993. }
  8994. if (!exportValues.includes(this.data.fieldValue)) {
  8995. this.data.fieldValue = "Off";
  8996. }
  8997. this.data.exportValue = exportValues[1];
  8998. const checkedAppearance = normalAppearance.get(this.data.exportValue);
  8999. this.checkedAppearance = checkedAppearance instanceof _base_stream.BaseStream ? checkedAppearance : null;
  9000. const uncheckedAppearance = normalAppearance.get("Off");
  9001. this.uncheckedAppearance = uncheckedAppearance instanceof _base_stream.BaseStream ? uncheckedAppearance : null;
  9002. if (this.checkedAppearance) {
  9003. this._streams.push(this.checkedAppearance);
  9004. } else {
  9005. this._getDefaultCheckedAppearance(params, "check");
  9006. }
  9007. if (this.uncheckedAppearance) {
  9008. this._streams.push(this.uncheckedAppearance);
  9009. }
  9010. this._fallbackFontDict = this.fallbackFontDict;
  9011. if (this.data.defaultFieldValue === null) {
  9012. this.data.defaultFieldValue = "Off";
  9013. }
  9014. }
  9015. _processRadioButton(params) {
  9016. this.data.fieldValue = this.data.buttonValue = null;
  9017. const fieldParent = params.dict.get("Parent");
  9018. if (fieldParent instanceof _primitives.Dict) {
  9019. this.parent = params.dict.getRaw("Parent");
  9020. const fieldParentValue = fieldParent.get("V");
  9021. if (fieldParentValue instanceof _primitives.Name) {
  9022. this.data.fieldValue = this._decodeFormValue(fieldParentValue);
  9023. }
  9024. }
  9025. const appearanceStates = params.dict.get("AP");
  9026. if (!(appearanceStates instanceof _primitives.Dict)) {
  9027. return;
  9028. }
  9029. const normalAppearance = appearanceStates.get("N");
  9030. if (!(normalAppearance instanceof _primitives.Dict)) {
  9031. return;
  9032. }
  9033. for (const key of normalAppearance.getKeys()) {
  9034. if (key !== "Off") {
  9035. this.data.buttonValue = this._decodeFormValue(key);
  9036. break;
  9037. }
  9038. }
  9039. const checkedAppearance = normalAppearance.get(this.data.buttonValue);
  9040. this.checkedAppearance = checkedAppearance instanceof _base_stream.BaseStream ? checkedAppearance : null;
  9041. const uncheckedAppearance = normalAppearance.get("Off");
  9042. this.uncheckedAppearance = uncheckedAppearance instanceof _base_stream.BaseStream ? uncheckedAppearance : null;
  9043. if (this.checkedAppearance) {
  9044. this._streams.push(this.checkedAppearance);
  9045. } else {
  9046. this._getDefaultCheckedAppearance(params, "disc");
  9047. }
  9048. if (this.uncheckedAppearance) {
  9049. this._streams.push(this.uncheckedAppearance);
  9050. }
  9051. this._fallbackFontDict = this.fallbackFontDict;
  9052. if (this.data.defaultFieldValue === null) {
  9053. this.data.defaultFieldValue = "Off";
  9054. }
  9055. }
  9056. _processPushButton(params) {
  9057. if (!params.dict.has("A") && !params.dict.has("AA") && !this.data.alternativeText) {
  9058. (0, _util.warn)("Push buttons without action dictionaries are not supported");
  9059. return;
  9060. }
  9061. this.data.isTooltipOnly = !params.dict.has("A") && !params.dict.has("AA");
  9062. _catalog.Catalog.parseDestDictionary({
  9063. destDict: params.dict,
  9064. resultObj: this.data,
  9065. docBaseUrl: params.pdfManager.docBaseUrl,
  9066. docAttachments: params.attachments
  9067. });
  9068. }
  9069. getFieldObject() {
  9070. let type = "button";
  9071. let exportValues;
  9072. if (this.data.checkBox) {
  9073. type = "checkbox";
  9074. exportValues = this.data.exportValue;
  9075. } else if (this.data.radioButton) {
  9076. type = "radiobutton";
  9077. exportValues = this.data.buttonValue;
  9078. }
  9079. return {
  9080. id: this.data.id,
  9081. value: this.data.fieldValue || "Off",
  9082. defaultValue: this.data.defaultFieldValue,
  9083. exportValues,
  9084. editable: !this.data.readOnly,
  9085. name: this.data.fieldName,
  9086. rect: this.data.rect,
  9087. hidden: this.data.hidden,
  9088. actions: this.data.actions,
  9089. page: this.data.pageIndex,
  9090. strokeColor: this.data.borderColor,
  9091. fillColor: this.data.backgroundColor,
  9092. rotation: this.rotation,
  9093. type
  9094. };
  9095. }
  9096. get fallbackFontDict() {
  9097. const dict = new _primitives.Dict();
  9098. dict.set("BaseFont", _primitives.Name.get("ZapfDingbats"));
  9099. dict.set("Type", _primitives.Name.get("FallbackType"));
  9100. dict.set("Subtype", _primitives.Name.get("FallbackType"));
  9101. dict.set("Encoding", _primitives.Name.get("ZapfDingbatsEncoding"));
  9102. return (0, _util.shadow)(this, "fallbackFontDict", dict);
  9103. }
  9104. }
  9105. class ChoiceWidgetAnnotation extends WidgetAnnotation {
  9106. constructor(params) {
  9107. super(params);
  9108. const {
  9109. dict,
  9110. xref
  9111. } = params;
  9112. this.indices = dict.getArray("I");
  9113. this.hasIndices = Array.isArray(this.indices) && this.indices.length > 0;
  9114. this.data.options = [];
  9115. const options = (0, _core_utils.getInheritableProperty)({
  9116. dict,
  9117. key: "Opt"
  9118. });
  9119. if (Array.isArray(options)) {
  9120. for (let i = 0, ii = options.length; i < ii; i++) {
  9121. const option = xref.fetchIfRef(options[i]);
  9122. const isOptionArray = Array.isArray(option);
  9123. this.data.options[i] = {
  9124. exportValue: this._decodeFormValue(isOptionArray ? xref.fetchIfRef(option[0]) : option),
  9125. displayValue: this._decodeFormValue(isOptionArray ? xref.fetchIfRef(option[1]) : option)
  9126. };
  9127. }
  9128. }
  9129. if (!this.hasIndices) {
  9130. if (typeof this.data.fieldValue === "string") {
  9131. this.data.fieldValue = [this.data.fieldValue];
  9132. } else if (!this.data.fieldValue) {
  9133. this.data.fieldValue = [];
  9134. }
  9135. } else {
  9136. this.data.fieldValue = [];
  9137. const ii = this.data.options.length;
  9138. for (const i of this.indices) {
  9139. if (Number.isInteger(i) && i >= 0 && i < ii) {
  9140. this.data.fieldValue.push(this.data.options[i].exportValue);
  9141. }
  9142. }
  9143. }
  9144. this.data.combo = this.hasFieldFlag(_util.AnnotationFieldFlag.COMBO);
  9145. this.data.multiSelect = this.hasFieldFlag(_util.AnnotationFieldFlag.MULTISELECT);
  9146. this._hasText = true;
  9147. }
  9148. getFieldObject() {
  9149. const type = this.data.combo ? "combobox" : "listbox";
  9150. const value = this.data.fieldValue.length > 0 ? this.data.fieldValue[0] : null;
  9151. return {
  9152. id: this.data.id,
  9153. value,
  9154. defaultValue: this.data.defaultFieldValue,
  9155. editable: !this.data.readOnly,
  9156. name: this.data.fieldName,
  9157. rect: this.data.rect,
  9158. numItems: this.data.fieldValue.length,
  9159. multipleSelection: this.data.multiSelect,
  9160. hidden: this.data.hidden,
  9161. actions: this.data.actions,
  9162. items: this.data.options,
  9163. page: this.data.pageIndex,
  9164. strokeColor: this.data.borderColor,
  9165. fillColor: this.data.backgroundColor,
  9166. rotation: this.rotation,
  9167. type
  9168. };
  9169. }
  9170. amendSavedDict(annotationStorage, dict) {
  9171. if (!this.hasIndices) {
  9172. return;
  9173. }
  9174. let values = annotationStorage?.get(this.data.id)?.value;
  9175. if (!Array.isArray(values)) {
  9176. values = [values];
  9177. }
  9178. const indices = [];
  9179. const {
  9180. options
  9181. } = this.data;
  9182. for (let i = 0, j = 0, ii = options.length; i < ii; i++) {
  9183. if (options[i].exportValue === values[j]) {
  9184. indices.push(i);
  9185. j += 1;
  9186. }
  9187. }
  9188. dict.set("I", indices);
  9189. }
  9190. async _getAppearance(evaluator, task, intent, annotationStorage) {
  9191. if (this.data.combo) {
  9192. return super._getAppearance(evaluator, task, intent, annotationStorage);
  9193. }
  9194. let exportedValue, rotation;
  9195. const storageEntry = annotationStorage?.get(this.data.id);
  9196. if (storageEntry) {
  9197. rotation = storageEntry.rotation;
  9198. exportedValue = storageEntry.value;
  9199. }
  9200. if (rotation === undefined && exportedValue === undefined && !this._needAppearances) {
  9201. return null;
  9202. }
  9203. if (exportedValue === undefined) {
  9204. exportedValue = this.data.fieldValue;
  9205. } else if (!Array.isArray(exportedValue)) {
  9206. exportedValue = [exportedValue];
  9207. }
  9208. const defaultPadding = 1;
  9209. const defaultHPadding = 2;
  9210. let totalHeight = this.data.rect[3] - this.data.rect[1];
  9211. let totalWidth = this.data.rect[2] - this.data.rect[0];
  9212. if (rotation === 90 || rotation === 270) {
  9213. [totalWidth, totalHeight] = [totalHeight, totalWidth];
  9214. }
  9215. const lineCount = this.data.options.length;
  9216. const valueIndices = [];
  9217. for (let i = 0; i < lineCount; i++) {
  9218. const {
  9219. exportValue
  9220. } = this.data.options[i];
  9221. if (exportedValue.includes(exportValue)) {
  9222. valueIndices.push(i);
  9223. }
  9224. }
  9225. if (!this._defaultAppearance) {
  9226. this.data.defaultAppearanceData = (0, _default_appearance.parseDefaultAppearance)(this._defaultAppearance = "/Helvetica 0 Tf 0 g");
  9227. }
  9228. const font = await WidgetAnnotation._getFontData(evaluator, task, this.data.defaultAppearanceData, this._fieldResources.mergedResources);
  9229. let defaultAppearance;
  9230. let {
  9231. fontSize
  9232. } = this.data.defaultAppearanceData;
  9233. if (!fontSize) {
  9234. const lineHeight = (totalHeight - defaultPadding) / lineCount;
  9235. let lineWidth = -1;
  9236. let value;
  9237. for (const {
  9238. displayValue
  9239. } of this.data.options) {
  9240. const width = this._getTextWidth(displayValue, font);
  9241. if (width > lineWidth) {
  9242. lineWidth = width;
  9243. value = displayValue;
  9244. }
  9245. }
  9246. [defaultAppearance, fontSize] = this._computeFontSize(lineHeight, totalWidth - 2 * defaultHPadding, value, font, -1);
  9247. } else {
  9248. defaultAppearance = this._defaultAppearance;
  9249. }
  9250. const lineHeight = fontSize * _util.LINE_FACTOR;
  9251. const vPadding = (lineHeight - fontSize) / 2;
  9252. const numberOfVisibleLines = Math.floor(totalHeight / lineHeight);
  9253. let firstIndex = 0;
  9254. if (valueIndices.length > 0) {
  9255. const minIndex = Math.min(...valueIndices);
  9256. const maxIndex = Math.max(...valueIndices);
  9257. firstIndex = Math.max(0, maxIndex - numberOfVisibleLines + 1);
  9258. if (firstIndex > minIndex) {
  9259. firstIndex = minIndex;
  9260. }
  9261. }
  9262. const end = Math.min(firstIndex + numberOfVisibleLines + 1, lineCount);
  9263. const buf = ["/Tx BMC q", `1 1 ${totalWidth} ${totalHeight} re W n`];
  9264. if (valueIndices.length) {
  9265. buf.push("0.600006 0.756866 0.854904 rg");
  9266. for (const index of valueIndices) {
  9267. if (firstIndex <= index && index < end) {
  9268. buf.push(`1 ${totalHeight - (index - firstIndex + 1) * lineHeight} ${totalWidth} ${lineHeight} re f`);
  9269. }
  9270. }
  9271. }
  9272. buf.push("BT", defaultAppearance, `1 0 0 1 0 ${totalHeight} Tm`);
  9273. const prevInfo = {
  9274. shift: 0
  9275. };
  9276. for (let i = firstIndex; i < end; i++) {
  9277. const {
  9278. displayValue
  9279. } = this.data.options[i];
  9280. const vpadding = i === firstIndex ? vPadding : 0;
  9281. buf.push(this._renderText(displayValue, font, fontSize, totalWidth, 0, prevInfo, defaultHPadding, -lineHeight + vpadding));
  9282. }
  9283. buf.push("ET Q EMC");
  9284. return buf.join("\n");
  9285. }
  9286. }
  9287. class SignatureWidgetAnnotation extends WidgetAnnotation {
  9288. constructor(params) {
  9289. super(params);
  9290. this.data.fieldValue = null;
  9291. this.data.hasOwnCanvas = this.data.noRotate;
  9292. }
  9293. getFieldObject() {
  9294. return {
  9295. id: this.data.id,
  9296. value: null,
  9297. page: this.data.pageIndex,
  9298. type: "signature"
  9299. };
  9300. }
  9301. }
  9302. class TextAnnotation extends MarkupAnnotation {
  9303. constructor(params) {
  9304. const DEFAULT_ICON_SIZE = 22;
  9305. super(params);
  9306. this.data.noRotate = true;
  9307. this.data.hasOwnCanvas = this.data.noRotate;
  9308. const {
  9309. dict
  9310. } = params;
  9311. this.data.annotationType = _util.AnnotationType.TEXT;
  9312. if (this.data.hasAppearance) {
  9313. this.data.name = "NoIcon";
  9314. } else {
  9315. this.data.rect[1] = this.data.rect[3] - DEFAULT_ICON_SIZE;
  9316. this.data.rect[2] = this.data.rect[0] + DEFAULT_ICON_SIZE;
  9317. this.data.name = dict.has("Name") ? dict.get("Name").name : "Note";
  9318. }
  9319. if (dict.has("State")) {
  9320. this.data.state = dict.get("State") || null;
  9321. this.data.stateModel = dict.get("StateModel") || null;
  9322. } else {
  9323. this.data.state = null;
  9324. this.data.stateModel = null;
  9325. }
  9326. }
  9327. }
  9328. class LinkAnnotation extends Annotation {
  9329. constructor(params) {
  9330. super(params);
  9331. this.data.annotationType = _util.AnnotationType.LINK;
  9332. const quadPoints = getQuadPoints(params.dict, this.rectangle);
  9333. if (quadPoints) {
  9334. this.data.quadPoints = quadPoints;
  9335. }
  9336. this.data.borderColor ||= this.data.color;
  9337. _catalog.Catalog.parseDestDictionary({
  9338. destDict: params.dict,
  9339. resultObj: this.data,
  9340. docBaseUrl: params.pdfManager.docBaseUrl,
  9341. docAttachments: params.attachments
  9342. });
  9343. }
  9344. }
  9345. class PopupAnnotation extends Annotation {
  9346. constructor(params) {
  9347. super(params);
  9348. const {
  9349. dict
  9350. } = params;
  9351. this.data.annotationType = _util.AnnotationType.POPUP;
  9352. if (this.data.rect[0] === this.data.rect[2] || this.data.rect[1] === this.data.rect[3]) {
  9353. this.data.rect = null;
  9354. }
  9355. let parentItem = dict.get("Parent");
  9356. if (!parentItem) {
  9357. (0, _util.warn)("Popup annotation has a missing or invalid parent annotation.");
  9358. return;
  9359. }
  9360. const parentRect = parentItem.getArray("Rect");
  9361. this.data.parentRect = Array.isArray(parentRect) && parentRect.length === 4 ? _util.Util.normalizeRect(parentRect) : null;
  9362. const rt = parentItem.get("RT");
  9363. if ((0, _primitives.isName)(rt, _util.AnnotationReplyType.GROUP)) {
  9364. parentItem = parentItem.get("IRT");
  9365. }
  9366. if (!parentItem.has("M")) {
  9367. this.data.modificationDate = null;
  9368. } else {
  9369. this.setModificationDate(parentItem.get("M"));
  9370. this.data.modificationDate = this.modificationDate;
  9371. }
  9372. if (!parentItem.has("C")) {
  9373. this.data.color = null;
  9374. } else {
  9375. this.setColor(parentItem.getArray("C"));
  9376. this.data.color = this.color;
  9377. }
  9378. if (!this.viewable) {
  9379. const parentFlags = parentItem.get("F");
  9380. if (this._isViewable(parentFlags)) {
  9381. this.setFlags(parentFlags);
  9382. }
  9383. }
  9384. this.setTitle(parentItem.get("T"));
  9385. this.data.titleObj = this._title;
  9386. this.setContents(parentItem.get("Contents"));
  9387. this.data.contentsObj = this._contents;
  9388. if (parentItem.has("RC")) {
  9389. this.data.richText = _factory.XFAFactory.getRichTextAsHtml(parentItem.get("RC"));
  9390. }
  9391. this.data.open = !!dict.get("Open");
  9392. }
  9393. }
  9394. exports.PopupAnnotation = PopupAnnotation;
  9395. class FreeTextAnnotation extends MarkupAnnotation {
  9396. constructor(params) {
  9397. super(params);
  9398. this.data.hasOwnCanvas = true;
  9399. const {
  9400. evaluatorOptions,
  9401. xref
  9402. } = params;
  9403. this.data.annotationType = _util.AnnotationType.FREETEXT;
  9404. this.setDefaultAppearance(params);
  9405. if (this.appearance) {
  9406. const {
  9407. fontColor,
  9408. fontSize
  9409. } = (0, _default_appearance.parseAppearanceStream)(this.appearance, evaluatorOptions, xref);
  9410. this.data.defaultAppearanceData.fontColor = fontColor;
  9411. this.data.defaultAppearanceData.fontSize = fontSize || 10;
  9412. } else if (this._isOffscreenCanvasSupported) {
  9413. const strokeAlpha = params.dict.get("CA");
  9414. const fakeUnicodeFont = new _default_appearance.FakeUnicodeFont(xref, "sans-serif");
  9415. this.data.defaultAppearanceData.fontSize ||= 10;
  9416. const {
  9417. fontColor,
  9418. fontSize
  9419. } = this.data.defaultAppearanceData;
  9420. this.appearance = fakeUnicodeFont.createAppearance(this._contents.str, this.rectangle, this.rotation, fontSize, fontColor, strokeAlpha);
  9421. this._streams.push(this.appearance, _default_appearance.FakeUnicodeFont.toUnicodeStream);
  9422. } else {
  9423. (0, _util.warn)("FreeTextAnnotation: OffscreenCanvas is not supported, annotation may not render correctly.");
  9424. }
  9425. }
  9426. get hasTextContent() {
  9427. return !!this.appearance;
  9428. }
  9429. static createNewDict(annotation, xref, _ref4) {
  9430. let {
  9431. apRef,
  9432. ap
  9433. } = _ref4;
  9434. const {
  9435. color,
  9436. fontSize,
  9437. rect,
  9438. rotation,
  9439. user,
  9440. value
  9441. } = annotation;
  9442. const freetext = new _primitives.Dict(xref);
  9443. freetext.set("Type", _primitives.Name.get("Annot"));
  9444. freetext.set("Subtype", _primitives.Name.get("FreeText"));
  9445. freetext.set("CreationDate", `D:${(0, _util.getModificationDate)()}`);
  9446. freetext.set("Rect", rect);
  9447. const da = `/Helv ${fontSize} Tf ${(0, _default_appearance.getPdfColor)(color, true)}`;
  9448. freetext.set("DA", da);
  9449. freetext.set("Contents", (0, _core_utils.isAscii)(value) ? value : (0, _core_utils.stringToUTF16String)(value, true));
  9450. freetext.set("F", 4);
  9451. freetext.set("Border", [0, 0, 0]);
  9452. freetext.set("Rotate", rotation);
  9453. if (user) {
  9454. freetext.set("T", (0, _core_utils.isAscii)(user) ? user : (0, _core_utils.stringToUTF16String)(user, true));
  9455. }
  9456. if (apRef || ap) {
  9457. const n = new _primitives.Dict(xref);
  9458. freetext.set("AP", n);
  9459. if (apRef) {
  9460. n.set("N", apRef);
  9461. } else {
  9462. n.set("N", ap);
  9463. }
  9464. }
  9465. return freetext;
  9466. }
  9467. static async createNewAppearanceStream(annotation, xref, params) {
  9468. const {
  9469. baseFontRef,
  9470. evaluator,
  9471. task
  9472. } = params;
  9473. const {
  9474. color,
  9475. fontSize,
  9476. rect,
  9477. rotation,
  9478. value
  9479. } = annotation;
  9480. const resources = new _primitives.Dict(xref);
  9481. const font = new _primitives.Dict(xref);
  9482. if (baseFontRef) {
  9483. font.set("Helv", baseFontRef);
  9484. } else {
  9485. const baseFont = new _primitives.Dict(xref);
  9486. baseFont.set("BaseFont", _primitives.Name.get("Helvetica"));
  9487. baseFont.set("Type", _primitives.Name.get("Font"));
  9488. baseFont.set("Subtype", _primitives.Name.get("Type1"));
  9489. baseFont.set("Encoding", _primitives.Name.get("WinAnsiEncoding"));
  9490. font.set("Helv", baseFont);
  9491. }
  9492. resources.set("Font", font);
  9493. const helv = await WidgetAnnotation._getFontData(evaluator, task, {
  9494. fontName: "Helv",
  9495. fontSize
  9496. }, resources);
  9497. const [x1, y1, x2, y2] = rect;
  9498. let w = x2 - x1;
  9499. let h = y2 - y1;
  9500. if (rotation % 180 !== 0) {
  9501. [w, h] = [h, w];
  9502. }
  9503. const lines = value.split("\n");
  9504. const scale = fontSize / 1000;
  9505. let totalWidth = -Infinity;
  9506. const encodedLines = [];
  9507. for (let line of lines) {
  9508. const encoded = helv.encodeString(line);
  9509. if (encoded.length > 1) {
  9510. return null;
  9511. }
  9512. line = encoded.join("");
  9513. encodedLines.push(line);
  9514. let lineWidth = 0;
  9515. const glyphs = helv.charsToGlyphs(line);
  9516. for (const glyph of glyphs) {
  9517. lineWidth += glyph.width * scale;
  9518. }
  9519. totalWidth = Math.max(totalWidth, lineWidth);
  9520. }
  9521. let hscale = 1;
  9522. if (totalWidth > w) {
  9523. hscale = w / totalWidth;
  9524. }
  9525. let vscale = 1;
  9526. const lineHeight = _util.LINE_FACTOR * fontSize;
  9527. const lineAscent = (_util.LINE_FACTOR - _util.LINE_DESCENT_FACTOR) * fontSize;
  9528. const totalHeight = lineHeight * lines.length;
  9529. if (totalHeight > h) {
  9530. vscale = h / totalHeight;
  9531. }
  9532. const fscale = Math.min(hscale, vscale);
  9533. const newFontSize = fontSize * fscale;
  9534. let firstPoint, clipBox, matrix;
  9535. switch (rotation) {
  9536. case 0:
  9537. matrix = [1, 0, 0, 1];
  9538. clipBox = [rect[0], rect[1], w, h];
  9539. firstPoint = [rect[0], rect[3] - lineAscent];
  9540. break;
  9541. case 90:
  9542. matrix = [0, 1, -1, 0];
  9543. clipBox = [rect[1], -rect[2], w, h];
  9544. firstPoint = [rect[1], -rect[0] - lineAscent];
  9545. break;
  9546. case 180:
  9547. matrix = [-1, 0, 0, -1];
  9548. clipBox = [-rect[2], -rect[3], w, h];
  9549. firstPoint = [-rect[2], -rect[1] - lineAscent];
  9550. break;
  9551. case 270:
  9552. matrix = [0, -1, 1, 0];
  9553. clipBox = [-rect[3], rect[0], w, h];
  9554. firstPoint = [-rect[3], rect[2] - lineAscent];
  9555. break;
  9556. }
  9557. 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`];
  9558. buffer.push(`${firstPoint.join(" ")} Td (${(0, _core_utils.escapeString)(encodedLines[0])}) Tj`);
  9559. const vShift = (0, _core_utils.numberToString)(lineHeight);
  9560. for (let i = 1, ii = encodedLines.length; i < ii; i++) {
  9561. const line = encodedLines[i];
  9562. buffer.push(`0 -${vShift} Td (${(0, _core_utils.escapeString)(line)}) Tj`);
  9563. }
  9564. buffer.push("ET", "Q");
  9565. const appearance = buffer.join("\n");
  9566. const appearanceStreamDict = new _primitives.Dict(xref);
  9567. appearanceStreamDict.set("FormType", 1);
  9568. appearanceStreamDict.set("Subtype", _primitives.Name.get("Form"));
  9569. appearanceStreamDict.set("Type", _primitives.Name.get("XObject"));
  9570. appearanceStreamDict.set("BBox", rect);
  9571. appearanceStreamDict.set("Resources", resources);
  9572. appearanceStreamDict.set("Matrix", [1, 0, 0, 1, -rect[0], -rect[1]]);
  9573. const ap = new _stream.StringStream(appearance);
  9574. ap.dict = appearanceStreamDict;
  9575. return ap;
  9576. }
  9577. }
  9578. class LineAnnotation extends MarkupAnnotation {
  9579. constructor(params) {
  9580. super(params);
  9581. const {
  9582. dict,
  9583. xref
  9584. } = params;
  9585. this.data.annotationType = _util.AnnotationType.LINE;
  9586. this.data.hasOwnCanvas = this.data.noRotate;
  9587. const lineCoordinates = dict.getArray("L");
  9588. this.data.lineCoordinates = _util.Util.normalizeRect(lineCoordinates);
  9589. this.setLineEndings(dict.getArray("LE"));
  9590. this.data.lineEndings = this.lineEndings;
  9591. if (!this.appearance) {
  9592. const strokeColor = this.color ? getPdfColorArray(this.color) : [0, 0, 0];
  9593. const strokeAlpha = dict.get("CA");
  9594. const interiorColor = getRgbColor(dict.getArray("IC"), null);
  9595. const fillColor = interiorColor ? getPdfColorArray(interiorColor) : null;
  9596. const fillAlpha = fillColor ? strokeAlpha : null;
  9597. const borderWidth = this.borderStyle.width || 1,
  9598. borderAdjust = 2 * borderWidth;
  9599. const bbox = [this.data.lineCoordinates[0] - borderAdjust, this.data.lineCoordinates[1] - borderAdjust, this.data.lineCoordinates[2] + borderAdjust, this.data.lineCoordinates[3] + borderAdjust];
  9600. if (!_util.Util.intersect(this.rectangle, bbox)) {
  9601. this.rectangle = bbox;
  9602. }
  9603. this._setDefaultAppearance({
  9604. xref,
  9605. extra: `${borderWidth} w`,
  9606. strokeColor,
  9607. fillColor,
  9608. strokeAlpha,
  9609. fillAlpha,
  9610. pointsCallback: (buffer, points) => {
  9611. buffer.push(`${lineCoordinates[0]} ${lineCoordinates[1]} m`, `${lineCoordinates[2]} ${lineCoordinates[3]} l`, "S");
  9612. return [points[0].x - borderWidth, points[1].x + borderWidth, points[3].y - borderWidth, points[1].y + borderWidth];
  9613. }
  9614. });
  9615. }
  9616. }
  9617. }
  9618. class SquareAnnotation extends MarkupAnnotation {
  9619. constructor(params) {
  9620. super(params);
  9621. const {
  9622. dict,
  9623. xref
  9624. } = params;
  9625. this.data.annotationType = _util.AnnotationType.SQUARE;
  9626. this.data.hasOwnCanvas = this.data.noRotate;
  9627. if (!this.appearance) {
  9628. const strokeColor = this.color ? getPdfColorArray(this.color) : [0, 0, 0];
  9629. const strokeAlpha = dict.get("CA");
  9630. const interiorColor = getRgbColor(dict.getArray("IC"), null);
  9631. const fillColor = interiorColor ? getPdfColorArray(interiorColor) : null;
  9632. const fillAlpha = fillColor ? strokeAlpha : null;
  9633. if (this.borderStyle.width === 0 && !fillColor) {
  9634. return;
  9635. }
  9636. this._setDefaultAppearance({
  9637. xref,
  9638. extra: `${this.borderStyle.width} w`,
  9639. strokeColor,
  9640. fillColor,
  9641. strokeAlpha,
  9642. fillAlpha,
  9643. pointsCallback: (buffer, points) => {
  9644. const x = points[2].x + this.borderStyle.width / 2;
  9645. const y = points[2].y + this.borderStyle.width / 2;
  9646. const width = points[3].x - points[2].x - this.borderStyle.width;
  9647. const height = points[1].y - points[3].y - this.borderStyle.width;
  9648. buffer.push(`${x} ${y} ${width} ${height} re`);
  9649. if (fillColor) {
  9650. buffer.push("B");
  9651. } else {
  9652. buffer.push("S");
  9653. }
  9654. return [points[0].x, points[1].x, points[3].y, points[1].y];
  9655. }
  9656. });
  9657. }
  9658. }
  9659. }
  9660. class CircleAnnotation extends MarkupAnnotation {
  9661. constructor(params) {
  9662. super(params);
  9663. const {
  9664. dict,
  9665. xref
  9666. } = params;
  9667. this.data.annotationType = _util.AnnotationType.CIRCLE;
  9668. if (!this.appearance) {
  9669. const strokeColor = this.color ? getPdfColorArray(this.color) : [0, 0, 0];
  9670. const strokeAlpha = dict.get("CA");
  9671. const interiorColor = getRgbColor(dict.getArray("IC"), null);
  9672. const fillColor = interiorColor ? getPdfColorArray(interiorColor) : null;
  9673. const fillAlpha = fillColor ? strokeAlpha : null;
  9674. if (this.borderStyle.width === 0 && !fillColor) {
  9675. return;
  9676. }
  9677. const controlPointsDistance = 4 / 3 * Math.tan(Math.PI / (2 * 4));
  9678. this._setDefaultAppearance({
  9679. xref,
  9680. extra: `${this.borderStyle.width} w`,
  9681. strokeColor,
  9682. fillColor,
  9683. strokeAlpha,
  9684. fillAlpha,
  9685. pointsCallback: (buffer, points) => {
  9686. const x0 = points[0].x + this.borderStyle.width / 2;
  9687. const y0 = points[0].y - this.borderStyle.width / 2;
  9688. const x1 = points[3].x - this.borderStyle.width / 2;
  9689. const y1 = points[3].y + this.borderStyle.width / 2;
  9690. const xMid = x0 + (x1 - x0) / 2;
  9691. const yMid = y0 + (y1 - y0) / 2;
  9692. const xOffset = (x1 - x0) / 2 * controlPointsDistance;
  9693. const yOffset = (y1 - y0) / 2 * controlPointsDistance;
  9694. 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");
  9695. if (fillColor) {
  9696. buffer.push("B");
  9697. } else {
  9698. buffer.push("S");
  9699. }
  9700. return [points[0].x, points[1].x, points[3].y, points[1].y];
  9701. }
  9702. });
  9703. }
  9704. }
  9705. }
  9706. class PolylineAnnotation extends MarkupAnnotation {
  9707. constructor(params) {
  9708. super(params);
  9709. const {
  9710. dict,
  9711. xref
  9712. } = params;
  9713. this.data.annotationType = _util.AnnotationType.POLYLINE;
  9714. this.data.hasOwnCanvas = this.data.noRotate;
  9715. this.data.vertices = [];
  9716. if (!(this instanceof PolygonAnnotation)) {
  9717. this.setLineEndings(dict.getArray("LE"));
  9718. this.data.lineEndings = this.lineEndings;
  9719. }
  9720. const rawVertices = dict.getArray("Vertices");
  9721. if (!Array.isArray(rawVertices)) {
  9722. return;
  9723. }
  9724. for (let i = 0, ii = rawVertices.length; i < ii; i += 2) {
  9725. this.data.vertices.push({
  9726. x: rawVertices[i],
  9727. y: rawVertices[i + 1]
  9728. });
  9729. }
  9730. if (!this.appearance) {
  9731. const strokeColor = this.color ? getPdfColorArray(this.color) : [0, 0, 0];
  9732. const strokeAlpha = dict.get("CA");
  9733. const borderWidth = this.borderStyle.width || 1,
  9734. borderAdjust = 2 * borderWidth;
  9735. const bbox = [Infinity, Infinity, -Infinity, -Infinity];
  9736. for (const vertex of this.data.vertices) {
  9737. bbox[0] = Math.min(bbox[0], vertex.x - borderAdjust);
  9738. bbox[1] = Math.min(bbox[1], vertex.y - borderAdjust);
  9739. bbox[2] = Math.max(bbox[2], vertex.x + borderAdjust);
  9740. bbox[3] = Math.max(bbox[3], vertex.y + borderAdjust);
  9741. }
  9742. if (!_util.Util.intersect(this.rectangle, bbox)) {
  9743. this.rectangle = bbox;
  9744. }
  9745. this._setDefaultAppearance({
  9746. xref,
  9747. extra: `${borderWidth} w`,
  9748. strokeColor,
  9749. strokeAlpha,
  9750. pointsCallback: (buffer, points) => {
  9751. const vertices = this.data.vertices;
  9752. for (let i = 0, ii = vertices.length; i < ii; i++) {
  9753. buffer.push(`${vertices[i].x} ${vertices[i].y} ${i === 0 ? "m" : "l"}`);
  9754. }
  9755. buffer.push("S");
  9756. return [points[0].x, points[1].x, points[3].y, points[1].y];
  9757. }
  9758. });
  9759. }
  9760. }
  9761. }
  9762. class PolygonAnnotation extends PolylineAnnotation {
  9763. constructor(params) {
  9764. super(params);
  9765. this.data.annotationType = _util.AnnotationType.POLYGON;
  9766. }
  9767. }
  9768. class CaretAnnotation extends MarkupAnnotation {
  9769. constructor(params) {
  9770. super(params);
  9771. this.data.annotationType = _util.AnnotationType.CARET;
  9772. }
  9773. }
  9774. class InkAnnotation extends MarkupAnnotation {
  9775. constructor(params) {
  9776. super(params);
  9777. this.data.hasOwnCanvas = this.data.noRotate;
  9778. const {
  9779. dict,
  9780. xref
  9781. } = params;
  9782. this.data.annotationType = _util.AnnotationType.INK;
  9783. this.data.inkLists = [];
  9784. const rawInkLists = dict.getArray("InkList");
  9785. if (!Array.isArray(rawInkLists)) {
  9786. return;
  9787. }
  9788. for (let i = 0, ii = rawInkLists.length; i < ii; ++i) {
  9789. this.data.inkLists.push([]);
  9790. for (let j = 0, jj = rawInkLists[i].length; j < jj; j += 2) {
  9791. this.data.inkLists[i].push({
  9792. x: xref.fetchIfRef(rawInkLists[i][j]),
  9793. y: xref.fetchIfRef(rawInkLists[i][j + 1])
  9794. });
  9795. }
  9796. }
  9797. if (!this.appearance) {
  9798. const strokeColor = this.color ? getPdfColorArray(this.color) : [0, 0, 0];
  9799. const strokeAlpha = dict.get("CA");
  9800. const borderWidth = this.borderStyle.width || 1,
  9801. borderAdjust = 2 * borderWidth;
  9802. const bbox = [Infinity, Infinity, -Infinity, -Infinity];
  9803. for (const inkLists of this.data.inkLists) {
  9804. for (const vertex of inkLists) {
  9805. bbox[0] = Math.min(bbox[0], vertex.x - borderAdjust);
  9806. bbox[1] = Math.min(bbox[1], vertex.y - borderAdjust);
  9807. bbox[2] = Math.max(bbox[2], vertex.x + borderAdjust);
  9808. bbox[3] = Math.max(bbox[3], vertex.y + borderAdjust);
  9809. }
  9810. }
  9811. if (!_util.Util.intersect(this.rectangle, bbox)) {
  9812. this.rectangle = bbox;
  9813. }
  9814. this._setDefaultAppearance({
  9815. xref,
  9816. extra: `${borderWidth} w`,
  9817. strokeColor,
  9818. strokeAlpha,
  9819. pointsCallback: (buffer, points) => {
  9820. for (const inkList of this.data.inkLists) {
  9821. for (let i = 0, ii = inkList.length; i < ii; i++) {
  9822. buffer.push(`${inkList[i].x} ${inkList[i].y} ${i === 0 ? "m" : "l"}`);
  9823. }
  9824. buffer.push("S");
  9825. }
  9826. return [points[0].x, points[1].x, points[3].y, points[1].y];
  9827. }
  9828. });
  9829. }
  9830. }
  9831. static createNewDict(annotation, xref, _ref5) {
  9832. let {
  9833. apRef,
  9834. ap
  9835. } = _ref5;
  9836. const {
  9837. color,
  9838. opacity,
  9839. paths,
  9840. rect,
  9841. rotation,
  9842. thickness
  9843. } = annotation;
  9844. const ink = new _primitives.Dict(xref);
  9845. ink.set("Type", _primitives.Name.get("Annot"));
  9846. ink.set("Subtype", _primitives.Name.get("Ink"));
  9847. ink.set("CreationDate", `D:${(0, _util.getModificationDate)()}`);
  9848. ink.set("Rect", rect);
  9849. ink.set("InkList", paths.map(p => p.points));
  9850. ink.set("F", 4);
  9851. ink.set("Rotate", rotation);
  9852. const bs = new _primitives.Dict(xref);
  9853. ink.set("BS", bs);
  9854. bs.set("W", thickness);
  9855. ink.set("C", Array.from(color, c => c / 255));
  9856. ink.set("CA", opacity);
  9857. const n = new _primitives.Dict(xref);
  9858. ink.set("AP", n);
  9859. if (apRef) {
  9860. n.set("N", apRef);
  9861. } else {
  9862. n.set("N", ap);
  9863. }
  9864. return ink;
  9865. }
  9866. static async createNewAppearanceStream(annotation, xref, params) {
  9867. const {
  9868. color,
  9869. rect,
  9870. paths,
  9871. thickness,
  9872. opacity
  9873. } = annotation;
  9874. const appearanceBuffer = [`${thickness} w 1 J 1 j`, `${(0, _default_appearance.getPdfColor)(color, false)}`];
  9875. if (opacity !== 1) {
  9876. appearanceBuffer.push("/R0 gs");
  9877. }
  9878. const buffer = [];
  9879. for (const {
  9880. bezier
  9881. } of paths) {
  9882. buffer.length = 0;
  9883. buffer.push(`${(0, _core_utils.numberToString)(bezier[0])} ${(0, _core_utils.numberToString)(bezier[1])} m`);
  9884. for (let i = 2, ii = bezier.length; i < ii; i += 6) {
  9885. const curve = bezier.slice(i, i + 6).map(_core_utils.numberToString).join(" ");
  9886. buffer.push(`${curve} c`);
  9887. }
  9888. buffer.push("S");
  9889. appearanceBuffer.push(buffer.join("\n"));
  9890. }
  9891. const appearance = appearanceBuffer.join("\n");
  9892. const appearanceStreamDict = new _primitives.Dict(xref);
  9893. appearanceStreamDict.set("FormType", 1);
  9894. appearanceStreamDict.set("Subtype", _primitives.Name.get("Form"));
  9895. appearanceStreamDict.set("Type", _primitives.Name.get("XObject"));
  9896. appearanceStreamDict.set("BBox", rect);
  9897. appearanceStreamDict.set("Length", appearance.length);
  9898. if (opacity !== 1) {
  9899. const resources = new _primitives.Dict(xref);
  9900. const extGState = new _primitives.Dict(xref);
  9901. const r0 = new _primitives.Dict(xref);
  9902. r0.set("CA", opacity);
  9903. r0.set("Type", _primitives.Name.get("ExtGState"));
  9904. extGState.set("R0", r0);
  9905. resources.set("ExtGState", extGState);
  9906. appearanceStreamDict.set("Resources", resources);
  9907. }
  9908. const ap = new _stream.StringStream(appearance);
  9909. ap.dict = appearanceStreamDict;
  9910. return ap;
  9911. }
  9912. }
  9913. class HighlightAnnotation extends MarkupAnnotation {
  9914. constructor(params) {
  9915. super(params);
  9916. const {
  9917. dict,
  9918. xref
  9919. } = params;
  9920. this.data.annotationType = _util.AnnotationType.HIGHLIGHT;
  9921. const quadPoints = this.data.quadPoints = getQuadPoints(dict, null);
  9922. if (quadPoints) {
  9923. const resources = this.appearance?.dict.get("Resources");
  9924. if (!this.appearance || !resources?.has("ExtGState")) {
  9925. if (this.appearance) {
  9926. (0, _util.warn)("HighlightAnnotation - ignoring built-in appearance stream.");
  9927. }
  9928. const fillColor = this.color ? getPdfColorArray(this.color) : [1, 1, 0];
  9929. const fillAlpha = dict.get("CA");
  9930. this._setDefaultAppearance({
  9931. xref,
  9932. fillColor,
  9933. blendMode: "Multiply",
  9934. fillAlpha,
  9935. pointsCallback: (buffer, points) => {
  9936. 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");
  9937. return [points[0].x, points[1].x, points[3].y, points[1].y];
  9938. }
  9939. });
  9940. }
  9941. } else {
  9942. this.data.popupRef = null;
  9943. }
  9944. }
  9945. }
  9946. class UnderlineAnnotation extends MarkupAnnotation {
  9947. constructor(params) {
  9948. super(params);
  9949. const {
  9950. dict,
  9951. xref
  9952. } = params;
  9953. this.data.annotationType = _util.AnnotationType.UNDERLINE;
  9954. const quadPoints = this.data.quadPoints = getQuadPoints(dict, null);
  9955. if (quadPoints) {
  9956. if (!this.appearance) {
  9957. const strokeColor = this.color ? getPdfColorArray(this.color) : [0, 0, 0];
  9958. const strokeAlpha = dict.get("CA");
  9959. this._setDefaultAppearance({
  9960. xref,
  9961. extra: "[] 0 d 0.571 w",
  9962. strokeColor,
  9963. strokeAlpha,
  9964. pointsCallback: (buffer, points) => {
  9965. buffer.push(`${points[2].x} ${points[2].y + 1.3} m`, `${points[3].x} ${points[3].y + 1.3} l`, "S");
  9966. return [points[0].x, points[1].x, points[3].y, points[1].y];
  9967. }
  9968. });
  9969. }
  9970. } else {
  9971. this.data.popupRef = null;
  9972. }
  9973. }
  9974. }
  9975. class SquigglyAnnotation extends MarkupAnnotation {
  9976. constructor(params) {
  9977. super(params);
  9978. const {
  9979. dict,
  9980. xref
  9981. } = params;
  9982. this.data.annotationType = _util.AnnotationType.SQUIGGLY;
  9983. const quadPoints = this.data.quadPoints = getQuadPoints(dict, null);
  9984. if (quadPoints) {
  9985. if (!this.appearance) {
  9986. const strokeColor = this.color ? getPdfColorArray(this.color) : [0, 0, 0];
  9987. const strokeAlpha = dict.get("CA");
  9988. this._setDefaultAppearance({
  9989. xref,
  9990. extra: "[] 0 d 1 w",
  9991. strokeColor,
  9992. strokeAlpha,
  9993. pointsCallback: (buffer, points) => {
  9994. const dy = (points[0].y - points[2].y) / 6;
  9995. let shift = dy;
  9996. let x = points[2].x;
  9997. const y = points[2].y;
  9998. const xEnd = points[3].x;
  9999. buffer.push(`${x} ${y + shift} m`);
  10000. do {
  10001. x += 2;
  10002. shift = shift === 0 ? dy : 0;
  10003. buffer.push(`${x} ${y + shift} l`);
  10004. } while (x < xEnd);
  10005. buffer.push("S");
  10006. return [points[2].x, xEnd, y - 2 * dy, y + 2 * dy];
  10007. }
  10008. });
  10009. }
  10010. } else {
  10011. this.data.popupRef = null;
  10012. }
  10013. }
  10014. }
  10015. class StrikeOutAnnotation extends MarkupAnnotation {
  10016. constructor(params) {
  10017. super(params);
  10018. const {
  10019. dict,
  10020. xref
  10021. } = params;
  10022. this.data.annotationType = _util.AnnotationType.STRIKEOUT;
  10023. const quadPoints = this.data.quadPoints = getQuadPoints(dict, null);
  10024. if (quadPoints) {
  10025. if (!this.appearance) {
  10026. const strokeColor = this.color ? getPdfColorArray(this.color) : [0, 0, 0];
  10027. const strokeAlpha = dict.get("CA");
  10028. this._setDefaultAppearance({
  10029. xref,
  10030. extra: "[] 0 d 1 w",
  10031. strokeColor,
  10032. strokeAlpha,
  10033. pointsCallback: (buffer, points) => {
  10034. 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");
  10035. return [points[0].x, points[1].x, points[3].y, points[1].y];
  10036. }
  10037. });
  10038. }
  10039. } else {
  10040. this.data.popupRef = null;
  10041. }
  10042. }
  10043. }
  10044. class StampAnnotation extends MarkupAnnotation {
  10045. constructor(params) {
  10046. super(params);
  10047. this.data.annotationType = _util.AnnotationType.STAMP;
  10048. this.data.hasOwnCanvas = this.data.noRotate;
  10049. }
  10050. static async createImage(bitmap, xref) {
  10051. const {
  10052. width,
  10053. height
  10054. } = bitmap;
  10055. const canvas = new OffscreenCanvas(width, height);
  10056. const ctx = canvas.getContext("2d", {
  10057. alpha: true
  10058. });
  10059. ctx.drawImage(bitmap, 0, 0);
  10060. const data = ctx.getImageData(0, 0, width, height).data;
  10061. const buf32 = new Uint32Array(data.buffer);
  10062. const hasAlpha = buf32.some(_util.FeatureTest.isLittleEndian ? x => x >>> 24 !== 0xff : x => (x & 0xff) !== 0xff);
  10063. if (hasAlpha) {
  10064. ctx.fillStyle = "white";
  10065. ctx.fillRect(0, 0, width, height);
  10066. ctx.drawImage(bitmap, 0, 0);
  10067. }
  10068. const jpegBufferPromise = canvas.convertToBlob({
  10069. type: "image/jpeg",
  10070. quality: 1
  10071. }).then(blob => {
  10072. return blob.arrayBuffer();
  10073. });
  10074. const xobjectName = _primitives.Name.get("XObject");
  10075. const imageName = _primitives.Name.get("Image");
  10076. const image = new _primitives.Dict(xref);
  10077. image.set("Type", xobjectName);
  10078. image.set("Subtype", imageName);
  10079. image.set("BitsPerComponent", 8);
  10080. image.set("ColorSpace", _primitives.Name.get("DeviceRGB"));
  10081. image.set("Filter", _primitives.Name.get("DCTDecode"));
  10082. image.set("BBox", [0, 0, width, height]);
  10083. image.set("Width", width);
  10084. image.set("Height", height);
  10085. let smaskStream = null;
  10086. if (hasAlpha) {
  10087. const alphaBuffer = new Uint8Array(buf32.length);
  10088. if (_util.FeatureTest.isLittleEndian) {
  10089. for (let i = 0, ii = buf32.length; i < ii; i++) {
  10090. alphaBuffer[i] = buf32[i] >>> 24;
  10091. }
  10092. } else {
  10093. for (let i = 0, ii = buf32.length; i < ii; i++) {
  10094. alphaBuffer[i] = buf32[i] & 0xff;
  10095. }
  10096. }
  10097. const smask = new _primitives.Dict(xref);
  10098. smask.set("Type", xobjectName);
  10099. smask.set("Subtype", imageName);
  10100. smask.set("BitsPerComponent", 8);
  10101. smask.set("ColorSpace", _primitives.Name.get("DeviceGray"));
  10102. smask.set("Width", width);
  10103. smask.set("Height", height);
  10104. smaskStream = new _stream.Stream(alphaBuffer, 0, 0, smask);
  10105. }
  10106. const imageStream = new _stream.Stream(await jpegBufferPromise, 0, 0, image);
  10107. return {
  10108. imageStream,
  10109. smaskStream,
  10110. width,
  10111. height
  10112. };
  10113. }
  10114. static createNewDict(annotation, xref, _ref6) {
  10115. let {
  10116. apRef,
  10117. ap
  10118. } = _ref6;
  10119. const {
  10120. rect,
  10121. rotation,
  10122. user
  10123. } = annotation;
  10124. const stamp = new _primitives.Dict(xref);
  10125. stamp.set("Type", _primitives.Name.get("Annot"));
  10126. stamp.set("Subtype", _primitives.Name.get("Stamp"));
  10127. stamp.set("CreationDate", `D:${(0, _util.getModificationDate)()}`);
  10128. stamp.set("Rect", rect);
  10129. stamp.set("F", 4);
  10130. stamp.set("Border", [0, 0, 0]);
  10131. stamp.set("Rotate", rotation);
  10132. if (user) {
  10133. stamp.set("T", (0, _core_utils.isAscii)(user) ? user : (0, _core_utils.stringToUTF16String)(user, true));
  10134. }
  10135. if (apRef || ap) {
  10136. const n = new _primitives.Dict(xref);
  10137. stamp.set("AP", n);
  10138. if (apRef) {
  10139. n.set("N", apRef);
  10140. } else {
  10141. n.set("N", ap);
  10142. }
  10143. }
  10144. return stamp;
  10145. }
  10146. static async createNewAppearanceStream(annotation, xref, params) {
  10147. const {
  10148. rotation
  10149. } = annotation;
  10150. const {
  10151. imageRef,
  10152. width,
  10153. height
  10154. } = params.image;
  10155. const resources = new _primitives.Dict(xref);
  10156. const xobject = new _primitives.Dict(xref);
  10157. resources.set("XObject", xobject);
  10158. xobject.set("Im0", imageRef);
  10159. const appearance = `q ${width} 0 0 ${height} 0 0 cm /Im0 Do Q`;
  10160. const appearanceStreamDict = new _primitives.Dict(xref);
  10161. appearanceStreamDict.set("FormType", 1);
  10162. appearanceStreamDict.set("Subtype", _primitives.Name.get("Form"));
  10163. appearanceStreamDict.set("Type", _primitives.Name.get("XObject"));
  10164. appearanceStreamDict.set("BBox", [0, 0, width, height]);
  10165. appearanceStreamDict.set("Resources", resources);
  10166. if (rotation) {
  10167. const matrix = (0, _core_utils.getRotationMatrix)(rotation, width, height);
  10168. appearanceStreamDict.set("Matrix", matrix);
  10169. }
  10170. const ap = new _stream.StringStream(appearance);
  10171. ap.dict = appearanceStreamDict;
  10172. return ap;
  10173. }
  10174. }
  10175. class FileAttachmentAnnotation extends MarkupAnnotation {
  10176. constructor(params) {
  10177. super(params);
  10178. const {
  10179. dict,
  10180. xref
  10181. } = params;
  10182. const file = new _file_spec.FileSpec(dict.get("FS"), xref);
  10183. this.data.annotationType = _util.AnnotationType.FILEATTACHMENT;
  10184. this.data.hasOwnCanvas = this.data.noRotate;
  10185. this.data.file = file.serializable;
  10186. const name = dict.get("Name");
  10187. this.data.name = name instanceof _primitives.Name ? (0, _util.stringToPDFString)(name.name) : "PushPin";
  10188. const fillAlpha = dict.get("ca");
  10189. this.data.fillAlpha = typeof fillAlpha === "number" && fillAlpha >= 0 && fillAlpha <= 1 ? fillAlpha : null;
  10190. }
  10191. }
  10192. /***/ }),
  10193. /* 158 */
  10194. /***/ ((__unused_webpack_module, __unused_webpack_exports, __w_pdfjs_require__) => {
  10195. var global = __w_pdfjs_require__(4);
  10196. var DESCRIPTORS = __w_pdfjs_require__(6);
  10197. var defineBuiltInAccessor = __w_pdfjs_require__(87);
  10198. var regExpFlags = __w_pdfjs_require__(159);
  10199. var fails = __w_pdfjs_require__(7);
  10200. var RegExp = global.RegExp;
  10201. var RegExpPrototype = RegExp.prototype;
  10202. var FORCED = DESCRIPTORS && fails(function () {
  10203. var INDICES_SUPPORT = true;
  10204. try {
  10205. RegExp('.', 'd');
  10206. } catch (error) {
  10207. INDICES_SUPPORT = false;
  10208. }
  10209. var O = {};
  10210. var calls = '';
  10211. var expected = INDICES_SUPPORT ? 'dgimsy' : 'gimsy';
  10212. var addGetter = function (key, chr) {
  10213. Object.defineProperty(O, key, {
  10214. get: function () {
  10215. calls += chr;
  10216. return true;
  10217. }
  10218. });
  10219. };
  10220. var pairs = {
  10221. dotAll: 's',
  10222. global: 'g',
  10223. ignoreCase: 'i',
  10224. multiline: 'm',
  10225. sticky: 'y'
  10226. };
  10227. if (INDICES_SUPPORT)
  10228. pairs.hasIndices = 'd';
  10229. for (var key in pairs)
  10230. addGetter(key, pairs[key]);
  10231. var result = Object.getOwnPropertyDescriptor(RegExpPrototype, 'flags').get.call(O);
  10232. return result !== expected || calls !== expected;
  10233. });
  10234. if (FORCED)
  10235. defineBuiltInAccessor(RegExpPrototype, 'flags', {
  10236. configurable: true,
  10237. get: regExpFlags
  10238. });
  10239. /***/ }),
  10240. /* 159 */
  10241. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  10242. var anObject = __w_pdfjs_require__(47);
  10243. module.exports = function () {
  10244. var that = anObject(this);
  10245. var result = '';
  10246. if (that.hasIndices)
  10247. result += 'd';
  10248. if (that.global)
  10249. result += 'g';
  10250. if (that.ignoreCase)
  10251. result += 'i';
  10252. if (that.multiline)
  10253. result += 'm';
  10254. if (that.dotAll)
  10255. result += 's';
  10256. if (that.unicode)
  10257. result += 'u';
  10258. if (that.unicodeSets)
  10259. result += 'v';
  10260. if (that.sticky)
  10261. result += 'y';
  10262. return result;
  10263. };
  10264. /***/ }),
  10265. /* 160 */
  10266. /***/ ((__unused_webpack_module, __unused_webpack_exports, __w_pdfjs_require__) => {
  10267. var $ = __w_pdfjs_require__(3);
  10268. var toObject = __w_pdfjs_require__(40);
  10269. var lengthOfArrayLike = __w_pdfjs_require__(64);
  10270. var setArrayLength = __w_pdfjs_require__(141);
  10271. var deletePropertyOrThrow = __w_pdfjs_require__(161);
  10272. var doesNotExceedSafeInteger = __w_pdfjs_require__(143);
  10273. var INCORRECT_RESULT = [].unshift(0) !== 1;
  10274. var properErrorOnNonWritableLength = function () {
  10275. try {
  10276. Object.defineProperty([], 'length', { writable: false }).unshift();
  10277. } catch (error) {
  10278. return error instanceof TypeError;
  10279. }
  10280. };
  10281. var FORCED = INCORRECT_RESULT || !properErrorOnNonWritableLength();
  10282. $({
  10283. target: 'Array',
  10284. proto: true,
  10285. arity: 1,
  10286. forced: FORCED
  10287. }, {
  10288. unshift: function unshift(item) {
  10289. var O = toObject(this);
  10290. var len = lengthOfArrayLike(O);
  10291. var argCount = arguments.length;
  10292. if (argCount) {
  10293. doesNotExceedSafeInteger(len + argCount);
  10294. var k = len;
  10295. while (k--) {
  10296. var to = k + argCount;
  10297. if (k in O)
  10298. O[to] = O[k];
  10299. else
  10300. deletePropertyOrThrow(O, to);
  10301. }
  10302. for (var j = 0; j < argCount; j++) {
  10303. O[j] = arguments[j];
  10304. }
  10305. }
  10306. return setArrayLength(O, len + argCount);
  10307. }
  10308. });
  10309. /***/ }),
  10310. /* 161 */
  10311. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  10312. var tryToString = __w_pdfjs_require__(32);
  10313. var $TypeError = TypeError;
  10314. module.exports = function (O, P) {
  10315. if (!delete O[P])
  10316. throw $TypeError('Cannot delete property ' + tryToString(P) + ' of ' + tryToString(O));
  10317. };
  10318. /***/ }),
  10319. /* 162 */
  10320. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  10321. Object.defineProperty(exports, "__esModule", ({
  10322. value: true
  10323. }));
  10324. exports.FakeUnicodeFont = void 0;
  10325. exports.createDefaultAppearance = createDefaultAppearance;
  10326. exports.getPdfColor = getPdfColor;
  10327. exports.parseAppearanceStream = parseAppearanceStream;
  10328. exports.parseDefaultAppearance = parseDefaultAppearance;
  10329. __w_pdfjs_require__(84);
  10330. __w_pdfjs_require__(93);
  10331. __w_pdfjs_require__(94);
  10332. __w_pdfjs_require__(97);
  10333. __w_pdfjs_require__(99);
  10334. __w_pdfjs_require__(101);
  10335. __w_pdfjs_require__(105);
  10336. __w_pdfjs_require__(108);
  10337. __w_pdfjs_require__(115);
  10338. __w_pdfjs_require__(140);
  10339. var _primitives = __w_pdfjs_require__(151);
  10340. var _core_utils = __w_pdfjs_require__(150);
  10341. var _util = __w_pdfjs_require__(145);
  10342. var _colorspace = __w_pdfjs_require__(163);
  10343. var _evaluator = __w_pdfjs_require__(164);
  10344. var _image_utils = __w_pdfjs_require__(210);
  10345. var _function = __w_pdfjs_require__(208);
  10346. var _stream = __w_pdfjs_require__(155);
  10347. class DefaultAppearanceEvaluator extends _evaluator.EvaluatorPreprocessor {
  10348. constructor(str) {
  10349. super(new _stream.StringStream(str));
  10350. }
  10351. parse() {
  10352. const operation = {
  10353. fn: 0,
  10354. args: []
  10355. };
  10356. const result = {
  10357. fontSize: 0,
  10358. fontName: "",
  10359. fontColor: new Uint8ClampedArray(3)
  10360. };
  10361. try {
  10362. while (true) {
  10363. operation.args.length = 0;
  10364. if (!this.read(operation)) {
  10365. break;
  10366. }
  10367. if (this.savedStatesDepth !== 0) {
  10368. continue;
  10369. }
  10370. const {
  10371. fn,
  10372. args
  10373. } = operation;
  10374. switch (fn | 0) {
  10375. case _util.OPS.setFont:
  10376. const [fontName, fontSize] = args;
  10377. if (fontName instanceof _primitives.Name) {
  10378. result.fontName = fontName.name;
  10379. }
  10380. if (typeof fontSize === "number" && fontSize > 0) {
  10381. result.fontSize = fontSize;
  10382. }
  10383. break;
  10384. case _util.OPS.setFillRGBColor:
  10385. _colorspace.ColorSpace.singletons.rgb.getRgbItem(args, 0, result.fontColor, 0);
  10386. break;
  10387. case _util.OPS.setFillGray:
  10388. _colorspace.ColorSpace.singletons.gray.getRgbItem(args, 0, result.fontColor, 0);
  10389. break;
  10390. case _util.OPS.setFillCMYKColor:
  10391. _colorspace.ColorSpace.singletons.cmyk.getRgbItem(args, 0, result.fontColor, 0);
  10392. break;
  10393. }
  10394. }
  10395. } catch (reason) {
  10396. (0, _util.warn)(`parseDefaultAppearance - ignoring errors: "${reason}".`);
  10397. }
  10398. return result;
  10399. }
  10400. }
  10401. function parseDefaultAppearance(str) {
  10402. return new DefaultAppearanceEvaluator(str).parse();
  10403. }
  10404. class AppearanceStreamEvaluator extends _evaluator.EvaluatorPreprocessor {
  10405. constructor(stream, evaluatorOptions, xref) {
  10406. super(stream);
  10407. this.stream = stream;
  10408. this.evaluatorOptions = evaluatorOptions;
  10409. this.xref = xref;
  10410. this.resources = stream.dict?.get("Resources");
  10411. }
  10412. parse() {
  10413. const operation = {
  10414. fn: 0,
  10415. args: []
  10416. };
  10417. let result = {
  10418. scaleFactor: 1,
  10419. fontSize: 0,
  10420. fontName: "",
  10421. fontColor: new Uint8ClampedArray(3),
  10422. fillColorSpace: _colorspace.ColorSpace.singletons.gray
  10423. };
  10424. let breakLoop = false;
  10425. const stack = [];
  10426. try {
  10427. while (true) {
  10428. operation.args.length = 0;
  10429. if (breakLoop || !this.read(operation)) {
  10430. break;
  10431. }
  10432. const {
  10433. fn,
  10434. args
  10435. } = operation;
  10436. switch (fn | 0) {
  10437. case _util.OPS.save:
  10438. stack.push({
  10439. scaleFactor: result.scaleFactor,
  10440. fontSize: result.fontSize,
  10441. fontName: result.fontName,
  10442. fontColor: result.fontColor.slice(),
  10443. fillColorSpace: result.fillColorSpace
  10444. });
  10445. break;
  10446. case _util.OPS.restore:
  10447. result = stack.pop() || result;
  10448. break;
  10449. case _util.OPS.setTextMatrix:
  10450. result.scaleFactor *= Math.hypot(args[0], args[1]);
  10451. break;
  10452. case _util.OPS.setFont:
  10453. const [fontName, fontSize] = args;
  10454. if (fontName instanceof _primitives.Name) {
  10455. result.fontName = fontName.name;
  10456. }
  10457. if (typeof fontSize === "number" && fontSize > 0) {
  10458. result.fontSize = fontSize * result.scaleFactor;
  10459. }
  10460. break;
  10461. case _util.OPS.setFillColorSpace:
  10462. result.fillColorSpace = _colorspace.ColorSpace.parse({
  10463. cs: args[0],
  10464. xref: this.xref,
  10465. resources: this.resources,
  10466. pdfFunctionFactory: this._pdfFunctionFactory,
  10467. localColorSpaceCache: this._localColorSpaceCache
  10468. });
  10469. break;
  10470. case _util.OPS.setFillColor:
  10471. const cs = result.fillColorSpace;
  10472. cs.getRgbItem(args, 0, result.fontColor, 0);
  10473. break;
  10474. case _util.OPS.setFillRGBColor:
  10475. _colorspace.ColorSpace.singletons.rgb.getRgbItem(args, 0, result.fontColor, 0);
  10476. break;
  10477. case _util.OPS.setFillGray:
  10478. _colorspace.ColorSpace.singletons.gray.getRgbItem(args, 0, result.fontColor, 0);
  10479. break;
  10480. case _util.OPS.setFillCMYKColor:
  10481. _colorspace.ColorSpace.singletons.cmyk.getRgbItem(args, 0, result.fontColor, 0);
  10482. break;
  10483. case _util.OPS.showText:
  10484. case _util.OPS.showSpacedText:
  10485. case _util.OPS.nextLineShowText:
  10486. case _util.OPS.nextLineSetSpacingShowText:
  10487. breakLoop = true;
  10488. break;
  10489. }
  10490. }
  10491. } catch (reason) {
  10492. (0, _util.warn)(`parseAppearanceStream - ignoring errors: "${reason}".`);
  10493. }
  10494. this.stream.reset();
  10495. delete result.scaleFactor;
  10496. delete result.fillColorSpace;
  10497. return result;
  10498. }
  10499. get _localColorSpaceCache() {
  10500. return (0, _util.shadow)(this, "_localColorSpaceCache", new _image_utils.LocalColorSpaceCache());
  10501. }
  10502. get _pdfFunctionFactory() {
  10503. const pdfFunctionFactory = new _function.PDFFunctionFactory({
  10504. xref: this.xref,
  10505. isEvalSupported: this.evaluatorOptions.isEvalSupported
  10506. });
  10507. return (0, _util.shadow)(this, "_pdfFunctionFactory", pdfFunctionFactory);
  10508. }
  10509. }
  10510. function parseAppearanceStream(stream, evaluatorOptions, xref) {
  10511. return new AppearanceStreamEvaluator(stream, evaluatorOptions, xref).parse();
  10512. }
  10513. function getPdfColor(color, isFill) {
  10514. if (color[0] === color[1] && color[1] === color[2]) {
  10515. const gray = color[0] / 255;
  10516. return `${(0, _core_utils.numberToString)(gray)} ${isFill ? "g" : "G"}`;
  10517. }
  10518. return Array.from(color, c => (0, _core_utils.numberToString)(c / 255)).join(" ") + ` ${isFill ? "rg" : "RG"}`;
  10519. }
  10520. function createDefaultAppearance(_ref) {
  10521. let {
  10522. fontSize,
  10523. fontName,
  10524. fontColor
  10525. } = _ref;
  10526. return `/${(0, _core_utils.escapePDFName)(fontName)} ${fontSize} Tf ${getPdfColor(fontColor, true)}`;
  10527. }
  10528. class FakeUnicodeFont {
  10529. constructor(xref, fontFamily) {
  10530. this.xref = xref;
  10531. this.widths = null;
  10532. this.firstChar = Infinity;
  10533. this.lastChar = -Infinity;
  10534. this.fontFamily = fontFamily;
  10535. const canvas = new OffscreenCanvas(1, 1);
  10536. this.ctxMeasure = canvas.getContext("2d");
  10537. if (!FakeUnicodeFont._fontNameId) {
  10538. FakeUnicodeFont._fontNameId = 1;
  10539. }
  10540. this.fontName = _primitives.Name.get(`InvalidPDFjsFont_${fontFamily}_${FakeUnicodeFont._fontNameId++}`);
  10541. }
  10542. get toUnicodeRef() {
  10543. if (!FakeUnicodeFont._toUnicodeRef) {
  10544. const toUnicode = `/CIDInit /ProcSet findresource begin
  10545. 12 dict begin
  10546. begincmap
  10547. /CIDSystemInfo
  10548. << /Registry (Adobe)
  10549. /Ordering (UCS) /Supplement 0 >> def
  10550. /CMapName /Adobe-Identity-UCS def
  10551. /CMapType 2 def
  10552. 1 begincodespacerange
  10553. <0000> <FFFF>
  10554. endcodespacerange
  10555. 1 beginbfrange
  10556. <0000> <FFFF> <0000>
  10557. endbfrange
  10558. endcmap CMapName currentdict /CMap defineresource pop end end`;
  10559. const toUnicodeStream = FakeUnicodeFont.toUnicodeStream = new _stream.StringStream(toUnicode);
  10560. const toUnicodeDict = new _primitives.Dict(this.xref);
  10561. toUnicodeStream.dict = toUnicodeDict;
  10562. toUnicodeDict.set("Length", toUnicode.length);
  10563. FakeUnicodeFont._toUnicodeRef = this.xref.getNewPersistentRef(toUnicodeStream);
  10564. }
  10565. return FakeUnicodeFont._toUnicodeRef;
  10566. }
  10567. get fontDescriptorRef() {
  10568. if (!FakeUnicodeFont._fontDescriptorRef) {
  10569. const fontDescriptor = new _primitives.Dict(this.xref);
  10570. fontDescriptor.set("Type", _primitives.Name.get("FontDescriptor"));
  10571. fontDescriptor.set("FontName", this.fontName);
  10572. fontDescriptor.set("FontFamily", "MyriadPro Regular");
  10573. fontDescriptor.set("FontBBox", [0, 0, 0, 0]);
  10574. fontDescriptor.set("FontStretch", _primitives.Name.get("Normal"));
  10575. fontDescriptor.set("FontWeight", 400);
  10576. fontDescriptor.set("ItalicAngle", 0);
  10577. FakeUnicodeFont._fontDescriptorRef = this.xref.getNewPersistentRef(fontDescriptor);
  10578. }
  10579. return FakeUnicodeFont._fontDescriptorRef;
  10580. }
  10581. get descendantFontRef() {
  10582. const descendantFont = new _primitives.Dict(this.xref);
  10583. descendantFont.set("BaseFont", this.fontName);
  10584. descendantFont.set("Type", _primitives.Name.get("Font"));
  10585. descendantFont.set("Subtype", _primitives.Name.get("CIDFontType0"));
  10586. descendantFont.set("CIDToGIDMap", _primitives.Name.get("Identity"));
  10587. descendantFont.set("FirstChar", this.firstChar);
  10588. descendantFont.set("LastChar", this.lastChar);
  10589. descendantFont.set("FontDescriptor", this.fontDescriptorRef);
  10590. descendantFont.set("DW", 1000);
  10591. const widths = [];
  10592. const chars = [...this.widths.entries()].sort();
  10593. let currentChar = null;
  10594. let currentWidths = null;
  10595. for (const [char, width] of chars) {
  10596. if (!currentChar) {
  10597. currentChar = char;
  10598. currentWidths = [width];
  10599. continue;
  10600. }
  10601. if (char === currentChar + currentWidths.length) {
  10602. currentWidths.push(width);
  10603. } else {
  10604. widths.push(currentChar, currentWidths);
  10605. currentChar = char;
  10606. currentWidths = [width];
  10607. }
  10608. }
  10609. if (currentChar) {
  10610. widths.push(currentChar, currentWidths);
  10611. }
  10612. descendantFont.set("W", widths);
  10613. const cidSystemInfo = new _primitives.Dict(this.xref);
  10614. cidSystemInfo.set("Ordering", "Identity");
  10615. cidSystemInfo.set("Registry", "Adobe");
  10616. cidSystemInfo.set("Supplement", 0);
  10617. descendantFont.set("CIDSystemInfo", cidSystemInfo);
  10618. return this.xref.getNewPersistentRef(descendantFont);
  10619. }
  10620. get baseFontRef() {
  10621. const baseFont = new _primitives.Dict(this.xref);
  10622. baseFont.set("BaseFont", this.fontName);
  10623. baseFont.set("Type", _primitives.Name.get("Font"));
  10624. baseFont.set("Subtype", _primitives.Name.get("Type0"));
  10625. baseFont.set("Encoding", _primitives.Name.get("Identity-H"));
  10626. baseFont.set("DescendantFonts", [this.descendantFontRef]);
  10627. baseFont.set("ToUnicode", this.toUnicodeRef);
  10628. return this.xref.getNewPersistentRef(baseFont);
  10629. }
  10630. get resources() {
  10631. const resources = new _primitives.Dict(this.xref);
  10632. const font = new _primitives.Dict(this.xref);
  10633. font.set(this.fontName.name, this.baseFontRef);
  10634. resources.set("Font", font);
  10635. return resources;
  10636. }
  10637. _createContext() {
  10638. this.widths = new Map();
  10639. this.ctxMeasure.font = `1000px ${this.fontFamily}`;
  10640. return this.ctxMeasure;
  10641. }
  10642. createFontResources(text) {
  10643. const ctx = this._createContext();
  10644. for (const line of text.split(/\r\n?|\n/)) {
  10645. for (const char of line.split("")) {
  10646. const code = char.charCodeAt(0);
  10647. if (this.widths.has(code)) {
  10648. continue;
  10649. }
  10650. const metrics = ctx.measureText(char);
  10651. const width = Math.ceil(metrics.width);
  10652. this.widths.set(code, width);
  10653. this.firstChar = Math.min(code, this.firstChar);
  10654. this.lastChar = Math.max(code, this.lastChar);
  10655. }
  10656. }
  10657. return this.resources;
  10658. }
  10659. createAppearance(text, rect, rotation, fontSize, bgColor, strokeAlpha) {
  10660. const ctx = this._createContext();
  10661. const lines = [];
  10662. let maxWidth = -Infinity;
  10663. for (const line of text.split(/\r\n?|\n/)) {
  10664. lines.push(line);
  10665. const lineWidth = ctx.measureText(line).width;
  10666. maxWidth = Math.max(maxWidth, lineWidth);
  10667. for (const char of line.split("")) {
  10668. const code = char.charCodeAt(0);
  10669. let width = this.widths.get(code);
  10670. if (width === undefined) {
  10671. const metrics = ctx.measureText(char);
  10672. width = Math.ceil(metrics.width);
  10673. this.widths.set(code, width);
  10674. this.firstChar = Math.min(code, this.firstChar);
  10675. this.lastChar = Math.max(code, this.lastChar);
  10676. }
  10677. }
  10678. }
  10679. maxWidth *= fontSize / 1000;
  10680. const [x1, y1, x2, y2] = rect;
  10681. let w = x2 - x1;
  10682. let h = y2 - y1;
  10683. if (rotation % 180 !== 0) {
  10684. [w, h] = [h, w];
  10685. }
  10686. let hscale = 1;
  10687. if (maxWidth > w) {
  10688. hscale = w / maxWidth;
  10689. }
  10690. let vscale = 1;
  10691. const lineHeight = _util.LINE_FACTOR * fontSize;
  10692. const lineDescent = _util.LINE_DESCENT_FACTOR * fontSize;
  10693. const maxHeight = lineHeight * lines.length;
  10694. if (maxHeight > h) {
  10695. vscale = h / maxHeight;
  10696. }
  10697. const fscale = Math.min(hscale, vscale);
  10698. const newFontSize = fontSize * fscale;
  10699. 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`];
  10700. const {
  10701. resources
  10702. } = this;
  10703. strokeAlpha = typeof strokeAlpha === "number" && strokeAlpha >= 0 && strokeAlpha <= 1 ? strokeAlpha : 1;
  10704. if (strokeAlpha !== 1) {
  10705. buffer.push("/R0 gs");
  10706. const extGState = new _primitives.Dict(this.xref);
  10707. const r0 = new _primitives.Dict(this.xref);
  10708. r0.set("ca", strokeAlpha);
  10709. r0.set("CA", strokeAlpha);
  10710. r0.set("Type", _primitives.Name.get("ExtGState"));
  10711. extGState.set("R0", r0);
  10712. resources.set("ExtGState", extGState);
  10713. }
  10714. const vShift = (0, _core_utils.numberToString)(lineHeight);
  10715. for (const line of lines) {
  10716. buffer.push(`0 -${vShift} Td <${(0, _core_utils.stringToUTF16HexString)(line)}> Tj`);
  10717. }
  10718. buffer.push("ET", "Q");
  10719. const appearance = buffer.join("\n");
  10720. const appearanceStreamDict = new _primitives.Dict(this.xref);
  10721. appearanceStreamDict.set("Subtype", _primitives.Name.get("Form"));
  10722. appearanceStreamDict.set("Type", _primitives.Name.get("XObject"));
  10723. appearanceStreamDict.set("BBox", [0, 0, w, h]);
  10724. appearanceStreamDict.set("Length", appearance.length);
  10725. appearanceStreamDict.set("Resources", resources);
  10726. if (rotation) {
  10727. const matrix = (0, _core_utils.getRotationMatrix)(rotation, w, h);
  10728. appearanceStreamDict.set("Matrix", matrix);
  10729. }
  10730. const ap = new _stream.StringStream(appearance);
  10731. ap.dict = appearanceStreamDict;
  10732. return ap;
  10733. }
  10734. }
  10735. exports.FakeUnicodeFont = FakeUnicodeFont;
  10736. /***/ }),
  10737. /* 163 */
  10738. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  10739. Object.defineProperty(exports, "__esModule", ({
  10740. value: true
  10741. }));
  10742. exports.ColorSpace = void 0;
  10743. __w_pdfjs_require__(84);
  10744. __w_pdfjs_require__(93);
  10745. __w_pdfjs_require__(94);
  10746. __w_pdfjs_require__(97);
  10747. __w_pdfjs_require__(99);
  10748. __w_pdfjs_require__(101);
  10749. __w_pdfjs_require__(105);
  10750. __w_pdfjs_require__(108);
  10751. __w_pdfjs_require__(115);
  10752. __w_pdfjs_require__(2);
  10753. var _util = __w_pdfjs_require__(145);
  10754. var _primitives = __w_pdfjs_require__(151);
  10755. var _base_stream = __w_pdfjs_require__(152);
  10756. var _core_utils = __w_pdfjs_require__(150);
  10757. function resizeRgbImage(src, dest, w1, h1, w2, h2, alpha01) {
  10758. const COMPONENTS = 3;
  10759. alpha01 = alpha01 !== 1 ? 0 : alpha01;
  10760. const xRatio = w1 / w2;
  10761. const yRatio = h1 / h2;
  10762. let newIndex = 0,
  10763. oldIndex;
  10764. const xScaled = new Uint16Array(w2);
  10765. const w1Scanline = w1 * COMPONENTS;
  10766. for (let i = 0; i < w2; i++) {
  10767. xScaled[i] = Math.floor(i * xRatio) * COMPONENTS;
  10768. }
  10769. for (let i = 0; i < h2; i++) {
  10770. const py = Math.floor(i * yRatio) * w1Scanline;
  10771. for (let j = 0; j < w2; j++) {
  10772. oldIndex = py + xScaled[j];
  10773. dest[newIndex++] = src[oldIndex++];
  10774. dest[newIndex++] = src[oldIndex++];
  10775. dest[newIndex++] = src[oldIndex++];
  10776. newIndex += alpha01;
  10777. }
  10778. }
  10779. }
  10780. class ColorSpace {
  10781. constructor(name, numComps) {
  10782. if (this.constructor === ColorSpace) {
  10783. (0, _util.unreachable)("Cannot initialize ColorSpace.");
  10784. }
  10785. this.name = name;
  10786. this.numComps = numComps;
  10787. }
  10788. getRgb(src, srcOffset) {
  10789. const rgb = new Uint8ClampedArray(3);
  10790. this.getRgbItem(src, srcOffset, rgb, 0);
  10791. return rgb;
  10792. }
  10793. getRgbItem(src, srcOffset, dest, destOffset) {
  10794. (0, _util.unreachable)("Should not call ColorSpace.getRgbItem");
  10795. }
  10796. getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  10797. (0, _util.unreachable)("Should not call ColorSpace.getRgbBuffer");
  10798. }
  10799. getOutputLength(inputLength, alpha01) {
  10800. (0, _util.unreachable)("Should not call ColorSpace.getOutputLength");
  10801. }
  10802. isPassthrough(bits) {
  10803. return false;
  10804. }
  10805. isDefaultDecode(decodeMap, bpc) {
  10806. return ColorSpace.isDefaultDecode(decodeMap, this.numComps);
  10807. }
  10808. fillRgb(dest, originalWidth, originalHeight, width, height, actualHeight, bpc, comps, alpha01) {
  10809. const count = originalWidth * originalHeight;
  10810. let rgbBuf = null;
  10811. const numComponentColors = 1 << bpc;
  10812. const needsResizing = originalHeight !== height || originalWidth !== width;
  10813. if (this.isPassthrough(bpc)) {
  10814. rgbBuf = comps;
  10815. } else if (this.numComps === 1 && count > numComponentColors && this.name !== "DeviceGray" && this.name !== "DeviceRGB") {
  10816. const allColors = bpc <= 8 ? new Uint8Array(numComponentColors) : new Uint16Array(numComponentColors);
  10817. for (let i = 0; i < numComponentColors; i++) {
  10818. allColors[i] = i;
  10819. }
  10820. const colorMap = new Uint8ClampedArray(numComponentColors * 3);
  10821. this.getRgbBuffer(allColors, 0, numComponentColors, colorMap, 0, bpc, 0);
  10822. if (!needsResizing) {
  10823. let destPos = 0;
  10824. for (let i = 0; i < count; ++i) {
  10825. const key = comps[i] * 3;
  10826. dest[destPos++] = colorMap[key];
  10827. dest[destPos++] = colorMap[key + 1];
  10828. dest[destPos++] = colorMap[key + 2];
  10829. destPos += alpha01;
  10830. }
  10831. } else {
  10832. rgbBuf = new Uint8Array(count * 3);
  10833. let rgbPos = 0;
  10834. for (let i = 0; i < count; ++i) {
  10835. const key = comps[i] * 3;
  10836. rgbBuf[rgbPos++] = colorMap[key];
  10837. rgbBuf[rgbPos++] = colorMap[key + 1];
  10838. rgbBuf[rgbPos++] = colorMap[key + 2];
  10839. }
  10840. }
  10841. } else if (!needsResizing) {
  10842. this.getRgbBuffer(comps, 0, width * actualHeight, dest, 0, bpc, alpha01);
  10843. } else {
  10844. rgbBuf = new Uint8ClampedArray(count * 3);
  10845. this.getRgbBuffer(comps, 0, count, rgbBuf, 0, bpc, 0);
  10846. }
  10847. if (rgbBuf) {
  10848. if (needsResizing) {
  10849. resizeRgbImage(rgbBuf, dest, originalWidth, originalHeight, width, height, alpha01);
  10850. } else {
  10851. let destPos = 0,
  10852. rgbPos = 0;
  10853. for (let i = 0, ii = width * actualHeight; i < ii; i++) {
  10854. dest[destPos++] = rgbBuf[rgbPos++];
  10855. dest[destPos++] = rgbBuf[rgbPos++];
  10856. dest[destPos++] = rgbBuf[rgbPos++];
  10857. destPos += alpha01;
  10858. }
  10859. }
  10860. }
  10861. }
  10862. get usesZeroToOneRange() {
  10863. return (0, _util.shadow)(this, "usesZeroToOneRange", true);
  10864. }
  10865. static _cache(cacheKey, xref, localColorSpaceCache, parsedColorSpace) {
  10866. if (!localColorSpaceCache) {
  10867. throw new Error('ColorSpace._cache - expected "localColorSpaceCache" argument.');
  10868. }
  10869. if (!parsedColorSpace) {
  10870. throw new Error('ColorSpace._cache - expected "parsedColorSpace" argument.');
  10871. }
  10872. let csName, csRef;
  10873. if (cacheKey instanceof _primitives.Ref) {
  10874. csRef = cacheKey;
  10875. cacheKey = xref.fetch(cacheKey);
  10876. }
  10877. if (cacheKey instanceof _primitives.Name) {
  10878. csName = cacheKey.name;
  10879. }
  10880. if (csName || csRef) {
  10881. localColorSpaceCache.set(csName, csRef, parsedColorSpace);
  10882. }
  10883. }
  10884. static getCached(cacheKey, xref, localColorSpaceCache) {
  10885. if (!localColorSpaceCache) {
  10886. throw new Error('ColorSpace.getCached - expected "localColorSpaceCache" argument.');
  10887. }
  10888. if (cacheKey instanceof _primitives.Ref) {
  10889. const localColorSpace = localColorSpaceCache.getByRef(cacheKey);
  10890. if (localColorSpace) {
  10891. return localColorSpace;
  10892. }
  10893. try {
  10894. cacheKey = xref.fetch(cacheKey);
  10895. } catch (ex) {
  10896. if (ex instanceof _core_utils.MissingDataException) {
  10897. throw ex;
  10898. }
  10899. }
  10900. }
  10901. if (cacheKey instanceof _primitives.Name) {
  10902. const localColorSpace = localColorSpaceCache.getByName(cacheKey.name);
  10903. if (localColorSpace) {
  10904. return localColorSpace;
  10905. }
  10906. }
  10907. return null;
  10908. }
  10909. static async parseAsync(_ref) {
  10910. let {
  10911. cs,
  10912. xref,
  10913. resources = null,
  10914. pdfFunctionFactory,
  10915. localColorSpaceCache
  10916. } = _ref;
  10917. const parsedColorSpace = this._parse(cs, xref, resources, pdfFunctionFactory);
  10918. this._cache(cs, xref, localColorSpaceCache, parsedColorSpace);
  10919. return parsedColorSpace;
  10920. }
  10921. static parse(_ref2) {
  10922. let {
  10923. cs,
  10924. xref,
  10925. resources = null,
  10926. pdfFunctionFactory,
  10927. localColorSpaceCache
  10928. } = _ref2;
  10929. const cachedColorSpace = this.getCached(cs, xref, localColorSpaceCache);
  10930. if (cachedColorSpace) {
  10931. return cachedColorSpace;
  10932. }
  10933. const parsedColorSpace = this._parse(cs, xref, resources, pdfFunctionFactory);
  10934. this._cache(cs, xref, localColorSpaceCache, parsedColorSpace);
  10935. return parsedColorSpace;
  10936. }
  10937. static _parse(cs, xref) {
  10938. let resources = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
  10939. let pdfFunctionFactory = arguments.length > 3 ? arguments[3] : undefined;
  10940. cs = xref.fetchIfRef(cs);
  10941. if (cs instanceof _primitives.Name) {
  10942. switch (cs.name) {
  10943. case "G":
  10944. case "DeviceGray":
  10945. return this.singletons.gray;
  10946. case "RGB":
  10947. case "DeviceRGB":
  10948. return this.singletons.rgb;
  10949. case "CMYK":
  10950. case "DeviceCMYK":
  10951. return this.singletons.cmyk;
  10952. case "Pattern":
  10953. return new PatternCS(null);
  10954. default:
  10955. if (resources instanceof _primitives.Dict) {
  10956. const colorSpaces = resources.get("ColorSpace");
  10957. if (colorSpaces instanceof _primitives.Dict) {
  10958. const resourcesCS = colorSpaces.get(cs.name);
  10959. if (resourcesCS) {
  10960. if (resourcesCS instanceof _primitives.Name) {
  10961. return this._parse(resourcesCS, xref, resources, pdfFunctionFactory);
  10962. }
  10963. cs = resourcesCS;
  10964. break;
  10965. }
  10966. }
  10967. }
  10968. throw new _util.FormatError(`Unrecognized ColorSpace: ${cs.name}`);
  10969. }
  10970. }
  10971. if (Array.isArray(cs)) {
  10972. const mode = xref.fetchIfRef(cs[0]).name;
  10973. let params, numComps, baseCS, whitePoint, blackPoint, gamma;
  10974. switch (mode) {
  10975. case "G":
  10976. case "DeviceGray":
  10977. return this.singletons.gray;
  10978. case "RGB":
  10979. case "DeviceRGB":
  10980. return this.singletons.rgb;
  10981. case "CMYK":
  10982. case "DeviceCMYK":
  10983. return this.singletons.cmyk;
  10984. case "CalGray":
  10985. params = xref.fetchIfRef(cs[1]);
  10986. whitePoint = params.getArray("WhitePoint");
  10987. blackPoint = params.getArray("BlackPoint");
  10988. gamma = params.get("Gamma");
  10989. return new CalGrayCS(whitePoint, blackPoint, gamma);
  10990. case "CalRGB":
  10991. params = xref.fetchIfRef(cs[1]);
  10992. whitePoint = params.getArray("WhitePoint");
  10993. blackPoint = params.getArray("BlackPoint");
  10994. gamma = params.getArray("Gamma");
  10995. const matrix = params.getArray("Matrix");
  10996. return new CalRGBCS(whitePoint, blackPoint, gamma, matrix);
  10997. case "ICCBased":
  10998. const stream = xref.fetchIfRef(cs[1]);
  10999. const dict = stream.dict;
  11000. numComps = dict.get("N");
  11001. const alt = dict.get("Alternate");
  11002. if (alt) {
  11003. const altCS = this._parse(alt, xref, resources, pdfFunctionFactory);
  11004. if (altCS.numComps === numComps) {
  11005. return altCS;
  11006. }
  11007. (0, _util.warn)("ICCBased color space: Ignoring incorrect /Alternate entry.");
  11008. }
  11009. if (numComps === 1) {
  11010. return this.singletons.gray;
  11011. } else if (numComps === 3) {
  11012. return this.singletons.rgb;
  11013. } else if (numComps === 4) {
  11014. return this.singletons.cmyk;
  11015. }
  11016. break;
  11017. case "Pattern":
  11018. baseCS = cs[1] || null;
  11019. if (baseCS) {
  11020. baseCS = this._parse(baseCS, xref, resources, pdfFunctionFactory);
  11021. }
  11022. return new PatternCS(baseCS);
  11023. case "I":
  11024. case "Indexed":
  11025. baseCS = this._parse(cs[1], xref, resources, pdfFunctionFactory);
  11026. const hiVal = xref.fetchIfRef(cs[2]) + 1;
  11027. const lookup = xref.fetchIfRef(cs[3]);
  11028. return new IndexedCS(baseCS, hiVal, lookup);
  11029. case "Separation":
  11030. case "DeviceN":
  11031. const name = xref.fetchIfRef(cs[1]);
  11032. numComps = Array.isArray(name) ? name.length : 1;
  11033. baseCS = this._parse(cs[2], xref, resources, pdfFunctionFactory);
  11034. const tintFn = pdfFunctionFactory.create(cs[3]);
  11035. return new AlternateCS(numComps, baseCS, tintFn);
  11036. case "Lab":
  11037. params = xref.fetchIfRef(cs[1]);
  11038. whitePoint = params.getArray("WhitePoint");
  11039. blackPoint = params.getArray("BlackPoint");
  11040. const range = params.getArray("Range");
  11041. return new LabCS(whitePoint, blackPoint, range);
  11042. default:
  11043. throw new _util.FormatError(`Unimplemented ColorSpace object: ${mode}`);
  11044. }
  11045. }
  11046. throw new _util.FormatError(`Unrecognized ColorSpace object: ${cs}`);
  11047. }
  11048. static isDefaultDecode(decode, numComps) {
  11049. if (!Array.isArray(decode)) {
  11050. return true;
  11051. }
  11052. if (numComps * 2 !== decode.length) {
  11053. (0, _util.warn)("The decode map is not the correct length");
  11054. return true;
  11055. }
  11056. for (let i = 0, ii = decode.length; i < ii; i += 2) {
  11057. if (decode[i] !== 0 || decode[i + 1] !== 1) {
  11058. return false;
  11059. }
  11060. }
  11061. return true;
  11062. }
  11063. static get singletons() {
  11064. return (0, _util.shadow)(this, "singletons", {
  11065. get gray() {
  11066. return (0, _util.shadow)(this, "gray", new DeviceGrayCS());
  11067. },
  11068. get rgb() {
  11069. return (0, _util.shadow)(this, "rgb", new DeviceRgbCS());
  11070. },
  11071. get cmyk() {
  11072. return (0, _util.shadow)(this, "cmyk", new DeviceCmykCS());
  11073. }
  11074. });
  11075. }
  11076. }
  11077. exports.ColorSpace = ColorSpace;
  11078. class AlternateCS extends ColorSpace {
  11079. constructor(numComps, base, tintFn) {
  11080. super("Alternate", numComps);
  11081. this.base = base;
  11082. this.tintFn = tintFn;
  11083. this.tmpBuf = new Float32Array(base.numComps);
  11084. }
  11085. getRgbItem(src, srcOffset, dest, destOffset) {
  11086. const tmpBuf = this.tmpBuf;
  11087. this.tintFn(src, srcOffset, tmpBuf, 0);
  11088. this.base.getRgbItem(tmpBuf, 0, dest, destOffset);
  11089. }
  11090. getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  11091. const tintFn = this.tintFn;
  11092. const base = this.base;
  11093. const scale = 1 / ((1 << bits) - 1);
  11094. const baseNumComps = base.numComps;
  11095. const usesZeroToOneRange = base.usesZeroToOneRange;
  11096. const isPassthrough = (base.isPassthrough(8) || !usesZeroToOneRange) && alpha01 === 0;
  11097. let pos = isPassthrough ? destOffset : 0;
  11098. const baseBuf = isPassthrough ? dest : new Uint8ClampedArray(baseNumComps * count);
  11099. const numComps = this.numComps;
  11100. const scaled = new Float32Array(numComps);
  11101. const tinted = new Float32Array(baseNumComps);
  11102. let i, j;
  11103. for (i = 0; i < count; i++) {
  11104. for (j = 0; j < numComps; j++) {
  11105. scaled[j] = src[srcOffset++] * scale;
  11106. }
  11107. tintFn(scaled, 0, tinted, 0);
  11108. if (usesZeroToOneRange) {
  11109. for (j = 0; j < baseNumComps; j++) {
  11110. baseBuf[pos++] = tinted[j] * 255;
  11111. }
  11112. } else {
  11113. base.getRgbItem(tinted, 0, baseBuf, pos);
  11114. pos += baseNumComps;
  11115. }
  11116. }
  11117. if (!isPassthrough) {
  11118. base.getRgbBuffer(baseBuf, 0, count, dest, destOffset, 8, alpha01);
  11119. }
  11120. }
  11121. getOutputLength(inputLength, alpha01) {
  11122. return this.base.getOutputLength(inputLength * this.base.numComps / this.numComps, alpha01);
  11123. }
  11124. }
  11125. class PatternCS extends ColorSpace {
  11126. constructor(baseCS) {
  11127. super("Pattern", null);
  11128. this.base = baseCS;
  11129. }
  11130. isDefaultDecode(decodeMap, bpc) {
  11131. (0, _util.unreachable)("Should not call PatternCS.isDefaultDecode");
  11132. }
  11133. }
  11134. class IndexedCS extends ColorSpace {
  11135. constructor(base, highVal, lookup) {
  11136. super("Indexed", 1);
  11137. this.base = base;
  11138. this.highVal = highVal;
  11139. const length = base.numComps * highVal;
  11140. this.lookup = new Uint8Array(length);
  11141. if (lookup instanceof _base_stream.BaseStream) {
  11142. const bytes = lookup.getBytes(length);
  11143. this.lookup.set(bytes);
  11144. } else if (typeof lookup === "string") {
  11145. for (let i = 0; i < length; ++i) {
  11146. this.lookup[i] = lookup.charCodeAt(i) & 0xff;
  11147. }
  11148. } else {
  11149. throw new _util.FormatError(`IndexedCS - unrecognized lookup table: ${lookup}`);
  11150. }
  11151. }
  11152. getRgbItem(src, srcOffset, dest, destOffset) {
  11153. const numComps = this.base.numComps;
  11154. const start = src[srcOffset] * numComps;
  11155. this.base.getRgbBuffer(this.lookup, start, 1, dest, destOffset, 8, 0);
  11156. }
  11157. getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  11158. const base = this.base;
  11159. const numComps = base.numComps;
  11160. const outputDelta = base.getOutputLength(numComps, alpha01);
  11161. const lookup = this.lookup;
  11162. for (let i = 0; i < count; ++i) {
  11163. const lookupPos = src[srcOffset++] * numComps;
  11164. base.getRgbBuffer(lookup, lookupPos, 1, dest, destOffset, 8, alpha01);
  11165. destOffset += outputDelta;
  11166. }
  11167. }
  11168. getOutputLength(inputLength, alpha01) {
  11169. return this.base.getOutputLength(inputLength * this.base.numComps, alpha01);
  11170. }
  11171. isDefaultDecode(decodeMap, bpc) {
  11172. if (!Array.isArray(decodeMap)) {
  11173. return true;
  11174. }
  11175. if (decodeMap.length !== 2) {
  11176. (0, _util.warn)("Decode map length is not correct");
  11177. return true;
  11178. }
  11179. if (!Number.isInteger(bpc) || bpc < 1) {
  11180. (0, _util.warn)("Bits per component is not correct");
  11181. return true;
  11182. }
  11183. return decodeMap[0] === 0 && decodeMap[1] === (1 << bpc) - 1;
  11184. }
  11185. }
  11186. class DeviceGrayCS extends ColorSpace {
  11187. constructor() {
  11188. super("DeviceGray", 1);
  11189. }
  11190. getRgbItem(src, srcOffset, dest, destOffset) {
  11191. const c = src[srcOffset] * 255;
  11192. dest[destOffset] = dest[destOffset + 1] = dest[destOffset + 2] = c;
  11193. }
  11194. getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  11195. const scale = 255 / ((1 << bits) - 1);
  11196. let j = srcOffset,
  11197. q = destOffset;
  11198. for (let i = 0; i < count; ++i) {
  11199. const c = scale * src[j++];
  11200. dest[q++] = c;
  11201. dest[q++] = c;
  11202. dest[q++] = c;
  11203. q += alpha01;
  11204. }
  11205. }
  11206. getOutputLength(inputLength, alpha01) {
  11207. return inputLength * (3 + alpha01);
  11208. }
  11209. }
  11210. class DeviceRgbCS extends ColorSpace {
  11211. constructor() {
  11212. super("DeviceRGB", 3);
  11213. }
  11214. getRgbItem(src, srcOffset, dest, destOffset) {
  11215. dest[destOffset] = src[srcOffset] * 255;
  11216. dest[destOffset + 1] = src[srcOffset + 1] * 255;
  11217. dest[destOffset + 2] = src[srcOffset + 2] * 255;
  11218. }
  11219. getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  11220. if (bits === 8 && alpha01 === 0) {
  11221. dest.set(src.subarray(srcOffset, srcOffset + count * 3), destOffset);
  11222. return;
  11223. }
  11224. const scale = 255 / ((1 << bits) - 1);
  11225. let j = srcOffset,
  11226. q = destOffset;
  11227. for (let i = 0; i < count; ++i) {
  11228. dest[q++] = scale * src[j++];
  11229. dest[q++] = scale * src[j++];
  11230. dest[q++] = scale * src[j++];
  11231. q += alpha01;
  11232. }
  11233. }
  11234. getOutputLength(inputLength, alpha01) {
  11235. return inputLength * (3 + alpha01) / 3 | 0;
  11236. }
  11237. isPassthrough(bits) {
  11238. return bits === 8;
  11239. }
  11240. }
  11241. const DeviceCmykCS = function DeviceCmykCSClosure() {
  11242. function convertToRgb(src, srcOffset, srcScale, dest, destOffset) {
  11243. const c = src[srcOffset] * srcScale;
  11244. const m = src[srcOffset + 1] * srcScale;
  11245. const y = src[srcOffset + 2] * srcScale;
  11246. const k = src[srcOffset + 3] * srcScale;
  11247. 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);
  11248. 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);
  11249. 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);
  11250. }
  11251. class DeviceCmykCS extends ColorSpace {
  11252. constructor() {
  11253. super("DeviceCMYK", 4);
  11254. }
  11255. getRgbItem(src, srcOffset, dest, destOffset) {
  11256. convertToRgb(src, srcOffset, 1, dest, destOffset);
  11257. }
  11258. getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  11259. const scale = 1 / ((1 << bits) - 1);
  11260. for (let i = 0; i < count; i++) {
  11261. convertToRgb(src, srcOffset, scale, dest, destOffset);
  11262. srcOffset += 4;
  11263. destOffset += 3 + alpha01;
  11264. }
  11265. }
  11266. getOutputLength(inputLength, alpha01) {
  11267. return inputLength / 4 * (3 + alpha01) | 0;
  11268. }
  11269. }
  11270. return DeviceCmykCS;
  11271. }();
  11272. const CalGrayCS = function CalGrayCSClosure() {
  11273. function convertToRgb(cs, src, srcOffset, dest, destOffset, scale) {
  11274. const A = src[srcOffset] * scale;
  11275. const AG = A ** cs.G;
  11276. const L = cs.YW * AG;
  11277. const val = Math.max(295.8 * L ** 0.3333333333333333 - 40.8, 0);
  11278. dest[destOffset] = val;
  11279. dest[destOffset + 1] = val;
  11280. dest[destOffset + 2] = val;
  11281. }
  11282. class CalGrayCS extends ColorSpace {
  11283. constructor(whitePoint, blackPoint, gamma) {
  11284. super("CalGray", 1);
  11285. if (!whitePoint) {
  11286. throw new _util.FormatError("WhitePoint missing - required for color space CalGray");
  11287. }
  11288. blackPoint ||= [0, 0, 0];
  11289. gamma ||= 1;
  11290. this.XW = whitePoint[0];
  11291. this.YW = whitePoint[1];
  11292. this.ZW = whitePoint[2];
  11293. this.XB = blackPoint[0];
  11294. this.YB = blackPoint[1];
  11295. this.ZB = blackPoint[2];
  11296. this.G = gamma;
  11297. if (this.XW < 0 || this.ZW < 0 || this.YW !== 1) {
  11298. throw new _util.FormatError(`Invalid WhitePoint components for ${this.name}` + ", no fallback available");
  11299. }
  11300. if (this.XB < 0 || this.YB < 0 || this.ZB < 0) {
  11301. (0, _util.info)(`Invalid BlackPoint for ${this.name}, falling back to default.`);
  11302. this.XB = this.YB = this.ZB = 0;
  11303. }
  11304. if (this.XB !== 0 || this.YB !== 0 || this.ZB !== 0) {
  11305. (0, _util.warn)(`${this.name}, BlackPoint: XB: ${this.XB}, YB: ${this.YB}, ` + `ZB: ${this.ZB}, only default values are supported.`);
  11306. }
  11307. if (this.G < 1) {
  11308. (0, _util.info)(`Invalid Gamma: ${this.G} for ${this.name}, ` + "falling back to default.");
  11309. this.G = 1;
  11310. }
  11311. }
  11312. getRgbItem(src, srcOffset, dest, destOffset) {
  11313. convertToRgb(this, src, srcOffset, dest, destOffset, 1);
  11314. }
  11315. getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  11316. const scale = 1 / ((1 << bits) - 1);
  11317. for (let i = 0; i < count; ++i) {
  11318. convertToRgb(this, src, srcOffset, dest, destOffset, scale);
  11319. srcOffset += 1;
  11320. destOffset += 3 + alpha01;
  11321. }
  11322. }
  11323. getOutputLength(inputLength, alpha01) {
  11324. return inputLength * (3 + alpha01);
  11325. }
  11326. }
  11327. return CalGrayCS;
  11328. }();
  11329. const CalRGBCS = function CalRGBCSClosure() {
  11330. const BRADFORD_SCALE_MATRIX = new Float32Array([0.8951, 0.2664, -0.1614, -0.7502, 1.7135, 0.0367, 0.0389, -0.0685, 1.0296]);
  11331. 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]);
  11332. 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]);
  11333. const FLAT_WHITEPOINT_MATRIX = new Float32Array([1, 1, 1]);
  11334. const tempNormalizeMatrix = new Float32Array(3);
  11335. const tempConvertMatrix1 = new Float32Array(3);
  11336. const tempConvertMatrix2 = new Float32Array(3);
  11337. const DECODE_L_CONSTANT = ((8 + 16) / 116) ** 3 / 8.0;
  11338. function matrixProduct(a, b, result) {
  11339. result[0] = a[0] * b[0] + a[1] * b[1] + a[2] * b[2];
  11340. result[1] = a[3] * b[0] + a[4] * b[1] + a[5] * b[2];
  11341. result[2] = a[6] * b[0] + a[7] * b[1] + a[8] * b[2];
  11342. }
  11343. function convertToFlat(sourceWhitePoint, LMS, result) {
  11344. result[0] = LMS[0] * 1 / sourceWhitePoint[0];
  11345. result[1] = LMS[1] * 1 / sourceWhitePoint[1];
  11346. result[2] = LMS[2] * 1 / sourceWhitePoint[2];
  11347. }
  11348. function convertToD65(sourceWhitePoint, LMS, result) {
  11349. const D65X = 0.95047;
  11350. const D65Y = 1;
  11351. const D65Z = 1.08883;
  11352. result[0] = LMS[0] * D65X / sourceWhitePoint[0];
  11353. result[1] = LMS[1] * D65Y / sourceWhitePoint[1];
  11354. result[2] = LMS[2] * D65Z / sourceWhitePoint[2];
  11355. }
  11356. function sRGBTransferFunction(color) {
  11357. if (color <= 0.0031308) {
  11358. return adjustToRange(0, 1, 12.92 * color);
  11359. }
  11360. if (color >= 0.99554525) {
  11361. return 1;
  11362. }
  11363. return adjustToRange(0, 1, (1 + 0.055) * color ** (1 / 2.4) - 0.055);
  11364. }
  11365. function adjustToRange(min, max, value) {
  11366. return Math.max(min, Math.min(max, value));
  11367. }
  11368. function decodeL(L) {
  11369. if (L < 0) {
  11370. return -decodeL(-L);
  11371. }
  11372. if (L > 8.0) {
  11373. return ((L + 16) / 116) ** 3;
  11374. }
  11375. return L * DECODE_L_CONSTANT;
  11376. }
  11377. function compensateBlackPoint(sourceBlackPoint, XYZ_Flat, result) {
  11378. if (sourceBlackPoint[0] === 0 && sourceBlackPoint[1] === 0 && sourceBlackPoint[2] === 0) {
  11379. result[0] = XYZ_Flat[0];
  11380. result[1] = XYZ_Flat[1];
  11381. result[2] = XYZ_Flat[2];
  11382. return;
  11383. }
  11384. const zeroDecodeL = decodeL(0);
  11385. const X_DST = zeroDecodeL;
  11386. const X_SRC = decodeL(sourceBlackPoint[0]);
  11387. const Y_DST = zeroDecodeL;
  11388. const Y_SRC = decodeL(sourceBlackPoint[1]);
  11389. const Z_DST = zeroDecodeL;
  11390. const Z_SRC = decodeL(sourceBlackPoint[2]);
  11391. const X_Scale = (1 - X_DST) / (1 - X_SRC);
  11392. const X_Offset = 1 - X_Scale;
  11393. const Y_Scale = (1 - Y_DST) / (1 - Y_SRC);
  11394. const Y_Offset = 1 - Y_Scale;
  11395. const Z_Scale = (1 - Z_DST) / (1 - Z_SRC);
  11396. const Z_Offset = 1 - Z_Scale;
  11397. result[0] = XYZ_Flat[0] * X_Scale + X_Offset;
  11398. result[1] = XYZ_Flat[1] * Y_Scale + Y_Offset;
  11399. result[2] = XYZ_Flat[2] * Z_Scale + Z_Offset;
  11400. }
  11401. function normalizeWhitePointToFlat(sourceWhitePoint, XYZ_In, result) {
  11402. if (sourceWhitePoint[0] === 1 && sourceWhitePoint[2] === 1) {
  11403. result[0] = XYZ_In[0];
  11404. result[1] = XYZ_In[1];
  11405. result[2] = XYZ_In[2];
  11406. return;
  11407. }
  11408. const LMS = result;
  11409. matrixProduct(BRADFORD_SCALE_MATRIX, XYZ_In, LMS);
  11410. const LMS_Flat = tempNormalizeMatrix;
  11411. convertToFlat(sourceWhitePoint, LMS, LMS_Flat);
  11412. matrixProduct(BRADFORD_SCALE_INVERSE_MATRIX, LMS_Flat, result);
  11413. }
  11414. function normalizeWhitePointToD65(sourceWhitePoint, XYZ_In, result) {
  11415. const LMS = result;
  11416. matrixProduct(BRADFORD_SCALE_MATRIX, XYZ_In, LMS);
  11417. const LMS_D65 = tempNormalizeMatrix;
  11418. convertToD65(sourceWhitePoint, LMS, LMS_D65);
  11419. matrixProduct(BRADFORD_SCALE_INVERSE_MATRIX, LMS_D65, result);
  11420. }
  11421. function convertToRgb(cs, src, srcOffset, dest, destOffset, scale) {
  11422. const A = adjustToRange(0, 1, src[srcOffset] * scale);
  11423. const B = adjustToRange(0, 1, src[srcOffset + 1] * scale);
  11424. const C = adjustToRange(0, 1, src[srcOffset + 2] * scale);
  11425. const AGR = A === 1 ? 1 : A ** cs.GR;
  11426. const BGG = B === 1 ? 1 : B ** cs.GG;
  11427. const CGB = C === 1 ? 1 : C ** cs.GB;
  11428. const X = cs.MXA * AGR + cs.MXB * BGG + cs.MXC * CGB;
  11429. const Y = cs.MYA * AGR + cs.MYB * BGG + cs.MYC * CGB;
  11430. const Z = cs.MZA * AGR + cs.MZB * BGG + cs.MZC * CGB;
  11431. const XYZ = tempConvertMatrix1;
  11432. XYZ[0] = X;
  11433. XYZ[1] = Y;
  11434. XYZ[2] = Z;
  11435. const XYZ_Flat = tempConvertMatrix2;
  11436. normalizeWhitePointToFlat(cs.whitePoint, XYZ, XYZ_Flat);
  11437. const XYZ_Black = tempConvertMatrix1;
  11438. compensateBlackPoint(cs.blackPoint, XYZ_Flat, XYZ_Black);
  11439. const XYZ_D65 = tempConvertMatrix2;
  11440. normalizeWhitePointToD65(FLAT_WHITEPOINT_MATRIX, XYZ_Black, XYZ_D65);
  11441. const SRGB = tempConvertMatrix1;
  11442. matrixProduct(SRGB_D65_XYZ_TO_RGB_MATRIX, XYZ_D65, SRGB);
  11443. dest[destOffset] = sRGBTransferFunction(SRGB[0]) * 255;
  11444. dest[destOffset + 1] = sRGBTransferFunction(SRGB[1]) * 255;
  11445. dest[destOffset + 2] = sRGBTransferFunction(SRGB[2]) * 255;
  11446. }
  11447. class CalRGBCS extends ColorSpace {
  11448. constructor(whitePoint, blackPoint, gamma, matrix) {
  11449. super("CalRGB", 3);
  11450. if (!whitePoint) {
  11451. throw new _util.FormatError("WhitePoint missing - required for color space CalRGB");
  11452. }
  11453. blackPoint ||= new Float32Array(3);
  11454. gamma ||= new Float32Array([1, 1, 1]);
  11455. matrix ||= new Float32Array([1, 0, 0, 0, 1, 0, 0, 0, 1]);
  11456. const XW = whitePoint[0];
  11457. const YW = whitePoint[1];
  11458. const ZW = whitePoint[2];
  11459. this.whitePoint = whitePoint;
  11460. const XB = blackPoint[0];
  11461. const YB = blackPoint[1];
  11462. const ZB = blackPoint[2];
  11463. this.blackPoint = blackPoint;
  11464. this.GR = gamma[0];
  11465. this.GG = gamma[1];
  11466. this.GB = gamma[2];
  11467. this.MXA = matrix[0];
  11468. this.MYA = matrix[1];
  11469. this.MZA = matrix[2];
  11470. this.MXB = matrix[3];
  11471. this.MYB = matrix[4];
  11472. this.MZB = matrix[5];
  11473. this.MXC = matrix[6];
  11474. this.MYC = matrix[7];
  11475. this.MZC = matrix[8];
  11476. if (XW < 0 || ZW < 0 || YW !== 1) {
  11477. throw new _util.FormatError(`Invalid WhitePoint components for ${this.name}` + ", no fallback available");
  11478. }
  11479. if (XB < 0 || YB < 0 || ZB < 0) {
  11480. (0, _util.info)(`Invalid BlackPoint for ${this.name} [${XB}, ${YB}, ${ZB}], ` + "falling back to default.");
  11481. this.blackPoint = new Float32Array(3);
  11482. }
  11483. if (this.GR < 0 || this.GG < 0 || this.GB < 0) {
  11484. (0, _util.info)(`Invalid Gamma [${this.GR}, ${this.GG}, ${this.GB}] for ` + `${this.name}, falling back to default.`);
  11485. this.GR = this.GG = this.GB = 1;
  11486. }
  11487. }
  11488. getRgbItem(src, srcOffset, dest, destOffset) {
  11489. convertToRgb(this, src, srcOffset, dest, destOffset, 1);
  11490. }
  11491. getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  11492. const scale = 1 / ((1 << bits) - 1);
  11493. for (let i = 0; i < count; ++i) {
  11494. convertToRgb(this, src, srcOffset, dest, destOffset, scale);
  11495. srcOffset += 3;
  11496. destOffset += 3 + alpha01;
  11497. }
  11498. }
  11499. getOutputLength(inputLength, alpha01) {
  11500. return inputLength * (3 + alpha01) / 3 | 0;
  11501. }
  11502. }
  11503. return CalRGBCS;
  11504. }();
  11505. const LabCS = function LabCSClosure() {
  11506. function fn_g(x) {
  11507. return x >= 6 / 29 ? x ** 3 : 108 / 841 * (x - 4 / 29);
  11508. }
  11509. function decode(value, high1, low2, high2) {
  11510. return low2 + value * (high2 - low2) / high1;
  11511. }
  11512. function convertToRgb(cs, src, srcOffset, maxVal, dest, destOffset) {
  11513. let Ls = src[srcOffset];
  11514. let as = src[srcOffset + 1];
  11515. let bs = src[srcOffset + 2];
  11516. if (maxVal !== false) {
  11517. Ls = decode(Ls, maxVal, 0, 100);
  11518. as = decode(as, maxVal, cs.amin, cs.amax);
  11519. bs = decode(bs, maxVal, cs.bmin, cs.bmax);
  11520. }
  11521. if (as > cs.amax) {
  11522. as = cs.amax;
  11523. } else if (as < cs.amin) {
  11524. as = cs.amin;
  11525. }
  11526. if (bs > cs.bmax) {
  11527. bs = cs.bmax;
  11528. } else if (bs < cs.bmin) {
  11529. bs = cs.bmin;
  11530. }
  11531. const M = (Ls + 16) / 116;
  11532. const L = M + as / 500;
  11533. const N = M - bs / 200;
  11534. const X = cs.XW * fn_g(L);
  11535. const Y = cs.YW * fn_g(M);
  11536. const Z = cs.ZW * fn_g(N);
  11537. let r, g, b;
  11538. if (cs.ZW < 1) {
  11539. r = X * 3.1339 + Y * -1.617 + Z * -0.4906;
  11540. g = X * -0.9785 + Y * 1.916 + Z * 0.0333;
  11541. b = X * 0.072 + Y * -0.229 + Z * 1.4057;
  11542. } else {
  11543. r = X * 3.2406 + Y * -1.5372 + Z * -0.4986;
  11544. g = X * -0.9689 + Y * 1.8758 + Z * 0.0415;
  11545. b = X * 0.0557 + Y * -0.204 + Z * 1.057;
  11546. }
  11547. dest[destOffset] = Math.sqrt(r) * 255;
  11548. dest[destOffset + 1] = Math.sqrt(g) * 255;
  11549. dest[destOffset + 2] = Math.sqrt(b) * 255;
  11550. }
  11551. class LabCS extends ColorSpace {
  11552. constructor(whitePoint, blackPoint, range) {
  11553. super("Lab", 3);
  11554. if (!whitePoint) {
  11555. throw new _util.FormatError("WhitePoint missing - required for color space Lab");
  11556. }
  11557. blackPoint ||= [0, 0, 0];
  11558. range ||= [-100, 100, -100, 100];
  11559. this.XW = whitePoint[0];
  11560. this.YW = whitePoint[1];
  11561. this.ZW = whitePoint[2];
  11562. this.amin = range[0];
  11563. this.amax = range[1];
  11564. this.bmin = range[2];
  11565. this.bmax = range[3];
  11566. this.XB = blackPoint[0];
  11567. this.YB = blackPoint[1];
  11568. this.ZB = blackPoint[2];
  11569. if (this.XW < 0 || this.ZW < 0 || this.YW !== 1) {
  11570. throw new _util.FormatError("Invalid WhitePoint components, no fallback available");
  11571. }
  11572. if (this.XB < 0 || this.YB < 0 || this.ZB < 0) {
  11573. (0, _util.info)("Invalid BlackPoint, falling back to default");
  11574. this.XB = this.YB = this.ZB = 0;
  11575. }
  11576. if (this.amin > this.amax || this.bmin > this.bmax) {
  11577. (0, _util.info)("Invalid Range, falling back to defaults");
  11578. this.amin = -100;
  11579. this.amax = 100;
  11580. this.bmin = -100;
  11581. this.bmax = 100;
  11582. }
  11583. }
  11584. getRgbItem(src, srcOffset, dest, destOffset) {
  11585. convertToRgb(this, src, srcOffset, false, dest, destOffset);
  11586. }
  11587. getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  11588. const maxVal = (1 << bits) - 1;
  11589. for (let i = 0; i < count; i++) {
  11590. convertToRgb(this, src, srcOffset, maxVal, dest, destOffset);
  11591. srcOffset += 3;
  11592. destOffset += 3 + alpha01;
  11593. }
  11594. }
  11595. getOutputLength(inputLength, alpha01) {
  11596. return inputLength * (3 + alpha01) / 3 | 0;
  11597. }
  11598. isDefaultDecode(decodeMap, bpc) {
  11599. return true;
  11600. }
  11601. get usesZeroToOneRange() {
  11602. return (0, _util.shadow)(this, "usesZeroToOneRange", false);
  11603. }
  11604. }
  11605. return LabCS;
  11606. }();
  11607. /***/ }),
  11608. /* 164 */
  11609. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  11610. Object.defineProperty(exports, "__esModule", ({
  11611. value: true
  11612. }));
  11613. exports.PartialEvaluator = exports.EvaluatorPreprocessor = void 0;
  11614. __w_pdfjs_require__(140);
  11615. __w_pdfjs_require__(2);
  11616. __w_pdfjs_require__(84);
  11617. __w_pdfjs_require__(93);
  11618. __w_pdfjs_require__(94);
  11619. __w_pdfjs_require__(97);
  11620. __w_pdfjs_require__(99);
  11621. __w_pdfjs_require__(101);
  11622. __w_pdfjs_require__(105);
  11623. __w_pdfjs_require__(108);
  11624. __w_pdfjs_require__(115);
  11625. __w_pdfjs_require__(116);
  11626. __w_pdfjs_require__(127);
  11627. __w_pdfjs_require__(129);
  11628. __w_pdfjs_require__(132);
  11629. __w_pdfjs_require__(134);
  11630. __w_pdfjs_require__(136);
  11631. __w_pdfjs_require__(138);
  11632. __w_pdfjs_require__(158);
  11633. __w_pdfjs_require__(160);
  11634. var _util = __w_pdfjs_require__(145);
  11635. var _cmap = __w_pdfjs_require__(165);
  11636. var _primitives = __w_pdfjs_require__(151);
  11637. var _fonts = __w_pdfjs_require__(185);
  11638. var _encodings = __w_pdfjs_require__(188);
  11639. var _standard_fonts = __w_pdfjs_require__(192);
  11640. var _pattern = __w_pdfjs_require__(201);
  11641. var _xfa_fonts = __w_pdfjs_require__(202);
  11642. var _to_unicode_map = __w_pdfjs_require__(193);
  11643. var _function = __w_pdfjs_require__(208);
  11644. var _parser = __w_pdfjs_require__(167);
  11645. var _image_utils = __w_pdfjs_require__(210);
  11646. var _stream = __w_pdfjs_require__(155);
  11647. var _base_stream = __w_pdfjs_require__(152);
  11648. var _bidi = __w_pdfjs_require__(211);
  11649. var _colorspace = __w_pdfjs_require__(163);
  11650. var _decode_stream = __w_pdfjs_require__(169);
  11651. var _fonts_utils = __w_pdfjs_require__(189);
  11652. var _font_substitutions = __w_pdfjs_require__(212);
  11653. var _glyphlist = __w_pdfjs_require__(190);
  11654. var _core_utils = __w_pdfjs_require__(150);
  11655. var _metrics = __w_pdfjs_require__(196);
  11656. var _unicode = __w_pdfjs_require__(191);
  11657. var _image_resizer = __w_pdfjs_require__(213);
  11658. var _murmurhash = __w_pdfjs_require__(214);
  11659. var _operator_list = __w_pdfjs_require__(215);
  11660. var _image = __w_pdfjs_require__(216);
  11661. const DefaultPartialEvaluatorOptions = Object.freeze({
  11662. maxImageSize: -1,
  11663. disableFontFace: false,
  11664. ignoreErrors: false,
  11665. isEvalSupported: true,
  11666. isOffscreenCanvasSupported: false,
  11667. canvasMaxAreaInBytes: -1,
  11668. fontExtraProperties: false,
  11669. useSystemFonts: true,
  11670. cMapUrl: null,
  11671. standardFontDataUrl: null
  11672. });
  11673. const PatternType = {
  11674. TILING: 1,
  11675. SHADING: 2
  11676. };
  11677. const TEXT_CHUNK_BATCH_SIZE = 10;
  11678. const deferred = Promise.resolve();
  11679. function normalizeBlendMode(value) {
  11680. let parsingArray = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  11681. if (Array.isArray(value)) {
  11682. for (const val of value) {
  11683. const maybeBM = normalizeBlendMode(val, true);
  11684. if (maybeBM) {
  11685. return maybeBM;
  11686. }
  11687. }
  11688. (0, _util.warn)(`Unsupported blend mode Array: ${value}`);
  11689. return "source-over";
  11690. }
  11691. if (!(value instanceof _primitives.Name)) {
  11692. if (parsingArray) {
  11693. return null;
  11694. }
  11695. return "source-over";
  11696. }
  11697. switch (value.name) {
  11698. case "Normal":
  11699. case "Compatible":
  11700. return "source-over";
  11701. case "Multiply":
  11702. return "multiply";
  11703. case "Screen":
  11704. return "screen";
  11705. case "Overlay":
  11706. return "overlay";
  11707. case "Darken":
  11708. return "darken";
  11709. case "Lighten":
  11710. return "lighten";
  11711. case "ColorDodge":
  11712. return "color-dodge";
  11713. case "ColorBurn":
  11714. return "color-burn";
  11715. case "HardLight":
  11716. return "hard-light";
  11717. case "SoftLight":
  11718. return "soft-light";
  11719. case "Difference":
  11720. return "difference";
  11721. case "Exclusion":
  11722. return "exclusion";
  11723. case "Hue":
  11724. return "hue";
  11725. case "Saturation":
  11726. return "saturation";
  11727. case "Color":
  11728. return "color";
  11729. case "Luminosity":
  11730. return "luminosity";
  11731. }
  11732. if (parsingArray) {
  11733. return null;
  11734. }
  11735. (0, _util.warn)(`Unsupported blend mode: ${value.name}`);
  11736. return "source-over";
  11737. }
  11738. function incrementCachedImageMaskCount(data) {
  11739. if (data.fn === _util.OPS.paintImageMaskXObject && data.args[0]?.count > 0) {
  11740. data.args[0].count++;
  11741. }
  11742. }
  11743. class TimeSlotManager {
  11744. static TIME_SLOT_DURATION_MS = 20;
  11745. static CHECK_TIME_EVERY = 100;
  11746. constructor() {
  11747. this.reset();
  11748. }
  11749. check() {
  11750. if (++this.checked < TimeSlotManager.CHECK_TIME_EVERY) {
  11751. return false;
  11752. }
  11753. this.checked = 0;
  11754. return this.endTime <= Date.now();
  11755. }
  11756. reset() {
  11757. this.endTime = Date.now() + TimeSlotManager.TIME_SLOT_DURATION_MS;
  11758. this.checked = 0;
  11759. }
  11760. }
  11761. class PartialEvaluator {
  11762. constructor(_ref) {
  11763. let {
  11764. xref,
  11765. handler,
  11766. pageIndex,
  11767. idFactory,
  11768. fontCache,
  11769. builtInCMapCache,
  11770. standardFontDataCache,
  11771. globalImageCache,
  11772. systemFontCache,
  11773. options = null
  11774. } = _ref;
  11775. this.xref = xref;
  11776. this.handler = handler;
  11777. this.pageIndex = pageIndex;
  11778. this.idFactory = idFactory;
  11779. this.fontCache = fontCache;
  11780. this.builtInCMapCache = builtInCMapCache;
  11781. this.standardFontDataCache = standardFontDataCache;
  11782. this.globalImageCache = globalImageCache;
  11783. this.systemFontCache = systemFontCache;
  11784. this.options = options || DefaultPartialEvaluatorOptions;
  11785. this.parsingType3Font = false;
  11786. this._regionalImageCache = new _image_utils.RegionalImageCache();
  11787. this._fetchBuiltInCMapBound = this.fetchBuiltInCMap.bind(this);
  11788. _image_resizer.ImageResizer.setMaxArea(this.options.canvasMaxAreaInBytes);
  11789. }
  11790. get _pdfFunctionFactory() {
  11791. const pdfFunctionFactory = new _function.PDFFunctionFactory({
  11792. xref: this.xref,
  11793. isEvalSupported: this.options.isEvalSupported
  11794. });
  11795. return (0, _util.shadow)(this, "_pdfFunctionFactory", pdfFunctionFactory);
  11796. }
  11797. clone() {
  11798. let newOptions = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
  11799. const newEvaluator = Object.create(this);
  11800. newEvaluator.options = Object.assign(Object.create(null), this.options, newOptions);
  11801. return newEvaluator;
  11802. }
  11803. hasBlendModes(resources, nonBlendModesSet) {
  11804. if (!(resources instanceof _primitives.Dict)) {
  11805. return false;
  11806. }
  11807. if (resources.objId && nonBlendModesSet.has(resources.objId)) {
  11808. return false;
  11809. }
  11810. const processed = new _primitives.RefSet(nonBlendModesSet);
  11811. if (resources.objId) {
  11812. processed.put(resources.objId);
  11813. }
  11814. const nodes = [resources],
  11815. xref = this.xref;
  11816. while (nodes.length) {
  11817. const node = nodes.shift();
  11818. const graphicStates = node.get("ExtGState");
  11819. if (graphicStates instanceof _primitives.Dict) {
  11820. for (let graphicState of graphicStates.getRawValues()) {
  11821. if (graphicState instanceof _primitives.Ref) {
  11822. if (processed.has(graphicState)) {
  11823. continue;
  11824. }
  11825. try {
  11826. graphicState = xref.fetch(graphicState);
  11827. } catch (ex) {
  11828. processed.put(graphicState);
  11829. (0, _util.info)(`hasBlendModes - ignoring ExtGState: "${ex}".`);
  11830. continue;
  11831. }
  11832. }
  11833. if (!(graphicState instanceof _primitives.Dict)) {
  11834. continue;
  11835. }
  11836. if (graphicState.objId) {
  11837. processed.put(graphicState.objId);
  11838. }
  11839. const bm = graphicState.get("BM");
  11840. if (bm instanceof _primitives.Name) {
  11841. if (bm.name !== "Normal") {
  11842. return true;
  11843. }
  11844. continue;
  11845. }
  11846. if (bm !== undefined && Array.isArray(bm)) {
  11847. for (const element of bm) {
  11848. if (element instanceof _primitives.Name && element.name !== "Normal") {
  11849. return true;
  11850. }
  11851. }
  11852. }
  11853. }
  11854. }
  11855. const xObjects = node.get("XObject");
  11856. if (!(xObjects instanceof _primitives.Dict)) {
  11857. continue;
  11858. }
  11859. for (let xObject of xObjects.getRawValues()) {
  11860. if (xObject instanceof _primitives.Ref) {
  11861. if (processed.has(xObject)) {
  11862. continue;
  11863. }
  11864. try {
  11865. xObject = xref.fetch(xObject);
  11866. } catch (ex) {
  11867. processed.put(xObject);
  11868. (0, _util.info)(`hasBlendModes - ignoring XObject: "${ex}".`);
  11869. continue;
  11870. }
  11871. }
  11872. if (!(xObject instanceof _base_stream.BaseStream)) {
  11873. continue;
  11874. }
  11875. if (xObject.dict.objId) {
  11876. processed.put(xObject.dict.objId);
  11877. }
  11878. const xResources = xObject.dict.get("Resources");
  11879. if (!(xResources instanceof _primitives.Dict)) {
  11880. continue;
  11881. }
  11882. if (xResources.objId && processed.has(xResources.objId)) {
  11883. continue;
  11884. }
  11885. nodes.push(xResources);
  11886. if (xResources.objId) {
  11887. processed.put(xResources.objId);
  11888. }
  11889. }
  11890. }
  11891. for (const ref of processed) {
  11892. nonBlendModesSet.put(ref);
  11893. }
  11894. return false;
  11895. }
  11896. async fetchBuiltInCMap(name) {
  11897. const cachedData = this.builtInCMapCache.get(name);
  11898. if (cachedData) {
  11899. return cachedData;
  11900. }
  11901. let data;
  11902. if (this.options.cMapUrl !== null) {
  11903. const url = `${this.options.cMapUrl}${name}.bcmap`;
  11904. const response = await fetch(url);
  11905. if (!response.ok) {
  11906. throw new Error(`fetchBuiltInCMap: failed to fetch file "${url}" with "${response.statusText}".`);
  11907. }
  11908. data = {
  11909. cMapData: new Uint8Array(await response.arrayBuffer()),
  11910. compressionType: _util.CMapCompressionType.BINARY
  11911. };
  11912. } else {
  11913. data = await this.handler.sendWithPromise("FetchBuiltInCMap", {
  11914. name
  11915. });
  11916. }
  11917. if (data.compressionType !== _util.CMapCompressionType.NONE) {
  11918. this.builtInCMapCache.set(name, data);
  11919. }
  11920. return data;
  11921. }
  11922. async fetchStandardFontData(name) {
  11923. const cachedData = this.standardFontDataCache.get(name);
  11924. if (cachedData) {
  11925. return new _stream.Stream(cachedData);
  11926. }
  11927. if (this.options.useSystemFonts && name !== "Symbol" && name !== "ZapfDingbats") {
  11928. return null;
  11929. }
  11930. const standardFontNameToFileName = (0, _standard_fonts.getFontNameToFileMap)(),
  11931. filename = standardFontNameToFileName[name];
  11932. let data;
  11933. if (this.options.standardFontDataUrl !== null) {
  11934. const url = `${this.options.standardFontDataUrl}${filename}`;
  11935. const response = await fetch(url);
  11936. if (!response.ok) {
  11937. (0, _util.warn)(`fetchStandardFontData: failed to fetch file "${url}" with "${response.statusText}".`);
  11938. } else {
  11939. data = await response.arrayBuffer();
  11940. }
  11941. } else {
  11942. try {
  11943. data = await this.handler.sendWithPromise("FetchStandardFontData", {
  11944. filename
  11945. });
  11946. } catch (e) {
  11947. (0, _util.warn)(`fetchStandardFontData: failed to fetch file "${filename}" with "${e}".`);
  11948. }
  11949. }
  11950. if (!data) {
  11951. return null;
  11952. }
  11953. this.standardFontDataCache.set(name, data);
  11954. return new _stream.Stream(data);
  11955. }
  11956. async buildFormXObject(resources, xobj, smask, operatorList, task, initialState, localColorSpaceCache) {
  11957. const dict = xobj.dict;
  11958. const matrix = dict.getArray("Matrix");
  11959. let bbox = dict.getArray("BBox");
  11960. bbox = Array.isArray(bbox) && bbox.length === 4 ? _util.Util.normalizeRect(bbox) : null;
  11961. let optionalContent, groupOptions;
  11962. if (dict.has("OC")) {
  11963. optionalContent = await this.parseMarkedContentProps(dict.get("OC"), resources);
  11964. }
  11965. if (optionalContent !== undefined) {
  11966. operatorList.addOp(_util.OPS.beginMarkedContentProps, ["OC", optionalContent]);
  11967. }
  11968. const group = dict.get("Group");
  11969. if (group) {
  11970. groupOptions = {
  11971. matrix,
  11972. bbox,
  11973. smask,
  11974. isolated: false,
  11975. knockout: false
  11976. };
  11977. const groupSubtype = group.get("S");
  11978. let colorSpace = null;
  11979. if ((0, _primitives.isName)(groupSubtype, "Transparency")) {
  11980. groupOptions.isolated = group.get("I") || false;
  11981. groupOptions.knockout = group.get("K") || false;
  11982. if (group.has("CS")) {
  11983. const cs = group.getRaw("CS");
  11984. const cachedColorSpace = _colorspace.ColorSpace.getCached(cs, this.xref, localColorSpaceCache);
  11985. if (cachedColorSpace) {
  11986. colorSpace = cachedColorSpace;
  11987. } else {
  11988. colorSpace = await this.parseColorSpace({
  11989. cs,
  11990. resources,
  11991. localColorSpaceCache
  11992. });
  11993. }
  11994. }
  11995. }
  11996. if (smask?.backdrop) {
  11997. colorSpace ||= _colorspace.ColorSpace.singletons.rgb;
  11998. smask.backdrop = colorSpace.getRgb(smask.backdrop, 0);
  11999. }
  12000. operatorList.addOp(_util.OPS.beginGroup, [groupOptions]);
  12001. }
  12002. const args = group ? [matrix, null] : [matrix, bbox];
  12003. operatorList.addOp(_util.OPS.paintFormXObjectBegin, args);
  12004. return this.getOperatorList({
  12005. stream: xobj,
  12006. task,
  12007. resources: dict.get("Resources") || resources,
  12008. operatorList,
  12009. initialState
  12010. }).then(function () {
  12011. operatorList.addOp(_util.OPS.paintFormXObjectEnd, []);
  12012. if (group) {
  12013. operatorList.addOp(_util.OPS.endGroup, [groupOptions]);
  12014. }
  12015. if (optionalContent !== undefined) {
  12016. operatorList.addOp(_util.OPS.endMarkedContent, []);
  12017. }
  12018. });
  12019. }
  12020. _sendImgData(objId, imgData) {
  12021. let cacheGlobally = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  12022. const transfers = imgData ? [imgData.bitmap || imgData.data.buffer] : null;
  12023. if (this.parsingType3Font || cacheGlobally) {
  12024. return this.handler.send("commonobj", [objId, "Image", imgData], transfers);
  12025. }
  12026. return this.handler.send("obj", [objId, this.pageIndex, "Image", imgData], transfers);
  12027. }
  12028. async buildPaintImageXObject(_ref2) {
  12029. let {
  12030. resources,
  12031. image,
  12032. isInline = false,
  12033. operatorList,
  12034. cacheKey,
  12035. localImageCache,
  12036. localColorSpaceCache
  12037. } = _ref2;
  12038. const dict = image.dict;
  12039. const imageRef = dict.objId;
  12040. const w = dict.get("W", "Width");
  12041. const h = dict.get("H", "Height");
  12042. if (!(w && typeof w === "number") || !(h && typeof h === "number")) {
  12043. (0, _util.warn)("Image dimensions are missing, or not numbers.");
  12044. return;
  12045. }
  12046. const maxImageSize = this.options.maxImageSize;
  12047. if (maxImageSize !== -1 && w * h > maxImageSize) {
  12048. const msg = "Image exceeded maximum allowed size and was removed.";
  12049. if (this.options.ignoreErrors) {
  12050. (0, _util.warn)(msg);
  12051. return;
  12052. }
  12053. throw new Error(msg);
  12054. }
  12055. let optionalContent;
  12056. if (dict.has("OC")) {
  12057. optionalContent = await this.parseMarkedContentProps(dict.get("OC"), resources);
  12058. }
  12059. const imageMask = dict.get("IM", "ImageMask") || false;
  12060. let imgData, args;
  12061. if (imageMask) {
  12062. const interpolate = dict.get("I", "Interpolate");
  12063. const bitStrideLength = w + 7 >> 3;
  12064. const imgArray = image.getBytes(bitStrideLength * h);
  12065. const decode = dict.getArray("D", "Decode");
  12066. if (this.parsingType3Font) {
  12067. imgData = _image.PDFImage.createRawMask({
  12068. imgArray,
  12069. width: w,
  12070. height: h,
  12071. imageIsFromDecodeStream: image instanceof _decode_stream.DecodeStream,
  12072. inverseDecode: decode?.[0] > 0,
  12073. interpolate
  12074. });
  12075. imgData.cached = !!cacheKey;
  12076. args = [imgData];
  12077. operatorList.addImageOps(_util.OPS.paintImageMaskXObject, args, optionalContent);
  12078. if (cacheKey) {
  12079. const cacheData = {
  12080. fn: _util.OPS.paintImageMaskXObject,
  12081. args,
  12082. optionalContent
  12083. };
  12084. localImageCache.set(cacheKey, imageRef, cacheData);
  12085. if (imageRef) {
  12086. this._regionalImageCache.set(null, imageRef, cacheData);
  12087. }
  12088. }
  12089. return;
  12090. }
  12091. imgData = await _image.PDFImage.createMask({
  12092. imgArray,
  12093. width: w,
  12094. height: h,
  12095. imageIsFromDecodeStream: image instanceof _decode_stream.DecodeStream,
  12096. inverseDecode: decode?.[0] > 0,
  12097. interpolate,
  12098. isOffscreenCanvasSupported: this.options.isOffscreenCanvasSupported
  12099. });
  12100. if (imgData.isSingleOpaquePixel) {
  12101. operatorList.addImageOps(_util.OPS.paintSolidColorImageMask, [], optionalContent);
  12102. if (cacheKey) {
  12103. const cacheData = {
  12104. fn: _util.OPS.paintSolidColorImageMask,
  12105. args: [],
  12106. optionalContent
  12107. };
  12108. localImageCache.set(cacheKey, imageRef, cacheData);
  12109. if (imageRef) {
  12110. this._regionalImageCache.set(null, imageRef, cacheData);
  12111. }
  12112. }
  12113. return;
  12114. }
  12115. const objId = `mask_${this.idFactory.createObjId()}`;
  12116. operatorList.addDependency(objId);
  12117. this._sendImgData(objId, imgData);
  12118. args = [{
  12119. data: objId,
  12120. width: imgData.width,
  12121. height: imgData.height,
  12122. interpolate: imgData.interpolate,
  12123. count: 1
  12124. }];
  12125. operatorList.addImageOps(_util.OPS.paintImageMaskXObject, args, optionalContent);
  12126. if (cacheKey) {
  12127. const cacheData = {
  12128. fn: _util.OPS.paintImageMaskXObject,
  12129. args,
  12130. optionalContent
  12131. };
  12132. localImageCache.set(cacheKey, imageRef, cacheData);
  12133. if (imageRef) {
  12134. this._regionalImageCache.set(null, imageRef, cacheData);
  12135. }
  12136. }
  12137. return;
  12138. }
  12139. const SMALL_IMAGE_DIMENSIONS = 200;
  12140. if (isInline && !dict.has("SMask") && !dict.has("Mask") && w + h < SMALL_IMAGE_DIMENSIONS) {
  12141. const imageObj = new _image.PDFImage({
  12142. xref: this.xref,
  12143. res: resources,
  12144. image,
  12145. isInline,
  12146. pdfFunctionFactory: this._pdfFunctionFactory,
  12147. localColorSpaceCache
  12148. });
  12149. imgData = await imageObj.createImageData(true, false);
  12150. operatorList.isOffscreenCanvasSupported = this.options.isOffscreenCanvasSupported;
  12151. operatorList.addImageOps(_util.OPS.paintInlineImageXObject, [imgData], optionalContent);
  12152. return;
  12153. }
  12154. let objId = `img_${this.idFactory.createObjId()}`,
  12155. cacheGlobally = false;
  12156. if (this.parsingType3Font) {
  12157. objId = `${this.idFactory.getDocId()}_type3_${objId}`;
  12158. } else if (imageRef) {
  12159. cacheGlobally = this.globalImageCache.shouldCache(imageRef, this.pageIndex);
  12160. if (cacheGlobally) {
  12161. objId = `${this.idFactory.getDocId()}_${objId}`;
  12162. }
  12163. }
  12164. operatorList.addDependency(objId);
  12165. args = [objId, w, h];
  12166. _image.PDFImage.buildImage({
  12167. xref: this.xref,
  12168. res: resources,
  12169. image,
  12170. isInline,
  12171. pdfFunctionFactory: this._pdfFunctionFactory,
  12172. localColorSpaceCache
  12173. }).then(async imageObj => {
  12174. imgData = await imageObj.createImageData(false, this.options.isOffscreenCanvasSupported);
  12175. if (cacheKey && imageRef && cacheGlobally) {
  12176. const length = imgData.bitmap ? imgData.width * imgData.height * 4 : imgData.data.length;
  12177. this.globalImageCache.addByteSize(imageRef, length);
  12178. }
  12179. return this._sendImgData(objId, imgData, cacheGlobally);
  12180. }).catch(reason => {
  12181. (0, _util.warn)(`Unable to decode image "${objId}": "${reason}".`);
  12182. return this._sendImgData(objId, null, cacheGlobally);
  12183. });
  12184. operatorList.addImageOps(_util.OPS.paintImageXObject, args, optionalContent);
  12185. if (cacheKey) {
  12186. const cacheData = {
  12187. fn: _util.OPS.paintImageXObject,
  12188. args,
  12189. optionalContent
  12190. };
  12191. localImageCache.set(cacheKey, imageRef, cacheData);
  12192. if (imageRef) {
  12193. this._regionalImageCache.set(null, imageRef, cacheData);
  12194. if (cacheGlobally) {
  12195. (0, _util.assert)(!isInline, "Cannot cache an inline image globally.");
  12196. this.globalImageCache.setData(imageRef, {
  12197. objId,
  12198. fn: _util.OPS.paintImageXObject,
  12199. args,
  12200. optionalContent,
  12201. byteSize: 0
  12202. });
  12203. }
  12204. }
  12205. }
  12206. }
  12207. handleSMask(smask, resources, operatorList, task, stateManager, localColorSpaceCache) {
  12208. const smaskContent = smask.get("G");
  12209. const smaskOptions = {
  12210. subtype: smask.get("S").name,
  12211. backdrop: smask.get("BC")
  12212. };
  12213. const transferObj = smask.get("TR");
  12214. if ((0, _function.isPDFFunction)(transferObj)) {
  12215. const transferFn = this._pdfFunctionFactory.create(transferObj);
  12216. const transferMap = new Uint8Array(256);
  12217. const tmp = new Float32Array(1);
  12218. for (let i = 0; i < 256; i++) {
  12219. tmp[0] = i / 255;
  12220. transferFn(tmp, 0, tmp, 0);
  12221. transferMap[i] = tmp[0] * 255 | 0;
  12222. }
  12223. smaskOptions.transferMap = transferMap;
  12224. }
  12225. return this.buildFormXObject(resources, smaskContent, smaskOptions, operatorList, task, stateManager.state.clone(), localColorSpaceCache);
  12226. }
  12227. handleTransferFunction(tr) {
  12228. let transferArray;
  12229. if (Array.isArray(tr)) {
  12230. transferArray = tr;
  12231. } else if ((0, _function.isPDFFunction)(tr)) {
  12232. transferArray = [tr];
  12233. } else {
  12234. return null;
  12235. }
  12236. const transferMaps = [];
  12237. let numFns = 0,
  12238. numEffectfulFns = 0;
  12239. for (const entry of transferArray) {
  12240. const transferObj = this.xref.fetchIfRef(entry);
  12241. numFns++;
  12242. if ((0, _primitives.isName)(transferObj, "Identity")) {
  12243. transferMaps.push(null);
  12244. continue;
  12245. } else if (!(0, _function.isPDFFunction)(transferObj)) {
  12246. return null;
  12247. }
  12248. const transferFn = this._pdfFunctionFactory.create(transferObj);
  12249. const transferMap = new Uint8Array(256),
  12250. tmp = new Float32Array(1);
  12251. for (let j = 0; j < 256; j++) {
  12252. tmp[0] = j / 255;
  12253. transferFn(tmp, 0, tmp, 0);
  12254. transferMap[j] = tmp[0] * 255 | 0;
  12255. }
  12256. transferMaps.push(transferMap);
  12257. numEffectfulFns++;
  12258. }
  12259. if (!(numFns === 1 || numFns === 4)) {
  12260. return null;
  12261. }
  12262. if (numEffectfulFns === 0) {
  12263. return null;
  12264. }
  12265. return transferMaps;
  12266. }
  12267. handleTilingType(fn, color, resources, pattern, patternDict, operatorList, task, localTilingPatternCache) {
  12268. const tilingOpList = new _operator_list.OperatorList();
  12269. const patternResources = _primitives.Dict.merge({
  12270. xref: this.xref,
  12271. dictArray: [patternDict.get("Resources"), resources]
  12272. });
  12273. return this.getOperatorList({
  12274. stream: pattern,
  12275. task,
  12276. resources: patternResources,
  12277. operatorList: tilingOpList
  12278. }).then(function () {
  12279. const operatorListIR = tilingOpList.getIR();
  12280. const tilingPatternIR = (0, _pattern.getTilingPatternIR)(operatorListIR, patternDict, color);
  12281. operatorList.addDependencies(tilingOpList.dependencies);
  12282. operatorList.addOp(fn, tilingPatternIR);
  12283. if (patternDict.objId) {
  12284. localTilingPatternCache.set(null, patternDict.objId, {
  12285. operatorListIR,
  12286. dict: patternDict
  12287. });
  12288. }
  12289. }).catch(reason => {
  12290. if (reason instanceof _util.AbortException) {
  12291. return;
  12292. }
  12293. if (this.options.ignoreErrors) {
  12294. (0, _util.warn)(`handleTilingType - ignoring pattern: "${reason}".`);
  12295. return;
  12296. }
  12297. throw reason;
  12298. });
  12299. }
  12300. handleSetFont(resources, fontArgs, fontRef, operatorList, task, state) {
  12301. let fallbackFontDict = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : null;
  12302. let cssFontInfo = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : null;
  12303. const fontName = fontArgs?.[0] instanceof _primitives.Name ? fontArgs[0].name : null;
  12304. return this.loadFont(fontName, fontRef, resources, fallbackFontDict, cssFontInfo).then(translated => {
  12305. if (!translated.font.isType3Font) {
  12306. return translated;
  12307. }
  12308. return translated.loadType3Data(this, resources, task).then(function () {
  12309. operatorList.addDependencies(translated.type3Dependencies);
  12310. return translated;
  12311. }).catch(reason => {
  12312. return new TranslatedFont({
  12313. loadedName: "g_font_error",
  12314. font: new _fonts.ErrorFont(`Type3 font load error: ${reason}`),
  12315. dict: translated.font,
  12316. evaluatorOptions: this.options
  12317. });
  12318. });
  12319. }).then(translated => {
  12320. state.font = translated.font;
  12321. translated.send(this.handler);
  12322. return translated.loadedName;
  12323. });
  12324. }
  12325. handleText(chars, state) {
  12326. const font = state.font;
  12327. const glyphs = font.charsToGlyphs(chars);
  12328. if (font.data) {
  12329. const isAddToPathSet = !!(state.textRenderingMode & _util.TextRenderingMode.ADD_TO_PATH_FLAG);
  12330. if (isAddToPathSet || state.fillColorSpace.name === "Pattern" || font.disableFontFace || this.options.disableFontFace) {
  12331. PartialEvaluator.buildFontPaths(font, glyphs, this.handler, this.options);
  12332. }
  12333. }
  12334. return glyphs;
  12335. }
  12336. ensureStateFont(state) {
  12337. if (state.font) {
  12338. return;
  12339. }
  12340. const reason = new _util.FormatError("Missing setFont (Tf) operator before text rendering operator.");
  12341. if (this.options.ignoreErrors) {
  12342. (0, _util.warn)(`ensureStateFont: "${reason}".`);
  12343. return;
  12344. }
  12345. throw reason;
  12346. }
  12347. async setGState(_ref3) {
  12348. let {
  12349. resources,
  12350. gState,
  12351. operatorList,
  12352. cacheKey,
  12353. task,
  12354. stateManager,
  12355. localGStateCache,
  12356. localColorSpaceCache
  12357. } = _ref3;
  12358. const gStateRef = gState.objId;
  12359. let isSimpleGState = true;
  12360. const gStateObj = [];
  12361. let promise = Promise.resolve();
  12362. for (const key of gState.getKeys()) {
  12363. const value = gState.get(key);
  12364. switch (key) {
  12365. case "Type":
  12366. break;
  12367. case "LW":
  12368. case "LC":
  12369. case "LJ":
  12370. case "ML":
  12371. case "D":
  12372. case "RI":
  12373. case "FL":
  12374. case "CA":
  12375. case "ca":
  12376. gStateObj.push([key, value]);
  12377. break;
  12378. case "Font":
  12379. isSimpleGState = false;
  12380. promise = promise.then(() => {
  12381. return this.handleSetFont(resources, null, value[0], operatorList, task, stateManager.state).then(function (loadedName) {
  12382. operatorList.addDependency(loadedName);
  12383. gStateObj.push([key, [loadedName, value[1]]]);
  12384. });
  12385. });
  12386. break;
  12387. case "BM":
  12388. gStateObj.push([key, normalizeBlendMode(value)]);
  12389. break;
  12390. case "SMask":
  12391. if ((0, _primitives.isName)(value, "None")) {
  12392. gStateObj.push([key, false]);
  12393. break;
  12394. }
  12395. if (value instanceof _primitives.Dict) {
  12396. isSimpleGState = false;
  12397. promise = promise.then(() => {
  12398. return this.handleSMask(value, resources, operatorList, task, stateManager, localColorSpaceCache);
  12399. });
  12400. gStateObj.push([key, true]);
  12401. } else {
  12402. (0, _util.warn)("Unsupported SMask type");
  12403. }
  12404. break;
  12405. case "TR":
  12406. const transferMaps = this.handleTransferFunction(value);
  12407. gStateObj.push([key, transferMaps]);
  12408. break;
  12409. case "OP":
  12410. case "op":
  12411. case "OPM":
  12412. case "BG":
  12413. case "BG2":
  12414. case "UCR":
  12415. case "UCR2":
  12416. case "TR2":
  12417. case "HT":
  12418. case "SM":
  12419. case "SA":
  12420. case "AIS":
  12421. case "TK":
  12422. (0, _util.info)("graphic state operator " + key);
  12423. break;
  12424. default:
  12425. (0, _util.info)("Unknown graphic state operator " + key);
  12426. break;
  12427. }
  12428. }
  12429. return promise.then(function () {
  12430. if (gStateObj.length > 0) {
  12431. operatorList.addOp(_util.OPS.setGState, [gStateObj]);
  12432. }
  12433. if (isSimpleGState) {
  12434. localGStateCache.set(cacheKey, gStateRef, gStateObj);
  12435. }
  12436. });
  12437. }
  12438. loadFont(fontName, font, resources) {
  12439. let fallbackFontDict = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
  12440. let cssFontInfo = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : null;
  12441. const errorFont = async () => {
  12442. return new TranslatedFont({
  12443. loadedName: "g_font_error",
  12444. font: new _fonts.ErrorFont(`Font "${fontName}" is not available.`),
  12445. dict: font,
  12446. evaluatorOptions: this.options
  12447. });
  12448. };
  12449. let fontRef;
  12450. if (font) {
  12451. if (font instanceof _primitives.Ref) {
  12452. fontRef = font;
  12453. }
  12454. } else {
  12455. const fontRes = resources.get("Font");
  12456. if (fontRes) {
  12457. fontRef = fontRes.getRaw(fontName);
  12458. }
  12459. }
  12460. if (fontRef) {
  12461. if (this.parsingType3Font && this.type3FontRefs.has(fontRef)) {
  12462. return errorFont();
  12463. }
  12464. if (this.fontCache.has(fontRef)) {
  12465. return this.fontCache.get(fontRef);
  12466. }
  12467. font = this.xref.fetchIfRef(fontRef);
  12468. }
  12469. if (!(font instanceof _primitives.Dict)) {
  12470. if (!this.options.ignoreErrors && !this.parsingType3Font) {
  12471. (0, _util.warn)(`Font "${fontName}" is not available.`);
  12472. return errorFont();
  12473. }
  12474. (0, _util.warn)(`Font "${fontName}" is not available -- attempting to fallback to a default font.`);
  12475. font = fallbackFontDict || PartialEvaluator.fallbackFontDict;
  12476. }
  12477. if (font.cacheKey && this.fontCache.has(font.cacheKey)) {
  12478. return this.fontCache.get(font.cacheKey);
  12479. }
  12480. const fontCapability = new _util.PromiseCapability();
  12481. let preEvaluatedFont;
  12482. try {
  12483. preEvaluatedFont = this.preEvaluateFont(font);
  12484. preEvaluatedFont.cssFontInfo = cssFontInfo;
  12485. } catch (reason) {
  12486. (0, _util.warn)(`loadFont - preEvaluateFont failed: "${reason}".`);
  12487. return errorFont();
  12488. }
  12489. const {
  12490. descriptor,
  12491. hash
  12492. } = preEvaluatedFont;
  12493. const fontRefIsRef = fontRef instanceof _primitives.Ref;
  12494. let fontID;
  12495. if (hash && descriptor instanceof _primitives.Dict) {
  12496. const fontAliases = descriptor.fontAliases ||= Object.create(null);
  12497. if (fontAliases[hash]) {
  12498. const aliasFontRef = fontAliases[hash].aliasRef;
  12499. if (fontRefIsRef && aliasFontRef && this.fontCache.has(aliasFontRef)) {
  12500. this.fontCache.putAlias(fontRef, aliasFontRef);
  12501. return this.fontCache.get(fontRef);
  12502. }
  12503. } else {
  12504. fontAliases[hash] = {
  12505. fontID: this.idFactory.createFontId()
  12506. };
  12507. }
  12508. if (fontRefIsRef) {
  12509. fontAliases[hash].aliasRef = fontRef;
  12510. }
  12511. fontID = fontAliases[hash].fontID;
  12512. } else {
  12513. fontID = this.idFactory.createFontId();
  12514. }
  12515. (0, _util.assert)(fontID?.startsWith("f"), 'The "fontID" must be (correctly) defined.');
  12516. if (fontRefIsRef) {
  12517. this.fontCache.put(fontRef, fontCapability.promise);
  12518. } else {
  12519. font.cacheKey = `cacheKey_${fontID}`;
  12520. this.fontCache.put(font.cacheKey, fontCapability.promise);
  12521. }
  12522. font.loadedName = `${this.idFactory.getDocId()}_${fontID}`;
  12523. this.translateFont(preEvaluatedFont).then(translatedFont => {
  12524. fontCapability.resolve(new TranslatedFont({
  12525. loadedName: font.loadedName,
  12526. font: translatedFont,
  12527. dict: font,
  12528. evaluatorOptions: this.options
  12529. }));
  12530. }).catch(reason => {
  12531. (0, _util.warn)(`loadFont - translateFont failed: "${reason}".`);
  12532. fontCapability.resolve(new TranslatedFont({
  12533. loadedName: font.loadedName,
  12534. font: new _fonts.ErrorFont(reason instanceof Error ? reason.message : reason),
  12535. dict: font,
  12536. evaluatorOptions: this.options
  12537. }));
  12538. });
  12539. return fontCapability.promise;
  12540. }
  12541. buildPath(operatorList, fn, args) {
  12542. let parsingText = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
  12543. const lastIndex = operatorList.length - 1;
  12544. if (!args) {
  12545. args = [];
  12546. }
  12547. if (lastIndex < 0 || operatorList.fnArray[lastIndex] !== _util.OPS.constructPath) {
  12548. if (parsingText) {
  12549. (0, _util.warn)(`Encountered path operator "${fn}" inside of a text object.`);
  12550. operatorList.addOp(_util.OPS.save, null);
  12551. }
  12552. let minMax;
  12553. switch (fn) {
  12554. case _util.OPS.rectangle:
  12555. const x = args[0] + args[2];
  12556. const y = args[1] + args[3];
  12557. minMax = [Math.min(args[0], x), Math.max(args[0], x), Math.min(args[1], y), Math.max(args[1], y)];
  12558. break;
  12559. case _util.OPS.moveTo:
  12560. case _util.OPS.lineTo:
  12561. minMax = [args[0], args[0], args[1], args[1]];
  12562. break;
  12563. default:
  12564. minMax = [Infinity, -Infinity, Infinity, -Infinity];
  12565. break;
  12566. }
  12567. operatorList.addOp(_util.OPS.constructPath, [[fn], args, minMax]);
  12568. if (parsingText) {
  12569. operatorList.addOp(_util.OPS.restore, null);
  12570. }
  12571. } else {
  12572. const opArgs = operatorList.argsArray[lastIndex];
  12573. opArgs[0].push(fn);
  12574. opArgs[1].push(...args);
  12575. const minMax = opArgs[2];
  12576. switch (fn) {
  12577. case _util.OPS.rectangle:
  12578. const x = args[0] + args[2];
  12579. const y = args[1] + args[3];
  12580. minMax[0] = Math.min(minMax[0], args[0], x);
  12581. minMax[1] = Math.max(minMax[1], args[0], x);
  12582. minMax[2] = Math.min(minMax[2], args[1], y);
  12583. minMax[3] = Math.max(minMax[3], args[1], y);
  12584. break;
  12585. case _util.OPS.moveTo:
  12586. case _util.OPS.lineTo:
  12587. minMax[0] = Math.min(minMax[0], args[0]);
  12588. minMax[1] = Math.max(minMax[1], args[0]);
  12589. minMax[2] = Math.min(minMax[2], args[1]);
  12590. minMax[3] = Math.max(minMax[3], args[1]);
  12591. break;
  12592. }
  12593. }
  12594. }
  12595. parseColorSpace(_ref4) {
  12596. let {
  12597. cs,
  12598. resources,
  12599. localColorSpaceCache
  12600. } = _ref4;
  12601. return _colorspace.ColorSpace.parseAsync({
  12602. cs,
  12603. xref: this.xref,
  12604. resources,
  12605. pdfFunctionFactory: this._pdfFunctionFactory,
  12606. localColorSpaceCache
  12607. }).catch(reason => {
  12608. if (reason instanceof _util.AbortException) {
  12609. return null;
  12610. }
  12611. if (this.options.ignoreErrors) {
  12612. (0, _util.warn)(`parseColorSpace - ignoring ColorSpace: "${reason}".`);
  12613. return null;
  12614. }
  12615. throw reason;
  12616. });
  12617. }
  12618. parseShading(_ref5) {
  12619. let {
  12620. shading,
  12621. resources,
  12622. localColorSpaceCache,
  12623. localShadingPatternCache
  12624. } = _ref5;
  12625. let id = localShadingPatternCache.get(shading);
  12626. if (!id) {
  12627. var shadingFill = _pattern.Pattern.parseShading(shading, this.xref, resources, this._pdfFunctionFactory, localColorSpaceCache);
  12628. const patternIR = shadingFill.getIR();
  12629. id = `pattern_${this.idFactory.createObjId()}`;
  12630. if (this.parsingType3Font) {
  12631. id = `${this.idFactory.getDocId()}_type3_${id}`;
  12632. }
  12633. localShadingPatternCache.set(shading, id);
  12634. if (this.parsingType3Font) {
  12635. this.handler.send("commonobj", [id, "Pattern", patternIR]);
  12636. } else {
  12637. this.handler.send("obj", [id, this.pageIndex, "Pattern", patternIR]);
  12638. }
  12639. }
  12640. return id;
  12641. }
  12642. handleColorN(operatorList, fn, args, cs, patterns, resources, task, localColorSpaceCache, localTilingPatternCache, localShadingPatternCache) {
  12643. const patternName = args.pop();
  12644. if (patternName instanceof _primitives.Name) {
  12645. const rawPattern = patterns.getRaw(patternName.name);
  12646. const localTilingPattern = rawPattern instanceof _primitives.Ref && localTilingPatternCache.getByRef(rawPattern);
  12647. if (localTilingPattern) {
  12648. try {
  12649. const color = cs.base ? cs.base.getRgb(args, 0) : null;
  12650. const tilingPatternIR = (0, _pattern.getTilingPatternIR)(localTilingPattern.operatorListIR, localTilingPattern.dict, color);
  12651. operatorList.addOp(fn, tilingPatternIR);
  12652. return undefined;
  12653. } catch {}
  12654. }
  12655. const pattern = this.xref.fetchIfRef(rawPattern);
  12656. if (pattern) {
  12657. const dict = pattern instanceof _base_stream.BaseStream ? pattern.dict : pattern;
  12658. const typeNum = dict.get("PatternType");
  12659. if (typeNum === PatternType.TILING) {
  12660. const color = cs.base ? cs.base.getRgb(args, 0) : null;
  12661. return this.handleTilingType(fn, color, resources, pattern, dict, operatorList, task, localTilingPatternCache);
  12662. } else if (typeNum === PatternType.SHADING) {
  12663. const shading = dict.get("Shading");
  12664. const matrix = dict.getArray("Matrix");
  12665. const objId = this.parseShading({
  12666. shading,
  12667. resources,
  12668. localColorSpaceCache,
  12669. localShadingPatternCache
  12670. });
  12671. operatorList.addOp(fn, ["Shading", objId, matrix]);
  12672. return undefined;
  12673. }
  12674. throw new _util.FormatError(`Unknown PatternType: ${typeNum}`);
  12675. }
  12676. }
  12677. throw new _util.FormatError(`Unknown PatternName: ${patternName}`);
  12678. }
  12679. _parseVisibilityExpression(array, nestingCounter, currentResult) {
  12680. const MAX_NESTING = 10;
  12681. if (++nestingCounter > MAX_NESTING) {
  12682. (0, _util.warn)("Visibility expression is too deeply nested");
  12683. return;
  12684. }
  12685. const length = array.length;
  12686. const operator = this.xref.fetchIfRef(array[0]);
  12687. if (length < 2 || !(operator instanceof _primitives.Name)) {
  12688. (0, _util.warn)("Invalid visibility expression");
  12689. return;
  12690. }
  12691. switch (operator.name) {
  12692. case "And":
  12693. case "Or":
  12694. case "Not":
  12695. currentResult.push(operator.name);
  12696. break;
  12697. default:
  12698. (0, _util.warn)(`Invalid operator ${operator.name} in visibility expression`);
  12699. return;
  12700. }
  12701. for (let i = 1; i < length; i++) {
  12702. const raw = array[i];
  12703. const object = this.xref.fetchIfRef(raw);
  12704. if (Array.isArray(object)) {
  12705. const nestedResult = [];
  12706. currentResult.push(nestedResult);
  12707. this._parseVisibilityExpression(object, nestingCounter, nestedResult);
  12708. } else if (raw instanceof _primitives.Ref) {
  12709. currentResult.push(raw.toString());
  12710. }
  12711. }
  12712. }
  12713. async parseMarkedContentProps(contentProperties, resources) {
  12714. let optionalContent;
  12715. if (contentProperties instanceof _primitives.Name) {
  12716. const properties = resources.get("Properties");
  12717. optionalContent = properties.get(contentProperties.name);
  12718. } else if (contentProperties instanceof _primitives.Dict) {
  12719. optionalContent = contentProperties;
  12720. } else {
  12721. throw new _util.FormatError("Optional content properties malformed.");
  12722. }
  12723. const optionalContentType = optionalContent.get("Type").name;
  12724. if (optionalContentType === "OCG") {
  12725. return {
  12726. type: optionalContentType,
  12727. id: optionalContent.objId
  12728. };
  12729. } else if (optionalContentType === "OCMD") {
  12730. const expression = optionalContent.get("VE");
  12731. if (Array.isArray(expression)) {
  12732. const result = [];
  12733. this._parseVisibilityExpression(expression, 0, result);
  12734. if (result.length > 0) {
  12735. return {
  12736. type: "OCMD",
  12737. expression: result
  12738. };
  12739. }
  12740. }
  12741. const optionalContentGroups = optionalContent.get("OCGs");
  12742. if (Array.isArray(optionalContentGroups) || optionalContentGroups instanceof _primitives.Dict) {
  12743. const groupIds = [];
  12744. if (Array.isArray(optionalContentGroups)) {
  12745. for (const ocg of optionalContentGroups) {
  12746. groupIds.push(ocg.toString());
  12747. }
  12748. } else {
  12749. groupIds.push(optionalContentGroups.objId);
  12750. }
  12751. return {
  12752. type: optionalContentType,
  12753. ids: groupIds,
  12754. policy: optionalContent.get("P") instanceof _primitives.Name ? optionalContent.get("P").name : null,
  12755. expression: null
  12756. };
  12757. } else if (optionalContentGroups instanceof _primitives.Ref) {
  12758. return {
  12759. type: optionalContentType,
  12760. id: optionalContentGroups.toString()
  12761. };
  12762. }
  12763. }
  12764. return null;
  12765. }
  12766. getOperatorList(_ref6) {
  12767. let {
  12768. stream,
  12769. task,
  12770. resources,
  12771. operatorList,
  12772. initialState = null,
  12773. fallbackFontDict = null
  12774. } = _ref6;
  12775. resources ||= _primitives.Dict.empty;
  12776. initialState ||= new EvalState();
  12777. if (!operatorList) {
  12778. throw new Error('getOperatorList: missing "operatorList" parameter');
  12779. }
  12780. const self = this;
  12781. const xref = this.xref;
  12782. let parsingText = false;
  12783. const localImageCache = new _image_utils.LocalImageCache();
  12784. const localColorSpaceCache = new _image_utils.LocalColorSpaceCache();
  12785. const localGStateCache = new _image_utils.LocalGStateCache();
  12786. const localTilingPatternCache = new _image_utils.LocalTilingPatternCache();
  12787. const localShadingPatternCache = new Map();
  12788. const xobjs = resources.get("XObject") || _primitives.Dict.empty;
  12789. const patterns = resources.get("Pattern") || _primitives.Dict.empty;
  12790. const stateManager = new StateManager(initialState);
  12791. const preprocessor = new EvaluatorPreprocessor(stream, xref, stateManager);
  12792. const timeSlotManager = new TimeSlotManager();
  12793. function closePendingRestoreOPS(argument) {
  12794. for (let i = 0, ii = preprocessor.savedStatesDepth; i < ii; i++) {
  12795. operatorList.addOp(_util.OPS.restore, []);
  12796. }
  12797. }
  12798. return new Promise(function promiseBody(resolve, reject) {
  12799. const next = function (promise) {
  12800. Promise.all([promise, operatorList.ready]).then(function () {
  12801. try {
  12802. promiseBody(resolve, reject);
  12803. } catch (ex) {
  12804. reject(ex);
  12805. }
  12806. }, reject);
  12807. };
  12808. task.ensureNotTerminated();
  12809. timeSlotManager.reset();
  12810. const operation = {};
  12811. let stop, i, ii, cs, name, isValidName;
  12812. while (!(stop = timeSlotManager.check())) {
  12813. operation.args = null;
  12814. if (!preprocessor.read(operation)) {
  12815. break;
  12816. }
  12817. let args = operation.args;
  12818. let fn = operation.fn;
  12819. switch (fn | 0) {
  12820. case _util.OPS.paintXObject:
  12821. isValidName = args[0] instanceof _primitives.Name;
  12822. name = args[0].name;
  12823. if (isValidName) {
  12824. const localImage = localImageCache.getByName(name);
  12825. if (localImage) {
  12826. operatorList.addImageOps(localImage.fn, localImage.args, localImage.optionalContent);
  12827. incrementCachedImageMaskCount(localImage);
  12828. args = null;
  12829. continue;
  12830. }
  12831. }
  12832. next(new Promise(function (resolveXObject, rejectXObject) {
  12833. if (!isValidName) {
  12834. throw new _util.FormatError("XObject must be referred to by name.");
  12835. }
  12836. let xobj = xobjs.getRaw(name);
  12837. if (xobj instanceof _primitives.Ref) {
  12838. const localImage = localImageCache.getByRef(xobj) || self._regionalImageCache.getByRef(xobj);
  12839. if (localImage) {
  12840. operatorList.addImageOps(localImage.fn, localImage.args, localImage.optionalContent);
  12841. incrementCachedImageMaskCount(localImage);
  12842. resolveXObject();
  12843. return;
  12844. }
  12845. const globalImage = self.globalImageCache.getData(xobj, self.pageIndex);
  12846. if (globalImage) {
  12847. operatorList.addDependency(globalImage.objId);
  12848. operatorList.addImageOps(globalImage.fn, globalImage.args, globalImage.optionalContent);
  12849. resolveXObject();
  12850. return;
  12851. }
  12852. xobj = xref.fetch(xobj);
  12853. }
  12854. if (!(xobj instanceof _base_stream.BaseStream)) {
  12855. throw new _util.FormatError("XObject should be a stream");
  12856. }
  12857. const type = xobj.dict.get("Subtype");
  12858. if (!(type instanceof _primitives.Name)) {
  12859. throw new _util.FormatError("XObject should have a Name subtype");
  12860. }
  12861. if (type.name === "Form") {
  12862. stateManager.save();
  12863. self.buildFormXObject(resources, xobj, null, operatorList, task, stateManager.state.clone(), localColorSpaceCache).then(function () {
  12864. stateManager.restore();
  12865. resolveXObject();
  12866. }, rejectXObject);
  12867. return;
  12868. } else if (type.name === "Image") {
  12869. self.buildPaintImageXObject({
  12870. resources,
  12871. image: xobj,
  12872. operatorList,
  12873. cacheKey: name,
  12874. localImageCache,
  12875. localColorSpaceCache
  12876. }).then(resolveXObject, rejectXObject);
  12877. return;
  12878. } else if (type.name === "PS") {
  12879. (0, _util.info)("Ignored XObject subtype PS");
  12880. } else {
  12881. throw new _util.FormatError(`Unhandled XObject subtype ${type.name}`);
  12882. }
  12883. resolveXObject();
  12884. }).catch(function (reason) {
  12885. if (reason instanceof _util.AbortException) {
  12886. return;
  12887. }
  12888. if (self.options.ignoreErrors) {
  12889. (0, _util.warn)(`getOperatorList - ignoring XObject: "${reason}".`);
  12890. return;
  12891. }
  12892. throw reason;
  12893. }));
  12894. return;
  12895. case _util.OPS.setFont:
  12896. var fontSize = args[1];
  12897. next(self.handleSetFont(resources, args, null, operatorList, task, stateManager.state, fallbackFontDict).then(function (loadedName) {
  12898. operatorList.addDependency(loadedName);
  12899. operatorList.addOp(_util.OPS.setFont, [loadedName, fontSize]);
  12900. }));
  12901. return;
  12902. case _util.OPS.beginText:
  12903. parsingText = true;
  12904. break;
  12905. case _util.OPS.endText:
  12906. parsingText = false;
  12907. break;
  12908. case _util.OPS.endInlineImage:
  12909. var cacheKey = args[0].cacheKey;
  12910. if (cacheKey) {
  12911. const localImage = localImageCache.getByName(cacheKey);
  12912. if (localImage) {
  12913. operatorList.addImageOps(localImage.fn, localImage.args, localImage.optionalContent);
  12914. incrementCachedImageMaskCount(localImage);
  12915. args = null;
  12916. continue;
  12917. }
  12918. }
  12919. next(self.buildPaintImageXObject({
  12920. resources,
  12921. image: args[0],
  12922. isInline: true,
  12923. operatorList,
  12924. cacheKey,
  12925. localImageCache,
  12926. localColorSpaceCache
  12927. }));
  12928. return;
  12929. case _util.OPS.showText:
  12930. if (!stateManager.state.font) {
  12931. self.ensureStateFont(stateManager.state);
  12932. continue;
  12933. }
  12934. args[0] = self.handleText(args[0], stateManager.state);
  12935. break;
  12936. case _util.OPS.showSpacedText:
  12937. if (!stateManager.state.font) {
  12938. self.ensureStateFont(stateManager.state);
  12939. continue;
  12940. }
  12941. var combinedGlyphs = [];
  12942. var state = stateManager.state;
  12943. for (const arrItem of args[0]) {
  12944. if (typeof arrItem === "string") {
  12945. combinedGlyphs.push(...self.handleText(arrItem, state));
  12946. } else if (typeof arrItem === "number") {
  12947. combinedGlyphs.push(arrItem);
  12948. }
  12949. }
  12950. args[0] = combinedGlyphs;
  12951. fn = _util.OPS.showText;
  12952. break;
  12953. case _util.OPS.nextLineShowText:
  12954. if (!stateManager.state.font) {
  12955. self.ensureStateFont(stateManager.state);
  12956. continue;
  12957. }
  12958. operatorList.addOp(_util.OPS.nextLine);
  12959. args[0] = self.handleText(args[0], stateManager.state);
  12960. fn = _util.OPS.showText;
  12961. break;
  12962. case _util.OPS.nextLineSetSpacingShowText:
  12963. if (!stateManager.state.font) {
  12964. self.ensureStateFont(stateManager.state);
  12965. continue;
  12966. }
  12967. operatorList.addOp(_util.OPS.nextLine);
  12968. operatorList.addOp(_util.OPS.setWordSpacing, [args.shift()]);
  12969. operatorList.addOp(_util.OPS.setCharSpacing, [args.shift()]);
  12970. args[0] = self.handleText(args[0], stateManager.state);
  12971. fn = _util.OPS.showText;
  12972. break;
  12973. case _util.OPS.setTextRenderingMode:
  12974. stateManager.state.textRenderingMode = args[0];
  12975. break;
  12976. case _util.OPS.setFillColorSpace:
  12977. {
  12978. const cachedColorSpace = _colorspace.ColorSpace.getCached(args[0], xref, localColorSpaceCache);
  12979. if (cachedColorSpace) {
  12980. stateManager.state.fillColorSpace = cachedColorSpace;
  12981. continue;
  12982. }
  12983. next(self.parseColorSpace({
  12984. cs: args[0],
  12985. resources,
  12986. localColorSpaceCache
  12987. }).then(function (colorSpace) {
  12988. if (colorSpace) {
  12989. stateManager.state.fillColorSpace = colorSpace;
  12990. }
  12991. }));
  12992. return;
  12993. }
  12994. case _util.OPS.setStrokeColorSpace:
  12995. {
  12996. const cachedColorSpace = _colorspace.ColorSpace.getCached(args[0], xref, localColorSpaceCache);
  12997. if (cachedColorSpace) {
  12998. stateManager.state.strokeColorSpace = cachedColorSpace;
  12999. continue;
  13000. }
  13001. next(self.parseColorSpace({
  13002. cs: args[0],
  13003. resources,
  13004. localColorSpaceCache
  13005. }).then(function (colorSpace) {
  13006. if (colorSpace) {
  13007. stateManager.state.strokeColorSpace = colorSpace;
  13008. }
  13009. }));
  13010. return;
  13011. }
  13012. case _util.OPS.setFillColor:
  13013. cs = stateManager.state.fillColorSpace;
  13014. args = cs.getRgb(args, 0);
  13015. fn = _util.OPS.setFillRGBColor;
  13016. break;
  13017. case _util.OPS.setStrokeColor:
  13018. cs = stateManager.state.strokeColorSpace;
  13019. args = cs.getRgb(args, 0);
  13020. fn = _util.OPS.setStrokeRGBColor;
  13021. break;
  13022. case _util.OPS.setFillGray:
  13023. stateManager.state.fillColorSpace = _colorspace.ColorSpace.singletons.gray;
  13024. args = _colorspace.ColorSpace.singletons.gray.getRgb(args, 0);
  13025. fn = _util.OPS.setFillRGBColor;
  13026. break;
  13027. case _util.OPS.setStrokeGray:
  13028. stateManager.state.strokeColorSpace = _colorspace.ColorSpace.singletons.gray;
  13029. args = _colorspace.ColorSpace.singletons.gray.getRgb(args, 0);
  13030. fn = _util.OPS.setStrokeRGBColor;
  13031. break;
  13032. case _util.OPS.setFillCMYKColor:
  13033. stateManager.state.fillColorSpace = _colorspace.ColorSpace.singletons.cmyk;
  13034. args = _colorspace.ColorSpace.singletons.cmyk.getRgb(args, 0);
  13035. fn = _util.OPS.setFillRGBColor;
  13036. break;
  13037. case _util.OPS.setStrokeCMYKColor:
  13038. stateManager.state.strokeColorSpace = _colorspace.ColorSpace.singletons.cmyk;
  13039. args = _colorspace.ColorSpace.singletons.cmyk.getRgb(args, 0);
  13040. fn = _util.OPS.setStrokeRGBColor;
  13041. break;
  13042. case _util.OPS.setFillRGBColor:
  13043. stateManager.state.fillColorSpace = _colorspace.ColorSpace.singletons.rgb;
  13044. args = _colorspace.ColorSpace.singletons.rgb.getRgb(args, 0);
  13045. break;
  13046. case _util.OPS.setStrokeRGBColor:
  13047. stateManager.state.strokeColorSpace = _colorspace.ColorSpace.singletons.rgb;
  13048. args = _colorspace.ColorSpace.singletons.rgb.getRgb(args, 0);
  13049. break;
  13050. case _util.OPS.setFillColorN:
  13051. cs = stateManager.state.fillColorSpace;
  13052. if (cs.name === "Pattern") {
  13053. next(self.handleColorN(operatorList, _util.OPS.setFillColorN, args, cs, patterns, resources, task, localColorSpaceCache, localTilingPatternCache, localShadingPatternCache));
  13054. return;
  13055. }
  13056. args = cs.getRgb(args, 0);
  13057. fn = _util.OPS.setFillRGBColor;
  13058. break;
  13059. case _util.OPS.setStrokeColorN:
  13060. cs = stateManager.state.strokeColorSpace;
  13061. if (cs.name === "Pattern") {
  13062. next(self.handleColorN(operatorList, _util.OPS.setStrokeColorN, args, cs, patterns, resources, task, localColorSpaceCache, localTilingPatternCache, localShadingPatternCache));
  13063. return;
  13064. }
  13065. args = cs.getRgb(args, 0);
  13066. fn = _util.OPS.setStrokeRGBColor;
  13067. break;
  13068. case _util.OPS.shadingFill:
  13069. var shadingRes = resources.get("Shading");
  13070. if (!shadingRes) {
  13071. throw new _util.FormatError("No shading resource found");
  13072. }
  13073. var shading = shadingRes.get(args[0].name);
  13074. if (!shading) {
  13075. throw new _util.FormatError("No shading object found");
  13076. }
  13077. const patternId = self.parseShading({
  13078. shading,
  13079. resources,
  13080. localColorSpaceCache,
  13081. localShadingPatternCache
  13082. });
  13083. args = [patternId];
  13084. fn = _util.OPS.shadingFill;
  13085. break;
  13086. case _util.OPS.setGState:
  13087. isValidName = args[0] instanceof _primitives.Name;
  13088. name = args[0].name;
  13089. if (isValidName) {
  13090. const localGStateObj = localGStateCache.getByName(name);
  13091. if (localGStateObj) {
  13092. if (localGStateObj.length > 0) {
  13093. operatorList.addOp(_util.OPS.setGState, [localGStateObj]);
  13094. }
  13095. args = null;
  13096. continue;
  13097. }
  13098. }
  13099. next(new Promise(function (resolveGState, rejectGState) {
  13100. if (!isValidName) {
  13101. throw new _util.FormatError("GState must be referred to by name.");
  13102. }
  13103. const extGState = resources.get("ExtGState");
  13104. if (!(extGState instanceof _primitives.Dict)) {
  13105. throw new _util.FormatError("ExtGState should be a dictionary.");
  13106. }
  13107. const gState = extGState.get(name);
  13108. if (!(gState instanceof _primitives.Dict)) {
  13109. throw new _util.FormatError("GState should be a dictionary.");
  13110. }
  13111. self.setGState({
  13112. resources,
  13113. gState,
  13114. operatorList,
  13115. cacheKey: name,
  13116. task,
  13117. stateManager,
  13118. localGStateCache,
  13119. localColorSpaceCache
  13120. }).then(resolveGState, rejectGState);
  13121. }).catch(function (reason) {
  13122. if (reason instanceof _util.AbortException) {
  13123. return;
  13124. }
  13125. if (self.options.ignoreErrors) {
  13126. (0, _util.warn)(`getOperatorList - ignoring ExtGState: "${reason}".`);
  13127. return;
  13128. }
  13129. throw reason;
  13130. }));
  13131. return;
  13132. case _util.OPS.moveTo:
  13133. case _util.OPS.lineTo:
  13134. case _util.OPS.curveTo:
  13135. case _util.OPS.curveTo2:
  13136. case _util.OPS.curveTo3:
  13137. case _util.OPS.closePath:
  13138. case _util.OPS.rectangle:
  13139. self.buildPath(operatorList, fn, args, parsingText);
  13140. continue;
  13141. case _util.OPS.markPoint:
  13142. case _util.OPS.markPointProps:
  13143. case _util.OPS.beginCompat:
  13144. case _util.OPS.endCompat:
  13145. continue;
  13146. case _util.OPS.beginMarkedContentProps:
  13147. if (!(args[0] instanceof _primitives.Name)) {
  13148. (0, _util.warn)(`Expected name for beginMarkedContentProps arg0=${args[0]}`);
  13149. continue;
  13150. }
  13151. if (args[0].name === "OC") {
  13152. next(self.parseMarkedContentProps(args[1], resources).then(data => {
  13153. operatorList.addOp(_util.OPS.beginMarkedContentProps, ["OC", data]);
  13154. }).catch(reason => {
  13155. if (reason instanceof _util.AbortException) {
  13156. return;
  13157. }
  13158. if (self.options.ignoreErrors) {
  13159. (0, _util.warn)(`getOperatorList - ignoring beginMarkedContentProps: "${reason}".`);
  13160. return;
  13161. }
  13162. throw reason;
  13163. }));
  13164. return;
  13165. }
  13166. args = [args[0].name, args[1] instanceof _primitives.Dict ? args[1].get("MCID") : null];
  13167. break;
  13168. case _util.OPS.beginMarkedContent:
  13169. case _util.OPS.endMarkedContent:
  13170. default:
  13171. if (args !== null) {
  13172. for (i = 0, ii = args.length; i < ii; i++) {
  13173. if (args[i] instanceof _primitives.Dict) {
  13174. break;
  13175. }
  13176. }
  13177. if (i < ii) {
  13178. (0, _util.warn)("getOperatorList - ignoring operator: " + fn);
  13179. continue;
  13180. }
  13181. }
  13182. }
  13183. operatorList.addOp(fn, args);
  13184. }
  13185. if (stop) {
  13186. next(deferred);
  13187. return;
  13188. }
  13189. closePendingRestoreOPS();
  13190. resolve();
  13191. }).catch(reason => {
  13192. if (reason instanceof _util.AbortException) {
  13193. return;
  13194. }
  13195. if (this.options.ignoreErrors) {
  13196. (0, _util.warn)(`getOperatorList - ignoring errors during "${task.name}" ` + `task: "${reason}".`);
  13197. closePendingRestoreOPS();
  13198. return;
  13199. }
  13200. throw reason;
  13201. });
  13202. }
  13203. getTextContent(_ref7) {
  13204. let {
  13205. stream,
  13206. task,
  13207. resources,
  13208. stateManager = null,
  13209. includeMarkedContent = false,
  13210. sink,
  13211. seenStyles = new Set(),
  13212. viewBox,
  13213. markedContentData = null,
  13214. disableNormalization = false
  13215. } = _ref7;
  13216. resources ||= _primitives.Dict.empty;
  13217. stateManager ||= new StateManager(new TextState());
  13218. if (includeMarkedContent) {
  13219. markedContentData ||= {
  13220. level: 0
  13221. };
  13222. }
  13223. const textContent = {
  13224. items: [],
  13225. styles: Object.create(null)
  13226. };
  13227. const textContentItem = {
  13228. initialized: false,
  13229. str: [],
  13230. totalWidth: 0,
  13231. totalHeight: 0,
  13232. width: 0,
  13233. height: 0,
  13234. vertical: false,
  13235. prevTransform: null,
  13236. textAdvanceScale: 0,
  13237. spaceInFlowMin: 0,
  13238. spaceInFlowMax: 0,
  13239. trackingSpaceMin: Infinity,
  13240. negativeSpaceMax: -Infinity,
  13241. notASpace: -Infinity,
  13242. transform: null,
  13243. fontName: null,
  13244. hasEOL: false
  13245. };
  13246. const twoLastChars = [" ", " "];
  13247. let twoLastCharsPos = 0;
  13248. function saveLastChar(char) {
  13249. const nextPos = (twoLastCharsPos + 1) % 2;
  13250. const ret = twoLastChars[twoLastCharsPos] !== " " && twoLastChars[nextPos] === " ";
  13251. twoLastChars[twoLastCharsPos] = char;
  13252. twoLastCharsPos = nextPos;
  13253. return ret;
  13254. }
  13255. function shouldAddWhitepsace() {
  13256. return twoLastChars[twoLastCharsPos] !== " " && twoLastChars[(twoLastCharsPos + 1) % 2] === " ";
  13257. }
  13258. function resetLastChars() {
  13259. twoLastChars[0] = twoLastChars[1] = " ";
  13260. twoLastCharsPos = 0;
  13261. }
  13262. const TRACKING_SPACE_FACTOR = 0.102;
  13263. const NOT_A_SPACE_FACTOR = 0.03;
  13264. const NEGATIVE_SPACE_FACTOR = -0.2;
  13265. const SPACE_IN_FLOW_MIN_FACTOR = 0.102;
  13266. const SPACE_IN_FLOW_MAX_FACTOR = 0.6;
  13267. const VERTICAL_SHIFT_RATIO = 0.25;
  13268. const self = this;
  13269. const xref = this.xref;
  13270. const showSpacedTextBuffer = [];
  13271. let xobjs = null;
  13272. const emptyXObjectCache = new _image_utils.LocalImageCache();
  13273. const emptyGStateCache = new _image_utils.LocalGStateCache();
  13274. const preprocessor = new EvaluatorPreprocessor(stream, xref, stateManager);
  13275. let textState;
  13276. function pushWhitespace(_ref8) {
  13277. let {
  13278. width = 0,
  13279. height = 0,
  13280. transform = textContentItem.prevTransform,
  13281. fontName = textContentItem.fontName
  13282. } = _ref8;
  13283. textContent.items.push({
  13284. str: " ",
  13285. dir: "ltr",
  13286. width,
  13287. height,
  13288. transform,
  13289. fontName,
  13290. hasEOL: false
  13291. });
  13292. }
  13293. function getCurrentTextTransform() {
  13294. const font = textState.font;
  13295. const tsm = [textState.fontSize * textState.textHScale, 0, 0, textState.fontSize, 0, textState.textRise];
  13296. if (font.isType3Font && (textState.fontSize <= 1 || font.isCharBBox) && !(0, _util.isArrayEqual)(textState.fontMatrix, _util.FONT_IDENTITY_MATRIX)) {
  13297. const glyphHeight = font.bbox[3] - font.bbox[1];
  13298. if (glyphHeight > 0) {
  13299. tsm[3] *= glyphHeight * textState.fontMatrix[3];
  13300. }
  13301. }
  13302. return _util.Util.transform(textState.ctm, _util.Util.transform(textState.textMatrix, tsm));
  13303. }
  13304. function ensureTextContentItem() {
  13305. if (textContentItem.initialized) {
  13306. return textContentItem;
  13307. }
  13308. const {
  13309. font,
  13310. loadedName
  13311. } = textState;
  13312. if (!seenStyles.has(loadedName)) {
  13313. seenStyles.add(loadedName);
  13314. textContent.styles[loadedName] = {
  13315. fontFamily: font.fallbackName,
  13316. ascent: font.ascent,
  13317. descent: font.descent,
  13318. vertical: font.vertical
  13319. };
  13320. }
  13321. textContentItem.fontName = loadedName;
  13322. const trm = textContentItem.transform = getCurrentTextTransform();
  13323. if (!font.vertical) {
  13324. textContentItem.width = textContentItem.totalWidth = 0;
  13325. textContentItem.height = textContentItem.totalHeight = Math.hypot(trm[2], trm[3]);
  13326. textContentItem.vertical = false;
  13327. } else {
  13328. textContentItem.width = textContentItem.totalWidth = Math.hypot(trm[0], trm[1]);
  13329. textContentItem.height = textContentItem.totalHeight = 0;
  13330. textContentItem.vertical = true;
  13331. }
  13332. const scaleLineX = Math.hypot(textState.textLineMatrix[0], textState.textLineMatrix[1]);
  13333. const scaleCtmX = Math.hypot(textState.ctm[0], textState.ctm[1]);
  13334. textContentItem.textAdvanceScale = scaleCtmX * scaleLineX;
  13335. const {
  13336. fontSize
  13337. } = textState;
  13338. textContentItem.trackingSpaceMin = fontSize * TRACKING_SPACE_FACTOR;
  13339. textContentItem.notASpace = fontSize * NOT_A_SPACE_FACTOR;
  13340. textContentItem.negativeSpaceMax = fontSize * NEGATIVE_SPACE_FACTOR;
  13341. textContentItem.spaceInFlowMin = fontSize * SPACE_IN_FLOW_MIN_FACTOR;
  13342. textContentItem.spaceInFlowMax = fontSize * SPACE_IN_FLOW_MAX_FACTOR;
  13343. textContentItem.hasEOL = false;
  13344. textContentItem.initialized = true;
  13345. return textContentItem;
  13346. }
  13347. function updateAdvanceScale() {
  13348. if (!textContentItem.initialized) {
  13349. return;
  13350. }
  13351. const scaleLineX = Math.hypot(textState.textLineMatrix[0], textState.textLineMatrix[1]);
  13352. const scaleCtmX = Math.hypot(textState.ctm[0], textState.ctm[1]);
  13353. const scaleFactor = scaleCtmX * scaleLineX;
  13354. if (scaleFactor === textContentItem.textAdvanceScale) {
  13355. return;
  13356. }
  13357. if (!textContentItem.vertical) {
  13358. textContentItem.totalWidth += textContentItem.width * textContentItem.textAdvanceScale;
  13359. textContentItem.width = 0;
  13360. } else {
  13361. textContentItem.totalHeight += textContentItem.height * textContentItem.textAdvanceScale;
  13362. textContentItem.height = 0;
  13363. }
  13364. textContentItem.textAdvanceScale = scaleFactor;
  13365. }
  13366. function runBidiTransform(textChunk) {
  13367. let text = textChunk.str.join("");
  13368. if (!disableNormalization) {
  13369. text = (0, _util.normalizeUnicode)(text);
  13370. }
  13371. const bidiResult = (0, _bidi.bidi)(text, -1, textChunk.vertical);
  13372. return {
  13373. str: bidiResult.str,
  13374. dir: bidiResult.dir,
  13375. width: Math.abs(textChunk.totalWidth),
  13376. height: Math.abs(textChunk.totalHeight),
  13377. transform: textChunk.transform,
  13378. fontName: textChunk.fontName,
  13379. hasEOL: textChunk.hasEOL
  13380. };
  13381. }
  13382. function handleSetFont(fontName, fontRef) {
  13383. return self.loadFont(fontName, fontRef, resources).then(function (translated) {
  13384. if (!translated.font.isType3Font) {
  13385. return translated;
  13386. }
  13387. return translated.loadType3Data(self, resources, task).catch(function () {}).then(function () {
  13388. return translated;
  13389. });
  13390. }).then(function (translated) {
  13391. textState.loadedName = translated.loadedName;
  13392. textState.font = translated.font;
  13393. textState.fontMatrix = translated.font.fontMatrix || _util.FONT_IDENTITY_MATRIX;
  13394. });
  13395. }
  13396. function applyInverseRotation(x, y, matrix) {
  13397. const scale = Math.hypot(matrix[0], matrix[1]);
  13398. return [(matrix[0] * x + matrix[1] * y) / scale, (matrix[2] * x + matrix[3] * y) / scale];
  13399. }
  13400. function compareWithLastPosition(glyphWidth) {
  13401. const currentTransform = getCurrentTextTransform();
  13402. let posX = currentTransform[4];
  13403. let posY = currentTransform[5];
  13404. if (textState.font?.vertical) {
  13405. if (posX < viewBox[0] || posX > viewBox[2] || posY + glyphWidth < viewBox[1] || posY > viewBox[3]) {
  13406. return false;
  13407. }
  13408. } else if (posX + glyphWidth < viewBox[0] || posX > viewBox[2] || posY < viewBox[1] || posY > viewBox[3]) {
  13409. return false;
  13410. }
  13411. if (!textState.font || !textContentItem.prevTransform) {
  13412. return true;
  13413. }
  13414. let lastPosX = textContentItem.prevTransform[4];
  13415. let lastPosY = textContentItem.prevTransform[5];
  13416. if (lastPosX === posX && lastPosY === posY) {
  13417. return true;
  13418. }
  13419. let rotate = -1;
  13420. if (currentTransform[0] && currentTransform[1] === 0 && currentTransform[2] === 0) {
  13421. rotate = currentTransform[0] > 0 ? 0 : 180;
  13422. } else if (currentTransform[1] && currentTransform[0] === 0 && currentTransform[3] === 0) {
  13423. rotate = currentTransform[1] > 0 ? 90 : 270;
  13424. }
  13425. switch (rotate) {
  13426. case 0:
  13427. break;
  13428. case 90:
  13429. [posX, posY] = [posY, posX];
  13430. [lastPosX, lastPosY] = [lastPosY, lastPosX];
  13431. break;
  13432. case 180:
  13433. [posX, posY, lastPosX, lastPosY] = [-posX, -posY, -lastPosX, -lastPosY];
  13434. break;
  13435. case 270:
  13436. [posX, posY] = [-posY, -posX];
  13437. [lastPosX, lastPosY] = [-lastPosY, -lastPosX];
  13438. break;
  13439. default:
  13440. [posX, posY] = applyInverseRotation(posX, posY, currentTransform);
  13441. [lastPosX, lastPosY] = applyInverseRotation(lastPosX, lastPosY, textContentItem.prevTransform);
  13442. }
  13443. if (textState.font.vertical) {
  13444. const advanceY = (lastPosY - posY) / textContentItem.textAdvanceScale;
  13445. const advanceX = posX - lastPosX;
  13446. const textOrientation = Math.sign(textContentItem.height);
  13447. if (advanceY < textOrientation * textContentItem.negativeSpaceMax) {
  13448. if (Math.abs(advanceX) > 0.5 * textContentItem.width) {
  13449. appendEOL();
  13450. return true;
  13451. }
  13452. resetLastChars();
  13453. flushTextContentItem();
  13454. return true;
  13455. }
  13456. if (Math.abs(advanceX) > textContentItem.width) {
  13457. appendEOL();
  13458. return true;
  13459. }
  13460. if (advanceY <= textOrientation * textContentItem.notASpace) {
  13461. resetLastChars();
  13462. }
  13463. if (advanceY <= textOrientation * textContentItem.trackingSpaceMin) {
  13464. if (shouldAddWhitepsace()) {
  13465. resetLastChars();
  13466. flushTextContentItem();
  13467. pushWhitespace({
  13468. height: Math.abs(advanceY)
  13469. });
  13470. } else {
  13471. textContentItem.height += advanceY;
  13472. }
  13473. } else if (!addFakeSpaces(advanceY, textContentItem.prevTransform, textOrientation)) {
  13474. if (textContentItem.str.length === 0) {
  13475. resetLastChars();
  13476. pushWhitespace({
  13477. height: Math.abs(advanceY)
  13478. });
  13479. } else {
  13480. textContentItem.height += advanceY;
  13481. }
  13482. }
  13483. if (Math.abs(advanceX) > textContentItem.width * VERTICAL_SHIFT_RATIO) {
  13484. flushTextContentItem();
  13485. }
  13486. return true;
  13487. }
  13488. const advanceX = (posX - lastPosX) / textContentItem.textAdvanceScale;
  13489. const advanceY = posY - lastPosY;
  13490. const textOrientation = Math.sign(textContentItem.width);
  13491. if (advanceX < textOrientation * textContentItem.negativeSpaceMax) {
  13492. if (Math.abs(advanceY) > 0.5 * textContentItem.height) {
  13493. appendEOL();
  13494. return true;
  13495. }
  13496. resetLastChars();
  13497. flushTextContentItem();
  13498. return true;
  13499. }
  13500. if (Math.abs(advanceY) > textContentItem.height) {
  13501. appendEOL();
  13502. return true;
  13503. }
  13504. if (advanceX <= textOrientation * textContentItem.notASpace) {
  13505. resetLastChars();
  13506. }
  13507. if (advanceX <= textOrientation * textContentItem.trackingSpaceMin) {
  13508. if (shouldAddWhitepsace()) {
  13509. resetLastChars();
  13510. flushTextContentItem();
  13511. pushWhitespace({
  13512. width: Math.abs(advanceX)
  13513. });
  13514. } else {
  13515. textContentItem.width += advanceX;
  13516. }
  13517. } else if (!addFakeSpaces(advanceX, textContentItem.prevTransform, textOrientation)) {
  13518. if (textContentItem.str.length === 0) {
  13519. resetLastChars();
  13520. pushWhitespace({
  13521. width: Math.abs(advanceX)
  13522. });
  13523. } else {
  13524. textContentItem.width += advanceX;
  13525. }
  13526. }
  13527. if (Math.abs(advanceY) > textContentItem.height * VERTICAL_SHIFT_RATIO) {
  13528. flushTextContentItem();
  13529. }
  13530. return true;
  13531. }
  13532. function buildTextContentItem(_ref9) {
  13533. let {
  13534. chars,
  13535. extraSpacing
  13536. } = _ref9;
  13537. const font = textState.font;
  13538. if (!chars) {
  13539. const charSpacing = textState.charSpacing + extraSpacing;
  13540. if (charSpacing) {
  13541. if (!font.vertical) {
  13542. textState.translateTextMatrix(charSpacing * textState.textHScale, 0);
  13543. } else {
  13544. textState.translateTextMatrix(0, -charSpacing);
  13545. }
  13546. }
  13547. return;
  13548. }
  13549. const glyphs = font.charsToGlyphs(chars);
  13550. const scale = textState.fontMatrix[0] * textState.fontSize;
  13551. for (let i = 0, ii = glyphs.length; i < ii; i++) {
  13552. const glyph = glyphs[i];
  13553. const {
  13554. category
  13555. } = glyph;
  13556. if (category.isInvisibleFormatMark) {
  13557. continue;
  13558. }
  13559. let charSpacing = textState.charSpacing + (i + 1 === ii ? extraSpacing : 0);
  13560. let glyphWidth = glyph.width;
  13561. if (font.vertical) {
  13562. glyphWidth = glyph.vmetric ? glyph.vmetric[0] : -glyphWidth;
  13563. }
  13564. let scaledDim = glyphWidth * scale;
  13565. if (category.isWhitespace) {
  13566. if (!font.vertical) {
  13567. charSpacing += scaledDim + textState.wordSpacing;
  13568. textState.translateTextMatrix(charSpacing * textState.textHScale, 0);
  13569. } else {
  13570. charSpacing += -scaledDim + textState.wordSpacing;
  13571. textState.translateTextMatrix(0, -charSpacing);
  13572. }
  13573. saveLastChar(" ");
  13574. continue;
  13575. }
  13576. if (!category.isZeroWidthDiacritic && !compareWithLastPosition(scaledDim)) {
  13577. if (!font.vertical) {
  13578. textState.translateTextMatrix(scaledDim * textState.textHScale, 0);
  13579. } else {
  13580. textState.translateTextMatrix(0, scaledDim);
  13581. }
  13582. continue;
  13583. }
  13584. const textChunk = ensureTextContentItem();
  13585. if (category.isZeroWidthDiacritic) {
  13586. scaledDim = 0;
  13587. }
  13588. if (!font.vertical) {
  13589. scaledDim *= textState.textHScale;
  13590. textState.translateTextMatrix(scaledDim, 0);
  13591. textChunk.width += scaledDim;
  13592. } else {
  13593. textState.translateTextMatrix(0, scaledDim);
  13594. scaledDim = Math.abs(scaledDim);
  13595. textChunk.height += scaledDim;
  13596. }
  13597. if (scaledDim) {
  13598. textChunk.prevTransform = getCurrentTextTransform();
  13599. }
  13600. const glyphUnicode = glyph.unicode;
  13601. if (saveLastChar(glyphUnicode)) {
  13602. textChunk.str.push(" ");
  13603. }
  13604. textChunk.str.push(glyphUnicode);
  13605. if (charSpacing) {
  13606. if (!font.vertical) {
  13607. textState.translateTextMatrix(charSpacing * textState.textHScale, 0);
  13608. } else {
  13609. textState.translateTextMatrix(0, -charSpacing);
  13610. }
  13611. }
  13612. }
  13613. }
  13614. function appendEOL() {
  13615. resetLastChars();
  13616. if (textContentItem.initialized) {
  13617. textContentItem.hasEOL = true;
  13618. flushTextContentItem();
  13619. } else {
  13620. textContent.items.push({
  13621. str: "",
  13622. dir: "ltr",
  13623. width: 0,
  13624. height: 0,
  13625. transform: getCurrentTextTransform(),
  13626. fontName: textState.loadedName,
  13627. hasEOL: true
  13628. });
  13629. }
  13630. }
  13631. function addFakeSpaces(width, transf, textOrientation) {
  13632. if (textOrientation * textContentItem.spaceInFlowMin <= width && width <= textOrientation * textContentItem.spaceInFlowMax) {
  13633. if (textContentItem.initialized) {
  13634. resetLastChars();
  13635. textContentItem.str.push(" ");
  13636. }
  13637. return false;
  13638. }
  13639. const fontName = textContentItem.fontName;
  13640. let height = 0;
  13641. if (textContentItem.vertical) {
  13642. height = width;
  13643. width = 0;
  13644. }
  13645. flushTextContentItem();
  13646. resetLastChars();
  13647. pushWhitespace({
  13648. width: Math.abs(width),
  13649. height: Math.abs(height),
  13650. transform: transf || getCurrentTextTransform(),
  13651. fontName
  13652. });
  13653. return true;
  13654. }
  13655. function flushTextContentItem() {
  13656. if (!textContentItem.initialized || !textContentItem.str) {
  13657. return;
  13658. }
  13659. if (!textContentItem.vertical) {
  13660. textContentItem.totalWidth += textContentItem.width * textContentItem.textAdvanceScale;
  13661. } else {
  13662. textContentItem.totalHeight += textContentItem.height * textContentItem.textAdvanceScale;
  13663. }
  13664. textContent.items.push(runBidiTransform(textContentItem));
  13665. textContentItem.initialized = false;
  13666. textContentItem.str.length = 0;
  13667. }
  13668. function enqueueChunk() {
  13669. let batch = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  13670. const length = textContent.items.length;
  13671. if (length === 0) {
  13672. return;
  13673. }
  13674. if (batch && length < TEXT_CHUNK_BATCH_SIZE) {
  13675. return;
  13676. }
  13677. sink.enqueue(textContent, length);
  13678. textContent.items = [];
  13679. textContent.styles = Object.create(null);
  13680. }
  13681. const timeSlotManager = new TimeSlotManager();
  13682. return new Promise(function promiseBody(resolve, reject) {
  13683. const next = function (promise) {
  13684. enqueueChunk(true);
  13685. Promise.all([promise, sink.ready]).then(function () {
  13686. try {
  13687. promiseBody(resolve, reject);
  13688. } catch (ex) {
  13689. reject(ex);
  13690. }
  13691. }, reject);
  13692. };
  13693. task.ensureNotTerminated();
  13694. timeSlotManager.reset();
  13695. const operation = {};
  13696. let stop,
  13697. args = [];
  13698. while (!(stop = timeSlotManager.check())) {
  13699. args.length = 0;
  13700. operation.args = args;
  13701. if (!preprocessor.read(operation)) {
  13702. break;
  13703. }
  13704. const previousState = textState;
  13705. textState = stateManager.state;
  13706. const fn = operation.fn;
  13707. args = operation.args;
  13708. switch (fn | 0) {
  13709. case _util.OPS.setFont:
  13710. var fontNameArg = args[0].name,
  13711. fontSizeArg = args[1];
  13712. if (textState.font && fontNameArg === textState.fontName && fontSizeArg === textState.fontSize) {
  13713. break;
  13714. }
  13715. flushTextContentItem();
  13716. textState.fontName = fontNameArg;
  13717. textState.fontSize = fontSizeArg;
  13718. next(handleSetFont(fontNameArg, null));
  13719. return;
  13720. case _util.OPS.setTextRise:
  13721. textState.textRise = args[0];
  13722. break;
  13723. case _util.OPS.setHScale:
  13724. textState.textHScale = args[0] / 100;
  13725. break;
  13726. case _util.OPS.setLeading:
  13727. textState.leading = args[0];
  13728. break;
  13729. case _util.OPS.moveText:
  13730. textState.translateTextLineMatrix(args[0], args[1]);
  13731. textState.textMatrix = textState.textLineMatrix.slice();
  13732. break;
  13733. case _util.OPS.setLeadingMoveText:
  13734. textState.leading = -args[1];
  13735. textState.translateTextLineMatrix(args[0], args[1]);
  13736. textState.textMatrix = textState.textLineMatrix.slice();
  13737. break;
  13738. case _util.OPS.nextLine:
  13739. textState.carriageReturn();
  13740. break;
  13741. case _util.OPS.setTextMatrix:
  13742. textState.setTextMatrix(args[0], args[1], args[2], args[3], args[4], args[5]);
  13743. textState.setTextLineMatrix(args[0], args[1], args[2], args[3], args[4], args[5]);
  13744. updateAdvanceScale();
  13745. break;
  13746. case _util.OPS.setCharSpacing:
  13747. textState.charSpacing = args[0];
  13748. break;
  13749. case _util.OPS.setWordSpacing:
  13750. textState.wordSpacing = args[0];
  13751. break;
  13752. case _util.OPS.beginText:
  13753. textState.textMatrix = _util.IDENTITY_MATRIX.slice();
  13754. textState.textLineMatrix = _util.IDENTITY_MATRIX.slice();
  13755. break;
  13756. case _util.OPS.showSpacedText:
  13757. if (!stateManager.state.font) {
  13758. self.ensureStateFont(stateManager.state);
  13759. continue;
  13760. }
  13761. const spaceFactor = (textState.font.vertical ? 1 : -1) * textState.fontSize / 1000;
  13762. const elements = args[0];
  13763. for (let i = 0, ii = elements.length; i < ii; i++) {
  13764. const item = elements[i];
  13765. if (typeof item === "string") {
  13766. showSpacedTextBuffer.push(item);
  13767. } else if (typeof item === "number" && item !== 0) {
  13768. const str = showSpacedTextBuffer.join("");
  13769. showSpacedTextBuffer.length = 0;
  13770. buildTextContentItem({
  13771. chars: str,
  13772. extraSpacing: item * spaceFactor
  13773. });
  13774. }
  13775. }
  13776. if (showSpacedTextBuffer.length > 0) {
  13777. const str = showSpacedTextBuffer.join("");
  13778. showSpacedTextBuffer.length = 0;
  13779. buildTextContentItem({
  13780. chars: str,
  13781. extraSpacing: 0
  13782. });
  13783. }
  13784. break;
  13785. case _util.OPS.showText:
  13786. if (!stateManager.state.font) {
  13787. self.ensureStateFont(stateManager.state);
  13788. continue;
  13789. }
  13790. buildTextContentItem({
  13791. chars: args[0],
  13792. extraSpacing: 0
  13793. });
  13794. break;
  13795. case _util.OPS.nextLineShowText:
  13796. if (!stateManager.state.font) {
  13797. self.ensureStateFont(stateManager.state);
  13798. continue;
  13799. }
  13800. textState.carriageReturn();
  13801. buildTextContentItem({
  13802. chars: args[0],
  13803. extraSpacing: 0
  13804. });
  13805. break;
  13806. case _util.OPS.nextLineSetSpacingShowText:
  13807. if (!stateManager.state.font) {
  13808. self.ensureStateFont(stateManager.state);
  13809. continue;
  13810. }
  13811. textState.wordSpacing = args[0];
  13812. textState.charSpacing = args[1];
  13813. textState.carriageReturn();
  13814. buildTextContentItem({
  13815. chars: args[2],
  13816. extraSpacing: 0
  13817. });
  13818. break;
  13819. case _util.OPS.paintXObject:
  13820. flushTextContentItem();
  13821. if (!xobjs) {
  13822. xobjs = resources.get("XObject") || _primitives.Dict.empty;
  13823. }
  13824. var isValidName = args[0] instanceof _primitives.Name;
  13825. var name = args[0].name;
  13826. if (isValidName && emptyXObjectCache.getByName(name)) {
  13827. break;
  13828. }
  13829. next(new Promise(function (resolveXObject, rejectXObject) {
  13830. if (!isValidName) {
  13831. throw new _util.FormatError("XObject must be referred to by name.");
  13832. }
  13833. let xobj = xobjs.getRaw(name);
  13834. if (xobj instanceof _primitives.Ref) {
  13835. if (emptyXObjectCache.getByRef(xobj)) {
  13836. resolveXObject();
  13837. return;
  13838. }
  13839. const globalImage = self.globalImageCache.getData(xobj, self.pageIndex);
  13840. if (globalImage) {
  13841. resolveXObject();
  13842. return;
  13843. }
  13844. xobj = xref.fetch(xobj);
  13845. }
  13846. if (!(xobj instanceof _base_stream.BaseStream)) {
  13847. throw new _util.FormatError("XObject should be a stream");
  13848. }
  13849. const type = xobj.dict.get("Subtype");
  13850. if (!(type instanceof _primitives.Name)) {
  13851. throw new _util.FormatError("XObject should have a Name subtype");
  13852. }
  13853. if (type.name !== "Form") {
  13854. emptyXObjectCache.set(name, xobj.dict.objId, true);
  13855. resolveXObject();
  13856. return;
  13857. }
  13858. const currentState = stateManager.state.clone();
  13859. const xObjStateManager = new StateManager(currentState);
  13860. const matrix = xobj.dict.getArray("Matrix");
  13861. if (Array.isArray(matrix) && matrix.length === 6) {
  13862. xObjStateManager.transform(matrix);
  13863. }
  13864. enqueueChunk();
  13865. const sinkWrapper = {
  13866. enqueueInvoked: false,
  13867. enqueue(chunk, size) {
  13868. this.enqueueInvoked = true;
  13869. sink.enqueue(chunk, size);
  13870. },
  13871. get desiredSize() {
  13872. return sink.desiredSize;
  13873. },
  13874. get ready() {
  13875. return sink.ready;
  13876. }
  13877. };
  13878. self.getTextContent({
  13879. stream: xobj,
  13880. task,
  13881. resources: xobj.dict.get("Resources") || resources,
  13882. stateManager: xObjStateManager,
  13883. includeMarkedContent,
  13884. sink: sinkWrapper,
  13885. seenStyles,
  13886. viewBox,
  13887. markedContentData,
  13888. disableNormalization
  13889. }).then(function () {
  13890. if (!sinkWrapper.enqueueInvoked) {
  13891. emptyXObjectCache.set(name, xobj.dict.objId, true);
  13892. }
  13893. resolveXObject();
  13894. }, rejectXObject);
  13895. }).catch(function (reason) {
  13896. if (reason instanceof _util.AbortException) {
  13897. return;
  13898. }
  13899. if (self.options.ignoreErrors) {
  13900. (0, _util.warn)(`getTextContent - ignoring XObject: "${reason}".`);
  13901. return;
  13902. }
  13903. throw reason;
  13904. }));
  13905. return;
  13906. case _util.OPS.setGState:
  13907. isValidName = args[0] instanceof _primitives.Name;
  13908. name = args[0].name;
  13909. if (isValidName && emptyGStateCache.getByName(name)) {
  13910. break;
  13911. }
  13912. next(new Promise(function (resolveGState, rejectGState) {
  13913. if (!isValidName) {
  13914. throw new _util.FormatError("GState must be referred to by name.");
  13915. }
  13916. const extGState = resources.get("ExtGState");
  13917. if (!(extGState instanceof _primitives.Dict)) {
  13918. throw new _util.FormatError("ExtGState should be a dictionary.");
  13919. }
  13920. const gState = extGState.get(name);
  13921. if (!(gState instanceof _primitives.Dict)) {
  13922. throw new _util.FormatError("GState should be a dictionary.");
  13923. }
  13924. const gStateFont = gState.get("Font");
  13925. if (!gStateFont) {
  13926. emptyGStateCache.set(name, gState.objId, true);
  13927. resolveGState();
  13928. return;
  13929. }
  13930. flushTextContentItem();
  13931. textState.fontName = null;
  13932. textState.fontSize = gStateFont[1];
  13933. handleSetFont(null, gStateFont[0]).then(resolveGState, rejectGState);
  13934. }).catch(function (reason) {
  13935. if (reason instanceof _util.AbortException) {
  13936. return;
  13937. }
  13938. if (self.options.ignoreErrors) {
  13939. (0, _util.warn)(`getTextContent - ignoring ExtGState: "${reason}".`);
  13940. return;
  13941. }
  13942. throw reason;
  13943. }));
  13944. return;
  13945. case _util.OPS.beginMarkedContent:
  13946. flushTextContentItem();
  13947. if (includeMarkedContent) {
  13948. markedContentData.level++;
  13949. textContent.items.push({
  13950. type: "beginMarkedContent",
  13951. tag: args[0] instanceof _primitives.Name ? args[0].name : null
  13952. });
  13953. }
  13954. break;
  13955. case _util.OPS.beginMarkedContentProps:
  13956. flushTextContentItem();
  13957. if (includeMarkedContent) {
  13958. markedContentData.level++;
  13959. let mcid = null;
  13960. if (args[1] instanceof _primitives.Dict) {
  13961. mcid = args[1].get("MCID");
  13962. }
  13963. textContent.items.push({
  13964. type: "beginMarkedContentProps",
  13965. id: Number.isInteger(mcid) ? `${self.idFactory.getPageObjId()}_mc${mcid}` : null,
  13966. tag: args[0] instanceof _primitives.Name ? args[0].name : null
  13967. });
  13968. }
  13969. break;
  13970. case _util.OPS.endMarkedContent:
  13971. flushTextContentItem();
  13972. if (includeMarkedContent) {
  13973. if (markedContentData.level === 0) {
  13974. break;
  13975. }
  13976. markedContentData.level--;
  13977. textContent.items.push({
  13978. type: "endMarkedContent"
  13979. });
  13980. }
  13981. break;
  13982. case _util.OPS.restore:
  13983. if (previousState && (previousState.font !== textState.font || previousState.fontSize !== textState.fontSize || previousState.fontName !== textState.fontName)) {
  13984. flushTextContentItem();
  13985. }
  13986. break;
  13987. }
  13988. if (textContent.items.length >= sink.desiredSize) {
  13989. stop = true;
  13990. break;
  13991. }
  13992. }
  13993. if (stop) {
  13994. next(deferred);
  13995. return;
  13996. }
  13997. flushTextContentItem();
  13998. enqueueChunk();
  13999. resolve();
  14000. }).catch(reason => {
  14001. if (reason instanceof _util.AbortException) {
  14002. return;
  14003. }
  14004. if (this.options.ignoreErrors) {
  14005. (0, _util.warn)(`getTextContent - ignoring errors during "${task.name}" ` + `task: "${reason}".`);
  14006. flushTextContentItem();
  14007. enqueueChunk();
  14008. return;
  14009. }
  14010. throw reason;
  14011. });
  14012. }
  14013. extractDataStructures(dict, baseDict, properties) {
  14014. const xref = this.xref;
  14015. let cidToGidBytes;
  14016. const toUnicodePromise = this.readToUnicode(properties.toUnicode || dict.get("ToUnicode") || baseDict.get("ToUnicode"));
  14017. if (properties.composite) {
  14018. const cidSystemInfo = dict.get("CIDSystemInfo");
  14019. if (cidSystemInfo instanceof _primitives.Dict) {
  14020. properties.cidSystemInfo = {
  14021. registry: (0, _util.stringToPDFString)(cidSystemInfo.get("Registry")),
  14022. ordering: (0, _util.stringToPDFString)(cidSystemInfo.get("Ordering")),
  14023. supplement: cidSystemInfo.get("Supplement")
  14024. };
  14025. }
  14026. try {
  14027. const cidToGidMap = dict.get("CIDToGIDMap");
  14028. if (cidToGidMap instanceof _base_stream.BaseStream) {
  14029. cidToGidBytes = cidToGidMap.getBytes();
  14030. }
  14031. } catch (ex) {
  14032. if (!this.options.ignoreErrors) {
  14033. throw ex;
  14034. }
  14035. (0, _util.warn)(`extractDataStructures - ignoring CIDToGIDMap data: "${ex}".`);
  14036. }
  14037. }
  14038. const differences = [];
  14039. let baseEncodingName = null;
  14040. let encoding;
  14041. if (dict.has("Encoding")) {
  14042. encoding = dict.get("Encoding");
  14043. if (encoding instanceof _primitives.Dict) {
  14044. baseEncodingName = encoding.get("BaseEncoding");
  14045. baseEncodingName = baseEncodingName instanceof _primitives.Name ? baseEncodingName.name : null;
  14046. if (encoding.has("Differences")) {
  14047. const diffEncoding = encoding.get("Differences");
  14048. let index = 0;
  14049. for (const entry of diffEncoding) {
  14050. const data = xref.fetchIfRef(entry);
  14051. if (typeof data === "number") {
  14052. index = data;
  14053. } else if (data instanceof _primitives.Name) {
  14054. differences[index++] = data.name;
  14055. } else {
  14056. throw new _util.FormatError(`Invalid entry in 'Differences' array: ${data}`);
  14057. }
  14058. }
  14059. }
  14060. } else if (encoding instanceof _primitives.Name) {
  14061. baseEncodingName = encoding.name;
  14062. } else {
  14063. const msg = "Encoding is not a Name nor a Dict";
  14064. if (!this.options.ignoreErrors) {
  14065. throw new _util.FormatError(msg);
  14066. }
  14067. (0, _util.warn)(msg);
  14068. }
  14069. if (baseEncodingName !== "MacRomanEncoding" && baseEncodingName !== "MacExpertEncoding" && baseEncodingName !== "WinAnsiEncoding") {
  14070. baseEncodingName = null;
  14071. }
  14072. }
  14073. const nonEmbeddedFont = !properties.file || properties.isInternalFont,
  14074. isSymbolsFontName = (0, _standard_fonts.getSymbolsFonts)()[properties.name];
  14075. if (baseEncodingName && nonEmbeddedFont && isSymbolsFontName) {
  14076. baseEncodingName = null;
  14077. }
  14078. if (baseEncodingName) {
  14079. properties.defaultEncoding = (0, _encodings.getEncoding)(baseEncodingName);
  14080. } else {
  14081. const isSymbolicFont = !!(properties.flags & _fonts_utils.FontFlags.Symbolic);
  14082. const isNonsymbolicFont = !!(properties.flags & _fonts_utils.FontFlags.Nonsymbolic);
  14083. encoding = _encodings.StandardEncoding;
  14084. if (properties.type === "TrueType" && !isNonsymbolicFont) {
  14085. encoding = _encodings.WinAnsiEncoding;
  14086. }
  14087. if (isSymbolicFont || isSymbolsFontName) {
  14088. encoding = _encodings.MacRomanEncoding;
  14089. if (nonEmbeddedFont) {
  14090. if (/Symbol/i.test(properties.name)) {
  14091. encoding = _encodings.SymbolSetEncoding;
  14092. } else if (/Dingbats/i.test(properties.name)) {
  14093. encoding = _encodings.ZapfDingbatsEncoding;
  14094. } else if (/Wingdings/i.test(properties.name)) {
  14095. encoding = _encodings.WinAnsiEncoding;
  14096. }
  14097. }
  14098. }
  14099. properties.defaultEncoding = encoding;
  14100. }
  14101. properties.differences = differences;
  14102. properties.baseEncodingName = baseEncodingName;
  14103. properties.hasEncoding = !!baseEncodingName || differences.length > 0;
  14104. properties.dict = dict;
  14105. return toUnicodePromise.then(readToUnicode => {
  14106. properties.toUnicode = readToUnicode;
  14107. return this.buildToUnicode(properties);
  14108. }).then(builtToUnicode => {
  14109. properties.toUnicode = builtToUnicode;
  14110. if (cidToGidBytes) {
  14111. properties.cidToGidMap = this.readCidToGidMap(cidToGidBytes, builtToUnicode);
  14112. }
  14113. return properties;
  14114. });
  14115. }
  14116. _simpleFontToUnicode(properties) {
  14117. let forceGlyphs = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  14118. (0, _util.assert)(!properties.composite, "Must be a simple font.");
  14119. const toUnicode = [];
  14120. const encoding = properties.defaultEncoding.slice();
  14121. const baseEncodingName = properties.baseEncodingName;
  14122. const differences = properties.differences;
  14123. for (const charcode in differences) {
  14124. const glyphName = differences[charcode];
  14125. if (glyphName === ".notdef") {
  14126. continue;
  14127. }
  14128. encoding[charcode] = glyphName;
  14129. }
  14130. const glyphsUnicodeMap = (0, _glyphlist.getGlyphsUnicode)();
  14131. for (const charcode in encoding) {
  14132. let glyphName = encoding[charcode];
  14133. if (glyphName === "") {
  14134. continue;
  14135. }
  14136. let unicode = glyphsUnicodeMap[glyphName];
  14137. if (unicode !== undefined) {
  14138. toUnicode[charcode] = String.fromCharCode(unicode);
  14139. continue;
  14140. }
  14141. let code = 0;
  14142. switch (glyphName[0]) {
  14143. case "G":
  14144. if (glyphName.length === 3) {
  14145. code = parseInt(glyphName.substring(1), 16);
  14146. }
  14147. break;
  14148. case "g":
  14149. if (glyphName.length === 5) {
  14150. code = parseInt(glyphName.substring(1), 16);
  14151. }
  14152. break;
  14153. case "C":
  14154. case "c":
  14155. if (glyphName.length >= 3 && glyphName.length <= 4) {
  14156. const codeStr = glyphName.substring(1);
  14157. if (forceGlyphs) {
  14158. code = parseInt(codeStr, 16);
  14159. break;
  14160. }
  14161. code = +codeStr;
  14162. if (Number.isNaN(code) && Number.isInteger(parseInt(codeStr, 16))) {
  14163. return this._simpleFontToUnicode(properties, true);
  14164. }
  14165. }
  14166. break;
  14167. case "u":
  14168. unicode = (0, _unicode.getUnicodeForGlyph)(glyphName, glyphsUnicodeMap);
  14169. if (unicode !== -1) {
  14170. code = unicode;
  14171. }
  14172. break;
  14173. default:
  14174. switch (glyphName) {
  14175. case "f_h":
  14176. case "f_t":
  14177. case "T_h":
  14178. toUnicode[charcode] = glyphName.replaceAll("_", "");
  14179. continue;
  14180. }
  14181. break;
  14182. }
  14183. if (code > 0 && code <= 0x10ffff && Number.isInteger(code)) {
  14184. if (baseEncodingName && code === +charcode) {
  14185. const baseEncoding = (0, _encodings.getEncoding)(baseEncodingName);
  14186. if (baseEncoding && (glyphName = baseEncoding[charcode])) {
  14187. toUnicode[charcode] = String.fromCharCode(glyphsUnicodeMap[glyphName]);
  14188. continue;
  14189. }
  14190. }
  14191. toUnicode[charcode] = String.fromCodePoint(code);
  14192. }
  14193. }
  14194. return toUnicode;
  14195. }
  14196. async buildToUnicode(properties) {
  14197. properties.hasIncludedToUnicodeMap = properties.toUnicode?.length > 0;
  14198. if (properties.hasIncludedToUnicodeMap) {
  14199. if (!properties.composite && properties.hasEncoding) {
  14200. properties.fallbackToUnicode = this._simpleFontToUnicode(properties);
  14201. }
  14202. return properties.toUnicode;
  14203. }
  14204. if (!properties.composite) {
  14205. return new _to_unicode_map.ToUnicodeMap(this._simpleFontToUnicode(properties));
  14206. }
  14207. 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"))) {
  14208. const {
  14209. registry,
  14210. ordering
  14211. } = properties.cidSystemInfo;
  14212. const ucs2CMapName = _primitives.Name.get(`${registry}-${ordering}-UCS2`);
  14213. const ucs2CMap = await _cmap.CMapFactory.create({
  14214. encoding: ucs2CMapName,
  14215. fetchBuiltInCMap: this._fetchBuiltInCMapBound,
  14216. useCMap: null
  14217. });
  14218. const toUnicode = [],
  14219. buf = [];
  14220. properties.cMap.forEach(function (charcode, cid) {
  14221. if (cid > 0xffff) {
  14222. throw new _util.FormatError("Max size of CID is 65,535");
  14223. }
  14224. const ucs2 = ucs2CMap.lookup(cid);
  14225. if (ucs2) {
  14226. buf.length = 0;
  14227. for (let i = 0, ii = ucs2.length; i < ii; i += 2) {
  14228. buf.push((ucs2.charCodeAt(i) << 8) + ucs2.charCodeAt(i + 1));
  14229. }
  14230. toUnicode[charcode] = String.fromCharCode(...buf);
  14231. }
  14232. });
  14233. return new _to_unicode_map.ToUnicodeMap(toUnicode);
  14234. }
  14235. return new _to_unicode_map.IdentityToUnicodeMap(properties.firstChar, properties.lastChar);
  14236. }
  14237. readToUnicode(cmapObj) {
  14238. if (!cmapObj) {
  14239. return Promise.resolve(null);
  14240. }
  14241. if (cmapObj instanceof _primitives.Name) {
  14242. return _cmap.CMapFactory.create({
  14243. encoding: cmapObj,
  14244. fetchBuiltInCMap: this._fetchBuiltInCMapBound,
  14245. useCMap: null
  14246. }).then(function (cmap) {
  14247. if (cmap instanceof _cmap.IdentityCMap) {
  14248. return new _to_unicode_map.IdentityToUnicodeMap(0, 0xffff);
  14249. }
  14250. return new _to_unicode_map.ToUnicodeMap(cmap.getMap());
  14251. });
  14252. } else if (cmapObj instanceof _base_stream.BaseStream) {
  14253. return _cmap.CMapFactory.create({
  14254. encoding: cmapObj,
  14255. fetchBuiltInCMap: this._fetchBuiltInCMapBound,
  14256. useCMap: null
  14257. }).then(function (cmap) {
  14258. if (cmap instanceof _cmap.IdentityCMap) {
  14259. return new _to_unicode_map.IdentityToUnicodeMap(0, 0xffff);
  14260. }
  14261. const map = new Array(cmap.length);
  14262. cmap.forEach(function (charCode, token) {
  14263. if (typeof token === "number") {
  14264. map[charCode] = String.fromCodePoint(token);
  14265. return;
  14266. }
  14267. const str = [];
  14268. for (let k = 0; k < token.length; k += 2) {
  14269. const w1 = token.charCodeAt(k) << 8 | token.charCodeAt(k + 1);
  14270. if ((w1 & 0xf800) !== 0xd800) {
  14271. str.push(w1);
  14272. continue;
  14273. }
  14274. k += 2;
  14275. const w2 = token.charCodeAt(k) << 8 | token.charCodeAt(k + 1);
  14276. str.push(((w1 & 0x3ff) << 10) + (w2 & 0x3ff) + 0x10000);
  14277. }
  14278. map[charCode] = String.fromCodePoint(...str);
  14279. });
  14280. return new _to_unicode_map.ToUnicodeMap(map);
  14281. }, reason => {
  14282. if (reason instanceof _util.AbortException) {
  14283. return null;
  14284. }
  14285. if (this.options.ignoreErrors) {
  14286. (0, _util.warn)(`readToUnicode - ignoring ToUnicode data: "${reason}".`);
  14287. return null;
  14288. }
  14289. throw reason;
  14290. });
  14291. }
  14292. return Promise.resolve(null);
  14293. }
  14294. readCidToGidMap(glyphsData, toUnicode) {
  14295. const result = [];
  14296. for (let j = 0, jj = glyphsData.length; j < jj; j++) {
  14297. const glyphID = glyphsData[j++] << 8 | glyphsData[j];
  14298. const code = j >> 1;
  14299. if (glyphID === 0 && !toUnicode.has(code)) {
  14300. continue;
  14301. }
  14302. result[code] = glyphID;
  14303. }
  14304. return result;
  14305. }
  14306. extractWidths(dict, descriptor, properties) {
  14307. const xref = this.xref;
  14308. let glyphsWidths = [];
  14309. let defaultWidth = 0;
  14310. const glyphsVMetrics = [];
  14311. let defaultVMetrics;
  14312. let i, ii, j, jj, start, code, widths;
  14313. if (properties.composite) {
  14314. defaultWidth = dict.has("DW") ? dict.get("DW") : 1000;
  14315. widths = dict.get("W");
  14316. if (widths) {
  14317. for (i = 0, ii = widths.length; i < ii; i++) {
  14318. start = xref.fetchIfRef(widths[i++]);
  14319. code = xref.fetchIfRef(widths[i]);
  14320. if (Array.isArray(code)) {
  14321. for (j = 0, jj = code.length; j < jj; j++) {
  14322. glyphsWidths[start++] = xref.fetchIfRef(code[j]);
  14323. }
  14324. } else {
  14325. const width = xref.fetchIfRef(widths[++i]);
  14326. for (j = start; j <= code; j++) {
  14327. glyphsWidths[j] = width;
  14328. }
  14329. }
  14330. }
  14331. }
  14332. if (properties.vertical) {
  14333. let vmetrics = dict.getArray("DW2") || [880, -1000];
  14334. defaultVMetrics = [vmetrics[1], defaultWidth * 0.5, vmetrics[0]];
  14335. vmetrics = dict.get("W2");
  14336. if (vmetrics) {
  14337. for (i = 0, ii = vmetrics.length; i < ii; i++) {
  14338. start = xref.fetchIfRef(vmetrics[i++]);
  14339. code = xref.fetchIfRef(vmetrics[i]);
  14340. if (Array.isArray(code)) {
  14341. for (j = 0, jj = code.length; j < jj; j++) {
  14342. glyphsVMetrics[start++] = [xref.fetchIfRef(code[j++]), xref.fetchIfRef(code[j++]), xref.fetchIfRef(code[j])];
  14343. }
  14344. } else {
  14345. const vmetric = [xref.fetchIfRef(vmetrics[++i]), xref.fetchIfRef(vmetrics[++i]), xref.fetchIfRef(vmetrics[++i])];
  14346. for (j = start; j <= code; j++) {
  14347. glyphsVMetrics[j] = vmetric;
  14348. }
  14349. }
  14350. }
  14351. }
  14352. }
  14353. } else {
  14354. const firstChar = properties.firstChar;
  14355. widths = dict.get("Widths");
  14356. if (widths) {
  14357. j = firstChar;
  14358. for (i = 0, ii = widths.length; i < ii; i++) {
  14359. glyphsWidths[j++] = xref.fetchIfRef(widths[i]);
  14360. }
  14361. defaultWidth = parseFloat(descriptor.get("MissingWidth")) || 0;
  14362. } else {
  14363. const baseFontName = dict.get("BaseFont");
  14364. if (baseFontName instanceof _primitives.Name) {
  14365. const metrics = this.getBaseFontMetrics(baseFontName.name);
  14366. glyphsWidths = this.buildCharCodeToWidth(metrics.widths, properties);
  14367. defaultWidth = metrics.defaultWidth;
  14368. }
  14369. }
  14370. }
  14371. let isMonospace = true;
  14372. let firstWidth = defaultWidth;
  14373. for (const glyph in glyphsWidths) {
  14374. const glyphWidth = glyphsWidths[glyph];
  14375. if (!glyphWidth) {
  14376. continue;
  14377. }
  14378. if (!firstWidth) {
  14379. firstWidth = glyphWidth;
  14380. continue;
  14381. }
  14382. if (firstWidth !== glyphWidth) {
  14383. isMonospace = false;
  14384. break;
  14385. }
  14386. }
  14387. if (isMonospace) {
  14388. properties.flags |= _fonts_utils.FontFlags.FixedPitch;
  14389. } else {
  14390. properties.flags &= ~_fonts_utils.FontFlags.FixedPitch;
  14391. }
  14392. properties.defaultWidth = defaultWidth;
  14393. properties.widths = glyphsWidths;
  14394. properties.defaultVMetrics = defaultVMetrics;
  14395. properties.vmetrics = glyphsVMetrics;
  14396. }
  14397. isSerifFont(baseFontName) {
  14398. const fontNameWoStyle = baseFontName.split("-")[0];
  14399. return fontNameWoStyle in (0, _standard_fonts.getSerifFonts)() || /serif/gi.test(fontNameWoStyle);
  14400. }
  14401. getBaseFontMetrics(name) {
  14402. let defaultWidth = 0;
  14403. let widths = Object.create(null);
  14404. let monospace = false;
  14405. const stdFontMap = (0, _standard_fonts.getStdFontMap)();
  14406. let lookupName = stdFontMap[name] || name;
  14407. const Metrics = (0, _metrics.getMetrics)();
  14408. if (!(lookupName in Metrics)) {
  14409. lookupName = this.isSerifFont(name) ? "Times-Roman" : "Helvetica";
  14410. }
  14411. const glyphWidths = Metrics[lookupName];
  14412. if (typeof glyphWidths === "number") {
  14413. defaultWidth = glyphWidths;
  14414. monospace = true;
  14415. } else {
  14416. widths = glyphWidths();
  14417. }
  14418. return {
  14419. defaultWidth,
  14420. monospace,
  14421. widths
  14422. };
  14423. }
  14424. buildCharCodeToWidth(widthsByGlyphName, properties) {
  14425. const widths = Object.create(null);
  14426. const differences = properties.differences;
  14427. const encoding = properties.defaultEncoding;
  14428. for (let charCode = 0; charCode < 256; charCode++) {
  14429. if (charCode in differences && widthsByGlyphName[differences[charCode]]) {
  14430. widths[charCode] = widthsByGlyphName[differences[charCode]];
  14431. continue;
  14432. }
  14433. if (charCode in encoding && widthsByGlyphName[encoding[charCode]]) {
  14434. widths[charCode] = widthsByGlyphName[encoding[charCode]];
  14435. continue;
  14436. }
  14437. }
  14438. return widths;
  14439. }
  14440. preEvaluateFont(dict) {
  14441. const baseDict = dict;
  14442. let type = dict.get("Subtype");
  14443. if (!(type instanceof _primitives.Name)) {
  14444. throw new _util.FormatError("invalid font Subtype");
  14445. }
  14446. let composite = false;
  14447. let hash, toUnicode;
  14448. if (type.name === "Type0") {
  14449. const df = dict.get("DescendantFonts");
  14450. if (!df) {
  14451. throw new _util.FormatError("Descendant fonts are not specified");
  14452. }
  14453. dict = Array.isArray(df) ? this.xref.fetchIfRef(df[0]) : df;
  14454. if (!(dict instanceof _primitives.Dict)) {
  14455. throw new _util.FormatError("Descendant font is not a dictionary.");
  14456. }
  14457. type = dict.get("Subtype");
  14458. if (!(type instanceof _primitives.Name)) {
  14459. throw new _util.FormatError("invalid font Subtype");
  14460. }
  14461. composite = true;
  14462. }
  14463. const firstChar = dict.get("FirstChar") || 0,
  14464. lastChar = dict.get("LastChar") || (composite ? 0xffff : 0xff);
  14465. const descriptor = dict.get("FontDescriptor");
  14466. if (descriptor) {
  14467. hash = new _murmurhash.MurmurHash3_64();
  14468. const encoding = baseDict.getRaw("Encoding");
  14469. if (encoding instanceof _primitives.Name) {
  14470. hash.update(encoding.name);
  14471. } else if (encoding instanceof _primitives.Ref) {
  14472. hash.update(encoding.toString());
  14473. } else if (encoding instanceof _primitives.Dict) {
  14474. for (const entry of encoding.getRawValues()) {
  14475. if (entry instanceof _primitives.Name) {
  14476. hash.update(entry.name);
  14477. } else if (entry instanceof _primitives.Ref) {
  14478. hash.update(entry.toString());
  14479. } else if (Array.isArray(entry)) {
  14480. const diffLength = entry.length,
  14481. diffBuf = new Array(diffLength);
  14482. for (let j = 0; j < diffLength; j++) {
  14483. const diffEntry = entry[j];
  14484. if (diffEntry instanceof _primitives.Name) {
  14485. diffBuf[j] = diffEntry.name;
  14486. } else if (typeof diffEntry === "number" || diffEntry instanceof _primitives.Ref) {
  14487. diffBuf[j] = diffEntry.toString();
  14488. }
  14489. }
  14490. hash.update(diffBuf.join());
  14491. }
  14492. }
  14493. }
  14494. hash.update(`${firstChar}-${lastChar}`);
  14495. toUnicode = dict.get("ToUnicode") || baseDict.get("ToUnicode");
  14496. if (toUnicode instanceof _base_stream.BaseStream) {
  14497. const stream = toUnicode.str || toUnicode;
  14498. const uint8array = stream.buffer ? new Uint8Array(stream.buffer.buffer, 0, stream.bufferLength) : new Uint8Array(stream.bytes.buffer, stream.start, stream.end - stream.start);
  14499. hash.update(uint8array);
  14500. } else if (toUnicode instanceof _primitives.Name) {
  14501. hash.update(toUnicode.name);
  14502. }
  14503. const widths = dict.get("Widths") || baseDict.get("Widths");
  14504. if (Array.isArray(widths)) {
  14505. const widthsBuf = [];
  14506. for (const entry of widths) {
  14507. if (typeof entry === "number" || entry instanceof _primitives.Ref) {
  14508. widthsBuf.push(entry.toString());
  14509. }
  14510. }
  14511. hash.update(widthsBuf.join());
  14512. }
  14513. if (composite) {
  14514. hash.update("compositeFont");
  14515. const compositeWidths = dict.get("W") || baseDict.get("W");
  14516. if (Array.isArray(compositeWidths)) {
  14517. const widthsBuf = [];
  14518. for (const entry of compositeWidths) {
  14519. if (typeof entry === "number" || entry instanceof _primitives.Ref) {
  14520. widthsBuf.push(entry.toString());
  14521. } else if (Array.isArray(entry)) {
  14522. const subWidthsBuf = [];
  14523. for (const element of entry) {
  14524. if (typeof element === "number" || element instanceof _primitives.Ref) {
  14525. subWidthsBuf.push(element.toString());
  14526. }
  14527. }
  14528. widthsBuf.push(`[${subWidthsBuf.join()}]`);
  14529. }
  14530. }
  14531. hash.update(widthsBuf.join());
  14532. }
  14533. const cidToGidMap = dict.getRaw("CIDToGIDMap") || baseDict.getRaw("CIDToGIDMap");
  14534. if (cidToGidMap instanceof _primitives.Name) {
  14535. hash.update(cidToGidMap.name);
  14536. } else if (cidToGidMap instanceof _primitives.Ref) {
  14537. hash.update(cidToGidMap.toString());
  14538. } else if (cidToGidMap instanceof _base_stream.BaseStream) {
  14539. hash.update(cidToGidMap.peekBytes());
  14540. }
  14541. }
  14542. }
  14543. return {
  14544. descriptor,
  14545. dict,
  14546. baseDict,
  14547. composite,
  14548. type: type.name,
  14549. firstChar,
  14550. lastChar,
  14551. toUnicode,
  14552. hash: hash ? hash.hexdigest() : ""
  14553. };
  14554. }
  14555. async translateFont(_ref10) {
  14556. let {
  14557. descriptor,
  14558. dict,
  14559. baseDict,
  14560. composite,
  14561. type,
  14562. firstChar,
  14563. lastChar,
  14564. toUnicode,
  14565. cssFontInfo
  14566. } = _ref10;
  14567. const isType3Font = type === "Type3";
  14568. let properties;
  14569. if (!descriptor) {
  14570. if (isType3Font) {
  14571. descriptor = new _primitives.Dict(null);
  14572. descriptor.set("FontName", _primitives.Name.get(type));
  14573. descriptor.set("FontBBox", dict.getArray("FontBBox") || [0, 0, 0, 0]);
  14574. } else {
  14575. let baseFontName = dict.get("BaseFont");
  14576. if (!(baseFontName instanceof _primitives.Name)) {
  14577. throw new _util.FormatError("Base font is not specified");
  14578. }
  14579. baseFontName = baseFontName.name.replaceAll(/[,_]/g, "-");
  14580. const metrics = this.getBaseFontMetrics(baseFontName);
  14581. const fontNameWoStyle = baseFontName.split("-")[0];
  14582. 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);
  14583. properties = {
  14584. type,
  14585. name: baseFontName,
  14586. loadedName: baseDict.loadedName,
  14587. systemFontInfo: null,
  14588. widths: metrics.widths,
  14589. defaultWidth: metrics.defaultWidth,
  14590. isSimulatedFlags: true,
  14591. flags,
  14592. firstChar,
  14593. lastChar,
  14594. toUnicode,
  14595. xHeight: 0,
  14596. capHeight: 0,
  14597. italicAngle: 0,
  14598. isType3Font
  14599. };
  14600. const widths = dict.get("Widths");
  14601. const standardFontName = (0, _standard_fonts.getStandardFontName)(baseFontName);
  14602. let file = null;
  14603. if (standardFontName) {
  14604. file = await this.fetchStandardFontData(standardFontName);
  14605. properties.isInternalFont = !!file;
  14606. }
  14607. if (!properties.isInternalFont && this.options.useSystemFonts) {
  14608. properties.systemFontInfo = (0, _font_substitutions.getFontSubstitution)(this.systemFontCache, this.idFactory, this.options.standardFontDataUrl, baseFontName, standardFontName);
  14609. }
  14610. return this.extractDataStructures(dict, dict, properties).then(newProperties => {
  14611. if (widths) {
  14612. const glyphWidths = [];
  14613. let j = firstChar;
  14614. for (const width of widths) {
  14615. glyphWidths[j++] = this.xref.fetchIfRef(width);
  14616. }
  14617. newProperties.widths = glyphWidths;
  14618. } else {
  14619. newProperties.widths = this.buildCharCodeToWidth(metrics.widths, newProperties);
  14620. }
  14621. return new _fonts.Font(baseFontName, file, newProperties);
  14622. });
  14623. }
  14624. }
  14625. let fontName = descriptor.get("FontName");
  14626. let baseFont = dict.get("BaseFont");
  14627. if (typeof fontName === "string") {
  14628. fontName = _primitives.Name.get(fontName);
  14629. }
  14630. if (typeof baseFont === "string") {
  14631. baseFont = _primitives.Name.get(baseFont);
  14632. }
  14633. const fontNameStr = fontName?.name;
  14634. const baseFontStr = baseFont?.name;
  14635. if (!isType3Font && fontNameStr !== baseFontStr) {
  14636. (0, _util.info)(`The FontDescriptor's FontName is "${fontNameStr}" but ` + `should be the same as the Font's BaseFont "${baseFontStr}".`);
  14637. if (fontNameStr && baseFontStr && (baseFontStr.startsWith(fontNameStr) || !(0, _standard_fonts.isKnownFontName)(fontNameStr) && (0, _standard_fonts.isKnownFontName)(baseFontStr))) {
  14638. fontName = null;
  14639. }
  14640. }
  14641. fontName ||= baseFont;
  14642. if (!(fontName instanceof _primitives.Name)) {
  14643. throw new _util.FormatError("invalid font name");
  14644. }
  14645. let fontFile, subtype, length1, length2, length3;
  14646. try {
  14647. fontFile = descriptor.get("FontFile", "FontFile2", "FontFile3");
  14648. } catch (ex) {
  14649. if (!this.options.ignoreErrors) {
  14650. throw ex;
  14651. }
  14652. (0, _util.warn)(`translateFont - fetching "${fontName.name}" font file: "${ex}".`);
  14653. fontFile = new _stream.NullStream();
  14654. }
  14655. let isInternalFont = false;
  14656. let glyphScaleFactors = null;
  14657. let systemFontInfo = null;
  14658. if (fontFile) {
  14659. if (fontFile.dict) {
  14660. const subtypeEntry = fontFile.dict.get("Subtype");
  14661. if (subtypeEntry instanceof _primitives.Name) {
  14662. subtype = subtypeEntry.name;
  14663. }
  14664. length1 = fontFile.dict.get("Length1");
  14665. length2 = fontFile.dict.get("Length2");
  14666. length3 = fontFile.dict.get("Length3");
  14667. }
  14668. } else if (cssFontInfo) {
  14669. const standardFontName = (0, _xfa_fonts.getXfaFontName)(fontName.name);
  14670. if (standardFontName) {
  14671. cssFontInfo.fontFamily = `${cssFontInfo.fontFamily}-PdfJS-XFA`;
  14672. cssFontInfo.metrics = standardFontName.metrics || null;
  14673. glyphScaleFactors = standardFontName.factors || null;
  14674. fontFile = await this.fetchStandardFontData(standardFontName.name);
  14675. isInternalFont = !!fontFile;
  14676. baseDict = dict = (0, _xfa_fonts.getXfaFontDict)(fontName.name);
  14677. composite = true;
  14678. }
  14679. } else if (!isType3Font) {
  14680. const standardFontName = (0, _standard_fonts.getStandardFontName)(fontName.name);
  14681. if (standardFontName) {
  14682. fontFile = await this.fetchStandardFontData(standardFontName);
  14683. isInternalFont = !!fontFile;
  14684. }
  14685. if (!isInternalFont && this.options.useSystemFonts) {
  14686. systemFontInfo = (0, _font_substitutions.getFontSubstitution)(this.systemFontCache, this.idFactory, this.options.standardFontDataUrl, fontName.name, standardFontName);
  14687. }
  14688. }
  14689. properties = {
  14690. type,
  14691. name: fontName.name,
  14692. subtype,
  14693. file: fontFile,
  14694. length1,
  14695. length2,
  14696. length3,
  14697. isInternalFont,
  14698. loadedName: baseDict.loadedName,
  14699. composite,
  14700. fixedPitch: false,
  14701. fontMatrix: dict.getArray("FontMatrix") || _util.FONT_IDENTITY_MATRIX,
  14702. firstChar,
  14703. lastChar,
  14704. toUnicode,
  14705. bbox: descriptor.getArray("FontBBox") || dict.getArray("FontBBox"),
  14706. ascent: descriptor.get("Ascent"),
  14707. descent: descriptor.get("Descent"),
  14708. xHeight: descriptor.get("XHeight") || 0,
  14709. capHeight: descriptor.get("CapHeight") || 0,
  14710. flags: descriptor.get("Flags"),
  14711. italicAngle: descriptor.get("ItalicAngle") || 0,
  14712. isType3Font,
  14713. cssFontInfo,
  14714. scaleFactors: glyphScaleFactors,
  14715. systemFontInfo
  14716. };
  14717. if (composite) {
  14718. const cidEncoding = baseDict.get("Encoding");
  14719. if (cidEncoding instanceof _primitives.Name) {
  14720. properties.cidEncoding = cidEncoding.name;
  14721. }
  14722. const cMap = await _cmap.CMapFactory.create({
  14723. encoding: cidEncoding,
  14724. fetchBuiltInCMap: this._fetchBuiltInCMapBound,
  14725. useCMap: null
  14726. });
  14727. properties.cMap = cMap;
  14728. properties.vertical = properties.cMap.vertical;
  14729. }
  14730. return this.extractDataStructures(dict, baseDict, properties).then(newProperties => {
  14731. this.extractWidths(dict, descriptor, newProperties);
  14732. return new _fonts.Font(fontName.name, fontFile, newProperties);
  14733. });
  14734. }
  14735. static buildFontPaths(font, glyphs, handler, evaluatorOptions) {
  14736. function buildPath(fontChar) {
  14737. const glyphName = `${font.loadedName}_path_${fontChar}`;
  14738. try {
  14739. if (font.renderer.hasBuiltPath(fontChar)) {
  14740. return;
  14741. }
  14742. handler.send("commonobj", [glyphName, "FontPath", font.renderer.getPathJs(fontChar)]);
  14743. } catch (reason) {
  14744. if (evaluatorOptions.ignoreErrors) {
  14745. (0, _util.warn)(`buildFontPaths - ignoring ${glyphName} glyph: "${reason}".`);
  14746. return;
  14747. }
  14748. throw reason;
  14749. }
  14750. }
  14751. for (const glyph of glyphs) {
  14752. buildPath(glyph.fontChar);
  14753. const accent = glyph.accent;
  14754. if (accent?.fontChar) {
  14755. buildPath(accent.fontChar);
  14756. }
  14757. }
  14758. }
  14759. static get fallbackFontDict() {
  14760. const dict = new _primitives.Dict();
  14761. dict.set("BaseFont", _primitives.Name.get("Helvetica"));
  14762. dict.set("Type", _primitives.Name.get("FallbackType"));
  14763. dict.set("Subtype", _primitives.Name.get("FallbackType"));
  14764. dict.set("Encoding", _primitives.Name.get("WinAnsiEncoding"));
  14765. return (0, _util.shadow)(this, "fallbackFontDict", dict);
  14766. }
  14767. }
  14768. exports.PartialEvaluator = PartialEvaluator;
  14769. class TranslatedFont {
  14770. constructor(_ref11) {
  14771. let {
  14772. loadedName,
  14773. font,
  14774. dict,
  14775. evaluatorOptions
  14776. } = _ref11;
  14777. this.loadedName = loadedName;
  14778. this.font = font;
  14779. this.dict = dict;
  14780. this._evaluatorOptions = evaluatorOptions || DefaultPartialEvaluatorOptions;
  14781. this.type3Loaded = null;
  14782. this.type3Dependencies = font.isType3Font ? new Set() : null;
  14783. this.sent = false;
  14784. }
  14785. send(handler) {
  14786. if (this.sent) {
  14787. return;
  14788. }
  14789. this.sent = true;
  14790. handler.send("commonobj", [this.loadedName, "Font", this.font.exportData(this._evaluatorOptions.fontExtraProperties)]);
  14791. }
  14792. fallback(handler) {
  14793. if (!this.font.data) {
  14794. return;
  14795. }
  14796. this.font.disableFontFace = true;
  14797. PartialEvaluator.buildFontPaths(this.font, this.font.glyphCacheValues, handler, this._evaluatorOptions);
  14798. }
  14799. loadType3Data(evaluator, resources, task) {
  14800. if (this.type3Loaded) {
  14801. return this.type3Loaded;
  14802. }
  14803. if (!this.font.isType3Font) {
  14804. throw new Error("Must be a Type3 font.");
  14805. }
  14806. const type3Evaluator = evaluator.clone({
  14807. ignoreErrors: false
  14808. });
  14809. type3Evaluator.parsingType3Font = true;
  14810. const type3FontRefs = new _primitives.RefSet(evaluator.type3FontRefs);
  14811. if (this.dict.objId && !type3FontRefs.has(this.dict.objId)) {
  14812. type3FontRefs.put(this.dict.objId);
  14813. }
  14814. type3Evaluator.type3FontRefs = type3FontRefs;
  14815. const translatedFont = this.font,
  14816. type3Dependencies = this.type3Dependencies;
  14817. let loadCharProcsPromise = Promise.resolve();
  14818. const charProcs = this.dict.get("CharProcs");
  14819. const fontResources = this.dict.get("Resources") || resources;
  14820. const charProcOperatorList = Object.create(null);
  14821. const fontBBox = _util.Util.normalizeRect(translatedFont.bbox || [0, 0, 0, 0]),
  14822. width = fontBBox[2] - fontBBox[0],
  14823. height = fontBBox[3] - fontBBox[1];
  14824. const fontBBoxSize = Math.hypot(width, height);
  14825. for (const key of charProcs.getKeys()) {
  14826. loadCharProcsPromise = loadCharProcsPromise.then(() => {
  14827. const glyphStream = charProcs.get(key);
  14828. const operatorList = new _operator_list.OperatorList();
  14829. return type3Evaluator.getOperatorList({
  14830. stream: glyphStream,
  14831. task,
  14832. resources: fontResources,
  14833. operatorList
  14834. }).then(() => {
  14835. if (operatorList.fnArray[0] === _util.OPS.setCharWidthAndBounds) {
  14836. this._removeType3ColorOperators(operatorList, fontBBoxSize);
  14837. }
  14838. charProcOperatorList[key] = operatorList.getIR();
  14839. for (const dependency of operatorList.dependencies) {
  14840. type3Dependencies.add(dependency);
  14841. }
  14842. }).catch(function (reason) {
  14843. (0, _util.warn)(`Type3 font resource "${key}" is not available.`);
  14844. const dummyOperatorList = new _operator_list.OperatorList();
  14845. charProcOperatorList[key] = dummyOperatorList.getIR();
  14846. });
  14847. });
  14848. }
  14849. this.type3Loaded = loadCharProcsPromise.then(() => {
  14850. translatedFont.charProcOperatorList = charProcOperatorList;
  14851. if (this._bbox) {
  14852. translatedFont.isCharBBox = true;
  14853. translatedFont.bbox = this._bbox;
  14854. }
  14855. });
  14856. return this.type3Loaded;
  14857. }
  14858. _removeType3ColorOperators(operatorList) {
  14859. let fontBBoxSize = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : NaN;
  14860. const charBBox = _util.Util.normalizeRect(operatorList.argsArray[0].slice(2)),
  14861. width = charBBox[2] - charBBox[0],
  14862. height = charBBox[3] - charBBox[1];
  14863. const charBBoxSize = Math.hypot(width, height);
  14864. if (width === 0 || height === 0) {
  14865. operatorList.fnArray.splice(0, 1);
  14866. operatorList.argsArray.splice(0, 1);
  14867. } else if (fontBBoxSize === 0 || Math.round(charBBoxSize / fontBBoxSize) >= 10) {
  14868. if (!this._bbox) {
  14869. this._bbox = [Infinity, Infinity, -Infinity, -Infinity];
  14870. }
  14871. this._bbox[0] = Math.min(this._bbox[0], charBBox[0]);
  14872. this._bbox[1] = Math.min(this._bbox[1], charBBox[1]);
  14873. this._bbox[2] = Math.max(this._bbox[2], charBBox[2]);
  14874. this._bbox[3] = Math.max(this._bbox[3], charBBox[3]);
  14875. }
  14876. let i = 0,
  14877. ii = operatorList.length;
  14878. while (i < ii) {
  14879. switch (operatorList.fnArray[i]) {
  14880. case _util.OPS.setCharWidthAndBounds:
  14881. break;
  14882. case _util.OPS.setStrokeColorSpace:
  14883. case _util.OPS.setFillColorSpace:
  14884. case _util.OPS.setStrokeColor:
  14885. case _util.OPS.setStrokeColorN:
  14886. case _util.OPS.setFillColor:
  14887. case _util.OPS.setFillColorN:
  14888. case _util.OPS.setStrokeGray:
  14889. case _util.OPS.setFillGray:
  14890. case _util.OPS.setStrokeRGBColor:
  14891. case _util.OPS.setFillRGBColor:
  14892. case _util.OPS.setStrokeCMYKColor:
  14893. case _util.OPS.setFillCMYKColor:
  14894. case _util.OPS.shadingFill:
  14895. case _util.OPS.setRenderingIntent:
  14896. operatorList.fnArray.splice(i, 1);
  14897. operatorList.argsArray.splice(i, 1);
  14898. ii--;
  14899. continue;
  14900. case _util.OPS.setGState:
  14901. const [gStateObj] = operatorList.argsArray[i];
  14902. let j = 0,
  14903. jj = gStateObj.length;
  14904. while (j < jj) {
  14905. const [gStateKey] = gStateObj[j];
  14906. switch (gStateKey) {
  14907. case "TR":
  14908. case "TR2":
  14909. case "HT":
  14910. case "BG":
  14911. case "BG2":
  14912. case "UCR":
  14913. case "UCR2":
  14914. gStateObj.splice(j, 1);
  14915. jj--;
  14916. continue;
  14917. }
  14918. j++;
  14919. }
  14920. break;
  14921. }
  14922. i++;
  14923. }
  14924. }
  14925. }
  14926. class StateManager {
  14927. constructor() {
  14928. let initialState = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : new EvalState();
  14929. this.state = initialState;
  14930. this.stateStack = [];
  14931. }
  14932. save() {
  14933. const old = this.state;
  14934. this.stateStack.push(this.state);
  14935. this.state = old.clone();
  14936. }
  14937. restore() {
  14938. const prev = this.stateStack.pop();
  14939. if (prev) {
  14940. this.state = prev;
  14941. }
  14942. }
  14943. transform(args) {
  14944. this.state.ctm = _util.Util.transform(this.state.ctm, args);
  14945. }
  14946. }
  14947. class TextState {
  14948. constructor() {
  14949. this.ctm = new Float32Array(_util.IDENTITY_MATRIX);
  14950. this.fontName = null;
  14951. this.fontSize = 0;
  14952. this.loadedName = null;
  14953. this.font = null;
  14954. this.fontMatrix = _util.FONT_IDENTITY_MATRIX;
  14955. this.textMatrix = _util.IDENTITY_MATRIX.slice();
  14956. this.textLineMatrix = _util.IDENTITY_MATRIX.slice();
  14957. this.charSpacing = 0;
  14958. this.wordSpacing = 0;
  14959. this.leading = 0;
  14960. this.textHScale = 1;
  14961. this.textRise = 0;
  14962. }
  14963. setTextMatrix(a, b, c, d, e, f) {
  14964. const m = this.textMatrix;
  14965. m[0] = a;
  14966. m[1] = b;
  14967. m[2] = c;
  14968. m[3] = d;
  14969. m[4] = e;
  14970. m[5] = f;
  14971. }
  14972. setTextLineMatrix(a, b, c, d, e, f) {
  14973. const m = this.textLineMatrix;
  14974. m[0] = a;
  14975. m[1] = b;
  14976. m[2] = c;
  14977. m[3] = d;
  14978. m[4] = e;
  14979. m[5] = f;
  14980. }
  14981. translateTextMatrix(x, y) {
  14982. const m = this.textMatrix;
  14983. m[4] = m[0] * x + m[2] * y + m[4];
  14984. m[5] = m[1] * x + m[3] * y + m[5];
  14985. }
  14986. translateTextLineMatrix(x, y) {
  14987. const m = this.textLineMatrix;
  14988. m[4] = m[0] * x + m[2] * y + m[4];
  14989. m[5] = m[1] * x + m[3] * y + m[5];
  14990. }
  14991. carriageReturn() {
  14992. this.translateTextLineMatrix(0, -this.leading);
  14993. this.textMatrix = this.textLineMatrix.slice();
  14994. }
  14995. clone() {
  14996. const clone = Object.create(this);
  14997. clone.textMatrix = this.textMatrix.slice();
  14998. clone.textLineMatrix = this.textLineMatrix.slice();
  14999. clone.fontMatrix = this.fontMatrix.slice();
  15000. return clone;
  15001. }
  15002. }
  15003. class EvalState {
  15004. constructor() {
  15005. this.ctm = new Float32Array(_util.IDENTITY_MATRIX);
  15006. this.font = null;
  15007. this.textRenderingMode = _util.TextRenderingMode.FILL;
  15008. this.fillColorSpace = _colorspace.ColorSpace.singletons.gray;
  15009. this.strokeColorSpace = _colorspace.ColorSpace.singletons.gray;
  15010. }
  15011. clone() {
  15012. return Object.create(this);
  15013. }
  15014. }
  15015. class EvaluatorPreprocessor {
  15016. static get opMap() {
  15017. const getOPMap = (0, _core_utils.getLookupTableFactory)(function (t) {
  15018. t.w = {
  15019. id: _util.OPS.setLineWidth,
  15020. numArgs: 1,
  15021. variableArgs: false
  15022. };
  15023. t.J = {
  15024. id: _util.OPS.setLineCap,
  15025. numArgs: 1,
  15026. variableArgs: false
  15027. };
  15028. t.j = {
  15029. id: _util.OPS.setLineJoin,
  15030. numArgs: 1,
  15031. variableArgs: false
  15032. };
  15033. t.M = {
  15034. id: _util.OPS.setMiterLimit,
  15035. numArgs: 1,
  15036. variableArgs: false
  15037. };
  15038. t.d = {
  15039. id: _util.OPS.setDash,
  15040. numArgs: 2,
  15041. variableArgs: false
  15042. };
  15043. t.ri = {
  15044. id: _util.OPS.setRenderingIntent,
  15045. numArgs: 1,
  15046. variableArgs: false
  15047. };
  15048. t.i = {
  15049. id: _util.OPS.setFlatness,
  15050. numArgs: 1,
  15051. variableArgs: false
  15052. };
  15053. t.gs = {
  15054. id: _util.OPS.setGState,
  15055. numArgs: 1,
  15056. variableArgs: false
  15057. };
  15058. t.q = {
  15059. id: _util.OPS.save,
  15060. numArgs: 0,
  15061. variableArgs: false
  15062. };
  15063. t.Q = {
  15064. id: _util.OPS.restore,
  15065. numArgs: 0,
  15066. variableArgs: false
  15067. };
  15068. t.cm = {
  15069. id: _util.OPS.transform,
  15070. numArgs: 6,
  15071. variableArgs: false
  15072. };
  15073. t.m = {
  15074. id: _util.OPS.moveTo,
  15075. numArgs: 2,
  15076. variableArgs: false
  15077. };
  15078. t.l = {
  15079. id: _util.OPS.lineTo,
  15080. numArgs: 2,
  15081. variableArgs: false
  15082. };
  15083. t.c = {
  15084. id: _util.OPS.curveTo,
  15085. numArgs: 6,
  15086. variableArgs: false
  15087. };
  15088. t.v = {
  15089. id: _util.OPS.curveTo2,
  15090. numArgs: 4,
  15091. variableArgs: false
  15092. };
  15093. t.y = {
  15094. id: _util.OPS.curveTo3,
  15095. numArgs: 4,
  15096. variableArgs: false
  15097. };
  15098. t.h = {
  15099. id: _util.OPS.closePath,
  15100. numArgs: 0,
  15101. variableArgs: false
  15102. };
  15103. t.re = {
  15104. id: _util.OPS.rectangle,
  15105. numArgs: 4,
  15106. variableArgs: false
  15107. };
  15108. t.S = {
  15109. id: _util.OPS.stroke,
  15110. numArgs: 0,
  15111. variableArgs: false
  15112. };
  15113. t.s = {
  15114. id: _util.OPS.closeStroke,
  15115. numArgs: 0,
  15116. variableArgs: false
  15117. };
  15118. t.f = {
  15119. id: _util.OPS.fill,
  15120. numArgs: 0,
  15121. variableArgs: false
  15122. };
  15123. t.F = {
  15124. id: _util.OPS.fill,
  15125. numArgs: 0,
  15126. variableArgs: false
  15127. };
  15128. t["f*"] = {
  15129. id: _util.OPS.eoFill,
  15130. numArgs: 0,
  15131. variableArgs: false
  15132. };
  15133. t.B = {
  15134. id: _util.OPS.fillStroke,
  15135. numArgs: 0,
  15136. variableArgs: false
  15137. };
  15138. t["B*"] = {
  15139. id: _util.OPS.eoFillStroke,
  15140. numArgs: 0,
  15141. variableArgs: false
  15142. };
  15143. t.b = {
  15144. id: _util.OPS.closeFillStroke,
  15145. numArgs: 0,
  15146. variableArgs: false
  15147. };
  15148. t["b*"] = {
  15149. id: _util.OPS.closeEOFillStroke,
  15150. numArgs: 0,
  15151. variableArgs: false
  15152. };
  15153. t.n = {
  15154. id: _util.OPS.endPath,
  15155. numArgs: 0,
  15156. variableArgs: false
  15157. };
  15158. t.W = {
  15159. id: _util.OPS.clip,
  15160. numArgs: 0,
  15161. variableArgs: false
  15162. };
  15163. t["W*"] = {
  15164. id: _util.OPS.eoClip,
  15165. numArgs: 0,
  15166. variableArgs: false
  15167. };
  15168. t.BT = {
  15169. id: _util.OPS.beginText,
  15170. numArgs: 0,
  15171. variableArgs: false
  15172. };
  15173. t.ET = {
  15174. id: _util.OPS.endText,
  15175. numArgs: 0,
  15176. variableArgs: false
  15177. };
  15178. t.Tc = {
  15179. id: _util.OPS.setCharSpacing,
  15180. numArgs: 1,
  15181. variableArgs: false
  15182. };
  15183. t.Tw = {
  15184. id: _util.OPS.setWordSpacing,
  15185. numArgs: 1,
  15186. variableArgs: false
  15187. };
  15188. t.Tz = {
  15189. id: _util.OPS.setHScale,
  15190. numArgs: 1,
  15191. variableArgs: false
  15192. };
  15193. t.TL = {
  15194. id: _util.OPS.setLeading,
  15195. numArgs: 1,
  15196. variableArgs: false
  15197. };
  15198. t.Tf = {
  15199. id: _util.OPS.setFont,
  15200. numArgs: 2,
  15201. variableArgs: false
  15202. };
  15203. t.Tr = {
  15204. id: _util.OPS.setTextRenderingMode,
  15205. numArgs: 1,
  15206. variableArgs: false
  15207. };
  15208. t.Ts = {
  15209. id: _util.OPS.setTextRise,
  15210. numArgs: 1,
  15211. variableArgs: false
  15212. };
  15213. t.Td = {
  15214. id: _util.OPS.moveText,
  15215. numArgs: 2,
  15216. variableArgs: false
  15217. };
  15218. t.TD = {
  15219. id: _util.OPS.setLeadingMoveText,
  15220. numArgs: 2,
  15221. variableArgs: false
  15222. };
  15223. t.Tm = {
  15224. id: _util.OPS.setTextMatrix,
  15225. numArgs: 6,
  15226. variableArgs: false
  15227. };
  15228. t["T*"] = {
  15229. id: _util.OPS.nextLine,
  15230. numArgs: 0,
  15231. variableArgs: false
  15232. };
  15233. t.Tj = {
  15234. id: _util.OPS.showText,
  15235. numArgs: 1,
  15236. variableArgs: false
  15237. };
  15238. t.TJ = {
  15239. id: _util.OPS.showSpacedText,
  15240. numArgs: 1,
  15241. variableArgs: false
  15242. };
  15243. t["'"] = {
  15244. id: _util.OPS.nextLineShowText,
  15245. numArgs: 1,
  15246. variableArgs: false
  15247. };
  15248. t['"'] = {
  15249. id: _util.OPS.nextLineSetSpacingShowText,
  15250. numArgs: 3,
  15251. variableArgs: false
  15252. };
  15253. t.d0 = {
  15254. id: _util.OPS.setCharWidth,
  15255. numArgs: 2,
  15256. variableArgs: false
  15257. };
  15258. t.d1 = {
  15259. id: _util.OPS.setCharWidthAndBounds,
  15260. numArgs: 6,
  15261. variableArgs: false
  15262. };
  15263. t.CS = {
  15264. id: _util.OPS.setStrokeColorSpace,
  15265. numArgs: 1,
  15266. variableArgs: false
  15267. };
  15268. t.cs = {
  15269. id: _util.OPS.setFillColorSpace,
  15270. numArgs: 1,
  15271. variableArgs: false
  15272. };
  15273. t.SC = {
  15274. id: _util.OPS.setStrokeColor,
  15275. numArgs: 4,
  15276. variableArgs: true
  15277. };
  15278. t.SCN = {
  15279. id: _util.OPS.setStrokeColorN,
  15280. numArgs: 33,
  15281. variableArgs: true
  15282. };
  15283. t.sc = {
  15284. id: _util.OPS.setFillColor,
  15285. numArgs: 4,
  15286. variableArgs: true
  15287. };
  15288. t.scn = {
  15289. id: _util.OPS.setFillColorN,
  15290. numArgs: 33,
  15291. variableArgs: true
  15292. };
  15293. t.G = {
  15294. id: _util.OPS.setStrokeGray,
  15295. numArgs: 1,
  15296. variableArgs: false
  15297. };
  15298. t.g = {
  15299. id: _util.OPS.setFillGray,
  15300. numArgs: 1,
  15301. variableArgs: false
  15302. };
  15303. t.RG = {
  15304. id: _util.OPS.setStrokeRGBColor,
  15305. numArgs: 3,
  15306. variableArgs: false
  15307. };
  15308. t.rg = {
  15309. id: _util.OPS.setFillRGBColor,
  15310. numArgs: 3,
  15311. variableArgs: false
  15312. };
  15313. t.K = {
  15314. id: _util.OPS.setStrokeCMYKColor,
  15315. numArgs: 4,
  15316. variableArgs: false
  15317. };
  15318. t.k = {
  15319. id: _util.OPS.setFillCMYKColor,
  15320. numArgs: 4,
  15321. variableArgs: false
  15322. };
  15323. t.sh = {
  15324. id: _util.OPS.shadingFill,
  15325. numArgs: 1,
  15326. variableArgs: false
  15327. };
  15328. t.BI = {
  15329. id: _util.OPS.beginInlineImage,
  15330. numArgs: 0,
  15331. variableArgs: false
  15332. };
  15333. t.ID = {
  15334. id: _util.OPS.beginImageData,
  15335. numArgs: 0,
  15336. variableArgs: false
  15337. };
  15338. t.EI = {
  15339. id: _util.OPS.endInlineImage,
  15340. numArgs: 1,
  15341. variableArgs: false
  15342. };
  15343. t.Do = {
  15344. id: _util.OPS.paintXObject,
  15345. numArgs: 1,
  15346. variableArgs: false
  15347. };
  15348. t.MP = {
  15349. id: _util.OPS.markPoint,
  15350. numArgs: 1,
  15351. variableArgs: false
  15352. };
  15353. t.DP = {
  15354. id: _util.OPS.markPointProps,
  15355. numArgs: 2,
  15356. variableArgs: false
  15357. };
  15358. t.BMC = {
  15359. id: _util.OPS.beginMarkedContent,
  15360. numArgs: 1,
  15361. variableArgs: false
  15362. };
  15363. t.BDC = {
  15364. id: _util.OPS.beginMarkedContentProps,
  15365. numArgs: 2,
  15366. variableArgs: false
  15367. };
  15368. t.EMC = {
  15369. id: _util.OPS.endMarkedContent,
  15370. numArgs: 0,
  15371. variableArgs: false
  15372. };
  15373. t.BX = {
  15374. id: _util.OPS.beginCompat,
  15375. numArgs: 0,
  15376. variableArgs: false
  15377. };
  15378. t.EX = {
  15379. id: _util.OPS.endCompat,
  15380. numArgs: 0,
  15381. variableArgs: false
  15382. };
  15383. t.BM = null;
  15384. t.BD = null;
  15385. t.true = null;
  15386. t.fa = null;
  15387. t.fal = null;
  15388. t.fals = null;
  15389. t.false = null;
  15390. t.nu = null;
  15391. t.nul = null;
  15392. t.null = null;
  15393. });
  15394. return (0, _util.shadow)(this, "opMap", getOPMap());
  15395. }
  15396. static MAX_INVALID_PATH_OPS = 10;
  15397. constructor(stream, xref) {
  15398. let stateManager = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : new StateManager();
  15399. this.parser = new _parser.Parser({
  15400. lexer: new _parser.Lexer(stream, EvaluatorPreprocessor.opMap),
  15401. xref
  15402. });
  15403. this.stateManager = stateManager;
  15404. this.nonProcessedArgs = [];
  15405. this._isPathOp = false;
  15406. this._numInvalidPathOPS = 0;
  15407. }
  15408. get savedStatesDepth() {
  15409. return this.stateManager.stateStack.length;
  15410. }
  15411. read(operation) {
  15412. let args = operation.args;
  15413. while (true) {
  15414. const obj = this.parser.getObj();
  15415. if (obj instanceof _primitives.Cmd) {
  15416. const cmd = obj.cmd;
  15417. const opSpec = EvaluatorPreprocessor.opMap[cmd];
  15418. if (!opSpec) {
  15419. (0, _util.warn)(`Unknown command "${cmd}".`);
  15420. continue;
  15421. }
  15422. const fn = opSpec.id;
  15423. const numArgs = opSpec.numArgs;
  15424. let argsLength = args !== null ? args.length : 0;
  15425. if (!this._isPathOp) {
  15426. this._numInvalidPathOPS = 0;
  15427. }
  15428. this._isPathOp = fn >= _util.OPS.moveTo && fn <= _util.OPS.endPath;
  15429. if (!opSpec.variableArgs) {
  15430. if (argsLength !== numArgs) {
  15431. const nonProcessedArgs = this.nonProcessedArgs;
  15432. while (argsLength > numArgs) {
  15433. nonProcessedArgs.push(args.shift());
  15434. argsLength--;
  15435. }
  15436. while (argsLength < numArgs && nonProcessedArgs.length !== 0) {
  15437. if (args === null) {
  15438. args = [];
  15439. }
  15440. args.unshift(nonProcessedArgs.pop());
  15441. argsLength++;
  15442. }
  15443. }
  15444. if (argsLength < numArgs) {
  15445. const partialMsg = `command ${cmd}: expected ${numArgs} args, ` + `but received ${argsLength} args.`;
  15446. if (this._isPathOp && ++this._numInvalidPathOPS > EvaluatorPreprocessor.MAX_INVALID_PATH_OPS) {
  15447. throw new _util.FormatError(`Invalid ${partialMsg}`);
  15448. }
  15449. (0, _util.warn)(`Skipping ${partialMsg}`);
  15450. if (args !== null) {
  15451. args.length = 0;
  15452. }
  15453. continue;
  15454. }
  15455. } else if (argsLength > numArgs) {
  15456. (0, _util.info)(`Command ${cmd}: expected [0, ${numArgs}] args, ` + `but received ${argsLength} args.`);
  15457. }
  15458. this.preprocessCommand(fn, args);
  15459. operation.fn = fn;
  15460. operation.args = args;
  15461. return true;
  15462. }
  15463. if (obj === _primitives.EOF) {
  15464. return false;
  15465. }
  15466. if (obj !== null) {
  15467. if (args === null) {
  15468. args = [];
  15469. }
  15470. args.push(obj);
  15471. if (args.length > 33) {
  15472. throw new _util.FormatError("Too many arguments");
  15473. }
  15474. }
  15475. }
  15476. }
  15477. preprocessCommand(fn, args) {
  15478. switch (fn | 0) {
  15479. case _util.OPS.save:
  15480. this.stateManager.save();
  15481. break;
  15482. case _util.OPS.restore:
  15483. this.stateManager.restore();
  15484. break;
  15485. case _util.OPS.transform:
  15486. this.stateManager.transform(args);
  15487. break;
  15488. }
  15489. }
  15490. }
  15491. exports.EvaluatorPreprocessor = EvaluatorPreprocessor;
  15492. /***/ }),
  15493. /* 165 */
  15494. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  15495. Object.defineProperty(exports, "__esModule", ({
  15496. value: true
  15497. }));
  15498. exports.IdentityCMap = exports.CMapFactory = exports.CMap = void 0;
  15499. __w_pdfjs_require__(140);
  15500. __w_pdfjs_require__(2);
  15501. var _util = __w_pdfjs_require__(145);
  15502. var _primitives = __w_pdfjs_require__(151);
  15503. var _base_stream = __w_pdfjs_require__(152);
  15504. var _binary_cmap = __w_pdfjs_require__(166);
  15505. var _parser = __w_pdfjs_require__(167);
  15506. var _core_utils = __w_pdfjs_require__(150);
  15507. var _stream = __w_pdfjs_require__(155);
  15508. 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"];
  15509. const MAX_MAP_RANGE = 2 ** 24 - 1;
  15510. class CMap {
  15511. constructor() {
  15512. let builtInCMap = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  15513. this.codespaceRanges = [[], [], [], []];
  15514. this.numCodespaceRanges = 0;
  15515. this._map = [];
  15516. this.name = "";
  15517. this.vertical = false;
  15518. this.useCMap = null;
  15519. this.builtInCMap = builtInCMap;
  15520. }
  15521. addCodespaceRange(n, low, high) {
  15522. this.codespaceRanges[n - 1].push(low, high);
  15523. this.numCodespaceRanges++;
  15524. }
  15525. mapCidRange(low, high, dstLow) {
  15526. if (high - low > MAX_MAP_RANGE) {
  15527. throw new Error("mapCidRange - ignoring data above MAX_MAP_RANGE.");
  15528. }
  15529. while (low <= high) {
  15530. this._map[low++] = dstLow++;
  15531. }
  15532. }
  15533. mapBfRange(low, high, dstLow) {
  15534. if (high - low > MAX_MAP_RANGE) {
  15535. throw new Error("mapBfRange - ignoring data above MAX_MAP_RANGE.");
  15536. }
  15537. const lastByte = dstLow.length - 1;
  15538. while (low <= high) {
  15539. this._map[low++] = dstLow;
  15540. const nextCharCode = dstLow.charCodeAt(lastByte) + 1;
  15541. if (nextCharCode > 0xff) {
  15542. dstLow = dstLow.substring(0, lastByte - 1) + String.fromCharCode(dstLow.charCodeAt(lastByte - 1) + 1) + "\x00";
  15543. continue;
  15544. }
  15545. dstLow = dstLow.substring(0, lastByte) + String.fromCharCode(nextCharCode);
  15546. }
  15547. }
  15548. mapBfRangeToArray(low, high, array) {
  15549. if (high - low > MAX_MAP_RANGE) {
  15550. throw new Error("mapBfRangeToArray - ignoring data above MAX_MAP_RANGE.");
  15551. }
  15552. const ii = array.length;
  15553. let i = 0;
  15554. while (low <= high && i < ii) {
  15555. this._map[low] = array[i++];
  15556. ++low;
  15557. }
  15558. }
  15559. mapOne(src, dst) {
  15560. this._map[src] = dst;
  15561. }
  15562. lookup(code) {
  15563. return this._map[code];
  15564. }
  15565. contains(code) {
  15566. return this._map[code] !== undefined;
  15567. }
  15568. forEach(callback) {
  15569. const map = this._map;
  15570. const length = map.length;
  15571. if (length <= 0x10000) {
  15572. for (let i = 0; i < length; i++) {
  15573. if (map[i] !== undefined) {
  15574. callback(i, map[i]);
  15575. }
  15576. }
  15577. } else {
  15578. for (const i in map) {
  15579. callback(i, map[i]);
  15580. }
  15581. }
  15582. }
  15583. charCodeOf(value) {
  15584. const map = this._map;
  15585. if (map.length <= 0x10000) {
  15586. return map.indexOf(value);
  15587. }
  15588. for (const charCode in map) {
  15589. if (map[charCode] === value) {
  15590. return charCode | 0;
  15591. }
  15592. }
  15593. return -1;
  15594. }
  15595. getMap() {
  15596. return this._map;
  15597. }
  15598. readCharCode(str, offset, out) {
  15599. let c = 0;
  15600. const codespaceRanges = this.codespaceRanges;
  15601. for (let n = 0, nn = codespaceRanges.length; n < nn; n++) {
  15602. c = (c << 8 | str.charCodeAt(offset + n)) >>> 0;
  15603. const codespaceRange = codespaceRanges[n];
  15604. for (let k = 0, kk = codespaceRange.length; k < kk;) {
  15605. const low = codespaceRange[k++];
  15606. const high = codespaceRange[k++];
  15607. if (c >= low && c <= high) {
  15608. out.charcode = c;
  15609. out.length = n + 1;
  15610. return;
  15611. }
  15612. }
  15613. }
  15614. out.charcode = 0;
  15615. out.length = 1;
  15616. }
  15617. getCharCodeLength(charCode) {
  15618. const codespaceRanges = this.codespaceRanges;
  15619. for (let n = 0, nn = codespaceRanges.length; n < nn; n++) {
  15620. const codespaceRange = codespaceRanges[n];
  15621. for (let k = 0, kk = codespaceRange.length; k < kk;) {
  15622. const low = codespaceRange[k++];
  15623. const high = codespaceRange[k++];
  15624. if (charCode >= low && charCode <= high) {
  15625. return n + 1;
  15626. }
  15627. }
  15628. }
  15629. return 1;
  15630. }
  15631. get length() {
  15632. return this._map.length;
  15633. }
  15634. get isIdentityCMap() {
  15635. if (!(this.name === "Identity-H" || this.name === "Identity-V")) {
  15636. return false;
  15637. }
  15638. if (this._map.length !== 0x10000) {
  15639. return false;
  15640. }
  15641. for (let i = 0; i < 0x10000; i++) {
  15642. if (this._map[i] !== i) {
  15643. return false;
  15644. }
  15645. }
  15646. return true;
  15647. }
  15648. }
  15649. exports.CMap = CMap;
  15650. class IdentityCMap extends CMap {
  15651. constructor(vertical, n) {
  15652. super();
  15653. this.vertical = vertical;
  15654. this.addCodespaceRange(n, 0, 0xffff);
  15655. }
  15656. mapCidRange(low, high, dstLow) {
  15657. (0, _util.unreachable)("should not call mapCidRange");
  15658. }
  15659. mapBfRange(low, high, dstLow) {
  15660. (0, _util.unreachable)("should not call mapBfRange");
  15661. }
  15662. mapBfRangeToArray(low, high, array) {
  15663. (0, _util.unreachable)("should not call mapBfRangeToArray");
  15664. }
  15665. mapOne(src, dst) {
  15666. (0, _util.unreachable)("should not call mapCidOne");
  15667. }
  15668. lookup(code) {
  15669. return Number.isInteger(code) && code <= 0xffff ? code : undefined;
  15670. }
  15671. contains(code) {
  15672. return Number.isInteger(code) && code <= 0xffff;
  15673. }
  15674. forEach(callback) {
  15675. for (let i = 0; i <= 0xffff; i++) {
  15676. callback(i, i);
  15677. }
  15678. }
  15679. charCodeOf(value) {
  15680. return Number.isInteger(value) && value <= 0xffff ? value : -1;
  15681. }
  15682. getMap() {
  15683. const map = new Array(0x10000);
  15684. for (let i = 0; i <= 0xffff; i++) {
  15685. map[i] = i;
  15686. }
  15687. return map;
  15688. }
  15689. get length() {
  15690. return 0x10000;
  15691. }
  15692. get isIdentityCMap() {
  15693. (0, _util.unreachable)("should not access .isIdentityCMap");
  15694. }
  15695. }
  15696. exports.IdentityCMap = IdentityCMap;
  15697. function strToInt(str) {
  15698. let a = 0;
  15699. for (let i = 0; i < str.length; i++) {
  15700. a = a << 8 | str.charCodeAt(i);
  15701. }
  15702. return a >>> 0;
  15703. }
  15704. function expectString(obj) {
  15705. if (typeof obj !== "string") {
  15706. throw new _util.FormatError("Malformed CMap: expected string.");
  15707. }
  15708. }
  15709. function expectInt(obj) {
  15710. if (!Number.isInteger(obj)) {
  15711. throw new _util.FormatError("Malformed CMap: expected int.");
  15712. }
  15713. }
  15714. function parseBfChar(cMap, lexer) {
  15715. while (true) {
  15716. let obj = lexer.getObj();
  15717. if (obj === _primitives.EOF) {
  15718. break;
  15719. }
  15720. if ((0, _primitives.isCmd)(obj, "endbfchar")) {
  15721. return;
  15722. }
  15723. expectString(obj);
  15724. const src = strToInt(obj);
  15725. obj = lexer.getObj();
  15726. expectString(obj);
  15727. const dst = obj;
  15728. cMap.mapOne(src, dst);
  15729. }
  15730. }
  15731. function parseBfRange(cMap, lexer) {
  15732. while (true) {
  15733. let obj = lexer.getObj();
  15734. if (obj === _primitives.EOF) {
  15735. break;
  15736. }
  15737. if ((0, _primitives.isCmd)(obj, "endbfrange")) {
  15738. return;
  15739. }
  15740. expectString(obj);
  15741. const low = strToInt(obj);
  15742. obj = lexer.getObj();
  15743. expectString(obj);
  15744. const high = strToInt(obj);
  15745. obj = lexer.getObj();
  15746. if (Number.isInteger(obj) || typeof obj === "string") {
  15747. const dstLow = Number.isInteger(obj) ? String.fromCharCode(obj) : obj;
  15748. cMap.mapBfRange(low, high, dstLow);
  15749. } else if ((0, _primitives.isCmd)(obj, "[")) {
  15750. obj = lexer.getObj();
  15751. const array = [];
  15752. while (!(0, _primitives.isCmd)(obj, "]") && obj !== _primitives.EOF) {
  15753. array.push(obj);
  15754. obj = lexer.getObj();
  15755. }
  15756. cMap.mapBfRangeToArray(low, high, array);
  15757. } else {
  15758. break;
  15759. }
  15760. }
  15761. throw new _util.FormatError("Invalid bf range.");
  15762. }
  15763. function parseCidChar(cMap, lexer) {
  15764. while (true) {
  15765. let obj = lexer.getObj();
  15766. if (obj === _primitives.EOF) {
  15767. break;
  15768. }
  15769. if ((0, _primitives.isCmd)(obj, "endcidchar")) {
  15770. return;
  15771. }
  15772. expectString(obj);
  15773. const src = strToInt(obj);
  15774. obj = lexer.getObj();
  15775. expectInt(obj);
  15776. const dst = obj;
  15777. cMap.mapOne(src, dst);
  15778. }
  15779. }
  15780. function parseCidRange(cMap, lexer) {
  15781. while (true) {
  15782. let obj = lexer.getObj();
  15783. if (obj === _primitives.EOF) {
  15784. break;
  15785. }
  15786. if ((0, _primitives.isCmd)(obj, "endcidrange")) {
  15787. return;
  15788. }
  15789. expectString(obj);
  15790. const low = strToInt(obj);
  15791. obj = lexer.getObj();
  15792. expectString(obj);
  15793. const high = strToInt(obj);
  15794. obj = lexer.getObj();
  15795. expectInt(obj);
  15796. const dstLow = obj;
  15797. cMap.mapCidRange(low, high, dstLow);
  15798. }
  15799. }
  15800. function parseCodespaceRange(cMap, lexer) {
  15801. while (true) {
  15802. let obj = lexer.getObj();
  15803. if (obj === _primitives.EOF) {
  15804. break;
  15805. }
  15806. if ((0, _primitives.isCmd)(obj, "endcodespacerange")) {
  15807. return;
  15808. }
  15809. if (typeof obj !== "string") {
  15810. break;
  15811. }
  15812. const low = strToInt(obj);
  15813. obj = lexer.getObj();
  15814. if (typeof obj !== "string") {
  15815. break;
  15816. }
  15817. const high = strToInt(obj);
  15818. cMap.addCodespaceRange(obj.length, low, high);
  15819. }
  15820. throw new _util.FormatError("Invalid codespace range.");
  15821. }
  15822. function parseWMode(cMap, lexer) {
  15823. const obj = lexer.getObj();
  15824. if (Number.isInteger(obj)) {
  15825. cMap.vertical = !!obj;
  15826. }
  15827. }
  15828. function parseCMapName(cMap, lexer) {
  15829. const obj = lexer.getObj();
  15830. if (obj instanceof _primitives.Name) {
  15831. cMap.name = obj.name;
  15832. }
  15833. }
  15834. async function parseCMap(cMap, lexer, fetchBuiltInCMap, useCMap) {
  15835. let previous, embeddedUseCMap;
  15836. objLoop: while (true) {
  15837. try {
  15838. const obj = lexer.getObj();
  15839. if (obj === _primitives.EOF) {
  15840. break;
  15841. } else if (obj instanceof _primitives.Name) {
  15842. if (obj.name === "WMode") {
  15843. parseWMode(cMap, lexer);
  15844. } else if (obj.name === "CMapName") {
  15845. parseCMapName(cMap, lexer);
  15846. }
  15847. previous = obj;
  15848. } else if (obj instanceof _primitives.Cmd) {
  15849. switch (obj.cmd) {
  15850. case "endcmap":
  15851. break objLoop;
  15852. case "usecmap":
  15853. if (previous instanceof _primitives.Name) {
  15854. embeddedUseCMap = previous.name;
  15855. }
  15856. break;
  15857. case "begincodespacerange":
  15858. parseCodespaceRange(cMap, lexer);
  15859. break;
  15860. case "beginbfchar":
  15861. parseBfChar(cMap, lexer);
  15862. break;
  15863. case "begincidchar":
  15864. parseCidChar(cMap, lexer);
  15865. break;
  15866. case "beginbfrange":
  15867. parseBfRange(cMap, lexer);
  15868. break;
  15869. case "begincidrange":
  15870. parseCidRange(cMap, lexer);
  15871. break;
  15872. }
  15873. }
  15874. } catch (ex) {
  15875. if (ex instanceof _core_utils.MissingDataException) {
  15876. throw ex;
  15877. }
  15878. (0, _util.warn)("Invalid cMap data: " + ex);
  15879. continue;
  15880. }
  15881. }
  15882. if (!useCMap && embeddedUseCMap) {
  15883. useCMap = embeddedUseCMap;
  15884. }
  15885. if (useCMap) {
  15886. return extendCMap(cMap, fetchBuiltInCMap, useCMap);
  15887. }
  15888. return cMap;
  15889. }
  15890. async function extendCMap(cMap, fetchBuiltInCMap, useCMap) {
  15891. cMap.useCMap = await createBuiltInCMap(useCMap, fetchBuiltInCMap);
  15892. if (cMap.numCodespaceRanges === 0) {
  15893. const useCodespaceRanges = cMap.useCMap.codespaceRanges;
  15894. for (let i = 0; i < useCodespaceRanges.length; i++) {
  15895. cMap.codespaceRanges[i] = useCodespaceRanges[i].slice();
  15896. }
  15897. cMap.numCodespaceRanges = cMap.useCMap.numCodespaceRanges;
  15898. }
  15899. cMap.useCMap.forEach(function (key, value) {
  15900. if (!cMap.contains(key)) {
  15901. cMap.mapOne(key, cMap.useCMap.lookup(key));
  15902. }
  15903. });
  15904. return cMap;
  15905. }
  15906. async function createBuiltInCMap(name, fetchBuiltInCMap) {
  15907. if (name === "Identity-H") {
  15908. return new IdentityCMap(false, 2);
  15909. } else if (name === "Identity-V") {
  15910. return new IdentityCMap(true, 2);
  15911. }
  15912. if (!BUILT_IN_CMAPS.includes(name)) {
  15913. throw new Error("Unknown CMap name: " + name);
  15914. }
  15915. if (!fetchBuiltInCMap) {
  15916. throw new Error("Built-in CMap parameters are not provided.");
  15917. }
  15918. const {
  15919. cMapData,
  15920. compressionType
  15921. } = await fetchBuiltInCMap(name);
  15922. const cMap = new CMap(true);
  15923. if (compressionType === _util.CMapCompressionType.BINARY) {
  15924. return new _binary_cmap.BinaryCMapReader().process(cMapData, cMap, useCMap => {
  15925. return extendCMap(cMap, fetchBuiltInCMap, useCMap);
  15926. });
  15927. }
  15928. if (compressionType === _util.CMapCompressionType.NONE) {
  15929. const lexer = new _parser.Lexer(new _stream.Stream(cMapData));
  15930. return parseCMap(cMap, lexer, fetchBuiltInCMap, null);
  15931. }
  15932. throw new Error(`Invalid CMap "compressionType" value: ${compressionType}`);
  15933. }
  15934. class CMapFactory {
  15935. static async create(_ref) {
  15936. let {
  15937. encoding,
  15938. fetchBuiltInCMap,
  15939. useCMap
  15940. } = _ref;
  15941. if (encoding instanceof _primitives.Name) {
  15942. return createBuiltInCMap(encoding.name, fetchBuiltInCMap);
  15943. } else if (encoding instanceof _base_stream.BaseStream) {
  15944. const parsedCMap = await parseCMap(new CMap(), new _parser.Lexer(encoding), fetchBuiltInCMap, useCMap);
  15945. if (parsedCMap.isIdentityCMap) {
  15946. return createBuiltInCMap(parsedCMap.name, fetchBuiltInCMap);
  15947. }
  15948. return parsedCMap;
  15949. }
  15950. throw new Error("Encoding required.");
  15951. }
  15952. }
  15953. exports.CMapFactory = CMapFactory;
  15954. /***/ }),
  15955. /* 166 */
  15956. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  15957. Object.defineProperty(exports, "__esModule", ({
  15958. value: true
  15959. }));
  15960. exports.BinaryCMapReader = void 0;
  15961. __w_pdfjs_require__(84);
  15962. __w_pdfjs_require__(93);
  15963. __w_pdfjs_require__(94);
  15964. __w_pdfjs_require__(97);
  15965. __w_pdfjs_require__(99);
  15966. __w_pdfjs_require__(101);
  15967. __w_pdfjs_require__(105);
  15968. __w_pdfjs_require__(108);
  15969. __w_pdfjs_require__(115);
  15970. __w_pdfjs_require__(2);
  15971. var _util = __w_pdfjs_require__(145);
  15972. function hexToInt(a, size) {
  15973. let n = 0;
  15974. for (let i = 0; i <= size; i++) {
  15975. n = n << 8 | a[i];
  15976. }
  15977. return n >>> 0;
  15978. }
  15979. function hexToStr(a, size) {
  15980. if (size === 1) {
  15981. return String.fromCharCode(a[0], a[1]);
  15982. }
  15983. if (size === 3) {
  15984. return String.fromCharCode(a[0], a[1], a[2], a[3]);
  15985. }
  15986. return String.fromCharCode(...a.subarray(0, size + 1));
  15987. }
  15988. function addHex(a, b, size) {
  15989. let c = 0;
  15990. for (let i = size; i >= 0; i--) {
  15991. c += a[i] + b[i];
  15992. a[i] = c & 255;
  15993. c >>= 8;
  15994. }
  15995. }
  15996. function incHex(a, size) {
  15997. let c = 1;
  15998. for (let i = size; i >= 0 && c > 0; i--) {
  15999. c += a[i];
  16000. a[i] = c & 255;
  16001. c >>= 8;
  16002. }
  16003. }
  16004. const MAX_NUM_SIZE = 16;
  16005. const MAX_ENCODED_NUM_SIZE = 19;
  16006. class BinaryCMapStream {
  16007. constructor(data) {
  16008. this.buffer = data;
  16009. this.pos = 0;
  16010. this.end = data.length;
  16011. this.tmpBuf = new Uint8Array(MAX_ENCODED_NUM_SIZE);
  16012. }
  16013. readByte() {
  16014. if (this.pos >= this.end) {
  16015. return -1;
  16016. }
  16017. return this.buffer[this.pos++];
  16018. }
  16019. readNumber() {
  16020. let n = 0;
  16021. let last;
  16022. do {
  16023. const b = this.readByte();
  16024. if (b < 0) {
  16025. throw new _util.FormatError("unexpected EOF in bcmap");
  16026. }
  16027. last = !(b & 0x80);
  16028. n = n << 7 | b & 0x7f;
  16029. } while (!last);
  16030. return n;
  16031. }
  16032. readSigned() {
  16033. const n = this.readNumber();
  16034. return n & 1 ? ~(n >>> 1) : n >>> 1;
  16035. }
  16036. readHex(num, size) {
  16037. num.set(this.buffer.subarray(this.pos, this.pos + size + 1));
  16038. this.pos += size + 1;
  16039. }
  16040. readHexNumber(num, size) {
  16041. let last;
  16042. const stack = this.tmpBuf;
  16043. let sp = 0;
  16044. do {
  16045. const b = this.readByte();
  16046. if (b < 0) {
  16047. throw new _util.FormatError("unexpected EOF in bcmap");
  16048. }
  16049. last = !(b & 0x80);
  16050. stack[sp++] = b & 0x7f;
  16051. } while (!last);
  16052. let i = size,
  16053. buffer = 0,
  16054. bufferSize = 0;
  16055. while (i >= 0) {
  16056. while (bufferSize < 8 && stack.length > 0) {
  16057. buffer |= stack[--sp] << bufferSize;
  16058. bufferSize += 7;
  16059. }
  16060. num[i] = buffer & 255;
  16061. i--;
  16062. buffer >>= 8;
  16063. bufferSize -= 8;
  16064. }
  16065. }
  16066. readHexSigned(num, size) {
  16067. this.readHexNumber(num, size);
  16068. const sign = num[size] & 1 ? 255 : 0;
  16069. let c = 0;
  16070. for (let i = 0; i <= size; i++) {
  16071. c = (c & 1) << 8 | num[i];
  16072. num[i] = c >> 1 ^ sign;
  16073. }
  16074. }
  16075. readString() {
  16076. const len = this.readNumber(),
  16077. buf = new Array(len);
  16078. for (let i = 0; i < len; i++) {
  16079. buf[i] = this.readNumber();
  16080. }
  16081. return String.fromCharCode(...buf);
  16082. }
  16083. }
  16084. class BinaryCMapReader {
  16085. async process(data, cMap, extend) {
  16086. const stream = new BinaryCMapStream(data);
  16087. const header = stream.readByte();
  16088. cMap.vertical = !!(header & 1);
  16089. let useCMap = null;
  16090. const start = new Uint8Array(MAX_NUM_SIZE);
  16091. const end = new Uint8Array(MAX_NUM_SIZE);
  16092. const char = new Uint8Array(MAX_NUM_SIZE);
  16093. const charCode = new Uint8Array(MAX_NUM_SIZE);
  16094. const tmp = new Uint8Array(MAX_NUM_SIZE);
  16095. let code;
  16096. let b;
  16097. while ((b = stream.readByte()) >= 0) {
  16098. const type = b >> 5;
  16099. if (type === 7) {
  16100. switch (b & 0x1f) {
  16101. case 0:
  16102. stream.readString();
  16103. break;
  16104. case 1:
  16105. useCMap = stream.readString();
  16106. break;
  16107. }
  16108. continue;
  16109. }
  16110. const sequence = !!(b & 0x10);
  16111. const dataSize = b & 15;
  16112. if (dataSize + 1 > MAX_NUM_SIZE) {
  16113. throw new Error("BinaryCMapReader.process: Invalid dataSize.");
  16114. }
  16115. const ucs2DataSize = 1;
  16116. const subitemsCount = stream.readNumber();
  16117. switch (type) {
  16118. case 0:
  16119. stream.readHex(start, dataSize);
  16120. stream.readHexNumber(end, dataSize);
  16121. addHex(end, start, dataSize);
  16122. cMap.addCodespaceRange(dataSize + 1, hexToInt(start, dataSize), hexToInt(end, dataSize));
  16123. for (let i = 1; i < subitemsCount; i++) {
  16124. incHex(end, dataSize);
  16125. stream.readHexNumber(start, dataSize);
  16126. addHex(start, end, dataSize);
  16127. stream.readHexNumber(end, dataSize);
  16128. addHex(end, start, dataSize);
  16129. cMap.addCodespaceRange(dataSize + 1, hexToInt(start, dataSize), hexToInt(end, dataSize));
  16130. }
  16131. break;
  16132. case 1:
  16133. stream.readHex(start, dataSize);
  16134. stream.readHexNumber(end, dataSize);
  16135. addHex(end, start, dataSize);
  16136. stream.readNumber();
  16137. for (let i = 1; i < subitemsCount; i++) {
  16138. incHex(end, dataSize);
  16139. stream.readHexNumber(start, dataSize);
  16140. addHex(start, end, dataSize);
  16141. stream.readHexNumber(end, dataSize);
  16142. addHex(end, start, dataSize);
  16143. stream.readNumber();
  16144. }
  16145. break;
  16146. case 2:
  16147. stream.readHex(char, dataSize);
  16148. code = stream.readNumber();
  16149. cMap.mapOne(hexToInt(char, dataSize), code);
  16150. for (let i = 1; i < subitemsCount; i++) {
  16151. incHex(char, dataSize);
  16152. if (!sequence) {
  16153. stream.readHexNumber(tmp, dataSize);
  16154. addHex(char, tmp, dataSize);
  16155. }
  16156. code = stream.readSigned() + (code + 1);
  16157. cMap.mapOne(hexToInt(char, dataSize), code);
  16158. }
  16159. break;
  16160. case 3:
  16161. stream.readHex(start, dataSize);
  16162. stream.readHexNumber(end, dataSize);
  16163. addHex(end, start, dataSize);
  16164. code = stream.readNumber();
  16165. cMap.mapCidRange(hexToInt(start, dataSize), hexToInt(end, dataSize), code);
  16166. for (let i = 1; i < subitemsCount; i++) {
  16167. incHex(end, dataSize);
  16168. if (!sequence) {
  16169. stream.readHexNumber(start, dataSize);
  16170. addHex(start, end, dataSize);
  16171. } else {
  16172. start.set(end);
  16173. }
  16174. stream.readHexNumber(end, dataSize);
  16175. addHex(end, start, dataSize);
  16176. code = stream.readNumber();
  16177. cMap.mapCidRange(hexToInt(start, dataSize), hexToInt(end, dataSize), code);
  16178. }
  16179. break;
  16180. case 4:
  16181. stream.readHex(char, ucs2DataSize);
  16182. stream.readHex(charCode, dataSize);
  16183. cMap.mapOne(hexToInt(char, ucs2DataSize), hexToStr(charCode, dataSize));
  16184. for (let i = 1; i < subitemsCount; i++) {
  16185. incHex(char, ucs2DataSize);
  16186. if (!sequence) {
  16187. stream.readHexNumber(tmp, ucs2DataSize);
  16188. addHex(char, tmp, ucs2DataSize);
  16189. }
  16190. incHex(charCode, dataSize);
  16191. stream.readHexSigned(tmp, dataSize);
  16192. addHex(charCode, tmp, dataSize);
  16193. cMap.mapOne(hexToInt(char, ucs2DataSize), hexToStr(charCode, dataSize));
  16194. }
  16195. break;
  16196. case 5:
  16197. stream.readHex(start, ucs2DataSize);
  16198. stream.readHexNumber(end, ucs2DataSize);
  16199. addHex(end, start, ucs2DataSize);
  16200. stream.readHex(charCode, dataSize);
  16201. cMap.mapBfRange(hexToInt(start, ucs2DataSize), hexToInt(end, ucs2DataSize), hexToStr(charCode, dataSize));
  16202. for (let i = 1; i < subitemsCount; i++) {
  16203. incHex(end, ucs2DataSize);
  16204. if (!sequence) {
  16205. stream.readHexNumber(start, ucs2DataSize);
  16206. addHex(start, end, ucs2DataSize);
  16207. } else {
  16208. start.set(end);
  16209. }
  16210. stream.readHexNumber(end, ucs2DataSize);
  16211. addHex(end, start, ucs2DataSize);
  16212. stream.readHex(charCode, dataSize);
  16213. cMap.mapBfRange(hexToInt(start, ucs2DataSize), hexToInt(end, ucs2DataSize), hexToStr(charCode, dataSize));
  16214. }
  16215. break;
  16216. default:
  16217. throw new Error(`BinaryCMapReader.process - unknown type: ${type}`);
  16218. }
  16219. }
  16220. if (useCMap) {
  16221. return extend(useCMap);
  16222. }
  16223. return cMap;
  16224. }
  16225. }
  16226. exports.BinaryCMapReader = BinaryCMapReader;
  16227. /***/ }),
  16228. /* 167 */
  16229. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  16230. Object.defineProperty(exports, "__esModule", ({
  16231. value: true
  16232. }));
  16233. exports.Parser = exports.Linearization = exports.Lexer = void 0;
  16234. __w_pdfjs_require__(140);
  16235. __w_pdfjs_require__(84);
  16236. __w_pdfjs_require__(93);
  16237. __w_pdfjs_require__(94);
  16238. __w_pdfjs_require__(97);
  16239. __w_pdfjs_require__(99);
  16240. __w_pdfjs_require__(101);
  16241. __w_pdfjs_require__(105);
  16242. __w_pdfjs_require__(108);
  16243. __w_pdfjs_require__(115);
  16244. __w_pdfjs_require__(2);
  16245. var _util = __w_pdfjs_require__(145);
  16246. var _primitives = __w_pdfjs_require__(151);
  16247. var _core_utils = __w_pdfjs_require__(150);
  16248. var _stream = __w_pdfjs_require__(155);
  16249. var _ascii_85_stream = __w_pdfjs_require__(168);
  16250. var _ascii_hex_stream = __w_pdfjs_require__(170);
  16251. var _ccitt_stream = __w_pdfjs_require__(171);
  16252. var _flate_stream = __w_pdfjs_require__(173);
  16253. var _jbig2_stream = __w_pdfjs_require__(174);
  16254. var _jpeg_stream = __w_pdfjs_require__(177);
  16255. var _jpx_stream = __w_pdfjs_require__(180);
  16256. var _lzw_stream = __w_pdfjs_require__(182);
  16257. var _predictor_stream = __w_pdfjs_require__(183);
  16258. var _run_length_stream = __w_pdfjs_require__(184);
  16259. const MAX_LENGTH_TO_CACHE = 1000;
  16260. function getInlineImageCacheKey(bytes) {
  16261. const strBuf = [],
  16262. ii = bytes.length;
  16263. let i = 0;
  16264. while (i < ii - 1) {
  16265. strBuf.push(bytes[i++] << 8 | bytes[i++]);
  16266. }
  16267. if (i < ii) {
  16268. strBuf.push(bytes[i]);
  16269. }
  16270. return ii + "_" + String.fromCharCode.apply(null, strBuf);
  16271. }
  16272. class Parser {
  16273. constructor(_ref) {
  16274. let {
  16275. lexer,
  16276. xref,
  16277. allowStreams = false,
  16278. recoveryMode = false
  16279. } = _ref;
  16280. this.lexer = lexer;
  16281. this.xref = xref;
  16282. this.allowStreams = allowStreams;
  16283. this.recoveryMode = recoveryMode;
  16284. this.imageCache = Object.create(null);
  16285. this._imageId = 0;
  16286. this.refill();
  16287. }
  16288. refill() {
  16289. this.buf1 = this.lexer.getObj();
  16290. this.buf2 = this.lexer.getObj();
  16291. }
  16292. shift() {
  16293. if (this.buf2 instanceof _primitives.Cmd && this.buf2.cmd === "ID") {
  16294. this.buf1 = this.buf2;
  16295. this.buf2 = null;
  16296. } else {
  16297. this.buf1 = this.buf2;
  16298. this.buf2 = this.lexer.getObj();
  16299. }
  16300. }
  16301. tryShift() {
  16302. try {
  16303. this.shift();
  16304. return true;
  16305. } catch (e) {
  16306. if (e instanceof _core_utils.MissingDataException) {
  16307. throw e;
  16308. }
  16309. return false;
  16310. }
  16311. }
  16312. getObj() {
  16313. let cipherTransform = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
  16314. const buf1 = this.buf1;
  16315. this.shift();
  16316. if (buf1 instanceof _primitives.Cmd) {
  16317. switch (buf1.cmd) {
  16318. case "BI":
  16319. return this.makeInlineImage(cipherTransform);
  16320. case "[":
  16321. const array = [];
  16322. while (!(0, _primitives.isCmd)(this.buf1, "]") && this.buf1 !== _primitives.EOF) {
  16323. array.push(this.getObj(cipherTransform));
  16324. }
  16325. if (this.buf1 === _primitives.EOF) {
  16326. if (this.recoveryMode) {
  16327. return array;
  16328. }
  16329. throw new _core_utils.ParserEOFException("End of file inside array.");
  16330. }
  16331. this.shift();
  16332. return array;
  16333. case "<<":
  16334. const dict = new _primitives.Dict(this.xref);
  16335. while (!(0, _primitives.isCmd)(this.buf1, ">>") && this.buf1 !== _primitives.EOF) {
  16336. if (!(this.buf1 instanceof _primitives.Name)) {
  16337. (0, _util.info)("Malformed dictionary: key must be a name object");
  16338. this.shift();
  16339. continue;
  16340. }
  16341. const key = this.buf1.name;
  16342. this.shift();
  16343. if (this.buf1 === _primitives.EOF) {
  16344. break;
  16345. }
  16346. dict.set(key, this.getObj(cipherTransform));
  16347. }
  16348. if (this.buf1 === _primitives.EOF) {
  16349. if (this.recoveryMode) {
  16350. return dict;
  16351. }
  16352. throw new _core_utils.ParserEOFException("End of file inside dictionary.");
  16353. }
  16354. if ((0, _primitives.isCmd)(this.buf2, "stream")) {
  16355. return this.allowStreams ? this.makeStream(dict, cipherTransform) : dict;
  16356. }
  16357. this.shift();
  16358. return dict;
  16359. default:
  16360. return buf1;
  16361. }
  16362. }
  16363. if (Number.isInteger(buf1)) {
  16364. if (Number.isInteger(this.buf1) && (0, _primitives.isCmd)(this.buf2, "R")) {
  16365. const ref = _primitives.Ref.get(buf1, this.buf1);
  16366. this.shift();
  16367. this.shift();
  16368. return ref;
  16369. }
  16370. return buf1;
  16371. }
  16372. if (typeof buf1 === "string") {
  16373. if (cipherTransform) {
  16374. return cipherTransform.decryptString(buf1);
  16375. }
  16376. return buf1;
  16377. }
  16378. return buf1;
  16379. }
  16380. findDefaultInlineStreamEnd(stream) {
  16381. const E = 0x45,
  16382. I = 0x49,
  16383. SPACE = 0x20,
  16384. LF = 0xa,
  16385. CR = 0xd,
  16386. NUL = 0x0;
  16387. const {
  16388. knownCommands
  16389. } = this.lexer,
  16390. startPos = stream.pos,
  16391. n = 15;
  16392. let state = 0,
  16393. ch,
  16394. maybeEIPos;
  16395. while ((ch = stream.getByte()) !== -1) {
  16396. if (state === 0) {
  16397. state = ch === E ? 1 : 0;
  16398. } else if (state === 1) {
  16399. state = ch === I ? 2 : 0;
  16400. } else {
  16401. if (ch === SPACE || ch === LF || ch === CR) {
  16402. maybeEIPos = stream.pos;
  16403. const followingBytes = stream.peekBytes(n);
  16404. const ii = followingBytes.length;
  16405. if (ii === 0) {
  16406. break;
  16407. }
  16408. for (let i = 0; i < ii; i++) {
  16409. ch = followingBytes[i];
  16410. if (ch === NUL && followingBytes[i + 1] !== NUL) {
  16411. continue;
  16412. }
  16413. if (ch !== LF && ch !== CR && (ch < SPACE || ch > 0x7f)) {
  16414. state = 0;
  16415. break;
  16416. }
  16417. }
  16418. if (state !== 2) {
  16419. continue;
  16420. }
  16421. if (!knownCommands) {
  16422. (0, _util.warn)("findDefaultInlineStreamEnd - `lexer.knownCommands` is undefined.");
  16423. continue;
  16424. }
  16425. const tmpLexer = new Lexer(new _stream.Stream(followingBytes.slice()), knownCommands);
  16426. tmpLexer._hexStringWarn = () => {};
  16427. let numArgs = 0;
  16428. while (true) {
  16429. const nextObj = tmpLexer.getObj();
  16430. if (nextObj === _primitives.EOF) {
  16431. state = 0;
  16432. break;
  16433. }
  16434. if (nextObj instanceof _primitives.Cmd) {
  16435. const knownCommand = knownCommands[nextObj.cmd];
  16436. if (!knownCommand) {
  16437. state = 0;
  16438. break;
  16439. } else if (knownCommand.variableArgs ? numArgs <= knownCommand.numArgs : numArgs === knownCommand.numArgs) {
  16440. break;
  16441. }
  16442. numArgs = 0;
  16443. continue;
  16444. }
  16445. numArgs++;
  16446. }
  16447. if (state === 2) {
  16448. break;
  16449. }
  16450. } else {
  16451. state = 0;
  16452. }
  16453. }
  16454. }
  16455. if (ch === -1) {
  16456. (0, _util.warn)("findDefaultInlineStreamEnd: " + "Reached the end of the stream without finding a valid EI marker");
  16457. if (maybeEIPos) {
  16458. (0, _util.warn)('... trying to recover by using the last "EI" occurrence.');
  16459. stream.skip(-(stream.pos - maybeEIPos));
  16460. }
  16461. }
  16462. let endOffset = 4;
  16463. stream.skip(-endOffset);
  16464. ch = stream.peekByte();
  16465. stream.skip(endOffset);
  16466. if (!(0, _core_utils.isWhiteSpace)(ch)) {
  16467. endOffset--;
  16468. }
  16469. return stream.pos - endOffset - startPos;
  16470. }
  16471. findDCTDecodeInlineStreamEnd(stream) {
  16472. const startPos = stream.pos;
  16473. let foundEOI = false,
  16474. b,
  16475. markerLength;
  16476. while ((b = stream.getByte()) !== -1) {
  16477. if (b !== 0xff) {
  16478. continue;
  16479. }
  16480. switch (stream.getByte()) {
  16481. case 0x00:
  16482. break;
  16483. case 0xff:
  16484. stream.skip(-1);
  16485. break;
  16486. case 0xd9:
  16487. foundEOI = true;
  16488. break;
  16489. case 0xc0:
  16490. case 0xc1:
  16491. case 0xc2:
  16492. case 0xc3:
  16493. case 0xc5:
  16494. case 0xc6:
  16495. case 0xc7:
  16496. case 0xc9:
  16497. case 0xca:
  16498. case 0xcb:
  16499. case 0xcd:
  16500. case 0xce:
  16501. case 0xcf:
  16502. case 0xc4:
  16503. case 0xcc:
  16504. case 0xda:
  16505. case 0xdb:
  16506. case 0xdc:
  16507. case 0xdd:
  16508. case 0xde:
  16509. case 0xdf:
  16510. case 0xe0:
  16511. case 0xe1:
  16512. case 0xe2:
  16513. case 0xe3:
  16514. case 0xe4:
  16515. case 0xe5:
  16516. case 0xe6:
  16517. case 0xe7:
  16518. case 0xe8:
  16519. case 0xe9:
  16520. case 0xea:
  16521. case 0xeb:
  16522. case 0xec:
  16523. case 0xed:
  16524. case 0xee:
  16525. case 0xef:
  16526. case 0xfe:
  16527. markerLength = stream.getUint16();
  16528. if (markerLength > 2) {
  16529. stream.skip(markerLength - 2);
  16530. } else {
  16531. stream.skip(-2);
  16532. }
  16533. break;
  16534. }
  16535. if (foundEOI) {
  16536. break;
  16537. }
  16538. }
  16539. const length = stream.pos - startPos;
  16540. if (b === -1) {
  16541. (0, _util.warn)("Inline DCTDecode image stream: " + "EOI marker not found, searching for /EI/ instead.");
  16542. stream.skip(-length);
  16543. return this.findDefaultInlineStreamEnd(stream);
  16544. }
  16545. this.inlineStreamSkipEI(stream);
  16546. return length;
  16547. }
  16548. findASCII85DecodeInlineStreamEnd(stream) {
  16549. const TILDE = 0x7e,
  16550. GT = 0x3e;
  16551. const startPos = stream.pos;
  16552. let ch;
  16553. while ((ch = stream.getByte()) !== -1) {
  16554. if (ch === TILDE) {
  16555. const tildePos = stream.pos;
  16556. ch = stream.peekByte();
  16557. while ((0, _core_utils.isWhiteSpace)(ch)) {
  16558. stream.skip();
  16559. ch = stream.peekByte();
  16560. }
  16561. if (ch === GT) {
  16562. stream.skip();
  16563. break;
  16564. }
  16565. if (stream.pos > tildePos) {
  16566. const maybeEI = stream.peekBytes(2);
  16567. if (maybeEI[0] === 0x45 && maybeEI[1] === 0x49) {
  16568. break;
  16569. }
  16570. }
  16571. }
  16572. }
  16573. const length = stream.pos - startPos;
  16574. if (ch === -1) {
  16575. (0, _util.warn)("Inline ASCII85Decode image stream: " + "EOD marker not found, searching for /EI/ instead.");
  16576. stream.skip(-length);
  16577. return this.findDefaultInlineStreamEnd(stream);
  16578. }
  16579. this.inlineStreamSkipEI(stream);
  16580. return length;
  16581. }
  16582. findASCIIHexDecodeInlineStreamEnd(stream) {
  16583. const GT = 0x3e;
  16584. const startPos = stream.pos;
  16585. let ch;
  16586. while ((ch = stream.getByte()) !== -1) {
  16587. if (ch === GT) {
  16588. break;
  16589. }
  16590. }
  16591. const length = stream.pos - startPos;
  16592. if (ch === -1) {
  16593. (0, _util.warn)("Inline ASCIIHexDecode image stream: " + "EOD marker not found, searching for /EI/ instead.");
  16594. stream.skip(-length);
  16595. return this.findDefaultInlineStreamEnd(stream);
  16596. }
  16597. this.inlineStreamSkipEI(stream);
  16598. return length;
  16599. }
  16600. inlineStreamSkipEI(stream) {
  16601. const E = 0x45,
  16602. I = 0x49;
  16603. let state = 0,
  16604. ch;
  16605. while ((ch = stream.getByte()) !== -1) {
  16606. if (state === 0) {
  16607. state = ch === E ? 1 : 0;
  16608. } else if (state === 1) {
  16609. state = ch === I ? 2 : 0;
  16610. } else if (state === 2) {
  16611. break;
  16612. }
  16613. }
  16614. }
  16615. makeInlineImage(cipherTransform) {
  16616. const lexer = this.lexer;
  16617. const stream = lexer.stream;
  16618. const dictMap = Object.create(null);
  16619. let dictLength;
  16620. while (!(0, _primitives.isCmd)(this.buf1, "ID") && this.buf1 !== _primitives.EOF) {
  16621. if (!(this.buf1 instanceof _primitives.Name)) {
  16622. throw new _util.FormatError("Dictionary key must be a name object");
  16623. }
  16624. const key = this.buf1.name;
  16625. this.shift();
  16626. if (this.buf1 === _primitives.EOF) {
  16627. break;
  16628. }
  16629. dictMap[key] = this.getObj(cipherTransform);
  16630. }
  16631. if (lexer.beginInlineImagePos !== -1) {
  16632. dictLength = stream.pos - lexer.beginInlineImagePos;
  16633. }
  16634. const filter = this.xref.fetchIfRef(dictMap.F || dictMap.Filter);
  16635. let filterName;
  16636. if (filter instanceof _primitives.Name) {
  16637. filterName = filter.name;
  16638. } else if (Array.isArray(filter)) {
  16639. const filterZero = this.xref.fetchIfRef(filter[0]);
  16640. if (filterZero instanceof _primitives.Name) {
  16641. filterName = filterZero.name;
  16642. }
  16643. }
  16644. const startPos = stream.pos;
  16645. let length;
  16646. switch (filterName) {
  16647. case "DCT":
  16648. case "DCTDecode":
  16649. length = this.findDCTDecodeInlineStreamEnd(stream);
  16650. break;
  16651. case "A85":
  16652. case "ASCII85Decode":
  16653. length = this.findASCII85DecodeInlineStreamEnd(stream);
  16654. break;
  16655. case "AHx":
  16656. case "ASCIIHexDecode":
  16657. length = this.findASCIIHexDecodeInlineStreamEnd(stream);
  16658. break;
  16659. default:
  16660. length = this.findDefaultInlineStreamEnd(stream);
  16661. }
  16662. let cacheKey;
  16663. if (length < MAX_LENGTH_TO_CACHE && dictLength > 0) {
  16664. const initialStreamPos = stream.pos;
  16665. stream.pos = lexer.beginInlineImagePos;
  16666. cacheKey = getInlineImageCacheKey(stream.getBytes(dictLength + length));
  16667. stream.pos = initialStreamPos;
  16668. const cacheEntry = this.imageCache[cacheKey];
  16669. if (cacheEntry !== undefined) {
  16670. this.buf2 = _primitives.Cmd.get("EI");
  16671. this.shift();
  16672. cacheEntry.reset();
  16673. return cacheEntry;
  16674. }
  16675. }
  16676. const dict = new _primitives.Dict(this.xref);
  16677. for (const key in dictMap) {
  16678. dict.set(key, dictMap[key]);
  16679. }
  16680. let imageStream = stream.makeSubStream(startPos, length, dict);
  16681. if (cipherTransform) {
  16682. imageStream = cipherTransform.createStream(imageStream, length);
  16683. }
  16684. imageStream = this.filter(imageStream, dict, length);
  16685. imageStream.dict = dict;
  16686. if (cacheKey !== undefined) {
  16687. imageStream.cacheKey = `inline_img_${++this._imageId}`;
  16688. this.imageCache[cacheKey] = imageStream;
  16689. }
  16690. this.buf2 = _primitives.Cmd.get("EI");
  16691. this.shift();
  16692. return imageStream;
  16693. }
  16694. _findStreamLength(startPos, signature) {
  16695. const {
  16696. stream
  16697. } = this.lexer;
  16698. stream.pos = startPos;
  16699. const SCAN_BLOCK_LENGTH = 2048;
  16700. const signatureLength = signature.length;
  16701. while (stream.pos < stream.end) {
  16702. const scanBytes = stream.peekBytes(SCAN_BLOCK_LENGTH);
  16703. const scanLength = scanBytes.length - signatureLength;
  16704. if (scanLength <= 0) {
  16705. break;
  16706. }
  16707. let pos = 0;
  16708. while (pos < scanLength) {
  16709. let j = 0;
  16710. while (j < signatureLength && scanBytes[pos + j] === signature[j]) {
  16711. j++;
  16712. }
  16713. if (j >= signatureLength) {
  16714. stream.pos += pos;
  16715. return stream.pos - startPos;
  16716. }
  16717. pos++;
  16718. }
  16719. stream.pos += scanLength;
  16720. }
  16721. return -1;
  16722. }
  16723. makeStream(dict, cipherTransform) {
  16724. const lexer = this.lexer;
  16725. let stream = lexer.stream;
  16726. lexer.skipToNextLine();
  16727. const startPos = stream.pos - 1;
  16728. let length = dict.get("Length");
  16729. if (!Number.isInteger(length)) {
  16730. (0, _util.info)(`Bad length "${length && length.toString()}" in stream.`);
  16731. length = 0;
  16732. }
  16733. stream.pos = startPos + length;
  16734. lexer.nextChar();
  16735. if (this.tryShift() && (0, _primitives.isCmd)(this.buf2, "endstream")) {
  16736. this.shift();
  16737. } else {
  16738. const ENDSTREAM_SIGNATURE = new Uint8Array([0x65, 0x6e, 0x64, 0x73, 0x74, 0x72, 0x65, 0x61, 0x6d]);
  16739. let actualLength = this._findStreamLength(startPos, ENDSTREAM_SIGNATURE);
  16740. if (actualLength < 0) {
  16741. const MAX_TRUNCATION = 1;
  16742. for (let i = 1; i <= MAX_TRUNCATION; i++) {
  16743. const end = ENDSTREAM_SIGNATURE.length - i;
  16744. const TRUNCATED_SIGNATURE = ENDSTREAM_SIGNATURE.slice(0, end);
  16745. const maybeLength = this._findStreamLength(startPos, TRUNCATED_SIGNATURE);
  16746. if (maybeLength >= 0) {
  16747. const lastByte = stream.peekBytes(end + 1)[end];
  16748. if (!(0, _core_utils.isWhiteSpace)(lastByte)) {
  16749. break;
  16750. }
  16751. (0, _util.info)(`Found "${(0, _util.bytesToString)(TRUNCATED_SIGNATURE)}" when ` + "searching for endstream command.");
  16752. actualLength = maybeLength;
  16753. break;
  16754. }
  16755. }
  16756. if (actualLength < 0) {
  16757. throw new _util.FormatError("Missing endstream command.");
  16758. }
  16759. }
  16760. length = actualLength;
  16761. lexer.nextChar();
  16762. this.shift();
  16763. this.shift();
  16764. }
  16765. this.shift();
  16766. stream = stream.makeSubStream(startPos, length, dict);
  16767. if (cipherTransform) {
  16768. stream = cipherTransform.createStream(stream, length);
  16769. }
  16770. stream = this.filter(stream, dict, length);
  16771. stream.dict = dict;
  16772. return stream;
  16773. }
  16774. filter(stream, dict, length) {
  16775. let filter = dict.get("F", "Filter");
  16776. let params = dict.get("DP", "DecodeParms");
  16777. if (filter instanceof _primitives.Name) {
  16778. if (Array.isArray(params)) {
  16779. (0, _util.warn)("/DecodeParms should not be an Array, when /Filter is a Name.");
  16780. }
  16781. return this.makeFilter(stream, filter.name, length, params);
  16782. }
  16783. let maybeLength = length;
  16784. if (Array.isArray(filter)) {
  16785. const filterArray = filter;
  16786. const paramsArray = params;
  16787. for (let i = 0, ii = filterArray.length; i < ii; ++i) {
  16788. filter = this.xref.fetchIfRef(filterArray[i]);
  16789. if (!(filter instanceof _primitives.Name)) {
  16790. throw new _util.FormatError(`Bad filter name "${filter}"`);
  16791. }
  16792. params = null;
  16793. if (Array.isArray(paramsArray) && i in paramsArray) {
  16794. params = this.xref.fetchIfRef(paramsArray[i]);
  16795. }
  16796. stream = this.makeFilter(stream, filter.name, maybeLength, params);
  16797. maybeLength = null;
  16798. }
  16799. }
  16800. return stream;
  16801. }
  16802. makeFilter(stream, name, maybeLength, params) {
  16803. if (maybeLength === 0) {
  16804. (0, _util.warn)(`Empty "${name}" stream.`);
  16805. return new _stream.NullStream();
  16806. }
  16807. try {
  16808. switch (name) {
  16809. case "Fl":
  16810. case "FlateDecode":
  16811. if (params) {
  16812. return new _predictor_stream.PredictorStream(new _flate_stream.FlateStream(stream, maybeLength), maybeLength, params);
  16813. }
  16814. return new _flate_stream.FlateStream(stream, maybeLength);
  16815. case "LZW":
  16816. case "LZWDecode":
  16817. let earlyChange = 1;
  16818. if (params) {
  16819. if (params.has("EarlyChange")) {
  16820. earlyChange = params.get("EarlyChange");
  16821. }
  16822. return new _predictor_stream.PredictorStream(new _lzw_stream.LZWStream(stream, maybeLength, earlyChange), maybeLength, params);
  16823. }
  16824. return new _lzw_stream.LZWStream(stream, maybeLength, earlyChange);
  16825. case "DCT":
  16826. case "DCTDecode":
  16827. return new _jpeg_stream.JpegStream(stream, maybeLength, params);
  16828. case "JPX":
  16829. case "JPXDecode":
  16830. return new _jpx_stream.JpxStream(stream, maybeLength, params);
  16831. case "A85":
  16832. case "ASCII85Decode":
  16833. return new _ascii_85_stream.Ascii85Stream(stream, maybeLength);
  16834. case "AHx":
  16835. case "ASCIIHexDecode":
  16836. return new _ascii_hex_stream.AsciiHexStream(stream, maybeLength);
  16837. case "CCF":
  16838. case "CCITTFaxDecode":
  16839. return new _ccitt_stream.CCITTFaxStream(stream, maybeLength, params);
  16840. case "RL":
  16841. case "RunLengthDecode":
  16842. return new _run_length_stream.RunLengthStream(stream, maybeLength);
  16843. case "JBIG2Decode":
  16844. return new _jbig2_stream.Jbig2Stream(stream, maybeLength, params);
  16845. }
  16846. (0, _util.warn)(`Filter "${name}" is not supported.`);
  16847. return stream;
  16848. } catch (ex) {
  16849. if (ex instanceof _core_utils.MissingDataException) {
  16850. throw ex;
  16851. }
  16852. (0, _util.warn)(`Invalid stream: "${ex}"`);
  16853. return new _stream.NullStream();
  16854. }
  16855. }
  16856. }
  16857. exports.Parser = Parser;
  16858. 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];
  16859. function toHexDigit(ch) {
  16860. if (ch >= 0x30 && ch <= 0x39) {
  16861. return ch & 0x0f;
  16862. }
  16863. if (ch >= 0x41 && ch <= 0x46 || ch >= 0x61 && ch <= 0x66) {
  16864. return (ch & 0x0f) + 9;
  16865. }
  16866. return -1;
  16867. }
  16868. class Lexer {
  16869. constructor(stream) {
  16870. let knownCommands = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  16871. this.stream = stream;
  16872. this.nextChar();
  16873. this.strBuf = [];
  16874. this.knownCommands = knownCommands;
  16875. this._hexStringNumWarn = 0;
  16876. this.beginInlineImagePos = -1;
  16877. }
  16878. nextChar() {
  16879. return this.currentChar = this.stream.getByte();
  16880. }
  16881. peekChar() {
  16882. return this.stream.peekByte();
  16883. }
  16884. getNumber() {
  16885. let ch = this.currentChar;
  16886. let eNotation = false;
  16887. let divideBy = 0;
  16888. let sign = 1;
  16889. if (ch === 0x2d) {
  16890. sign = -1;
  16891. ch = this.nextChar();
  16892. if (ch === 0x2d) {
  16893. ch = this.nextChar();
  16894. }
  16895. } else if (ch === 0x2b) {
  16896. ch = this.nextChar();
  16897. }
  16898. if (ch === 0x0a || ch === 0x0d) {
  16899. do {
  16900. ch = this.nextChar();
  16901. } while (ch === 0x0a || ch === 0x0d);
  16902. }
  16903. if (ch === 0x2e) {
  16904. divideBy = 10;
  16905. ch = this.nextChar();
  16906. }
  16907. if (ch < 0x30 || ch > 0x39) {
  16908. const msg = `Invalid number: ${String.fromCharCode(ch)} (charCode ${ch})`;
  16909. if ((0, _core_utils.isWhiteSpace)(ch) || ch === -1) {
  16910. (0, _util.info)(`Lexer.getNumber - "${msg}".`);
  16911. return 0;
  16912. }
  16913. throw new _util.FormatError(msg);
  16914. }
  16915. let baseValue = ch - 0x30;
  16916. let powerValue = 0;
  16917. let powerValueSign = 1;
  16918. while ((ch = this.nextChar()) >= 0) {
  16919. if (ch >= 0x30 && ch <= 0x39) {
  16920. const currentDigit = ch - 0x30;
  16921. if (eNotation) {
  16922. powerValue = powerValue * 10 + currentDigit;
  16923. } else {
  16924. if (divideBy !== 0) {
  16925. divideBy *= 10;
  16926. }
  16927. baseValue = baseValue * 10 + currentDigit;
  16928. }
  16929. } else if (ch === 0x2e) {
  16930. if (divideBy === 0) {
  16931. divideBy = 1;
  16932. } else {
  16933. break;
  16934. }
  16935. } else if (ch === 0x2d) {
  16936. (0, _util.warn)("Badly formatted number: minus sign in the middle");
  16937. } else if (ch === 0x45 || ch === 0x65) {
  16938. ch = this.peekChar();
  16939. if (ch === 0x2b || ch === 0x2d) {
  16940. powerValueSign = ch === 0x2d ? -1 : 1;
  16941. this.nextChar();
  16942. } else if (ch < 0x30 || ch > 0x39) {
  16943. break;
  16944. }
  16945. eNotation = true;
  16946. } else {
  16947. break;
  16948. }
  16949. }
  16950. if (divideBy !== 0) {
  16951. baseValue /= divideBy;
  16952. }
  16953. if (eNotation) {
  16954. baseValue *= 10 ** (powerValueSign * powerValue);
  16955. }
  16956. return sign * baseValue;
  16957. }
  16958. getString() {
  16959. let numParen = 1;
  16960. let done = false;
  16961. const strBuf = this.strBuf;
  16962. strBuf.length = 0;
  16963. let ch = this.nextChar();
  16964. while (true) {
  16965. let charBuffered = false;
  16966. switch (ch | 0) {
  16967. case -1:
  16968. (0, _util.warn)("Unterminated string");
  16969. done = true;
  16970. break;
  16971. case 0x28:
  16972. ++numParen;
  16973. strBuf.push("(");
  16974. break;
  16975. case 0x29:
  16976. if (--numParen === 0) {
  16977. this.nextChar();
  16978. done = true;
  16979. } else {
  16980. strBuf.push(")");
  16981. }
  16982. break;
  16983. case 0x5c:
  16984. ch = this.nextChar();
  16985. switch (ch) {
  16986. case -1:
  16987. (0, _util.warn)("Unterminated string");
  16988. done = true;
  16989. break;
  16990. case 0x6e:
  16991. strBuf.push("\n");
  16992. break;
  16993. case 0x72:
  16994. strBuf.push("\r");
  16995. break;
  16996. case 0x74:
  16997. strBuf.push("\t");
  16998. break;
  16999. case 0x62:
  17000. strBuf.push("\b");
  17001. break;
  17002. case 0x66:
  17003. strBuf.push("\f");
  17004. break;
  17005. case 0x5c:
  17006. case 0x28:
  17007. case 0x29:
  17008. strBuf.push(String.fromCharCode(ch));
  17009. break;
  17010. case 0x30:
  17011. case 0x31:
  17012. case 0x32:
  17013. case 0x33:
  17014. case 0x34:
  17015. case 0x35:
  17016. case 0x36:
  17017. case 0x37:
  17018. let x = ch & 0x0f;
  17019. ch = this.nextChar();
  17020. charBuffered = true;
  17021. if (ch >= 0x30 && ch <= 0x37) {
  17022. x = (x << 3) + (ch & 0x0f);
  17023. ch = this.nextChar();
  17024. if (ch >= 0x30 && ch <= 0x37) {
  17025. charBuffered = false;
  17026. x = (x << 3) + (ch & 0x0f);
  17027. }
  17028. }
  17029. strBuf.push(String.fromCharCode(x));
  17030. break;
  17031. case 0x0d:
  17032. if (this.peekChar() === 0x0a) {
  17033. this.nextChar();
  17034. }
  17035. break;
  17036. case 0x0a:
  17037. break;
  17038. default:
  17039. strBuf.push(String.fromCharCode(ch));
  17040. break;
  17041. }
  17042. break;
  17043. default:
  17044. strBuf.push(String.fromCharCode(ch));
  17045. break;
  17046. }
  17047. if (done) {
  17048. break;
  17049. }
  17050. if (!charBuffered) {
  17051. ch = this.nextChar();
  17052. }
  17053. }
  17054. return strBuf.join("");
  17055. }
  17056. getName() {
  17057. let ch, previousCh;
  17058. const strBuf = this.strBuf;
  17059. strBuf.length = 0;
  17060. while ((ch = this.nextChar()) >= 0 && !specialChars[ch]) {
  17061. if (ch === 0x23) {
  17062. ch = this.nextChar();
  17063. if (specialChars[ch]) {
  17064. (0, _util.warn)("Lexer_getName: " + "NUMBER SIGN (#) should be followed by a hexadecimal number.");
  17065. strBuf.push("#");
  17066. break;
  17067. }
  17068. const x = toHexDigit(ch);
  17069. if (x !== -1) {
  17070. previousCh = ch;
  17071. ch = this.nextChar();
  17072. const x2 = toHexDigit(ch);
  17073. if (x2 === -1) {
  17074. (0, _util.warn)(`Lexer_getName: Illegal digit (${String.fromCharCode(ch)}) ` + "in hexadecimal number.");
  17075. strBuf.push("#", String.fromCharCode(previousCh));
  17076. if (specialChars[ch]) {
  17077. break;
  17078. }
  17079. strBuf.push(String.fromCharCode(ch));
  17080. continue;
  17081. }
  17082. strBuf.push(String.fromCharCode(x << 4 | x2));
  17083. } else {
  17084. strBuf.push("#", String.fromCharCode(ch));
  17085. }
  17086. } else {
  17087. strBuf.push(String.fromCharCode(ch));
  17088. }
  17089. }
  17090. if (strBuf.length > 127) {
  17091. (0, _util.warn)(`Name token is longer than allowed by the spec: ${strBuf.length}`);
  17092. }
  17093. return _primitives.Name.get(strBuf.join(""));
  17094. }
  17095. _hexStringWarn(ch) {
  17096. const MAX_HEX_STRING_NUM_WARN = 5;
  17097. if (this._hexStringNumWarn++ === MAX_HEX_STRING_NUM_WARN) {
  17098. (0, _util.warn)("getHexString - ignoring additional invalid characters.");
  17099. return;
  17100. }
  17101. if (this._hexStringNumWarn > MAX_HEX_STRING_NUM_WARN) {
  17102. return;
  17103. }
  17104. (0, _util.warn)(`getHexString - ignoring invalid character: ${ch}`);
  17105. }
  17106. getHexString() {
  17107. const strBuf = this.strBuf;
  17108. strBuf.length = 0;
  17109. let ch = this.currentChar;
  17110. let isFirstHex = true;
  17111. let firstDigit, secondDigit;
  17112. this._hexStringNumWarn = 0;
  17113. while (true) {
  17114. if (ch < 0) {
  17115. (0, _util.warn)("Unterminated hex string");
  17116. break;
  17117. } else if (ch === 0x3e) {
  17118. this.nextChar();
  17119. break;
  17120. } else if (specialChars[ch] === 1) {
  17121. ch = this.nextChar();
  17122. continue;
  17123. } else {
  17124. if (isFirstHex) {
  17125. firstDigit = toHexDigit(ch);
  17126. if (firstDigit === -1) {
  17127. this._hexStringWarn(ch);
  17128. ch = this.nextChar();
  17129. continue;
  17130. }
  17131. } else {
  17132. secondDigit = toHexDigit(ch);
  17133. if (secondDigit === -1) {
  17134. this._hexStringWarn(ch);
  17135. ch = this.nextChar();
  17136. continue;
  17137. }
  17138. strBuf.push(String.fromCharCode(firstDigit << 4 | secondDigit));
  17139. }
  17140. isFirstHex = !isFirstHex;
  17141. ch = this.nextChar();
  17142. }
  17143. }
  17144. return strBuf.join("");
  17145. }
  17146. getObj() {
  17147. let comment = false;
  17148. let ch = this.currentChar;
  17149. while (true) {
  17150. if (ch < 0) {
  17151. return _primitives.EOF;
  17152. }
  17153. if (comment) {
  17154. if (ch === 0x0a || ch === 0x0d) {
  17155. comment = false;
  17156. }
  17157. } else if (ch === 0x25) {
  17158. comment = true;
  17159. } else if (specialChars[ch] !== 1) {
  17160. break;
  17161. }
  17162. ch = this.nextChar();
  17163. }
  17164. switch (ch | 0) {
  17165. case 0x30:
  17166. case 0x31:
  17167. case 0x32:
  17168. case 0x33:
  17169. case 0x34:
  17170. case 0x35:
  17171. case 0x36:
  17172. case 0x37:
  17173. case 0x38:
  17174. case 0x39:
  17175. case 0x2b:
  17176. case 0x2d:
  17177. case 0x2e:
  17178. return this.getNumber();
  17179. case 0x28:
  17180. return this.getString();
  17181. case 0x2f:
  17182. return this.getName();
  17183. case 0x5b:
  17184. this.nextChar();
  17185. return _primitives.Cmd.get("[");
  17186. case 0x5d:
  17187. this.nextChar();
  17188. return _primitives.Cmd.get("]");
  17189. case 0x3c:
  17190. ch = this.nextChar();
  17191. if (ch === 0x3c) {
  17192. this.nextChar();
  17193. return _primitives.Cmd.get("<<");
  17194. }
  17195. return this.getHexString();
  17196. case 0x3e:
  17197. ch = this.nextChar();
  17198. if (ch === 0x3e) {
  17199. this.nextChar();
  17200. return _primitives.Cmd.get(">>");
  17201. }
  17202. return _primitives.Cmd.get(">");
  17203. case 0x7b:
  17204. this.nextChar();
  17205. return _primitives.Cmd.get("{");
  17206. case 0x7d:
  17207. this.nextChar();
  17208. return _primitives.Cmd.get("}");
  17209. case 0x29:
  17210. this.nextChar();
  17211. throw new _util.FormatError(`Illegal character: ${ch}`);
  17212. }
  17213. let str = String.fromCharCode(ch);
  17214. if (ch < 0x20 || ch > 0x7f) {
  17215. const nextCh = this.peekChar();
  17216. if (nextCh >= 0x20 && nextCh <= 0x7f) {
  17217. this.nextChar();
  17218. return _primitives.Cmd.get(str);
  17219. }
  17220. }
  17221. const knownCommands = this.knownCommands;
  17222. let knownCommandFound = knownCommands?.[str] !== undefined;
  17223. while ((ch = this.nextChar()) >= 0 && !specialChars[ch]) {
  17224. const possibleCommand = str + String.fromCharCode(ch);
  17225. if (knownCommandFound && knownCommands[possibleCommand] === undefined) {
  17226. break;
  17227. }
  17228. if (str.length === 128) {
  17229. throw new _util.FormatError(`Command token too long: ${str.length}`);
  17230. }
  17231. str = possibleCommand;
  17232. knownCommandFound = knownCommands?.[str] !== undefined;
  17233. }
  17234. if (str === "true") {
  17235. return true;
  17236. }
  17237. if (str === "false") {
  17238. return false;
  17239. }
  17240. if (str === "null") {
  17241. return null;
  17242. }
  17243. if (str === "BI") {
  17244. this.beginInlineImagePos = this.stream.pos;
  17245. }
  17246. return _primitives.Cmd.get(str);
  17247. }
  17248. skipToNextLine() {
  17249. let ch = this.currentChar;
  17250. while (ch >= 0) {
  17251. if (ch === 0x0d) {
  17252. ch = this.nextChar();
  17253. if (ch === 0x0a) {
  17254. this.nextChar();
  17255. }
  17256. break;
  17257. } else if (ch === 0x0a) {
  17258. this.nextChar();
  17259. break;
  17260. }
  17261. ch = this.nextChar();
  17262. }
  17263. }
  17264. }
  17265. exports.Lexer = Lexer;
  17266. class Linearization {
  17267. static create(stream) {
  17268. function getInt(linDict, name) {
  17269. let allowZeroValue = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  17270. const obj = linDict.get(name);
  17271. if (Number.isInteger(obj) && (allowZeroValue ? obj >= 0 : obj > 0)) {
  17272. return obj;
  17273. }
  17274. throw new Error(`The "${name}" parameter in the linearization ` + "dictionary is invalid.");
  17275. }
  17276. function getHints(linDict) {
  17277. const hints = linDict.get("H");
  17278. let hintsLength;
  17279. if (Array.isArray(hints) && ((hintsLength = hints.length) === 2 || hintsLength === 4)) {
  17280. for (let index = 0; index < hintsLength; index++) {
  17281. const hint = hints[index];
  17282. if (!(Number.isInteger(hint) && hint > 0)) {
  17283. throw new Error(`Hint (${index}) in the linearization dictionary is invalid.`);
  17284. }
  17285. }
  17286. return hints;
  17287. }
  17288. throw new Error("Hint array in the linearization dictionary is invalid.");
  17289. }
  17290. const parser = new Parser({
  17291. lexer: new Lexer(stream),
  17292. xref: null
  17293. });
  17294. const obj1 = parser.getObj();
  17295. const obj2 = parser.getObj();
  17296. const obj3 = parser.getObj();
  17297. const linDict = parser.getObj();
  17298. let obj, length;
  17299. if (!(Number.isInteger(obj1) && Number.isInteger(obj2) && (0, _primitives.isCmd)(obj3, "obj") && linDict instanceof _primitives.Dict && typeof (obj = linDict.get("Linearized")) === "number" && obj > 0)) {
  17300. return null;
  17301. } else if ((length = getInt(linDict, "L")) !== stream.length) {
  17302. throw new Error('The "L" parameter in the linearization dictionary ' + "does not equal the stream length.");
  17303. }
  17304. return {
  17305. length,
  17306. hints: getHints(linDict),
  17307. objectNumberFirst: getInt(linDict, "O"),
  17308. endFirst: getInt(linDict, "E"),
  17309. numPages: getInt(linDict, "N"),
  17310. mainXRefEntriesOffset: getInt(linDict, "T"),
  17311. pageFirst: linDict.has("P") ? getInt(linDict, "P", true) : 0
  17312. };
  17313. }
  17314. }
  17315. exports.Linearization = Linearization;
  17316. /***/ }),
  17317. /* 168 */
  17318. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  17319. Object.defineProperty(exports, "__esModule", ({
  17320. value: true
  17321. }));
  17322. exports.Ascii85Stream = void 0;
  17323. __w_pdfjs_require__(84);
  17324. __w_pdfjs_require__(93);
  17325. __w_pdfjs_require__(94);
  17326. __w_pdfjs_require__(97);
  17327. __w_pdfjs_require__(99);
  17328. __w_pdfjs_require__(101);
  17329. __w_pdfjs_require__(105);
  17330. __w_pdfjs_require__(108);
  17331. __w_pdfjs_require__(115);
  17332. var _decode_stream = __w_pdfjs_require__(169);
  17333. var _core_utils = __w_pdfjs_require__(150);
  17334. class Ascii85Stream extends _decode_stream.DecodeStream {
  17335. constructor(str, maybeLength) {
  17336. if (maybeLength) {
  17337. maybeLength *= 0.8;
  17338. }
  17339. super(maybeLength);
  17340. this.str = str;
  17341. this.dict = str.dict;
  17342. this.input = new Uint8Array(5);
  17343. }
  17344. readBlock() {
  17345. const TILDA_CHAR = 0x7e;
  17346. const Z_LOWER_CHAR = 0x7a;
  17347. const EOF = -1;
  17348. const str = this.str;
  17349. let c = str.getByte();
  17350. while ((0, _core_utils.isWhiteSpace)(c)) {
  17351. c = str.getByte();
  17352. }
  17353. if (c === EOF || c === TILDA_CHAR) {
  17354. this.eof = true;
  17355. return;
  17356. }
  17357. const bufferLength = this.bufferLength;
  17358. let buffer, i;
  17359. if (c === Z_LOWER_CHAR) {
  17360. buffer = this.ensureBuffer(bufferLength + 4);
  17361. for (i = 0; i < 4; ++i) {
  17362. buffer[bufferLength + i] = 0;
  17363. }
  17364. this.bufferLength += 4;
  17365. } else {
  17366. const input = this.input;
  17367. input[0] = c;
  17368. for (i = 1; i < 5; ++i) {
  17369. c = str.getByte();
  17370. while ((0, _core_utils.isWhiteSpace)(c)) {
  17371. c = str.getByte();
  17372. }
  17373. input[i] = c;
  17374. if (c === EOF || c === TILDA_CHAR) {
  17375. break;
  17376. }
  17377. }
  17378. buffer = this.ensureBuffer(bufferLength + i - 1);
  17379. this.bufferLength += i - 1;
  17380. if (i < 5) {
  17381. for (; i < 5; ++i) {
  17382. input[i] = 0x21 + 84;
  17383. }
  17384. this.eof = true;
  17385. }
  17386. let t = 0;
  17387. for (i = 0; i < 5; ++i) {
  17388. t = t * 85 + (input[i] - 0x21);
  17389. }
  17390. for (i = 3; i >= 0; --i) {
  17391. buffer[bufferLength + i] = t & 0xff;
  17392. t >>= 8;
  17393. }
  17394. }
  17395. }
  17396. }
  17397. exports.Ascii85Stream = Ascii85Stream;
  17398. /***/ }),
  17399. /* 169 */
  17400. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  17401. Object.defineProperty(exports, "__esModule", ({
  17402. value: true
  17403. }));
  17404. exports.StreamsSequenceStream = exports.DecodeStream = void 0;
  17405. __w_pdfjs_require__(84);
  17406. __w_pdfjs_require__(93);
  17407. __w_pdfjs_require__(94);
  17408. __w_pdfjs_require__(97);
  17409. __w_pdfjs_require__(99);
  17410. __w_pdfjs_require__(101);
  17411. __w_pdfjs_require__(105);
  17412. __w_pdfjs_require__(108);
  17413. __w_pdfjs_require__(115);
  17414. __w_pdfjs_require__(140);
  17415. var _base_stream = __w_pdfjs_require__(152);
  17416. var _stream = __w_pdfjs_require__(155);
  17417. const emptyBuffer = new Uint8Array(0);
  17418. class DecodeStream extends _base_stream.BaseStream {
  17419. constructor(maybeMinBufferLength) {
  17420. super();
  17421. this._rawMinBufferLength = maybeMinBufferLength || 0;
  17422. this.pos = 0;
  17423. this.bufferLength = 0;
  17424. this.eof = false;
  17425. this.buffer = emptyBuffer;
  17426. this.minBufferLength = 512;
  17427. if (maybeMinBufferLength) {
  17428. while (this.minBufferLength < maybeMinBufferLength) {
  17429. this.minBufferLength *= 2;
  17430. }
  17431. }
  17432. }
  17433. get isEmpty() {
  17434. while (!this.eof && this.bufferLength === 0) {
  17435. this.readBlock();
  17436. }
  17437. return this.bufferLength === 0;
  17438. }
  17439. ensureBuffer(requested) {
  17440. const buffer = this.buffer;
  17441. if (requested <= buffer.byteLength) {
  17442. return buffer;
  17443. }
  17444. let size = this.minBufferLength;
  17445. while (size < requested) {
  17446. size *= 2;
  17447. }
  17448. const buffer2 = new Uint8Array(size);
  17449. buffer2.set(buffer);
  17450. return this.buffer = buffer2;
  17451. }
  17452. getByte() {
  17453. const pos = this.pos;
  17454. while (this.bufferLength <= pos) {
  17455. if (this.eof) {
  17456. return -1;
  17457. }
  17458. this.readBlock();
  17459. }
  17460. return this.buffer[this.pos++];
  17461. }
  17462. getBytes(length) {
  17463. const pos = this.pos;
  17464. let end;
  17465. if (length) {
  17466. this.ensureBuffer(pos + length);
  17467. end = pos + length;
  17468. while (!this.eof && this.bufferLength < end) {
  17469. this.readBlock();
  17470. }
  17471. const bufEnd = this.bufferLength;
  17472. if (end > bufEnd) {
  17473. end = bufEnd;
  17474. }
  17475. } else {
  17476. while (!this.eof) {
  17477. this.readBlock();
  17478. }
  17479. end = this.bufferLength;
  17480. }
  17481. this.pos = end;
  17482. return this.buffer.subarray(pos, end);
  17483. }
  17484. reset() {
  17485. this.pos = 0;
  17486. }
  17487. makeSubStream(start, length) {
  17488. let dict = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
  17489. if (length === undefined) {
  17490. while (!this.eof) {
  17491. this.readBlock();
  17492. }
  17493. } else {
  17494. const end = start + length;
  17495. while (this.bufferLength <= end && !this.eof) {
  17496. this.readBlock();
  17497. }
  17498. }
  17499. return new _stream.Stream(this.buffer, start, length, dict);
  17500. }
  17501. getBaseStreams() {
  17502. return this.str ? this.str.getBaseStreams() : null;
  17503. }
  17504. }
  17505. exports.DecodeStream = DecodeStream;
  17506. class StreamsSequenceStream extends DecodeStream {
  17507. constructor(streams) {
  17508. let onError = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  17509. let maybeLength = 0;
  17510. for (const stream of streams) {
  17511. maybeLength += stream instanceof DecodeStream ? stream._rawMinBufferLength : stream.length;
  17512. }
  17513. super(maybeLength);
  17514. this.streams = streams;
  17515. this._onError = onError;
  17516. }
  17517. readBlock() {
  17518. const streams = this.streams;
  17519. if (streams.length === 0) {
  17520. this.eof = true;
  17521. return;
  17522. }
  17523. const stream = streams.shift();
  17524. let chunk;
  17525. try {
  17526. chunk = stream.getBytes();
  17527. } catch (reason) {
  17528. if (this._onError) {
  17529. this._onError(reason, stream.dict?.objId);
  17530. return;
  17531. }
  17532. throw reason;
  17533. }
  17534. const bufferLength = this.bufferLength;
  17535. const newLength = bufferLength + chunk.length;
  17536. const buffer = this.ensureBuffer(newLength);
  17537. buffer.set(chunk, bufferLength);
  17538. this.bufferLength = newLength;
  17539. }
  17540. getBaseStreams() {
  17541. const baseStreamsBuf = [];
  17542. for (const stream of this.streams) {
  17543. const baseStreams = stream.getBaseStreams();
  17544. if (baseStreams) {
  17545. baseStreamsBuf.push(...baseStreams);
  17546. }
  17547. }
  17548. return baseStreamsBuf.length > 0 ? baseStreamsBuf : null;
  17549. }
  17550. }
  17551. exports.StreamsSequenceStream = StreamsSequenceStream;
  17552. /***/ }),
  17553. /* 170 */
  17554. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  17555. Object.defineProperty(exports, "__esModule", ({
  17556. value: true
  17557. }));
  17558. exports.AsciiHexStream = void 0;
  17559. var _decode_stream = __w_pdfjs_require__(169);
  17560. class AsciiHexStream extends _decode_stream.DecodeStream {
  17561. constructor(str, maybeLength) {
  17562. if (maybeLength) {
  17563. maybeLength *= 0.5;
  17564. }
  17565. super(maybeLength);
  17566. this.str = str;
  17567. this.dict = str.dict;
  17568. this.firstDigit = -1;
  17569. }
  17570. readBlock() {
  17571. const UPSTREAM_BLOCK_SIZE = 8000;
  17572. const bytes = this.str.getBytes(UPSTREAM_BLOCK_SIZE);
  17573. if (!bytes.length) {
  17574. this.eof = true;
  17575. return;
  17576. }
  17577. const maxDecodeLength = bytes.length + 1 >> 1;
  17578. const buffer = this.ensureBuffer(this.bufferLength + maxDecodeLength);
  17579. let bufferLength = this.bufferLength;
  17580. let firstDigit = this.firstDigit;
  17581. for (const ch of bytes) {
  17582. let digit;
  17583. if (ch >= 0x30 && ch <= 0x39) {
  17584. digit = ch & 0x0f;
  17585. } else if (ch >= 0x41 && ch <= 0x46 || ch >= 0x61 && ch <= 0x66) {
  17586. digit = (ch & 0x0f) + 9;
  17587. } else if (ch === 0x3e) {
  17588. this.eof = true;
  17589. break;
  17590. } else {
  17591. continue;
  17592. }
  17593. if (firstDigit < 0) {
  17594. firstDigit = digit;
  17595. } else {
  17596. buffer[bufferLength++] = firstDigit << 4 | digit;
  17597. firstDigit = -1;
  17598. }
  17599. }
  17600. if (firstDigit >= 0 && this.eof) {
  17601. buffer[bufferLength++] = firstDigit << 4;
  17602. firstDigit = -1;
  17603. }
  17604. this.firstDigit = firstDigit;
  17605. this.bufferLength = bufferLength;
  17606. }
  17607. }
  17608. exports.AsciiHexStream = AsciiHexStream;
  17609. /***/ }),
  17610. /* 171 */
  17611. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  17612. Object.defineProperty(exports, "__esModule", ({
  17613. value: true
  17614. }));
  17615. exports.CCITTFaxStream = void 0;
  17616. var _ccitt = __w_pdfjs_require__(172);
  17617. var _decode_stream = __w_pdfjs_require__(169);
  17618. var _primitives = __w_pdfjs_require__(151);
  17619. class CCITTFaxStream extends _decode_stream.DecodeStream {
  17620. constructor(str, maybeLength, params) {
  17621. super(maybeLength);
  17622. this.str = str;
  17623. this.dict = str.dict;
  17624. if (!(params instanceof _primitives.Dict)) {
  17625. params = _primitives.Dict.empty;
  17626. }
  17627. const source = {
  17628. next() {
  17629. return str.getByte();
  17630. }
  17631. };
  17632. this.ccittFaxDecoder = new _ccitt.CCITTFaxDecoder(source, {
  17633. K: params.get("K"),
  17634. EndOfLine: params.get("EndOfLine"),
  17635. EncodedByteAlign: params.get("EncodedByteAlign"),
  17636. Columns: params.get("Columns"),
  17637. Rows: params.get("Rows"),
  17638. EndOfBlock: params.get("EndOfBlock"),
  17639. BlackIs1: params.get("BlackIs1")
  17640. });
  17641. }
  17642. readBlock() {
  17643. while (!this.eof) {
  17644. const c = this.ccittFaxDecoder.readNextChar();
  17645. if (c === -1) {
  17646. this.eof = true;
  17647. return;
  17648. }
  17649. this.ensureBuffer(this.bufferLength + 1);
  17650. this.buffer[this.bufferLength++] = c;
  17651. }
  17652. }
  17653. }
  17654. exports.CCITTFaxStream = CCITTFaxStream;
  17655. /***/ }),
  17656. /* 172 */
  17657. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  17658. Object.defineProperty(exports, "__esModule", ({
  17659. value: true
  17660. }));
  17661. exports.CCITTFaxDecoder = void 0;
  17662. __w_pdfjs_require__(2);
  17663. __w_pdfjs_require__(84);
  17664. __w_pdfjs_require__(93);
  17665. __w_pdfjs_require__(94);
  17666. __w_pdfjs_require__(97);
  17667. __w_pdfjs_require__(99);
  17668. __w_pdfjs_require__(101);
  17669. __w_pdfjs_require__(105);
  17670. __w_pdfjs_require__(108);
  17671. __w_pdfjs_require__(115);
  17672. var _util = __w_pdfjs_require__(145);
  17673. const ccittEOL = -2;
  17674. const ccittEOF = -1;
  17675. const twoDimPass = 0;
  17676. const twoDimHoriz = 1;
  17677. const twoDimVert0 = 2;
  17678. const twoDimVertR1 = 3;
  17679. const twoDimVertL1 = 4;
  17680. const twoDimVertR2 = 5;
  17681. const twoDimVertL2 = 6;
  17682. const twoDimVertR3 = 7;
  17683. const twoDimVertL3 = 8;
  17684. 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]];
  17685. 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]];
  17686. 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]];
  17687. 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]];
  17688. 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]];
  17689. 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]];
  17690. class CCITTFaxDecoder {
  17691. constructor(source) {
  17692. let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  17693. if (!source || typeof source.next !== "function") {
  17694. throw new Error('CCITTFaxDecoder - invalid "source" parameter.');
  17695. }
  17696. this.source = source;
  17697. this.eof = false;
  17698. this.encoding = options.K || 0;
  17699. this.eoline = options.EndOfLine || false;
  17700. this.byteAlign = options.EncodedByteAlign || false;
  17701. this.columns = options.Columns || 1728;
  17702. this.rows = options.Rows || 0;
  17703. this.eoblock = options.EndOfBlock ?? true;
  17704. this.black = options.BlackIs1 || false;
  17705. this.codingLine = new Uint32Array(this.columns + 1);
  17706. this.refLine = new Uint32Array(this.columns + 2);
  17707. this.codingLine[0] = this.columns;
  17708. this.codingPos = 0;
  17709. this.row = 0;
  17710. this.nextLine2D = this.encoding < 0;
  17711. this.inputBits = 0;
  17712. this.inputBuf = 0;
  17713. this.outputBits = 0;
  17714. this.rowsDone = false;
  17715. let code1;
  17716. while ((code1 = this._lookBits(12)) === 0) {
  17717. this._eatBits(1);
  17718. }
  17719. if (code1 === 1) {
  17720. this._eatBits(12);
  17721. }
  17722. if (this.encoding > 0) {
  17723. this.nextLine2D = !this._lookBits(1);
  17724. this._eatBits(1);
  17725. }
  17726. }
  17727. readNextChar() {
  17728. if (this.eof) {
  17729. return -1;
  17730. }
  17731. const refLine = this.refLine;
  17732. const codingLine = this.codingLine;
  17733. const columns = this.columns;
  17734. let refPos, blackPixels, bits, i;
  17735. if (this.outputBits === 0) {
  17736. if (this.rowsDone) {
  17737. this.eof = true;
  17738. }
  17739. if (this.eof) {
  17740. return -1;
  17741. }
  17742. this.err = false;
  17743. let code1, code2, code3;
  17744. if (this.nextLine2D) {
  17745. for (i = 0; codingLine[i] < columns; ++i) {
  17746. refLine[i] = codingLine[i];
  17747. }
  17748. refLine[i++] = columns;
  17749. refLine[i] = columns;
  17750. codingLine[0] = 0;
  17751. this.codingPos = 0;
  17752. refPos = 0;
  17753. blackPixels = 0;
  17754. while (codingLine[this.codingPos] < columns) {
  17755. code1 = this._getTwoDimCode();
  17756. switch (code1) {
  17757. case twoDimPass:
  17758. this._addPixels(refLine[refPos + 1], blackPixels);
  17759. if (refLine[refPos + 1] < columns) {
  17760. refPos += 2;
  17761. }
  17762. break;
  17763. case twoDimHoriz:
  17764. code1 = code2 = 0;
  17765. if (blackPixels) {
  17766. do {
  17767. code1 += code3 = this._getBlackCode();
  17768. } while (code3 >= 64);
  17769. do {
  17770. code2 += code3 = this._getWhiteCode();
  17771. } while (code3 >= 64);
  17772. } else {
  17773. do {
  17774. code1 += code3 = this._getWhiteCode();
  17775. } while (code3 >= 64);
  17776. do {
  17777. code2 += code3 = this._getBlackCode();
  17778. } while (code3 >= 64);
  17779. }
  17780. this._addPixels(codingLine[this.codingPos] + code1, blackPixels);
  17781. if (codingLine[this.codingPos] < columns) {
  17782. this._addPixels(codingLine[this.codingPos] + code2, blackPixels ^ 1);
  17783. }
  17784. while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
  17785. refPos += 2;
  17786. }
  17787. break;
  17788. case twoDimVertR3:
  17789. this._addPixels(refLine[refPos] + 3, blackPixels);
  17790. blackPixels ^= 1;
  17791. if (codingLine[this.codingPos] < columns) {
  17792. ++refPos;
  17793. while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
  17794. refPos += 2;
  17795. }
  17796. }
  17797. break;
  17798. case twoDimVertR2:
  17799. this._addPixels(refLine[refPos] + 2, blackPixels);
  17800. blackPixels ^= 1;
  17801. if (codingLine[this.codingPos] < columns) {
  17802. ++refPos;
  17803. while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
  17804. refPos += 2;
  17805. }
  17806. }
  17807. break;
  17808. case twoDimVertR1:
  17809. this._addPixels(refLine[refPos] + 1, blackPixels);
  17810. blackPixels ^= 1;
  17811. if (codingLine[this.codingPos] < columns) {
  17812. ++refPos;
  17813. while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
  17814. refPos += 2;
  17815. }
  17816. }
  17817. break;
  17818. case twoDimVert0:
  17819. this._addPixels(refLine[refPos], blackPixels);
  17820. blackPixels ^= 1;
  17821. if (codingLine[this.codingPos] < columns) {
  17822. ++refPos;
  17823. while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
  17824. refPos += 2;
  17825. }
  17826. }
  17827. break;
  17828. case twoDimVertL3:
  17829. this._addPixelsNeg(refLine[refPos] - 3, blackPixels);
  17830. blackPixels ^= 1;
  17831. if (codingLine[this.codingPos] < columns) {
  17832. if (refPos > 0) {
  17833. --refPos;
  17834. } else {
  17835. ++refPos;
  17836. }
  17837. while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
  17838. refPos += 2;
  17839. }
  17840. }
  17841. break;
  17842. case twoDimVertL2:
  17843. this._addPixelsNeg(refLine[refPos] - 2, blackPixels);
  17844. blackPixels ^= 1;
  17845. if (codingLine[this.codingPos] < columns) {
  17846. if (refPos > 0) {
  17847. --refPos;
  17848. } else {
  17849. ++refPos;
  17850. }
  17851. while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
  17852. refPos += 2;
  17853. }
  17854. }
  17855. break;
  17856. case twoDimVertL1:
  17857. this._addPixelsNeg(refLine[refPos] - 1, blackPixels);
  17858. blackPixels ^= 1;
  17859. if (codingLine[this.codingPos] < columns) {
  17860. if (refPos > 0) {
  17861. --refPos;
  17862. } else {
  17863. ++refPos;
  17864. }
  17865. while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
  17866. refPos += 2;
  17867. }
  17868. }
  17869. break;
  17870. case ccittEOF:
  17871. this._addPixels(columns, 0);
  17872. this.eof = true;
  17873. break;
  17874. default:
  17875. (0, _util.info)("bad 2d code");
  17876. this._addPixels(columns, 0);
  17877. this.err = true;
  17878. }
  17879. }
  17880. } else {
  17881. codingLine[0] = 0;
  17882. this.codingPos = 0;
  17883. blackPixels = 0;
  17884. while (codingLine[this.codingPos] < columns) {
  17885. code1 = 0;
  17886. if (blackPixels) {
  17887. do {
  17888. code1 += code3 = this._getBlackCode();
  17889. } while (code3 >= 64);
  17890. } else {
  17891. do {
  17892. code1 += code3 = this._getWhiteCode();
  17893. } while (code3 >= 64);
  17894. }
  17895. this._addPixels(codingLine[this.codingPos] + code1, blackPixels);
  17896. blackPixels ^= 1;
  17897. }
  17898. }
  17899. let gotEOL = false;
  17900. if (this.byteAlign) {
  17901. this.inputBits &= ~7;
  17902. }
  17903. if (!this.eoblock && this.row === this.rows - 1) {
  17904. this.rowsDone = true;
  17905. } else {
  17906. code1 = this._lookBits(12);
  17907. if (this.eoline) {
  17908. while (code1 !== ccittEOF && code1 !== 1) {
  17909. this._eatBits(1);
  17910. code1 = this._lookBits(12);
  17911. }
  17912. } else {
  17913. while (code1 === 0) {
  17914. this._eatBits(1);
  17915. code1 = this._lookBits(12);
  17916. }
  17917. }
  17918. if (code1 === 1) {
  17919. this._eatBits(12);
  17920. gotEOL = true;
  17921. } else if (code1 === ccittEOF) {
  17922. this.eof = true;
  17923. }
  17924. }
  17925. if (!this.eof && this.encoding > 0 && !this.rowsDone) {
  17926. this.nextLine2D = !this._lookBits(1);
  17927. this._eatBits(1);
  17928. }
  17929. if (this.eoblock && gotEOL && this.byteAlign) {
  17930. code1 = this._lookBits(12);
  17931. if (code1 === 1) {
  17932. this._eatBits(12);
  17933. if (this.encoding > 0) {
  17934. this._lookBits(1);
  17935. this._eatBits(1);
  17936. }
  17937. if (this.encoding >= 0) {
  17938. for (i = 0; i < 4; ++i) {
  17939. code1 = this._lookBits(12);
  17940. if (code1 !== 1) {
  17941. (0, _util.info)("bad rtc code: " + code1);
  17942. }
  17943. this._eatBits(12);
  17944. if (this.encoding > 0) {
  17945. this._lookBits(1);
  17946. this._eatBits(1);
  17947. }
  17948. }
  17949. }
  17950. this.eof = true;
  17951. }
  17952. } else if (this.err && this.eoline) {
  17953. while (true) {
  17954. code1 = this._lookBits(13);
  17955. if (code1 === ccittEOF) {
  17956. this.eof = true;
  17957. return -1;
  17958. }
  17959. if (code1 >> 1 === 1) {
  17960. break;
  17961. }
  17962. this._eatBits(1);
  17963. }
  17964. this._eatBits(12);
  17965. if (this.encoding > 0) {
  17966. this._eatBits(1);
  17967. this.nextLine2D = !(code1 & 1);
  17968. }
  17969. }
  17970. this.outputBits = codingLine[0] > 0 ? codingLine[this.codingPos = 0] : codingLine[this.codingPos = 1];
  17971. this.row++;
  17972. }
  17973. let c;
  17974. if (this.outputBits >= 8) {
  17975. c = this.codingPos & 1 ? 0 : 0xff;
  17976. this.outputBits -= 8;
  17977. if (this.outputBits === 0 && codingLine[this.codingPos] < columns) {
  17978. this.codingPos++;
  17979. this.outputBits = codingLine[this.codingPos] - codingLine[this.codingPos - 1];
  17980. }
  17981. } else {
  17982. bits = 8;
  17983. c = 0;
  17984. do {
  17985. if (typeof this.outputBits !== "number") {
  17986. throw new _util.FormatError('Invalid /CCITTFaxDecode data, "outputBits" must be a number.');
  17987. }
  17988. if (this.outputBits > bits) {
  17989. c <<= bits;
  17990. if (!(this.codingPos & 1)) {
  17991. c |= 0xff >> 8 - bits;
  17992. }
  17993. this.outputBits -= bits;
  17994. bits = 0;
  17995. } else {
  17996. c <<= this.outputBits;
  17997. if (!(this.codingPos & 1)) {
  17998. c |= 0xff >> 8 - this.outputBits;
  17999. }
  18000. bits -= this.outputBits;
  18001. this.outputBits = 0;
  18002. if (codingLine[this.codingPos] < columns) {
  18003. this.codingPos++;
  18004. this.outputBits = codingLine[this.codingPos] - codingLine[this.codingPos - 1];
  18005. } else if (bits > 0) {
  18006. c <<= bits;
  18007. bits = 0;
  18008. }
  18009. }
  18010. } while (bits);
  18011. }
  18012. if (this.black) {
  18013. c ^= 0xff;
  18014. }
  18015. return c;
  18016. }
  18017. _addPixels(a1, blackPixels) {
  18018. const codingLine = this.codingLine;
  18019. let codingPos = this.codingPos;
  18020. if (a1 > codingLine[codingPos]) {
  18021. if (a1 > this.columns) {
  18022. (0, _util.info)("row is wrong length");
  18023. this.err = true;
  18024. a1 = this.columns;
  18025. }
  18026. if (codingPos & 1 ^ blackPixels) {
  18027. ++codingPos;
  18028. }
  18029. codingLine[codingPos] = a1;
  18030. }
  18031. this.codingPos = codingPos;
  18032. }
  18033. _addPixelsNeg(a1, blackPixels) {
  18034. const codingLine = this.codingLine;
  18035. let codingPos = this.codingPos;
  18036. if (a1 > codingLine[codingPos]) {
  18037. if (a1 > this.columns) {
  18038. (0, _util.info)("row is wrong length");
  18039. this.err = true;
  18040. a1 = this.columns;
  18041. }
  18042. if (codingPos & 1 ^ blackPixels) {
  18043. ++codingPos;
  18044. }
  18045. codingLine[codingPos] = a1;
  18046. } else if (a1 < codingLine[codingPos]) {
  18047. if (a1 < 0) {
  18048. (0, _util.info)("invalid code");
  18049. this.err = true;
  18050. a1 = 0;
  18051. }
  18052. while (codingPos > 0 && a1 < codingLine[codingPos - 1]) {
  18053. --codingPos;
  18054. }
  18055. codingLine[codingPos] = a1;
  18056. }
  18057. this.codingPos = codingPos;
  18058. }
  18059. _findTableCode(start, end, table, limit) {
  18060. const limitValue = limit || 0;
  18061. for (let i = start; i <= end; ++i) {
  18062. let code = this._lookBits(i);
  18063. if (code === ccittEOF) {
  18064. return [true, 1, false];
  18065. }
  18066. if (i < end) {
  18067. code <<= end - i;
  18068. }
  18069. if (!limitValue || code >= limitValue) {
  18070. const p = table[code - limitValue];
  18071. if (p[0] === i) {
  18072. this._eatBits(i);
  18073. return [true, p[1], true];
  18074. }
  18075. }
  18076. }
  18077. return [false, 0, false];
  18078. }
  18079. _getTwoDimCode() {
  18080. let code = 0;
  18081. let p;
  18082. if (this.eoblock) {
  18083. code = this._lookBits(7);
  18084. p = twoDimTable[code];
  18085. if (p?.[0] > 0) {
  18086. this._eatBits(p[0]);
  18087. return p[1];
  18088. }
  18089. } else {
  18090. const result = this._findTableCode(1, 7, twoDimTable);
  18091. if (result[0] && result[2]) {
  18092. return result[1];
  18093. }
  18094. }
  18095. (0, _util.info)("Bad two dim code");
  18096. return ccittEOF;
  18097. }
  18098. _getWhiteCode() {
  18099. let code = 0;
  18100. let p;
  18101. if (this.eoblock) {
  18102. code = this._lookBits(12);
  18103. if (code === ccittEOF) {
  18104. return 1;
  18105. }
  18106. p = code >> 5 === 0 ? whiteTable1[code] : whiteTable2[code >> 3];
  18107. if (p[0] > 0) {
  18108. this._eatBits(p[0]);
  18109. return p[1];
  18110. }
  18111. } else {
  18112. let result = this._findTableCode(1, 9, whiteTable2);
  18113. if (result[0]) {
  18114. return result[1];
  18115. }
  18116. result = this._findTableCode(11, 12, whiteTable1);
  18117. if (result[0]) {
  18118. return result[1];
  18119. }
  18120. }
  18121. (0, _util.info)("bad white code");
  18122. this._eatBits(1);
  18123. return 1;
  18124. }
  18125. _getBlackCode() {
  18126. let code, p;
  18127. if (this.eoblock) {
  18128. code = this._lookBits(13);
  18129. if (code === ccittEOF) {
  18130. return 1;
  18131. }
  18132. if (code >> 7 === 0) {
  18133. p = blackTable1[code];
  18134. } else if (code >> 9 === 0 && code >> 7 !== 0) {
  18135. p = blackTable2[(code >> 1) - 64];
  18136. } else {
  18137. p = blackTable3[code >> 7];
  18138. }
  18139. if (p[0] > 0) {
  18140. this._eatBits(p[0]);
  18141. return p[1];
  18142. }
  18143. } else {
  18144. let result = this._findTableCode(2, 6, blackTable3);
  18145. if (result[0]) {
  18146. return result[1];
  18147. }
  18148. result = this._findTableCode(7, 12, blackTable2, 64);
  18149. if (result[0]) {
  18150. return result[1];
  18151. }
  18152. result = this._findTableCode(10, 13, blackTable1);
  18153. if (result[0]) {
  18154. return result[1];
  18155. }
  18156. }
  18157. (0, _util.info)("bad black code");
  18158. this._eatBits(1);
  18159. return 1;
  18160. }
  18161. _lookBits(n) {
  18162. let c;
  18163. while (this.inputBits < n) {
  18164. if ((c = this.source.next()) === -1) {
  18165. if (this.inputBits === 0) {
  18166. return ccittEOF;
  18167. }
  18168. return this.inputBuf << n - this.inputBits & 0xffff >> 16 - n;
  18169. }
  18170. this.inputBuf = this.inputBuf << 8 | c;
  18171. this.inputBits += 8;
  18172. }
  18173. return this.inputBuf >> this.inputBits - n & 0xffff >> 16 - n;
  18174. }
  18175. _eatBits(n) {
  18176. if ((this.inputBits -= n) < 0) {
  18177. this.inputBits = 0;
  18178. }
  18179. }
  18180. }
  18181. exports.CCITTFaxDecoder = CCITTFaxDecoder;
  18182. /***/ }),
  18183. /* 173 */
  18184. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  18185. Object.defineProperty(exports, "__esModule", ({
  18186. value: true
  18187. }));
  18188. exports.FlateStream = void 0;
  18189. __w_pdfjs_require__(84);
  18190. __w_pdfjs_require__(93);
  18191. __w_pdfjs_require__(94);
  18192. __w_pdfjs_require__(97);
  18193. __w_pdfjs_require__(99);
  18194. __w_pdfjs_require__(101);
  18195. __w_pdfjs_require__(105);
  18196. __w_pdfjs_require__(108);
  18197. __w_pdfjs_require__(115);
  18198. var _decode_stream = __w_pdfjs_require__(169);
  18199. var _util = __w_pdfjs_require__(145);
  18200. const codeLenCodeMap = new Int32Array([16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15]);
  18201. 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]);
  18202. 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]);
  18203. 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];
  18204. 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];
  18205. class FlateStream extends _decode_stream.DecodeStream {
  18206. constructor(str, maybeLength) {
  18207. super(maybeLength);
  18208. this.str = str;
  18209. this.dict = str.dict;
  18210. const cmf = str.getByte();
  18211. const flg = str.getByte();
  18212. if (cmf === -1 || flg === -1) {
  18213. throw new _util.FormatError(`Invalid header in flate stream: ${cmf}, ${flg}`);
  18214. }
  18215. if ((cmf & 0x0f) !== 0x08) {
  18216. throw new _util.FormatError(`Unknown compression method in flate stream: ${cmf}, ${flg}`);
  18217. }
  18218. if (((cmf << 8) + flg) % 31 !== 0) {
  18219. throw new _util.FormatError(`Bad FCHECK in flate stream: ${cmf}, ${flg}`);
  18220. }
  18221. if (flg & 0x20) {
  18222. throw new _util.FormatError(`FDICT bit set in flate stream: ${cmf}, ${flg}`);
  18223. }
  18224. this.codeSize = 0;
  18225. this.codeBuf = 0;
  18226. }
  18227. getBits(bits) {
  18228. const str = this.str;
  18229. let codeSize = this.codeSize;
  18230. let codeBuf = this.codeBuf;
  18231. let b;
  18232. while (codeSize < bits) {
  18233. if ((b = str.getByte()) === -1) {
  18234. throw new _util.FormatError("Bad encoding in flate stream");
  18235. }
  18236. codeBuf |= b << codeSize;
  18237. codeSize += 8;
  18238. }
  18239. b = codeBuf & (1 << bits) - 1;
  18240. this.codeBuf = codeBuf >> bits;
  18241. this.codeSize = codeSize -= bits;
  18242. return b;
  18243. }
  18244. getCode(table) {
  18245. const str = this.str;
  18246. const codes = table[0];
  18247. const maxLen = table[1];
  18248. let codeSize = this.codeSize;
  18249. let codeBuf = this.codeBuf;
  18250. let b;
  18251. while (codeSize < maxLen) {
  18252. if ((b = str.getByte()) === -1) {
  18253. break;
  18254. }
  18255. codeBuf |= b << codeSize;
  18256. codeSize += 8;
  18257. }
  18258. const code = codes[codeBuf & (1 << maxLen) - 1];
  18259. const codeLen = code >> 16;
  18260. const codeVal = code & 0xffff;
  18261. if (codeLen < 1 || codeSize < codeLen) {
  18262. throw new _util.FormatError("Bad encoding in flate stream");
  18263. }
  18264. this.codeBuf = codeBuf >> codeLen;
  18265. this.codeSize = codeSize - codeLen;
  18266. return codeVal;
  18267. }
  18268. generateHuffmanTable(lengths) {
  18269. const n = lengths.length;
  18270. let maxLen = 0;
  18271. let i;
  18272. for (i = 0; i < n; ++i) {
  18273. if (lengths[i] > maxLen) {
  18274. maxLen = lengths[i];
  18275. }
  18276. }
  18277. const size = 1 << maxLen;
  18278. const codes = new Int32Array(size);
  18279. for (let len = 1, code = 0, skip = 2; len <= maxLen; ++len, code <<= 1, skip <<= 1) {
  18280. for (let val = 0; val < n; ++val) {
  18281. if (lengths[val] === len) {
  18282. let code2 = 0;
  18283. let t = code;
  18284. for (i = 0; i < len; ++i) {
  18285. code2 = code2 << 1 | t & 1;
  18286. t >>= 1;
  18287. }
  18288. for (i = code2; i < size; i += skip) {
  18289. codes[i] = len << 16 | val;
  18290. }
  18291. ++code;
  18292. }
  18293. }
  18294. }
  18295. return [codes, maxLen];
  18296. }
  18297. readBlock() {
  18298. let buffer, len;
  18299. const str = this.str;
  18300. let hdr = this.getBits(3);
  18301. if (hdr & 1) {
  18302. this.eof = true;
  18303. }
  18304. hdr >>= 1;
  18305. if (hdr === 0) {
  18306. let b;
  18307. if ((b = str.getByte()) === -1) {
  18308. throw new _util.FormatError("Bad block header in flate stream");
  18309. }
  18310. let blockLen = b;
  18311. if ((b = str.getByte()) === -1) {
  18312. throw new _util.FormatError("Bad block header in flate stream");
  18313. }
  18314. blockLen |= b << 8;
  18315. if ((b = str.getByte()) === -1) {
  18316. throw new _util.FormatError("Bad block header in flate stream");
  18317. }
  18318. let check = b;
  18319. if ((b = str.getByte()) === -1) {
  18320. throw new _util.FormatError("Bad block header in flate stream");
  18321. }
  18322. check |= b << 8;
  18323. if (check !== (~blockLen & 0xffff) && (blockLen !== 0 || check !== 0)) {
  18324. throw new _util.FormatError("Bad uncompressed block length in flate stream");
  18325. }
  18326. this.codeBuf = 0;
  18327. this.codeSize = 0;
  18328. const bufferLength = this.bufferLength,
  18329. end = bufferLength + blockLen;
  18330. buffer = this.ensureBuffer(end);
  18331. this.bufferLength = end;
  18332. if (blockLen === 0) {
  18333. if (str.peekByte() === -1) {
  18334. this.eof = true;
  18335. }
  18336. } else {
  18337. const block = str.getBytes(blockLen);
  18338. buffer.set(block, bufferLength);
  18339. if (block.length < blockLen) {
  18340. this.eof = true;
  18341. }
  18342. }
  18343. return;
  18344. }
  18345. let litCodeTable;
  18346. let distCodeTable;
  18347. if (hdr === 1) {
  18348. litCodeTable = fixedLitCodeTab;
  18349. distCodeTable = fixedDistCodeTab;
  18350. } else if (hdr === 2) {
  18351. const numLitCodes = this.getBits(5) + 257;
  18352. const numDistCodes = this.getBits(5) + 1;
  18353. const numCodeLenCodes = this.getBits(4) + 4;
  18354. const codeLenCodeLengths = new Uint8Array(codeLenCodeMap.length);
  18355. let i;
  18356. for (i = 0; i < numCodeLenCodes; ++i) {
  18357. codeLenCodeLengths[codeLenCodeMap[i]] = this.getBits(3);
  18358. }
  18359. const codeLenCodeTab = this.generateHuffmanTable(codeLenCodeLengths);
  18360. len = 0;
  18361. i = 0;
  18362. const codes = numLitCodes + numDistCodes;
  18363. const codeLengths = new Uint8Array(codes);
  18364. let bitsLength, bitsOffset, what;
  18365. while (i < codes) {
  18366. const code = this.getCode(codeLenCodeTab);
  18367. if (code === 16) {
  18368. bitsLength = 2;
  18369. bitsOffset = 3;
  18370. what = len;
  18371. } else if (code === 17) {
  18372. bitsLength = 3;
  18373. bitsOffset = 3;
  18374. what = len = 0;
  18375. } else if (code === 18) {
  18376. bitsLength = 7;
  18377. bitsOffset = 11;
  18378. what = len = 0;
  18379. } else {
  18380. codeLengths[i++] = len = code;
  18381. continue;
  18382. }
  18383. let repeatLength = this.getBits(bitsLength) + bitsOffset;
  18384. while (repeatLength-- > 0) {
  18385. codeLengths[i++] = what;
  18386. }
  18387. }
  18388. litCodeTable = this.generateHuffmanTable(codeLengths.subarray(0, numLitCodes));
  18389. distCodeTable = this.generateHuffmanTable(codeLengths.subarray(numLitCodes, codes));
  18390. } else {
  18391. throw new _util.FormatError("Unknown block type in flate stream");
  18392. }
  18393. buffer = this.buffer;
  18394. let limit = buffer ? buffer.length : 0;
  18395. let pos = this.bufferLength;
  18396. while (true) {
  18397. let code1 = this.getCode(litCodeTable);
  18398. if (code1 < 256) {
  18399. if (pos + 1 >= limit) {
  18400. buffer = this.ensureBuffer(pos + 1);
  18401. limit = buffer.length;
  18402. }
  18403. buffer[pos++] = code1;
  18404. continue;
  18405. }
  18406. if (code1 === 256) {
  18407. this.bufferLength = pos;
  18408. return;
  18409. }
  18410. code1 -= 257;
  18411. code1 = lengthDecode[code1];
  18412. let code2 = code1 >> 16;
  18413. if (code2 > 0) {
  18414. code2 = this.getBits(code2);
  18415. }
  18416. len = (code1 & 0xffff) + code2;
  18417. code1 = this.getCode(distCodeTable);
  18418. code1 = distDecode[code1];
  18419. code2 = code1 >> 16;
  18420. if (code2 > 0) {
  18421. code2 = this.getBits(code2);
  18422. }
  18423. const dist = (code1 & 0xffff) + code2;
  18424. if (pos + len >= limit) {
  18425. buffer = this.ensureBuffer(pos + len);
  18426. limit = buffer.length;
  18427. }
  18428. for (let k = 0; k < len; ++k, ++pos) {
  18429. buffer[pos] = buffer[pos - dist];
  18430. }
  18431. }
  18432. }
  18433. }
  18434. exports.FlateStream = FlateStream;
  18435. /***/ }),
  18436. /* 174 */
  18437. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  18438. Object.defineProperty(exports, "__esModule", ({
  18439. value: true
  18440. }));
  18441. exports.Jbig2Stream = void 0;
  18442. __w_pdfjs_require__(140);
  18443. var _base_stream = __w_pdfjs_require__(152);
  18444. var _decode_stream = __w_pdfjs_require__(169);
  18445. var _primitives = __w_pdfjs_require__(151);
  18446. var _jbig = __w_pdfjs_require__(175);
  18447. var _util = __w_pdfjs_require__(145);
  18448. class Jbig2Stream extends _decode_stream.DecodeStream {
  18449. constructor(stream, maybeLength, params) {
  18450. super(maybeLength);
  18451. this.stream = stream;
  18452. this.dict = stream.dict;
  18453. this.maybeLength = maybeLength;
  18454. this.params = params;
  18455. }
  18456. get bytes() {
  18457. return (0, _util.shadow)(this, "bytes", this.stream.getBytes(this.maybeLength));
  18458. }
  18459. ensureBuffer(requested) {}
  18460. readBlock() {
  18461. if (this.eof) {
  18462. return;
  18463. }
  18464. const jbig2Image = new _jbig.Jbig2Image();
  18465. const chunks = [];
  18466. if (this.params instanceof _primitives.Dict) {
  18467. const globalsStream = this.params.get("JBIG2Globals");
  18468. if (globalsStream instanceof _base_stream.BaseStream) {
  18469. const globals = globalsStream.getBytes();
  18470. chunks.push({
  18471. data: globals,
  18472. start: 0,
  18473. end: globals.length
  18474. });
  18475. }
  18476. }
  18477. chunks.push({
  18478. data: this.bytes,
  18479. start: 0,
  18480. end: this.bytes.length
  18481. });
  18482. const data = jbig2Image.parseChunks(chunks);
  18483. const dataLength = data.length;
  18484. for (let i = 0; i < dataLength; i++) {
  18485. data[i] ^= 0xff;
  18486. }
  18487. this.buffer = data;
  18488. this.bufferLength = dataLength;
  18489. this.eof = true;
  18490. }
  18491. }
  18492. exports.Jbig2Stream = Jbig2Stream;
  18493. /***/ }),
  18494. /* 175 */
  18495. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  18496. Object.defineProperty(exports, "__esModule", ({
  18497. value: true
  18498. }));
  18499. exports.Jbig2Image = void 0;
  18500. __w_pdfjs_require__(84);
  18501. __w_pdfjs_require__(93);
  18502. __w_pdfjs_require__(94);
  18503. __w_pdfjs_require__(97);
  18504. __w_pdfjs_require__(99);
  18505. __w_pdfjs_require__(101);
  18506. __w_pdfjs_require__(105);
  18507. __w_pdfjs_require__(108);
  18508. __w_pdfjs_require__(115);
  18509. __w_pdfjs_require__(140);
  18510. __w_pdfjs_require__(2);
  18511. var _util = __w_pdfjs_require__(145);
  18512. var _core_utils = __w_pdfjs_require__(150);
  18513. var _arithmetic_decoder = __w_pdfjs_require__(176);
  18514. var _ccitt = __w_pdfjs_require__(172);
  18515. class Jbig2Error extends _util.BaseException {
  18516. constructor(msg) {
  18517. super(`JBIG2 error: ${msg}`, "Jbig2Error");
  18518. }
  18519. }
  18520. class ContextCache {
  18521. getContexts(id) {
  18522. if (id in this) {
  18523. return this[id];
  18524. }
  18525. return this[id] = new Int8Array(1 << 16);
  18526. }
  18527. }
  18528. class DecodingContext {
  18529. constructor(data, start, end) {
  18530. this.data = data;
  18531. this.start = start;
  18532. this.end = end;
  18533. }
  18534. get decoder() {
  18535. const decoder = new _arithmetic_decoder.ArithmeticDecoder(this.data, this.start, this.end);
  18536. return (0, _util.shadow)(this, "decoder", decoder);
  18537. }
  18538. get contextCache() {
  18539. const cache = new ContextCache();
  18540. return (0, _util.shadow)(this, "contextCache", cache);
  18541. }
  18542. }
  18543. const MAX_INT_32 = 2 ** 31 - 1;
  18544. const MIN_INT_32 = -(2 ** 31);
  18545. function decodeInteger(contextCache, procedure, decoder) {
  18546. const contexts = contextCache.getContexts(procedure);
  18547. let prev = 1;
  18548. function readBits(length) {
  18549. let v = 0;
  18550. for (let i = 0; i < length; i++) {
  18551. const bit = decoder.readBit(contexts, prev);
  18552. prev = prev < 256 ? prev << 1 | bit : (prev << 1 | bit) & 511 | 256;
  18553. v = v << 1 | bit;
  18554. }
  18555. return v >>> 0;
  18556. }
  18557. const sign = readBits(1);
  18558. 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);
  18559. let signedValue;
  18560. if (sign === 0) {
  18561. signedValue = value;
  18562. } else if (value > 0) {
  18563. signedValue = -value;
  18564. }
  18565. if (signedValue >= MIN_INT_32 && signedValue <= MAX_INT_32) {
  18566. return signedValue;
  18567. }
  18568. return null;
  18569. }
  18570. function decodeIAID(contextCache, decoder, codeLength) {
  18571. const contexts = contextCache.getContexts("IAID");
  18572. let prev = 1;
  18573. for (let i = 0; i < codeLength; i++) {
  18574. const bit = decoder.readBit(contexts, prev);
  18575. prev = prev << 1 | bit;
  18576. }
  18577. if (codeLength < 31) {
  18578. return prev & (1 << codeLength) - 1;
  18579. }
  18580. return prev & 0x7fffffff;
  18581. }
  18582. 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"];
  18583. const CodingTemplates = [[{
  18584. x: -1,
  18585. y: -2
  18586. }, {
  18587. x: 0,
  18588. y: -2
  18589. }, {
  18590. x: 1,
  18591. y: -2
  18592. }, {
  18593. x: -2,
  18594. y: -1
  18595. }, {
  18596. x: -1,
  18597. y: -1
  18598. }, {
  18599. x: 0,
  18600. y: -1
  18601. }, {
  18602. x: 1,
  18603. y: -1
  18604. }, {
  18605. x: 2,
  18606. y: -1
  18607. }, {
  18608. x: -4,
  18609. y: 0
  18610. }, {
  18611. x: -3,
  18612. y: 0
  18613. }, {
  18614. x: -2,
  18615. y: 0
  18616. }, {
  18617. x: -1,
  18618. y: 0
  18619. }], [{
  18620. x: -1,
  18621. y: -2
  18622. }, {
  18623. x: 0,
  18624. y: -2
  18625. }, {
  18626. x: 1,
  18627. y: -2
  18628. }, {
  18629. x: 2,
  18630. y: -2
  18631. }, {
  18632. x: -2,
  18633. y: -1
  18634. }, {
  18635. x: -1,
  18636. y: -1
  18637. }, {
  18638. x: 0,
  18639. y: -1
  18640. }, {
  18641. x: 1,
  18642. y: -1
  18643. }, {
  18644. x: 2,
  18645. y: -1
  18646. }, {
  18647. x: -3,
  18648. y: 0
  18649. }, {
  18650. x: -2,
  18651. y: 0
  18652. }, {
  18653. x: -1,
  18654. y: 0
  18655. }], [{
  18656. x: -1,
  18657. y: -2
  18658. }, {
  18659. x: 0,
  18660. y: -2
  18661. }, {
  18662. x: 1,
  18663. y: -2
  18664. }, {
  18665. x: -2,
  18666. y: -1
  18667. }, {
  18668. x: -1,
  18669. y: -1
  18670. }, {
  18671. x: 0,
  18672. y: -1
  18673. }, {
  18674. x: 1,
  18675. y: -1
  18676. }, {
  18677. x: -2,
  18678. y: 0
  18679. }, {
  18680. x: -1,
  18681. y: 0
  18682. }], [{
  18683. x: -3,
  18684. y: -1
  18685. }, {
  18686. x: -2,
  18687. y: -1
  18688. }, {
  18689. x: -1,
  18690. y: -1
  18691. }, {
  18692. x: 0,
  18693. y: -1
  18694. }, {
  18695. x: 1,
  18696. y: -1
  18697. }, {
  18698. x: -4,
  18699. y: 0
  18700. }, {
  18701. x: -3,
  18702. y: 0
  18703. }, {
  18704. x: -2,
  18705. y: 0
  18706. }, {
  18707. x: -1,
  18708. y: 0
  18709. }]];
  18710. const RefinementTemplates = [{
  18711. coding: [{
  18712. x: 0,
  18713. y: -1
  18714. }, {
  18715. x: 1,
  18716. y: -1
  18717. }, {
  18718. x: -1,
  18719. y: 0
  18720. }],
  18721. reference: [{
  18722. x: 0,
  18723. y: -1
  18724. }, {
  18725. x: 1,
  18726. y: -1
  18727. }, {
  18728. x: -1,
  18729. y: 0
  18730. }, {
  18731. x: 0,
  18732. y: 0
  18733. }, {
  18734. x: 1,
  18735. y: 0
  18736. }, {
  18737. x: -1,
  18738. y: 1
  18739. }, {
  18740. x: 0,
  18741. y: 1
  18742. }, {
  18743. x: 1,
  18744. y: 1
  18745. }]
  18746. }, {
  18747. coding: [{
  18748. x: -1,
  18749. y: -1
  18750. }, {
  18751. x: 0,
  18752. y: -1
  18753. }, {
  18754. x: 1,
  18755. y: -1
  18756. }, {
  18757. x: -1,
  18758. y: 0
  18759. }],
  18760. reference: [{
  18761. x: 0,
  18762. y: -1
  18763. }, {
  18764. x: -1,
  18765. y: 0
  18766. }, {
  18767. x: 0,
  18768. y: 0
  18769. }, {
  18770. x: 1,
  18771. y: 0
  18772. }, {
  18773. x: 0,
  18774. y: 1
  18775. }, {
  18776. x: 1,
  18777. y: 1
  18778. }]
  18779. }];
  18780. const ReusedContexts = [0x9b25, 0x0795, 0x00e5, 0x0195];
  18781. const RefinementReusedContexts = [0x0020, 0x0008];
  18782. function decodeBitmapTemplate0(width, height, decodingContext) {
  18783. const decoder = decodingContext.decoder;
  18784. const contexts = decodingContext.contextCache.getContexts("GB");
  18785. const bitmap = [];
  18786. let contextLabel, i, j, pixel, row, row1, row2;
  18787. const OLD_PIXEL_MASK = 0x7bf7;
  18788. for (i = 0; i < height; i++) {
  18789. row = bitmap[i] = new Uint8Array(width);
  18790. row1 = i < 1 ? row : bitmap[i - 1];
  18791. row2 = i < 2 ? row : bitmap[i - 2];
  18792. contextLabel = row2[0] << 13 | row2[1] << 12 | row2[2] << 11 | row1[0] << 7 | row1[1] << 6 | row1[2] << 5 | row1[3] << 4;
  18793. for (j = 0; j < width; j++) {
  18794. row[j] = pixel = decoder.readBit(contexts, contextLabel);
  18795. contextLabel = (contextLabel & OLD_PIXEL_MASK) << 1 | (j + 3 < width ? row2[j + 3] << 11 : 0) | (j + 4 < width ? row1[j + 4] << 4 : 0) | pixel;
  18796. }
  18797. }
  18798. return bitmap;
  18799. }
  18800. function decodeBitmap(mmr, width, height, templateIndex, prediction, skip, at, decodingContext) {
  18801. if (mmr) {
  18802. const input = new Reader(decodingContext.data, decodingContext.start, decodingContext.end);
  18803. return decodeMMRBitmap(input, width, height, false);
  18804. }
  18805. 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) {
  18806. return decodeBitmapTemplate0(width, height, decodingContext);
  18807. }
  18808. const useskip = !!skip;
  18809. const template = CodingTemplates[templateIndex].concat(at);
  18810. template.sort(function (a, b) {
  18811. return a.y - b.y || a.x - b.x;
  18812. });
  18813. const templateLength = template.length;
  18814. const templateX = new Int8Array(templateLength);
  18815. const templateY = new Int8Array(templateLength);
  18816. const changingTemplateEntries = [];
  18817. let reuseMask = 0,
  18818. minX = 0,
  18819. maxX = 0,
  18820. minY = 0;
  18821. let c, k;
  18822. for (k = 0; k < templateLength; k++) {
  18823. templateX[k] = template[k].x;
  18824. templateY[k] = template[k].y;
  18825. minX = Math.min(minX, template[k].x);
  18826. maxX = Math.max(maxX, template[k].x);
  18827. minY = Math.min(minY, template[k].y);
  18828. if (k < templateLength - 1 && template[k].y === template[k + 1].y && template[k].x === template[k + 1].x - 1) {
  18829. reuseMask |= 1 << templateLength - 1 - k;
  18830. } else {
  18831. changingTemplateEntries.push(k);
  18832. }
  18833. }
  18834. const changingEntriesLength = changingTemplateEntries.length;
  18835. const changingTemplateX = new Int8Array(changingEntriesLength);
  18836. const changingTemplateY = new Int8Array(changingEntriesLength);
  18837. const changingTemplateBit = new Uint16Array(changingEntriesLength);
  18838. for (c = 0; c < changingEntriesLength; c++) {
  18839. k = changingTemplateEntries[c];
  18840. changingTemplateX[c] = template[k].x;
  18841. changingTemplateY[c] = template[k].y;
  18842. changingTemplateBit[c] = 1 << templateLength - 1 - k;
  18843. }
  18844. const sbb_left = -minX;
  18845. const sbb_top = -minY;
  18846. const sbb_right = width - maxX;
  18847. const pseudoPixelContext = ReusedContexts[templateIndex];
  18848. let row = new Uint8Array(width);
  18849. const bitmap = [];
  18850. const decoder = decodingContext.decoder;
  18851. const contexts = decodingContext.contextCache.getContexts("GB");
  18852. let ltp = 0,
  18853. j,
  18854. i0,
  18855. j0,
  18856. contextLabel = 0,
  18857. bit,
  18858. shift;
  18859. for (let i = 0; i < height; i++) {
  18860. if (prediction) {
  18861. const sltp = decoder.readBit(contexts, pseudoPixelContext);
  18862. ltp ^= sltp;
  18863. if (ltp) {
  18864. bitmap.push(row);
  18865. continue;
  18866. }
  18867. }
  18868. row = new Uint8Array(row);
  18869. bitmap.push(row);
  18870. for (j = 0; j < width; j++) {
  18871. if (useskip && skip[i][j]) {
  18872. row[j] = 0;
  18873. continue;
  18874. }
  18875. if (j >= sbb_left && j < sbb_right && i >= sbb_top) {
  18876. contextLabel = contextLabel << 1 & reuseMask;
  18877. for (k = 0; k < changingEntriesLength; k++) {
  18878. i0 = i + changingTemplateY[k];
  18879. j0 = j + changingTemplateX[k];
  18880. bit = bitmap[i0][j0];
  18881. if (bit) {
  18882. bit = changingTemplateBit[k];
  18883. contextLabel |= bit;
  18884. }
  18885. }
  18886. } else {
  18887. contextLabel = 0;
  18888. shift = templateLength - 1;
  18889. for (k = 0; k < templateLength; k++, shift--) {
  18890. j0 = j + templateX[k];
  18891. if (j0 >= 0 && j0 < width) {
  18892. i0 = i + templateY[k];
  18893. if (i0 >= 0) {
  18894. bit = bitmap[i0][j0];
  18895. if (bit) {
  18896. contextLabel |= bit << shift;
  18897. }
  18898. }
  18899. }
  18900. }
  18901. }
  18902. const pixel = decoder.readBit(contexts, contextLabel);
  18903. row[j] = pixel;
  18904. }
  18905. }
  18906. return bitmap;
  18907. }
  18908. function decodeRefinement(width, height, templateIndex, referenceBitmap, offsetX, offsetY, prediction, at, decodingContext) {
  18909. let codingTemplate = RefinementTemplates[templateIndex].coding;
  18910. if (templateIndex === 0) {
  18911. codingTemplate = codingTemplate.concat([at[0]]);
  18912. }
  18913. const codingTemplateLength = codingTemplate.length;
  18914. const codingTemplateX = new Int32Array(codingTemplateLength);
  18915. const codingTemplateY = new Int32Array(codingTemplateLength);
  18916. let k;
  18917. for (k = 0; k < codingTemplateLength; k++) {
  18918. codingTemplateX[k] = codingTemplate[k].x;
  18919. codingTemplateY[k] = codingTemplate[k].y;
  18920. }
  18921. let referenceTemplate = RefinementTemplates[templateIndex].reference;
  18922. if (templateIndex === 0) {
  18923. referenceTemplate = referenceTemplate.concat([at[1]]);
  18924. }
  18925. const referenceTemplateLength = referenceTemplate.length;
  18926. const referenceTemplateX = new Int32Array(referenceTemplateLength);
  18927. const referenceTemplateY = new Int32Array(referenceTemplateLength);
  18928. for (k = 0; k < referenceTemplateLength; k++) {
  18929. referenceTemplateX[k] = referenceTemplate[k].x;
  18930. referenceTemplateY[k] = referenceTemplate[k].y;
  18931. }
  18932. const referenceWidth = referenceBitmap[0].length;
  18933. const referenceHeight = referenceBitmap.length;
  18934. const pseudoPixelContext = RefinementReusedContexts[templateIndex];
  18935. const bitmap = [];
  18936. const decoder = decodingContext.decoder;
  18937. const contexts = decodingContext.contextCache.getContexts("GR");
  18938. let ltp = 0;
  18939. for (let i = 0; i < height; i++) {
  18940. if (prediction) {
  18941. const sltp = decoder.readBit(contexts, pseudoPixelContext);
  18942. ltp ^= sltp;
  18943. if (ltp) {
  18944. throw new Jbig2Error("prediction is not supported");
  18945. }
  18946. }
  18947. const row = new Uint8Array(width);
  18948. bitmap.push(row);
  18949. for (let j = 0; j < width; j++) {
  18950. let i0, j0;
  18951. let contextLabel = 0;
  18952. for (k = 0; k < codingTemplateLength; k++) {
  18953. i0 = i + codingTemplateY[k];
  18954. j0 = j + codingTemplateX[k];
  18955. if (i0 < 0 || j0 < 0 || j0 >= width) {
  18956. contextLabel <<= 1;
  18957. } else {
  18958. contextLabel = contextLabel << 1 | bitmap[i0][j0];
  18959. }
  18960. }
  18961. for (k = 0; k < referenceTemplateLength; k++) {
  18962. i0 = i + referenceTemplateY[k] - offsetY;
  18963. j0 = j + referenceTemplateX[k] - offsetX;
  18964. if (i0 < 0 || i0 >= referenceHeight || j0 < 0 || j0 >= referenceWidth) {
  18965. contextLabel <<= 1;
  18966. } else {
  18967. contextLabel = contextLabel << 1 | referenceBitmap[i0][j0];
  18968. }
  18969. }
  18970. const pixel = decoder.readBit(contexts, contextLabel);
  18971. row[j] = pixel;
  18972. }
  18973. }
  18974. return bitmap;
  18975. }
  18976. function decodeSymbolDictionary(huffman, refinement, symbols, numberOfNewSymbols, numberOfExportedSymbols, huffmanTables, templateIndex, at, refinementTemplateIndex, refinementAt, decodingContext, huffmanInput) {
  18977. if (huffman && refinement) {
  18978. throw new Jbig2Error("symbol refinement with Huffman is not supported");
  18979. }
  18980. const newSymbols = [];
  18981. let currentHeight = 0;
  18982. let symbolCodeLength = (0, _core_utils.log2)(symbols.length + numberOfNewSymbols);
  18983. const decoder = decodingContext.decoder;
  18984. const contextCache = decodingContext.contextCache;
  18985. let tableB1, symbolWidths;
  18986. if (huffman) {
  18987. tableB1 = getStandardTable(1);
  18988. symbolWidths = [];
  18989. symbolCodeLength = Math.max(symbolCodeLength, 1);
  18990. }
  18991. while (newSymbols.length < numberOfNewSymbols) {
  18992. const deltaHeight = huffman ? huffmanTables.tableDeltaHeight.decode(huffmanInput) : decodeInteger(contextCache, "IADH", decoder);
  18993. currentHeight += deltaHeight;
  18994. let currentWidth = 0,
  18995. totalWidth = 0;
  18996. const firstSymbol = huffman ? symbolWidths.length : 0;
  18997. while (true) {
  18998. const deltaWidth = huffman ? huffmanTables.tableDeltaWidth.decode(huffmanInput) : decodeInteger(contextCache, "IADW", decoder);
  18999. if (deltaWidth === null) {
  19000. break;
  19001. }
  19002. currentWidth += deltaWidth;
  19003. totalWidth += currentWidth;
  19004. let bitmap;
  19005. if (refinement) {
  19006. const numberOfInstances = decodeInteger(contextCache, "IAAI", decoder);
  19007. if (numberOfInstances > 1) {
  19008. bitmap = decodeTextRegion(huffman, refinement, currentWidth, currentHeight, 0, numberOfInstances, 1, symbols.concat(newSymbols), symbolCodeLength, 0, 0, 1, 0, huffmanTables, refinementTemplateIndex, refinementAt, decodingContext, 0, huffmanInput);
  19009. } else {
  19010. const symbolId = decodeIAID(contextCache, decoder, symbolCodeLength);
  19011. const rdx = decodeInteger(contextCache, "IARDX", decoder);
  19012. const rdy = decodeInteger(contextCache, "IARDY", decoder);
  19013. const symbol = symbolId < symbols.length ? symbols[symbolId] : newSymbols[symbolId - symbols.length];
  19014. bitmap = decodeRefinement(currentWidth, currentHeight, refinementTemplateIndex, symbol, rdx, rdy, false, refinementAt, decodingContext);
  19015. }
  19016. newSymbols.push(bitmap);
  19017. } else if (huffman) {
  19018. symbolWidths.push(currentWidth);
  19019. } else {
  19020. bitmap = decodeBitmap(false, currentWidth, currentHeight, templateIndex, false, null, at, decodingContext);
  19021. newSymbols.push(bitmap);
  19022. }
  19023. }
  19024. if (huffman && !refinement) {
  19025. const bitmapSize = huffmanTables.tableBitmapSize.decode(huffmanInput);
  19026. huffmanInput.byteAlign();
  19027. let collectiveBitmap;
  19028. if (bitmapSize === 0) {
  19029. collectiveBitmap = readUncompressedBitmap(huffmanInput, totalWidth, currentHeight);
  19030. } else {
  19031. const originalEnd = huffmanInput.end;
  19032. const bitmapEnd = huffmanInput.position + bitmapSize;
  19033. huffmanInput.end = bitmapEnd;
  19034. collectiveBitmap = decodeMMRBitmap(huffmanInput, totalWidth, currentHeight, false);
  19035. huffmanInput.end = originalEnd;
  19036. huffmanInput.position = bitmapEnd;
  19037. }
  19038. const numberOfSymbolsDecoded = symbolWidths.length;
  19039. if (firstSymbol === numberOfSymbolsDecoded - 1) {
  19040. newSymbols.push(collectiveBitmap);
  19041. } else {
  19042. let i,
  19043. y,
  19044. xMin = 0,
  19045. xMax,
  19046. bitmapWidth,
  19047. symbolBitmap;
  19048. for (i = firstSymbol; i < numberOfSymbolsDecoded; i++) {
  19049. bitmapWidth = symbolWidths[i];
  19050. xMax = xMin + bitmapWidth;
  19051. symbolBitmap = [];
  19052. for (y = 0; y < currentHeight; y++) {
  19053. symbolBitmap.push(collectiveBitmap[y].subarray(xMin, xMax));
  19054. }
  19055. newSymbols.push(symbolBitmap);
  19056. xMin = xMax;
  19057. }
  19058. }
  19059. }
  19060. }
  19061. const exportedSymbols = [],
  19062. flags = [];
  19063. let currentFlag = false,
  19064. i,
  19065. ii;
  19066. const totalSymbolsLength = symbols.length + numberOfNewSymbols;
  19067. while (flags.length < totalSymbolsLength) {
  19068. let runLength = huffman ? tableB1.decode(huffmanInput) : decodeInteger(contextCache, "IAEX", decoder);
  19069. while (runLength--) {
  19070. flags.push(currentFlag);
  19071. }
  19072. currentFlag = !currentFlag;
  19073. }
  19074. for (i = 0, ii = symbols.length; i < ii; i++) {
  19075. if (flags[i]) {
  19076. exportedSymbols.push(symbols[i]);
  19077. }
  19078. }
  19079. for (let j = 0; j < numberOfNewSymbols; i++, j++) {
  19080. if (flags[i]) {
  19081. exportedSymbols.push(newSymbols[j]);
  19082. }
  19083. }
  19084. return exportedSymbols;
  19085. }
  19086. function decodeTextRegion(huffman, refinement, width, height, defaultPixelValue, numberOfSymbolInstances, stripSize, inputSymbols, symbolCodeLength, transposed, dsOffset, referenceCorner, combinationOperator, huffmanTables, refinementTemplateIndex, refinementAt, decodingContext, logStripSize, huffmanInput) {
  19087. if (huffman && refinement) {
  19088. throw new Jbig2Error("refinement with Huffman is not supported");
  19089. }
  19090. const bitmap = [];
  19091. let i, row;
  19092. for (i = 0; i < height; i++) {
  19093. row = new Uint8Array(width);
  19094. if (defaultPixelValue) {
  19095. for (let j = 0; j < width; j++) {
  19096. row[j] = defaultPixelValue;
  19097. }
  19098. }
  19099. bitmap.push(row);
  19100. }
  19101. const decoder = decodingContext.decoder;
  19102. const contextCache = decodingContext.contextCache;
  19103. let stripT = huffman ? -huffmanTables.tableDeltaT.decode(huffmanInput) : -decodeInteger(contextCache, "IADT", decoder);
  19104. let firstS = 0;
  19105. i = 0;
  19106. while (i < numberOfSymbolInstances) {
  19107. const deltaT = huffman ? huffmanTables.tableDeltaT.decode(huffmanInput) : decodeInteger(contextCache, "IADT", decoder);
  19108. stripT += deltaT;
  19109. const deltaFirstS = huffman ? huffmanTables.tableFirstS.decode(huffmanInput) : decodeInteger(contextCache, "IAFS", decoder);
  19110. firstS += deltaFirstS;
  19111. let currentS = firstS;
  19112. do {
  19113. let currentT = 0;
  19114. if (stripSize > 1) {
  19115. currentT = huffman ? huffmanInput.readBits(logStripSize) : decodeInteger(contextCache, "IAIT", decoder);
  19116. }
  19117. const t = stripSize * stripT + currentT;
  19118. const symbolId = huffman ? huffmanTables.symbolIDTable.decode(huffmanInput) : decodeIAID(contextCache, decoder, symbolCodeLength);
  19119. const applyRefinement = refinement && (huffman ? huffmanInput.readBit() : decodeInteger(contextCache, "IARI", decoder));
  19120. let symbolBitmap = inputSymbols[symbolId];
  19121. let symbolWidth = symbolBitmap[0].length;
  19122. let symbolHeight = symbolBitmap.length;
  19123. if (applyRefinement) {
  19124. const rdw = decodeInteger(contextCache, "IARDW", decoder);
  19125. const rdh = decodeInteger(contextCache, "IARDH", decoder);
  19126. const rdx = decodeInteger(contextCache, "IARDX", decoder);
  19127. const rdy = decodeInteger(contextCache, "IARDY", decoder);
  19128. symbolWidth += rdw;
  19129. symbolHeight += rdh;
  19130. symbolBitmap = decodeRefinement(symbolWidth, symbolHeight, refinementTemplateIndex, symbolBitmap, (rdw >> 1) + rdx, (rdh >> 1) + rdy, false, refinementAt, decodingContext);
  19131. }
  19132. const offsetT = t - (referenceCorner & 1 ? 0 : symbolHeight - 1);
  19133. const offsetS = currentS - (referenceCorner & 2 ? symbolWidth - 1 : 0);
  19134. let s2, t2, symbolRow;
  19135. if (transposed) {
  19136. for (s2 = 0; s2 < symbolHeight; s2++) {
  19137. row = bitmap[offsetS + s2];
  19138. if (!row) {
  19139. continue;
  19140. }
  19141. symbolRow = symbolBitmap[s2];
  19142. const maxWidth = Math.min(width - offsetT, symbolWidth);
  19143. switch (combinationOperator) {
  19144. case 0:
  19145. for (t2 = 0; t2 < maxWidth; t2++) {
  19146. row[offsetT + t2] |= symbolRow[t2];
  19147. }
  19148. break;
  19149. case 2:
  19150. for (t2 = 0; t2 < maxWidth; t2++) {
  19151. row[offsetT + t2] ^= symbolRow[t2];
  19152. }
  19153. break;
  19154. default:
  19155. throw new Jbig2Error(`operator ${combinationOperator} is not supported`);
  19156. }
  19157. }
  19158. currentS += symbolHeight - 1;
  19159. } else {
  19160. for (t2 = 0; t2 < symbolHeight; t2++) {
  19161. row = bitmap[offsetT + t2];
  19162. if (!row) {
  19163. continue;
  19164. }
  19165. symbolRow = symbolBitmap[t2];
  19166. switch (combinationOperator) {
  19167. case 0:
  19168. for (s2 = 0; s2 < symbolWidth; s2++) {
  19169. row[offsetS + s2] |= symbolRow[s2];
  19170. }
  19171. break;
  19172. case 2:
  19173. for (s2 = 0; s2 < symbolWidth; s2++) {
  19174. row[offsetS + s2] ^= symbolRow[s2];
  19175. }
  19176. break;
  19177. default:
  19178. throw new Jbig2Error(`operator ${combinationOperator} is not supported`);
  19179. }
  19180. }
  19181. currentS += symbolWidth - 1;
  19182. }
  19183. i++;
  19184. const deltaS = huffman ? huffmanTables.tableDeltaS.decode(huffmanInput) : decodeInteger(contextCache, "IADS", decoder);
  19185. if (deltaS === null) {
  19186. break;
  19187. }
  19188. currentS += deltaS + dsOffset;
  19189. } while (true);
  19190. }
  19191. return bitmap;
  19192. }
  19193. function decodePatternDictionary(mmr, patternWidth, patternHeight, maxPatternIndex, template, decodingContext) {
  19194. const at = [];
  19195. if (!mmr) {
  19196. at.push({
  19197. x: -patternWidth,
  19198. y: 0
  19199. });
  19200. if (template === 0) {
  19201. at.push({
  19202. x: -3,
  19203. y: -1
  19204. }, {
  19205. x: 2,
  19206. y: -2
  19207. }, {
  19208. x: -2,
  19209. y: -2
  19210. });
  19211. }
  19212. }
  19213. const collectiveWidth = (maxPatternIndex + 1) * patternWidth;
  19214. const collectiveBitmap = decodeBitmap(mmr, collectiveWidth, patternHeight, template, false, null, at, decodingContext);
  19215. const patterns = [];
  19216. for (let i = 0; i <= maxPatternIndex; i++) {
  19217. const patternBitmap = [];
  19218. const xMin = patternWidth * i;
  19219. const xMax = xMin + patternWidth;
  19220. for (let y = 0; y < patternHeight; y++) {
  19221. patternBitmap.push(collectiveBitmap[y].subarray(xMin, xMax));
  19222. }
  19223. patterns.push(patternBitmap);
  19224. }
  19225. return patterns;
  19226. }
  19227. function decodeHalftoneRegion(mmr, patterns, template, regionWidth, regionHeight, defaultPixelValue, enableSkip, combinationOperator, gridWidth, gridHeight, gridOffsetX, gridOffsetY, gridVectorX, gridVectorY, decodingContext) {
  19228. const skip = null;
  19229. if (enableSkip) {
  19230. throw new Jbig2Error("skip is not supported");
  19231. }
  19232. if (combinationOperator !== 0) {
  19233. throw new Jbig2Error(`operator "${combinationOperator}" is not supported in halftone region`);
  19234. }
  19235. const regionBitmap = [];
  19236. let i, j, row;
  19237. for (i = 0; i < regionHeight; i++) {
  19238. row = new Uint8Array(regionWidth);
  19239. if (defaultPixelValue) {
  19240. for (j = 0; j < regionWidth; j++) {
  19241. row[j] = defaultPixelValue;
  19242. }
  19243. }
  19244. regionBitmap.push(row);
  19245. }
  19246. const numberOfPatterns = patterns.length;
  19247. const pattern0 = patterns[0];
  19248. const patternWidth = pattern0[0].length,
  19249. patternHeight = pattern0.length;
  19250. const bitsPerValue = (0, _core_utils.log2)(numberOfPatterns);
  19251. const at = [];
  19252. if (!mmr) {
  19253. at.push({
  19254. x: template <= 1 ? 3 : 2,
  19255. y: -1
  19256. });
  19257. if (template === 0) {
  19258. at.push({
  19259. x: -3,
  19260. y: -1
  19261. }, {
  19262. x: 2,
  19263. y: -2
  19264. }, {
  19265. x: -2,
  19266. y: -2
  19267. });
  19268. }
  19269. }
  19270. const grayScaleBitPlanes = [];
  19271. let mmrInput, bitmap;
  19272. if (mmr) {
  19273. mmrInput = new Reader(decodingContext.data, decodingContext.start, decodingContext.end);
  19274. }
  19275. for (i = bitsPerValue - 1; i >= 0; i--) {
  19276. if (mmr) {
  19277. bitmap = decodeMMRBitmap(mmrInput, gridWidth, gridHeight, true);
  19278. } else {
  19279. bitmap = decodeBitmap(false, gridWidth, gridHeight, template, false, skip, at, decodingContext);
  19280. }
  19281. grayScaleBitPlanes[i] = bitmap;
  19282. }
  19283. let mg, ng, bit, patternIndex, patternBitmap, x, y, patternRow, regionRow;
  19284. for (mg = 0; mg < gridHeight; mg++) {
  19285. for (ng = 0; ng < gridWidth; ng++) {
  19286. bit = 0;
  19287. patternIndex = 0;
  19288. for (j = bitsPerValue - 1; j >= 0; j--) {
  19289. bit ^= grayScaleBitPlanes[j][mg][ng];
  19290. patternIndex |= bit << j;
  19291. }
  19292. patternBitmap = patterns[patternIndex];
  19293. x = gridOffsetX + mg * gridVectorY + ng * gridVectorX >> 8;
  19294. y = gridOffsetY + mg * gridVectorX - ng * gridVectorY >> 8;
  19295. if (x >= 0 && x + patternWidth <= regionWidth && y >= 0 && y + patternHeight <= regionHeight) {
  19296. for (i = 0; i < patternHeight; i++) {
  19297. regionRow = regionBitmap[y + i];
  19298. patternRow = patternBitmap[i];
  19299. for (j = 0; j < patternWidth; j++) {
  19300. regionRow[x + j] |= patternRow[j];
  19301. }
  19302. }
  19303. } else {
  19304. let regionX, regionY;
  19305. for (i = 0; i < patternHeight; i++) {
  19306. regionY = y + i;
  19307. if (regionY < 0 || regionY >= regionHeight) {
  19308. continue;
  19309. }
  19310. regionRow = regionBitmap[regionY];
  19311. patternRow = patternBitmap[i];
  19312. for (j = 0; j < patternWidth; j++) {
  19313. regionX = x + j;
  19314. if (regionX >= 0 && regionX < regionWidth) {
  19315. regionRow[regionX] |= patternRow[j];
  19316. }
  19317. }
  19318. }
  19319. }
  19320. }
  19321. }
  19322. return regionBitmap;
  19323. }
  19324. function readSegmentHeader(data, start) {
  19325. const segmentHeader = {};
  19326. segmentHeader.number = (0, _core_utils.readUint32)(data, start);
  19327. const flags = data[start + 4];
  19328. const segmentType = flags & 0x3f;
  19329. if (!SegmentTypes[segmentType]) {
  19330. throw new Jbig2Error("invalid segment type: " + segmentType);
  19331. }
  19332. segmentHeader.type = segmentType;
  19333. segmentHeader.typeName = SegmentTypes[segmentType];
  19334. segmentHeader.deferredNonRetain = !!(flags & 0x80);
  19335. const pageAssociationFieldSize = !!(flags & 0x40);
  19336. const referredFlags = data[start + 5];
  19337. let referredToCount = referredFlags >> 5 & 7;
  19338. const retainBits = [referredFlags & 31];
  19339. let position = start + 6;
  19340. if (referredFlags === 7) {
  19341. referredToCount = (0, _core_utils.readUint32)(data, position - 1) & 0x1fffffff;
  19342. position += 3;
  19343. let bytes = referredToCount + 7 >> 3;
  19344. retainBits[0] = data[position++];
  19345. while (--bytes > 0) {
  19346. retainBits.push(data[position++]);
  19347. }
  19348. } else if (referredFlags === 5 || referredFlags === 6) {
  19349. throw new Jbig2Error("invalid referred-to flags");
  19350. }
  19351. segmentHeader.retainBits = retainBits;
  19352. let referredToSegmentNumberSize = 4;
  19353. if (segmentHeader.number <= 256) {
  19354. referredToSegmentNumberSize = 1;
  19355. } else if (segmentHeader.number <= 65536) {
  19356. referredToSegmentNumberSize = 2;
  19357. }
  19358. const referredTo = [];
  19359. let i, ii;
  19360. for (i = 0; i < referredToCount; i++) {
  19361. let number;
  19362. if (referredToSegmentNumberSize === 1) {
  19363. number = data[position];
  19364. } else if (referredToSegmentNumberSize === 2) {
  19365. number = (0, _core_utils.readUint16)(data, position);
  19366. } else {
  19367. number = (0, _core_utils.readUint32)(data, position);
  19368. }
  19369. referredTo.push(number);
  19370. position += referredToSegmentNumberSize;
  19371. }
  19372. segmentHeader.referredTo = referredTo;
  19373. if (!pageAssociationFieldSize) {
  19374. segmentHeader.pageAssociation = data[position++];
  19375. } else {
  19376. segmentHeader.pageAssociation = (0, _core_utils.readUint32)(data, position);
  19377. position += 4;
  19378. }
  19379. segmentHeader.length = (0, _core_utils.readUint32)(data, position);
  19380. position += 4;
  19381. if (segmentHeader.length === 0xffffffff) {
  19382. if (segmentType === 38) {
  19383. const genericRegionInfo = readRegionSegmentInformation(data, position);
  19384. const genericRegionSegmentFlags = data[position + RegionSegmentInformationFieldLength];
  19385. const genericRegionMmr = !!(genericRegionSegmentFlags & 1);
  19386. const searchPatternLength = 6;
  19387. const searchPattern = new Uint8Array(searchPatternLength);
  19388. if (!genericRegionMmr) {
  19389. searchPattern[0] = 0xff;
  19390. searchPattern[1] = 0xac;
  19391. }
  19392. searchPattern[2] = genericRegionInfo.height >>> 24 & 0xff;
  19393. searchPattern[3] = genericRegionInfo.height >> 16 & 0xff;
  19394. searchPattern[4] = genericRegionInfo.height >> 8 & 0xff;
  19395. searchPattern[5] = genericRegionInfo.height & 0xff;
  19396. for (i = position, ii = data.length; i < ii; i++) {
  19397. let j = 0;
  19398. while (j < searchPatternLength && searchPattern[j] === data[i + j]) {
  19399. j++;
  19400. }
  19401. if (j === searchPatternLength) {
  19402. segmentHeader.length = i + searchPatternLength;
  19403. break;
  19404. }
  19405. }
  19406. if (segmentHeader.length === 0xffffffff) {
  19407. throw new Jbig2Error("segment end was not found");
  19408. }
  19409. } else {
  19410. throw new Jbig2Error("invalid unknown segment length");
  19411. }
  19412. }
  19413. segmentHeader.headerEnd = position;
  19414. return segmentHeader;
  19415. }
  19416. function readSegments(header, data, start, end) {
  19417. const segments = [];
  19418. let position = start;
  19419. while (position < end) {
  19420. const segmentHeader = readSegmentHeader(data, position);
  19421. position = segmentHeader.headerEnd;
  19422. const segment = {
  19423. header: segmentHeader,
  19424. data
  19425. };
  19426. if (!header.randomAccess) {
  19427. segment.start = position;
  19428. position += segmentHeader.length;
  19429. segment.end = position;
  19430. }
  19431. segments.push(segment);
  19432. if (segmentHeader.type === 51) {
  19433. break;
  19434. }
  19435. }
  19436. if (header.randomAccess) {
  19437. for (let i = 0, ii = segments.length; i < ii; i++) {
  19438. segments[i].start = position;
  19439. position += segments[i].header.length;
  19440. segments[i].end = position;
  19441. }
  19442. }
  19443. return segments;
  19444. }
  19445. function readRegionSegmentInformation(data, start) {
  19446. return {
  19447. width: (0, _core_utils.readUint32)(data, start),
  19448. height: (0, _core_utils.readUint32)(data, start + 4),
  19449. x: (0, _core_utils.readUint32)(data, start + 8),
  19450. y: (0, _core_utils.readUint32)(data, start + 12),
  19451. combinationOperator: data[start + 16] & 7
  19452. };
  19453. }
  19454. const RegionSegmentInformationFieldLength = 17;
  19455. function processSegment(segment, visitor) {
  19456. const header = segment.header;
  19457. const data = segment.data,
  19458. end = segment.end;
  19459. let position = segment.start;
  19460. let args, at, i, atLength;
  19461. switch (header.type) {
  19462. case 0:
  19463. const dictionary = {};
  19464. const dictionaryFlags = (0, _core_utils.readUint16)(data, position);
  19465. dictionary.huffman = !!(dictionaryFlags & 1);
  19466. dictionary.refinement = !!(dictionaryFlags & 2);
  19467. dictionary.huffmanDHSelector = dictionaryFlags >> 2 & 3;
  19468. dictionary.huffmanDWSelector = dictionaryFlags >> 4 & 3;
  19469. dictionary.bitmapSizeSelector = dictionaryFlags >> 6 & 1;
  19470. dictionary.aggregationInstancesSelector = dictionaryFlags >> 7 & 1;
  19471. dictionary.bitmapCodingContextUsed = !!(dictionaryFlags & 256);
  19472. dictionary.bitmapCodingContextRetained = !!(dictionaryFlags & 512);
  19473. dictionary.template = dictionaryFlags >> 10 & 3;
  19474. dictionary.refinementTemplate = dictionaryFlags >> 12 & 1;
  19475. position += 2;
  19476. if (!dictionary.huffman) {
  19477. atLength = dictionary.template === 0 ? 4 : 1;
  19478. at = [];
  19479. for (i = 0; i < atLength; i++) {
  19480. at.push({
  19481. x: (0, _core_utils.readInt8)(data, position),
  19482. y: (0, _core_utils.readInt8)(data, position + 1)
  19483. });
  19484. position += 2;
  19485. }
  19486. dictionary.at = at;
  19487. }
  19488. if (dictionary.refinement && !dictionary.refinementTemplate) {
  19489. at = [];
  19490. for (i = 0; i < 2; i++) {
  19491. at.push({
  19492. x: (0, _core_utils.readInt8)(data, position),
  19493. y: (0, _core_utils.readInt8)(data, position + 1)
  19494. });
  19495. position += 2;
  19496. }
  19497. dictionary.refinementAt = at;
  19498. }
  19499. dictionary.numberOfExportedSymbols = (0, _core_utils.readUint32)(data, position);
  19500. position += 4;
  19501. dictionary.numberOfNewSymbols = (0, _core_utils.readUint32)(data, position);
  19502. position += 4;
  19503. args = [dictionary, header.number, header.referredTo, data, position, end];
  19504. break;
  19505. case 6:
  19506. case 7:
  19507. const textRegion = {};
  19508. textRegion.info = readRegionSegmentInformation(data, position);
  19509. position += RegionSegmentInformationFieldLength;
  19510. const textRegionSegmentFlags = (0, _core_utils.readUint16)(data, position);
  19511. position += 2;
  19512. textRegion.huffman = !!(textRegionSegmentFlags & 1);
  19513. textRegion.refinement = !!(textRegionSegmentFlags & 2);
  19514. textRegion.logStripSize = textRegionSegmentFlags >> 2 & 3;
  19515. textRegion.stripSize = 1 << textRegion.logStripSize;
  19516. textRegion.referenceCorner = textRegionSegmentFlags >> 4 & 3;
  19517. textRegion.transposed = !!(textRegionSegmentFlags & 64);
  19518. textRegion.combinationOperator = textRegionSegmentFlags >> 7 & 3;
  19519. textRegion.defaultPixelValue = textRegionSegmentFlags >> 9 & 1;
  19520. textRegion.dsOffset = textRegionSegmentFlags << 17 >> 27;
  19521. textRegion.refinementTemplate = textRegionSegmentFlags >> 15 & 1;
  19522. if (textRegion.huffman) {
  19523. const textRegionHuffmanFlags = (0, _core_utils.readUint16)(data, position);
  19524. position += 2;
  19525. textRegion.huffmanFS = textRegionHuffmanFlags & 3;
  19526. textRegion.huffmanDS = textRegionHuffmanFlags >> 2 & 3;
  19527. textRegion.huffmanDT = textRegionHuffmanFlags >> 4 & 3;
  19528. textRegion.huffmanRefinementDW = textRegionHuffmanFlags >> 6 & 3;
  19529. textRegion.huffmanRefinementDH = textRegionHuffmanFlags >> 8 & 3;
  19530. textRegion.huffmanRefinementDX = textRegionHuffmanFlags >> 10 & 3;
  19531. textRegion.huffmanRefinementDY = textRegionHuffmanFlags >> 12 & 3;
  19532. textRegion.huffmanRefinementSizeSelector = !!(textRegionHuffmanFlags & 0x4000);
  19533. }
  19534. if (textRegion.refinement && !textRegion.refinementTemplate) {
  19535. at = [];
  19536. for (i = 0; i < 2; i++) {
  19537. at.push({
  19538. x: (0, _core_utils.readInt8)(data, position),
  19539. y: (0, _core_utils.readInt8)(data, position + 1)
  19540. });
  19541. position += 2;
  19542. }
  19543. textRegion.refinementAt = at;
  19544. }
  19545. textRegion.numberOfSymbolInstances = (0, _core_utils.readUint32)(data, position);
  19546. position += 4;
  19547. args = [textRegion, header.referredTo, data, position, end];
  19548. break;
  19549. case 16:
  19550. const patternDictionary = {};
  19551. const patternDictionaryFlags = data[position++];
  19552. patternDictionary.mmr = !!(patternDictionaryFlags & 1);
  19553. patternDictionary.template = patternDictionaryFlags >> 1 & 3;
  19554. patternDictionary.patternWidth = data[position++];
  19555. patternDictionary.patternHeight = data[position++];
  19556. patternDictionary.maxPatternIndex = (0, _core_utils.readUint32)(data, position);
  19557. position += 4;
  19558. args = [patternDictionary, header.number, data, position, end];
  19559. break;
  19560. case 22:
  19561. case 23:
  19562. const halftoneRegion = {};
  19563. halftoneRegion.info = readRegionSegmentInformation(data, position);
  19564. position += RegionSegmentInformationFieldLength;
  19565. const halftoneRegionFlags = data[position++];
  19566. halftoneRegion.mmr = !!(halftoneRegionFlags & 1);
  19567. halftoneRegion.template = halftoneRegionFlags >> 1 & 3;
  19568. halftoneRegion.enableSkip = !!(halftoneRegionFlags & 8);
  19569. halftoneRegion.combinationOperator = halftoneRegionFlags >> 4 & 7;
  19570. halftoneRegion.defaultPixelValue = halftoneRegionFlags >> 7 & 1;
  19571. halftoneRegion.gridWidth = (0, _core_utils.readUint32)(data, position);
  19572. position += 4;
  19573. halftoneRegion.gridHeight = (0, _core_utils.readUint32)(data, position);
  19574. position += 4;
  19575. halftoneRegion.gridOffsetX = (0, _core_utils.readUint32)(data, position) & 0xffffffff;
  19576. position += 4;
  19577. halftoneRegion.gridOffsetY = (0, _core_utils.readUint32)(data, position) & 0xffffffff;
  19578. position += 4;
  19579. halftoneRegion.gridVectorX = (0, _core_utils.readUint16)(data, position);
  19580. position += 2;
  19581. halftoneRegion.gridVectorY = (0, _core_utils.readUint16)(data, position);
  19582. position += 2;
  19583. args = [halftoneRegion, header.referredTo, data, position, end];
  19584. break;
  19585. case 38:
  19586. case 39:
  19587. const genericRegion = {};
  19588. genericRegion.info = readRegionSegmentInformation(data, position);
  19589. position += RegionSegmentInformationFieldLength;
  19590. const genericRegionSegmentFlags = data[position++];
  19591. genericRegion.mmr = !!(genericRegionSegmentFlags & 1);
  19592. genericRegion.template = genericRegionSegmentFlags >> 1 & 3;
  19593. genericRegion.prediction = !!(genericRegionSegmentFlags & 8);
  19594. if (!genericRegion.mmr) {
  19595. atLength = genericRegion.template === 0 ? 4 : 1;
  19596. at = [];
  19597. for (i = 0; i < atLength; i++) {
  19598. at.push({
  19599. x: (0, _core_utils.readInt8)(data, position),
  19600. y: (0, _core_utils.readInt8)(data, position + 1)
  19601. });
  19602. position += 2;
  19603. }
  19604. genericRegion.at = at;
  19605. }
  19606. args = [genericRegion, data, position, end];
  19607. break;
  19608. case 48:
  19609. const pageInfo = {
  19610. width: (0, _core_utils.readUint32)(data, position),
  19611. height: (0, _core_utils.readUint32)(data, position + 4),
  19612. resolutionX: (0, _core_utils.readUint32)(data, position + 8),
  19613. resolutionY: (0, _core_utils.readUint32)(data, position + 12)
  19614. };
  19615. if (pageInfo.height === 0xffffffff) {
  19616. delete pageInfo.height;
  19617. }
  19618. const pageSegmentFlags = data[position + 16];
  19619. (0, _core_utils.readUint16)(data, position + 17);
  19620. pageInfo.lossless = !!(pageSegmentFlags & 1);
  19621. pageInfo.refinement = !!(pageSegmentFlags & 2);
  19622. pageInfo.defaultPixelValue = pageSegmentFlags >> 2 & 1;
  19623. pageInfo.combinationOperator = pageSegmentFlags >> 3 & 3;
  19624. pageInfo.requiresBuffer = !!(pageSegmentFlags & 32);
  19625. pageInfo.combinationOperatorOverride = !!(pageSegmentFlags & 64);
  19626. args = [pageInfo];
  19627. break;
  19628. case 49:
  19629. break;
  19630. case 50:
  19631. break;
  19632. case 51:
  19633. break;
  19634. case 53:
  19635. args = [header.number, data, position, end];
  19636. break;
  19637. case 62:
  19638. break;
  19639. default:
  19640. throw new Jbig2Error(`segment type ${header.typeName}(${header.type}) is not implemented`);
  19641. }
  19642. const callbackName = "on" + header.typeName;
  19643. if (callbackName in visitor) {
  19644. visitor[callbackName].apply(visitor, args);
  19645. }
  19646. }
  19647. function processSegments(segments, visitor) {
  19648. for (let i = 0, ii = segments.length; i < ii; i++) {
  19649. processSegment(segments[i], visitor);
  19650. }
  19651. }
  19652. function parseJbig2Chunks(chunks) {
  19653. const visitor = new SimpleSegmentVisitor();
  19654. for (let i = 0, ii = chunks.length; i < ii; i++) {
  19655. const chunk = chunks[i];
  19656. const segments = readSegments({}, chunk.data, chunk.start, chunk.end);
  19657. processSegments(segments, visitor);
  19658. }
  19659. return visitor.buffer;
  19660. }
  19661. function parseJbig2(data) {
  19662. throw new Error("Not implemented: parseJbig2");
  19663. }
  19664. class SimpleSegmentVisitor {
  19665. onPageInformation(info) {
  19666. this.currentPageInfo = info;
  19667. const rowSize = info.width + 7 >> 3;
  19668. const buffer = new Uint8ClampedArray(rowSize * info.height);
  19669. if (info.defaultPixelValue) {
  19670. buffer.fill(0xff);
  19671. }
  19672. this.buffer = buffer;
  19673. }
  19674. drawBitmap(regionInfo, bitmap) {
  19675. const pageInfo = this.currentPageInfo;
  19676. const width = regionInfo.width,
  19677. height = regionInfo.height;
  19678. const rowSize = pageInfo.width + 7 >> 3;
  19679. const combinationOperator = pageInfo.combinationOperatorOverride ? regionInfo.combinationOperator : pageInfo.combinationOperator;
  19680. const buffer = this.buffer;
  19681. const mask0 = 128 >> (regionInfo.x & 7);
  19682. let offset0 = regionInfo.y * rowSize + (regionInfo.x >> 3);
  19683. let i, j, mask, offset;
  19684. switch (combinationOperator) {
  19685. case 0:
  19686. for (i = 0; i < height; i++) {
  19687. mask = mask0;
  19688. offset = offset0;
  19689. for (j = 0; j < width; j++) {
  19690. if (bitmap[i][j]) {
  19691. buffer[offset] |= mask;
  19692. }
  19693. mask >>= 1;
  19694. if (!mask) {
  19695. mask = 128;
  19696. offset++;
  19697. }
  19698. }
  19699. offset0 += rowSize;
  19700. }
  19701. break;
  19702. case 2:
  19703. for (i = 0; i < height; i++) {
  19704. mask = mask0;
  19705. offset = offset0;
  19706. for (j = 0; j < width; j++) {
  19707. if (bitmap[i][j]) {
  19708. buffer[offset] ^= mask;
  19709. }
  19710. mask >>= 1;
  19711. if (!mask) {
  19712. mask = 128;
  19713. offset++;
  19714. }
  19715. }
  19716. offset0 += rowSize;
  19717. }
  19718. break;
  19719. default:
  19720. throw new Jbig2Error(`operator ${combinationOperator} is not supported`);
  19721. }
  19722. }
  19723. onImmediateGenericRegion(region, data, start, end) {
  19724. const regionInfo = region.info;
  19725. const decodingContext = new DecodingContext(data, start, end);
  19726. const bitmap = decodeBitmap(region.mmr, regionInfo.width, regionInfo.height, region.template, region.prediction, null, region.at, decodingContext);
  19727. this.drawBitmap(regionInfo, bitmap);
  19728. }
  19729. onImmediateLosslessGenericRegion() {
  19730. this.onImmediateGenericRegion(...arguments);
  19731. }
  19732. onSymbolDictionary(dictionary, currentSegment, referredSegments, data, start, end) {
  19733. let huffmanTables, huffmanInput;
  19734. if (dictionary.huffman) {
  19735. huffmanTables = getSymbolDictionaryHuffmanTables(dictionary, referredSegments, this.customTables);
  19736. huffmanInput = new Reader(data, start, end);
  19737. }
  19738. let symbols = this.symbols;
  19739. if (!symbols) {
  19740. this.symbols = symbols = {};
  19741. }
  19742. const inputSymbols = [];
  19743. for (const referredSegment of referredSegments) {
  19744. const referredSymbols = symbols[referredSegment];
  19745. if (referredSymbols) {
  19746. inputSymbols.push(...referredSymbols);
  19747. }
  19748. }
  19749. const decodingContext = new DecodingContext(data, start, end);
  19750. symbols[currentSegment] = decodeSymbolDictionary(dictionary.huffman, dictionary.refinement, inputSymbols, dictionary.numberOfNewSymbols, dictionary.numberOfExportedSymbols, huffmanTables, dictionary.template, dictionary.at, dictionary.refinementTemplate, dictionary.refinementAt, decodingContext, huffmanInput);
  19751. }
  19752. onImmediateTextRegion(region, referredSegments, data, start, end) {
  19753. const regionInfo = region.info;
  19754. let huffmanTables, huffmanInput;
  19755. const symbols = this.symbols;
  19756. const inputSymbols = [];
  19757. for (const referredSegment of referredSegments) {
  19758. const referredSymbols = symbols[referredSegment];
  19759. if (referredSymbols) {
  19760. inputSymbols.push(...referredSymbols);
  19761. }
  19762. }
  19763. const symbolCodeLength = (0, _core_utils.log2)(inputSymbols.length);
  19764. if (region.huffman) {
  19765. huffmanInput = new Reader(data, start, end);
  19766. huffmanTables = getTextRegionHuffmanTables(region, referredSegments, this.customTables, inputSymbols.length, huffmanInput);
  19767. }
  19768. const decodingContext = new DecodingContext(data, start, end);
  19769. 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);
  19770. this.drawBitmap(regionInfo, bitmap);
  19771. }
  19772. onImmediateLosslessTextRegion() {
  19773. this.onImmediateTextRegion(...arguments);
  19774. }
  19775. onPatternDictionary(dictionary, currentSegment, data, start, end) {
  19776. let patterns = this.patterns;
  19777. if (!patterns) {
  19778. this.patterns = patterns = {};
  19779. }
  19780. const decodingContext = new DecodingContext(data, start, end);
  19781. patterns[currentSegment] = decodePatternDictionary(dictionary.mmr, dictionary.patternWidth, dictionary.patternHeight, dictionary.maxPatternIndex, dictionary.template, decodingContext);
  19782. }
  19783. onImmediateHalftoneRegion(region, referredSegments, data, start, end) {
  19784. const patterns = this.patterns[referredSegments[0]];
  19785. const regionInfo = region.info;
  19786. const decodingContext = new DecodingContext(data, start, end);
  19787. 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);
  19788. this.drawBitmap(regionInfo, bitmap);
  19789. }
  19790. onImmediateLosslessHalftoneRegion() {
  19791. this.onImmediateHalftoneRegion(...arguments);
  19792. }
  19793. onTables(currentSegment, data, start, end) {
  19794. let customTables = this.customTables;
  19795. if (!customTables) {
  19796. this.customTables = customTables = {};
  19797. }
  19798. customTables[currentSegment] = decodeTablesSegment(data, start, end);
  19799. }
  19800. }
  19801. class HuffmanLine {
  19802. constructor(lineData) {
  19803. if (lineData.length === 2) {
  19804. this.isOOB = true;
  19805. this.rangeLow = 0;
  19806. this.prefixLength = lineData[0];
  19807. this.rangeLength = 0;
  19808. this.prefixCode = lineData[1];
  19809. this.isLowerRange = false;
  19810. } else {
  19811. this.isOOB = false;
  19812. this.rangeLow = lineData[0];
  19813. this.prefixLength = lineData[1];
  19814. this.rangeLength = lineData[2];
  19815. this.prefixCode = lineData[3];
  19816. this.isLowerRange = lineData[4] === "lower";
  19817. }
  19818. }
  19819. }
  19820. class HuffmanTreeNode {
  19821. constructor(line) {
  19822. this.children = [];
  19823. if (line) {
  19824. this.isLeaf = true;
  19825. this.rangeLength = line.rangeLength;
  19826. this.rangeLow = line.rangeLow;
  19827. this.isLowerRange = line.isLowerRange;
  19828. this.isOOB = line.isOOB;
  19829. } else {
  19830. this.isLeaf = false;
  19831. }
  19832. }
  19833. buildTree(line, shift) {
  19834. const bit = line.prefixCode >> shift & 1;
  19835. if (shift <= 0) {
  19836. this.children[bit] = new HuffmanTreeNode(line);
  19837. } else {
  19838. let node = this.children[bit];
  19839. if (!node) {
  19840. this.children[bit] = node = new HuffmanTreeNode(null);
  19841. }
  19842. node.buildTree(line, shift - 1);
  19843. }
  19844. }
  19845. decodeNode(reader) {
  19846. if (this.isLeaf) {
  19847. if (this.isOOB) {
  19848. return null;
  19849. }
  19850. const htOffset = reader.readBits(this.rangeLength);
  19851. return this.rangeLow + (this.isLowerRange ? -htOffset : htOffset);
  19852. }
  19853. const node = this.children[reader.readBit()];
  19854. if (!node) {
  19855. throw new Jbig2Error("invalid Huffman data");
  19856. }
  19857. return node.decodeNode(reader);
  19858. }
  19859. }
  19860. class HuffmanTable {
  19861. constructor(lines, prefixCodesDone) {
  19862. if (!prefixCodesDone) {
  19863. this.assignPrefixCodes(lines);
  19864. }
  19865. this.rootNode = new HuffmanTreeNode(null);
  19866. for (let i = 0, ii = lines.length; i < ii; i++) {
  19867. const line = lines[i];
  19868. if (line.prefixLength > 0) {
  19869. this.rootNode.buildTree(line, line.prefixLength - 1);
  19870. }
  19871. }
  19872. }
  19873. decode(reader) {
  19874. return this.rootNode.decodeNode(reader);
  19875. }
  19876. assignPrefixCodes(lines) {
  19877. const linesLength = lines.length;
  19878. let prefixLengthMax = 0;
  19879. for (let i = 0; i < linesLength; i++) {
  19880. prefixLengthMax = Math.max(prefixLengthMax, lines[i].prefixLength);
  19881. }
  19882. const histogram = new Uint32Array(prefixLengthMax + 1);
  19883. for (let i = 0; i < linesLength; i++) {
  19884. histogram[lines[i].prefixLength]++;
  19885. }
  19886. let currentLength = 1,
  19887. firstCode = 0,
  19888. currentCode,
  19889. currentTemp,
  19890. line;
  19891. histogram[0] = 0;
  19892. while (currentLength <= prefixLengthMax) {
  19893. firstCode = firstCode + histogram[currentLength - 1] << 1;
  19894. currentCode = firstCode;
  19895. currentTemp = 0;
  19896. while (currentTemp < linesLength) {
  19897. line = lines[currentTemp];
  19898. if (line.prefixLength === currentLength) {
  19899. line.prefixCode = currentCode;
  19900. currentCode++;
  19901. }
  19902. currentTemp++;
  19903. }
  19904. currentLength++;
  19905. }
  19906. }
  19907. }
  19908. function decodeTablesSegment(data, start, end) {
  19909. const flags = data[start];
  19910. const lowestValue = (0, _core_utils.readUint32)(data, start + 1) & 0xffffffff;
  19911. const highestValue = (0, _core_utils.readUint32)(data, start + 5) & 0xffffffff;
  19912. const reader = new Reader(data, start + 9, end);
  19913. const prefixSizeBits = (flags >> 1 & 7) + 1;
  19914. const rangeSizeBits = (flags >> 4 & 7) + 1;
  19915. const lines = [];
  19916. let prefixLength,
  19917. rangeLength,
  19918. currentRangeLow = lowestValue;
  19919. do {
  19920. prefixLength = reader.readBits(prefixSizeBits);
  19921. rangeLength = reader.readBits(rangeSizeBits);
  19922. lines.push(new HuffmanLine([currentRangeLow, prefixLength, rangeLength, 0]));
  19923. currentRangeLow += 1 << rangeLength;
  19924. } while (currentRangeLow < highestValue);
  19925. prefixLength = reader.readBits(prefixSizeBits);
  19926. lines.push(new HuffmanLine([lowestValue - 1, prefixLength, 32, 0, "lower"]));
  19927. prefixLength = reader.readBits(prefixSizeBits);
  19928. lines.push(new HuffmanLine([highestValue, prefixLength, 32, 0]));
  19929. if (flags & 1) {
  19930. prefixLength = reader.readBits(prefixSizeBits);
  19931. lines.push(new HuffmanLine([prefixLength, 0]));
  19932. }
  19933. return new HuffmanTable(lines, false);
  19934. }
  19935. const standardTablesCache = {};
  19936. function getStandardTable(number) {
  19937. let table = standardTablesCache[number];
  19938. if (table) {
  19939. return table;
  19940. }
  19941. let lines;
  19942. switch (number) {
  19943. case 1:
  19944. lines = [[0, 1, 4, 0x0], [16, 2, 8, 0x2], [272, 3, 16, 0x6], [65808, 3, 32, 0x7]];
  19945. break;
  19946. case 2:
  19947. 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]];
  19948. break;
  19949. case 3:
  19950. 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]];
  19951. break;
  19952. case 4:
  19953. 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]];
  19954. break;
  19955. case 5:
  19956. 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]];
  19957. break;
  19958. case 6:
  19959. 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]];
  19960. break;
  19961. case 7:
  19962. 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]];
  19963. break;
  19964. case 8:
  19965. 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]];
  19966. break;
  19967. case 9:
  19968. 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]];
  19969. break;
  19970. case 10:
  19971. 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]];
  19972. break;
  19973. case 11:
  19974. 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]];
  19975. break;
  19976. case 12:
  19977. 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]];
  19978. break;
  19979. case 13:
  19980. 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]];
  19981. break;
  19982. case 14:
  19983. lines = [[-2, 3, 0, 0x4], [-1, 3, 0, 0x5], [0, 1, 0, 0x0], [1, 3, 0, 0x6], [2, 3, 0, 0x7]];
  19984. break;
  19985. case 15:
  19986. 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]];
  19987. break;
  19988. default:
  19989. throw new Jbig2Error(`standard table B.${number} does not exist`);
  19990. }
  19991. for (let i = 0, ii = lines.length; i < ii; i++) {
  19992. lines[i] = new HuffmanLine(lines[i]);
  19993. }
  19994. table = new HuffmanTable(lines, true);
  19995. standardTablesCache[number] = table;
  19996. return table;
  19997. }
  19998. class Reader {
  19999. constructor(data, start, end) {
  20000. this.data = data;
  20001. this.start = start;
  20002. this.end = end;
  20003. this.position = start;
  20004. this.shift = -1;
  20005. this.currentByte = 0;
  20006. }
  20007. readBit() {
  20008. if (this.shift < 0) {
  20009. if (this.position >= this.end) {
  20010. throw new Jbig2Error("end of data while reading bit");
  20011. }
  20012. this.currentByte = this.data[this.position++];
  20013. this.shift = 7;
  20014. }
  20015. const bit = this.currentByte >> this.shift & 1;
  20016. this.shift--;
  20017. return bit;
  20018. }
  20019. readBits(numBits) {
  20020. let result = 0,
  20021. i;
  20022. for (i = numBits - 1; i >= 0; i--) {
  20023. result |= this.readBit() << i;
  20024. }
  20025. return result;
  20026. }
  20027. byteAlign() {
  20028. this.shift = -1;
  20029. }
  20030. next() {
  20031. if (this.position >= this.end) {
  20032. return -1;
  20033. }
  20034. return this.data[this.position++];
  20035. }
  20036. }
  20037. function getCustomHuffmanTable(index, referredTo, customTables) {
  20038. let currentIndex = 0;
  20039. for (let i = 0, ii = referredTo.length; i < ii; i++) {
  20040. const table = customTables[referredTo[i]];
  20041. if (table) {
  20042. if (index === currentIndex) {
  20043. return table;
  20044. }
  20045. currentIndex++;
  20046. }
  20047. }
  20048. throw new Jbig2Error("can't find custom Huffman table");
  20049. }
  20050. function getTextRegionHuffmanTables(textRegion, referredTo, customTables, numberOfSymbols, reader) {
  20051. const codes = [];
  20052. for (let i = 0; i <= 34; i++) {
  20053. const codeLength = reader.readBits(4);
  20054. codes.push(new HuffmanLine([i, codeLength, 0, 0]));
  20055. }
  20056. const runCodesTable = new HuffmanTable(codes, false);
  20057. codes.length = 0;
  20058. for (let i = 0; i < numberOfSymbols;) {
  20059. const codeLength = runCodesTable.decode(reader);
  20060. if (codeLength >= 32) {
  20061. let repeatedLength, numberOfRepeats, j;
  20062. switch (codeLength) {
  20063. case 32:
  20064. if (i === 0) {
  20065. throw new Jbig2Error("no previous value in symbol ID table");
  20066. }
  20067. numberOfRepeats = reader.readBits(2) + 3;
  20068. repeatedLength = codes[i - 1].prefixLength;
  20069. break;
  20070. case 33:
  20071. numberOfRepeats = reader.readBits(3) + 3;
  20072. repeatedLength = 0;
  20073. break;
  20074. case 34:
  20075. numberOfRepeats = reader.readBits(7) + 11;
  20076. repeatedLength = 0;
  20077. break;
  20078. default:
  20079. throw new Jbig2Error("invalid code length in symbol ID table");
  20080. }
  20081. for (j = 0; j < numberOfRepeats; j++) {
  20082. codes.push(new HuffmanLine([i, repeatedLength, 0, 0]));
  20083. i++;
  20084. }
  20085. } else {
  20086. codes.push(new HuffmanLine([i, codeLength, 0, 0]));
  20087. i++;
  20088. }
  20089. }
  20090. reader.byteAlign();
  20091. const symbolIDTable = new HuffmanTable(codes, false);
  20092. let customIndex = 0,
  20093. tableFirstS,
  20094. tableDeltaS,
  20095. tableDeltaT;
  20096. switch (textRegion.huffmanFS) {
  20097. case 0:
  20098. case 1:
  20099. tableFirstS = getStandardTable(textRegion.huffmanFS + 6);
  20100. break;
  20101. case 3:
  20102. tableFirstS = getCustomHuffmanTable(customIndex, referredTo, customTables);
  20103. customIndex++;
  20104. break;
  20105. default:
  20106. throw new Jbig2Error("invalid Huffman FS selector");
  20107. }
  20108. switch (textRegion.huffmanDS) {
  20109. case 0:
  20110. case 1:
  20111. case 2:
  20112. tableDeltaS = getStandardTable(textRegion.huffmanDS + 8);
  20113. break;
  20114. case 3:
  20115. tableDeltaS = getCustomHuffmanTable(customIndex, referredTo, customTables);
  20116. customIndex++;
  20117. break;
  20118. default:
  20119. throw new Jbig2Error("invalid Huffman DS selector");
  20120. }
  20121. switch (textRegion.huffmanDT) {
  20122. case 0:
  20123. case 1:
  20124. case 2:
  20125. tableDeltaT = getStandardTable(textRegion.huffmanDT + 11);
  20126. break;
  20127. case 3:
  20128. tableDeltaT = getCustomHuffmanTable(customIndex, referredTo, customTables);
  20129. customIndex++;
  20130. break;
  20131. default:
  20132. throw new Jbig2Error("invalid Huffman DT selector");
  20133. }
  20134. if (textRegion.refinement) {
  20135. throw new Jbig2Error("refinement with Huffman is not supported");
  20136. }
  20137. return {
  20138. symbolIDTable,
  20139. tableFirstS,
  20140. tableDeltaS,
  20141. tableDeltaT
  20142. };
  20143. }
  20144. function getSymbolDictionaryHuffmanTables(dictionary, referredTo, customTables) {
  20145. let customIndex = 0,
  20146. tableDeltaHeight,
  20147. tableDeltaWidth;
  20148. switch (dictionary.huffmanDHSelector) {
  20149. case 0:
  20150. case 1:
  20151. tableDeltaHeight = getStandardTable(dictionary.huffmanDHSelector + 4);
  20152. break;
  20153. case 3:
  20154. tableDeltaHeight = getCustomHuffmanTable(customIndex, referredTo, customTables);
  20155. customIndex++;
  20156. break;
  20157. default:
  20158. throw new Jbig2Error("invalid Huffman DH selector");
  20159. }
  20160. switch (dictionary.huffmanDWSelector) {
  20161. case 0:
  20162. case 1:
  20163. tableDeltaWidth = getStandardTable(dictionary.huffmanDWSelector + 2);
  20164. break;
  20165. case 3:
  20166. tableDeltaWidth = getCustomHuffmanTable(customIndex, referredTo, customTables);
  20167. customIndex++;
  20168. break;
  20169. default:
  20170. throw new Jbig2Error("invalid Huffman DW selector");
  20171. }
  20172. let tableBitmapSize, tableAggregateInstances;
  20173. if (dictionary.bitmapSizeSelector) {
  20174. tableBitmapSize = getCustomHuffmanTable(customIndex, referredTo, customTables);
  20175. customIndex++;
  20176. } else {
  20177. tableBitmapSize = getStandardTable(1);
  20178. }
  20179. if (dictionary.aggregationInstancesSelector) {
  20180. tableAggregateInstances = getCustomHuffmanTable(customIndex, referredTo, customTables);
  20181. } else {
  20182. tableAggregateInstances = getStandardTable(1);
  20183. }
  20184. return {
  20185. tableDeltaHeight,
  20186. tableDeltaWidth,
  20187. tableBitmapSize,
  20188. tableAggregateInstances
  20189. };
  20190. }
  20191. function readUncompressedBitmap(reader, width, height) {
  20192. const bitmap = [];
  20193. for (let y = 0; y < height; y++) {
  20194. const row = new Uint8Array(width);
  20195. bitmap.push(row);
  20196. for (let x = 0; x < width; x++) {
  20197. row[x] = reader.readBit();
  20198. }
  20199. reader.byteAlign();
  20200. }
  20201. return bitmap;
  20202. }
  20203. function decodeMMRBitmap(input, width, height, endOfBlock) {
  20204. const params = {
  20205. K: -1,
  20206. Columns: width,
  20207. Rows: height,
  20208. BlackIs1: true,
  20209. EndOfBlock: endOfBlock
  20210. };
  20211. const decoder = new _ccitt.CCITTFaxDecoder(input, params);
  20212. const bitmap = [];
  20213. let currentByte,
  20214. eof = false;
  20215. for (let y = 0; y < height; y++) {
  20216. const row = new Uint8Array(width);
  20217. bitmap.push(row);
  20218. let shift = -1;
  20219. for (let x = 0; x < width; x++) {
  20220. if (shift < 0) {
  20221. currentByte = decoder.readNextChar();
  20222. if (currentByte === -1) {
  20223. currentByte = 0;
  20224. eof = true;
  20225. }
  20226. shift = 7;
  20227. }
  20228. row[x] = currentByte >> shift & 1;
  20229. shift--;
  20230. }
  20231. }
  20232. if (endOfBlock && !eof) {
  20233. const lookForEOFLimit = 5;
  20234. for (let i = 0; i < lookForEOFLimit; i++) {
  20235. if (decoder.readNextChar() === -1) {
  20236. break;
  20237. }
  20238. }
  20239. }
  20240. return bitmap;
  20241. }
  20242. class Jbig2Image {
  20243. parseChunks(chunks) {
  20244. return parseJbig2Chunks(chunks);
  20245. }
  20246. parse(data) {
  20247. throw new Error("Not implemented: Jbig2Image.parse");
  20248. }
  20249. }
  20250. exports.Jbig2Image = Jbig2Image;
  20251. /***/ }),
  20252. /* 176 */
  20253. /***/ ((__unused_webpack_module, exports) => {
  20254. Object.defineProperty(exports, "__esModule", ({
  20255. value: true
  20256. }));
  20257. exports.ArithmeticDecoder = void 0;
  20258. const QeTable = [{
  20259. qe: 0x5601,
  20260. nmps: 1,
  20261. nlps: 1,
  20262. switchFlag: 1
  20263. }, {
  20264. qe: 0x3401,
  20265. nmps: 2,
  20266. nlps: 6,
  20267. switchFlag: 0
  20268. }, {
  20269. qe: 0x1801,
  20270. nmps: 3,
  20271. nlps: 9,
  20272. switchFlag: 0
  20273. }, {
  20274. qe: 0x0ac1,
  20275. nmps: 4,
  20276. nlps: 12,
  20277. switchFlag: 0
  20278. }, {
  20279. qe: 0x0521,
  20280. nmps: 5,
  20281. nlps: 29,
  20282. switchFlag: 0
  20283. }, {
  20284. qe: 0x0221,
  20285. nmps: 38,
  20286. nlps: 33,
  20287. switchFlag: 0
  20288. }, {
  20289. qe: 0x5601,
  20290. nmps: 7,
  20291. nlps: 6,
  20292. switchFlag: 1
  20293. }, {
  20294. qe: 0x5401,
  20295. nmps: 8,
  20296. nlps: 14,
  20297. switchFlag: 0
  20298. }, {
  20299. qe: 0x4801,
  20300. nmps: 9,
  20301. nlps: 14,
  20302. switchFlag: 0
  20303. }, {
  20304. qe: 0x3801,
  20305. nmps: 10,
  20306. nlps: 14,
  20307. switchFlag: 0
  20308. }, {
  20309. qe: 0x3001,
  20310. nmps: 11,
  20311. nlps: 17,
  20312. switchFlag: 0
  20313. }, {
  20314. qe: 0x2401,
  20315. nmps: 12,
  20316. nlps: 18,
  20317. switchFlag: 0
  20318. }, {
  20319. qe: 0x1c01,
  20320. nmps: 13,
  20321. nlps: 20,
  20322. switchFlag: 0
  20323. }, {
  20324. qe: 0x1601,
  20325. nmps: 29,
  20326. nlps: 21,
  20327. switchFlag: 0
  20328. }, {
  20329. qe: 0x5601,
  20330. nmps: 15,
  20331. nlps: 14,
  20332. switchFlag: 1
  20333. }, {
  20334. qe: 0x5401,
  20335. nmps: 16,
  20336. nlps: 14,
  20337. switchFlag: 0
  20338. }, {
  20339. qe: 0x5101,
  20340. nmps: 17,
  20341. nlps: 15,
  20342. switchFlag: 0
  20343. }, {
  20344. qe: 0x4801,
  20345. nmps: 18,
  20346. nlps: 16,
  20347. switchFlag: 0
  20348. }, {
  20349. qe: 0x3801,
  20350. nmps: 19,
  20351. nlps: 17,
  20352. switchFlag: 0
  20353. }, {
  20354. qe: 0x3401,
  20355. nmps: 20,
  20356. nlps: 18,
  20357. switchFlag: 0
  20358. }, {
  20359. qe: 0x3001,
  20360. nmps: 21,
  20361. nlps: 19,
  20362. switchFlag: 0
  20363. }, {
  20364. qe: 0x2801,
  20365. nmps: 22,
  20366. nlps: 19,
  20367. switchFlag: 0
  20368. }, {
  20369. qe: 0x2401,
  20370. nmps: 23,
  20371. nlps: 20,
  20372. switchFlag: 0
  20373. }, {
  20374. qe: 0x2201,
  20375. nmps: 24,
  20376. nlps: 21,
  20377. switchFlag: 0
  20378. }, {
  20379. qe: 0x1c01,
  20380. nmps: 25,
  20381. nlps: 22,
  20382. switchFlag: 0
  20383. }, {
  20384. qe: 0x1801,
  20385. nmps: 26,
  20386. nlps: 23,
  20387. switchFlag: 0
  20388. }, {
  20389. qe: 0x1601,
  20390. nmps: 27,
  20391. nlps: 24,
  20392. switchFlag: 0
  20393. }, {
  20394. qe: 0x1401,
  20395. nmps: 28,
  20396. nlps: 25,
  20397. switchFlag: 0
  20398. }, {
  20399. qe: 0x1201,
  20400. nmps: 29,
  20401. nlps: 26,
  20402. switchFlag: 0
  20403. }, {
  20404. qe: 0x1101,
  20405. nmps: 30,
  20406. nlps: 27,
  20407. switchFlag: 0
  20408. }, {
  20409. qe: 0x0ac1,
  20410. nmps: 31,
  20411. nlps: 28,
  20412. switchFlag: 0
  20413. }, {
  20414. qe: 0x09c1,
  20415. nmps: 32,
  20416. nlps: 29,
  20417. switchFlag: 0
  20418. }, {
  20419. qe: 0x08a1,
  20420. nmps: 33,
  20421. nlps: 30,
  20422. switchFlag: 0
  20423. }, {
  20424. qe: 0x0521,
  20425. nmps: 34,
  20426. nlps: 31,
  20427. switchFlag: 0
  20428. }, {
  20429. qe: 0x0441,
  20430. nmps: 35,
  20431. nlps: 32,
  20432. switchFlag: 0
  20433. }, {
  20434. qe: 0x02a1,
  20435. nmps: 36,
  20436. nlps: 33,
  20437. switchFlag: 0
  20438. }, {
  20439. qe: 0x0221,
  20440. nmps: 37,
  20441. nlps: 34,
  20442. switchFlag: 0
  20443. }, {
  20444. qe: 0x0141,
  20445. nmps: 38,
  20446. nlps: 35,
  20447. switchFlag: 0
  20448. }, {
  20449. qe: 0x0111,
  20450. nmps: 39,
  20451. nlps: 36,
  20452. switchFlag: 0
  20453. }, {
  20454. qe: 0x0085,
  20455. nmps: 40,
  20456. nlps: 37,
  20457. switchFlag: 0
  20458. }, {
  20459. qe: 0x0049,
  20460. nmps: 41,
  20461. nlps: 38,
  20462. switchFlag: 0
  20463. }, {
  20464. qe: 0x0025,
  20465. nmps: 42,
  20466. nlps: 39,
  20467. switchFlag: 0
  20468. }, {
  20469. qe: 0x0015,
  20470. nmps: 43,
  20471. nlps: 40,
  20472. switchFlag: 0
  20473. }, {
  20474. qe: 0x0009,
  20475. nmps: 44,
  20476. nlps: 41,
  20477. switchFlag: 0
  20478. }, {
  20479. qe: 0x0005,
  20480. nmps: 45,
  20481. nlps: 42,
  20482. switchFlag: 0
  20483. }, {
  20484. qe: 0x0001,
  20485. nmps: 45,
  20486. nlps: 43,
  20487. switchFlag: 0
  20488. }, {
  20489. qe: 0x5601,
  20490. nmps: 46,
  20491. nlps: 46,
  20492. switchFlag: 0
  20493. }];
  20494. class ArithmeticDecoder {
  20495. constructor(data, start, end) {
  20496. this.data = data;
  20497. this.bp = start;
  20498. this.dataEnd = end;
  20499. this.chigh = data[start];
  20500. this.clow = 0;
  20501. this.byteIn();
  20502. this.chigh = this.chigh << 7 & 0xffff | this.clow >> 9 & 0x7f;
  20503. this.clow = this.clow << 7 & 0xffff;
  20504. this.ct -= 7;
  20505. this.a = 0x8000;
  20506. }
  20507. byteIn() {
  20508. const data = this.data;
  20509. let bp = this.bp;
  20510. if (data[bp] === 0xff) {
  20511. if (data[bp + 1] > 0x8f) {
  20512. this.clow += 0xff00;
  20513. this.ct = 8;
  20514. } else {
  20515. bp++;
  20516. this.clow += data[bp] << 9;
  20517. this.ct = 7;
  20518. this.bp = bp;
  20519. }
  20520. } else {
  20521. bp++;
  20522. this.clow += bp < this.dataEnd ? data[bp] << 8 : 0xff00;
  20523. this.ct = 8;
  20524. this.bp = bp;
  20525. }
  20526. if (this.clow > 0xffff) {
  20527. this.chigh += this.clow >> 16;
  20528. this.clow &= 0xffff;
  20529. }
  20530. }
  20531. readBit(contexts, pos) {
  20532. let cx_index = contexts[pos] >> 1,
  20533. cx_mps = contexts[pos] & 1;
  20534. const qeTableIcx = QeTable[cx_index];
  20535. const qeIcx = qeTableIcx.qe;
  20536. let d;
  20537. let a = this.a - qeIcx;
  20538. if (this.chigh < qeIcx) {
  20539. if (a < qeIcx) {
  20540. a = qeIcx;
  20541. d = cx_mps;
  20542. cx_index = qeTableIcx.nmps;
  20543. } else {
  20544. a = qeIcx;
  20545. d = 1 ^ cx_mps;
  20546. if (qeTableIcx.switchFlag === 1) {
  20547. cx_mps = d;
  20548. }
  20549. cx_index = qeTableIcx.nlps;
  20550. }
  20551. } else {
  20552. this.chigh -= qeIcx;
  20553. if ((a & 0x8000) !== 0) {
  20554. this.a = a;
  20555. return cx_mps;
  20556. }
  20557. if (a < qeIcx) {
  20558. d = 1 ^ cx_mps;
  20559. if (qeTableIcx.switchFlag === 1) {
  20560. cx_mps = d;
  20561. }
  20562. cx_index = qeTableIcx.nlps;
  20563. } else {
  20564. d = cx_mps;
  20565. cx_index = qeTableIcx.nmps;
  20566. }
  20567. }
  20568. do {
  20569. if (this.ct === 0) {
  20570. this.byteIn();
  20571. }
  20572. a <<= 1;
  20573. this.chigh = this.chigh << 1 & 0xffff | this.clow >> 15 & 1;
  20574. this.clow = this.clow << 1 & 0xffff;
  20575. this.ct--;
  20576. } while ((a & 0x8000) === 0);
  20577. this.a = a;
  20578. contexts[pos] = cx_index << 1 | cx_mps;
  20579. return d;
  20580. }
  20581. }
  20582. exports.ArithmeticDecoder = ArithmeticDecoder;
  20583. /***/ }),
  20584. /* 177 */
  20585. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  20586. Object.defineProperty(exports, "__esModule", ({
  20587. value: true
  20588. }));
  20589. exports.JpegStream = void 0;
  20590. __w_pdfjs_require__(84);
  20591. __w_pdfjs_require__(93);
  20592. __w_pdfjs_require__(94);
  20593. __w_pdfjs_require__(97);
  20594. __w_pdfjs_require__(99);
  20595. __w_pdfjs_require__(101);
  20596. __w_pdfjs_require__(105);
  20597. __w_pdfjs_require__(108);
  20598. __w_pdfjs_require__(115);
  20599. var _decode_stream = __w_pdfjs_require__(169);
  20600. var _primitives = __w_pdfjs_require__(151);
  20601. var _jpg = __w_pdfjs_require__(178);
  20602. var _util = __w_pdfjs_require__(145);
  20603. class JpegStream extends _decode_stream.DecodeStream {
  20604. constructor(stream, maybeLength, params) {
  20605. let ch;
  20606. while ((ch = stream.getByte()) !== -1) {
  20607. if (ch === 0xff) {
  20608. stream.skip(-1);
  20609. break;
  20610. }
  20611. }
  20612. super(maybeLength);
  20613. this.stream = stream;
  20614. this.dict = stream.dict;
  20615. this.maybeLength = maybeLength;
  20616. this.params = params;
  20617. }
  20618. get bytes() {
  20619. return (0, _util.shadow)(this, "bytes", this.stream.getBytes(this.maybeLength));
  20620. }
  20621. ensureBuffer(requested) {}
  20622. readBlock() {
  20623. if (this.eof) {
  20624. return;
  20625. }
  20626. const jpegOptions = {
  20627. decodeTransform: undefined,
  20628. colorTransform: undefined
  20629. };
  20630. const decodeArr = this.dict.getArray("D", "Decode");
  20631. if ((this.forceRGBA || this.forceRGB) && Array.isArray(decodeArr)) {
  20632. const bitsPerComponent = this.dict.get("BPC", "BitsPerComponent") || 8;
  20633. const decodeArrLength = decodeArr.length;
  20634. const transform = new Int32Array(decodeArrLength);
  20635. let transformNeeded = false;
  20636. const maxValue = (1 << bitsPerComponent) - 1;
  20637. for (let i = 0; i < decodeArrLength; i += 2) {
  20638. transform[i] = (decodeArr[i + 1] - decodeArr[i]) * 256 | 0;
  20639. transform[i + 1] = decodeArr[i] * maxValue | 0;
  20640. if (transform[i] !== 256 || transform[i + 1] !== 0) {
  20641. transformNeeded = true;
  20642. }
  20643. }
  20644. if (transformNeeded) {
  20645. jpegOptions.decodeTransform = transform;
  20646. }
  20647. }
  20648. if (this.params instanceof _primitives.Dict) {
  20649. const colorTransform = this.params.get("ColorTransform");
  20650. if (Number.isInteger(colorTransform)) {
  20651. jpegOptions.colorTransform = colorTransform;
  20652. }
  20653. }
  20654. const jpegImage = new _jpg.JpegImage(jpegOptions);
  20655. jpegImage.parse(this.bytes);
  20656. const data = jpegImage.getData({
  20657. width: this.drawWidth,
  20658. height: this.drawHeight,
  20659. forceRGBA: this.forceRGBA,
  20660. forceRGB: this.forceRGB,
  20661. isSourcePDF: true
  20662. });
  20663. this.buffer = data;
  20664. this.bufferLength = data.length;
  20665. this.eof = true;
  20666. }
  20667. }
  20668. exports.JpegStream = JpegStream;
  20669. /***/ }),
  20670. /* 178 */
  20671. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  20672. Object.defineProperty(exports, "__esModule", ({
  20673. value: true
  20674. }));
  20675. exports.JpegImage = void 0;
  20676. __w_pdfjs_require__(84);
  20677. __w_pdfjs_require__(93);
  20678. __w_pdfjs_require__(94);
  20679. __w_pdfjs_require__(97);
  20680. __w_pdfjs_require__(99);
  20681. __w_pdfjs_require__(101);
  20682. __w_pdfjs_require__(105);
  20683. __w_pdfjs_require__(108);
  20684. __w_pdfjs_require__(115);
  20685. __w_pdfjs_require__(140);
  20686. var _util = __w_pdfjs_require__(145);
  20687. var _image_utils = __w_pdfjs_require__(179);
  20688. var _core_utils = __w_pdfjs_require__(150);
  20689. class JpegError extends _util.BaseException {
  20690. constructor(msg) {
  20691. super(`JPEG error: ${msg}`, "JpegError");
  20692. }
  20693. }
  20694. class DNLMarkerError extends _util.BaseException {
  20695. constructor(message, scanLines) {
  20696. super(message, "DNLMarkerError");
  20697. this.scanLines = scanLines;
  20698. }
  20699. }
  20700. class EOIMarkerError extends _util.BaseException {
  20701. constructor(msg) {
  20702. super(msg, "EOIMarkerError");
  20703. }
  20704. }
  20705. 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]);
  20706. const dctCos1 = 4017;
  20707. const dctSin1 = 799;
  20708. const dctCos3 = 3406;
  20709. const dctSin3 = 2276;
  20710. const dctCos6 = 1567;
  20711. const dctSin6 = 3784;
  20712. const dctSqrt2 = 5793;
  20713. const dctSqrt1d2 = 2896;
  20714. function buildHuffmanTable(codeLengths, values) {
  20715. let k = 0,
  20716. i,
  20717. j,
  20718. length = 16;
  20719. while (length > 0 && !codeLengths[length - 1]) {
  20720. length--;
  20721. }
  20722. const code = [{
  20723. children: [],
  20724. index: 0
  20725. }];
  20726. let p = code[0],
  20727. q;
  20728. for (i = 0; i < length; i++) {
  20729. for (j = 0; j < codeLengths[i]; j++) {
  20730. p = code.pop();
  20731. p.children[p.index] = values[k];
  20732. while (p.index > 0) {
  20733. p = code.pop();
  20734. }
  20735. p.index++;
  20736. code.push(p);
  20737. while (code.length <= i) {
  20738. code.push(q = {
  20739. children: [],
  20740. index: 0
  20741. });
  20742. p.children[p.index] = q.children;
  20743. p = q;
  20744. }
  20745. k++;
  20746. }
  20747. if (i + 1 < length) {
  20748. code.push(q = {
  20749. children: [],
  20750. index: 0
  20751. });
  20752. p.children[p.index] = q.children;
  20753. p = q;
  20754. }
  20755. }
  20756. return code[0].children;
  20757. }
  20758. function getBlockBufferOffset(component, row, col) {
  20759. return 64 * ((component.blocksPerLine + 1) * row + col);
  20760. }
  20761. function decodeScan(data, offset, frame, components, resetInterval, spectralStart, spectralEnd, successivePrev, successive) {
  20762. let parseDNLMarker = arguments.length > 9 && arguments[9] !== undefined ? arguments[9] : false;
  20763. const mcusPerLine = frame.mcusPerLine;
  20764. const progressive = frame.progressive;
  20765. const startOffset = offset;
  20766. let bitsData = 0,
  20767. bitsCount = 0;
  20768. function readBit() {
  20769. if (bitsCount > 0) {
  20770. bitsCount--;
  20771. return bitsData >> bitsCount & 1;
  20772. }
  20773. bitsData = data[offset++];
  20774. if (bitsData === 0xff) {
  20775. const nextByte = data[offset++];
  20776. if (nextByte) {
  20777. if (nextByte === 0xdc && parseDNLMarker) {
  20778. offset += 2;
  20779. const scanLines = (0, _core_utils.readUint16)(data, offset);
  20780. offset += 2;
  20781. if (scanLines > 0 && scanLines !== frame.scanLines) {
  20782. throw new DNLMarkerError("Found DNL marker (0xFFDC) while parsing scan data", scanLines);
  20783. }
  20784. } else if (nextByte === 0xd9) {
  20785. if (parseDNLMarker) {
  20786. const maybeScanLines = blockRow * (frame.precision === 8 ? 8 : 0);
  20787. if (maybeScanLines > 0 && Math.round(frame.scanLines / maybeScanLines) >= 5) {
  20788. throw new DNLMarkerError("Found EOI marker (0xFFD9) while parsing scan data, " + "possibly caused by incorrect `scanLines` parameter", maybeScanLines);
  20789. }
  20790. }
  20791. throw new EOIMarkerError("Found EOI marker (0xFFD9) while parsing scan data");
  20792. }
  20793. throw new JpegError(`unexpected marker ${(bitsData << 8 | nextByte).toString(16)}`);
  20794. }
  20795. }
  20796. bitsCount = 7;
  20797. return bitsData >>> 7;
  20798. }
  20799. function decodeHuffman(tree) {
  20800. let node = tree;
  20801. while (true) {
  20802. node = node[readBit()];
  20803. switch (typeof node) {
  20804. case "number":
  20805. return node;
  20806. case "object":
  20807. continue;
  20808. }
  20809. throw new JpegError("invalid huffman sequence");
  20810. }
  20811. }
  20812. function receive(length) {
  20813. let n = 0;
  20814. while (length > 0) {
  20815. n = n << 1 | readBit();
  20816. length--;
  20817. }
  20818. return n;
  20819. }
  20820. function receiveAndExtend(length) {
  20821. if (length === 1) {
  20822. return readBit() === 1 ? 1 : -1;
  20823. }
  20824. const n = receive(length);
  20825. if (n >= 1 << length - 1) {
  20826. return n;
  20827. }
  20828. return n + (-1 << length) + 1;
  20829. }
  20830. function decodeBaseline(component, blockOffset) {
  20831. const t = decodeHuffman(component.huffmanTableDC);
  20832. const diff = t === 0 ? 0 : receiveAndExtend(t);
  20833. component.blockData[blockOffset] = component.pred += diff;
  20834. let k = 1;
  20835. while (k < 64) {
  20836. const rs = decodeHuffman(component.huffmanTableAC);
  20837. const s = rs & 15,
  20838. r = rs >> 4;
  20839. if (s === 0) {
  20840. if (r < 15) {
  20841. break;
  20842. }
  20843. k += 16;
  20844. continue;
  20845. }
  20846. k += r;
  20847. const z = dctZigZag[k];
  20848. component.blockData[blockOffset + z] = receiveAndExtend(s);
  20849. k++;
  20850. }
  20851. }
  20852. function decodeDCFirst(component, blockOffset) {
  20853. const t = decodeHuffman(component.huffmanTableDC);
  20854. const diff = t === 0 ? 0 : receiveAndExtend(t) << successive;
  20855. component.blockData[blockOffset] = component.pred += diff;
  20856. }
  20857. function decodeDCSuccessive(component, blockOffset) {
  20858. component.blockData[blockOffset] |= readBit() << successive;
  20859. }
  20860. let eobrun = 0;
  20861. function decodeACFirst(component, blockOffset) {
  20862. if (eobrun > 0) {
  20863. eobrun--;
  20864. return;
  20865. }
  20866. let k = spectralStart;
  20867. const e = spectralEnd;
  20868. while (k <= e) {
  20869. const rs = decodeHuffman(component.huffmanTableAC);
  20870. const s = rs & 15,
  20871. r = rs >> 4;
  20872. if (s === 0) {
  20873. if (r < 15) {
  20874. eobrun = receive(r) + (1 << r) - 1;
  20875. break;
  20876. }
  20877. k += 16;
  20878. continue;
  20879. }
  20880. k += r;
  20881. const z = dctZigZag[k];
  20882. component.blockData[blockOffset + z] = receiveAndExtend(s) * (1 << successive);
  20883. k++;
  20884. }
  20885. }
  20886. let successiveACState = 0,
  20887. successiveACNextValue;
  20888. function decodeACSuccessive(component, blockOffset) {
  20889. let k = spectralStart;
  20890. const e = spectralEnd;
  20891. let r = 0;
  20892. let s;
  20893. let rs;
  20894. while (k <= e) {
  20895. const offsetZ = blockOffset + dctZigZag[k];
  20896. const sign = component.blockData[offsetZ] < 0 ? -1 : 1;
  20897. switch (successiveACState) {
  20898. case 0:
  20899. rs = decodeHuffman(component.huffmanTableAC);
  20900. s = rs & 15;
  20901. r = rs >> 4;
  20902. if (s === 0) {
  20903. if (r < 15) {
  20904. eobrun = receive(r) + (1 << r);
  20905. successiveACState = 4;
  20906. } else {
  20907. r = 16;
  20908. successiveACState = 1;
  20909. }
  20910. } else {
  20911. if (s !== 1) {
  20912. throw new JpegError("invalid ACn encoding");
  20913. }
  20914. successiveACNextValue = receiveAndExtend(s);
  20915. successiveACState = r ? 2 : 3;
  20916. }
  20917. continue;
  20918. case 1:
  20919. case 2:
  20920. if (component.blockData[offsetZ]) {
  20921. component.blockData[offsetZ] += sign * (readBit() << successive);
  20922. } else {
  20923. r--;
  20924. if (r === 0) {
  20925. successiveACState = successiveACState === 2 ? 3 : 0;
  20926. }
  20927. }
  20928. break;
  20929. case 3:
  20930. if (component.blockData[offsetZ]) {
  20931. component.blockData[offsetZ] += sign * (readBit() << successive);
  20932. } else {
  20933. component.blockData[offsetZ] = successiveACNextValue << successive;
  20934. successiveACState = 0;
  20935. }
  20936. break;
  20937. case 4:
  20938. if (component.blockData[offsetZ]) {
  20939. component.blockData[offsetZ] += sign * (readBit() << successive);
  20940. }
  20941. break;
  20942. }
  20943. k++;
  20944. }
  20945. if (successiveACState === 4) {
  20946. eobrun--;
  20947. if (eobrun === 0) {
  20948. successiveACState = 0;
  20949. }
  20950. }
  20951. }
  20952. let blockRow = 0;
  20953. function decodeMcu(component, decode, mcu, row, col) {
  20954. const mcuRow = mcu / mcusPerLine | 0;
  20955. const mcuCol = mcu % mcusPerLine;
  20956. blockRow = mcuRow * component.v + row;
  20957. const blockCol = mcuCol * component.h + col;
  20958. const blockOffset = getBlockBufferOffset(component, blockRow, blockCol);
  20959. decode(component, blockOffset);
  20960. }
  20961. function decodeBlock(component, decode, mcu) {
  20962. blockRow = mcu / component.blocksPerLine | 0;
  20963. const blockCol = mcu % component.blocksPerLine;
  20964. const blockOffset = getBlockBufferOffset(component, blockRow, blockCol);
  20965. decode(component, blockOffset);
  20966. }
  20967. const componentsLength = components.length;
  20968. let component, i, j, k, n;
  20969. let decodeFn;
  20970. if (progressive) {
  20971. if (spectralStart === 0) {
  20972. decodeFn = successivePrev === 0 ? decodeDCFirst : decodeDCSuccessive;
  20973. } else {
  20974. decodeFn = successivePrev === 0 ? decodeACFirst : decodeACSuccessive;
  20975. }
  20976. } else {
  20977. decodeFn = decodeBaseline;
  20978. }
  20979. let mcu = 0,
  20980. fileMarker;
  20981. const mcuExpected = componentsLength === 1 ? components[0].blocksPerLine * components[0].blocksPerColumn : mcusPerLine * frame.mcusPerColumn;
  20982. let h, v;
  20983. while (mcu <= mcuExpected) {
  20984. const mcuToRead = resetInterval ? Math.min(mcuExpected - mcu, resetInterval) : mcuExpected;
  20985. if (mcuToRead > 0) {
  20986. for (i = 0; i < componentsLength; i++) {
  20987. components[i].pred = 0;
  20988. }
  20989. eobrun = 0;
  20990. if (componentsLength === 1) {
  20991. component = components[0];
  20992. for (n = 0; n < mcuToRead; n++) {
  20993. decodeBlock(component, decodeFn, mcu);
  20994. mcu++;
  20995. }
  20996. } else {
  20997. for (n = 0; n < mcuToRead; n++) {
  20998. for (i = 0; i < componentsLength; i++) {
  20999. component = components[i];
  21000. h = component.h;
  21001. v = component.v;
  21002. for (j = 0; j < v; j++) {
  21003. for (k = 0; k < h; k++) {
  21004. decodeMcu(component, decodeFn, mcu, j, k);
  21005. }
  21006. }
  21007. }
  21008. mcu++;
  21009. }
  21010. }
  21011. }
  21012. bitsCount = 0;
  21013. fileMarker = findNextFileMarker(data, offset);
  21014. if (!fileMarker) {
  21015. break;
  21016. }
  21017. if (fileMarker.invalid) {
  21018. const partialMsg = mcuToRead > 0 ? "unexpected" : "excessive";
  21019. (0, _util.warn)(`decodeScan - ${partialMsg} MCU data, current marker is: ${fileMarker.invalid}`);
  21020. offset = fileMarker.offset;
  21021. }
  21022. if (fileMarker.marker >= 0xffd0 && fileMarker.marker <= 0xffd7) {
  21023. offset += 2;
  21024. } else {
  21025. break;
  21026. }
  21027. }
  21028. return offset - startOffset;
  21029. }
  21030. function quantizeAndInverse(component, blockBufferOffset, p) {
  21031. const qt = component.quantizationTable,
  21032. blockData = component.blockData;
  21033. let v0, v1, v2, v3, v4, v5, v6, v7;
  21034. let p0, p1, p2, p3, p4, p5, p6, p7;
  21035. let t;
  21036. if (!qt) {
  21037. throw new JpegError("missing required Quantization Table.");
  21038. }
  21039. for (let row = 0; row < 64; row += 8) {
  21040. p0 = blockData[blockBufferOffset + row];
  21041. p1 = blockData[blockBufferOffset + row + 1];
  21042. p2 = blockData[blockBufferOffset + row + 2];
  21043. p3 = blockData[blockBufferOffset + row + 3];
  21044. p4 = blockData[blockBufferOffset + row + 4];
  21045. p5 = blockData[blockBufferOffset + row + 5];
  21046. p6 = blockData[blockBufferOffset + row + 6];
  21047. p7 = blockData[blockBufferOffset + row + 7];
  21048. p0 *= qt[row];
  21049. if ((p1 | p2 | p3 | p4 | p5 | p6 | p7) === 0) {
  21050. t = dctSqrt2 * p0 + 512 >> 10;
  21051. p[row] = t;
  21052. p[row + 1] = t;
  21053. p[row + 2] = t;
  21054. p[row + 3] = t;
  21055. p[row + 4] = t;
  21056. p[row + 5] = t;
  21057. p[row + 6] = t;
  21058. p[row + 7] = t;
  21059. continue;
  21060. }
  21061. p1 *= qt[row + 1];
  21062. p2 *= qt[row + 2];
  21063. p3 *= qt[row + 3];
  21064. p4 *= qt[row + 4];
  21065. p5 *= qt[row + 5];
  21066. p6 *= qt[row + 6];
  21067. p7 *= qt[row + 7];
  21068. v0 = dctSqrt2 * p0 + 128 >> 8;
  21069. v1 = dctSqrt2 * p4 + 128 >> 8;
  21070. v2 = p2;
  21071. v3 = p6;
  21072. v4 = dctSqrt1d2 * (p1 - p7) + 128 >> 8;
  21073. v7 = dctSqrt1d2 * (p1 + p7) + 128 >> 8;
  21074. v5 = p3 << 4;
  21075. v6 = p5 << 4;
  21076. v0 = v0 + v1 + 1 >> 1;
  21077. v1 = v0 - v1;
  21078. t = v2 * dctSin6 + v3 * dctCos6 + 128 >> 8;
  21079. v2 = v2 * dctCos6 - v3 * dctSin6 + 128 >> 8;
  21080. v3 = t;
  21081. v4 = v4 + v6 + 1 >> 1;
  21082. v6 = v4 - v6;
  21083. v7 = v7 + v5 + 1 >> 1;
  21084. v5 = v7 - v5;
  21085. v0 = v0 + v3 + 1 >> 1;
  21086. v3 = v0 - v3;
  21087. v1 = v1 + v2 + 1 >> 1;
  21088. v2 = v1 - v2;
  21089. t = v4 * dctSin3 + v7 * dctCos3 + 2048 >> 12;
  21090. v4 = v4 * dctCos3 - v7 * dctSin3 + 2048 >> 12;
  21091. v7 = t;
  21092. t = v5 * dctSin1 + v6 * dctCos1 + 2048 >> 12;
  21093. v5 = v5 * dctCos1 - v6 * dctSin1 + 2048 >> 12;
  21094. v6 = t;
  21095. p[row] = v0 + v7;
  21096. p[row + 7] = v0 - v7;
  21097. p[row + 1] = v1 + v6;
  21098. p[row + 6] = v1 - v6;
  21099. p[row + 2] = v2 + v5;
  21100. p[row + 5] = v2 - v5;
  21101. p[row + 3] = v3 + v4;
  21102. p[row + 4] = v3 - v4;
  21103. }
  21104. for (let col = 0; col < 8; ++col) {
  21105. p0 = p[col];
  21106. p1 = p[col + 8];
  21107. p2 = p[col + 16];
  21108. p3 = p[col + 24];
  21109. p4 = p[col + 32];
  21110. p5 = p[col + 40];
  21111. p6 = p[col + 48];
  21112. p7 = p[col + 56];
  21113. if ((p1 | p2 | p3 | p4 | p5 | p6 | p7) === 0) {
  21114. t = dctSqrt2 * p0 + 8192 >> 14;
  21115. if (t < -2040) {
  21116. t = 0;
  21117. } else if (t >= 2024) {
  21118. t = 255;
  21119. } else {
  21120. t = t + 2056 >> 4;
  21121. }
  21122. blockData[blockBufferOffset + col] = t;
  21123. blockData[blockBufferOffset + col + 8] = t;
  21124. blockData[blockBufferOffset + col + 16] = t;
  21125. blockData[blockBufferOffset + col + 24] = t;
  21126. blockData[blockBufferOffset + col + 32] = t;
  21127. blockData[blockBufferOffset + col + 40] = t;
  21128. blockData[blockBufferOffset + col + 48] = t;
  21129. blockData[blockBufferOffset + col + 56] = t;
  21130. continue;
  21131. }
  21132. v0 = dctSqrt2 * p0 + 2048 >> 12;
  21133. v1 = dctSqrt2 * p4 + 2048 >> 12;
  21134. v2 = p2;
  21135. v3 = p6;
  21136. v4 = dctSqrt1d2 * (p1 - p7) + 2048 >> 12;
  21137. v7 = dctSqrt1d2 * (p1 + p7) + 2048 >> 12;
  21138. v5 = p3;
  21139. v6 = p5;
  21140. v0 = (v0 + v1 + 1 >> 1) + 4112;
  21141. v1 = v0 - v1;
  21142. t = v2 * dctSin6 + v3 * dctCos6 + 2048 >> 12;
  21143. v2 = v2 * dctCos6 - v3 * dctSin6 + 2048 >> 12;
  21144. v3 = t;
  21145. v4 = v4 + v6 + 1 >> 1;
  21146. v6 = v4 - v6;
  21147. v7 = v7 + v5 + 1 >> 1;
  21148. v5 = v7 - v5;
  21149. v0 = v0 + v3 + 1 >> 1;
  21150. v3 = v0 - v3;
  21151. v1 = v1 + v2 + 1 >> 1;
  21152. v2 = v1 - v2;
  21153. t = v4 * dctSin3 + v7 * dctCos3 + 2048 >> 12;
  21154. v4 = v4 * dctCos3 - v7 * dctSin3 + 2048 >> 12;
  21155. v7 = t;
  21156. t = v5 * dctSin1 + v6 * dctCos1 + 2048 >> 12;
  21157. v5 = v5 * dctCos1 - v6 * dctSin1 + 2048 >> 12;
  21158. v6 = t;
  21159. p0 = v0 + v7;
  21160. p7 = v0 - v7;
  21161. p1 = v1 + v6;
  21162. p6 = v1 - v6;
  21163. p2 = v2 + v5;
  21164. p5 = v2 - v5;
  21165. p3 = v3 + v4;
  21166. p4 = v3 - v4;
  21167. if (p0 < 16) {
  21168. p0 = 0;
  21169. } else if (p0 >= 4080) {
  21170. p0 = 255;
  21171. } else {
  21172. p0 >>= 4;
  21173. }
  21174. if (p1 < 16) {
  21175. p1 = 0;
  21176. } else if (p1 >= 4080) {
  21177. p1 = 255;
  21178. } else {
  21179. p1 >>= 4;
  21180. }
  21181. if (p2 < 16) {
  21182. p2 = 0;
  21183. } else if (p2 >= 4080) {
  21184. p2 = 255;
  21185. } else {
  21186. p2 >>= 4;
  21187. }
  21188. if (p3 < 16) {
  21189. p3 = 0;
  21190. } else if (p3 >= 4080) {
  21191. p3 = 255;
  21192. } else {
  21193. p3 >>= 4;
  21194. }
  21195. if (p4 < 16) {
  21196. p4 = 0;
  21197. } else if (p4 >= 4080) {
  21198. p4 = 255;
  21199. } else {
  21200. p4 >>= 4;
  21201. }
  21202. if (p5 < 16) {
  21203. p5 = 0;
  21204. } else if (p5 >= 4080) {
  21205. p5 = 255;
  21206. } else {
  21207. p5 >>= 4;
  21208. }
  21209. if (p6 < 16) {
  21210. p6 = 0;
  21211. } else if (p6 >= 4080) {
  21212. p6 = 255;
  21213. } else {
  21214. p6 >>= 4;
  21215. }
  21216. if (p7 < 16) {
  21217. p7 = 0;
  21218. } else if (p7 >= 4080) {
  21219. p7 = 255;
  21220. } else {
  21221. p7 >>= 4;
  21222. }
  21223. blockData[blockBufferOffset + col] = p0;
  21224. blockData[blockBufferOffset + col + 8] = p1;
  21225. blockData[blockBufferOffset + col + 16] = p2;
  21226. blockData[blockBufferOffset + col + 24] = p3;
  21227. blockData[blockBufferOffset + col + 32] = p4;
  21228. blockData[blockBufferOffset + col + 40] = p5;
  21229. blockData[blockBufferOffset + col + 48] = p6;
  21230. blockData[blockBufferOffset + col + 56] = p7;
  21231. }
  21232. }
  21233. function buildComponentData(frame, component) {
  21234. const blocksPerLine = component.blocksPerLine;
  21235. const blocksPerColumn = component.blocksPerColumn;
  21236. const computationBuffer = new Int16Array(64);
  21237. for (let blockRow = 0; blockRow < blocksPerColumn; blockRow++) {
  21238. for (let blockCol = 0; blockCol < blocksPerLine; blockCol++) {
  21239. const offset = getBlockBufferOffset(component, blockRow, blockCol);
  21240. quantizeAndInverse(component, offset, computationBuffer);
  21241. }
  21242. }
  21243. return component.blockData;
  21244. }
  21245. function findNextFileMarker(data, currentPos) {
  21246. let startPos = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : currentPos;
  21247. const maxPos = data.length - 1;
  21248. let newPos = startPos < currentPos ? startPos : currentPos;
  21249. if (currentPos >= maxPos) {
  21250. return null;
  21251. }
  21252. const currentMarker = (0, _core_utils.readUint16)(data, currentPos);
  21253. if (currentMarker >= 0xffc0 && currentMarker <= 0xfffe) {
  21254. return {
  21255. invalid: null,
  21256. marker: currentMarker,
  21257. offset: currentPos
  21258. };
  21259. }
  21260. let newMarker = (0, _core_utils.readUint16)(data, newPos);
  21261. while (!(newMarker >= 0xffc0 && newMarker <= 0xfffe)) {
  21262. if (++newPos >= maxPos) {
  21263. return null;
  21264. }
  21265. newMarker = (0, _core_utils.readUint16)(data, newPos);
  21266. }
  21267. return {
  21268. invalid: currentMarker.toString(16),
  21269. marker: newMarker,
  21270. offset: newPos
  21271. };
  21272. }
  21273. class JpegImage {
  21274. constructor() {
  21275. let {
  21276. decodeTransform = null,
  21277. colorTransform = -1
  21278. } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  21279. this._decodeTransform = decodeTransform;
  21280. this._colorTransform = colorTransform;
  21281. }
  21282. parse(data) {
  21283. let {
  21284. dnlScanLines = null
  21285. } = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  21286. function readDataBlock() {
  21287. const length = (0, _core_utils.readUint16)(data, offset);
  21288. offset += 2;
  21289. let endOffset = offset + length - 2;
  21290. const fileMarker = findNextFileMarker(data, endOffset, offset);
  21291. if (fileMarker?.invalid) {
  21292. (0, _util.warn)("readDataBlock - incorrect length, current marker is: " + fileMarker.invalid);
  21293. endOffset = fileMarker.offset;
  21294. }
  21295. const array = data.subarray(offset, endOffset);
  21296. offset += array.length;
  21297. return array;
  21298. }
  21299. function prepareComponents(frame) {
  21300. const mcusPerLine = Math.ceil(frame.samplesPerLine / 8 / frame.maxH);
  21301. const mcusPerColumn = Math.ceil(frame.scanLines / 8 / frame.maxV);
  21302. for (const component of frame.components) {
  21303. const blocksPerLine = Math.ceil(Math.ceil(frame.samplesPerLine / 8) * component.h / frame.maxH);
  21304. const blocksPerColumn = Math.ceil(Math.ceil(frame.scanLines / 8) * component.v / frame.maxV);
  21305. const blocksPerLineForMcu = mcusPerLine * component.h;
  21306. const blocksPerColumnForMcu = mcusPerColumn * component.v;
  21307. const blocksBufferSize = 64 * blocksPerColumnForMcu * (blocksPerLineForMcu + 1);
  21308. component.blockData = new Int16Array(blocksBufferSize);
  21309. component.blocksPerLine = blocksPerLine;
  21310. component.blocksPerColumn = blocksPerColumn;
  21311. }
  21312. frame.mcusPerLine = mcusPerLine;
  21313. frame.mcusPerColumn = mcusPerColumn;
  21314. }
  21315. let offset = 0;
  21316. let jfif = null;
  21317. let adobe = null;
  21318. let frame, resetInterval;
  21319. let numSOSMarkers = 0;
  21320. const quantizationTables = [];
  21321. const huffmanTablesAC = [],
  21322. huffmanTablesDC = [];
  21323. let fileMarker = (0, _core_utils.readUint16)(data, offset);
  21324. offset += 2;
  21325. if (fileMarker !== 0xffd8) {
  21326. throw new JpegError("SOI not found");
  21327. }
  21328. fileMarker = (0, _core_utils.readUint16)(data, offset);
  21329. offset += 2;
  21330. markerLoop: while (fileMarker !== 0xffd9) {
  21331. let i, j, l;
  21332. switch (fileMarker) {
  21333. case 0xffe0:
  21334. case 0xffe1:
  21335. case 0xffe2:
  21336. case 0xffe3:
  21337. case 0xffe4:
  21338. case 0xffe5:
  21339. case 0xffe6:
  21340. case 0xffe7:
  21341. case 0xffe8:
  21342. case 0xffe9:
  21343. case 0xffea:
  21344. case 0xffeb:
  21345. case 0xffec:
  21346. case 0xffed:
  21347. case 0xffee:
  21348. case 0xffef:
  21349. case 0xfffe:
  21350. const appData = readDataBlock();
  21351. if (fileMarker === 0xffe0) {
  21352. if (appData[0] === 0x4a && appData[1] === 0x46 && appData[2] === 0x49 && appData[3] === 0x46 && appData[4] === 0) {
  21353. jfif = {
  21354. version: {
  21355. major: appData[5],
  21356. minor: appData[6]
  21357. },
  21358. densityUnits: appData[7],
  21359. xDensity: appData[8] << 8 | appData[9],
  21360. yDensity: appData[10] << 8 | appData[11],
  21361. thumbWidth: appData[12],
  21362. thumbHeight: appData[13],
  21363. thumbData: appData.subarray(14, 14 + 3 * appData[12] * appData[13])
  21364. };
  21365. }
  21366. }
  21367. if (fileMarker === 0xffee) {
  21368. if (appData[0] === 0x41 && appData[1] === 0x64 && appData[2] === 0x6f && appData[3] === 0x62 && appData[4] === 0x65) {
  21369. adobe = {
  21370. version: appData[5] << 8 | appData[6],
  21371. flags0: appData[7] << 8 | appData[8],
  21372. flags1: appData[9] << 8 | appData[10],
  21373. transformCode: appData[11]
  21374. };
  21375. }
  21376. }
  21377. break;
  21378. case 0xffdb:
  21379. const quantizationTablesLength = (0, _core_utils.readUint16)(data, offset);
  21380. offset += 2;
  21381. const quantizationTablesEnd = quantizationTablesLength + offset - 2;
  21382. let z;
  21383. while (offset < quantizationTablesEnd) {
  21384. const quantizationTableSpec = data[offset++];
  21385. const tableData = new Uint16Array(64);
  21386. if (quantizationTableSpec >> 4 === 0) {
  21387. for (j = 0; j < 64; j++) {
  21388. z = dctZigZag[j];
  21389. tableData[z] = data[offset++];
  21390. }
  21391. } else if (quantizationTableSpec >> 4 === 1) {
  21392. for (j = 0; j < 64; j++) {
  21393. z = dctZigZag[j];
  21394. tableData[z] = (0, _core_utils.readUint16)(data, offset);
  21395. offset += 2;
  21396. }
  21397. } else {
  21398. throw new JpegError("DQT - invalid table spec");
  21399. }
  21400. quantizationTables[quantizationTableSpec & 15] = tableData;
  21401. }
  21402. break;
  21403. case 0xffc0:
  21404. case 0xffc1:
  21405. case 0xffc2:
  21406. if (frame) {
  21407. throw new JpegError("Only single frame JPEGs supported");
  21408. }
  21409. offset += 2;
  21410. frame = {};
  21411. frame.extended = fileMarker === 0xffc1;
  21412. frame.progressive = fileMarker === 0xffc2;
  21413. frame.precision = data[offset++];
  21414. const sofScanLines = (0, _core_utils.readUint16)(data, offset);
  21415. offset += 2;
  21416. frame.scanLines = dnlScanLines || sofScanLines;
  21417. frame.samplesPerLine = (0, _core_utils.readUint16)(data, offset);
  21418. offset += 2;
  21419. frame.components = [];
  21420. frame.componentIds = {};
  21421. const componentsCount = data[offset++];
  21422. let maxH = 0,
  21423. maxV = 0;
  21424. for (i = 0; i < componentsCount; i++) {
  21425. const componentId = data[offset];
  21426. const h = data[offset + 1] >> 4;
  21427. const v = data[offset + 1] & 15;
  21428. if (maxH < h) {
  21429. maxH = h;
  21430. }
  21431. if (maxV < v) {
  21432. maxV = v;
  21433. }
  21434. const qId = data[offset + 2];
  21435. l = frame.components.push({
  21436. h,
  21437. v,
  21438. quantizationId: qId,
  21439. quantizationTable: null
  21440. });
  21441. frame.componentIds[componentId] = l - 1;
  21442. offset += 3;
  21443. }
  21444. frame.maxH = maxH;
  21445. frame.maxV = maxV;
  21446. prepareComponents(frame);
  21447. break;
  21448. case 0xffc4:
  21449. const huffmanLength = (0, _core_utils.readUint16)(data, offset);
  21450. offset += 2;
  21451. for (i = 2; i < huffmanLength;) {
  21452. const huffmanTableSpec = data[offset++];
  21453. const codeLengths = new Uint8Array(16);
  21454. let codeLengthSum = 0;
  21455. for (j = 0; j < 16; j++, offset++) {
  21456. codeLengthSum += codeLengths[j] = data[offset];
  21457. }
  21458. const huffmanValues = new Uint8Array(codeLengthSum);
  21459. for (j = 0; j < codeLengthSum; j++, offset++) {
  21460. huffmanValues[j] = data[offset];
  21461. }
  21462. i += 17 + codeLengthSum;
  21463. (huffmanTableSpec >> 4 === 0 ? huffmanTablesDC : huffmanTablesAC)[huffmanTableSpec & 15] = buildHuffmanTable(codeLengths, huffmanValues);
  21464. }
  21465. break;
  21466. case 0xffdd:
  21467. offset += 2;
  21468. resetInterval = (0, _core_utils.readUint16)(data, offset);
  21469. offset += 2;
  21470. break;
  21471. case 0xffda:
  21472. const parseDNLMarker = ++numSOSMarkers === 1 && !dnlScanLines;
  21473. offset += 2;
  21474. const selectorsCount = data[offset++],
  21475. components = [];
  21476. for (i = 0; i < selectorsCount; i++) {
  21477. const index = data[offset++];
  21478. const componentIndex = frame.componentIds[index];
  21479. const component = frame.components[componentIndex];
  21480. component.index = index;
  21481. const tableSpec = data[offset++];
  21482. component.huffmanTableDC = huffmanTablesDC[tableSpec >> 4];
  21483. component.huffmanTableAC = huffmanTablesAC[tableSpec & 15];
  21484. components.push(component);
  21485. }
  21486. const spectralStart = data[offset++],
  21487. spectralEnd = data[offset++],
  21488. successiveApproximation = data[offset++];
  21489. try {
  21490. const processed = decodeScan(data, offset, frame, components, resetInterval, spectralStart, spectralEnd, successiveApproximation >> 4, successiveApproximation & 15, parseDNLMarker);
  21491. offset += processed;
  21492. } catch (ex) {
  21493. if (ex instanceof DNLMarkerError) {
  21494. (0, _util.warn)(`${ex.message} -- attempting to re-parse the JPEG image.`);
  21495. return this.parse(data, {
  21496. dnlScanLines: ex.scanLines
  21497. });
  21498. } else if (ex instanceof EOIMarkerError) {
  21499. (0, _util.warn)(`${ex.message} -- ignoring the rest of the image data.`);
  21500. break markerLoop;
  21501. }
  21502. throw ex;
  21503. }
  21504. break;
  21505. case 0xffdc:
  21506. offset += 4;
  21507. break;
  21508. case 0xffff:
  21509. if (data[offset] !== 0xff) {
  21510. offset--;
  21511. }
  21512. break;
  21513. default:
  21514. const nextFileMarker = findNextFileMarker(data, offset - 2, offset - 3);
  21515. if (nextFileMarker?.invalid) {
  21516. (0, _util.warn)("JpegImage.parse - unexpected data, current marker is: " + nextFileMarker.invalid);
  21517. offset = nextFileMarker.offset;
  21518. break;
  21519. }
  21520. if (!nextFileMarker || offset >= data.length - 1) {
  21521. (0, _util.warn)("JpegImage.parse - reached the end of the image data " + "without finding an EOI marker (0xFFD9).");
  21522. break markerLoop;
  21523. }
  21524. throw new JpegError("JpegImage.parse - unknown marker: " + fileMarker.toString(16));
  21525. }
  21526. fileMarker = (0, _core_utils.readUint16)(data, offset);
  21527. offset += 2;
  21528. }
  21529. this.width = frame.samplesPerLine;
  21530. this.height = frame.scanLines;
  21531. this.jfif = jfif;
  21532. this.adobe = adobe;
  21533. this.components = [];
  21534. for (const component of frame.components) {
  21535. const quantizationTable = quantizationTables[component.quantizationId];
  21536. if (quantizationTable) {
  21537. component.quantizationTable = quantizationTable;
  21538. }
  21539. this.components.push({
  21540. index: component.index,
  21541. output: buildComponentData(frame, component),
  21542. scaleX: component.h / frame.maxH,
  21543. scaleY: component.v / frame.maxV,
  21544. blocksPerLine: component.blocksPerLine,
  21545. blocksPerColumn: component.blocksPerColumn
  21546. });
  21547. }
  21548. this.numComponents = this.components.length;
  21549. return undefined;
  21550. }
  21551. _getLinearizedBlockData(width, height) {
  21552. let isSourcePDF = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  21553. const scaleX = this.width / width,
  21554. scaleY = this.height / height;
  21555. let component, componentScaleX, componentScaleY, blocksPerScanline;
  21556. let x, y, i, j, k;
  21557. let index;
  21558. let offset = 0;
  21559. let output;
  21560. const numComponents = this.components.length;
  21561. const dataLength = width * height * numComponents;
  21562. const data = new Uint8ClampedArray(dataLength);
  21563. const xScaleBlockOffset = new Uint32Array(width);
  21564. const mask3LSB = 0xfffffff8;
  21565. let lastComponentScaleX;
  21566. for (i = 0; i < numComponents; i++) {
  21567. component = this.components[i];
  21568. componentScaleX = component.scaleX * scaleX;
  21569. componentScaleY = component.scaleY * scaleY;
  21570. offset = i;
  21571. output = component.output;
  21572. blocksPerScanline = component.blocksPerLine + 1 << 3;
  21573. if (componentScaleX !== lastComponentScaleX) {
  21574. for (x = 0; x < width; x++) {
  21575. j = 0 | x * componentScaleX;
  21576. xScaleBlockOffset[x] = (j & mask3LSB) << 3 | j & 7;
  21577. }
  21578. lastComponentScaleX = componentScaleX;
  21579. }
  21580. for (y = 0; y < height; y++) {
  21581. j = 0 | y * componentScaleY;
  21582. index = blocksPerScanline * (j & mask3LSB) | (j & 7) << 3;
  21583. for (x = 0; x < width; x++) {
  21584. data[offset] = output[index + xScaleBlockOffset[x]];
  21585. offset += numComponents;
  21586. }
  21587. }
  21588. }
  21589. let transform = this._decodeTransform;
  21590. if (!isSourcePDF && numComponents === 4 && !transform) {
  21591. transform = new Int32Array([-256, 255, -256, 255, -256, 255, -256, 255]);
  21592. }
  21593. if (transform) {
  21594. for (i = 0; i < dataLength;) {
  21595. for (j = 0, k = 0; j < numComponents; j++, i++, k += 2) {
  21596. data[i] = (data[i] * transform[k] >> 8) + transform[k + 1];
  21597. }
  21598. }
  21599. }
  21600. return data;
  21601. }
  21602. get _isColorConversionNeeded() {
  21603. if (this.adobe) {
  21604. return !!this.adobe.transformCode;
  21605. }
  21606. if (this.numComponents === 3) {
  21607. if (this._colorTransform === 0) {
  21608. return false;
  21609. } else if (this.components[0].index === 0x52 && this.components[1].index === 0x47 && this.components[2].index === 0x42) {
  21610. return false;
  21611. }
  21612. return true;
  21613. }
  21614. if (this._colorTransform === 1) {
  21615. return true;
  21616. }
  21617. return false;
  21618. }
  21619. _convertYccToRgb(data) {
  21620. let Y, Cb, Cr;
  21621. for (let i = 0, length = data.length; i < length; i += 3) {
  21622. Y = data[i];
  21623. Cb = data[i + 1];
  21624. Cr = data[i + 2];
  21625. data[i] = Y - 179.456 + 1.402 * Cr;
  21626. data[i + 1] = Y + 135.459 - 0.344 * Cb - 0.714 * Cr;
  21627. data[i + 2] = Y - 226.816 + 1.772 * Cb;
  21628. }
  21629. return data;
  21630. }
  21631. _convertYccToRgba(data, out) {
  21632. for (let i = 0, j = 0, length = data.length; i < length; i += 3, j += 4) {
  21633. const Y = data[i];
  21634. const Cb = data[i + 1];
  21635. const Cr = data[i + 2];
  21636. out[j] = Y - 179.456 + 1.402 * Cr;
  21637. out[j + 1] = Y + 135.459 - 0.344 * Cb - 0.714 * Cr;
  21638. out[j + 2] = Y - 226.816 + 1.772 * Cb;
  21639. out[j + 3] = 255;
  21640. }
  21641. return out;
  21642. }
  21643. _convertYcckToRgb(data) {
  21644. let Y, Cb, Cr, k;
  21645. let offset = 0;
  21646. for (let i = 0, length = data.length; i < length; i += 4) {
  21647. Y = data[i];
  21648. Cb = data[i + 1];
  21649. Cr = data[i + 2];
  21650. k = data[i + 3];
  21651. 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);
  21652. 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);
  21653. 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);
  21654. }
  21655. return data.subarray(0, offset);
  21656. }
  21657. _convertYcckToRgba(data) {
  21658. for (let i = 0, length = data.length; i < length; i += 4) {
  21659. const Y = data[i];
  21660. const Cb = data[i + 1];
  21661. const Cr = data[i + 2];
  21662. const k = data[i + 3];
  21663. 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);
  21664. 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);
  21665. 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);
  21666. data[i + 3] = 255;
  21667. }
  21668. return data;
  21669. }
  21670. _convertYcckToCmyk(data) {
  21671. let Y, Cb, Cr;
  21672. for (let i = 0, length = data.length; i < length; i += 4) {
  21673. Y = data[i];
  21674. Cb = data[i + 1];
  21675. Cr = data[i + 2];
  21676. data[i] = 434.456 - Y - 1.402 * Cr;
  21677. data[i + 1] = 119.541 - Y + 0.344 * Cb + 0.714 * Cr;
  21678. data[i + 2] = 481.816 - Y - 1.772 * Cb;
  21679. }
  21680. return data;
  21681. }
  21682. _convertCmykToRgb(data) {
  21683. let c, m, y, k;
  21684. let offset = 0;
  21685. for (let i = 0, length = data.length; i < length; i += 4) {
  21686. c = data[i];
  21687. m = data[i + 1];
  21688. y = data[i + 2];
  21689. k = data[i + 3];
  21690. 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);
  21691. 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);
  21692. 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);
  21693. }
  21694. return data.subarray(0, offset);
  21695. }
  21696. _convertCmykToRgba(data) {
  21697. for (let i = 0, length = data.length; i < length; i += 4) {
  21698. const c = data[i];
  21699. const m = data[i + 1];
  21700. const y = data[i + 2];
  21701. const k = data[i + 3];
  21702. 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);
  21703. 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);
  21704. 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);
  21705. data[i + 3] = 255;
  21706. }
  21707. return data;
  21708. }
  21709. getData(_ref) {
  21710. let {
  21711. width,
  21712. height,
  21713. forceRGBA = false,
  21714. forceRGB = false,
  21715. isSourcePDF = false
  21716. } = _ref;
  21717. if (this.numComponents > 4) {
  21718. throw new JpegError("Unsupported color mode");
  21719. }
  21720. const data = this._getLinearizedBlockData(width, height, isSourcePDF);
  21721. if (this.numComponents === 1 && (forceRGBA || forceRGB)) {
  21722. const len = data.length * (forceRGBA ? 4 : 3);
  21723. const rgbaData = new Uint8ClampedArray(len);
  21724. let offset = 0;
  21725. if (forceRGBA) {
  21726. (0, _image_utils.grayToRGBA)(data, new Uint32Array(rgbaData.buffer));
  21727. } else {
  21728. for (const grayColor of data) {
  21729. rgbaData[offset++] = grayColor;
  21730. rgbaData[offset++] = grayColor;
  21731. rgbaData[offset++] = grayColor;
  21732. }
  21733. }
  21734. return rgbaData;
  21735. } else if (this.numComponents === 3 && this._isColorConversionNeeded) {
  21736. if (forceRGBA) {
  21737. const rgbaData = new Uint8ClampedArray(data.length / 3 * 4);
  21738. return this._convertYccToRgba(data, rgbaData);
  21739. }
  21740. return this._convertYccToRgb(data);
  21741. } else if (this.numComponents === 4) {
  21742. if (this._isColorConversionNeeded) {
  21743. if (forceRGBA) {
  21744. return this._convertYcckToRgba(data);
  21745. }
  21746. if (forceRGB) {
  21747. return this._convertYcckToRgb(data);
  21748. }
  21749. return this._convertYcckToCmyk(data);
  21750. } else if (forceRGBA) {
  21751. return this._convertCmykToRgba(data);
  21752. } else if (forceRGB) {
  21753. return this._convertCmykToRgb(data);
  21754. }
  21755. }
  21756. return data;
  21757. }
  21758. }
  21759. exports.JpegImage = JpegImage;
  21760. /***/ }),
  21761. /* 179 */
  21762. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  21763. Object.defineProperty(exports, "__esModule", ({
  21764. value: true
  21765. }));
  21766. exports.convertBlackAndWhiteToRGBA = convertBlackAndWhiteToRGBA;
  21767. exports.convertToRGBA = convertToRGBA;
  21768. exports.grayToRGBA = grayToRGBA;
  21769. __w_pdfjs_require__(84);
  21770. __w_pdfjs_require__(93);
  21771. __w_pdfjs_require__(94);
  21772. __w_pdfjs_require__(97);
  21773. __w_pdfjs_require__(99);
  21774. __w_pdfjs_require__(101);
  21775. __w_pdfjs_require__(105);
  21776. __w_pdfjs_require__(108);
  21777. __w_pdfjs_require__(115);
  21778. var _util = __w_pdfjs_require__(145);
  21779. function convertToRGBA(params) {
  21780. switch (params.kind) {
  21781. case _util.ImageKind.GRAYSCALE_1BPP:
  21782. return convertBlackAndWhiteToRGBA(params);
  21783. case _util.ImageKind.RGB_24BPP:
  21784. return convertRGBToRGBA(params);
  21785. }
  21786. return null;
  21787. }
  21788. function convertBlackAndWhiteToRGBA(_ref) {
  21789. let {
  21790. src,
  21791. srcPos = 0,
  21792. dest,
  21793. width,
  21794. height,
  21795. nonBlackColor = 0xffffffff,
  21796. inverseDecode = false
  21797. } = _ref;
  21798. const black = _util.FeatureTest.isLittleEndian ? 0xff000000 : 0x000000ff;
  21799. const [zeroMapping, oneMapping] = inverseDecode ? [nonBlackColor, black] : [black, nonBlackColor];
  21800. const widthInSource = width >> 3;
  21801. const widthRemainder = width & 7;
  21802. const srcLength = src.length;
  21803. dest = new Uint32Array(dest.buffer);
  21804. let destPos = 0;
  21805. for (let i = 0; i < height; i++) {
  21806. for (const max = srcPos + widthInSource; srcPos < max; srcPos++) {
  21807. const elem = srcPos < srcLength ? src[srcPos] : 255;
  21808. dest[destPos++] = elem & 0b10000000 ? oneMapping : zeroMapping;
  21809. dest[destPos++] = elem & 0b1000000 ? oneMapping : zeroMapping;
  21810. dest[destPos++] = elem & 0b100000 ? oneMapping : zeroMapping;
  21811. dest[destPos++] = elem & 0b10000 ? oneMapping : zeroMapping;
  21812. dest[destPos++] = elem & 0b1000 ? oneMapping : zeroMapping;
  21813. dest[destPos++] = elem & 0b100 ? oneMapping : zeroMapping;
  21814. dest[destPos++] = elem & 0b10 ? oneMapping : zeroMapping;
  21815. dest[destPos++] = elem & 0b1 ? oneMapping : zeroMapping;
  21816. }
  21817. if (widthRemainder === 0) {
  21818. continue;
  21819. }
  21820. const elem = srcPos < srcLength ? src[srcPos++] : 255;
  21821. for (let j = 0; j < widthRemainder; j++) {
  21822. dest[destPos++] = elem & 1 << 7 - j ? oneMapping : zeroMapping;
  21823. }
  21824. }
  21825. return {
  21826. srcPos,
  21827. destPos
  21828. };
  21829. }
  21830. function convertRGBToRGBA(_ref2) {
  21831. let {
  21832. src,
  21833. srcPos = 0,
  21834. dest,
  21835. destPos = 0,
  21836. width,
  21837. height
  21838. } = _ref2;
  21839. let i = 0;
  21840. const len32 = src.length >> 2;
  21841. const src32 = new Uint32Array(src.buffer, srcPos, len32);
  21842. if (_util.FeatureTest.isLittleEndian) {
  21843. for (; i < len32 - 2; i += 3, destPos += 4) {
  21844. const s1 = src32[i];
  21845. const s2 = src32[i + 1];
  21846. const s3 = src32[i + 2];
  21847. dest[destPos] = s1 | 0xff000000;
  21848. dest[destPos + 1] = s1 >>> 24 | s2 << 8 | 0xff000000;
  21849. dest[destPos + 2] = s2 >>> 16 | s3 << 16 | 0xff000000;
  21850. dest[destPos + 3] = s3 >>> 8 | 0xff000000;
  21851. }
  21852. for (let j = i * 4, jj = src.length; j < jj; j += 3) {
  21853. dest[destPos++] = src[j] | src[j + 1] << 8 | src[j + 2] << 16 | 0xff000000;
  21854. }
  21855. } else {
  21856. for (; i < len32 - 2; i += 3, destPos += 4) {
  21857. const s1 = src32[i];
  21858. const s2 = src32[i + 1];
  21859. const s3 = src32[i + 2];
  21860. dest[destPos] = s1 | 0xff;
  21861. dest[destPos + 1] = s1 << 24 | s2 >>> 8 | 0xff;
  21862. dest[destPos + 2] = s2 << 16 | s3 >>> 16 | 0xff;
  21863. dest[destPos + 3] = s3 << 8 | 0xff;
  21864. }
  21865. for (let j = i * 4, jj = src.length; j < jj; j += 3) {
  21866. dest[destPos++] = src[j] << 24 | src[j + 1] << 16 | src[j + 2] << 8 | 0xff;
  21867. }
  21868. }
  21869. return {
  21870. srcPos,
  21871. destPos
  21872. };
  21873. }
  21874. function grayToRGBA(src, dest) {
  21875. if (_util.FeatureTest.isLittleEndian) {
  21876. for (let i = 0, ii = src.length; i < ii; i++) {
  21877. dest[i] = src[i] * 0x10101 | 0xff000000;
  21878. }
  21879. } else {
  21880. for (let i = 0, ii = src.length; i < ii; i++) {
  21881. dest[i] = src[i] * 0x1010100 | 0x000000ff;
  21882. }
  21883. }
  21884. }
  21885. /***/ }),
  21886. /* 180 */
  21887. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  21888. Object.defineProperty(exports, "__esModule", ({
  21889. value: true
  21890. }));
  21891. exports.JpxStream = void 0;
  21892. __w_pdfjs_require__(84);
  21893. __w_pdfjs_require__(93);
  21894. __w_pdfjs_require__(94);
  21895. __w_pdfjs_require__(97);
  21896. __w_pdfjs_require__(99);
  21897. __w_pdfjs_require__(101);
  21898. __w_pdfjs_require__(105);
  21899. __w_pdfjs_require__(108);
  21900. __w_pdfjs_require__(115);
  21901. var _decode_stream = __w_pdfjs_require__(169);
  21902. var _jpx = __w_pdfjs_require__(181);
  21903. var _util = __w_pdfjs_require__(145);
  21904. class JpxStream extends _decode_stream.DecodeStream {
  21905. constructor(stream, maybeLength, params) {
  21906. super(maybeLength);
  21907. this.stream = stream;
  21908. this.dict = stream.dict;
  21909. this.maybeLength = maybeLength;
  21910. this.params = params;
  21911. }
  21912. get bytes() {
  21913. return (0, _util.shadow)(this, "bytes", this.stream.getBytes(this.maybeLength));
  21914. }
  21915. ensureBuffer(requested) {}
  21916. readBlock() {
  21917. if (this.eof) {
  21918. return;
  21919. }
  21920. const jpxImage = new _jpx.JpxImage();
  21921. jpxImage.parse(this.bytes);
  21922. const width = jpxImage.width;
  21923. const height = jpxImage.height;
  21924. const componentsCount = jpxImage.componentsCount;
  21925. const tileCount = jpxImage.tiles.length;
  21926. if (tileCount === 1) {
  21927. this.buffer = jpxImage.tiles[0].items;
  21928. } else {
  21929. const data = new Uint8ClampedArray(width * height * componentsCount);
  21930. for (let k = 0; k < tileCount; k++) {
  21931. const tileComponents = jpxImage.tiles[k];
  21932. const tileWidth = tileComponents.width;
  21933. const tileHeight = tileComponents.height;
  21934. const tileLeft = tileComponents.left;
  21935. const tileTop = tileComponents.top;
  21936. const src = tileComponents.items;
  21937. let srcPosition = 0;
  21938. let dataPosition = (width * tileTop + tileLeft) * componentsCount;
  21939. const imgRowSize = width * componentsCount;
  21940. const tileRowSize = tileWidth * componentsCount;
  21941. for (let j = 0; j < tileHeight; j++) {
  21942. const rowBytes = src.subarray(srcPosition, srcPosition + tileRowSize);
  21943. data.set(rowBytes, dataPosition);
  21944. srcPosition += tileRowSize;
  21945. dataPosition += imgRowSize;
  21946. }
  21947. }
  21948. this.buffer = data;
  21949. }
  21950. this.bufferLength = this.buffer.length;
  21951. this.eof = true;
  21952. }
  21953. }
  21954. exports.JpxStream = JpxStream;
  21955. /***/ }),
  21956. /* 181 */
  21957. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  21958. Object.defineProperty(exports, "__esModule", ({
  21959. value: true
  21960. }));
  21961. exports.JpxImage = void 0;
  21962. __w_pdfjs_require__(140);
  21963. __w_pdfjs_require__(2);
  21964. __w_pdfjs_require__(84);
  21965. __w_pdfjs_require__(93);
  21966. __w_pdfjs_require__(94);
  21967. __w_pdfjs_require__(97);
  21968. __w_pdfjs_require__(99);
  21969. __w_pdfjs_require__(101);
  21970. __w_pdfjs_require__(105);
  21971. __w_pdfjs_require__(108);
  21972. __w_pdfjs_require__(115);
  21973. var _util = __w_pdfjs_require__(145);
  21974. var _core_utils = __w_pdfjs_require__(150);
  21975. var _arithmetic_decoder = __w_pdfjs_require__(176);
  21976. class JpxError extends _util.BaseException {
  21977. constructor(msg) {
  21978. super(`JPX error: ${msg}`, "JpxError");
  21979. }
  21980. }
  21981. const SubbandsGainLog2 = {
  21982. LL: 0,
  21983. LH: 1,
  21984. HL: 1,
  21985. HH: 2
  21986. };
  21987. class JpxImage {
  21988. constructor() {
  21989. this.failOnCorruptedImage = false;
  21990. }
  21991. parse(data) {
  21992. const head = (0, _core_utils.readUint16)(data, 0);
  21993. if (head === 0xff4f) {
  21994. this.parseCodestream(data, 0, data.length);
  21995. return;
  21996. }
  21997. const length = data.length;
  21998. let position = 0;
  21999. while (position < length) {
  22000. let headerSize = 8;
  22001. let lbox = (0, _core_utils.readUint32)(data, position);
  22002. const tbox = (0, _core_utils.readUint32)(data, position + 4);
  22003. position += headerSize;
  22004. if (lbox === 1) {
  22005. lbox = (0, _core_utils.readUint32)(data, position) * 4294967296 + (0, _core_utils.readUint32)(data, position + 4);
  22006. position += 8;
  22007. headerSize += 8;
  22008. }
  22009. if (lbox === 0) {
  22010. lbox = length - position + headerSize;
  22011. }
  22012. if (lbox < headerSize) {
  22013. throw new JpxError("Invalid box field size");
  22014. }
  22015. const dataLength = lbox - headerSize;
  22016. let jumpDataLength = true;
  22017. switch (tbox) {
  22018. case 0x6a703268:
  22019. jumpDataLength = false;
  22020. break;
  22021. case 0x636f6c72:
  22022. const method = data[position];
  22023. if (method === 1) {
  22024. const colorspace = (0, _core_utils.readUint32)(data, position + 3);
  22025. switch (colorspace) {
  22026. case 16:
  22027. case 17:
  22028. case 18:
  22029. break;
  22030. default:
  22031. (0, _util.warn)("Unknown colorspace " + colorspace);
  22032. break;
  22033. }
  22034. } else if (method === 2) {
  22035. (0, _util.info)("ICC profile not supported");
  22036. }
  22037. break;
  22038. case 0x6a703263:
  22039. this.parseCodestream(data, position, position + dataLength);
  22040. break;
  22041. case 0x6a502020:
  22042. if ((0, _core_utils.readUint32)(data, position) !== 0x0d0a870a) {
  22043. (0, _util.warn)("Invalid JP2 signature");
  22044. }
  22045. break;
  22046. case 0x6a501a1a:
  22047. case 0x66747970:
  22048. case 0x72726571:
  22049. case 0x72657320:
  22050. case 0x69686472:
  22051. break;
  22052. default:
  22053. const headerType = String.fromCharCode(tbox >> 24 & 0xff, tbox >> 16 & 0xff, tbox >> 8 & 0xff, tbox & 0xff);
  22054. (0, _util.warn)(`Unsupported header type ${tbox} (${headerType}).`);
  22055. break;
  22056. }
  22057. if (jumpDataLength) {
  22058. position += dataLength;
  22059. }
  22060. }
  22061. }
  22062. parseImageProperties(stream) {
  22063. let newByte = stream.getByte();
  22064. while (newByte >= 0) {
  22065. const oldByte = newByte;
  22066. newByte = stream.getByte();
  22067. const code = oldByte << 8 | newByte;
  22068. if (code === 0xff51) {
  22069. stream.skip(4);
  22070. const Xsiz = stream.getInt32() >>> 0;
  22071. const Ysiz = stream.getInt32() >>> 0;
  22072. const XOsiz = stream.getInt32() >>> 0;
  22073. const YOsiz = stream.getInt32() >>> 0;
  22074. stream.skip(16);
  22075. const Csiz = stream.getUint16();
  22076. this.width = Xsiz - XOsiz;
  22077. this.height = Ysiz - YOsiz;
  22078. this.componentsCount = Csiz;
  22079. this.bitsPerComponent = 8;
  22080. return;
  22081. }
  22082. }
  22083. throw new JpxError("No size marker found in JPX stream");
  22084. }
  22085. parseCodestream(data, start, end) {
  22086. const context = {};
  22087. let doNotRecover = false;
  22088. try {
  22089. let position = start;
  22090. while (position + 1 < end) {
  22091. const code = (0, _core_utils.readUint16)(data, position);
  22092. position += 2;
  22093. let length = 0,
  22094. j,
  22095. sqcd,
  22096. spqcds,
  22097. spqcdSize,
  22098. scalarExpounded,
  22099. tile;
  22100. switch (code) {
  22101. case 0xff4f:
  22102. context.mainHeader = true;
  22103. break;
  22104. case 0xffd9:
  22105. break;
  22106. case 0xff51:
  22107. length = (0, _core_utils.readUint16)(data, position);
  22108. const siz = {};
  22109. siz.Xsiz = (0, _core_utils.readUint32)(data, position + 4);
  22110. siz.Ysiz = (0, _core_utils.readUint32)(data, position + 8);
  22111. siz.XOsiz = (0, _core_utils.readUint32)(data, position + 12);
  22112. siz.YOsiz = (0, _core_utils.readUint32)(data, position + 16);
  22113. siz.XTsiz = (0, _core_utils.readUint32)(data, position + 20);
  22114. siz.YTsiz = (0, _core_utils.readUint32)(data, position + 24);
  22115. siz.XTOsiz = (0, _core_utils.readUint32)(data, position + 28);
  22116. siz.YTOsiz = (0, _core_utils.readUint32)(data, position + 32);
  22117. const componentsCount = (0, _core_utils.readUint16)(data, position + 36);
  22118. siz.Csiz = componentsCount;
  22119. const components = [];
  22120. j = position + 38;
  22121. for (let i = 0; i < componentsCount; i++) {
  22122. const component = {
  22123. precision: (data[j] & 0x7f) + 1,
  22124. isSigned: !!(data[j] & 0x80),
  22125. XRsiz: data[j + 1],
  22126. YRsiz: data[j + 2]
  22127. };
  22128. j += 3;
  22129. calculateComponentDimensions(component, siz);
  22130. components.push(component);
  22131. }
  22132. context.SIZ = siz;
  22133. context.components = components;
  22134. calculateTileGrids(context, components);
  22135. context.QCC = [];
  22136. context.COC = [];
  22137. break;
  22138. case 0xff5c:
  22139. length = (0, _core_utils.readUint16)(data, position);
  22140. const qcd = {};
  22141. j = position + 2;
  22142. sqcd = data[j++];
  22143. switch (sqcd & 0x1f) {
  22144. case 0:
  22145. spqcdSize = 8;
  22146. scalarExpounded = true;
  22147. break;
  22148. case 1:
  22149. spqcdSize = 16;
  22150. scalarExpounded = false;
  22151. break;
  22152. case 2:
  22153. spqcdSize = 16;
  22154. scalarExpounded = true;
  22155. break;
  22156. default:
  22157. throw new Error("Invalid SQcd value " + sqcd);
  22158. }
  22159. qcd.noQuantization = spqcdSize === 8;
  22160. qcd.scalarExpounded = scalarExpounded;
  22161. qcd.guardBits = sqcd >> 5;
  22162. spqcds = [];
  22163. while (j < length + position) {
  22164. const spqcd = {};
  22165. if (spqcdSize === 8) {
  22166. spqcd.epsilon = data[j++] >> 3;
  22167. spqcd.mu = 0;
  22168. } else {
  22169. spqcd.epsilon = data[j] >> 3;
  22170. spqcd.mu = (data[j] & 0x7) << 8 | data[j + 1];
  22171. j += 2;
  22172. }
  22173. spqcds.push(spqcd);
  22174. }
  22175. qcd.SPqcds = spqcds;
  22176. if (context.mainHeader) {
  22177. context.QCD = qcd;
  22178. } else {
  22179. context.currentTile.QCD = qcd;
  22180. context.currentTile.QCC = [];
  22181. }
  22182. break;
  22183. case 0xff5d:
  22184. length = (0, _core_utils.readUint16)(data, position);
  22185. const qcc = {};
  22186. j = position + 2;
  22187. let cqcc;
  22188. if (context.SIZ.Csiz < 257) {
  22189. cqcc = data[j++];
  22190. } else {
  22191. cqcc = (0, _core_utils.readUint16)(data, j);
  22192. j += 2;
  22193. }
  22194. sqcd = data[j++];
  22195. switch (sqcd & 0x1f) {
  22196. case 0:
  22197. spqcdSize = 8;
  22198. scalarExpounded = true;
  22199. break;
  22200. case 1:
  22201. spqcdSize = 16;
  22202. scalarExpounded = false;
  22203. break;
  22204. case 2:
  22205. spqcdSize = 16;
  22206. scalarExpounded = true;
  22207. break;
  22208. default:
  22209. throw new Error("Invalid SQcd value " + sqcd);
  22210. }
  22211. qcc.noQuantization = spqcdSize === 8;
  22212. qcc.scalarExpounded = scalarExpounded;
  22213. qcc.guardBits = sqcd >> 5;
  22214. spqcds = [];
  22215. while (j < length + position) {
  22216. const spqcd = {};
  22217. if (spqcdSize === 8) {
  22218. spqcd.epsilon = data[j++] >> 3;
  22219. spqcd.mu = 0;
  22220. } else {
  22221. spqcd.epsilon = data[j] >> 3;
  22222. spqcd.mu = (data[j] & 0x7) << 8 | data[j + 1];
  22223. j += 2;
  22224. }
  22225. spqcds.push(spqcd);
  22226. }
  22227. qcc.SPqcds = spqcds;
  22228. if (context.mainHeader) {
  22229. context.QCC[cqcc] = qcc;
  22230. } else {
  22231. context.currentTile.QCC[cqcc] = qcc;
  22232. }
  22233. break;
  22234. case 0xff52:
  22235. length = (0, _core_utils.readUint16)(data, position);
  22236. const cod = {};
  22237. j = position + 2;
  22238. const scod = data[j++];
  22239. cod.entropyCoderWithCustomPrecincts = !!(scod & 1);
  22240. cod.sopMarkerUsed = !!(scod & 2);
  22241. cod.ephMarkerUsed = !!(scod & 4);
  22242. cod.progressionOrder = data[j++];
  22243. cod.layersCount = (0, _core_utils.readUint16)(data, j);
  22244. j += 2;
  22245. cod.multipleComponentTransform = data[j++];
  22246. cod.decompositionLevelsCount = data[j++];
  22247. cod.xcb = (data[j++] & 0xf) + 2;
  22248. cod.ycb = (data[j++] & 0xf) + 2;
  22249. const blockStyle = data[j++];
  22250. cod.selectiveArithmeticCodingBypass = !!(blockStyle & 1);
  22251. cod.resetContextProbabilities = !!(blockStyle & 2);
  22252. cod.terminationOnEachCodingPass = !!(blockStyle & 4);
  22253. cod.verticallyStripe = !!(blockStyle & 8);
  22254. cod.predictableTermination = !!(blockStyle & 16);
  22255. cod.segmentationSymbolUsed = !!(blockStyle & 32);
  22256. cod.reversibleTransformation = data[j++];
  22257. if (cod.entropyCoderWithCustomPrecincts) {
  22258. const precinctsSizes = [];
  22259. while (j < length + position) {
  22260. const precinctsSize = data[j++];
  22261. precinctsSizes.push({
  22262. PPx: precinctsSize & 0xf,
  22263. PPy: precinctsSize >> 4
  22264. });
  22265. }
  22266. cod.precinctsSizes = precinctsSizes;
  22267. }
  22268. const unsupported = [];
  22269. if (cod.selectiveArithmeticCodingBypass) {
  22270. unsupported.push("selectiveArithmeticCodingBypass");
  22271. }
  22272. if (cod.terminationOnEachCodingPass) {
  22273. unsupported.push("terminationOnEachCodingPass");
  22274. }
  22275. if (cod.verticallyStripe) {
  22276. unsupported.push("verticallyStripe");
  22277. }
  22278. if (cod.predictableTermination) {
  22279. unsupported.push("predictableTermination");
  22280. }
  22281. if (unsupported.length > 0) {
  22282. doNotRecover = true;
  22283. (0, _util.warn)(`JPX: Unsupported COD options (${unsupported.join(", ")}).`);
  22284. }
  22285. if (context.mainHeader) {
  22286. context.COD = cod;
  22287. } else {
  22288. context.currentTile.COD = cod;
  22289. context.currentTile.COC = [];
  22290. }
  22291. break;
  22292. case 0xff90:
  22293. length = (0, _core_utils.readUint16)(data, position);
  22294. tile = {};
  22295. tile.index = (0, _core_utils.readUint16)(data, position + 2);
  22296. tile.length = (0, _core_utils.readUint32)(data, position + 4);
  22297. tile.dataEnd = tile.length + position - 2;
  22298. tile.partIndex = data[position + 8];
  22299. tile.partsCount = data[position + 9];
  22300. context.mainHeader = false;
  22301. if (tile.partIndex === 0) {
  22302. tile.COD = context.COD;
  22303. tile.COC = context.COC.slice(0);
  22304. tile.QCD = context.QCD;
  22305. tile.QCC = context.QCC.slice(0);
  22306. }
  22307. context.currentTile = tile;
  22308. break;
  22309. case 0xff93:
  22310. tile = context.currentTile;
  22311. if (tile.partIndex === 0) {
  22312. initializeTile(context, tile.index);
  22313. buildPackets(context);
  22314. }
  22315. length = tile.dataEnd - position;
  22316. parseTilePackets(context, data, position, length);
  22317. break;
  22318. case 0xff53:
  22319. (0, _util.warn)("JPX: Codestream code 0xFF53 (COC) is not implemented.");
  22320. case 0xff55:
  22321. case 0xff57:
  22322. case 0xff58:
  22323. case 0xff64:
  22324. length = (0, _core_utils.readUint16)(data, position);
  22325. break;
  22326. default:
  22327. throw new Error("Unknown codestream code: " + code.toString(16));
  22328. }
  22329. position += length;
  22330. }
  22331. } catch (e) {
  22332. if (doNotRecover || this.failOnCorruptedImage) {
  22333. throw new JpxError(e.message);
  22334. } else {
  22335. (0, _util.warn)(`JPX: Trying to recover from: "${e.message}".`);
  22336. }
  22337. }
  22338. this.tiles = transformComponents(context);
  22339. this.width = context.SIZ.Xsiz - context.SIZ.XOsiz;
  22340. this.height = context.SIZ.Ysiz - context.SIZ.YOsiz;
  22341. this.componentsCount = context.SIZ.Csiz;
  22342. }
  22343. }
  22344. exports.JpxImage = JpxImage;
  22345. function calculateComponentDimensions(component, siz) {
  22346. component.x0 = Math.ceil(siz.XOsiz / component.XRsiz);
  22347. component.x1 = Math.ceil(siz.Xsiz / component.XRsiz);
  22348. component.y0 = Math.ceil(siz.YOsiz / component.YRsiz);
  22349. component.y1 = Math.ceil(siz.Ysiz / component.YRsiz);
  22350. component.width = component.x1 - component.x0;
  22351. component.height = component.y1 - component.y0;
  22352. }
  22353. function calculateTileGrids(context, components) {
  22354. const siz = context.SIZ;
  22355. const tiles = [];
  22356. let tile;
  22357. const numXtiles = Math.ceil((siz.Xsiz - siz.XTOsiz) / siz.XTsiz);
  22358. const numYtiles = Math.ceil((siz.Ysiz - siz.YTOsiz) / siz.YTsiz);
  22359. for (let q = 0; q < numYtiles; q++) {
  22360. for (let p = 0; p < numXtiles; p++) {
  22361. tile = {};
  22362. tile.tx0 = Math.max(siz.XTOsiz + p * siz.XTsiz, siz.XOsiz);
  22363. tile.ty0 = Math.max(siz.YTOsiz + q * siz.YTsiz, siz.YOsiz);
  22364. tile.tx1 = Math.min(siz.XTOsiz + (p + 1) * siz.XTsiz, siz.Xsiz);
  22365. tile.ty1 = Math.min(siz.YTOsiz + (q + 1) * siz.YTsiz, siz.Ysiz);
  22366. tile.width = tile.tx1 - tile.tx0;
  22367. tile.height = tile.ty1 - tile.ty0;
  22368. tile.components = [];
  22369. tiles.push(tile);
  22370. }
  22371. }
  22372. context.tiles = tiles;
  22373. const componentsCount = siz.Csiz;
  22374. for (let i = 0, ii = componentsCount; i < ii; i++) {
  22375. const component = components[i];
  22376. for (let j = 0, jj = tiles.length; j < jj; j++) {
  22377. const tileComponent = {};
  22378. tile = tiles[j];
  22379. tileComponent.tcx0 = Math.ceil(tile.tx0 / component.XRsiz);
  22380. tileComponent.tcy0 = Math.ceil(tile.ty0 / component.YRsiz);
  22381. tileComponent.tcx1 = Math.ceil(tile.tx1 / component.XRsiz);
  22382. tileComponent.tcy1 = Math.ceil(tile.ty1 / component.YRsiz);
  22383. tileComponent.width = tileComponent.tcx1 - tileComponent.tcx0;
  22384. tileComponent.height = tileComponent.tcy1 - tileComponent.tcy0;
  22385. tile.components[i] = tileComponent;
  22386. }
  22387. }
  22388. }
  22389. function getBlocksDimensions(context, component, r) {
  22390. const codOrCoc = component.codingStyleParameters;
  22391. const result = {};
  22392. if (!codOrCoc.entropyCoderWithCustomPrecincts) {
  22393. result.PPx = 15;
  22394. result.PPy = 15;
  22395. } else {
  22396. result.PPx = codOrCoc.precinctsSizes[r].PPx;
  22397. result.PPy = codOrCoc.precinctsSizes[r].PPy;
  22398. }
  22399. result.xcb_ = r > 0 ? Math.min(codOrCoc.xcb, result.PPx - 1) : Math.min(codOrCoc.xcb, result.PPx);
  22400. result.ycb_ = r > 0 ? Math.min(codOrCoc.ycb, result.PPy - 1) : Math.min(codOrCoc.ycb, result.PPy);
  22401. return result;
  22402. }
  22403. function buildPrecincts(context, resolution, dimensions) {
  22404. const precinctWidth = 1 << dimensions.PPx;
  22405. const precinctHeight = 1 << dimensions.PPy;
  22406. const isZeroRes = resolution.resLevel === 0;
  22407. const precinctWidthInSubband = 1 << dimensions.PPx + (isZeroRes ? 0 : -1);
  22408. const precinctHeightInSubband = 1 << dimensions.PPy + (isZeroRes ? 0 : -1);
  22409. const numprecinctswide = resolution.trx1 > resolution.trx0 ? Math.ceil(resolution.trx1 / precinctWidth) - Math.floor(resolution.trx0 / precinctWidth) : 0;
  22410. const numprecinctshigh = resolution.try1 > resolution.try0 ? Math.ceil(resolution.try1 / precinctHeight) - Math.floor(resolution.try0 / precinctHeight) : 0;
  22411. const numprecincts = numprecinctswide * numprecinctshigh;
  22412. resolution.precinctParameters = {
  22413. precinctWidth,
  22414. precinctHeight,
  22415. numprecinctswide,
  22416. numprecinctshigh,
  22417. numprecincts,
  22418. precinctWidthInSubband,
  22419. precinctHeightInSubband
  22420. };
  22421. }
  22422. function buildCodeblocks(context, subband, dimensions) {
  22423. const xcb_ = dimensions.xcb_;
  22424. const ycb_ = dimensions.ycb_;
  22425. const codeblockWidth = 1 << xcb_;
  22426. const codeblockHeight = 1 << ycb_;
  22427. const cbx0 = subband.tbx0 >> xcb_;
  22428. const cby0 = subband.tby0 >> ycb_;
  22429. const cbx1 = subband.tbx1 + codeblockWidth - 1 >> xcb_;
  22430. const cby1 = subband.tby1 + codeblockHeight - 1 >> ycb_;
  22431. const precinctParameters = subband.resolution.precinctParameters;
  22432. const codeblocks = [];
  22433. const precincts = [];
  22434. let i, j, codeblock, precinctNumber;
  22435. for (j = cby0; j < cby1; j++) {
  22436. for (i = cbx0; i < cbx1; i++) {
  22437. codeblock = {
  22438. cbx: i,
  22439. cby: j,
  22440. tbx0: codeblockWidth * i,
  22441. tby0: codeblockHeight * j,
  22442. tbx1: codeblockWidth * (i + 1),
  22443. tby1: codeblockHeight * (j + 1)
  22444. };
  22445. codeblock.tbx0_ = Math.max(subband.tbx0, codeblock.tbx0);
  22446. codeblock.tby0_ = Math.max(subband.tby0, codeblock.tby0);
  22447. codeblock.tbx1_ = Math.min(subband.tbx1, codeblock.tbx1);
  22448. codeblock.tby1_ = Math.min(subband.tby1, codeblock.tby1);
  22449. const pi = Math.floor((codeblock.tbx0_ - subband.tbx0) / precinctParameters.precinctWidthInSubband);
  22450. const pj = Math.floor((codeblock.tby0_ - subband.tby0) / precinctParameters.precinctHeightInSubband);
  22451. precinctNumber = pi + pj * precinctParameters.numprecinctswide;
  22452. codeblock.precinctNumber = precinctNumber;
  22453. codeblock.subbandType = subband.type;
  22454. codeblock.Lblock = 3;
  22455. if (codeblock.tbx1_ <= codeblock.tbx0_ || codeblock.tby1_ <= codeblock.tby0_) {
  22456. continue;
  22457. }
  22458. codeblocks.push(codeblock);
  22459. let precinct = precincts[precinctNumber];
  22460. if (precinct !== undefined) {
  22461. if (i < precinct.cbxMin) {
  22462. precinct.cbxMin = i;
  22463. } else if (i > precinct.cbxMax) {
  22464. precinct.cbxMax = i;
  22465. }
  22466. if (j < precinct.cbyMin) {
  22467. precinct.cbxMin = j;
  22468. } else if (j > precinct.cbyMax) {
  22469. precinct.cbyMax = j;
  22470. }
  22471. } else {
  22472. precincts[precinctNumber] = precinct = {
  22473. cbxMin: i,
  22474. cbyMin: j,
  22475. cbxMax: i,
  22476. cbyMax: j
  22477. };
  22478. }
  22479. codeblock.precinct = precinct;
  22480. }
  22481. }
  22482. subband.codeblockParameters = {
  22483. codeblockWidth: xcb_,
  22484. codeblockHeight: ycb_,
  22485. numcodeblockwide: cbx1 - cbx0 + 1,
  22486. numcodeblockhigh: cby1 - cby0 + 1
  22487. };
  22488. subband.codeblocks = codeblocks;
  22489. subband.precincts = precincts;
  22490. }
  22491. function createPacket(resolution, precinctNumber, layerNumber) {
  22492. const precinctCodeblocks = [];
  22493. const subbands = resolution.subbands;
  22494. for (let i = 0, ii = subbands.length; i < ii; i++) {
  22495. const subband = subbands[i];
  22496. const codeblocks = subband.codeblocks;
  22497. for (let j = 0, jj = codeblocks.length; j < jj; j++) {
  22498. const codeblock = codeblocks[j];
  22499. if (codeblock.precinctNumber !== precinctNumber) {
  22500. continue;
  22501. }
  22502. precinctCodeblocks.push(codeblock);
  22503. }
  22504. }
  22505. return {
  22506. layerNumber,
  22507. codeblocks: precinctCodeblocks
  22508. };
  22509. }
  22510. function LayerResolutionComponentPositionIterator(context) {
  22511. const siz = context.SIZ;
  22512. const tileIndex = context.currentTile.index;
  22513. const tile = context.tiles[tileIndex];
  22514. const layersCount = tile.codingStyleDefaultParameters.layersCount;
  22515. const componentsCount = siz.Csiz;
  22516. let maxDecompositionLevelsCount = 0;
  22517. for (let q = 0; q < componentsCount; q++) {
  22518. maxDecompositionLevelsCount = Math.max(maxDecompositionLevelsCount, tile.components[q].codingStyleParameters.decompositionLevelsCount);
  22519. }
  22520. let l = 0,
  22521. r = 0,
  22522. i = 0,
  22523. k = 0;
  22524. this.nextPacket = function JpxImage_nextPacket() {
  22525. for (; l < layersCount; l++) {
  22526. for (; r <= maxDecompositionLevelsCount; r++) {
  22527. for (; i < componentsCount; i++) {
  22528. const component = tile.components[i];
  22529. if (r > component.codingStyleParameters.decompositionLevelsCount) {
  22530. continue;
  22531. }
  22532. const resolution = component.resolutions[r];
  22533. const numprecincts = resolution.precinctParameters.numprecincts;
  22534. for (; k < numprecincts;) {
  22535. const packet = createPacket(resolution, k, l);
  22536. k++;
  22537. return packet;
  22538. }
  22539. k = 0;
  22540. }
  22541. i = 0;
  22542. }
  22543. r = 0;
  22544. }
  22545. throw new JpxError("Out of packets");
  22546. };
  22547. }
  22548. function ResolutionLayerComponentPositionIterator(context) {
  22549. const siz = context.SIZ;
  22550. const tileIndex = context.currentTile.index;
  22551. const tile = context.tiles[tileIndex];
  22552. const layersCount = tile.codingStyleDefaultParameters.layersCount;
  22553. const componentsCount = siz.Csiz;
  22554. let maxDecompositionLevelsCount = 0;
  22555. for (let q = 0; q < componentsCount; q++) {
  22556. maxDecompositionLevelsCount = Math.max(maxDecompositionLevelsCount, tile.components[q].codingStyleParameters.decompositionLevelsCount);
  22557. }
  22558. let r = 0,
  22559. l = 0,
  22560. i = 0,
  22561. k = 0;
  22562. this.nextPacket = function JpxImage_nextPacket() {
  22563. for (; r <= maxDecompositionLevelsCount; r++) {
  22564. for (; l < layersCount; l++) {
  22565. for (; i < componentsCount; i++) {
  22566. const component = tile.components[i];
  22567. if (r > component.codingStyleParameters.decompositionLevelsCount) {
  22568. continue;
  22569. }
  22570. const resolution = component.resolutions[r];
  22571. const numprecincts = resolution.precinctParameters.numprecincts;
  22572. for (; k < numprecincts;) {
  22573. const packet = createPacket(resolution, k, l);
  22574. k++;
  22575. return packet;
  22576. }
  22577. k = 0;
  22578. }
  22579. i = 0;
  22580. }
  22581. l = 0;
  22582. }
  22583. throw new JpxError("Out of packets");
  22584. };
  22585. }
  22586. function ResolutionPositionComponentLayerIterator(context) {
  22587. const siz = context.SIZ;
  22588. const tileIndex = context.currentTile.index;
  22589. const tile = context.tiles[tileIndex];
  22590. const layersCount = tile.codingStyleDefaultParameters.layersCount;
  22591. const componentsCount = siz.Csiz;
  22592. let l, r, c, p;
  22593. let maxDecompositionLevelsCount = 0;
  22594. for (c = 0; c < componentsCount; c++) {
  22595. const component = tile.components[c];
  22596. maxDecompositionLevelsCount = Math.max(maxDecompositionLevelsCount, component.codingStyleParameters.decompositionLevelsCount);
  22597. }
  22598. const maxNumPrecinctsInLevel = new Int32Array(maxDecompositionLevelsCount + 1);
  22599. for (r = 0; r <= maxDecompositionLevelsCount; ++r) {
  22600. let maxNumPrecincts = 0;
  22601. for (c = 0; c < componentsCount; ++c) {
  22602. const resolutions = tile.components[c].resolutions;
  22603. if (r < resolutions.length) {
  22604. maxNumPrecincts = Math.max(maxNumPrecincts, resolutions[r].precinctParameters.numprecincts);
  22605. }
  22606. }
  22607. maxNumPrecinctsInLevel[r] = maxNumPrecincts;
  22608. }
  22609. l = 0;
  22610. r = 0;
  22611. c = 0;
  22612. p = 0;
  22613. this.nextPacket = function JpxImage_nextPacket() {
  22614. for (; r <= maxDecompositionLevelsCount; r++) {
  22615. for (; p < maxNumPrecinctsInLevel[r]; p++) {
  22616. for (; c < componentsCount; c++) {
  22617. const component = tile.components[c];
  22618. if (r > component.codingStyleParameters.decompositionLevelsCount) {
  22619. continue;
  22620. }
  22621. const resolution = component.resolutions[r];
  22622. const numprecincts = resolution.precinctParameters.numprecincts;
  22623. if (p >= numprecincts) {
  22624. continue;
  22625. }
  22626. for (; l < layersCount;) {
  22627. const packet = createPacket(resolution, p, l);
  22628. l++;
  22629. return packet;
  22630. }
  22631. l = 0;
  22632. }
  22633. c = 0;
  22634. }
  22635. p = 0;
  22636. }
  22637. throw new JpxError("Out of packets");
  22638. };
  22639. }
  22640. function PositionComponentResolutionLayerIterator(context) {
  22641. const siz = context.SIZ;
  22642. const tileIndex = context.currentTile.index;
  22643. const tile = context.tiles[tileIndex];
  22644. const layersCount = tile.codingStyleDefaultParameters.layersCount;
  22645. const componentsCount = siz.Csiz;
  22646. const precinctsSizes = getPrecinctSizesInImageScale(tile);
  22647. const precinctsIterationSizes = precinctsSizes;
  22648. let l = 0,
  22649. r = 0,
  22650. c = 0,
  22651. px = 0,
  22652. py = 0;
  22653. this.nextPacket = function JpxImage_nextPacket() {
  22654. for (; py < precinctsIterationSizes.maxNumHigh; py++) {
  22655. for (; px < precinctsIterationSizes.maxNumWide; px++) {
  22656. for (; c < componentsCount; c++) {
  22657. const component = tile.components[c];
  22658. const decompositionLevelsCount = component.codingStyleParameters.decompositionLevelsCount;
  22659. for (; r <= decompositionLevelsCount; r++) {
  22660. const resolution = component.resolutions[r];
  22661. const sizeInImageScale = precinctsSizes.components[c].resolutions[r];
  22662. const k = getPrecinctIndexIfExist(px, py, sizeInImageScale, precinctsIterationSizes, resolution);
  22663. if (k === null) {
  22664. continue;
  22665. }
  22666. for (; l < layersCount;) {
  22667. const packet = createPacket(resolution, k, l);
  22668. l++;
  22669. return packet;
  22670. }
  22671. l = 0;
  22672. }
  22673. r = 0;
  22674. }
  22675. c = 0;
  22676. }
  22677. px = 0;
  22678. }
  22679. throw new JpxError("Out of packets");
  22680. };
  22681. }
  22682. function ComponentPositionResolutionLayerIterator(context) {
  22683. const siz = context.SIZ;
  22684. const tileIndex = context.currentTile.index;
  22685. const tile = context.tiles[tileIndex];
  22686. const layersCount = tile.codingStyleDefaultParameters.layersCount;
  22687. const componentsCount = siz.Csiz;
  22688. const precinctsSizes = getPrecinctSizesInImageScale(tile);
  22689. let l = 0,
  22690. r = 0,
  22691. c = 0,
  22692. px = 0,
  22693. py = 0;
  22694. this.nextPacket = function JpxImage_nextPacket() {
  22695. for (; c < componentsCount; ++c) {
  22696. const component = tile.components[c];
  22697. const precinctsIterationSizes = precinctsSizes.components[c];
  22698. const decompositionLevelsCount = component.codingStyleParameters.decompositionLevelsCount;
  22699. for (; py < precinctsIterationSizes.maxNumHigh; py++) {
  22700. for (; px < precinctsIterationSizes.maxNumWide; px++) {
  22701. for (; r <= decompositionLevelsCount; r++) {
  22702. const resolution = component.resolutions[r];
  22703. const sizeInImageScale = precinctsIterationSizes.resolutions[r];
  22704. const k = getPrecinctIndexIfExist(px, py, sizeInImageScale, precinctsIterationSizes, resolution);
  22705. if (k === null) {
  22706. continue;
  22707. }
  22708. for (; l < layersCount;) {
  22709. const packet = createPacket(resolution, k, l);
  22710. l++;
  22711. return packet;
  22712. }
  22713. l = 0;
  22714. }
  22715. r = 0;
  22716. }
  22717. px = 0;
  22718. }
  22719. py = 0;
  22720. }
  22721. throw new JpxError("Out of packets");
  22722. };
  22723. }
  22724. function getPrecinctIndexIfExist(pxIndex, pyIndex, sizeInImageScale, precinctIterationSizes, resolution) {
  22725. const posX = pxIndex * precinctIterationSizes.minWidth;
  22726. const posY = pyIndex * precinctIterationSizes.minHeight;
  22727. if (posX % sizeInImageScale.width !== 0 || posY % sizeInImageScale.height !== 0) {
  22728. return null;
  22729. }
  22730. const startPrecinctRowIndex = posY / sizeInImageScale.width * resolution.precinctParameters.numprecinctswide;
  22731. return posX / sizeInImageScale.height + startPrecinctRowIndex;
  22732. }
  22733. function getPrecinctSizesInImageScale(tile) {
  22734. const componentsCount = tile.components.length;
  22735. let minWidth = Number.MAX_VALUE;
  22736. let minHeight = Number.MAX_VALUE;
  22737. let maxNumWide = 0;
  22738. let maxNumHigh = 0;
  22739. const sizePerComponent = new Array(componentsCount);
  22740. for (let c = 0; c < componentsCount; c++) {
  22741. const component = tile.components[c];
  22742. const decompositionLevelsCount = component.codingStyleParameters.decompositionLevelsCount;
  22743. const sizePerResolution = new Array(decompositionLevelsCount + 1);
  22744. let minWidthCurrentComponent = Number.MAX_VALUE;
  22745. let minHeightCurrentComponent = Number.MAX_VALUE;
  22746. let maxNumWideCurrentComponent = 0;
  22747. let maxNumHighCurrentComponent = 0;
  22748. let scale = 1;
  22749. for (let r = decompositionLevelsCount; r >= 0; --r) {
  22750. const resolution = component.resolutions[r];
  22751. const widthCurrentResolution = scale * resolution.precinctParameters.precinctWidth;
  22752. const heightCurrentResolution = scale * resolution.precinctParameters.precinctHeight;
  22753. minWidthCurrentComponent = Math.min(minWidthCurrentComponent, widthCurrentResolution);
  22754. minHeightCurrentComponent = Math.min(minHeightCurrentComponent, heightCurrentResolution);
  22755. maxNumWideCurrentComponent = Math.max(maxNumWideCurrentComponent, resolution.precinctParameters.numprecinctswide);
  22756. maxNumHighCurrentComponent = Math.max(maxNumHighCurrentComponent, resolution.precinctParameters.numprecinctshigh);
  22757. sizePerResolution[r] = {
  22758. width: widthCurrentResolution,
  22759. height: heightCurrentResolution
  22760. };
  22761. scale <<= 1;
  22762. }
  22763. minWidth = Math.min(minWidth, minWidthCurrentComponent);
  22764. minHeight = Math.min(minHeight, minHeightCurrentComponent);
  22765. maxNumWide = Math.max(maxNumWide, maxNumWideCurrentComponent);
  22766. maxNumHigh = Math.max(maxNumHigh, maxNumHighCurrentComponent);
  22767. sizePerComponent[c] = {
  22768. resolutions: sizePerResolution,
  22769. minWidth: minWidthCurrentComponent,
  22770. minHeight: minHeightCurrentComponent,
  22771. maxNumWide: maxNumWideCurrentComponent,
  22772. maxNumHigh: maxNumHighCurrentComponent
  22773. };
  22774. }
  22775. return {
  22776. components: sizePerComponent,
  22777. minWidth,
  22778. minHeight,
  22779. maxNumWide,
  22780. maxNumHigh
  22781. };
  22782. }
  22783. function buildPackets(context) {
  22784. const siz = context.SIZ;
  22785. const tileIndex = context.currentTile.index;
  22786. const tile = context.tiles[tileIndex];
  22787. const componentsCount = siz.Csiz;
  22788. for (let c = 0; c < componentsCount; c++) {
  22789. const component = tile.components[c];
  22790. const decompositionLevelsCount = component.codingStyleParameters.decompositionLevelsCount;
  22791. const resolutions = [];
  22792. const subbands = [];
  22793. for (let r = 0; r <= decompositionLevelsCount; r++) {
  22794. const blocksDimensions = getBlocksDimensions(context, component, r);
  22795. const resolution = {};
  22796. const scale = 1 << decompositionLevelsCount - r;
  22797. resolution.trx0 = Math.ceil(component.tcx0 / scale);
  22798. resolution.try0 = Math.ceil(component.tcy0 / scale);
  22799. resolution.trx1 = Math.ceil(component.tcx1 / scale);
  22800. resolution.try1 = Math.ceil(component.tcy1 / scale);
  22801. resolution.resLevel = r;
  22802. buildPrecincts(context, resolution, blocksDimensions);
  22803. resolutions.push(resolution);
  22804. let subband;
  22805. if (r === 0) {
  22806. subband = {};
  22807. subband.type = "LL";
  22808. subband.tbx0 = Math.ceil(component.tcx0 / scale);
  22809. subband.tby0 = Math.ceil(component.tcy0 / scale);
  22810. subband.tbx1 = Math.ceil(component.tcx1 / scale);
  22811. subband.tby1 = Math.ceil(component.tcy1 / scale);
  22812. subband.resolution = resolution;
  22813. buildCodeblocks(context, subband, blocksDimensions);
  22814. subbands.push(subband);
  22815. resolution.subbands = [subband];
  22816. } else {
  22817. const bscale = 1 << decompositionLevelsCount - r + 1;
  22818. const resolutionSubbands = [];
  22819. subband = {};
  22820. subband.type = "HL";
  22821. subband.tbx0 = Math.ceil(component.tcx0 / bscale - 0.5);
  22822. subband.tby0 = Math.ceil(component.tcy0 / bscale);
  22823. subband.tbx1 = Math.ceil(component.tcx1 / bscale - 0.5);
  22824. subband.tby1 = Math.ceil(component.tcy1 / bscale);
  22825. subband.resolution = resolution;
  22826. buildCodeblocks(context, subband, blocksDimensions);
  22827. subbands.push(subband);
  22828. resolutionSubbands.push(subband);
  22829. subband = {};
  22830. subband.type = "LH";
  22831. subband.tbx0 = Math.ceil(component.tcx0 / bscale);
  22832. subband.tby0 = Math.ceil(component.tcy0 / bscale - 0.5);
  22833. subband.tbx1 = Math.ceil(component.tcx1 / bscale);
  22834. subband.tby1 = Math.ceil(component.tcy1 / bscale - 0.5);
  22835. subband.resolution = resolution;
  22836. buildCodeblocks(context, subband, blocksDimensions);
  22837. subbands.push(subband);
  22838. resolutionSubbands.push(subband);
  22839. subband = {};
  22840. subband.type = "HH";
  22841. subband.tbx0 = Math.ceil(component.tcx0 / bscale - 0.5);
  22842. subband.tby0 = Math.ceil(component.tcy0 / bscale - 0.5);
  22843. subband.tbx1 = Math.ceil(component.tcx1 / bscale - 0.5);
  22844. subband.tby1 = Math.ceil(component.tcy1 / bscale - 0.5);
  22845. subband.resolution = resolution;
  22846. buildCodeblocks(context, subband, blocksDimensions);
  22847. subbands.push(subband);
  22848. resolutionSubbands.push(subband);
  22849. resolution.subbands = resolutionSubbands;
  22850. }
  22851. }
  22852. component.resolutions = resolutions;
  22853. component.subbands = subbands;
  22854. }
  22855. const progressionOrder = tile.codingStyleDefaultParameters.progressionOrder;
  22856. switch (progressionOrder) {
  22857. case 0:
  22858. tile.packetsIterator = new LayerResolutionComponentPositionIterator(context);
  22859. break;
  22860. case 1:
  22861. tile.packetsIterator = new ResolutionLayerComponentPositionIterator(context);
  22862. break;
  22863. case 2:
  22864. tile.packetsIterator = new ResolutionPositionComponentLayerIterator(context);
  22865. break;
  22866. case 3:
  22867. tile.packetsIterator = new PositionComponentResolutionLayerIterator(context);
  22868. break;
  22869. case 4:
  22870. tile.packetsIterator = new ComponentPositionResolutionLayerIterator(context);
  22871. break;
  22872. default:
  22873. throw new JpxError(`Unsupported progression order ${progressionOrder}`);
  22874. }
  22875. }
  22876. function parseTilePackets(context, data, offset, dataLength) {
  22877. let position = 0;
  22878. let buffer,
  22879. bufferSize = 0,
  22880. skipNextBit = false;
  22881. function readBits(count) {
  22882. while (bufferSize < count) {
  22883. const b = data[offset + position];
  22884. position++;
  22885. if (skipNextBit) {
  22886. buffer = buffer << 7 | b;
  22887. bufferSize += 7;
  22888. skipNextBit = false;
  22889. } else {
  22890. buffer = buffer << 8 | b;
  22891. bufferSize += 8;
  22892. }
  22893. if (b === 0xff) {
  22894. skipNextBit = true;
  22895. }
  22896. }
  22897. bufferSize -= count;
  22898. return buffer >>> bufferSize & (1 << count) - 1;
  22899. }
  22900. function skipMarkerIfEqual(value) {
  22901. if (data[offset + position - 1] === 0xff && data[offset + position] === value) {
  22902. skipBytes(1);
  22903. return true;
  22904. } else if (data[offset + position] === 0xff && data[offset + position + 1] === value) {
  22905. skipBytes(2);
  22906. return true;
  22907. }
  22908. return false;
  22909. }
  22910. function skipBytes(count) {
  22911. position += count;
  22912. }
  22913. function alignToByte() {
  22914. bufferSize = 0;
  22915. if (skipNextBit) {
  22916. position++;
  22917. skipNextBit = false;
  22918. }
  22919. }
  22920. function readCodingpasses() {
  22921. if (readBits(1) === 0) {
  22922. return 1;
  22923. }
  22924. if (readBits(1) === 0) {
  22925. return 2;
  22926. }
  22927. let value = readBits(2);
  22928. if (value < 3) {
  22929. return value + 3;
  22930. }
  22931. value = readBits(5);
  22932. if (value < 31) {
  22933. return value + 6;
  22934. }
  22935. value = readBits(7);
  22936. return value + 37;
  22937. }
  22938. const tileIndex = context.currentTile.index;
  22939. const tile = context.tiles[tileIndex];
  22940. const sopMarkerUsed = context.COD.sopMarkerUsed;
  22941. const ephMarkerUsed = context.COD.ephMarkerUsed;
  22942. const packetsIterator = tile.packetsIterator;
  22943. while (position < dataLength) {
  22944. alignToByte();
  22945. if (sopMarkerUsed && skipMarkerIfEqual(0x91)) {
  22946. skipBytes(4);
  22947. }
  22948. const packet = packetsIterator.nextPacket();
  22949. if (!readBits(1)) {
  22950. continue;
  22951. }
  22952. const layerNumber = packet.layerNumber,
  22953. queue = [];
  22954. let codeblock;
  22955. for (let i = 0, ii = packet.codeblocks.length; i < ii; i++) {
  22956. codeblock = packet.codeblocks[i];
  22957. let precinct = codeblock.precinct;
  22958. const codeblockColumn = codeblock.cbx - precinct.cbxMin;
  22959. const codeblockRow = codeblock.cby - precinct.cbyMin;
  22960. let codeblockIncluded = false;
  22961. let firstTimeInclusion = false;
  22962. let valueReady, zeroBitPlanesTree;
  22963. if (codeblock.included !== undefined) {
  22964. codeblockIncluded = !!readBits(1);
  22965. } else {
  22966. precinct = codeblock.precinct;
  22967. let inclusionTree;
  22968. if (precinct.inclusionTree !== undefined) {
  22969. inclusionTree = precinct.inclusionTree;
  22970. } else {
  22971. const width = precinct.cbxMax - precinct.cbxMin + 1;
  22972. const height = precinct.cbyMax - precinct.cbyMin + 1;
  22973. inclusionTree = new InclusionTree(width, height, layerNumber);
  22974. zeroBitPlanesTree = new TagTree(width, height);
  22975. precinct.inclusionTree = inclusionTree;
  22976. precinct.zeroBitPlanesTree = zeroBitPlanesTree;
  22977. for (let l = 0; l < layerNumber; l++) {
  22978. if (readBits(1) !== 0) {
  22979. throw new JpxError("Invalid tag tree");
  22980. }
  22981. }
  22982. }
  22983. if (inclusionTree.reset(codeblockColumn, codeblockRow, layerNumber)) {
  22984. while (true) {
  22985. if (readBits(1)) {
  22986. valueReady = !inclusionTree.nextLevel();
  22987. if (valueReady) {
  22988. codeblock.included = true;
  22989. codeblockIncluded = firstTimeInclusion = true;
  22990. break;
  22991. }
  22992. } else {
  22993. inclusionTree.incrementValue(layerNumber);
  22994. break;
  22995. }
  22996. }
  22997. }
  22998. }
  22999. if (!codeblockIncluded) {
  23000. continue;
  23001. }
  23002. if (firstTimeInclusion) {
  23003. zeroBitPlanesTree = precinct.zeroBitPlanesTree;
  23004. zeroBitPlanesTree.reset(codeblockColumn, codeblockRow);
  23005. while (true) {
  23006. if (readBits(1)) {
  23007. valueReady = !zeroBitPlanesTree.nextLevel();
  23008. if (valueReady) {
  23009. break;
  23010. }
  23011. } else {
  23012. zeroBitPlanesTree.incrementValue();
  23013. }
  23014. }
  23015. codeblock.zeroBitPlanes = zeroBitPlanesTree.value;
  23016. }
  23017. const codingpasses = readCodingpasses();
  23018. while (readBits(1)) {
  23019. codeblock.Lblock++;
  23020. }
  23021. const codingpassesLog2 = (0, _core_utils.log2)(codingpasses);
  23022. const bits = (codingpasses < 1 << codingpassesLog2 ? codingpassesLog2 - 1 : codingpassesLog2) + codeblock.Lblock;
  23023. const codedDataLength = readBits(bits);
  23024. queue.push({
  23025. codeblock,
  23026. codingpasses,
  23027. dataLength: codedDataLength
  23028. });
  23029. }
  23030. alignToByte();
  23031. if (ephMarkerUsed) {
  23032. skipMarkerIfEqual(0x92);
  23033. }
  23034. while (queue.length > 0) {
  23035. const packetItem = queue.shift();
  23036. codeblock = packetItem.codeblock;
  23037. if (codeblock.data === undefined) {
  23038. codeblock.data = [];
  23039. }
  23040. codeblock.data.push({
  23041. data,
  23042. start: offset + position,
  23043. end: offset + position + packetItem.dataLength,
  23044. codingpasses: packetItem.codingpasses
  23045. });
  23046. position += packetItem.dataLength;
  23047. }
  23048. }
  23049. return position;
  23050. }
  23051. function copyCoefficients(coefficients, levelWidth, levelHeight, subband, delta, mb, reversible, segmentationSymbolUsed, resetContextProbabilities) {
  23052. const x0 = subband.tbx0;
  23053. const y0 = subband.tby0;
  23054. const width = subband.tbx1 - subband.tbx0;
  23055. const codeblocks = subband.codeblocks;
  23056. const right = subband.type.charAt(0) === "H" ? 1 : 0;
  23057. const bottom = subband.type.charAt(1) === "H" ? levelWidth : 0;
  23058. for (let i = 0, ii = codeblocks.length; i < ii; ++i) {
  23059. const codeblock = codeblocks[i];
  23060. const blockWidth = codeblock.tbx1_ - codeblock.tbx0_;
  23061. const blockHeight = codeblock.tby1_ - codeblock.tby0_;
  23062. if (blockWidth === 0 || blockHeight === 0) {
  23063. continue;
  23064. }
  23065. if (codeblock.data === undefined) {
  23066. continue;
  23067. }
  23068. const bitModel = new BitModel(blockWidth, blockHeight, codeblock.subbandType, codeblock.zeroBitPlanes, mb);
  23069. let currentCodingpassType = 2;
  23070. const data = codeblock.data;
  23071. let totalLength = 0,
  23072. codingpasses = 0;
  23073. let j, jj, dataItem;
  23074. for (j = 0, jj = data.length; j < jj; j++) {
  23075. dataItem = data[j];
  23076. totalLength += dataItem.end - dataItem.start;
  23077. codingpasses += dataItem.codingpasses;
  23078. }
  23079. const encodedData = new Uint8Array(totalLength);
  23080. let position = 0;
  23081. for (j = 0, jj = data.length; j < jj; j++) {
  23082. dataItem = data[j];
  23083. const chunk = dataItem.data.subarray(dataItem.start, dataItem.end);
  23084. encodedData.set(chunk, position);
  23085. position += chunk.length;
  23086. }
  23087. const decoder = new _arithmetic_decoder.ArithmeticDecoder(encodedData, 0, totalLength);
  23088. bitModel.setDecoder(decoder);
  23089. for (j = 0; j < codingpasses; j++) {
  23090. switch (currentCodingpassType) {
  23091. case 0:
  23092. bitModel.runSignificancePropagationPass();
  23093. break;
  23094. case 1:
  23095. bitModel.runMagnitudeRefinementPass();
  23096. break;
  23097. case 2:
  23098. bitModel.runCleanupPass();
  23099. if (segmentationSymbolUsed) {
  23100. bitModel.checkSegmentationSymbol();
  23101. }
  23102. break;
  23103. }
  23104. if (resetContextProbabilities) {
  23105. bitModel.reset();
  23106. }
  23107. currentCodingpassType = (currentCodingpassType + 1) % 3;
  23108. }
  23109. let offset = codeblock.tbx0_ - x0 + (codeblock.tby0_ - y0) * width;
  23110. const sign = bitModel.coefficentsSign;
  23111. const magnitude = bitModel.coefficentsMagnitude;
  23112. const bitsDecoded = bitModel.bitsDecoded;
  23113. const magnitudeCorrection = reversible ? 0 : 0.5;
  23114. let k, n, nb;
  23115. position = 0;
  23116. const interleave = subband.type !== "LL";
  23117. for (j = 0; j < blockHeight; j++) {
  23118. const row = offset / width | 0;
  23119. const levelOffset = 2 * row * (levelWidth - width) + right + bottom;
  23120. for (k = 0; k < blockWidth; k++) {
  23121. n = magnitude[position];
  23122. if (n !== 0) {
  23123. n = (n + magnitudeCorrection) * delta;
  23124. if (sign[position] !== 0) {
  23125. n = -n;
  23126. }
  23127. nb = bitsDecoded[position];
  23128. const pos = interleave ? levelOffset + (offset << 1) : offset;
  23129. coefficients[pos] = reversible && nb >= mb ? n : n * (1 << mb - nb);
  23130. }
  23131. offset++;
  23132. position++;
  23133. }
  23134. offset += width - blockWidth;
  23135. }
  23136. }
  23137. }
  23138. function transformTile(context, tile, c) {
  23139. const component = tile.components[c];
  23140. const codingStyleParameters = component.codingStyleParameters;
  23141. const quantizationParameters = component.quantizationParameters;
  23142. const decompositionLevelsCount = codingStyleParameters.decompositionLevelsCount;
  23143. const spqcds = quantizationParameters.SPqcds;
  23144. const scalarExpounded = quantizationParameters.scalarExpounded;
  23145. const guardBits = quantizationParameters.guardBits;
  23146. const segmentationSymbolUsed = codingStyleParameters.segmentationSymbolUsed;
  23147. const resetContextProbabilities = codingStyleParameters.resetContextProbabilities;
  23148. const precision = context.components[c].precision;
  23149. const reversible = codingStyleParameters.reversibleTransformation;
  23150. const transform = reversible ? new ReversibleTransform() : new IrreversibleTransform();
  23151. const subbandCoefficients = [];
  23152. let b = 0;
  23153. for (let i = 0; i <= decompositionLevelsCount; i++) {
  23154. const resolution = component.resolutions[i];
  23155. const width = resolution.trx1 - resolution.trx0;
  23156. const height = resolution.try1 - resolution.try0;
  23157. const coefficients = new Float32Array(width * height);
  23158. for (let j = 0, jj = resolution.subbands.length; j < jj; j++) {
  23159. let mu, epsilon;
  23160. if (!scalarExpounded) {
  23161. mu = spqcds[0].mu;
  23162. epsilon = spqcds[0].epsilon + (i > 0 ? 1 - i : 0);
  23163. } else {
  23164. mu = spqcds[b].mu;
  23165. epsilon = spqcds[b].epsilon;
  23166. b++;
  23167. }
  23168. const subband = resolution.subbands[j];
  23169. const gainLog2 = SubbandsGainLog2[subband.type];
  23170. const delta = reversible ? 1 : 2 ** (precision + gainLog2 - epsilon) * (1 + mu / 2048);
  23171. const mb = guardBits + epsilon - 1;
  23172. copyCoefficients(coefficients, width, height, subband, delta, mb, reversible, segmentationSymbolUsed, resetContextProbabilities);
  23173. }
  23174. subbandCoefficients.push({
  23175. width,
  23176. height,
  23177. items: coefficients
  23178. });
  23179. }
  23180. const result = transform.calculate(subbandCoefficients, component.tcx0, component.tcy0);
  23181. return {
  23182. left: component.tcx0,
  23183. top: component.tcy0,
  23184. width: result.width,
  23185. height: result.height,
  23186. items: result.items
  23187. };
  23188. }
  23189. function transformComponents(context) {
  23190. const siz = context.SIZ;
  23191. const components = context.components;
  23192. const componentsCount = siz.Csiz;
  23193. const resultImages = [];
  23194. for (let i = 0, ii = context.tiles.length; i < ii; i++) {
  23195. const tile = context.tiles[i];
  23196. const transformedTiles = [];
  23197. for (let c = 0; c < componentsCount; c++) {
  23198. transformedTiles[c] = transformTile(context, tile, c);
  23199. }
  23200. const tile0 = transformedTiles[0];
  23201. const out = new Uint8ClampedArray(tile0.items.length * componentsCount);
  23202. const result = {
  23203. left: tile0.left,
  23204. top: tile0.top,
  23205. width: tile0.width,
  23206. height: tile0.height,
  23207. items: out
  23208. };
  23209. let shift, offset;
  23210. let pos = 0,
  23211. j,
  23212. jj,
  23213. y0,
  23214. y1,
  23215. y2;
  23216. if (tile.codingStyleDefaultParameters.multipleComponentTransform) {
  23217. const fourComponents = componentsCount === 4;
  23218. const y0items = transformedTiles[0].items;
  23219. const y1items = transformedTiles[1].items;
  23220. const y2items = transformedTiles[2].items;
  23221. const y3items = fourComponents ? transformedTiles[3].items : null;
  23222. shift = components[0].precision - 8;
  23223. offset = (128 << shift) + 0.5;
  23224. const component0 = tile.components[0];
  23225. const alpha01 = componentsCount - 3;
  23226. jj = y0items.length;
  23227. if (!component0.codingStyleParameters.reversibleTransformation) {
  23228. for (j = 0; j < jj; j++, pos += alpha01) {
  23229. y0 = y0items[j] + offset;
  23230. y1 = y1items[j];
  23231. y2 = y2items[j];
  23232. out[pos++] = y0 + 1.402 * y2 >> shift;
  23233. out[pos++] = y0 - 0.34413 * y1 - 0.71414 * y2 >> shift;
  23234. out[pos++] = y0 + 1.772 * y1 >> shift;
  23235. }
  23236. } else {
  23237. for (j = 0; j < jj; j++, pos += alpha01) {
  23238. y0 = y0items[j] + offset;
  23239. y1 = y1items[j];
  23240. y2 = y2items[j];
  23241. const g = y0 - (y2 + y1 >> 2);
  23242. out[pos++] = g + y2 >> shift;
  23243. out[pos++] = g >> shift;
  23244. out[pos++] = g + y1 >> shift;
  23245. }
  23246. }
  23247. if (fourComponents) {
  23248. for (j = 0, pos = 3; j < jj; j++, pos += 4) {
  23249. out[pos] = y3items[j] + offset >> shift;
  23250. }
  23251. }
  23252. } else {
  23253. for (let c = 0; c < componentsCount; c++) {
  23254. const items = transformedTiles[c].items;
  23255. shift = components[c].precision - 8;
  23256. offset = (128 << shift) + 0.5;
  23257. for (pos = c, j = 0, jj = items.length; j < jj; j++) {
  23258. out[pos] = items[j] + offset >> shift;
  23259. pos += componentsCount;
  23260. }
  23261. }
  23262. }
  23263. resultImages.push(result);
  23264. }
  23265. return resultImages;
  23266. }
  23267. function initializeTile(context, tileIndex) {
  23268. const siz = context.SIZ;
  23269. const componentsCount = siz.Csiz;
  23270. const tile = context.tiles[tileIndex];
  23271. for (let c = 0; c < componentsCount; c++) {
  23272. const component = tile.components[c];
  23273. const qcdOrQcc = context.currentTile.QCC[c] !== undefined ? context.currentTile.QCC[c] : context.currentTile.QCD;
  23274. component.quantizationParameters = qcdOrQcc;
  23275. const codOrCoc = context.currentTile.COC[c] !== undefined ? context.currentTile.COC[c] : context.currentTile.COD;
  23276. component.codingStyleParameters = codOrCoc;
  23277. }
  23278. tile.codingStyleDefaultParameters = context.currentTile.COD;
  23279. }
  23280. class TagTree {
  23281. constructor(width, height) {
  23282. const levelsLength = (0, _core_utils.log2)(Math.max(width, height)) + 1;
  23283. this.levels = [];
  23284. for (let i = 0; i < levelsLength; i++) {
  23285. const level = {
  23286. width,
  23287. height,
  23288. items: []
  23289. };
  23290. this.levels.push(level);
  23291. width = Math.ceil(width / 2);
  23292. height = Math.ceil(height / 2);
  23293. }
  23294. }
  23295. reset(i, j) {
  23296. let currentLevel = 0,
  23297. value = 0,
  23298. level;
  23299. while (currentLevel < this.levels.length) {
  23300. level = this.levels[currentLevel];
  23301. const index = i + j * level.width;
  23302. if (level.items[index] !== undefined) {
  23303. value = level.items[index];
  23304. break;
  23305. }
  23306. level.index = index;
  23307. i >>= 1;
  23308. j >>= 1;
  23309. currentLevel++;
  23310. }
  23311. currentLevel--;
  23312. level = this.levels[currentLevel];
  23313. level.items[level.index] = value;
  23314. this.currentLevel = currentLevel;
  23315. delete this.value;
  23316. }
  23317. incrementValue() {
  23318. const level = this.levels[this.currentLevel];
  23319. level.items[level.index]++;
  23320. }
  23321. nextLevel() {
  23322. let currentLevel = this.currentLevel;
  23323. let level = this.levels[currentLevel];
  23324. const value = level.items[level.index];
  23325. currentLevel--;
  23326. if (currentLevel < 0) {
  23327. this.value = value;
  23328. return false;
  23329. }
  23330. this.currentLevel = currentLevel;
  23331. level = this.levels[currentLevel];
  23332. level.items[level.index] = value;
  23333. return true;
  23334. }
  23335. }
  23336. class InclusionTree {
  23337. constructor(width, height, defaultValue) {
  23338. const levelsLength = (0, _core_utils.log2)(Math.max(width, height)) + 1;
  23339. this.levels = [];
  23340. for (let i = 0; i < levelsLength; i++) {
  23341. const items = new Uint8Array(width * height);
  23342. for (let j = 0, jj = items.length; j < jj; j++) {
  23343. items[j] = defaultValue;
  23344. }
  23345. const level = {
  23346. width,
  23347. height,
  23348. items
  23349. };
  23350. this.levels.push(level);
  23351. width = Math.ceil(width / 2);
  23352. height = Math.ceil(height / 2);
  23353. }
  23354. }
  23355. reset(i, j, stopValue) {
  23356. let currentLevel = 0;
  23357. while (currentLevel < this.levels.length) {
  23358. const level = this.levels[currentLevel];
  23359. const index = i + j * level.width;
  23360. level.index = index;
  23361. const value = level.items[index];
  23362. if (value === 0xff) {
  23363. break;
  23364. }
  23365. if (value > stopValue) {
  23366. this.currentLevel = currentLevel;
  23367. this.propagateValues();
  23368. return false;
  23369. }
  23370. i >>= 1;
  23371. j >>= 1;
  23372. currentLevel++;
  23373. }
  23374. this.currentLevel = currentLevel - 1;
  23375. return true;
  23376. }
  23377. incrementValue(stopValue) {
  23378. const level = this.levels[this.currentLevel];
  23379. level.items[level.index] = stopValue + 1;
  23380. this.propagateValues();
  23381. }
  23382. propagateValues() {
  23383. let levelIndex = this.currentLevel;
  23384. let level = this.levels[levelIndex];
  23385. const currentValue = level.items[level.index];
  23386. while (--levelIndex >= 0) {
  23387. level = this.levels[levelIndex];
  23388. level.items[level.index] = currentValue;
  23389. }
  23390. }
  23391. nextLevel() {
  23392. let currentLevel = this.currentLevel;
  23393. let level = this.levels[currentLevel];
  23394. const value = level.items[level.index];
  23395. level.items[level.index] = 0xff;
  23396. currentLevel--;
  23397. if (currentLevel < 0) {
  23398. return false;
  23399. }
  23400. this.currentLevel = currentLevel;
  23401. level = this.levels[currentLevel];
  23402. level.items[level.index] = value;
  23403. return true;
  23404. }
  23405. }
  23406. class BitModel {
  23407. static UNIFORM_CONTEXT = 17;
  23408. static RUNLENGTH_CONTEXT = 18;
  23409. 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]);
  23410. 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]);
  23411. 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]);
  23412. constructor(width, height, subband, zeroBitPlanes, mb) {
  23413. this.width = width;
  23414. this.height = height;
  23415. let contextLabelTable;
  23416. if (subband === "HH") {
  23417. contextLabelTable = BitModel.HHContextLabel;
  23418. } else if (subband === "HL") {
  23419. contextLabelTable = BitModel.HLContextLabel;
  23420. } else {
  23421. contextLabelTable = BitModel.LLAndLHContextsLabel;
  23422. }
  23423. this.contextLabelTable = contextLabelTable;
  23424. const coefficientCount = width * height;
  23425. this.neighborsSignificance = new Uint8Array(coefficientCount);
  23426. this.coefficentsSign = new Uint8Array(coefficientCount);
  23427. let coefficentsMagnitude;
  23428. if (mb > 14) {
  23429. coefficentsMagnitude = new Uint32Array(coefficientCount);
  23430. } else if (mb > 6) {
  23431. coefficentsMagnitude = new Uint16Array(coefficientCount);
  23432. } else {
  23433. coefficentsMagnitude = new Uint8Array(coefficientCount);
  23434. }
  23435. this.coefficentsMagnitude = coefficentsMagnitude;
  23436. this.processingFlags = new Uint8Array(coefficientCount);
  23437. const bitsDecoded = new Uint8Array(coefficientCount);
  23438. if (zeroBitPlanes !== 0) {
  23439. for (let i = 0; i < coefficientCount; i++) {
  23440. bitsDecoded[i] = zeroBitPlanes;
  23441. }
  23442. }
  23443. this.bitsDecoded = bitsDecoded;
  23444. this.reset();
  23445. }
  23446. setDecoder(decoder) {
  23447. this.decoder = decoder;
  23448. }
  23449. reset() {
  23450. this.contexts = new Int8Array(19);
  23451. this.contexts[0] = 4 << 1 | 0;
  23452. this.contexts[BitModel.UNIFORM_CONTEXT] = 46 << 1 | 0;
  23453. this.contexts[BitModel.RUNLENGTH_CONTEXT] = 3 << 1 | 0;
  23454. }
  23455. setNeighborsSignificance(row, column, index) {
  23456. const neighborsSignificance = this.neighborsSignificance;
  23457. const width = this.width,
  23458. height = this.height;
  23459. const left = column > 0;
  23460. const right = column + 1 < width;
  23461. let i;
  23462. if (row > 0) {
  23463. i = index - width;
  23464. if (left) {
  23465. neighborsSignificance[i - 1] += 0x10;
  23466. }
  23467. if (right) {
  23468. neighborsSignificance[i + 1] += 0x10;
  23469. }
  23470. neighborsSignificance[i] += 0x04;
  23471. }
  23472. if (row + 1 < height) {
  23473. i = index + width;
  23474. if (left) {
  23475. neighborsSignificance[i - 1] += 0x10;
  23476. }
  23477. if (right) {
  23478. neighborsSignificance[i + 1] += 0x10;
  23479. }
  23480. neighborsSignificance[i] += 0x04;
  23481. }
  23482. if (left) {
  23483. neighborsSignificance[index - 1] += 0x01;
  23484. }
  23485. if (right) {
  23486. neighborsSignificance[index + 1] += 0x01;
  23487. }
  23488. neighborsSignificance[index] |= 0x80;
  23489. }
  23490. runSignificancePropagationPass() {
  23491. const decoder = this.decoder;
  23492. const width = this.width,
  23493. height = this.height;
  23494. const coefficentsMagnitude = this.coefficentsMagnitude;
  23495. const coefficentsSign = this.coefficentsSign;
  23496. const neighborsSignificance = this.neighborsSignificance;
  23497. const processingFlags = this.processingFlags;
  23498. const contexts = this.contexts;
  23499. const labels = this.contextLabelTable;
  23500. const bitsDecoded = this.bitsDecoded;
  23501. const processedInverseMask = ~1;
  23502. const processedMask = 1;
  23503. const firstMagnitudeBitMask = 2;
  23504. for (let i0 = 0; i0 < height; i0 += 4) {
  23505. for (let j = 0; j < width; j++) {
  23506. let index = i0 * width + j;
  23507. for (let i1 = 0; i1 < 4; i1++, index += width) {
  23508. const i = i0 + i1;
  23509. if (i >= height) {
  23510. break;
  23511. }
  23512. processingFlags[index] &= processedInverseMask;
  23513. if (coefficentsMagnitude[index] || !neighborsSignificance[index]) {
  23514. continue;
  23515. }
  23516. const contextLabel = labels[neighborsSignificance[index]];
  23517. const decision = decoder.readBit(contexts, contextLabel);
  23518. if (decision) {
  23519. const sign = this.decodeSignBit(i, j, index);
  23520. coefficentsSign[index] = sign;
  23521. coefficentsMagnitude[index] = 1;
  23522. this.setNeighborsSignificance(i, j, index);
  23523. processingFlags[index] |= firstMagnitudeBitMask;
  23524. }
  23525. bitsDecoded[index]++;
  23526. processingFlags[index] |= processedMask;
  23527. }
  23528. }
  23529. }
  23530. }
  23531. decodeSignBit(row, column, index) {
  23532. const width = this.width,
  23533. height = this.height;
  23534. const coefficentsMagnitude = this.coefficentsMagnitude;
  23535. const coefficentsSign = this.coefficentsSign;
  23536. let contribution, sign0, sign1, significance1;
  23537. let contextLabel, decoded;
  23538. significance1 = column > 0 && coefficentsMagnitude[index - 1] !== 0;
  23539. if (column + 1 < width && coefficentsMagnitude[index + 1] !== 0) {
  23540. sign1 = coefficentsSign[index + 1];
  23541. if (significance1) {
  23542. sign0 = coefficentsSign[index - 1];
  23543. contribution = 1 - sign1 - sign0;
  23544. } else {
  23545. contribution = 1 - sign1 - sign1;
  23546. }
  23547. } else if (significance1) {
  23548. sign0 = coefficentsSign[index - 1];
  23549. contribution = 1 - sign0 - sign0;
  23550. } else {
  23551. contribution = 0;
  23552. }
  23553. const horizontalContribution = 3 * contribution;
  23554. significance1 = row > 0 && coefficentsMagnitude[index - width] !== 0;
  23555. if (row + 1 < height && coefficentsMagnitude[index + width] !== 0) {
  23556. sign1 = coefficentsSign[index + width];
  23557. if (significance1) {
  23558. sign0 = coefficentsSign[index - width];
  23559. contribution = 1 - sign1 - sign0 + horizontalContribution;
  23560. } else {
  23561. contribution = 1 - sign1 - sign1 + horizontalContribution;
  23562. }
  23563. } else if (significance1) {
  23564. sign0 = coefficentsSign[index - width];
  23565. contribution = 1 - sign0 - sign0 + horizontalContribution;
  23566. } else {
  23567. contribution = horizontalContribution;
  23568. }
  23569. if (contribution >= 0) {
  23570. contextLabel = 9 + contribution;
  23571. decoded = this.decoder.readBit(this.contexts, contextLabel);
  23572. } else {
  23573. contextLabel = 9 - contribution;
  23574. decoded = this.decoder.readBit(this.contexts, contextLabel) ^ 1;
  23575. }
  23576. return decoded;
  23577. }
  23578. runMagnitudeRefinementPass() {
  23579. const decoder = this.decoder;
  23580. const width = this.width,
  23581. height = this.height;
  23582. const coefficentsMagnitude = this.coefficentsMagnitude;
  23583. const neighborsSignificance = this.neighborsSignificance;
  23584. const contexts = this.contexts;
  23585. const bitsDecoded = this.bitsDecoded;
  23586. const processingFlags = this.processingFlags;
  23587. const processedMask = 1;
  23588. const firstMagnitudeBitMask = 2;
  23589. const length = width * height;
  23590. const width4 = width * 4;
  23591. for (let index0 = 0, indexNext; index0 < length; index0 = indexNext) {
  23592. indexNext = Math.min(length, index0 + width4);
  23593. for (let j = 0; j < width; j++) {
  23594. for (let index = index0 + j; index < indexNext; index += width) {
  23595. if (!coefficentsMagnitude[index] || (processingFlags[index] & processedMask) !== 0) {
  23596. continue;
  23597. }
  23598. let contextLabel = 16;
  23599. if ((processingFlags[index] & firstMagnitudeBitMask) !== 0) {
  23600. processingFlags[index] ^= firstMagnitudeBitMask;
  23601. const significance = neighborsSignificance[index] & 127;
  23602. contextLabel = significance === 0 ? 15 : 14;
  23603. }
  23604. const bit = decoder.readBit(contexts, contextLabel);
  23605. coefficentsMagnitude[index] = coefficentsMagnitude[index] << 1 | bit;
  23606. bitsDecoded[index]++;
  23607. processingFlags[index] |= processedMask;
  23608. }
  23609. }
  23610. }
  23611. }
  23612. runCleanupPass() {
  23613. const decoder = this.decoder;
  23614. const width = this.width,
  23615. height = this.height;
  23616. const neighborsSignificance = this.neighborsSignificance;
  23617. const coefficentsMagnitude = this.coefficentsMagnitude;
  23618. const coefficentsSign = this.coefficentsSign;
  23619. const contexts = this.contexts;
  23620. const labels = this.contextLabelTable;
  23621. const bitsDecoded = this.bitsDecoded;
  23622. const processingFlags = this.processingFlags;
  23623. const processedMask = 1;
  23624. const firstMagnitudeBitMask = 2;
  23625. const oneRowDown = width;
  23626. const twoRowsDown = width * 2;
  23627. const threeRowsDown = width * 3;
  23628. let iNext;
  23629. for (let i0 = 0; i0 < height; i0 = iNext) {
  23630. iNext = Math.min(i0 + 4, height);
  23631. const indexBase = i0 * width;
  23632. const checkAllEmpty = i0 + 3 < height;
  23633. for (let j = 0; j < width; j++) {
  23634. const index0 = indexBase + j;
  23635. 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;
  23636. let i1 = 0,
  23637. index = index0;
  23638. let i = i0,
  23639. sign;
  23640. if (allEmpty) {
  23641. const hasSignificantCoefficent = decoder.readBit(contexts, BitModel.RUNLENGTH_CONTEXT);
  23642. if (!hasSignificantCoefficent) {
  23643. bitsDecoded[index0]++;
  23644. bitsDecoded[index0 + oneRowDown]++;
  23645. bitsDecoded[index0 + twoRowsDown]++;
  23646. bitsDecoded[index0 + threeRowsDown]++;
  23647. continue;
  23648. }
  23649. i1 = decoder.readBit(contexts, BitModel.UNIFORM_CONTEXT) << 1 | decoder.readBit(contexts, BitModel.UNIFORM_CONTEXT);
  23650. if (i1 !== 0) {
  23651. i = i0 + i1;
  23652. index += i1 * width;
  23653. }
  23654. sign = this.decodeSignBit(i, j, index);
  23655. coefficentsSign[index] = sign;
  23656. coefficentsMagnitude[index] = 1;
  23657. this.setNeighborsSignificance(i, j, index);
  23658. processingFlags[index] |= firstMagnitudeBitMask;
  23659. index = index0;
  23660. for (let i2 = i0; i2 <= i; i2++, index += width) {
  23661. bitsDecoded[index]++;
  23662. }
  23663. i1++;
  23664. }
  23665. for (i = i0 + i1; i < iNext; i++, index += width) {
  23666. if (coefficentsMagnitude[index] || (processingFlags[index] & processedMask) !== 0) {
  23667. continue;
  23668. }
  23669. const contextLabel = labels[neighborsSignificance[index]];
  23670. const decision = decoder.readBit(contexts, contextLabel);
  23671. if (decision === 1) {
  23672. sign = this.decodeSignBit(i, j, index);
  23673. coefficentsSign[index] = sign;
  23674. coefficentsMagnitude[index] = 1;
  23675. this.setNeighborsSignificance(i, j, index);
  23676. processingFlags[index] |= firstMagnitudeBitMask;
  23677. }
  23678. bitsDecoded[index]++;
  23679. }
  23680. }
  23681. }
  23682. }
  23683. checkSegmentationSymbol() {
  23684. const decoder = this.decoder;
  23685. const contexts = this.contexts;
  23686. 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);
  23687. if (symbol !== 0xa) {
  23688. throw new JpxError("Invalid segmentation symbol");
  23689. }
  23690. }
  23691. }
  23692. class Transform {
  23693. constructor() {
  23694. if (this.constructor === Transform) {
  23695. (0, _util.unreachable)("Cannot initialize Transform.");
  23696. }
  23697. }
  23698. calculate(subbands, u0, v0) {
  23699. let ll = subbands[0];
  23700. for (let i = 1, ii = subbands.length; i < ii; i++) {
  23701. ll = this.iterate(ll, subbands[i], u0, v0);
  23702. }
  23703. return ll;
  23704. }
  23705. extend(buffer, offset, size) {
  23706. let i1 = offset - 1,
  23707. j1 = offset + 1;
  23708. let i2 = offset + size - 2,
  23709. j2 = offset + size;
  23710. buffer[i1--] = buffer[j1++];
  23711. buffer[j2++] = buffer[i2--];
  23712. buffer[i1--] = buffer[j1++];
  23713. buffer[j2++] = buffer[i2--];
  23714. buffer[i1--] = buffer[j1++];
  23715. buffer[j2++] = buffer[i2--];
  23716. buffer[i1] = buffer[j1];
  23717. buffer[j2] = buffer[i2];
  23718. }
  23719. filter(x, offset, length) {
  23720. (0, _util.unreachable)("Abstract method `filter` called");
  23721. }
  23722. iterate(ll, hl_lh_hh, u0, v0) {
  23723. const llWidth = ll.width,
  23724. llHeight = ll.height;
  23725. let llItems = ll.items;
  23726. const width = hl_lh_hh.width;
  23727. const height = hl_lh_hh.height;
  23728. const items = hl_lh_hh.items;
  23729. let i, j, k, l, u, v;
  23730. for (k = 0, i = 0; i < llHeight; i++) {
  23731. l = i * 2 * width;
  23732. for (j = 0; j < llWidth; j++, k++, l += 2) {
  23733. items[l] = llItems[k];
  23734. }
  23735. }
  23736. llItems = ll.items = null;
  23737. const bufferPadding = 4;
  23738. const rowBuffer = new Float32Array(width + 2 * bufferPadding);
  23739. if (width === 1) {
  23740. if ((u0 & 1) !== 0) {
  23741. for (v = 0, k = 0; v < height; v++, k += width) {
  23742. items[k] *= 0.5;
  23743. }
  23744. }
  23745. } else {
  23746. for (v = 0, k = 0; v < height; v++, k += width) {
  23747. rowBuffer.set(items.subarray(k, k + width), bufferPadding);
  23748. this.extend(rowBuffer, bufferPadding, width);
  23749. this.filter(rowBuffer, bufferPadding, width);
  23750. items.set(rowBuffer.subarray(bufferPadding, bufferPadding + width), k);
  23751. }
  23752. }
  23753. let numBuffers = 16;
  23754. const colBuffers = [];
  23755. for (i = 0; i < numBuffers; i++) {
  23756. colBuffers.push(new Float32Array(height + 2 * bufferPadding));
  23757. }
  23758. let b,
  23759. currentBuffer = 0;
  23760. ll = bufferPadding + height;
  23761. if (height === 1) {
  23762. if ((v0 & 1) !== 0) {
  23763. for (u = 0; u < width; u++) {
  23764. items[u] *= 0.5;
  23765. }
  23766. }
  23767. } else {
  23768. for (u = 0; u < width; u++) {
  23769. if (currentBuffer === 0) {
  23770. numBuffers = Math.min(width - u, numBuffers);
  23771. for (k = u, l = bufferPadding; l < ll; k += width, l++) {
  23772. for (b = 0; b < numBuffers; b++) {
  23773. colBuffers[b][l] = items[k + b];
  23774. }
  23775. }
  23776. currentBuffer = numBuffers;
  23777. }
  23778. currentBuffer--;
  23779. const buffer = colBuffers[currentBuffer];
  23780. this.extend(buffer, bufferPadding, height);
  23781. this.filter(buffer, bufferPadding, height);
  23782. if (currentBuffer === 0) {
  23783. k = u - numBuffers + 1;
  23784. for (l = bufferPadding; l < ll; k += width, l++) {
  23785. for (b = 0; b < numBuffers; b++) {
  23786. items[k + b] = colBuffers[b][l];
  23787. }
  23788. }
  23789. }
  23790. }
  23791. }
  23792. return {
  23793. width,
  23794. height,
  23795. items
  23796. };
  23797. }
  23798. }
  23799. class IrreversibleTransform extends Transform {
  23800. filter(x, offset, length) {
  23801. const len = length >> 1;
  23802. offset |= 0;
  23803. let j, n, current, next;
  23804. const alpha = -1.586134342059924;
  23805. const beta = -0.052980118572961;
  23806. const gamma = 0.882911075530934;
  23807. const delta = 0.443506852043971;
  23808. const K = 1.230174104914001;
  23809. const K_ = 1 / K;
  23810. j = offset - 3;
  23811. for (n = len + 4; n--; j += 2) {
  23812. x[j] *= K_;
  23813. }
  23814. j = offset - 2;
  23815. current = delta * x[j - 1];
  23816. for (n = len + 3; n--; j += 2) {
  23817. next = delta * x[j + 1];
  23818. x[j] = K * x[j] - current - next;
  23819. if (n--) {
  23820. j += 2;
  23821. current = delta * x[j + 1];
  23822. x[j] = K * x[j] - current - next;
  23823. } else {
  23824. break;
  23825. }
  23826. }
  23827. j = offset - 1;
  23828. current = gamma * x[j - 1];
  23829. for (n = len + 2; n--; j += 2) {
  23830. next = gamma * x[j + 1];
  23831. x[j] -= current + next;
  23832. if (n--) {
  23833. j += 2;
  23834. current = gamma * x[j + 1];
  23835. x[j] -= current + next;
  23836. } else {
  23837. break;
  23838. }
  23839. }
  23840. j = offset;
  23841. current = beta * x[j - 1];
  23842. for (n = len + 1; n--; j += 2) {
  23843. next = beta * x[j + 1];
  23844. x[j] -= current + next;
  23845. if (n--) {
  23846. j += 2;
  23847. current = beta * x[j + 1];
  23848. x[j] -= current + next;
  23849. } else {
  23850. break;
  23851. }
  23852. }
  23853. if (len !== 0) {
  23854. j = offset + 1;
  23855. current = alpha * x[j - 1];
  23856. for (n = len; n--; j += 2) {
  23857. next = alpha * x[j + 1];
  23858. x[j] -= current + next;
  23859. if (n--) {
  23860. j += 2;
  23861. current = alpha * x[j + 1];
  23862. x[j] -= current + next;
  23863. } else {
  23864. break;
  23865. }
  23866. }
  23867. }
  23868. }
  23869. }
  23870. class ReversibleTransform extends Transform {
  23871. filter(x, offset, length) {
  23872. const len = length >> 1;
  23873. offset |= 0;
  23874. let j, n;
  23875. for (j = offset, n = len + 1; n--; j += 2) {
  23876. x[j] -= x[j - 1] + x[j + 1] + 2 >> 2;
  23877. }
  23878. for (j = offset + 1, n = len; n--; j += 2) {
  23879. x[j] += x[j - 1] + x[j + 1] >> 1;
  23880. }
  23881. }
  23882. }
  23883. /***/ }),
  23884. /* 182 */
  23885. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  23886. Object.defineProperty(exports, "__esModule", ({
  23887. value: true
  23888. }));
  23889. exports.LZWStream = void 0;
  23890. __w_pdfjs_require__(84);
  23891. __w_pdfjs_require__(93);
  23892. __w_pdfjs_require__(94);
  23893. __w_pdfjs_require__(97);
  23894. __w_pdfjs_require__(99);
  23895. __w_pdfjs_require__(101);
  23896. __w_pdfjs_require__(105);
  23897. __w_pdfjs_require__(108);
  23898. __w_pdfjs_require__(115);
  23899. var _decode_stream = __w_pdfjs_require__(169);
  23900. class LZWStream extends _decode_stream.DecodeStream {
  23901. constructor(str, maybeLength, earlyChange) {
  23902. super(maybeLength);
  23903. this.str = str;
  23904. this.dict = str.dict;
  23905. this.cachedData = 0;
  23906. this.bitsCached = 0;
  23907. const maxLzwDictionarySize = 4096;
  23908. const lzwState = {
  23909. earlyChange,
  23910. codeLength: 9,
  23911. nextCode: 258,
  23912. dictionaryValues: new Uint8Array(maxLzwDictionarySize),
  23913. dictionaryLengths: new Uint16Array(maxLzwDictionarySize),
  23914. dictionaryPrevCodes: new Uint16Array(maxLzwDictionarySize),
  23915. currentSequence: new Uint8Array(maxLzwDictionarySize),
  23916. currentSequenceLength: 0
  23917. };
  23918. for (let i = 0; i < 256; ++i) {
  23919. lzwState.dictionaryValues[i] = i;
  23920. lzwState.dictionaryLengths[i] = 1;
  23921. }
  23922. this.lzwState = lzwState;
  23923. }
  23924. readBits(n) {
  23925. let bitsCached = this.bitsCached;
  23926. let cachedData = this.cachedData;
  23927. while (bitsCached < n) {
  23928. const c = this.str.getByte();
  23929. if (c === -1) {
  23930. this.eof = true;
  23931. return null;
  23932. }
  23933. cachedData = cachedData << 8 | c;
  23934. bitsCached += 8;
  23935. }
  23936. this.bitsCached = bitsCached -= n;
  23937. this.cachedData = cachedData;
  23938. this.lastCode = null;
  23939. return cachedData >>> bitsCached & (1 << n) - 1;
  23940. }
  23941. readBlock() {
  23942. const blockSize = 512,
  23943. decodedSizeDelta = blockSize;
  23944. let estimatedDecodedSize = blockSize * 2;
  23945. let i, j, q;
  23946. const lzwState = this.lzwState;
  23947. if (!lzwState) {
  23948. return;
  23949. }
  23950. const earlyChange = lzwState.earlyChange;
  23951. let nextCode = lzwState.nextCode;
  23952. const dictionaryValues = lzwState.dictionaryValues;
  23953. const dictionaryLengths = lzwState.dictionaryLengths;
  23954. const dictionaryPrevCodes = lzwState.dictionaryPrevCodes;
  23955. let codeLength = lzwState.codeLength;
  23956. let prevCode = lzwState.prevCode;
  23957. const currentSequence = lzwState.currentSequence;
  23958. let currentSequenceLength = lzwState.currentSequenceLength;
  23959. let decodedLength = 0;
  23960. let currentBufferLength = this.bufferLength;
  23961. let buffer = this.ensureBuffer(this.bufferLength + estimatedDecodedSize);
  23962. for (i = 0; i < blockSize; i++) {
  23963. const code = this.readBits(codeLength);
  23964. const hasPrev = currentSequenceLength > 0;
  23965. if (code < 256) {
  23966. currentSequence[0] = code;
  23967. currentSequenceLength = 1;
  23968. } else if (code >= 258) {
  23969. if (code < nextCode) {
  23970. currentSequenceLength = dictionaryLengths[code];
  23971. for (j = currentSequenceLength - 1, q = code; j >= 0; j--) {
  23972. currentSequence[j] = dictionaryValues[q];
  23973. q = dictionaryPrevCodes[q];
  23974. }
  23975. } else {
  23976. currentSequence[currentSequenceLength++] = currentSequence[0];
  23977. }
  23978. } else if (code === 256) {
  23979. codeLength = 9;
  23980. nextCode = 258;
  23981. currentSequenceLength = 0;
  23982. continue;
  23983. } else {
  23984. this.eof = true;
  23985. delete this.lzwState;
  23986. break;
  23987. }
  23988. if (hasPrev) {
  23989. dictionaryPrevCodes[nextCode] = prevCode;
  23990. dictionaryLengths[nextCode] = dictionaryLengths[prevCode] + 1;
  23991. dictionaryValues[nextCode] = currentSequence[0];
  23992. nextCode++;
  23993. codeLength = nextCode + earlyChange & nextCode + earlyChange - 1 ? codeLength : Math.min(Math.log(nextCode + earlyChange) / 0.6931471805599453 + 1, 12) | 0;
  23994. }
  23995. prevCode = code;
  23996. decodedLength += currentSequenceLength;
  23997. if (estimatedDecodedSize < decodedLength) {
  23998. do {
  23999. estimatedDecodedSize += decodedSizeDelta;
  24000. } while (estimatedDecodedSize < decodedLength);
  24001. buffer = this.ensureBuffer(this.bufferLength + estimatedDecodedSize);
  24002. }
  24003. for (j = 0; j < currentSequenceLength; j++) {
  24004. buffer[currentBufferLength++] = currentSequence[j];
  24005. }
  24006. }
  24007. lzwState.nextCode = nextCode;
  24008. lzwState.codeLength = codeLength;
  24009. lzwState.prevCode = prevCode;
  24010. lzwState.currentSequenceLength = currentSequenceLength;
  24011. this.bufferLength = currentBufferLength;
  24012. }
  24013. }
  24014. exports.LZWStream = LZWStream;
  24015. /***/ }),
  24016. /* 183 */
  24017. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  24018. Object.defineProperty(exports, "__esModule", ({
  24019. value: true
  24020. }));
  24021. exports.PredictorStream = void 0;
  24022. __w_pdfjs_require__(84);
  24023. __w_pdfjs_require__(93);
  24024. __w_pdfjs_require__(94);
  24025. __w_pdfjs_require__(97);
  24026. __w_pdfjs_require__(99);
  24027. __w_pdfjs_require__(101);
  24028. __w_pdfjs_require__(105);
  24029. __w_pdfjs_require__(108);
  24030. __w_pdfjs_require__(115);
  24031. var _decode_stream = __w_pdfjs_require__(169);
  24032. var _primitives = __w_pdfjs_require__(151);
  24033. var _util = __w_pdfjs_require__(145);
  24034. class PredictorStream extends _decode_stream.DecodeStream {
  24035. constructor(str, maybeLength, params) {
  24036. super(maybeLength);
  24037. if (!(params instanceof _primitives.Dict)) {
  24038. return str;
  24039. }
  24040. const predictor = this.predictor = params.get("Predictor") || 1;
  24041. if (predictor <= 1) {
  24042. return str;
  24043. }
  24044. if (predictor !== 2 && (predictor < 10 || predictor > 15)) {
  24045. throw new _util.FormatError(`Unsupported predictor: ${predictor}`);
  24046. }
  24047. this.readBlock = predictor === 2 ? this.readBlockTiff : this.readBlockPng;
  24048. this.str = str;
  24049. this.dict = str.dict;
  24050. const colors = this.colors = params.get("Colors") || 1;
  24051. const bits = this.bits = params.get("BPC", "BitsPerComponent") || 8;
  24052. const columns = this.columns = params.get("Columns") || 1;
  24053. this.pixBytes = colors * bits + 7 >> 3;
  24054. this.rowBytes = columns * colors * bits + 7 >> 3;
  24055. return this;
  24056. }
  24057. readBlockTiff() {
  24058. const rowBytes = this.rowBytes;
  24059. const bufferLength = this.bufferLength;
  24060. const buffer = this.ensureBuffer(bufferLength + rowBytes);
  24061. const bits = this.bits;
  24062. const colors = this.colors;
  24063. const rawBytes = this.str.getBytes(rowBytes);
  24064. this.eof = !rawBytes.length;
  24065. if (this.eof) {
  24066. return;
  24067. }
  24068. let inbuf = 0,
  24069. outbuf = 0;
  24070. let inbits = 0,
  24071. outbits = 0;
  24072. let pos = bufferLength;
  24073. let i;
  24074. if (bits === 1 && colors === 1) {
  24075. for (i = 0; i < rowBytes; ++i) {
  24076. let c = rawBytes[i] ^ inbuf;
  24077. c ^= c >> 1;
  24078. c ^= c >> 2;
  24079. c ^= c >> 4;
  24080. inbuf = (c & 1) << 7;
  24081. buffer[pos++] = c;
  24082. }
  24083. } else if (bits === 8) {
  24084. for (i = 0; i < colors; ++i) {
  24085. buffer[pos++] = rawBytes[i];
  24086. }
  24087. for (; i < rowBytes; ++i) {
  24088. buffer[pos] = buffer[pos - colors] + rawBytes[i];
  24089. pos++;
  24090. }
  24091. } else if (bits === 16) {
  24092. const bytesPerPixel = colors * 2;
  24093. for (i = 0; i < bytesPerPixel; ++i) {
  24094. buffer[pos++] = rawBytes[i];
  24095. }
  24096. for (; i < rowBytes; i += 2) {
  24097. const sum = ((rawBytes[i] & 0xff) << 8) + (rawBytes[i + 1] & 0xff) + ((buffer[pos - bytesPerPixel] & 0xff) << 8) + (buffer[pos - bytesPerPixel + 1] & 0xff);
  24098. buffer[pos++] = sum >> 8 & 0xff;
  24099. buffer[pos++] = sum & 0xff;
  24100. }
  24101. } else {
  24102. const compArray = new Uint8Array(colors + 1);
  24103. const bitMask = (1 << bits) - 1;
  24104. let j = 0,
  24105. k = bufferLength;
  24106. const columns = this.columns;
  24107. for (i = 0; i < columns; ++i) {
  24108. for (let kk = 0; kk < colors; ++kk) {
  24109. if (inbits < bits) {
  24110. inbuf = inbuf << 8 | rawBytes[j++] & 0xff;
  24111. inbits += 8;
  24112. }
  24113. compArray[kk] = compArray[kk] + (inbuf >> inbits - bits) & bitMask;
  24114. inbits -= bits;
  24115. outbuf = outbuf << bits | compArray[kk];
  24116. outbits += bits;
  24117. if (outbits >= 8) {
  24118. buffer[k++] = outbuf >> outbits - 8 & 0xff;
  24119. outbits -= 8;
  24120. }
  24121. }
  24122. }
  24123. if (outbits > 0) {
  24124. buffer[k++] = (outbuf << 8 - outbits) + (inbuf & (1 << 8 - outbits) - 1);
  24125. }
  24126. }
  24127. this.bufferLength += rowBytes;
  24128. }
  24129. readBlockPng() {
  24130. const rowBytes = this.rowBytes;
  24131. const pixBytes = this.pixBytes;
  24132. const predictor = this.str.getByte();
  24133. const rawBytes = this.str.getBytes(rowBytes);
  24134. this.eof = !rawBytes.length;
  24135. if (this.eof) {
  24136. return;
  24137. }
  24138. const bufferLength = this.bufferLength;
  24139. const buffer = this.ensureBuffer(bufferLength + rowBytes);
  24140. let prevRow = buffer.subarray(bufferLength - rowBytes, bufferLength);
  24141. if (prevRow.length === 0) {
  24142. prevRow = new Uint8Array(rowBytes);
  24143. }
  24144. let i,
  24145. j = bufferLength,
  24146. up,
  24147. c;
  24148. switch (predictor) {
  24149. case 0:
  24150. for (i = 0; i < rowBytes; ++i) {
  24151. buffer[j++] = rawBytes[i];
  24152. }
  24153. break;
  24154. case 1:
  24155. for (i = 0; i < pixBytes; ++i) {
  24156. buffer[j++] = rawBytes[i];
  24157. }
  24158. for (; i < rowBytes; ++i) {
  24159. buffer[j] = buffer[j - pixBytes] + rawBytes[i] & 0xff;
  24160. j++;
  24161. }
  24162. break;
  24163. case 2:
  24164. for (i = 0; i < rowBytes; ++i) {
  24165. buffer[j++] = prevRow[i] + rawBytes[i] & 0xff;
  24166. }
  24167. break;
  24168. case 3:
  24169. for (i = 0; i < pixBytes; ++i) {
  24170. buffer[j++] = (prevRow[i] >> 1) + rawBytes[i];
  24171. }
  24172. for (; i < rowBytes; ++i) {
  24173. buffer[j] = (prevRow[i] + buffer[j - pixBytes] >> 1) + rawBytes[i] & 0xff;
  24174. j++;
  24175. }
  24176. break;
  24177. case 4:
  24178. for (i = 0; i < pixBytes; ++i) {
  24179. up = prevRow[i];
  24180. c = rawBytes[i];
  24181. buffer[j++] = up + c;
  24182. }
  24183. for (; i < rowBytes; ++i) {
  24184. up = prevRow[i];
  24185. const upLeft = prevRow[i - pixBytes];
  24186. const left = buffer[j - pixBytes];
  24187. const p = left + up - upLeft;
  24188. let pa = p - left;
  24189. if (pa < 0) {
  24190. pa = -pa;
  24191. }
  24192. let pb = p - up;
  24193. if (pb < 0) {
  24194. pb = -pb;
  24195. }
  24196. let pc = p - upLeft;
  24197. if (pc < 0) {
  24198. pc = -pc;
  24199. }
  24200. c = rawBytes[i];
  24201. if (pa <= pb && pa <= pc) {
  24202. buffer[j++] = left + c;
  24203. } else if (pb <= pc) {
  24204. buffer[j++] = up + c;
  24205. } else {
  24206. buffer[j++] = upLeft + c;
  24207. }
  24208. }
  24209. break;
  24210. default:
  24211. throw new _util.FormatError(`Unsupported predictor: ${predictor}`);
  24212. }
  24213. this.bufferLength += rowBytes;
  24214. }
  24215. }
  24216. exports.PredictorStream = PredictorStream;
  24217. /***/ }),
  24218. /* 184 */
  24219. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  24220. Object.defineProperty(exports, "__esModule", ({
  24221. value: true
  24222. }));
  24223. exports.RunLengthStream = void 0;
  24224. var _decode_stream = __w_pdfjs_require__(169);
  24225. class RunLengthStream extends _decode_stream.DecodeStream {
  24226. constructor(str, maybeLength) {
  24227. super(maybeLength);
  24228. this.str = str;
  24229. this.dict = str.dict;
  24230. }
  24231. readBlock() {
  24232. const repeatHeader = this.str.getBytes(2);
  24233. if (!repeatHeader || repeatHeader.length < 2 || repeatHeader[0] === 128) {
  24234. this.eof = true;
  24235. return;
  24236. }
  24237. let buffer;
  24238. let bufferLength = this.bufferLength;
  24239. let n = repeatHeader[0];
  24240. if (n < 128) {
  24241. buffer = this.ensureBuffer(bufferLength + n + 1);
  24242. buffer[bufferLength++] = repeatHeader[1];
  24243. if (n > 0) {
  24244. const source = this.str.getBytes(n);
  24245. buffer.set(source, bufferLength);
  24246. bufferLength += n;
  24247. }
  24248. } else {
  24249. n = 257 - n;
  24250. const b = repeatHeader[1];
  24251. buffer = this.ensureBuffer(bufferLength + n + 1);
  24252. for (let i = 0; i < n; i++) {
  24253. buffer[bufferLength++] = b;
  24254. }
  24255. }
  24256. this.bufferLength = bufferLength;
  24257. }
  24258. }
  24259. exports.RunLengthStream = RunLengthStream;
  24260. /***/ }),
  24261. /* 185 */
  24262. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  24263. Object.defineProperty(exports, "__esModule", ({
  24264. value: true
  24265. }));
  24266. exports.Font = exports.ErrorFont = void 0;
  24267. __w_pdfjs_require__(116);
  24268. __w_pdfjs_require__(127);
  24269. __w_pdfjs_require__(129);
  24270. __w_pdfjs_require__(132);
  24271. __w_pdfjs_require__(134);
  24272. __w_pdfjs_require__(136);
  24273. __w_pdfjs_require__(138);
  24274. __w_pdfjs_require__(140);
  24275. __w_pdfjs_require__(158);
  24276. __w_pdfjs_require__(84);
  24277. __w_pdfjs_require__(93);
  24278. __w_pdfjs_require__(94);
  24279. __w_pdfjs_require__(97);
  24280. __w_pdfjs_require__(99);
  24281. __w_pdfjs_require__(101);
  24282. __w_pdfjs_require__(105);
  24283. __w_pdfjs_require__(108);
  24284. __w_pdfjs_require__(115);
  24285. var _util = __w_pdfjs_require__(145);
  24286. var _cff_parser = __w_pdfjs_require__(186);
  24287. var _fonts_utils = __w_pdfjs_require__(189);
  24288. var _unicode = __w_pdfjs_require__(191);
  24289. var _glyphlist = __w_pdfjs_require__(190);
  24290. var _encodings = __w_pdfjs_require__(188);
  24291. var _standard_fonts = __w_pdfjs_require__(192);
  24292. var _to_unicode_map = __w_pdfjs_require__(193);
  24293. var _cff_font = __w_pdfjs_require__(194);
  24294. var _font_renderer = __w_pdfjs_require__(195);
  24295. var _metrics = __w_pdfjs_require__(196);
  24296. var _glyf = __w_pdfjs_require__(197);
  24297. var _cmap = __w_pdfjs_require__(165);
  24298. var _opentype_file_builder = __w_pdfjs_require__(198);
  24299. var _core_utils = __w_pdfjs_require__(150);
  24300. var _stream = __w_pdfjs_require__(155);
  24301. var _type1_font = __w_pdfjs_require__(199);
  24302. const PRIVATE_USE_AREAS = [[0xe000, 0xf8ff], [0x100000, 0x10fffd]];
  24303. const PDF_GLYPH_SPACE_UNITS = 1000;
  24304. 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"];
  24305. const EXPORT_DATA_EXTRA_PROPERTIES = ["cMap", "defaultEncoding", "differences", "isMonospace", "isSerifFont", "isSymbolicFont", "seacMap", "toFontChar", "toUnicode", "vmetrics", "widths"];
  24306. function adjustWidths(properties) {
  24307. if (!properties.fontMatrix) {
  24308. return;
  24309. }
  24310. if (properties.fontMatrix[0] === _util.FONT_IDENTITY_MATRIX[0]) {
  24311. return;
  24312. }
  24313. const scale = 0.001 / properties.fontMatrix[0];
  24314. const glyphsWidths = properties.widths;
  24315. for (const glyph in glyphsWidths) {
  24316. glyphsWidths[glyph] *= scale;
  24317. }
  24318. properties.defaultWidth *= scale;
  24319. }
  24320. function adjustTrueTypeToUnicode(properties, isSymbolicFont, nameRecords) {
  24321. if (properties.isInternalFont) {
  24322. return;
  24323. }
  24324. if (properties.hasIncludedToUnicodeMap) {
  24325. return;
  24326. }
  24327. if (properties.hasEncoding) {
  24328. return;
  24329. }
  24330. if (properties.toUnicode instanceof _to_unicode_map.IdentityToUnicodeMap) {
  24331. return;
  24332. }
  24333. if (!isSymbolicFont) {
  24334. return;
  24335. }
  24336. if (nameRecords.length === 0) {
  24337. return;
  24338. }
  24339. if (properties.defaultEncoding === _encodings.WinAnsiEncoding) {
  24340. return;
  24341. }
  24342. for (const r of nameRecords) {
  24343. if (!isWinNameRecord(r)) {
  24344. return;
  24345. }
  24346. }
  24347. const encoding = _encodings.WinAnsiEncoding;
  24348. const toUnicode = [],
  24349. glyphsUnicodeMap = (0, _glyphlist.getGlyphsUnicode)();
  24350. for (const charCode in encoding) {
  24351. const glyphName = encoding[charCode];
  24352. if (glyphName === "") {
  24353. continue;
  24354. }
  24355. const unicode = glyphsUnicodeMap[glyphName];
  24356. if (unicode === undefined) {
  24357. continue;
  24358. }
  24359. toUnicode[charCode] = String.fromCharCode(unicode);
  24360. }
  24361. if (toUnicode.length > 0) {
  24362. properties.toUnicode.amend(toUnicode);
  24363. }
  24364. }
  24365. function adjustType1ToUnicode(properties, builtInEncoding) {
  24366. if (properties.isInternalFont) {
  24367. return;
  24368. }
  24369. if (properties.hasIncludedToUnicodeMap) {
  24370. return;
  24371. }
  24372. if (builtInEncoding === properties.defaultEncoding) {
  24373. return;
  24374. }
  24375. if (properties.toUnicode instanceof _to_unicode_map.IdentityToUnicodeMap) {
  24376. return;
  24377. }
  24378. const toUnicode = [],
  24379. glyphsUnicodeMap = (0, _glyphlist.getGlyphsUnicode)();
  24380. for (const charCode in builtInEncoding) {
  24381. if (properties.hasEncoding) {
  24382. if (properties.baseEncodingName || properties.differences[charCode] !== undefined) {
  24383. continue;
  24384. }
  24385. }
  24386. const glyphName = builtInEncoding[charCode];
  24387. const unicode = (0, _unicode.getUnicodeForGlyph)(glyphName, glyphsUnicodeMap);
  24388. if (unicode !== -1) {
  24389. toUnicode[charCode] = String.fromCharCode(unicode);
  24390. }
  24391. }
  24392. if (toUnicode.length > 0) {
  24393. properties.toUnicode.amend(toUnicode);
  24394. }
  24395. }
  24396. function amendFallbackToUnicode(properties) {
  24397. if (!properties.fallbackToUnicode) {
  24398. return;
  24399. }
  24400. if (properties.toUnicode instanceof _to_unicode_map.IdentityToUnicodeMap) {
  24401. return;
  24402. }
  24403. const toUnicode = [];
  24404. for (const charCode in properties.fallbackToUnicode) {
  24405. if (properties.toUnicode.has(charCode)) {
  24406. continue;
  24407. }
  24408. toUnicode[charCode] = properties.fallbackToUnicode[charCode];
  24409. }
  24410. if (toUnicode.length > 0) {
  24411. properties.toUnicode.amend(toUnicode);
  24412. }
  24413. }
  24414. class Glyph {
  24415. constructor(originalCharCode, fontChar, unicode, accent, width, vmetric, operatorListId, isSpace, isInFont) {
  24416. this.originalCharCode = originalCharCode;
  24417. this.fontChar = fontChar;
  24418. this.unicode = unicode;
  24419. this.accent = accent;
  24420. this.width = width;
  24421. this.vmetric = vmetric;
  24422. this.operatorListId = operatorListId;
  24423. this.isSpace = isSpace;
  24424. this.isInFont = isInFont;
  24425. }
  24426. get category() {
  24427. return (0, _util.shadow)(this, "category", (0, _unicode.getCharUnicodeCategory)(this.unicode), true);
  24428. }
  24429. }
  24430. function int16(b0, b1) {
  24431. return (b0 << 8) + b1;
  24432. }
  24433. function writeSignedInt16(bytes, index, value) {
  24434. bytes[index + 1] = value;
  24435. bytes[index] = value >>> 8;
  24436. }
  24437. function signedInt16(b0, b1) {
  24438. const value = (b0 << 8) + b1;
  24439. return value & 1 << 15 ? value - 0x10000 : value;
  24440. }
  24441. function int32(b0, b1, b2, b3) {
  24442. return (b0 << 24) + (b1 << 16) + (b2 << 8) + b3;
  24443. }
  24444. function string16(value) {
  24445. return String.fromCharCode(value >> 8 & 0xff, value & 0xff);
  24446. }
  24447. function safeString16(value) {
  24448. if (value > 0x7fff) {
  24449. value = 0x7fff;
  24450. } else if (value < -0x8000) {
  24451. value = -0x8000;
  24452. }
  24453. return String.fromCharCode(value >> 8 & 0xff, value & 0xff);
  24454. }
  24455. function isTrueTypeFile(file) {
  24456. const header = file.peekBytes(4);
  24457. return (0, _core_utils.readUint32)(header, 0) === 0x00010000 || (0, _util.bytesToString)(header) === "true";
  24458. }
  24459. function isTrueTypeCollectionFile(file) {
  24460. const header = file.peekBytes(4);
  24461. return (0, _util.bytesToString)(header) === "ttcf";
  24462. }
  24463. function isOpenTypeFile(file) {
  24464. const header = file.peekBytes(4);
  24465. return (0, _util.bytesToString)(header) === "OTTO";
  24466. }
  24467. function isType1File(file) {
  24468. const header = file.peekBytes(2);
  24469. if (header[0] === 0x25 && header[1] === 0x21) {
  24470. return true;
  24471. }
  24472. if (header[0] === 0x80 && header[1] === 0x01) {
  24473. return true;
  24474. }
  24475. return false;
  24476. }
  24477. function isCFFFile(file) {
  24478. const header = file.peekBytes(4);
  24479. if (header[0] >= 1 && header[3] >= 1 && header[3] <= 4) {
  24480. return true;
  24481. }
  24482. return false;
  24483. }
  24484. function getFontFileType(file, _ref) {
  24485. let {
  24486. type,
  24487. subtype,
  24488. composite
  24489. } = _ref;
  24490. let fileType, fileSubtype;
  24491. if (isTrueTypeFile(file) || isTrueTypeCollectionFile(file)) {
  24492. fileType = composite ? "CIDFontType2" : "TrueType";
  24493. } else if (isOpenTypeFile(file)) {
  24494. fileType = composite ? "CIDFontType2" : "OpenType";
  24495. } else if (isType1File(file)) {
  24496. if (composite) {
  24497. fileType = "CIDFontType0";
  24498. } else {
  24499. fileType = type === "MMType1" ? "MMType1" : "Type1";
  24500. }
  24501. } else if (isCFFFile(file)) {
  24502. if (composite) {
  24503. fileType = "CIDFontType0";
  24504. fileSubtype = "CIDFontType0C";
  24505. } else {
  24506. fileType = type === "MMType1" ? "MMType1" : "Type1";
  24507. fileSubtype = "Type1C";
  24508. }
  24509. } else {
  24510. (0, _util.warn)("getFontFileType: Unable to detect correct font file Type/Subtype.");
  24511. fileType = type;
  24512. fileSubtype = subtype;
  24513. }
  24514. return [fileType, fileSubtype];
  24515. }
  24516. function applyStandardFontGlyphMap(map, glyphMap) {
  24517. for (const charCode in glyphMap) {
  24518. map[+charCode] = glyphMap[charCode];
  24519. }
  24520. }
  24521. function buildToFontChar(encoding, glyphsUnicodeMap, differences) {
  24522. const toFontChar = [];
  24523. let unicode;
  24524. for (let i = 0, ii = encoding.length; i < ii; i++) {
  24525. unicode = (0, _unicode.getUnicodeForGlyph)(encoding[i], glyphsUnicodeMap);
  24526. if (unicode !== -1) {
  24527. toFontChar[i] = unicode;
  24528. }
  24529. }
  24530. for (const charCode in differences) {
  24531. unicode = (0, _unicode.getUnicodeForGlyph)(differences[charCode], glyphsUnicodeMap);
  24532. if (unicode !== -1) {
  24533. toFontChar[+charCode] = unicode;
  24534. }
  24535. }
  24536. return toFontChar;
  24537. }
  24538. function isMacNameRecord(r) {
  24539. return r.platform === 1 && r.encoding === 0 && r.language === 0;
  24540. }
  24541. function isWinNameRecord(r) {
  24542. return r.platform === 3 && r.encoding === 1 && r.language === 0x409;
  24543. }
  24544. function convertCidString(charCode, cid) {
  24545. let shouldThrow = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  24546. switch (cid.length) {
  24547. case 1:
  24548. return cid.charCodeAt(0);
  24549. case 2:
  24550. return cid.charCodeAt(0) << 8 | cid.charCodeAt(1);
  24551. }
  24552. const msg = `Unsupported CID string (charCode ${charCode}): "${cid}".`;
  24553. if (shouldThrow) {
  24554. throw new _util.FormatError(msg);
  24555. }
  24556. (0, _util.warn)(msg);
  24557. return cid;
  24558. }
  24559. function adjustMapping(charCodeToGlyphId, hasGlyph, newGlyphZeroId, toUnicode) {
  24560. const newMap = Object.create(null);
  24561. const toUnicodeExtraMap = new Map();
  24562. const toFontChar = [];
  24563. const usedGlyphIds = new Set();
  24564. let privateUseAreaIndex = 0;
  24565. const privateUseOffetStart = PRIVATE_USE_AREAS[privateUseAreaIndex][0];
  24566. let nextAvailableFontCharCode = privateUseOffetStart;
  24567. let privateUseOffetEnd = PRIVATE_USE_AREAS[privateUseAreaIndex][1];
  24568. 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];
  24569. for (let originalCharCode in charCodeToGlyphId) {
  24570. originalCharCode |= 0;
  24571. let glyphId = charCodeToGlyphId[originalCharCode];
  24572. if (!hasGlyph(glyphId)) {
  24573. continue;
  24574. }
  24575. if (nextAvailableFontCharCode > privateUseOffetEnd) {
  24576. privateUseAreaIndex++;
  24577. if (privateUseAreaIndex >= PRIVATE_USE_AREAS.length) {
  24578. (0, _util.warn)("Ran out of space in font private use area.");
  24579. break;
  24580. }
  24581. nextAvailableFontCharCode = PRIVATE_USE_AREAS[privateUseAreaIndex][0];
  24582. privateUseOffetEnd = PRIVATE_USE_AREAS[privateUseAreaIndex][1];
  24583. }
  24584. const fontCharCode = nextAvailableFontCharCode++;
  24585. if (glyphId === 0) {
  24586. glyphId = newGlyphZeroId;
  24587. }
  24588. let unicode = toUnicode.get(originalCharCode);
  24589. if (typeof unicode === "string") {
  24590. unicode = unicode.codePointAt(0);
  24591. }
  24592. if (unicode && !isInPrivateArea(unicode) && !usedGlyphIds.has(glyphId)) {
  24593. toUnicodeExtraMap.set(unicode, glyphId);
  24594. usedGlyphIds.add(glyphId);
  24595. }
  24596. newMap[fontCharCode] = glyphId;
  24597. toFontChar[originalCharCode] = fontCharCode;
  24598. }
  24599. return {
  24600. toFontChar,
  24601. charCodeToGlyphId: newMap,
  24602. toUnicodeExtraMap,
  24603. nextAvailableFontCharCode
  24604. };
  24605. }
  24606. function getRanges(glyphs, toUnicodeExtraMap, numGlyphs) {
  24607. const codes = [];
  24608. for (const charCode in glyphs) {
  24609. if (glyphs[charCode] >= numGlyphs) {
  24610. continue;
  24611. }
  24612. codes.push({
  24613. fontCharCode: charCode | 0,
  24614. glyphId: glyphs[charCode]
  24615. });
  24616. }
  24617. if (toUnicodeExtraMap) {
  24618. for (const [unicode, glyphId] of toUnicodeExtraMap) {
  24619. if (glyphId >= numGlyphs) {
  24620. continue;
  24621. }
  24622. codes.push({
  24623. fontCharCode: unicode,
  24624. glyphId
  24625. });
  24626. }
  24627. }
  24628. if (codes.length === 0) {
  24629. codes.push({
  24630. fontCharCode: 0,
  24631. glyphId: 0
  24632. });
  24633. }
  24634. codes.sort(function fontGetRangesSort(a, b) {
  24635. return a.fontCharCode - b.fontCharCode;
  24636. });
  24637. const ranges = [];
  24638. const length = codes.length;
  24639. for (let n = 0; n < length;) {
  24640. const start = codes[n].fontCharCode;
  24641. const codeIndices = [codes[n].glyphId];
  24642. ++n;
  24643. let end = start;
  24644. while (n < length && end + 1 === codes[n].fontCharCode) {
  24645. codeIndices.push(codes[n].glyphId);
  24646. ++end;
  24647. ++n;
  24648. if (end === 0xffff) {
  24649. break;
  24650. }
  24651. }
  24652. ranges.push([start, end, codeIndices]);
  24653. }
  24654. return ranges;
  24655. }
  24656. function createCmapTable(glyphs, toUnicodeExtraMap, numGlyphs) {
  24657. const ranges = getRanges(glyphs, toUnicodeExtraMap, numGlyphs);
  24658. const numTables = ranges.at(-1)[1] > 0xffff ? 2 : 1;
  24659. let cmap = "\x00\x00" + string16(numTables) + "\x00\x03" + "\x00\x01" + (0, _util.string32)(4 + numTables * 8);
  24660. let i, ii, j, jj;
  24661. for (i = ranges.length - 1; i >= 0; --i) {
  24662. if (ranges[i][0] <= 0xffff) {
  24663. break;
  24664. }
  24665. }
  24666. const bmpLength = i + 1;
  24667. if (ranges[i][0] < 0xffff && ranges[i][1] === 0xffff) {
  24668. ranges[i][1] = 0xfffe;
  24669. }
  24670. const trailingRangesCount = ranges[i][1] < 0xffff ? 1 : 0;
  24671. const segCount = bmpLength + trailingRangesCount;
  24672. const searchParams = _opentype_file_builder.OpenTypeFileBuilder.getSearchParams(segCount, 2);
  24673. let startCount = "";
  24674. let endCount = "";
  24675. let idDeltas = "";
  24676. let idRangeOffsets = "";
  24677. let glyphsIds = "";
  24678. let bias = 0;
  24679. let range, start, end, codes;
  24680. for (i = 0, ii = bmpLength; i < ii; i++) {
  24681. range = ranges[i];
  24682. start = range[0];
  24683. end = range[1];
  24684. startCount += string16(start);
  24685. endCount += string16(end);
  24686. codes = range[2];
  24687. let contiguous = true;
  24688. for (j = 1, jj = codes.length; j < jj; ++j) {
  24689. if (codes[j] !== codes[j - 1] + 1) {
  24690. contiguous = false;
  24691. break;
  24692. }
  24693. }
  24694. if (!contiguous) {
  24695. const offset = (segCount - i) * 2 + bias * 2;
  24696. bias += end - start + 1;
  24697. idDeltas += string16(0);
  24698. idRangeOffsets += string16(offset);
  24699. for (j = 0, jj = codes.length; j < jj; ++j) {
  24700. glyphsIds += string16(codes[j]);
  24701. }
  24702. } else {
  24703. const startCode = codes[0];
  24704. idDeltas += string16(startCode - start & 0xffff);
  24705. idRangeOffsets += string16(0);
  24706. }
  24707. }
  24708. if (trailingRangesCount > 0) {
  24709. endCount += "\xFF\xFF";
  24710. startCount += "\xFF\xFF";
  24711. idDeltas += "\x00\x01";
  24712. idRangeOffsets += "\x00\x00";
  24713. }
  24714. const format314 = "\x00\x00" + string16(2 * segCount) + string16(searchParams.range) + string16(searchParams.entry) + string16(searchParams.rangeShift) + endCount + "\x00\x00" + startCount + idDeltas + idRangeOffsets + glyphsIds;
  24715. let format31012 = "";
  24716. let header31012 = "";
  24717. if (numTables > 1) {
  24718. cmap += "\x00\x03" + "\x00\x0A" + (0, _util.string32)(4 + numTables * 8 + 4 + format314.length);
  24719. format31012 = "";
  24720. for (i = 0, ii = ranges.length; i < ii; i++) {
  24721. range = ranges[i];
  24722. start = range[0];
  24723. codes = range[2];
  24724. let code = codes[0];
  24725. for (j = 1, jj = codes.length; j < jj; ++j) {
  24726. if (codes[j] !== codes[j - 1] + 1) {
  24727. end = range[0] + j - 1;
  24728. format31012 += (0, _util.string32)(start) + (0, _util.string32)(end) + (0, _util.string32)(code);
  24729. start = end + 1;
  24730. code = codes[j];
  24731. }
  24732. }
  24733. format31012 += (0, _util.string32)(start) + (0, _util.string32)(range[1]) + (0, _util.string32)(code);
  24734. }
  24735. header31012 = "\x00\x0C" + "\x00\x00" + (0, _util.string32)(format31012.length + 16) + "\x00\x00\x00\x00" + (0, _util.string32)(format31012.length / 12);
  24736. }
  24737. return cmap + "\x00\x04" + string16(format314.length + 4) + format314 + header31012 + format31012;
  24738. }
  24739. function validateOS2Table(os2, file) {
  24740. file.pos = (file.start || 0) + os2.offset;
  24741. const version = file.getUint16();
  24742. file.skip(60);
  24743. const selection = file.getUint16();
  24744. if (version < 4 && selection & 0x0300) {
  24745. return false;
  24746. }
  24747. const firstChar = file.getUint16();
  24748. const lastChar = file.getUint16();
  24749. if (firstChar > lastChar) {
  24750. return false;
  24751. }
  24752. file.skip(6);
  24753. const usWinAscent = file.getUint16();
  24754. if (usWinAscent === 0) {
  24755. return false;
  24756. }
  24757. os2.data[8] = os2.data[9] = 0;
  24758. return true;
  24759. }
  24760. function createOS2Table(properties, charstrings, override) {
  24761. override ||= {
  24762. unitsPerEm: 0,
  24763. yMax: 0,
  24764. yMin: 0,
  24765. ascent: 0,
  24766. descent: 0
  24767. };
  24768. let ulUnicodeRange1 = 0;
  24769. let ulUnicodeRange2 = 0;
  24770. let ulUnicodeRange3 = 0;
  24771. let ulUnicodeRange4 = 0;
  24772. let firstCharIndex = null;
  24773. let lastCharIndex = 0;
  24774. let position = -1;
  24775. if (charstrings) {
  24776. for (let code in charstrings) {
  24777. code |= 0;
  24778. if (firstCharIndex > code || !firstCharIndex) {
  24779. firstCharIndex = code;
  24780. }
  24781. if (lastCharIndex < code) {
  24782. lastCharIndex = code;
  24783. }
  24784. position = (0, _unicode.getUnicodeRangeFor)(code, position);
  24785. if (position < 32) {
  24786. ulUnicodeRange1 |= 1 << position;
  24787. } else if (position < 64) {
  24788. ulUnicodeRange2 |= 1 << position - 32;
  24789. } else if (position < 96) {
  24790. ulUnicodeRange3 |= 1 << position - 64;
  24791. } else if (position < 123) {
  24792. ulUnicodeRange4 |= 1 << position - 96;
  24793. } else {
  24794. throw new _util.FormatError("Unicode ranges Bits > 123 are reserved for internal usage");
  24795. }
  24796. }
  24797. if (lastCharIndex > 0xffff) {
  24798. lastCharIndex = 0xffff;
  24799. }
  24800. } else {
  24801. firstCharIndex = 0;
  24802. lastCharIndex = 255;
  24803. }
  24804. const bbox = properties.bbox || [0, 0, 0, 0];
  24805. const unitsPerEm = override.unitsPerEm || 1 / (properties.fontMatrix || _util.FONT_IDENTITY_MATRIX)[0];
  24806. const scale = properties.ascentScaled ? 1.0 : unitsPerEm / PDF_GLYPH_SPACE_UNITS;
  24807. const typoAscent = override.ascent || Math.round(scale * (properties.ascent || bbox[3]));
  24808. let typoDescent = override.descent || Math.round(scale * (properties.descent || bbox[1]));
  24809. if (typoDescent > 0 && properties.descent > 0 && bbox[1] < 0) {
  24810. typoDescent = -typoDescent;
  24811. }
  24812. const winAscent = override.yMax || typoAscent;
  24813. const winDescent = -override.yMin || -typoDescent;
  24814. 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";
  24815. }
  24816. function createPostTable(properties) {
  24817. const angle = Math.floor(properties.italicAngle * 2 ** 16);
  24818. 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";
  24819. }
  24820. function createPostscriptName(name) {
  24821. return name.replaceAll(/[^\x21-\x7E]|[[\](){}<>/%]/g, "").slice(0, 63);
  24822. }
  24823. function createNameTable(name, proto) {
  24824. if (!proto) {
  24825. proto = [[], []];
  24826. }
  24827. 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"];
  24828. const stringsUnicode = [];
  24829. let i, ii, j, jj, str;
  24830. for (i = 0, ii = strings.length; i < ii; i++) {
  24831. str = proto[1][i] || strings[i];
  24832. const strBufUnicode = [];
  24833. for (j = 0, jj = str.length; j < jj; j++) {
  24834. strBufUnicode.push(string16(str.charCodeAt(j)));
  24835. }
  24836. stringsUnicode.push(strBufUnicode.join(""));
  24837. }
  24838. const names = [strings, stringsUnicode];
  24839. const platforms = ["\x00\x01", "\x00\x03"];
  24840. const encodings = ["\x00\x00", "\x00\x01"];
  24841. const languages = ["\x00\x00", "\x04\x09"];
  24842. const namesRecordCount = strings.length * platforms.length;
  24843. let nameTable = "\x00\x00" + string16(namesRecordCount) + string16(namesRecordCount * 12 + 6);
  24844. let strOffset = 0;
  24845. for (i = 0, ii = platforms.length; i < ii; i++) {
  24846. const strs = names[i];
  24847. for (j = 0, jj = strs.length; j < jj; j++) {
  24848. str = strs[j];
  24849. const nameRecord = platforms[i] + encodings[i] + languages[i] + string16(j) + string16(str.length) + string16(strOffset);
  24850. nameTable += nameRecord;
  24851. strOffset += str.length;
  24852. }
  24853. }
  24854. nameTable += strings.join("") + stringsUnicode.join("");
  24855. return nameTable;
  24856. }
  24857. class Font {
  24858. constructor(name, file, properties) {
  24859. this.name = name;
  24860. this.psName = null;
  24861. this.mimetype = null;
  24862. this.disableFontFace = false;
  24863. this.loadedName = properties.loadedName;
  24864. this.isType3Font = properties.isType3Font;
  24865. this.missingFile = false;
  24866. this.cssFontInfo = properties.cssFontInfo;
  24867. this._charsCache = Object.create(null);
  24868. this._glyphCache = Object.create(null);
  24869. let isSerifFont = !!(properties.flags & _fonts_utils.FontFlags.Serif);
  24870. if (!isSerifFont && !properties.isSimulatedFlags) {
  24871. const baseName = name.replaceAll(/[,_]/g, "-").split("-")[0],
  24872. serifFonts = (0, _standard_fonts.getSerifFonts)();
  24873. for (const namePart of baseName.split("+")) {
  24874. if (serifFonts[namePart]) {
  24875. isSerifFont = true;
  24876. break;
  24877. }
  24878. }
  24879. }
  24880. this.isSerifFont = isSerifFont;
  24881. this.isSymbolicFont = !!(properties.flags & _fonts_utils.FontFlags.Symbolic);
  24882. this.isMonospace = !!(properties.flags & _fonts_utils.FontFlags.FixedPitch);
  24883. let {
  24884. type,
  24885. subtype
  24886. } = properties;
  24887. this.type = type;
  24888. this.subtype = subtype;
  24889. this.systemFontInfo = properties.systemFontInfo;
  24890. const matches = name.match(/^InvalidPDFjsFont_(.*)_\d+$/);
  24891. this.isInvalidPDFjsFont = !!matches;
  24892. if (this.isInvalidPDFjsFont) {
  24893. this.fallbackName = matches[1];
  24894. } else if (this.isMonospace) {
  24895. this.fallbackName = "monospace";
  24896. } else if (this.isSerifFont) {
  24897. this.fallbackName = "serif";
  24898. } else {
  24899. this.fallbackName = "sans-serif";
  24900. }
  24901. if (this.systemFontInfo?.guessFallback) {
  24902. this.systemFontInfo.guessFallback = false;
  24903. this.systemFontInfo.css += `,${this.fallbackName}`;
  24904. }
  24905. this.differences = properties.differences;
  24906. this.widths = properties.widths;
  24907. this.defaultWidth = properties.defaultWidth;
  24908. this.composite = properties.composite;
  24909. this.cMap = properties.cMap;
  24910. this.capHeight = properties.capHeight / PDF_GLYPH_SPACE_UNITS;
  24911. this.ascent = properties.ascent / PDF_GLYPH_SPACE_UNITS;
  24912. this.descent = properties.descent / PDF_GLYPH_SPACE_UNITS;
  24913. this.lineHeight = this.ascent - this.descent;
  24914. this.fontMatrix = properties.fontMatrix;
  24915. this.bbox = properties.bbox;
  24916. this.defaultEncoding = properties.defaultEncoding;
  24917. this.toUnicode = properties.toUnicode;
  24918. this.toFontChar = [];
  24919. if (properties.type === "Type3") {
  24920. for (let charCode = 0; charCode < 256; charCode++) {
  24921. this.toFontChar[charCode] = this.differences[charCode] || properties.defaultEncoding[charCode];
  24922. }
  24923. return;
  24924. }
  24925. this.cidEncoding = properties.cidEncoding || "";
  24926. this.vertical = !!properties.vertical;
  24927. if (this.vertical) {
  24928. this.vmetrics = properties.vmetrics;
  24929. this.defaultVMetrics = properties.defaultVMetrics;
  24930. }
  24931. if (!file || file.isEmpty) {
  24932. if (file) {
  24933. (0, _util.warn)('Font file is empty in "' + name + '" (' + this.loadedName + ")");
  24934. }
  24935. this.fallbackToSystemFont(properties);
  24936. return;
  24937. }
  24938. [type, subtype] = getFontFileType(file, properties);
  24939. if (type !== this.type || subtype !== this.subtype) {
  24940. (0, _util.info)("Inconsistent font file Type/SubType, expected: " + `${this.type}/${this.subtype} but found: ${type}/${subtype}.`);
  24941. }
  24942. let data;
  24943. try {
  24944. switch (type) {
  24945. case "MMType1":
  24946. (0, _util.info)("MMType1 font (" + name + "), falling back to Type1.");
  24947. case "Type1":
  24948. case "CIDFontType0":
  24949. this.mimetype = "font/opentype";
  24950. const cff = subtype === "Type1C" || subtype === "CIDFontType0C" ? new _cff_font.CFFFont(file, properties) : new _type1_font.Type1Font(name, file, properties);
  24951. adjustWidths(properties);
  24952. data = this.convert(name, cff, properties);
  24953. break;
  24954. case "OpenType":
  24955. case "TrueType":
  24956. case "CIDFontType2":
  24957. this.mimetype = "font/opentype";
  24958. data = this.checkAndRepair(name, file, properties);
  24959. if (this.isOpenType) {
  24960. adjustWidths(properties);
  24961. type = "OpenType";
  24962. }
  24963. break;
  24964. default:
  24965. throw new _util.FormatError(`Font ${type} is not supported`);
  24966. }
  24967. } catch (e) {
  24968. (0, _util.warn)(e);
  24969. this.fallbackToSystemFont(properties);
  24970. return;
  24971. }
  24972. amendFallbackToUnicode(properties);
  24973. this.data = data;
  24974. this.type = type;
  24975. this.subtype = subtype;
  24976. this.fontMatrix = properties.fontMatrix;
  24977. this.widths = properties.widths;
  24978. this.defaultWidth = properties.defaultWidth;
  24979. this.toUnicode = properties.toUnicode;
  24980. this.seacMap = properties.seacMap;
  24981. }
  24982. get renderer() {
  24983. const renderer = _font_renderer.FontRendererFactory.create(this, _fonts_utils.SEAC_ANALYSIS_ENABLED);
  24984. return (0, _util.shadow)(this, "renderer", renderer);
  24985. }
  24986. exportData() {
  24987. let extraProperties = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  24988. const exportDataProperties = extraProperties ? [...EXPORT_DATA_PROPERTIES, ...EXPORT_DATA_EXTRA_PROPERTIES] : EXPORT_DATA_PROPERTIES;
  24989. const data = Object.create(null);
  24990. let property, value;
  24991. for (property of exportDataProperties) {
  24992. value = this[property];
  24993. if (value !== undefined) {
  24994. data[property] = value;
  24995. }
  24996. }
  24997. return data;
  24998. }
  24999. fallbackToSystemFont(properties) {
  25000. this.missingFile = true;
  25001. const {
  25002. name,
  25003. type
  25004. } = this;
  25005. let fontName = (0, _fonts_utils.normalizeFontName)(name);
  25006. const stdFontMap = (0, _standard_fonts.getStdFontMap)(),
  25007. nonStdFontMap = (0, _standard_fonts.getNonStdFontMap)();
  25008. const isStandardFont = !!stdFontMap[fontName];
  25009. const isMappedToStandardFont = !!(nonStdFontMap[fontName] && stdFontMap[nonStdFontMap[fontName]]);
  25010. fontName = stdFontMap[fontName] || nonStdFontMap[fontName] || fontName;
  25011. const fontBasicMetricsMap = (0, _metrics.getFontBasicMetrics)();
  25012. const metrics = fontBasicMetricsMap[fontName];
  25013. if (metrics) {
  25014. if (isNaN(this.ascent)) {
  25015. this.ascent = metrics.ascent / PDF_GLYPH_SPACE_UNITS;
  25016. }
  25017. if (isNaN(this.descent)) {
  25018. this.descent = metrics.descent / PDF_GLYPH_SPACE_UNITS;
  25019. }
  25020. if (isNaN(this.capHeight)) {
  25021. this.capHeight = metrics.capHeight / PDF_GLYPH_SPACE_UNITS;
  25022. }
  25023. }
  25024. this.bold = /bold/gi.test(fontName);
  25025. this.italic = /oblique|italic/gi.test(fontName);
  25026. this.black = /Black/g.test(name);
  25027. const isNarrow = /Narrow/g.test(name);
  25028. this.remeasure = (!isStandardFont || isNarrow) && Object.keys(this.widths).length > 0;
  25029. if ((isStandardFont || isMappedToStandardFont) && type === "CIDFontType2" && this.cidEncoding.startsWith("Identity-")) {
  25030. const cidToGidMap = properties.cidToGidMap;
  25031. const map = [];
  25032. applyStandardFontGlyphMap(map, (0, _standard_fonts.getGlyphMapForStandardFonts)());
  25033. if (/Arial-?Black/i.test(name)) {
  25034. applyStandardFontGlyphMap(map, (0, _standard_fonts.getSupplementalGlyphMapForArialBlack)());
  25035. } else if (/Calibri/i.test(name)) {
  25036. applyStandardFontGlyphMap(map, (0, _standard_fonts.getSupplementalGlyphMapForCalibri)());
  25037. }
  25038. if (cidToGidMap) {
  25039. for (const charCode in map) {
  25040. const cid = map[charCode];
  25041. if (cidToGidMap[cid] !== undefined) {
  25042. map[+charCode] = cidToGidMap[cid];
  25043. }
  25044. }
  25045. if (cidToGidMap.length !== this.toUnicode.length && properties.hasIncludedToUnicodeMap && this.toUnicode instanceof _to_unicode_map.IdentityToUnicodeMap) {
  25046. this.toUnicode.forEach(function (charCode, unicodeCharCode) {
  25047. const cid = map[charCode];
  25048. if (cidToGidMap[cid] === undefined) {
  25049. map[+charCode] = unicodeCharCode;
  25050. }
  25051. });
  25052. }
  25053. }
  25054. if (!(this.toUnicode instanceof _to_unicode_map.IdentityToUnicodeMap)) {
  25055. this.toUnicode.forEach(function (charCode, unicodeCharCode) {
  25056. map[+charCode] = unicodeCharCode;
  25057. });
  25058. }
  25059. this.toFontChar = map;
  25060. this.toUnicode = new _to_unicode_map.ToUnicodeMap(map);
  25061. } else if (/Symbol/i.test(fontName)) {
  25062. this.toFontChar = buildToFontChar(_encodings.SymbolSetEncoding, (0, _glyphlist.getGlyphsUnicode)(), this.differences);
  25063. } else if (/Dingbats/i.test(fontName)) {
  25064. this.toFontChar = buildToFontChar(_encodings.ZapfDingbatsEncoding, (0, _glyphlist.getDingbatsGlyphsUnicode)(), this.differences);
  25065. } else if (isStandardFont) {
  25066. const map = buildToFontChar(this.defaultEncoding, (0, _glyphlist.getGlyphsUnicode)(), this.differences);
  25067. if (type === "CIDFontType2" && !this.cidEncoding.startsWith("Identity-") && !(this.toUnicode instanceof _to_unicode_map.IdentityToUnicodeMap)) {
  25068. this.toUnicode.forEach(function (charCode, unicodeCharCode) {
  25069. map[+charCode] = unicodeCharCode;
  25070. });
  25071. }
  25072. this.toFontChar = map;
  25073. } else {
  25074. const glyphsUnicodeMap = (0, _glyphlist.getGlyphsUnicode)();
  25075. const map = [];
  25076. this.toUnicode.forEach((charCode, unicodeCharCode) => {
  25077. if (!this.composite) {
  25078. const glyphName = this.differences[charCode] || this.defaultEncoding[charCode];
  25079. const unicode = (0, _unicode.getUnicodeForGlyph)(glyphName, glyphsUnicodeMap);
  25080. if (unicode !== -1) {
  25081. unicodeCharCode = unicode;
  25082. }
  25083. }
  25084. map[+charCode] = unicodeCharCode;
  25085. });
  25086. if (this.composite && this.toUnicode instanceof _to_unicode_map.IdentityToUnicodeMap) {
  25087. if (/Tahoma|Verdana/i.test(name)) {
  25088. applyStandardFontGlyphMap(map, (0, _standard_fonts.getGlyphMapForStandardFonts)());
  25089. }
  25090. }
  25091. this.toFontChar = map;
  25092. }
  25093. amendFallbackToUnicode(properties);
  25094. this.loadedName = fontName.split("-")[0];
  25095. }
  25096. checkAndRepair(name, font, properties) {
  25097. const VALID_TABLES = ["OS/2", "cmap", "head", "hhea", "hmtx", "maxp", "name", "post", "loca", "glyf", "fpgm", "prep", "cvt ", "CFF "];
  25098. function readTables(file, numTables) {
  25099. const tables = Object.create(null);
  25100. tables["OS/2"] = null;
  25101. tables.cmap = null;
  25102. tables.head = null;
  25103. tables.hhea = null;
  25104. tables.hmtx = null;
  25105. tables.maxp = null;
  25106. tables.name = null;
  25107. tables.post = null;
  25108. for (let i = 0; i < numTables; i++) {
  25109. const table = readTableEntry(file);
  25110. if (!VALID_TABLES.includes(table.tag)) {
  25111. continue;
  25112. }
  25113. if (table.length === 0) {
  25114. continue;
  25115. }
  25116. tables[table.tag] = table;
  25117. }
  25118. return tables;
  25119. }
  25120. function readTableEntry(file) {
  25121. const tag = file.getString(4);
  25122. const checksum = file.getInt32() >>> 0;
  25123. const offset = file.getInt32() >>> 0;
  25124. const length = file.getInt32() >>> 0;
  25125. const previousPosition = file.pos;
  25126. file.pos = file.start || 0;
  25127. file.skip(offset);
  25128. const data = file.getBytes(length);
  25129. file.pos = previousPosition;
  25130. if (tag === "head") {
  25131. data[8] = data[9] = data[10] = data[11] = 0;
  25132. data[17] |= 0x20;
  25133. }
  25134. return {
  25135. tag,
  25136. checksum,
  25137. length,
  25138. offset,
  25139. data
  25140. };
  25141. }
  25142. function readOpenTypeHeader(ttf) {
  25143. return {
  25144. version: ttf.getString(4),
  25145. numTables: ttf.getUint16(),
  25146. searchRange: ttf.getUint16(),
  25147. entrySelector: ttf.getUint16(),
  25148. rangeShift: ttf.getUint16()
  25149. };
  25150. }
  25151. function readTrueTypeCollectionHeader(ttc) {
  25152. const ttcTag = ttc.getString(4);
  25153. (0, _util.assert)(ttcTag === "ttcf", "Must be a TrueType Collection font.");
  25154. const majorVersion = ttc.getUint16();
  25155. const minorVersion = ttc.getUint16();
  25156. const numFonts = ttc.getInt32() >>> 0;
  25157. const offsetTable = [];
  25158. for (let i = 0; i < numFonts; i++) {
  25159. offsetTable.push(ttc.getInt32() >>> 0);
  25160. }
  25161. const header = {
  25162. ttcTag,
  25163. majorVersion,
  25164. minorVersion,
  25165. numFonts,
  25166. offsetTable
  25167. };
  25168. switch (majorVersion) {
  25169. case 1:
  25170. return header;
  25171. case 2:
  25172. header.dsigTag = ttc.getInt32() >>> 0;
  25173. header.dsigLength = ttc.getInt32() >>> 0;
  25174. header.dsigOffset = ttc.getInt32() >>> 0;
  25175. return header;
  25176. }
  25177. throw new _util.FormatError(`Invalid TrueType Collection majorVersion: ${majorVersion}.`);
  25178. }
  25179. function readTrueTypeCollectionData(ttc, fontName) {
  25180. const {
  25181. numFonts,
  25182. offsetTable
  25183. } = readTrueTypeCollectionHeader(ttc);
  25184. const fontNameParts = fontName.split("+");
  25185. let fallbackData;
  25186. for (let i = 0; i < numFonts; i++) {
  25187. ttc.pos = (ttc.start || 0) + offsetTable[i];
  25188. const potentialHeader = readOpenTypeHeader(ttc);
  25189. const potentialTables = readTables(ttc, potentialHeader.numTables);
  25190. if (!potentialTables.name) {
  25191. throw new _util.FormatError('TrueType Collection font must contain a "name" table.');
  25192. }
  25193. const [nameTable] = readNameTable(potentialTables.name);
  25194. for (let j = 0, jj = nameTable.length; j < jj; j++) {
  25195. for (let k = 0, kk = nameTable[j].length; k < kk; k++) {
  25196. const nameEntry = nameTable[j][k]?.replaceAll(/\s/g, "");
  25197. if (!nameEntry) {
  25198. continue;
  25199. }
  25200. if (nameEntry === fontName) {
  25201. return {
  25202. header: potentialHeader,
  25203. tables: potentialTables
  25204. };
  25205. }
  25206. if (fontNameParts.length < 2) {
  25207. continue;
  25208. }
  25209. for (const part of fontNameParts) {
  25210. if (nameEntry === part) {
  25211. fallbackData = {
  25212. name: part,
  25213. header: potentialHeader,
  25214. tables: potentialTables
  25215. };
  25216. }
  25217. }
  25218. }
  25219. }
  25220. }
  25221. if (fallbackData) {
  25222. (0, _util.warn)(`TrueType Collection does not contain "${fontName}" font, ` + `falling back to "${fallbackData.name}" font instead.`);
  25223. return {
  25224. header: fallbackData.header,
  25225. tables: fallbackData.tables
  25226. };
  25227. }
  25228. throw new _util.FormatError(`TrueType Collection does not contain "${fontName}" font.`);
  25229. }
  25230. function readCmapTable(cmap, file, isSymbolicFont, hasEncoding) {
  25231. if (!cmap) {
  25232. (0, _util.warn)("No cmap table available.");
  25233. return {
  25234. platformId: -1,
  25235. encodingId: -1,
  25236. mappings: [],
  25237. hasShortCmap: false
  25238. };
  25239. }
  25240. let segment;
  25241. let start = (file.start || 0) + cmap.offset;
  25242. file.pos = start;
  25243. file.skip(2);
  25244. const numTables = file.getUint16();
  25245. let potentialTable;
  25246. let canBreak = false;
  25247. for (let i = 0; i < numTables; i++) {
  25248. const platformId = file.getUint16();
  25249. const encodingId = file.getUint16();
  25250. const offset = file.getInt32() >>> 0;
  25251. let useTable = false;
  25252. if (potentialTable?.platformId === platformId && potentialTable?.encodingId === encodingId) {
  25253. continue;
  25254. }
  25255. if (platformId === 0 && (encodingId === 0 || encodingId === 1 || encodingId === 3)) {
  25256. useTable = true;
  25257. } else if (platformId === 1 && encodingId === 0) {
  25258. useTable = true;
  25259. } else if (platformId === 3 && encodingId === 1 && (hasEncoding || !potentialTable)) {
  25260. useTable = true;
  25261. if (!isSymbolicFont) {
  25262. canBreak = true;
  25263. }
  25264. } else if (isSymbolicFont && platformId === 3 && encodingId === 0) {
  25265. useTable = true;
  25266. let correctlySorted = true;
  25267. if (i < numTables - 1) {
  25268. const nextBytes = file.peekBytes(2),
  25269. nextPlatformId = int16(nextBytes[0], nextBytes[1]);
  25270. if (nextPlatformId < platformId) {
  25271. correctlySorted = false;
  25272. }
  25273. }
  25274. if (correctlySorted) {
  25275. canBreak = true;
  25276. }
  25277. }
  25278. if (useTable) {
  25279. potentialTable = {
  25280. platformId,
  25281. encodingId,
  25282. offset
  25283. };
  25284. }
  25285. if (canBreak) {
  25286. break;
  25287. }
  25288. }
  25289. if (potentialTable) {
  25290. file.pos = start + potentialTable.offset;
  25291. }
  25292. if (!potentialTable || file.peekByte() === -1) {
  25293. (0, _util.warn)("Could not find a preferred cmap table.");
  25294. return {
  25295. platformId: -1,
  25296. encodingId: -1,
  25297. mappings: [],
  25298. hasShortCmap: false
  25299. };
  25300. }
  25301. const format = file.getUint16();
  25302. let hasShortCmap = false;
  25303. const mappings = [];
  25304. let j, glyphId;
  25305. if (format === 0) {
  25306. file.skip(2 + 2);
  25307. for (j = 0; j < 256; j++) {
  25308. const index = file.getByte();
  25309. if (!index) {
  25310. continue;
  25311. }
  25312. mappings.push({
  25313. charCode: j,
  25314. glyphId: index
  25315. });
  25316. }
  25317. hasShortCmap = true;
  25318. } else if (format === 2) {
  25319. file.skip(2 + 2);
  25320. const subHeaderKeys = [];
  25321. let maxSubHeaderKey = 0;
  25322. for (let i = 0; i < 256; i++) {
  25323. const subHeaderKey = file.getUint16() >> 3;
  25324. subHeaderKeys.push(subHeaderKey);
  25325. maxSubHeaderKey = Math.max(subHeaderKey, maxSubHeaderKey);
  25326. }
  25327. const subHeaders = [];
  25328. for (let i = 0; i <= maxSubHeaderKey; i++) {
  25329. subHeaders.push({
  25330. firstCode: file.getUint16(),
  25331. entryCount: file.getUint16(),
  25332. idDelta: signedInt16(file.getByte(), file.getByte()),
  25333. idRangePos: file.pos + file.getUint16()
  25334. });
  25335. }
  25336. for (let i = 0; i < 256; i++) {
  25337. if (subHeaderKeys[i] === 0) {
  25338. file.pos = subHeaders[0].idRangePos + 2 * i;
  25339. glyphId = file.getUint16();
  25340. mappings.push({
  25341. charCode: i,
  25342. glyphId
  25343. });
  25344. } else {
  25345. const s = subHeaders[subHeaderKeys[i]];
  25346. for (j = 0; j < s.entryCount; j++) {
  25347. const charCode = (i << 8) + j + s.firstCode;
  25348. file.pos = s.idRangePos + 2 * j;
  25349. glyphId = file.getUint16();
  25350. if (glyphId !== 0) {
  25351. glyphId = (glyphId + s.idDelta) % 65536;
  25352. }
  25353. mappings.push({
  25354. charCode,
  25355. glyphId
  25356. });
  25357. }
  25358. }
  25359. }
  25360. } else if (format === 4) {
  25361. file.skip(2 + 2);
  25362. const segCount = file.getUint16() >> 1;
  25363. file.skip(6);
  25364. const segments = [];
  25365. let segIndex;
  25366. for (segIndex = 0; segIndex < segCount; segIndex++) {
  25367. segments.push({
  25368. end: file.getUint16()
  25369. });
  25370. }
  25371. file.skip(2);
  25372. for (segIndex = 0; segIndex < segCount; segIndex++) {
  25373. segments[segIndex].start = file.getUint16();
  25374. }
  25375. for (segIndex = 0; segIndex < segCount; segIndex++) {
  25376. segments[segIndex].delta = file.getUint16();
  25377. }
  25378. let offsetsCount = 0,
  25379. offsetIndex;
  25380. for (segIndex = 0; segIndex < segCount; segIndex++) {
  25381. segment = segments[segIndex];
  25382. const rangeOffset = file.getUint16();
  25383. if (!rangeOffset) {
  25384. segment.offsetIndex = -1;
  25385. continue;
  25386. }
  25387. offsetIndex = (rangeOffset >> 1) - (segCount - segIndex);
  25388. segment.offsetIndex = offsetIndex;
  25389. offsetsCount = Math.max(offsetsCount, offsetIndex + segment.end - segment.start + 1);
  25390. }
  25391. const offsets = [];
  25392. for (j = 0; j < offsetsCount; j++) {
  25393. offsets.push(file.getUint16());
  25394. }
  25395. for (segIndex = 0; segIndex < segCount; segIndex++) {
  25396. segment = segments[segIndex];
  25397. start = segment.start;
  25398. const end = segment.end;
  25399. const delta = segment.delta;
  25400. offsetIndex = segment.offsetIndex;
  25401. for (j = start; j <= end; j++) {
  25402. if (j === 0xffff) {
  25403. continue;
  25404. }
  25405. glyphId = offsetIndex < 0 ? j : offsets[offsetIndex + j - start];
  25406. glyphId = glyphId + delta & 0xffff;
  25407. mappings.push({
  25408. charCode: j,
  25409. glyphId
  25410. });
  25411. }
  25412. }
  25413. } else if (format === 6) {
  25414. file.skip(2 + 2);
  25415. const firstCode = file.getUint16();
  25416. const entryCount = file.getUint16();
  25417. for (j = 0; j < entryCount; j++) {
  25418. glyphId = file.getUint16();
  25419. const charCode = firstCode + j;
  25420. mappings.push({
  25421. charCode,
  25422. glyphId
  25423. });
  25424. }
  25425. } else if (format === 12) {
  25426. file.skip(2 + 4 + 4);
  25427. const nGroups = file.getInt32() >>> 0;
  25428. for (j = 0; j < nGroups; j++) {
  25429. const startCharCode = file.getInt32() >>> 0;
  25430. const endCharCode = file.getInt32() >>> 0;
  25431. let glyphCode = file.getInt32() >>> 0;
  25432. for (let charCode = startCharCode; charCode <= endCharCode; charCode++) {
  25433. mappings.push({
  25434. charCode,
  25435. glyphId: glyphCode++
  25436. });
  25437. }
  25438. }
  25439. } else {
  25440. (0, _util.warn)("cmap table has unsupported format: " + format);
  25441. return {
  25442. platformId: -1,
  25443. encodingId: -1,
  25444. mappings: [],
  25445. hasShortCmap: false
  25446. };
  25447. }
  25448. mappings.sort(function (a, b) {
  25449. return a.charCode - b.charCode;
  25450. });
  25451. for (let i = 1; i < mappings.length; i++) {
  25452. if (mappings[i - 1].charCode === mappings[i].charCode) {
  25453. mappings.splice(i, 1);
  25454. i--;
  25455. }
  25456. }
  25457. return {
  25458. platformId: potentialTable.platformId,
  25459. encodingId: potentialTable.encodingId,
  25460. mappings,
  25461. hasShortCmap
  25462. };
  25463. }
  25464. function sanitizeMetrics(file, header, metrics, headTable, numGlyphs, dupFirstEntry) {
  25465. if (!header) {
  25466. if (metrics) {
  25467. metrics.data = null;
  25468. }
  25469. return;
  25470. }
  25471. file.pos = (file.start || 0) + header.offset;
  25472. file.pos += 4;
  25473. file.pos += 2;
  25474. file.pos += 2;
  25475. file.pos += 2;
  25476. file.pos += 2;
  25477. file.pos += 2;
  25478. file.pos += 2;
  25479. file.pos += 2;
  25480. file.pos += 2;
  25481. file.pos += 2;
  25482. const caretOffset = file.getUint16();
  25483. file.pos += 8;
  25484. file.pos += 2;
  25485. let numOfMetrics = file.getUint16();
  25486. if (caretOffset !== 0) {
  25487. const macStyle = int16(headTable.data[44], headTable.data[45]);
  25488. if (!(macStyle & 2)) {
  25489. header.data[22] = 0;
  25490. header.data[23] = 0;
  25491. }
  25492. }
  25493. if (numOfMetrics > numGlyphs) {
  25494. (0, _util.info)(`The numOfMetrics (${numOfMetrics}) should not be ` + `greater than the numGlyphs (${numGlyphs}).`);
  25495. numOfMetrics = numGlyphs;
  25496. header.data[34] = (numOfMetrics & 0xff00) >> 8;
  25497. header.data[35] = numOfMetrics & 0x00ff;
  25498. }
  25499. const numOfSidebearings = numGlyphs - numOfMetrics;
  25500. const numMissing = numOfSidebearings - (metrics.length - numOfMetrics * 4 >> 1);
  25501. if (numMissing > 0) {
  25502. const entries = new Uint8Array(metrics.length + numMissing * 2);
  25503. entries.set(metrics.data);
  25504. if (dupFirstEntry) {
  25505. entries[metrics.length] = metrics.data[2];
  25506. entries[metrics.length + 1] = metrics.data[3];
  25507. }
  25508. metrics.data = entries;
  25509. }
  25510. }
  25511. function sanitizeGlyph(source, sourceStart, sourceEnd, dest, destStart, hintsValid) {
  25512. const glyphProfile = {
  25513. length: 0,
  25514. sizeOfInstructions: 0
  25515. };
  25516. if (sourceStart < 0 || sourceStart >= source.length || sourceEnd > source.length || sourceEnd - sourceStart <= 12) {
  25517. return glyphProfile;
  25518. }
  25519. const glyf = source.subarray(sourceStart, sourceEnd);
  25520. const xMin = signedInt16(glyf[2], glyf[3]);
  25521. const yMin = signedInt16(glyf[4], glyf[5]);
  25522. const xMax = signedInt16(glyf[6], glyf[7]);
  25523. const yMax = signedInt16(glyf[8], glyf[9]);
  25524. if (xMin > xMax) {
  25525. writeSignedInt16(glyf, 2, xMax);
  25526. writeSignedInt16(glyf, 6, xMin);
  25527. }
  25528. if (yMin > yMax) {
  25529. writeSignedInt16(glyf, 4, yMax);
  25530. writeSignedInt16(glyf, 8, yMin);
  25531. }
  25532. const contoursCount = signedInt16(glyf[0], glyf[1]);
  25533. if (contoursCount < 0) {
  25534. if (contoursCount < -1) {
  25535. return glyphProfile;
  25536. }
  25537. dest.set(glyf, destStart);
  25538. glyphProfile.length = glyf.length;
  25539. return glyphProfile;
  25540. }
  25541. let i,
  25542. j = 10,
  25543. flagsCount = 0;
  25544. for (i = 0; i < contoursCount; i++) {
  25545. const endPoint = glyf[j] << 8 | glyf[j + 1];
  25546. flagsCount = endPoint + 1;
  25547. j += 2;
  25548. }
  25549. const instructionsStart = j;
  25550. const instructionsLength = glyf[j] << 8 | glyf[j + 1];
  25551. glyphProfile.sizeOfInstructions = instructionsLength;
  25552. j += 2 + instructionsLength;
  25553. const instructionsEnd = j;
  25554. let coordinatesLength = 0;
  25555. for (i = 0; i < flagsCount; i++) {
  25556. const flag = glyf[j++];
  25557. if (flag & 0xc0) {
  25558. glyf[j - 1] = flag & 0x3f;
  25559. }
  25560. let xLength = 2;
  25561. if (flag & 2) {
  25562. xLength = 1;
  25563. } else if (flag & 16) {
  25564. xLength = 0;
  25565. }
  25566. let yLength = 2;
  25567. if (flag & 4) {
  25568. yLength = 1;
  25569. } else if (flag & 32) {
  25570. yLength = 0;
  25571. }
  25572. const xyLength = xLength + yLength;
  25573. coordinatesLength += xyLength;
  25574. if (flag & 8) {
  25575. const repeat = glyf[j++];
  25576. if (repeat === 0) {
  25577. glyf[j - 1] ^= 8;
  25578. }
  25579. i += repeat;
  25580. coordinatesLength += repeat * xyLength;
  25581. }
  25582. }
  25583. if (coordinatesLength === 0) {
  25584. return glyphProfile;
  25585. }
  25586. let glyphDataLength = j + coordinatesLength;
  25587. if (glyphDataLength > glyf.length) {
  25588. return glyphProfile;
  25589. }
  25590. if (!hintsValid && instructionsLength > 0) {
  25591. dest.set(glyf.subarray(0, instructionsStart), destStart);
  25592. dest.set([0, 0], destStart + instructionsStart);
  25593. dest.set(glyf.subarray(instructionsEnd, glyphDataLength), destStart + instructionsStart + 2);
  25594. glyphDataLength -= instructionsLength;
  25595. if (glyf.length - glyphDataLength > 3) {
  25596. glyphDataLength = glyphDataLength + 3 & ~3;
  25597. }
  25598. glyphProfile.length = glyphDataLength;
  25599. return glyphProfile;
  25600. }
  25601. if (glyf.length - glyphDataLength > 3) {
  25602. glyphDataLength = glyphDataLength + 3 & ~3;
  25603. dest.set(glyf.subarray(0, glyphDataLength), destStart);
  25604. glyphProfile.length = glyphDataLength;
  25605. return glyphProfile;
  25606. }
  25607. dest.set(glyf, destStart);
  25608. glyphProfile.length = glyf.length;
  25609. return glyphProfile;
  25610. }
  25611. function sanitizeHead(head, numGlyphs, locaLength) {
  25612. const data = head.data;
  25613. const version = int32(data[0], data[1], data[2], data[3]);
  25614. if (version >> 16 !== 1) {
  25615. (0, _util.info)("Attempting to fix invalid version in head table: " + version);
  25616. data[0] = 0;
  25617. data[1] = 1;
  25618. data[2] = 0;
  25619. data[3] = 0;
  25620. }
  25621. const indexToLocFormat = int16(data[50], data[51]);
  25622. if (indexToLocFormat < 0 || indexToLocFormat > 1) {
  25623. (0, _util.info)("Attempting to fix invalid indexToLocFormat in head table: " + indexToLocFormat);
  25624. const numGlyphsPlusOne = numGlyphs + 1;
  25625. if (locaLength === numGlyphsPlusOne << 1) {
  25626. data[50] = 0;
  25627. data[51] = 0;
  25628. } else if (locaLength === numGlyphsPlusOne << 2) {
  25629. data[50] = 0;
  25630. data[51] = 1;
  25631. } else {
  25632. throw new _util.FormatError("Could not fix indexToLocFormat: " + indexToLocFormat);
  25633. }
  25634. }
  25635. }
  25636. function sanitizeGlyphLocations(loca, glyf, numGlyphs, isGlyphLocationsLong, hintsValid, dupFirstEntry, maxSizeOfInstructions) {
  25637. let itemSize, itemDecode, itemEncode;
  25638. if (isGlyphLocationsLong) {
  25639. itemSize = 4;
  25640. itemDecode = function fontItemDecodeLong(data, offset) {
  25641. return data[offset] << 24 | data[offset + 1] << 16 | data[offset + 2] << 8 | data[offset + 3];
  25642. };
  25643. itemEncode = function fontItemEncodeLong(data, offset, value) {
  25644. data[offset] = value >>> 24 & 0xff;
  25645. data[offset + 1] = value >> 16 & 0xff;
  25646. data[offset + 2] = value >> 8 & 0xff;
  25647. data[offset + 3] = value & 0xff;
  25648. };
  25649. } else {
  25650. itemSize = 2;
  25651. itemDecode = function fontItemDecode(data, offset) {
  25652. return data[offset] << 9 | data[offset + 1] << 1;
  25653. };
  25654. itemEncode = function fontItemEncode(data, offset, value) {
  25655. data[offset] = value >> 9 & 0xff;
  25656. data[offset + 1] = value >> 1 & 0xff;
  25657. };
  25658. }
  25659. const numGlyphsOut = dupFirstEntry ? numGlyphs + 1 : numGlyphs;
  25660. const locaDataSize = itemSize * (1 + numGlyphsOut);
  25661. const locaData = new Uint8Array(locaDataSize);
  25662. locaData.set(loca.data.subarray(0, locaDataSize));
  25663. loca.data = locaData;
  25664. const oldGlyfData = glyf.data;
  25665. const oldGlyfDataLength = oldGlyfData.length;
  25666. const newGlyfData = new Uint8Array(oldGlyfDataLength);
  25667. let i, j;
  25668. const locaEntries = [];
  25669. for (i = 0, j = 0; i < numGlyphs + 1; i++, j += itemSize) {
  25670. let offset = itemDecode(locaData, j);
  25671. if (offset > oldGlyfDataLength) {
  25672. offset = oldGlyfDataLength;
  25673. }
  25674. locaEntries.push({
  25675. index: i,
  25676. offset,
  25677. endOffset: 0
  25678. });
  25679. }
  25680. locaEntries.sort((a, b) => {
  25681. return a.offset - b.offset;
  25682. });
  25683. for (i = 0; i < numGlyphs; i++) {
  25684. locaEntries[i].endOffset = locaEntries[i + 1].offset;
  25685. }
  25686. locaEntries.sort((a, b) => {
  25687. return a.index - b.index;
  25688. });
  25689. for (i = 0; i < numGlyphs; i++) {
  25690. const {
  25691. offset,
  25692. endOffset
  25693. } = locaEntries[i];
  25694. if (offset !== 0 || endOffset !== 0) {
  25695. break;
  25696. }
  25697. const nextOffset = locaEntries[i + 1].offset;
  25698. if (nextOffset === 0) {
  25699. continue;
  25700. }
  25701. locaEntries[i].endOffset = nextOffset;
  25702. break;
  25703. }
  25704. const missingGlyphs = Object.create(null);
  25705. let writeOffset = 0;
  25706. itemEncode(locaData, 0, writeOffset);
  25707. for (i = 0, j = itemSize; i < numGlyphs; i++, j += itemSize) {
  25708. const glyphProfile = sanitizeGlyph(oldGlyfData, locaEntries[i].offset, locaEntries[i].endOffset, newGlyfData, writeOffset, hintsValid);
  25709. const newLength = glyphProfile.length;
  25710. if (newLength === 0) {
  25711. missingGlyphs[i] = true;
  25712. }
  25713. if (glyphProfile.sizeOfInstructions > maxSizeOfInstructions) {
  25714. maxSizeOfInstructions = glyphProfile.sizeOfInstructions;
  25715. }
  25716. writeOffset += newLength;
  25717. itemEncode(locaData, j, writeOffset);
  25718. }
  25719. if (writeOffset === 0) {
  25720. const simpleGlyph = new Uint8Array([0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 49, 0]);
  25721. for (i = 0, j = itemSize; i < numGlyphsOut; i++, j += itemSize) {
  25722. itemEncode(locaData, j, simpleGlyph.length);
  25723. }
  25724. glyf.data = simpleGlyph;
  25725. } else if (dupFirstEntry) {
  25726. const firstEntryLength = itemDecode(locaData, itemSize);
  25727. if (newGlyfData.length > firstEntryLength + writeOffset) {
  25728. glyf.data = newGlyfData.subarray(0, firstEntryLength + writeOffset);
  25729. } else {
  25730. glyf.data = new Uint8Array(firstEntryLength + writeOffset);
  25731. glyf.data.set(newGlyfData.subarray(0, writeOffset));
  25732. }
  25733. glyf.data.set(newGlyfData.subarray(0, firstEntryLength), writeOffset);
  25734. itemEncode(loca.data, locaData.length - itemSize, writeOffset + firstEntryLength);
  25735. } else {
  25736. glyf.data = newGlyfData.subarray(0, writeOffset);
  25737. }
  25738. return {
  25739. missingGlyphs,
  25740. maxSizeOfInstructions
  25741. };
  25742. }
  25743. function readPostScriptTable(post, propertiesObj, maxpNumGlyphs) {
  25744. const start = (font.start || 0) + post.offset;
  25745. font.pos = start;
  25746. const length = post.length,
  25747. end = start + length;
  25748. const version = font.getInt32();
  25749. font.skip(28);
  25750. let glyphNames;
  25751. let valid = true;
  25752. let i;
  25753. switch (version) {
  25754. case 0x00010000:
  25755. glyphNames = _fonts_utils.MacStandardGlyphOrdering;
  25756. break;
  25757. case 0x00020000:
  25758. const numGlyphs = font.getUint16();
  25759. if (numGlyphs !== maxpNumGlyphs) {
  25760. valid = false;
  25761. break;
  25762. }
  25763. const glyphNameIndexes = [];
  25764. for (i = 0; i < numGlyphs; ++i) {
  25765. const index = font.getUint16();
  25766. if (index >= 32768) {
  25767. valid = false;
  25768. break;
  25769. }
  25770. glyphNameIndexes.push(index);
  25771. }
  25772. if (!valid) {
  25773. break;
  25774. }
  25775. const customNames = [],
  25776. strBuf = [];
  25777. while (font.pos < end) {
  25778. const stringLength = font.getByte();
  25779. strBuf.length = stringLength;
  25780. for (i = 0; i < stringLength; ++i) {
  25781. strBuf[i] = String.fromCharCode(font.getByte());
  25782. }
  25783. customNames.push(strBuf.join(""));
  25784. }
  25785. glyphNames = [];
  25786. for (i = 0; i < numGlyphs; ++i) {
  25787. const j = glyphNameIndexes[i];
  25788. if (j < 258) {
  25789. glyphNames.push(_fonts_utils.MacStandardGlyphOrdering[j]);
  25790. continue;
  25791. }
  25792. glyphNames.push(customNames[j - 258]);
  25793. }
  25794. break;
  25795. case 0x00030000:
  25796. break;
  25797. default:
  25798. (0, _util.warn)("Unknown/unsupported post table version " + version);
  25799. valid = false;
  25800. if (propertiesObj.defaultEncoding) {
  25801. glyphNames = propertiesObj.defaultEncoding;
  25802. }
  25803. break;
  25804. }
  25805. propertiesObj.glyphNames = glyphNames;
  25806. return valid;
  25807. }
  25808. function readNameTable(nameTable) {
  25809. const start = (font.start || 0) + nameTable.offset;
  25810. font.pos = start;
  25811. const names = [[], []],
  25812. records = [];
  25813. const length = nameTable.length,
  25814. end = start + length;
  25815. const format = font.getUint16();
  25816. const FORMAT_0_HEADER_LENGTH = 6;
  25817. if (format !== 0 || length < FORMAT_0_HEADER_LENGTH) {
  25818. return [names, records];
  25819. }
  25820. const numRecords = font.getUint16();
  25821. const stringsStart = font.getUint16();
  25822. const NAME_RECORD_LENGTH = 12;
  25823. let i, ii;
  25824. for (i = 0; i < numRecords && font.pos + NAME_RECORD_LENGTH <= end; i++) {
  25825. const r = {
  25826. platform: font.getUint16(),
  25827. encoding: font.getUint16(),
  25828. language: font.getUint16(),
  25829. name: font.getUint16(),
  25830. length: font.getUint16(),
  25831. offset: font.getUint16()
  25832. };
  25833. if (isMacNameRecord(r) || isWinNameRecord(r)) {
  25834. records.push(r);
  25835. }
  25836. }
  25837. for (i = 0, ii = records.length; i < ii; i++) {
  25838. const record = records[i];
  25839. if (record.length <= 0) {
  25840. continue;
  25841. }
  25842. const pos = start + stringsStart + record.offset;
  25843. if (pos + record.length > end) {
  25844. continue;
  25845. }
  25846. font.pos = pos;
  25847. const nameIndex = record.name;
  25848. if (record.encoding) {
  25849. let str = "";
  25850. for (let j = 0, jj = record.length; j < jj; j += 2) {
  25851. str += String.fromCharCode(font.getUint16());
  25852. }
  25853. names[1][nameIndex] = str;
  25854. } else {
  25855. names[0][nameIndex] = font.getString(record.length);
  25856. }
  25857. }
  25858. return [names, records];
  25859. }
  25860. 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];
  25861. function sanitizeTTProgram(table, ttContext) {
  25862. let data = table.data;
  25863. let i = 0,
  25864. j,
  25865. n,
  25866. b,
  25867. funcId,
  25868. pc,
  25869. lastEndf = 0,
  25870. lastDeff = 0;
  25871. const stack = [];
  25872. const callstack = [];
  25873. const functionsCalled = [];
  25874. let tooComplexToFollowFunctions = ttContext.tooComplexToFollowFunctions;
  25875. let inFDEF = false,
  25876. ifLevel = 0,
  25877. inELSE = 0;
  25878. for (let ii = data.length; i < ii;) {
  25879. const op = data[i++];
  25880. if (op === 0x40) {
  25881. n = data[i++];
  25882. if (inFDEF || inELSE) {
  25883. i += n;
  25884. } else {
  25885. for (j = 0; j < n; j++) {
  25886. stack.push(data[i++]);
  25887. }
  25888. }
  25889. } else if (op === 0x41) {
  25890. n = data[i++];
  25891. if (inFDEF || inELSE) {
  25892. i += n * 2;
  25893. } else {
  25894. for (j = 0; j < n; j++) {
  25895. b = data[i++];
  25896. stack.push(b << 8 | data[i++]);
  25897. }
  25898. }
  25899. } else if ((op & 0xf8) === 0xb0) {
  25900. n = op - 0xb0 + 1;
  25901. if (inFDEF || inELSE) {
  25902. i += n;
  25903. } else {
  25904. for (j = 0; j < n; j++) {
  25905. stack.push(data[i++]);
  25906. }
  25907. }
  25908. } else if ((op & 0xf8) === 0xb8) {
  25909. n = op - 0xb8 + 1;
  25910. if (inFDEF || inELSE) {
  25911. i += n * 2;
  25912. } else {
  25913. for (j = 0; j < n; j++) {
  25914. b = data[i++];
  25915. stack.push(b << 8 | data[i++]);
  25916. }
  25917. }
  25918. } else if (op === 0x2b && !tooComplexToFollowFunctions) {
  25919. if (!inFDEF && !inELSE) {
  25920. funcId = stack.at(-1);
  25921. if (isNaN(funcId)) {
  25922. (0, _util.info)("TT: CALL empty stack (or invalid entry).");
  25923. } else {
  25924. ttContext.functionsUsed[funcId] = true;
  25925. if (funcId in ttContext.functionsStackDeltas) {
  25926. const newStackLength = stack.length + ttContext.functionsStackDeltas[funcId];
  25927. if (newStackLength < 0) {
  25928. (0, _util.warn)("TT: CALL invalid functions stack delta.");
  25929. ttContext.hintsValid = false;
  25930. return;
  25931. }
  25932. stack.length = newStackLength;
  25933. } else if (funcId in ttContext.functionsDefined && !functionsCalled.includes(funcId)) {
  25934. callstack.push({
  25935. data,
  25936. i,
  25937. stackTop: stack.length - 1
  25938. });
  25939. functionsCalled.push(funcId);
  25940. pc = ttContext.functionsDefined[funcId];
  25941. if (!pc) {
  25942. (0, _util.warn)("TT: CALL non-existent function");
  25943. ttContext.hintsValid = false;
  25944. return;
  25945. }
  25946. data = pc.data;
  25947. i = pc.i;
  25948. }
  25949. }
  25950. }
  25951. } else if (op === 0x2c && !tooComplexToFollowFunctions) {
  25952. if (inFDEF || inELSE) {
  25953. (0, _util.warn)("TT: nested FDEFs not allowed");
  25954. tooComplexToFollowFunctions = true;
  25955. }
  25956. inFDEF = true;
  25957. lastDeff = i;
  25958. funcId = stack.pop();
  25959. ttContext.functionsDefined[funcId] = {
  25960. data,
  25961. i
  25962. };
  25963. } else if (op === 0x2d) {
  25964. if (inFDEF) {
  25965. inFDEF = false;
  25966. lastEndf = i;
  25967. } else {
  25968. pc = callstack.pop();
  25969. if (!pc) {
  25970. (0, _util.warn)("TT: ENDF bad stack");
  25971. ttContext.hintsValid = false;
  25972. return;
  25973. }
  25974. funcId = functionsCalled.pop();
  25975. data = pc.data;
  25976. i = pc.i;
  25977. ttContext.functionsStackDeltas[funcId] = stack.length - pc.stackTop;
  25978. }
  25979. } else if (op === 0x89) {
  25980. if (inFDEF || inELSE) {
  25981. (0, _util.warn)("TT: nested IDEFs not allowed");
  25982. tooComplexToFollowFunctions = true;
  25983. }
  25984. inFDEF = true;
  25985. lastDeff = i;
  25986. } else if (op === 0x58) {
  25987. ++ifLevel;
  25988. } else if (op === 0x1b) {
  25989. inELSE = ifLevel;
  25990. } else if (op === 0x59) {
  25991. if (inELSE === ifLevel) {
  25992. inELSE = 0;
  25993. }
  25994. --ifLevel;
  25995. } else if (op === 0x1c) {
  25996. if (!inFDEF && !inELSE) {
  25997. const offset = stack.at(-1);
  25998. if (offset > 0) {
  25999. i += offset - 1;
  26000. }
  26001. }
  26002. }
  26003. if (!inFDEF && !inELSE) {
  26004. let stackDelta = 0;
  26005. if (op <= 0x8e) {
  26006. stackDelta = TTOpsStackDeltas[op];
  26007. } else if (op >= 0xc0 && op <= 0xdf) {
  26008. stackDelta = -1;
  26009. } else if (op >= 0xe0) {
  26010. stackDelta = -2;
  26011. }
  26012. if (op >= 0x71 && op <= 0x75) {
  26013. n = stack.pop();
  26014. if (!isNaN(n)) {
  26015. stackDelta = -n * 2;
  26016. }
  26017. }
  26018. while (stackDelta < 0 && stack.length > 0) {
  26019. stack.pop();
  26020. stackDelta++;
  26021. }
  26022. while (stackDelta > 0) {
  26023. stack.push(NaN);
  26024. stackDelta--;
  26025. }
  26026. }
  26027. }
  26028. ttContext.tooComplexToFollowFunctions = tooComplexToFollowFunctions;
  26029. const content = [data];
  26030. if (i > data.length) {
  26031. content.push(new Uint8Array(i - data.length));
  26032. }
  26033. if (lastDeff > lastEndf) {
  26034. (0, _util.warn)("TT: complementing a missing function tail");
  26035. content.push(new Uint8Array([0x22, 0x2d]));
  26036. }
  26037. foldTTTable(table, content);
  26038. }
  26039. function checkInvalidFunctions(ttContext, maxFunctionDefs) {
  26040. if (ttContext.tooComplexToFollowFunctions) {
  26041. return;
  26042. }
  26043. if (ttContext.functionsDefined.length > maxFunctionDefs) {
  26044. (0, _util.warn)("TT: more functions defined than expected");
  26045. ttContext.hintsValid = false;
  26046. return;
  26047. }
  26048. for (let j = 0, jj = ttContext.functionsUsed.length; j < jj; j++) {
  26049. if (j > maxFunctionDefs) {
  26050. (0, _util.warn)("TT: invalid function id: " + j);
  26051. ttContext.hintsValid = false;
  26052. return;
  26053. }
  26054. if (ttContext.functionsUsed[j] && !ttContext.functionsDefined[j]) {
  26055. (0, _util.warn)("TT: undefined function: " + j);
  26056. ttContext.hintsValid = false;
  26057. return;
  26058. }
  26059. }
  26060. }
  26061. function foldTTTable(table, content) {
  26062. if (content.length > 1) {
  26063. let newLength = 0;
  26064. let j, jj;
  26065. for (j = 0, jj = content.length; j < jj; j++) {
  26066. newLength += content[j].length;
  26067. }
  26068. newLength = newLength + 3 & ~3;
  26069. const result = new Uint8Array(newLength);
  26070. let pos = 0;
  26071. for (j = 0, jj = content.length; j < jj; j++) {
  26072. result.set(content[j], pos);
  26073. pos += content[j].length;
  26074. }
  26075. table.data = result;
  26076. table.length = newLength;
  26077. }
  26078. }
  26079. function sanitizeTTPrograms(fpgm, prep, cvt, maxFunctionDefs) {
  26080. const ttContext = {
  26081. functionsDefined: [],
  26082. functionsUsed: [],
  26083. functionsStackDeltas: [],
  26084. tooComplexToFollowFunctions: false,
  26085. hintsValid: true
  26086. };
  26087. if (fpgm) {
  26088. sanitizeTTProgram(fpgm, ttContext);
  26089. }
  26090. if (prep) {
  26091. sanitizeTTProgram(prep, ttContext);
  26092. }
  26093. if (fpgm) {
  26094. checkInvalidFunctions(ttContext, maxFunctionDefs);
  26095. }
  26096. if (cvt && cvt.length & 1) {
  26097. const cvtData = new Uint8Array(cvt.length + 1);
  26098. cvtData.set(cvt.data);
  26099. cvt.data = cvtData;
  26100. }
  26101. return ttContext.hintsValid;
  26102. }
  26103. font = new _stream.Stream(new Uint8Array(font.getBytes()));
  26104. let header, tables;
  26105. if (isTrueTypeCollectionFile(font)) {
  26106. const ttcData = readTrueTypeCollectionData(font, this.name);
  26107. header = ttcData.header;
  26108. tables = ttcData.tables;
  26109. } else {
  26110. header = readOpenTypeHeader(font);
  26111. tables = readTables(font, header.numTables);
  26112. }
  26113. let cff, cffFile;
  26114. const isTrueType = !tables["CFF "];
  26115. if (!isTrueType) {
  26116. const isComposite = properties.composite && (properties.cidToGidMap?.length > 0 || !(properties.cMap instanceof _cmap.IdentityCMap));
  26117. if (header.version === "OTTO" && !isComposite || !tables.head || !tables.hhea || !tables.maxp || !tables.post) {
  26118. cffFile = new _stream.Stream(tables["CFF "].data);
  26119. cff = new _cff_font.CFFFont(cffFile, properties);
  26120. adjustWidths(properties);
  26121. return this.convert(name, cff, properties);
  26122. }
  26123. delete tables.glyf;
  26124. delete tables.loca;
  26125. delete tables.fpgm;
  26126. delete tables.prep;
  26127. delete tables["cvt "];
  26128. this.isOpenType = true;
  26129. } else {
  26130. if (!tables.loca) {
  26131. throw new _util.FormatError('Required "loca" table is not found');
  26132. }
  26133. if (!tables.glyf) {
  26134. (0, _util.warn)('Required "glyf" table is not found -- trying to recover.');
  26135. tables.glyf = {
  26136. tag: "glyf",
  26137. data: new Uint8Array(0)
  26138. };
  26139. }
  26140. this.isOpenType = false;
  26141. }
  26142. if (!tables.maxp) {
  26143. throw new _util.FormatError('Required "maxp" table is not found');
  26144. }
  26145. font.pos = (font.start || 0) + tables.maxp.offset;
  26146. const version = font.getInt32();
  26147. const numGlyphs = font.getUint16();
  26148. if (properties.scaleFactors?.length === numGlyphs && isTrueType) {
  26149. const {
  26150. scaleFactors
  26151. } = properties;
  26152. const isGlyphLocationsLong = int16(tables.head.data[50], tables.head.data[51]);
  26153. const glyphs = new _glyf.GlyfTable({
  26154. glyfTable: tables.glyf.data,
  26155. isGlyphLocationsLong,
  26156. locaTable: tables.loca.data,
  26157. numGlyphs
  26158. });
  26159. glyphs.scale(scaleFactors);
  26160. const {
  26161. glyf,
  26162. loca,
  26163. isLocationLong
  26164. } = glyphs.write();
  26165. tables.glyf.data = glyf;
  26166. tables.loca.data = loca;
  26167. if (isLocationLong !== !!isGlyphLocationsLong) {
  26168. tables.head.data[50] = 0;
  26169. tables.head.data[51] = isLocationLong ? 1 : 0;
  26170. }
  26171. const metrics = tables.hmtx.data;
  26172. for (let i = 0; i < numGlyphs; i++) {
  26173. const j = 4 * i;
  26174. const advanceWidth = Math.round(scaleFactors[i] * int16(metrics[j], metrics[j + 1]));
  26175. metrics[j] = advanceWidth >> 8 & 0xff;
  26176. metrics[j + 1] = advanceWidth & 0xff;
  26177. const lsb = Math.round(scaleFactors[i] * signedInt16(metrics[j + 2], metrics[j + 3]));
  26178. writeSignedInt16(metrics, j + 2, lsb);
  26179. }
  26180. }
  26181. let numGlyphsOut = numGlyphs + 1;
  26182. let dupFirstEntry = true;
  26183. if (numGlyphsOut > 0xffff) {
  26184. dupFirstEntry = false;
  26185. numGlyphsOut = numGlyphs;
  26186. (0, _util.warn)("Not enough space in glyfs to duplicate first glyph.");
  26187. }
  26188. let maxFunctionDefs = 0;
  26189. let maxSizeOfInstructions = 0;
  26190. if (version >= 0x00010000 && tables.maxp.length >= 22) {
  26191. font.pos += 8;
  26192. const maxZones = font.getUint16();
  26193. if (maxZones > 2) {
  26194. tables.maxp.data[14] = 0;
  26195. tables.maxp.data[15] = 2;
  26196. }
  26197. font.pos += 4;
  26198. maxFunctionDefs = font.getUint16();
  26199. font.pos += 4;
  26200. maxSizeOfInstructions = font.getUint16();
  26201. }
  26202. tables.maxp.data[4] = numGlyphsOut >> 8;
  26203. tables.maxp.data[5] = numGlyphsOut & 255;
  26204. const hintsValid = sanitizeTTPrograms(tables.fpgm, tables.prep, tables["cvt "], maxFunctionDefs);
  26205. if (!hintsValid) {
  26206. delete tables.fpgm;
  26207. delete tables.prep;
  26208. delete tables["cvt "];
  26209. }
  26210. sanitizeMetrics(font, tables.hhea, tables.hmtx, tables.head, numGlyphsOut, dupFirstEntry);
  26211. if (!tables.head) {
  26212. throw new _util.FormatError('Required "head" table is not found');
  26213. }
  26214. sanitizeHead(tables.head, numGlyphs, isTrueType ? tables.loca.length : 0);
  26215. let missingGlyphs = Object.create(null);
  26216. if (isTrueType) {
  26217. const isGlyphLocationsLong = int16(tables.head.data[50], tables.head.data[51]);
  26218. const glyphsInfo = sanitizeGlyphLocations(tables.loca, tables.glyf, numGlyphs, isGlyphLocationsLong, hintsValid, dupFirstEntry, maxSizeOfInstructions);
  26219. missingGlyphs = glyphsInfo.missingGlyphs;
  26220. if (version >= 0x00010000 && tables.maxp.length >= 22) {
  26221. tables.maxp.data[26] = glyphsInfo.maxSizeOfInstructions >> 8;
  26222. tables.maxp.data[27] = glyphsInfo.maxSizeOfInstructions & 255;
  26223. }
  26224. }
  26225. if (!tables.hhea) {
  26226. throw new _util.FormatError('Required "hhea" table is not found');
  26227. }
  26228. if (tables.hhea.data[10] === 0 && tables.hhea.data[11] === 0) {
  26229. tables.hhea.data[10] = 0xff;
  26230. tables.hhea.data[11] = 0xff;
  26231. }
  26232. const metricsOverride = {
  26233. unitsPerEm: int16(tables.head.data[18], tables.head.data[19]),
  26234. yMax: signedInt16(tables.head.data[42], tables.head.data[43]),
  26235. yMin: signedInt16(tables.head.data[38], tables.head.data[39]),
  26236. ascent: signedInt16(tables.hhea.data[4], tables.hhea.data[5]),
  26237. descent: signedInt16(tables.hhea.data[6], tables.hhea.data[7]),
  26238. lineGap: signedInt16(tables.hhea.data[8], tables.hhea.data[9])
  26239. };
  26240. this.ascent = metricsOverride.ascent / metricsOverride.unitsPerEm;
  26241. this.descent = metricsOverride.descent / metricsOverride.unitsPerEm;
  26242. this.lineGap = metricsOverride.lineGap / metricsOverride.unitsPerEm;
  26243. if (this.cssFontInfo?.lineHeight) {
  26244. this.lineHeight = this.cssFontInfo.metrics.lineHeight;
  26245. this.lineGap = this.cssFontInfo.metrics.lineGap;
  26246. } else {
  26247. this.lineHeight = this.ascent - this.descent + this.lineGap;
  26248. }
  26249. if (tables.post) {
  26250. readPostScriptTable(tables.post, properties, numGlyphs);
  26251. }
  26252. tables.post = {
  26253. tag: "post",
  26254. data: createPostTable(properties)
  26255. };
  26256. const charCodeToGlyphId = [];
  26257. function hasGlyph(glyphId) {
  26258. return !missingGlyphs[glyphId];
  26259. }
  26260. if (properties.composite) {
  26261. const cidToGidMap = properties.cidToGidMap || [];
  26262. const isCidToGidMapEmpty = cidToGidMap.length === 0;
  26263. properties.cMap.forEach(function (charCode, cid) {
  26264. if (typeof cid === "string") {
  26265. cid = convertCidString(charCode, cid, true);
  26266. }
  26267. if (cid > 0xffff) {
  26268. throw new _util.FormatError("Max size of CID is 65,535");
  26269. }
  26270. let glyphId = -1;
  26271. if (isCidToGidMapEmpty) {
  26272. glyphId = cid;
  26273. } else if (cidToGidMap[cid] !== undefined) {
  26274. glyphId = cidToGidMap[cid];
  26275. }
  26276. if (glyphId >= 0 && glyphId < numGlyphs && hasGlyph(glyphId)) {
  26277. charCodeToGlyphId[charCode] = glyphId;
  26278. }
  26279. });
  26280. } else {
  26281. const cmapTable = readCmapTable(tables.cmap, font, this.isSymbolicFont, properties.hasEncoding);
  26282. const cmapPlatformId = cmapTable.platformId;
  26283. const cmapEncodingId = cmapTable.encodingId;
  26284. const cmapMappings = cmapTable.mappings;
  26285. let baseEncoding = [],
  26286. forcePostTable = false;
  26287. if (properties.hasEncoding && (properties.baseEncodingName === "MacRomanEncoding" || properties.baseEncodingName === "WinAnsiEncoding")) {
  26288. baseEncoding = (0, _encodings.getEncoding)(properties.baseEncodingName);
  26289. }
  26290. if (properties.hasEncoding && !this.isSymbolicFont && (cmapPlatformId === 3 && cmapEncodingId === 1 || cmapPlatformId === 1 && cmapEncodingId === 0)) {
  26291. const glyphsUnicodeMap = (0, _glyphlist.getGlyphsUnicode)();
  26292. for (let charCode = 0; charCode < 256; charCode++) {
  26293. let glyphName;
  26294. if (this.differences[charCode] !== undefined) {
  26295. glyphName = this.differences[charCode];
  26296. } else if (baseEncoding.length && baseEncoding[charCode] !== "") {
  26297. glyphName = baseEncoding[charCode];
  26298. } else {
  26299. glyphName = _encodings.StandardEncoding[charCode];
  26300. }
  26301. if (!glyphName) {
  26302. continue;
  26303. }
  26304. const standardGlyphName = (0, _fonts_utils.recoverGlyphName)(glyphName, glyphsUnicodeMap);
  26305. let unicodeOrCharCode;
  26306. if (cmapPlatformId === 3 && cmapEncodingId === 1) {
  26307. unicodeOrCharCode = glyphsUnicodeMap[standardGlyphName];
  26308. } else if (cmapPlatformId === 1 && cmapEncodingId === 0) {
  26309. unicodeOrCharCode = _encodings.MacRomanEncoding.indexOf(standardGlyphName);
  26310. }
  26311. if (unicodeOrCharCode === undefined) {
  26312. if (!properties.glyphNames && properties.hasIncludedToUnicodeMap && !(this.toUnicode instanceof _to_unicode_map.IdentityToUnicodeMap)) {
  26313. const unicode = this.toUnicode.get(charCode);
  26314. if (unicode) {
  26315. unicodeOrCharCode = unicode.codePointAt(0);
  26316. }
  26317. }
  26318. if (unicodeOrCharCode === undefined) {
  26319. continue;
  26320. }
  26321. }
  26322. for (const mapping of cmapMappings) {
  26323. if (mapping.charCode !== unicodeOrCharCode) {
  26324. continue;
  26325. }
  26326. charCodeToGlyphId[charCode] = mapping.glyphId;
  26327. break;
  26328. }
  26329. }
  26330. } else if (cmapPlatformId === 0) {
  26331. for (const mapping of cmapMappings) {
  26332. charCodeToGlyphId[mapping.charCode] = mapping.glyphId;
  26333. }
  26334. forcePostTable = true;
  26335. } else {
  26336. for (const mapping of cmapMappings) {
  26337. let charCode = mapping.charCode;
  26338. if (cmapPlatformId === 3 && charCode >= 0xf000 && charCode <= 0xf0ff) {
  26339. charCode &= 0xff;
  26340. }
  26341. charCodeToGlyphId[charCode] = mapping.glyphId;
  26342. }
  26343. }
  26344. if (properties.glyphNames && (baseEncoding.length || this.differences.length)) {
  26345. for (let i = 0; i < 256; ++i) {
  26346. if (!forcePostTable && charCodeToGlyphId[i] !== undefined) {
  26347. continue;
  26348. }
  26349. const glyphName = this.differences[i] || baseEncoding[i];
  26350. if (!glyphName) {
  26351. continue;
  26352. }
  26353. const glyphId = properties.glyphNames.indexOf(glyphName);
  26354. if (glyphId > 0 && hasGlyph(glyphId)) {
  26355. charCodeToGlyphId[i] = glyphId;
  26356. }
  26357. }
  26358. }
  26359. }
  26360. if (charCodeToGlyphId.length === 0) {
  26361. charCodeToGlyphId[0] = 0;
  26362. }
  26363. let glyphZeroId = numGlyphsOut - 1;
  26364. if (!dupFirstEntry) {
  26365. glyphZeroId = 0;
  26366. }
  26367. if (!properties.cssFontInfo) {
  26368. const newMapping = adjustMapping(charCodeToGlyphId, hasGlyph, glyphZeroId, this.toUnicode);
  26369. this.toFontChar = newMapping.toFontChar;
  26370. tables.cmap = {
  26371. tag: "cmap",
  26372. data: createCmapTable(newMapping.charCodeToGlyphId, newMapping.toUnicodeExtraMap, numGlyphsOut)
  26373. };
  26374. if (!tables["OS/2"] || !validateOS2Table(tables["OS/2"], font)) {
  26375. tables["OS/2"] = {
  26376. tag: "OS/2",
  26377. data: createOS2Table(properties, newMapping.charCodeToGlyphId, metricsOverride)
  26378. };
  26379. }
  26380. }
  26381. if (!isTrueType) {
  26382. try {
  26383. cffFile = new _stream.Stream(tables["CFF "].data);
  26384. const parser = new _cff_parser.CFFParser(cffFile, properties, _fonts_utils.SEAC_ANALYSIS_ENABLED);
  26385. cff = parser.parse();
  26386. cff.duplicateFirstGlyph();
  26387. const compiler = new _cff_parser.CFFCompiler(cff);
  26388. tables["CFF "].data = compiler.compile();
  26389. } catch {
  26390. (0, _util.warn)("Failed to compile font " + properties.loadedName);
  26391. }
  26392. }
  26393. if (!tables.name) {
  26394. tables.name = {
  26395. tag: "name",
  26396. data: createNameTable(this.name)
  26397. };
  26398. } else {
  26399. const [namePrototype, nameRecords] = readNameTable(tables.name);
  26400. tables.name.data = createNameTable(name, namePrototype);
  26401. this.psName = namePrototype[0][6] || null;
  26402. if (!properties.composite) {
  26403. adjustTrueTypeToUnicode(properties, this.isSymbolicFont, nameRecords);
  26404. }
  26405. }
  26406. const builder = new _opentype_file_builder.OpenTypeFileBuilder(header.version);
  26407. for (const tableTag in tables) {
  26408. builder.addTable(tableTag, tables[tableTag].data);
  26409. }
  26410. return builder.toArray();
  26411. }
  26412. convert(fontName, font, properties) {
  26413. properties.fixedPitch = false;
  26414. if (properties.builtInEncoding) {
  26415. adjustType1ToUnicode(properties, properties.builtInEncoding);
  26416. }
  26417. let glyphZeroId = 1;
  26418. if (font instanceof _cff_font.CFFFont) {
  26419. glyphZeroId = font.numGlyphs - 1;
  26420. }
  26421. const mapping = font.getGlyphMapping(properties);
  26422. let newMapping = null;
  26423. let newCharCodeToGlyphId = mapping;
  26424. let toUnicodeExtraMap = null;
  26425. if (!properties.cssFontInfo) {
  26426. newMapping = adjustMapping(mapping, font.hasGlyphId.bind(font), glyphZeroId, this.toUnicode);
  26427. this.toFontChar = newMapping.toFontChar;
  26428. newCharCodeToGlyphId = newMapping.charCodeToGlyphId;
  26429. toUnicodeExtraMap = newMapping.toUnicodeExtraMap;
  26430. }
  26431. const numGlyphs = font.numGlyphs;
  26432. function getCharCodes(charCodeToGlyphId, glyphId) {
  26433. let charCodes = null;
  26434. for (const charCode in charCodeToGlyphId) {
  26435. if (glyphId === charCodeToGlyphId[charCode]) {
  26436. (charCodes ||= []).push(charCode | 0);
  26437. }
  26438. }
  26439. return charCodes;
  26440. }
  26441. function createCharCode(charCodeToGlyphId, glyphId) {
  26442. for (const charCode in charCodeToGlyphId) {
  26443. if (glyphId === charCodeToGlyphId[charCode]) {
  26444. return charCode | 0;
  26445. }
  26446. }
  26447. newMapping.charCodeToGlyphId[newMapping.nextAvailableFontCharCode] = glyphId;
  26448. return newMapping.nextAvailableFontCharCode++;
  26449. }
  26450. const seacs = font.seacs;
  26451. if (newMapping && _fonts_utils.SEAC_ANALYSIS_ENABLED && seacs?.length) {
  26452. const matrix = properties.fontMatrix || _util.FONT_IDENTITY_MATRIX;
  26453. const charset = font.getCharset();
  26454. const seacMap = Object.create(null);
  26455. for (let glyphId in seacs) {
  26456. glyphId |= 0;
  26457. const seac = seacs[glyphId];
  26458. const baseGlyphName = _encodings.StandardEncoding[seac[2]];
  26459. const accentGlyphName = _encodings.StandardEncoding[seac[3]];
  26460. const baseGlyphId = charset.indexOf(baseGlyphName);
  26461. const accentGlyphId = charset.indexOf(accentGlyphName);
  26462. if (baseGlyphId < 0 || accentGlyphId < 0) {
  26463. continue;
  26464. }
  26465. const accentOffset = {
  26466. x: seac[0] * matrix[0] + seac[1] * matrix[2] + matrix[4],
  26467. y: seac[0] * matrix[1] + seac[1] * matrix[3] + matrix[5]
  26468. };
  26469. const charCodes = getCharCodes(mapping, glyphId);
  26470. if (!charCodes) {
  26471. continue;
  26472. }
  26473. for (const charCode of charCodes) {
  26474. const charCodeToGlyphId = newMapping.charCodeToGlyphId;
  26475. const baseFontCharCode = createCharCode(charCodeToGlyphId, baseGlyphId);
  26476. const accentFontCharCode = createCharCode(charCodeToGlyphId, accentGlyphId);
  26477. seacMap[charCode] = {
  26478. baseFontCharCode,
  26479. accentFontCharCode,
  26480. accentOffset
  26481. };
  26482. }
  26483. }
  26484. properties.seacMap = seacMap;
  26485. }
  26486. const unitsPerEm = 1 / (properties.fontMatrix || _util.FONT_IDENTITY_MATRIX)[0];
  26487. const builder = new _opentype_file_builder.OpenTypeFileBuilder("\x4F\x54\x54\x4F");
  26488. builder.addTable("CFF ", font.data);
  26489. builder.addTable("OS/2", createOS2Table(properties, newCharCodeToGlyphId));
  26490. builder.addTable("cmap", createCmapTable(newCharCodeToGlyphId, toUnicodeExtraMap, numGlyphs));
  26491. 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");
  26492. 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));
  26493. builder.addTable("hmtx", function fontFieldsHmtx() {
  26494. const charstrings = font.charstrings;
  26495. const cffWidths = font.cff ? font.cff.widths : null;
  26496. let hmtx = "\x00\x00\x00\x00";
  26497. for (let i = 1, ii = numGlyphs; i < ii; i++) {
  26498. let width = 0;
  26499. if (charstrings) {
  26500. const charstring = charstrings[i - 1];
  26501. width = "width" in charstring ? charstring.width : 0;
  26502. } else if (cffWidths) {
  26503. width = Math.ceil(cffWidths[i] || 0);
  26504. }
  26505. hmtx += string16(width) + string16(0);
  26506. }
  26507. return hmtx;
  26508. }());
  26509. builder.addTable("maxp", "\x00\x00\x50\x00" + string16(numGlyphs));
  26510. builder.addTable("name", createNameTable(fontName));
  26511. builder.addTable("post", createPostTable(properties));
  26512. return builder.toArray();
  26513. }
  26514. get spaceWidth() {
  26515. const possibleSpaceReplacements = ["space", "minus", "one", "i", "I"];
  26516. let width;
  26517. for (const glyphName of possibleSpaceReplacements) {
  26518. if (glyphName in this.widths) {
  26519. width = this.widths[glyphName];
  26520. break;
  26521. }
  26522. const glyphsUnicodeMap = (0, _glyphlist.getGlyphsUnicode)();
  26523. const glyphUnicode = glyphsUnicodeMap[glyphName];
  26524. let charcode = 0;
  26525. if (this.composite && this.cMap.contains(glyphUnicode)) {
  26526. charcode = this.cMap.lookup(glyphUnicode);
  26527. if (typeof charcode === "string") {
  26528. charcode = convertCidString(glyphUnicode, charcode);
  26529. }
  26530. }
  26531. if (!charcode && this.toUnicode) {
  26532. charcode = this.toUnicode.charCodeOf(glyphUnicode);
  26533. }
  26534. if (charcode <= 0) {
  26535. charcode = glyphUnicode;
  26536. }
  26537. width = this.widths[charcode];
  26538. if (width) {
  26539. break;
  26540. }
  26541. }
  26542. return (0, _util.shadow)(this, "spaceWidth", width || this.defaultWidth);
  26543. }
  26544. _charToGlyph(charcode) {
  26545. let isSpace = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  26546. let glyph = this._glyphCache[charcode];
  26547. if (glyph?.isSpace === isSpace) {
  26548. return glyph;
  26549. }
  26550. let fontCharCode, width, operatorListId;
  26551. let widthCode = charcode;
  26552. if (this.cMap?.contains(charcode)) {
  26553. widthCode = this.cMap.lookup(charcode);
  26554. if (typeof widthCode === "string") {
  26555. widthCode = convertCidString(charcode, widthCode);
  26556. }
  26557. }
  26558. width = this.widths[widthCode];
  26559. if (typeof width !== "number") {
  26560. width = this.defaultWidth;
  26561. }
  26562. const vmetric = this.vmetrics?.[widthCode];
  26563. let unicode = this.toUnicode.get(charcode) || charcode;
  26564. if (typeof unicode === "number") {
  26565. unicode = String.fromCharCode(unicode);
  26566. }
  26567. let isInFont = this.toFontChar[charcode] !== undefined;
  26568. fontCharCode = this.toFontChar[charcode] || charcode;
  26569. if (this.missingFile) {
  26570. const glyphName = this.differences[charcode] || this.defaultEncoding[charcode];
  26571. if ((glyphName === ".notdef" || glyphName === "") && this.type === "Type1") {
  26572. fontCharCode = 0x20;
  26573. }
  26574. fontCharCode = (0, _unicode.mapSpecialUnicodeValues)(fontCharCode);
  26575. }
  26576. if (this.isType3Font) {
  26577. operatorListId = fontCharCode;
  26578. }
  26579. let accent = null;
  26580. if (this.seacMap?.[charcode]) {
  26581. isInFont = true;
  26582. const seac = this.seacMap[charcode];
  26583. fontCharCode = seac.baseFontCharCode;
  26584. accent = {
  26585. fontChar: String.fromCodePoint(seac.accentFontCharCode),
  26586. offset: seac.accentOffset
  26587. };
  26588. }
  26589. let fontChar = "";
  26590. if (typeof fontCharCode === "number") {
  26591. if (fontCharCode <= 0x10ffff) {
  26592. fontChar = String.fromCodePoint(fontCharCode);
  26593. } else {
  26594. (0, _util.warn)(`charToGlyph - invalid fontCharCode: ${fontCharCode}`);
  26595. }
  26596. }
  26597. glyph = new Glyph(charcode, fontChar, unicode, accent, width, vmetric, operatorListId, isSpace, isInFont);
  26598. return this._glyphCache[charcode] = glyph;
  26599. }
  26600. charsToGlyphs(chars) {
  26601. let glyphs = this._charsCache[chars];
  26602. if (glyphs) {
  26603. return glyphs;
  26604. }
  26605. glyphs = [];
  26606. if (this.cMap) {
  26607. const c = Object.create(null),
  26608. ii = chars.length;
  26609. let i = 0;
  26610. while (i < ii) {
  26611. this.cMap.readCharCode(chars, i, c);
  26612. const {
  26613. charcode,
  26614. length
  26615. } = c;
  26616. i += length;
  26617. const glyph = this._charToGlyph(charcode, length === 1 && chars.charCodeAt(i - 1) === 0x20);
  26618. glyphs.push(glyph);
  26619. }
  26620. } else {
  26621. for (let i = 0, ii = chars.length; i < ii; ++i) {
  26622. const charcode = chars.charCodeAt(i);
  26623. const glyph = this._charToGlyph(charcode, charcode === 0x20);
  26624. glyphs.push(glyph);
  26625. }
  26626. }
  26627. return this._charsCache[chars] = glyphs;
  26628. }
  26629. getCharPositions(chars) {
  26630. const positions = [];
  26631. if (this.cMap) {
  26632. const c = Object.create(null);
  26633. let i = 0;
  26634. while (i < chars.length) {
  26635. this.cMap.readCharCode(chars, i, c);
  26636. const length = c.length;
  26637. positions.push([i, i + length]);
  26638. i += length;
  26639. }
  26640. } else {
  26641. for (let i = 0, ii = chars.length; i < ii; ++i) {
  26642. positions.push([i, i + 1]);
  26643. }
  26644. }
  26645. return positions;
  26646. }
  26647. get glyphCacheValues() {
  26648. return Object.values(this._glyphCache);
  26649. }
  26650. encodeString(str) {
  26651. const buffers = [];
  26652. const currentBuf = [];
  26653. const hasCurrentBufErrors = () => buffers.length % 2 === 1;
  26654. const getCharCode = this.toUnicode instanceof _to_unicode_map.IdentityToUnicodeMap ? unicode => this.toUnicode.charCodeOf(unicode) : unicode => this.toUnicode.charCodeOf(String.fromCodePoint(unicode));
  26655. for (let i = 0, ii = str.length; i < ii; i++) {
  26656. const unicode = str.codePointAt(i);
  26657. if (unicode > 0xd7ff && (unicode < 0xe000 || unicode > 0xfffd)) {
  26658. i++;
  26659. }
  26660. if (this.toUnicode) {
  26661. const charCode = getCharCode(unicode);
  26662. if (charCode !== -1) {
  26663. if (hasCurrentBufErrors()) {
  26664. buffers.push(currentBuf.join(""));
  26665. currentBuf.length = 0;
  26666. }
  26667. const charCodeLength = this.cMap ? this.cMap.getCharCodeLength(charCode) : 1;
  26668. for (let j = charCodeLength - 1; j >= 0; j--) {
  26669. currentBuf.push(String.fromCharCode(charCode >> 8 * j & 0xff));
  26670. }
  26671. continue;
  26672. }
  26673. }
  26674. if (!hasCurrentBufErrors()) {
  26675. buffers.push(currentBuf.join(""));
  26676. currentBuf.length = 0;
  26677. }
  26678. currentBuf.push(String.fromCodePoint(unicode));
  26679. }
  26680. buffers.push(currentBuf.join(""));
  26681. return buffers;
  26682. }
  26683. }
  26684. exports.Font = Font;
  26685. class ErrorFont {
  26686. constructor(error) {
  26687. this.error = error;
  26688. this.loadedName = "g_font_error";
  26689. this.missingFile = true;
  26690. }
  26691. charsToGlyphs() {
  26692. return [];
  26693. }
  26694. encodeString(chars) {
  26695. return [chars];
  26696. }
  26697. exportData() {
  26698. let extraProperties = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  26699. return {
  26700. error: this.error
  26701. };
  26702. }
  26703. }
  26704. exports.ErrorFont = ErrorFont;
  26705. /***/ }),
  26706. /* 186 */
  26707. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  26708. Object.defineProperty(exports, "__esModule", ({
  26709. value: true
  26710. }));
  26711. exports.CFFTopDict = exports.CFFStrings = exports.CFFStandardStrings = exports.CFFPrivateDict = exports.CFFParser = exports.CFFIndex = exports.CFFHeader = exports.CFFFDSelect = exports.CFFCompiler = exports.CFFCharset = exports.CFF = void 0;
  26712. __w_pdfjs_require__(140);
  26713. __w_pdfjs_require__(84);
  26714. __w_pdfjs_require__(93);
  26715. __w_pdfjs_require__(94);
  26716. __w_pdfjs_require__(97);
  26717. __w_pdfjs_require__(99);
  26718. __w_pdfjs_require__(101);
  26719. __w_pdfjs_require__(105);
  26720. __w_pdfjs_require__(108);
  26721. __w_pdfjs_require__(115);
  26722. var _util = __w_pdfjs_require__(145);
  26723. var _charsets = __w_pdfjs_require__(187);
  26724. var _encodings = __w_pdfjs_require__(188);
  26725. const MAX_SUBR_NESTING = 10;
  26726. 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"];
  26727. exports.CFFStandardStrings = CFFStandardStrings;
  26728. const NUM_STANDARD_CFF_STRINGS = 391;
  26729. const CharstringValidationData = [null, {
  26730. id: "hstem",
  26731. min: 2,
  26732. stackClearing: true,
  26733. stem: true
  26734. }, null, {
  26735. id: "vstem",
  26736. min: 2,
  26737. stackClearing: true,
  26738. stem: true
  26739. }, {
  26740. id: "vmoveto",
  26741. min: 1,
  26742. stackClearing: true
  26743. }, {
  26744. id: "rlineto",
  26745. min: 2,
  26746. resetStack: true
  26747. }, {
  26748. id: "hlineto",
  26749. min: 1,
  26750. resetStack: true
  26751. }, {
  26752. id: "vlineto",
  26753. min: 1,
  26754. resetStack: true
  26755. }, {
  26756. id: "rrcurveto",
  26757. min: 6,
  26758. resetStack: true
  26759. }, null, {
  26760. id: "callsubr",
  26761. min: 1,
  26762. undefStack: true
  26763. }, {
  26764. id: "return",
  26765. min: 0,
  26766. undefStack: true
  26767. }, null, null, {
  26768. id: "endchar",
  26769. min: 0,
  26770. stackClearing: true
  26771. }, null, null, null, {
  26772. id: "hstemhm",
  26773. min: 2,
  26774. stackClearing: true,
  26775. stem: true
  26776. }, {
  26777. id: "hintmask",
  26778. min: 0,
  26779. stackClearing: true
  26780. }, {
  26781. id: "cntrmask",
  26782. min: 0,
  26783. stackClearing: true
  26784. }, {
  26785. id: "rmoveto",
  26786. min: 2,
  26787. stackClearing: true
  26788. }, {
  26789. id: "hmoveto",
  26790. min: 1,
  26791. stackClearing: true
  26792. }, {
  26793. id: "vstemhm",
  26794. min: 2,
  26795. stackClearing: true,
  26796. stem: true
  26797. }, {
  26798. id: "rcurveline",
  26799. min: 8,
  26800. resetStack: true
  26801. }, {
  26802. id: "rlinecurve",
  26803. min: 8,
  26804. resetStack: true
  26805. }, {
  26806. id: "vvcurveto",
  26807. min: 4,
  26808. resetStack: true
  26809. }, {
  26810. id: "hhcurveto",
  26811. min: 4,
  26812. resetStack: true
  26813. }, null, {
  26814. id: "callgsubr",
  26815. min: 1,
  26816. undefStack: true
  26817. }, {
  26818. id: "vhcurveto",
  26819. min: 4,
  26820. resetStack: true
  26821. }, {
  26822. id: "hvcurveto",
  26823. min: 4,
  26824. resetStack: true
  26825. }];
  26826. const CharstringValidationData12 = [null, null, null, {
  26827. id: "and",
  26828. min: 2,
  26829. stackDelta: -1
  26830. }, {
  26831. id: "or",
  26832. min: 2,
  26833. stackDelta: -1
  26834. }, {
  26835. id: "not",
  26836. min: 1,
  26837. stackDelta: 0
  26838. }, null, null, null, {
  26839. id: "abs",
  26840. min: 1,
  26841. stackDelta: 0
  26842. }, {
  26843. id: "add",
  26844. min: 2,
  26845. stackDelta: -1,
  26846. stackFn(stack, index) {
  26847. stack[index - 2] = stack[index - 2] + stack[index - 1];
  26848. }
  26849. }, {
  26850. id: "sub",
  26851. min: 2,
  26852. stackDelta: -1,
  26853. stackFn(stack, index) {
  26854. stack[index - 2] = stack[index - 2] - stack[index - 1];
  26855. }
  26856. }, {
  26857. id: "div",
  26858. min: 2,
  26859. stackDelta: -1,
  26860. stackFn(stack, index) {
  26861. stack[index - 2] = stack[index - 2] / stack[index - 1];
  26862. }
  26863. }, null, {
  26864. id: "neg",
  26865. min: 1,
  26866. stackDelta: 0,
  26867. stackFn(stack, index) {
  26868. stack[index - 1] = -stack[index - 1];
  26869. }
  26870. }, {
  26871. id: "eq",
  26872. min: 2,
  26873. stackDelta: -1
  26874. }, null, null, {
  26875. id: "drop",
  26876. min: 1,
  26877. stackDelta: -1
  26878. }, null, {
  26879. id: "put",
  26880. min: 2,
  26881. stackDelta: -2
  26882. }, {
  26883. id: "get",
  26884. min: 1,
  26885. stackDelta: 0
  26886. }, {
  26887. id: "ifelse",
  26888. min: 4,
  26889. stackDelta: -3
  26890. }, {
  26891. id: "random",
  26892. min: 0,
  26893. stackDelta: 1
  26894. }, {
  26895. id: "mul",
  26896. min: 2,
  26897. stackDelta: -1,
  26898. stackFn(stack, index) {
  26899. stack[index - 2] = stack[index - 2] * stack[index - 1];
  26900. }
  26901. }, null, {
  26902. id: "sqrt",
  26903. min: 1,
  26904. stackDelta: 0
  26905. }, {
  26906. id: "dup",
  26907. min: 1,
  26908. stackDelta: 1
  26909. }, {
  26910. id: "exch",
  26911. min: 2,
  26912. stackDelta: 0
  26913. }, {
  26914. id: "index",
  26915. min: 2,
  26916. stackDelta: 0
  26917. }, {
  26918. id: "roll",
  26919. min: 3,
  26920. stackDelta: -2
  26921. }, null, null, null, {
  26922. id: "hflex",
  26923. min: 7,
  26924. resetStack: true
  26925. }, {
  26926. id: "flex",
  26927. min: 13,
  26928. resetStack: true
  26929. }, {
  26930. id: "hflex1",
  26931. min: 9,
  26932. resetStack: true
  26933. }, {
  26934. id: "flex1",
  26935. min: 11,
  26936. resetStack: true
  26937. }];
  26938. class CFFParser {
  26939. constructor(file, properties, seacAnalysisEnabled) {
  26940. this.bytes = file.getBytes();
  26941. this.properties = properties;
  26942. this.seacAnalysisEnabled = !!seacAnalysisEnabled;
  26943. }
  26944. parse() {
  26945. const properties = this.properties;
  26946. const cff = new CFF();
  26947. this.cff = cff;
  26948. const header = this.parseHeader();
  26949. const nameIndex = this.parseIndex(header.endPos);
  26950. const topDictIndex = this.parseIndex(nameIndex.endPos);
  26951. const stringIndex = this.parseIndex(topDictIndex.endPos);
  26952. const globalSubrIndex = this.parseIndex(stringIndex.endPos);
  26953. const topDictParsed = this.parseDict(topDictIndex.obj.get(0));
  26954. const topDict = this.createDict(CFFTopDict, topDictParsed, cff.strings);
  26955. cff.header = header.obj;
  26956. cff.names = this.parseNameIndex(nameIndex.obj);
  26957. cff.strings = this.parseStringIndex(stringIndex.obj);
  26958. cff.topDict = topDict;
  26959. cff.globalSubrIndex = globalSubrIndex.obj;
  26960. this.parsePrivateDict(cff.topDict);
  26961. cff.isCIDFont = topDict.hasName("ROS");
  26962. const charStringOffset = topDict.getByName("CharStrings");
  26963. const charStringIndex = this.parseIndex(charStringOffset).obj;
  26964. const fontMatrix = topDict.getByName("FontMatrix");
  26965. if (fontMatrix) {
  26966. properties.fontMatrix = fontMatrix;
  26967. }
  26968. const fontBBox = topDict.getByName("FontBBox");
  26969. if (fontBBox) {
  26970. properties.ascent = Math.max(fontBBox[3], fontBBox[1]);
  26971. properties.descent = Math.min(fontBBox[1], fontBBox[3]);
  26972. properties.ascentScaled = true;
  26973. }
  26974. let charset, encoding;
  26975. if (cff.isCIDFont) {
  26976. const fdArrayIndex = this.parseIndex(topDict.getByName("FDArray")).obj;
  26977. for (let i = 0, ii = fdArrayIndex.count; i < ii; ++i) {
  26978. const dictRaw = fdArrayIndex.get(i);
  26979. const fontDict = this.createDict(CFFTopDict, this.parseDict(dictRaw), cff.strings);
  26980. this.parsePrivateDict(fontDict);
  26981. cff.fdArray.push(fontDict);
  26982. }
  26983. encoding = null;
  26984. charset = this.parseCharsets(topDict.getByName("charset"), charStringIndex.count, cff.strings, true);
  26985. cff.fdSelect = this.parseFDSelect(topDict.getByName("FDSelect"), charStringIndex.count);
  26986. } else {
  26987. charset = this.parseCharsets(topDict.getByName("charset"), charStringIndex.count, cff.strings, false);
  26988. encoding = this.parseEncoding(topDict.getByName("Encoding"), properties, cff.strings, charset.charset);
  26989. }
  26990. cff.charset = charset;
  26991. cff.encoding = encoding;
  26992. const charStringsAndSeacs = this.parseCharStrings({
  26993. charStrings: charStringIndex,
  26994. localSubrIndex: topDict.privateDict.subrsIndex,
  26995. globalSubrIndex: globalSubrIndex.obj,
  26996. fdSelect: cff.fdSelect,
  26997. fdArray: cff.fdArray,
  26998. privateDict: topDict.privateDict
  26999. });
  27000. cff.charStrings = charStringsAndSeacs.charStrings;
  27001. cff.seacs = charStringsAndSeacs.seacs;
  27002. cff.widths = charStringsAndSeacs.widths;
  27003. return cff;
  27004. }
  27005. parseHeader() {
  27006. let bytes = this.bytes;
  27007. const bytesLength = bytes.length;
  27008. let offset = 0;
  27009. while (offset < bytesLength && bytes[offset] !== 1) {
  27010. ++offset;
  27011. }
  27012. if (offset >= bytesLength) {
  27013. throw new _util.FormatError("Invalid CFF header");
  27014. }
  27015. if (offset !== 0) {
  27016. (0, _util.info)("cff data is shifted");
  27017. bytes = bytes.subarray(offset);
  27018. this.bytes = bytes;
  27019. }
  27020. const major = bytes[0];
  27021. const minor = bytes[1];
  27022. const hdrSize = bytes[2];
  27023. const offSize = bytes[3];
  27024. const header = new CFFHeader(major, minor, hdrSize, offSize);
  27025. return {
  27026. obj: header,
  27027. endPos: hdrSize
  27028. };
  27029. }
  27030. parseDict(dict) {
  27031. let pos = 0;
  27032. function parseOperand() {
  27033. let value = dict[pos++];
  27034. if (value === 30) {
  27035. return parseFloatOperand();
  27036. } else if (value === 28) {
  27037. value = dict[pos++];
  27038. value = (value << 24 | dict[pos++] << 16) >> 16;
  27039. return value;
  27040. } else if (value === 29) {
  27041. value = dict[pos++];
  27042. value = value << 8 | dict[pos++];
  27043. value = value << 8 | dict[pos++];
  27044. value = value << 8 | dict[pos++];
  27045. return value;
  27046. } else if (value >= 32 && value <= 246) {
  27047. return value - 139;
  27048. } else if (value >= 247 && value <= 250) {
  27049. return (value - 247) * 256 + dict[pos++] + 108;
  27050. } else if (value >= 251 && value <= 254) {
  27051. return -((value - 251) * 256) - dict[pos++] - 108;
  27052. }
  27053. (0, _util.warn)('CFFParser_parseDict: "' + value + '" is a reserved command.');
  27054. return NaN;
  27055. }
  27056. function parseFloatOperand() {
  27057. let str = "";
  27058. const eof = 15;
  27059. const lookup = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", ".", "E", "E-", null, "-"];
  27060. const length = dict.length;
  27061. while (pos < length) {
  27062. const b = dict[pos++];
  27063. const b1 = b >> 4;
  27064. const b2 = b & 15;
  27065. if (b1 === eof) {
  27066. break;
  27067. }
  27068. str += lookup[b1];
  27069. if (b2 === eof) {
  27070. break;
  27071. }
  27072. str += lookup[b2];
  27073. }
  27074. return parseFloat(str);
  27075. }
  27076. let operands = [];
  27077. const entries = [];
  27078. pos = 0;
  27079. const end = dict.length;
  27080. while (pos < end) {
  27081. let b = dict[pos];
  27082. if (b <= 21) {
  27083. if (b === 12) {
  27084. b = b << 8 | dict[++pos];
  27085. }
  27086. entries.push([b, operands]);
  27087. operands = [];
  27088. ++pos;
  27089. } else {
  27090. operands.push(parseOperand());
  27091. }
  27092. }
  27093. return entries;
  27094. }
  27095. parseIndex(pos) {
  27096. const cffIndex = new CFFIndex();
  27097. const bytes = this.bytes;
  27098. const count = bytes[pos++] << 8 | bytes[pos++];
  27099. const offsets = [];
  27100. let end = pos;
  27101. let i, ii;
  27102. if (count !== 0) {
  27103. const offsetSize = bytes[pos++];
  27104. const startPos = pos + (count + 1) * offsetSize - 1;
  27105. for (i = 0, ii = count + 1; i < ii; ++i) {
  27106. let offset = 0;
  27107. for (let j = 0; j < offsetSize; ++j) {
  27108. offset <<= 8;
  27109. offset += bytes[pos++];
  27110. }
  27111. offsets.push(startPos + offset);
  27112. }
  27113. end = offsets[count];
  27114. }
  27115. for (i = 0, ii = offsets.length - 1; i < ii; ++i) {
  27116. const offsetStart = offsets[i];
  27117. const offsetEnd = offsets[i + 1];
  27118. cffIndex.add(bytes.subarray(offsetStart, offsetEnd));
  27119. }
  27120. return {
  27121. obj: cffIndex,
  27122. endPos: end
  27123. };
  27124. }
  27125. parseNameIndex(index) {
  27126. const names = [];
  27127. for (let i = 0, ii = index.count; i < ii; ++i) {
  27128. const name = index.get(i);
  27129. names.push((0, _util.bytesToString)(name));
  27130. }
  27131. return names;
  27132. }
  27133. parseStringIndex(index) {
  27134. const strings = new CFFStrings();
  27135. for (let i = 0, ii = index.count; i < ii; ++i) {
  27136. const data = index.get(i);
  27137. strings.add((0, _util.bytesToString)(data));
  27138. }
  27139. return strings;
  27140. }
  27141. createDict(Type, dict, strings) {
  27142. const cffDict = new Type(strings);
  27143. for (const [key, value] of dict) {
  27144. cffDict.setByKey(key, value);
  27145. }
  27146. return cffDict;
  27147. }
  27148. parseCharString(state, data, localSubrIndex, globalSubrIndex) {
  27149. if (!data || state.callDepth > MAX_SUBR_NESTING) {
  27150. return false;
  27151. }
  27152. let stackSize = state.stackSize;
  27153. const stack = state.stack;
  27154. let length = data.length;
  27155. for (let j = 0; j < length;) {
  27156. const value = data[j++];
  27157. let validationCommand = null;
  27158. if (value === 12) {
  27159. const q = data[j++];
  27160. if (q === 0) {
  27161. data[j - 2] = 139;
  27162. data[j - 1] = 22;
  27163. stackSize = 0;
  27164. } else {
  27165. validationCommand = CharstringValidationData12[q];
  27166. }
  27167. } else if (value === 28) {
  27168. stack[stackSize] = (data[j] << 24 | data[j + 1] << 16) >> 16;
  27169. j += 2;
  27170. stackSize++;
  27171. } else if (value === 14) {
  27172. if (stackSize >= 4) {
  27173. stackSize -= 4;
  27174. if (this.seacAnalysisEnabled) {
  27175. state.seac = stack.slice(stackSize, stackSize + 4);
  27176. return false;
  27177. }
  27178. }
  27179. validationCommand = CharstringValidationData[value];
  27180. } else if (value >= 32 && value <= 246) {
  27181. stack[stackSize] = value - 139;
  27182. stackSize++;
  27183. } else if (value >= 247 && value <= 254) {
  27184. stack[stackSize] = value < 251 ? (value - 247 << 8) + data[j] + 108 : -(value - 251 << 8) - data[j] - 108;
  27185. j++;
  27186. stackSize++;
  27187. } else if (value === 255) {
  27188. stack[stackSize] = (data[j] << 24 | data[j + 1] << 16 | data[j + 2] << 8 | data[j + 3]) / 65536;
  27189. j += 4;
  27190. stackSize++;
  27191. } else if (value === 19 || value === 20) {
  27192. state.hints += stackSize >> 1;
  27193. if (state.hints === 0) {
  27194. data.copyWithin(j - 1, j, -1);
  27195. j -= 1;
  27196. length -= 1;
  27197. continue;
  27198. }
  27199. j += state.hints + 7 >> 3;
  27200. stackSize %= 2;
  27201. validationCommand = CharstringValidationData[value];
  27202. } else if (value === 10 || value === 29) {
  27203. const subrsIndex = value === 10 ? localSubrIndex : globalSubrIndex;
  27204. if (!subrsIndex) {
  27205. validationCommand = CharstringValidationData[value];
  27206. (0, _util.warn)("Missing subrsIndex for " + validationCommand.id);
  27207. return false;
  27208. }
  27209. let bias = 32768;
  27210. if (subrsIndex.count < 1240) {
  27211. bias = 107;
  27212. } else if (subrsIndex.count < 33900) {
  27213. bias = 1131;
  27214. }
  27215. const subrNumber = stack[--stackSize] + bias;
  27216. if (subrNumber < 0 || subrNumber >= subrsIndex.count || isNaN(subrNumber)) {
  27217. validationCommand = CharstringValidationData[value];
  27218. (0, _util.warn)("Out of bounds subrIndex for " + validationCommand.id);
  27219. return false;
  27220. }
  27221. state.stackSize = stackSize;
  27222. state.callDepth++;
  27223. const valid = this.parseCharString(state, subrsIndex.get(subrNumber), localSubrIndex, globalSubrIndex);
  27224. if (!valid) {
  27225. return false;
  27226. }
  27227. state.callDepth--;
  27228. stackSize = state.stackSize;
  27229. continue;
  27230. } else if (value === 11) {
  27231. state.stackSize = stackSize;
  27232. return true;
  27233. } else if (value === 0 && j === data.length) {
  27234. data[j - 1] = 14;
  27235. validationCommand = CharstringValidationData[14];
  27236. } else if (value === 9) {
  27237. data.copyWithin(j - 1, j, -1);
  27238. j -= 1;
  27239. length -= 1;
  27240. continue;
  27241. } else {
  27242. validationCommand = CharstringValidationData[value];
  27243. }
  27244. if (validationCommand) {
  27245. if (validationCommand.stem) {
  27246. state.hints += stackSize >> 1;
  27247. if (value === 3 || value === 23) {
  27248. state.hasVStems = true;
  27249. } else if (state.hasVStems && (value === 1 || value === 18)) {
  27250. (0, _util.warn)("CFF stem hints are in wrong order");
  27251. data[j - 1] = value === 1 ? 3 : 23;
  27252. }
  27253. }
  27254. if ("min" in validationCommand) {
  27255. if (!state.undefStack && stackSize < validationCommand.min) {
  27256. (0, _util.warn)("Not enough parameters for " + validationCommand.id + "; actual: " + stackSize + ", expected: " + validationCommand.min);
  27257. if (stackSize === 0) {
  27258. data[j - 1] = 14;
  27259. return true;
  27260. }
  27261. return false;
  27262. }
  27263. }
  27264. if (state.firstStackClearing && validationCommand.stackClearing) {
  27265. state.firstStackClearing = false;
  27266. stackSize -= validationCommand.min;
  27267. if (stackSize >= 2 && validationCommand.stem) {
  27268. stackSize %= 2;
  27269. } else if (stackSize > 1) {
  27270. (0, _util.warn)("Found too many parameters for stack-clearing command");
  27271. }
  27272. if (stackSize > 0) {
  27273. state.width = stack[stackSize - 1];
  27274. }
  27275. }
  27276. if ("stackDelta" in validationCommand) {
  27277. if ("stackFn" in validationCommand) {
  27278. validationCommand.stackFn(stack, stackSize);
  27279. }
  27280. stackSize += validationCommand.stackDelta;
  27281. } else if (validationCommand.stackClearing) {
  27282. stackSize = 0;
  27283. } else if (validationCommand.resetStack) {
  27284. stackSize = 0;
  27285. state.undefStack = false;
  27286. } else if (validationCommand.undefStack) {
  27287. stackSize = 0;
  27288. state.undefStack = true;
  27289. state.firstStackClearing = false;
  27290. }
  27291. }
  27292. }
  27293. if (length < data.length) {
  27294. data.fill(14, length);
  27295. }
  27296. state.stackSize = stackSize;
  27297. return true;
  27298. }
  27299. parseCharStrings(_ref) {
  27300. let {
  27301. charStrings,
  27302. localSubrIndex,
  27303. globalSubrIndex,
  27304. fdSelect,
  27305. fdArray,
  27306. privateDict
  27307. } = _ref;
  27308. const seacs = [];
  27309. const widths = [];
  27310. const count = charStrings.count;
  27311. for (let i = 0; i < count; i++) {
  27312. const charstring = charStrings.get(i);
  27313. const state = {
  27314. callDepth: 0,
  27315. stackSize: 0,
  27316. stack: [],
  27317. undefStack: true,
  27318. hints: 0,
  27319. firstStackClearing: true,
  27320. seac: null,
  27321. width: null,
  27322. hasVStems: false
  27323. };
  27324. let valid = true;
  27325. let localSubrToUse = null;
  27326. let privateDictToUse = privateDict;
  27327. if (fdSelect && fdArray.length) {
  27328. const fdIndex = fdSelect.getFDIndex(i);
  27329. if (fdIndex === -1) {
  27330. (0, _util.warn)("Glyph index is not in fd select.");
  27331. valid = false;
  27332. }
  27333. if (fdIndex >= fdArray.length) {
  27334. (0, _util.warn)("Invalid fd index for glyph index.");
  27335. valid = false;
  27336. }
  27337. if (valid) {
  27338. privateDictToUse = fdArray[fdIndex].privateDict;
  27339. localSubrToUse = privateDictToUse.subrsIndex;
  27340. }
  27341. } else if (localSubrIndex) {
  27342. localSubrToUse = localSubrIndex;
  27343. }
  27344. if (valid) {
  27345. valid = this.parseCharString(state, charstring, localSubrToUse, globalSubrIndex);
  27346. }
  27347. if (state.width !== null) {
  27348. const nominalWidth = privateDictToUse.getByName("nominalWidthX");
  27349. widths[i] = nominalWidth + state.width;
  27350. } else {
  27351. const defaultWidth = privateDictToUse.getByName("defaultWidthX");
  27352. widths[i] = defaultWidth;
  27353. }
  27354. if (state.seac !== null) {
  27355. seacs[i] = state.seac;
  27356. }
  27357. if (!valid) {
  27358. charStrings.set(i, new Uint8Array([14]));
  27359. }
  27360. }
  27361. return {
  27362. charStrings,
  27363. seacs,
  27364. widths
  27365. };
  27366. }
  27367. emptyPrivateDictionary(parentDict) {
  27368. const privateDict = this.createDict(CFFPrivateDict, [], parentDict.strings);
  27369. parentDict.setByKey(18, [0, 0]);
  27370. parentDict.privateDict = privateDict;
  27371. }
  27372. parsePrivateDict(parentDict) {
  27373. if (!parentDict.hasName("Private")) {
  27374. this.emptyPrivateDictionary(parentDict);
  27375. return;
  27376. }
  27377. const privateOffset = parentDict.getByName("Private");
  27378. if (!Array.isArray(privateOffset) || privateOffset.length !== 2) {
  27379. parentDict.removeByName("Private");
  27380. return;
  27381. }
  27382. const size = privateOffset[0];
  27383. const offset = privateOffset[1];
  27384. if (size === 0 || offset >= this.bytes.length) {
  27385. this.emptyPrivateDictionary(parentDict);
  27386. return;
  27387. }
  27388. const privateDictEnd = offset + size;
  27389. const dictData = this.bytes.subarray(offset, privateDictEnd);
  27390. const dict = this.parseDict(dictData);
  27391. const privateDict = this.createDict(CFFPrivateDict, dict, parentDict.strings);
  27392. parentDict.privateDict = privateDict;
  27393. if (privateDict.getByName("ExpansionFactor") === 0) {
  27394. privateDict.setByName("ExpansionFactor", 0.06);
  27395. }
  27396. if (!privateDict.getByName("Subrs")) {
  27397. return;
  27398. }
  27399. const subrsOffset = privateDict.getByName("Subrs");
  27400. const relativeOffset = offset + subrsOffset;
  27401. if (subrsOffset === 0 || relativeOffset >= this.bytes.length) {
  27402. this.emptyPrivateDictionary(parentDict);
  27403. return;
  27404. }
  27405. const subrsIndex = this.parseIndex(relativeOffset);
  27406. privateDict.subrsIndex = subrsIndex.obj;
  27407. }
  27408. parseCharsets(pos, length, strings, cid) {
  27409. if (pos === 0) {
  27410. return new CFFCharset(true, CFFCharsetPredefinedTypes.ISO_ADOBE, _charsets.ISOAdobeCharset);
  27411. } else if (pos === 1) {
  27412. return new CFFCharset(true, CFFCharsetPredefinedTypes.EXPERT, _charsets.ExpertCharset);
  27413. } else if (pos === 2) {
  27414. return new CFFCharset(true, CFFCharsetPredefinedTypes.EXPERT_SUBSET, _charsets.ExpertSubsetCharset);
  27415. }
  27416. const bytes = this.bytes;
  27417. const start = pos;
  27418. const format = bytes[pos++];
  27419. const charset = [cid ? 0 : ".notdef"];
  27420. let id, count, i;
  27421. length -= 1;
  27422. switch (format) {
  27423. case 0:
  27424. for (i = 0; i < length; i++) {
  27425. id = bytes[pos++] << 8 | bytes[pos++];
  27426. charset.push(cid ? id : strings.get(id));
  27427. }
  27428. break;
  27429. case 1:
  27430. while (charset.length <= length) {
  27431. id = bytes[pos++] << 8 | bytes[pos++];
  27432. count = bytes[pos++];
  27433. for (i = 0; i <= count; i++) {
  27434. charset.push(cid ? id++ : strings.get(id++));
  27435. }
  27436. }
  27437. break;
  27438. case 2:
  27439. while (charset.length <= length) {
  27440. id = bytes[pos++] << 8 | bytes[pos++];
  27441. count = bytes[pos++] << 8 | bytes[pos++];
  27442. for (i = 0; i <= count; i++) {
  27443. charset.push(cid ? id++ : strings.get(id++));
  27444. }
  27445. }
  27446. break;
  27447. default:
  27448. throw new _util.FormatError("Unknown charset format");
  27449. }
  27450. const end = pos;
  27451. const raw = bytes.subarray(start, end);
  27452. return new CFFCharset(false, format, charset, raw);
  27453. }
  27454. parseEncoding(pos, properties, strings, charset) {
  27455. const encoding = Object.create(null);
  27456. const bytes = this.bytes;
  27457. let predefined = false;
  27458. let format, i, ii;
  27459. let raw = null;
  27460. function readSupplement() {
  27461. const supplementsCount = bytes[pos++];
  27462. for (i = 0; i < supplementsCount; i++) {
  27463. const code = bytes[pos++];
  27464. const sid = (bytes[pos++] << 8) + (bytes[pos++] & 0xff);
  27465. encoding[code] = charset.indexOf(strings.get(sid));
  27466. }
  27467. }
  27468. if (pos === 0 || pos === 1) {
  27469. predefined = true;
  27470. format = pos;
  27471. const baseEncoding = pos ? _encodings.ExpertEncoding : _encodings.StandardEncoding;
  27472. for (i = 0, ii = charset.length; i < ii; i++) {
  27473. const index = baseEncoding.indexOf(charset[i]);
  27474. if (index !== -1) {
  27475. encoding[index] = i;
  27476. }
  27477. }
  27478. } else {
  27479. const dataStart = pos;
  27480. format = bytes[pos++];
  27481. switch (format & 0x7f) {
  27482. case 0:
  27483. const glyphsCount = bytes[pos++];
  27484. for (i = 1; i <= glyphsCount; i++) {
  27485. encoding[bytes[pos++]] = i;
  27486. }
  27487. break;
  27488. case 1:
  27489. const rangesCount = bytes[pos++];
  27490. let gid = 1;
  27491. for (i = 0; i < rangesCount; i++) {
  27492. const start = bytes[pos++];
  27493. const left = bytes[pos++];
  27494. for (let j = start; j <= start + left; j++) {
  27495. encoding[j] = gid++;
  27496. }
  27497. }
  27498. break;
  27499. default:
  27500. throw new _util.FormatError(`Unknown encoding format: ${format} in CFF`);
  27501. }
  27502. const dataEnd = pos;
  27503. if (format & 0x80) {
  27504. bytes[dataStart] &= 0x7f;
  27505. readSupplement();
  27506. }
  27507. raw = bytes.subarray(dataStart, dataEnd);
  27508. }
  27509. format &= 0x7f;
  27510. return new CFFEncoding(predefined, format, encoding, raw);
  27511. }
  27512. parseFDSelect(pos, length) {
  27513. const bytes = this.bytes;
  27514. const format = bytes[pos++];
  27515. const fdSelect = [];
  27516. let i;
  27517. switch (format) {
  27518. case 0:
  27519. for (i = 0; i < length; ++i) {
  27520. const id = bytes[pos++];
  27521. fdSelect.push(id);
  27522. }
  27523. break;
  27524. case 3:
  27525. const rangesCount = bytes[pos++] << 8 | bytes[pos++];
  27526. for (i = 0; i < rangesCount; ++i) {
  27527. let first = bytes[pos++] << 8 | bytes[pos++];
  27528. if (i === 0 && first !== 0) {
  27529. (0, _util.warn)("parseFDSelect: The first range must have a first GID of 0" + " -- trying to recover.");
  27530. first = 0;
  27531. }
  27532. const fdIndex = bytes[pos++];
  27533. const next = bytes[pos] << 8 | bytes[pos + 1];
  27534. for (let j = first; j < next; ++j) {
  27535. fdSelect.push(fdIndex);
  27536. }
  27537. }
  27538. pos += 2;
  27539. break;
  27540. default:
  27541. throw new _util.FormatError(`parseFDSelect: Unknown format "${format}".`);
  27542. }
  27543. if (fdSelect.length !== length) {
  27544. throw new _util.FormatError("parseFDSelect: Invalid font data.");
  27545. }
  27546. return new CFFFDSelect(format, fdSelect);
  27547. }
  27548. }
  27549. exports.CFFParser = CFFParser;
  27550. class CFF {
  27551. constructor() {
  27552. this.header = null;
  27553. this.names = [];
  27554. this.topDict = null;
  27555. this.strings = new CFFStrings();
  27556. this.globalSubrIndex = null;
  27557. this.encoding = null;
  27558. this.charset = null;
  27559. this.charStrings = null;
  27560. this.fdArray = [];
  27561. this.fdSelect = null;
  27562. this.isCIDFont = false;
  27563. }
  27564. duplicateFirstGlyph() {
  27565. if (this.charStrings.count >= 65535) {
  27566. (0, _util.warn)("Not enough space in charstrings to duplicate first glyph.");
  27567. return;
  27568. }
  27569. const glyphZero = this.charStrings.get(0);
  27570. this.charStrings.add(glyphZero);
  27571. if (this.isCIDFont) {
  27572. this.fdSelect.fdSelect.push(this.fdSelect.fdSelect[0]);
  27573. }
  27574. }
  27575. hasGlyphId(id) {
  27576. if (id < 0 || id >= this.charStrings.count) {
  27577. return false;
  27578. }
  27579. const glyph = this.charStrings.get(id);
  27580. return glyph.length > 0;
  27581. }
  27582. }
  27583. exports.CFF = CFF;
  27584. class CFFHeader {
  27585. constructor(major, minor, hdrSize, offSize) {
  27586. this.major = major;
  27587. this.minor = minor;
  27588. this.hdrSize = hdrSize;
  27589. this.offSize = offSize;
  27590. }
  27591. }
  27592. exports.CFFHeader = CFFHeader;
  27593. class CFFStrings {
  27594. constructor() {
  27595. this.strings = [];
  27596. }
  27597. get(index) {
  27598. if (index >= 0 && index <= NUM_STANDARD_CFF_STRINGS - 1) {
  27599. return CFFStandardStrings[index];
  27600. }
  27601. if (index - NUM_STANDARD_CFF_STRINGS <= this.strings.length) {
  27602. return this.strings[index - NUM_STANDARD_CFF_STRINGS];
  27603. }
  27604. return CFFStandardStrings[0];
  27605. }
  27606. getSID(str) {
  27607. let index = CFFStandardStrings.indexOf(str);
  27608. if (index !== -1) {
  27609. return index;
  27610. }
  27611. index = this.strings.indexOf(str);
  27612. if (index !== -1) {
  27613. return index + NUM_STANDARD_CFF_STRINGS;
  27614. }
  27615. return -1;
  27616. }
  27617. add(value) {
  27618. this.strings.push(value);
  27619. }
  27620. get count() {
  27621. return this.strings.length;
  27622. }
  27623. }
  27624. exports.CFFStrings = CFFStrings;
  27625. class CFFIndex {
  27626. constructor() {
  27627. this.objects = [];
  27628. this.length = 0;
  27629. }
  27630. add(data) {
  27631. this.length += data.length;
  27632. this.objects.push(data);
  27633. }
  27634. set(index, data) {
  27635. this.length += data.length - this.objects[index].length;
  27636. this.objects[index] = data;
  27637. }
  27638. get(index) {
  27639. return this.objects[index];
  27640. }
  27641. get count() {
  27642. return this.objects.length;
  27643. }
  27644. }
  27645. exports.CFFIndex = CFFIndex;
  27646. class CFFDict {
  27647. constructor(tables, strings) {
  27648. this.keyToNameMap = tables.keyToNameMap;
  27649. this.nameToKeyMap = tables.nameToKeyMap;
  27650. this.defaults = tables.defaults;
  27651. this.types = tables.types;
  27652. this.opcodes = tables.opcodes;
  27653. this.order = tables.order;
  27654. this.strings = strings;
  27655. this.values = Object.create(null);
  27656. }
  27657. setByKey(key, value) {
  27658. if (!(key in this.keyToNameMap)) {
  27659. return false;
  27660. }
  27661. if (value.length === 0) {
  27662. return true;
  27663. }
  27664. for (const val of value) {
  27665. if (isNaN(val)) {
  27666. (0, _util.warn)(`Invalid CFFDict value: "${value}" for key "${key}".`);
  27667. return true;
  27668. }
  27669. }
  27670. const type = this.types[key];
  27671. if (type === "num" || type === "sid" || type === "offset") {
  27672. value = value[0];
  27673. }
  27674. this.values[key] = value;
  27675. return true;
  27676. }
  27677. setByName(name, value) {
  27678. if (!(name in this.nameToKeyMap)) {
  27679. throw new _util.FormatError(`Invalid dictionary name "${name}"`);
  27680. }
  27681. this.values[this.nameToKeyMap[name]] = value;
  27682. }
  27683. hasName(name) {
  27684. return this.nameToKeyMap[name] in this.values;
  27685. }
  27686. getByName(name) {
  27687. if (!(name in this.nameToKeyMap)) {
  27688. throw new _util.FormatError(`Invalid dictionary name ${name}"`);
  27689. }
  27690. const key = this.nameToKeyMap[name];
  27691. if (!(key in this.values)) {
  27692. return this.defaults[key];
  27693. }
  27694. return this.values[key];
  27695. }
  27696. removeByName(name) {
  27697. delete this.values[this.nameToKeyMap[name]];
  27698. }
  27699. static createTables(layout) {
  27700. const tables = {
  27701. keyToNameMap: {},
  27702. nameToKeyMap: {},
  27703. defaults: {},
  27704. types: {},
  27705. opcodes: {},
  27706. order: []
  27707. };
  27708. for (const entry of layout) {
  27709. const key = Array.isArray(entry[0]) ? (entry[0][0] << 8) + entry[0][1] : entry[0];
  27710. tables.keyToNameMap[key] = entry[1];
  27711. tables.nameToKeyMap[entry[1]] = key;
  27712. tables.types[key] = entry[2];
  27713. tables.defaults[key] = entry[3];
  27714. tables.opcodes[key] = Array.isArray(entry[0]) ? entry[0] : [entry[0]];
  27715. tables.order.push(key);
  27716. }
  27717. return tables;
  27718. }
  27719. }
  27720. 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]];
  27721. class CFFTopDict extends CFFDict {
  27722. static get tables() {
  27723. return (0, _util.shadow)(this, "tables", this.createTables(CFFTopDictLayout));
  27724. }
  27725. constructor(strings) {
  27726. super(CFFTopDict.tables, strings);
  27727. this.privateDict = null;
  27728. }
  27729. }
  27730. exports.CFFTopDict = CFFTopDict;
  27731. 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]];
  27732. class CFFPrivateDict extends CFFDict {
  27733. static get tables() {
  27734. return (0, _util.shadow)(this, "tables", this.createTables(CFFPrivateDictLayout));
  27735. }
  27736. constructor(strings) {
  27737. super(CFFPrivateDict.tables, strings);
  27738. this.subrsIndex = null;
  27739. }
  27740. }
  27741. exports.CFFPrivateDict = CFFPrivateDict;
  27742. const CFFCharsetPredefinedTypes = {
  27743. ISO_ADOBE: 0,
  27744. EXPERT: 1,
  27745. EXPERT_SUBSET: 2
  27746. };
  27747. class CFFCharset {
  27748. constructor(predefined, format, charset, raw) {
  27749. this.predefined = predefined;
  27750. this.format = format;
  27751. this.charset = charset;
  27752. this.raw = raw;
  27753. }
  27754. }
  27755. exports.CFFCharset = CFFCharset;
  27756. class CFFEncoding {
  27757. constructor(predefined, format, encoding, raw) {
  27758. this.predefined = predefined;
  27759. this.format = format;
  27760. this.encoding = encoding;
  27761. this.raw = raw;
  27762. }
  27763. }
  27764. class CFFFDSelect {
  27765. constructor(format, fdSelect) {
  27766. this.format = format;
  27767. this.fdSelect = fdSelect;
  27768. }
  27769. getFDIndex(glyphIndex) {
  27770. if (glyphIndex < 0 || glyphIndex >= this.fdSelect.length) {
  27771. return -1;
  27772. }
  27773. return this.fdSelect[glyphIndex];
  27774. }
  27775. }
  27776. exports.CFFFDSelect = CFFFDSelect;
  27777. class CFFOffsetTracker {
  27778. constructor() {
  27779. this.offsets = Object.create(null);
  27780. }
  27781. isTracking(key) {
  27782. return key in this.offsets;
  27783. }
  27784. track(key, location) {
  27785. if (key in this.offsets) {
  27786. throw new _util.FormatError(`Already tracking location of ${key}`);
  27787. }
  27788. this.offsets[key] = location;
  27789. }
  27790. offset(value) {
  27791. for (const key in this.offsets) {
  27792. this.offsets[key] += value;
  27793. }
  27794. }
  27795. setEntryLocation(key, values, output) {
  27796. if (!(key in this.offsets)) {
  27797. throw new _util.FormatError(`Not tracking location of ${key}`);
  27798. }
  27799. const data = output.data;
  27800. const dataOffset = this.offsets[key];
  27801. const size = 5;
  27802. for (let i = 0, ii = values.length; i < ii; ++i) {
  27803. const offset0 = i * size + dataOffset;
  27804. const offset1 = offset0 + 1;
  27805. const offset2 = offset0 + 2;
  27806. const offset3 = offset0 + 3;
  27807. const offset4 = offset0 + 4;
  27808. if (data[offset0] !== 0x1d || data[offset1] !== 0 || data[offset2] !== 0 || data[offset3] !== 0 || data[offset4] !== 0) {
  27809. throw new _util.FormatError("writing to an offset that is not empty");
  27810. }
  27811. const value = values[i];
  27812. data[offset0] = 0x1d;
  27813. data[offset1] = value >> 24 & 0xff;
  27814. data[offset2] = value >> 16 & 0xff;
  27815. data[offset3] = value >> 8 & 0xff;
  27816. data[offset4] = value & 0xff;
  27817. }
  27818. }
  27819. }
  27820. class CFFCompiler {
  27821. constructor(cff) {
  27822. this.cff = cff;
  27823. }
  27824. compile() {
  27825. const cff = this.cff;
  27826. const output = {
  27827. data: [],
  27828. length: 0,
  27829. add(data) {
  27830. try {
  27831. this.data.push(...data);
  27832. } catch {
  27833. this.data = this.data.concat(data);
  27834. }
  27835. this.length = this.data.length;
  27836. }
  27837. };
  27838. const header = this.compileHeader(cff.header);
  27839. output.add(header);
  27840. const nameIndex = this.compileNameIndex(cff.names);
  27841. output.add(nameIndex);
  27842. if (cff.isCIDFont) {
  27843. if (cff.topDict.hasName("FontMatrix")) {
  27844. const base = cff.topDict.getByName("FontMatrix");
  27845. cff.topDict.removeByName("FontMatrix");
  27846. for (const subDict of cff.fdArray) {
  27847. let matrix = base.slice(0);
  27848. if (subDict.hasName("FontMatrix")) {
  27849. matrix = _util.Util.transform(matrix, subDict.getByName("FontMatrix"));
  27850. }
  27851. subDict.setByName("FontMatrix", matrix);
  27852. }
  27853. }
  27854. }
  27855. const xuid = cff.topDict.getByName("XUID");
  27856. if (xuid?.length > 16) {
  27857. cff.topDict.removeByName("XUID");
  27858. }
  27859. cff.topDict.setByName("charset", 0);
  27860. let compiled = this.compileTopDicts([cff.topDict], output.length, cff.isCIDFont);
  27861. output.add(compiled.output);
  27862. const topDictTracker = compiled.trackers[0];
  27863. const stringIndex = this.compileStringIndex(cff.strings.strings);
  27864. output.add(stringIndex);
  27865. const globalSubrIndex = this.compileIndex(cff.globalSubrIndex);
  27866. output.add(globalSubrIndex);
  27867. if (cff.encoding && cff.topDict.hasName("Encoding")) {
  27868. if (cff.encoding.predefined) {
  27869. topDictTracker.setEntryLocation("Encoding", [cff.encoding.format], output);
  27870. } else {
  27871. const encoding = this.compileEncoding(cff.encoding);
  27872. topDictTracker.setEntryLocation("Encoding", [output.length], output);
  27873. output.add(encoding);
  27874. }
  27875. }
  27876. const charset = this.compileCharset(cff.charset, cff.charStrings.count, cff.strings, cff.isCIDFont);
  27877. topDictTracker.setEntryLocation("charset", [output.length], output);
  27878. output.add(charset);
  27879. const charStrings = this.compileCharStrings(cff.charStrings);
  27880. topDictTracker.setEntryLocation("CharStrings", [output.length], output);
  27881. output.add(charStrings);
  27882. if (cff.isCIDFont) {
  27883. topDictTracker.setEntryLocation("FDSelect", [output.length], output);
  27884. const fdSelect = this.compileFDSelect(cff.fdSelect);
  27885. output.add(fdSelect);
  27886. compiled = this.compileTopDicts(cff.fdArray, output.length, true);
  27887. topDictTracker.setEntryLocation("FDArray", [output.length], output);
  27888. output.add(compiled.output);
  27889. const fontDictTrackers = compiled.trackers;
  27890. this.compilePrivateDicts(cff.fdArray, fontDictTrackers, output);
  27891. }
  27892. this.compilePrivateDicts([cff.topDict], [topDictTracker], output);
  27893. output.add([0]);
  27894. return output.data;
  27895. }
  27896. encodeNumber(value) {
  27897. if (Number.isInteger(value)) {
  27898. return this.encodeInteger(value);
  27899. }
  27900. return this.encodeFloat(value);
  27901. }
  27902. static get EncodeFloatRegExp() {
  27903. return (0, _util.shadow)(this, "EncodeFloatRegExp", /\.(\d*?)(?:9{5,20}|0{5,20})\d{0,2}(?:e(.+)|$)/);
  27904. }
  27905. encodeFloat(num) {
  27906. let value = num.toString();
  27907. const m = CFFCompiler.EncodeFloatRegExp.exec(value);
  27908. if (m) {
  27909. const epsilon = parseFloat("1e" + ((m[2] ? +m[2] : 0) + m[1].length));
  27910. value = (Math.round(num * epsilon) / epsilon).toString();
  27911. }
  27912. let nibbles = "";
  27913. let i, ii;
  27914. for (i = 0, ii = value.length; i < ii; ++i) {
  27915. const a = value[i];
  27916. if (a === "e") {
  27917. nibbles += value[++i] === "-" ? "c" : "b";
  27918. } else if (a === ".") {
  27919. nibbles += "a";
  27920. } else if (a === "-") {
  27921. nibbles += "e";
  27922. } else {
  27923. nibbles += a;
  27924. }
  27925. }
  27926. nibbles += nibbles.length & 1 ? "f" : "ff";
  27927. const out = [30];
  27928. for (i = 0, ii = nibbles.length; i < ii; i += 2) {
  27929. out.push(parseInt(nibbles.substring(i, i + 2), 16));
  27930. }
  27931. return out;
  27932. }
  27933. encodeInteger(value) {
  27934. let code;
  27935. if (value >= -107 && value <= 107) {
  27936. code = [value + 139];
  27937. } else if (value >= 108 && value <= 1131) {
  27938. value -= 108;
  27939. code = [(value >> 8) + 247, value & 0xff];
  27940. } else if (value >= -1131 && value <= -108) {
  27941. value = -value - 108;
  27942. code = [(value >> 8) + 251, value & 0xff];
  27943. } else if (value >= -32768 && value <= 32767) {
  27944. code = [0x1c, value >> 8 & 0xff, value & 0xff];
  27945. } else {
  27946. code = [0x1d, value >> 24 & 0xff, value >> 16 & 0xff, value >> 8 & 0xff, value & 0xff];
  27947. }
  27948. return code;
  27949. }
  27950. compileHeader(header) {
  27951. return [header.major, header.minor, 4, header.offSize];
  27952. }
  27953. compileNameIndex(names) {
  27954. const nameIndex = new CFFIndex();
  27955. for (const name of names) {
  27956. const length = Math.min(name.length, 127);
  27957. let sanitizedName = new Array(length);
  27958. for (let j = 0; j < length; j++) {
  27959. let char = name[j];
  27960. if (char < "!" || char > "~" || char === "[" || char === "]" || char === "(" || char === ")" || char === "{" || char === "}" || char === "<" || char === ">" || char === "/" || char === "%") {
  27961. char = "_";
  27962. }
  27963. sanitizedName[j] = char;
  27964. }
  27965. sanitizedName = sanitizedName.join("");
  27966. if (sanitizedName === "") {
  27967. sanitizedName = "Bad_Font_Name";
  27968. }
  27969. nameIndex.add((0, _util.stringToBytes)(sanitizedName));
  27970. }
  27971. return this.compileIndex(nameIndex);
  27972. }
  27973. compileTopDicts(dicts, length, removeCidKeys) {
  27974. const fontDictTrackers = [];
  27975. let fdArrayIndex = new CFFIndex();
  27976. for (const fontDict of dicts) {
  27977. if (removeCidKeys) {
  27978. fontDict.removeByName("CIDFontVersion");
  27979. fontDict.removeByName("CIDFontRevision");
  27980. fontDict.removeByName("CIDFontType");
  27981. fontDict.removeByName("CIDCount");
  27982. fontDict.removeByName("UIDBase");
  27983. }
  27984. const fontDictTracker = new CFFOffsetTracker();
  27985. const fontDictData = this.compileDict(fontDict, fontDictTracker);
  27986. fontDictTrackers.push(fontDictTracker);
  27987. fdArrayIndex.add(fontDictData);
  27988. fontDictTracker.offset(length);
  27989. }
  27990. fdArrayIndex = this.compileIndex(fdArrayIndex, fontDictTrackers);
  27991. return {
  27992. trackers: fontDictTrackers,
  27993. output: fdArrayIndex
  27994. };
  27995. }
  27996. compilePrivateDicts(dicts, trackers, output) {
  27997. for (let i = 0, ii = dicts.length; i < ii; ++i) {
  27998. const fontDict = dicts[i];
  27999. const privateDict = fontDict.privateDict;
  28000. if (!privateDict || !fontDict.hasName("Private")) {
  28001. throw new _util.FormatError("There must be a private dictionary.");
  28002. }
  28003. const privateDictTracker = new CFFOffsetTracker();
  28004. const privateDictData = this.compileDict(privateDict, privateDictTracker);
  28005. let outputLength = output.length;
  28006. privateDictTracker.offset(outputLength);
  28007. if (!privateDictData.length) {
  28008. outputLength = 0;
  28009. }
  28010. trackers[i].setEntryLocation("Private", [privateDictData.length, outputLength], output);
  28011. output.add(privateDictData);
  28012. if (privateDict.subrsIndex && privateDict.hasName("Subrs")) {
  28013. const subrs = this.compileIndex(privateDict.subrsIndex);
  28014. privateDictTracker.setEntryLocation("Subrs", [privateDictData.length], output);
  28015. output.add(subrs);
  28016. }
  28017. }
  28018. }
  28019. compileDict(dict, offsetTracker) {
  28020. const out = [];
  28021. for (const key of dict.order) {
  28022. if (!(key in dict.values)) {
  28023. continue;
  28024. }
  28025. let values = dict.values[key];
  28026. let types = dict.types[key];
  28027. if (!Array.isArray(types)) {
  28028. types = [types];
  28029. }
  28030. if (!Array.isArray(values)) {
  28031. values = [values];
  28032. }
  28033. if (values.length === 0) {
  28034. continue;
  28035. }
  28036. for (let j = 0, jj = types.length; j < jj; ++j) {
  28037. const type = types[j];
  28038. const value = values[j];
  28039. switch (type) {
  28040. case "num":
  28041. case "sid":
  28042. out.push(...this.encodeNumber(value));
  28043. break;
  28044. case "offset":
  28045. const name = dict.keyToNameMap[key];
  28046. if (!offsetTracker.isTracking(name)) {
  28047. offsetTracker.track(name, out.length);
  28048. }
  28049. out.push(0x1d, 0, 0, 0, 0);
  28050. break;
  28051. case "array":
  28052. case "delta":
  28053. out.push(...this.encodeNumber(value));
  28054. for (let k = 1, kk = values.length; k < kk; ++k) {
  28055. out.push(...this.encodeNumber(values[k]));
  28056. }
  28057. break;
  28058. default:
  28059. throw new _util.FormatError(`Unknown data type of ${type}`);
  28060. }
  28061. }
  28062. out.push(...dict.opcodes[key]);
  28063. }
  28064. return out;
  28065. }
  28066. compileStringIndex(strings) {
  28067. const stringIndex = new CFFIndex();
  28068. for (const string of strings) {
  28069. stringIndex.add((0, _util.stringToBytes)(string));
  28070. }
  28071. return this.compileIndex(stringIndex);
  28072. }
  28073. compileCharStrings(charStrings) {
  28074. const charStringsIndex = new CFFIndex();
  28075. for (let i = 0; i < charStrings.count; i++) {
  28076. const glyph = charStrings.get(i);
  28077. if (glyph.length === 0) {
  28078. charStringsIndex.add(new Uint8Array([0x8b, 0x0e]));
  28079. continue;
  28080. }
  28081. charStringsIndex.add(glyph);
  28082. }
  28083. return this.compileIndex(charStringsIndex);
  28084. }
  28085. compileCharset(charset, numGlyphs, strings, isCIDFont) {
  28086. let out;
  28087. const numGlyphsLessNotDef = numGlyphs - 1;
  28088. if (isCIDFont) {
  28089. out = new Uint8Array([2, 0, 0, numGlyphsLessNotDef >> 8 & 0xff, numGlyphsLessNotDef & 0xff]);
  28090. } else {
  28091. const length = 1 + numGlyphsLessNotDef * 2;
  28092. out = new Uint8Array(length);
  28093. out[0] = 0;
  28094. let charsetIndex = 0;
  28095. const numCharsets = charset.charset.length;
  28096. let warned = false;
  28097. for (let i = 1; i < out.length; i += 2) {
  28098. let sid = 0;
  28099. if (charsetIndex < numCharsets) {
  28100. const name = charset.charset[charsetIndex++];
  28101. sid = strings.getSID(name);
  28102. if (sid === -1) {
  28103. sid = 0;
  28104. if (!warned) {
  28105. warned = true;
  28106. (0, _util.warn)(`Couldn't find ${name} in CFF strings`);
  28107. }
  28108. }
  28109. }
  28110. out[i] = sid >> 8 & 0xff;
  28111. out[i + 1] = sid & 0xff;
  28112. }
  28113. }
  28114. return this.compileTypedArray(out);
  28115. }
  28116. compileEncoding(encoding) {
  28117. return this.compileTypedArray(encoding.raw);
  28118. }
  28119. compileFDSelect(fdSelect) {
  28120. const format = fdSelect.format;
  28121. let out, i;
  28122. switch (format) {
  28123. case 0:
  28124. out = new Uint8Array(1 + fdSelect.fdSelect.length);
  28125. out[0] = format;
  28126. for (i = 0; i < fdSelect.fdSelect.length; i++) {
  28127. out[i + 1] = fdSelect.fdSelect[i];
  28128. }
  28129. break;
  28130. case 3:
  28131. const start = 0;
  28132. let lastFD = fdSelect.fdSelect[0];
  28133. const ranges = [format, 0, 0, start >> 8 & 0xff, start & 0xff, lastFD];
  28134. for (i = 1; i < fdSelect.fdSelect.length; i++) {
  28135. const currentFD = fdSelect.fdSelect[i];
  28136. if (currentFD !== lastFD) {
  28137. ranges.push(i >> 8 & 0xff, i & 0xff, currentFD);
  28138. lastFD = currentFD;
  28139. }
  28140. }
  28141. const numRanges = (ranges.length - 3) / 3;
  28142. ranges[1] = numRanges >> 8 & 0xff;
  28143. ranges[2] = numRanges & 0xff;
  28144. ranges.push(i >> 8 & 0xff, i & 0xff);
  28145. out = new Uint8Array(ranges);
  28146. break;
  28147. }
  28148. return this.compileTypedArray(out);
  28149. }
  28150. compileTypedArray(data) {
  28151. return Array.from(data);
  28152. }
  28153. compileIndex(index) {
  28154. let trackers = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
  28155. const objects = index.objects;
  28156. const count = objects.length;
  28157. if (count === 0) {
  28158. return [0, 0];
  28159. }
  28160. const data = [count >> 8 & 0xff, count & 0xff];
  28161. let lastOffset = 1,
  28162. i;
  28163. for (i = 0; i < count; ++i) {
  28164. lastOffset += objects[i].length;
  28165. }
  28166. let offsetSize;
  28167. if (lastOffset < 0x100) {
  28168. offsetSize = 1;
  28169. } else if (lastOffset < 0x10000) {
  28170. offsetSize = 2;
  28171. } else if (lastOffset < 0x1000000) {
  28172. offsetSize = 3;
  28173. } else {
  28174. offsetSize = 4;
  28175. }
  28176. data.push(offsetSize);
  28177. let relativeOffset = 1;
  28178. for (i = 0; i < count + 1; i++) {
  28179. if (offsetSize === 1) {
  28180. data.push(relativeOffset & 0xff);
  28181. } else if (offsetSize === 2) {
  28182. data.push(relativeOffset >> 8 & 0xff, relativeOffset & 0xff);
  28183. } else if (offsetSize === 3) {
  28184. data.push(relativeOffset >> 16 & 0xff, relativeOffset >> 8 & 0xff, relativeOffset & 0xff);
  28185. } else {
  28186. data.push(relativeOffset >>> 24 & 0xff, relativeOffset >> 16 & 0xff, relativeOffset >> 8 & 0xff, relativeOffset & 0xff);
  28187. }
  28188. if (objects[i]) {
  28189. relativeOffset += objects[i].length;
  28190. }
  28191. }
  28192. for (i = 0; i < count; i++) {
  28193. if (trackers[i]) {
  28194. trackers[i].offset(data.length);
  28195. }
  28196. data.push(...objects[i]);
  28197. }
  28198. return data;
  28199. }
  28200. }
  28201. exports.CFFCompiler = CFFCompiler;
  28202. /***/ }),
  28203. /* 187 */
  28204. /***/ ((__unused_webpack_module, exports) => {
  28205. Object.defineProperty(exports, "__esModule", ({
  28206. value: true
  28207. }));
  28208. exports.ISOAdobeCharset = exports.ExpertSubsetCharset = exports.ExpertCharset = void 0;
  28209. 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"];
  28210. exports.ISOAdobeCharset = ISOAdobeCharset;
  28211. 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"];
  28212. exports.ExpertCharset = ExpertCharset;
  28213. 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"];
  28214. exports.ExpertSubsetCharset = ExpertSubsetCharset;
  28215. /***/ }),
  28216. /* 188 */
  28217. /***/ ((__unused_webpack_module, exports) => {
  28218. Object.defineProperty(exports, "__esModule", ({
  28219. value: true
  28220. }));
  28221. exports.ZapfDingbatsEncoding = exports.WinAnsiEncoding = exports.SymbolSetEncoding = exports.StandardEncoding = exports.MacRomanEncoding = exports.ExpertEncoding = void 0;
  28222. exports.getEncoding = getEncoding;
  28223. 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"];
  28224. exports.ExpertEncoding = ExpertEncoding;
  28225. 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", "", "", "", ""];
  28226. 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"];
  28227. exports.MacRomanEncoding = MacRomanEncoding;
  28228. 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", "", "", "", ""];
  28229. exports.StandardEncoding = StandardEncoding;
  28230. 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"];
  28231. exports.WinAnsiEncoding = WinAnsiEncoding;
  28232. 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", ""];
  28233. exports.SymbolSetEncoding = SymbolSetEncoding;
  28234. 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", ""];
  28235. exports.ZapfDingbatsEncoding = ZapfDingbatsEncoding;
  28236. function getEncoding(encodingName) {
  28237. switch (encodingName) {
  28238. case "WinAnsiEncoding":
  28239. return WinAnsiEncoding;
  28240. case "StandardEncoding":
  28241. return StandardEncoding;
  28242. case "MacRomanEncoding":
  28243. return MacRomanEncoding;
  28244. case "SymbolSetEncoding":
  28245. return SymbolSetEncoding;
  28246. case "ZapfDingbatsEncoding":
  28247. return ZapfDingbatsEncoding;
  28248. case "ExpertEncoding":
  28249. return ExpertEncoding;
  28250. case "MacExpertEncoding":
  28251. return MacExpertEncoding;
  28252. default:
  28253. return null;
  28254. }
  28255. }
  28256. /***/ }),
  28257. /* 189 */
  28258. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  28259. Object.defineProperty(exports, "__esModule", ({
  28260. value: true
  28261. }));
  28262. exports.SEAC_ANALYSIS_ENABLED = exports.MacStandardGlyphOrdering = exports.FontFlags = void 0;
  28263. exports.normalizeFontName = normalizeFontName;
  28264. exports.recoverGlyphName = recoverGlyphName;
  28265. exports.type1FontGlyphMapping = type1FontGlyphMapping;
  28266. __w_pdfjs_require__(158);
  28267. var _encodings = __w_pdfjs_require__(188);
  28268. var _glyphlist = __w_pdfjs_require__(190);
  28269. var _unicode = __w_pdfjs_require__(191);
  28270. var _util = __w_pdfjs_require__(145);
  28271. const SEAC_ANALYSIS_ENABLED = true;
  28272. exports.SEAC_ANALYSIS_ENABLED = SEAC_ANALYSIS_ENABLED;
  28273. const FontFlags = {
  28274. FixedPitch: 1,
  28275. Serif: 2,
  28276. Symbolic: 4,
  28277. Script: 8,
  28278. Nonsymbolic: 32,
  28279. Italic: 64,
  28280. AllCap: 65536,
  28281. SmallCap: 131072,
  28282. ForceBold: 262144
  28283. };
  28284. exports.FontFlags = FontFlags;
  28285. 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"];
  28286. exports.MacStandardGlyphOrdering = MacStandardGlyphOrdering;
  28287. function recoverGlyphName(name, glyphsUnicodeMap) {
  28288. if (glyphsUnicodeMap[name] !== undefined) {
  28289. return name;
  28290. }
  28291. const unicode = (0, _unicode.getUnicodeForGlyph)(name, glyphsUnicodeMap);
  28292. if (unicode !== -1) {
  28293. for (const key in glyphsUnicodeMap) {
  28294. if (glyphsUnicodeMap[key] === unicode) {
  28295. return key;
  28296. }
  28297. }
  28298. }
  28299. (0, _util.info)("Unable to recover a standard glyph name for: " + name);
  28300. return name;
  28301. }
  28302. function type1FontGlyphMapping(properties, builtInEncoding, glyphNames) {
  28303. const charCodeToGlyphId = Object.create(null);
  28304. let glyphId, charCode, baseEncoding;
  28305. const isSymbolicFont = !!(properties.flags & FontFlags.Symbolic);
  28306. if (properties.isInternalFont) {
  28307. baseEncoding = builtInEncoding;
  28308. for (charCode = 0; charCode < baseEncoding.length; charCode++) {
  28309. glyphId = glyphNames.indexOf(baseEncoding[charCode]);
  28310. charCodeToGlyphId[charCode] = glyphId >= 0 ? glyphId : 0;
  28311. }
  28312. } else if (properties.baseEncodingName) {
  28313. baseEncoding = (0, _encodings.getEncoding)(properties.baseEncodingName);
  28314. for (charCode = 0; charCode < baseEncoding.length; charCode++) {
  28315. glyphId = glyphNames.indexOf(baseEncoding[charCode]);
  28316. charCodeToGlyphId[charCode] = glyphId >= 0 ? glyphId : 0;
  28317. }
  28318. } else if (isSymbolicFont) {
  28319. for (charCode in builtInEncoding) {
  28320. charCodeToGlyphId[charCode] = builtInEncoding[charCode];
  28321. }
  28322. } else {
  28323. baseEncoding = _encodings.StandardEncoding;
  28324. for (charCode = 0; charCode < baseEncoding.length; charCode++) {
  28325. glyphId = glyphNames.indexOf(baseEncoding[charCode]);
  28326. charCodeToGlyphId[charCode] = glyphId >= 0 ? glyphId : 0;
  28327. }
  28328. }
  28329. const differences = properties.differences;
  28330. let glyphsUnicodeMap;
  28331. if (differences) {
  28332. for (charCode in differences) {
  28333. const glyphName = differences[charCode];
  28334. glyphId = glyphNames.indexOf(glyphName);
  28335. if (glyphId === -1) {
  28336. if (!glyphsUnicodeMap) {
  28337. glyphsUnicodeMap = (0, _glyphlist.getGlyphsUnicode)();
  28338. }
  28339. const standardGlyphName = recoverGlyphName(glyphName, glyphsUnicodeMap);
  28340. if (standardGlyphName !== glyphName) {
  28341. glyphId = glyphNames.indexOf(standardGlyphName);
  28342. }
  28343. }
  28344. charCodeToGlyphId[charCode] = glyphId >= 0 ? glyphId : 0;
  28345. }
  28346. }
  28347. return charCodeToGlyphId;
  28348. }
  28349. function normalizeFontName(name) {
  28350. return name.replaceAll(/[,_]/g, "-").replaceAll(/\s/g, "");
  28351. }
  28352. /***/ }),
  28353. /* 190 */
  28354. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  28355. Object.defineProperty(exports, "__esModule", ({
  28356. value: true
  28357. }));
  28358. exports.getGlyphsUnicode = exports.getDingbatsGlyphsUnicode = void 0;
  28359. var _core_utils = __w_pdfjs_require__(150);
  28360. const getGlyphsUnicode = (0, _core_utils.getLookupTableFactory)(function (t) {
  28361. t.A = 0x0041;
  28362. t.AE = 0x00c6;
  28363. t.AEacute = 0x01fc;
  28364. t.AEmacron = 0x01e2;
  28365. t.AEsmall = 0xf7e6;
  28366. t.Aacute = 0x00c1;
  28367. t.Aacutesmall = 0xf7e1;
  28368. t.Abreve = 0x0102;
  28369. t.Abreveacute = 0x1eae;
  28370. t.Abrevecyrillic = 0x04d0;
  28371. t.Abrevedotbelow = 0x1eb6;
  28372. t.Abrevegrave = 0x1eb0;
  28373. t.Abrevehookabove = 0x1eb2;
  28374. t.Abrevetilde = 0x1eb4;
  28375. t.Acaron = 0x01cd;
  28376. t.Acircle = 0x24b6;
  28377. t.Acircumflex = 0x00c2;
  28378. t.Acircumflexacute = 0x1ea4;
  28379. t.Acircumflexdotbelow = 0x1eac;
  28380. t.Acircumflexgrave = 0x1ea6;
  28381. t.Acircumflexhookabove = 0x1ea8;
  28382. t.Acircumflexsmall = 0xf7e2;
  28383. t.Acircumflextilde = 0x1eaa;
  28384. t.Acute = 0xf6c9;
  28385. t.Acutesmall = 0xf7b4;
  28386. t.Acyrillic = 0x0410;
  28387. t.Adblgrave = 0x0200;
  28388. t.Adieresis = 0x00c4;
  28389. t.Adieresiscyrillic = 0x04d2;
  28390. t.Adieresismacron = 0x01de;
  28391. t.Adieresissmall = 0xf7e4;
  28392. t.Adotbelow = 0x1ea0;
  28393. t.Adotmacron = 0x01e0;
  28394. t.Agrave = 0x00c0;
  28395. t.Agravesmall = 0xf7e0;
  28396. t.Ahookabove = 0x1ea2;
  28397. t.Aiecyrillic = 0x04d4;
  28398. t.Ainvertedbreve = 0x0202;
  28399. t.Alpha = 0x0391;
  28400. t.Alphatonos = 0x0386;
  28401. t.Amacron = 0x0100;
  28402. t.Amonospace = 0xff21;
  28403. t.Aogonek = 0x0104;
  28404. t.Aring = 0x00c5;
  28405. t.Aringacute = 0x01fa;
  28406. t.Aringbelow = 0x1e00;
  28407. t.Aringsmall = 0xf7e5;
  28408. t.Asmall = 0xf761;
  28409. t.Atilde = 0x00c3;
  28410. t.Atildesmall = 0xf7e3;
  28411. t.Aybarmenian = 0x0531;
  28412. t.B = 0x0042;
  28413. t.Bcircle = 0x24b7;
  28414. t.Bdotaccent = 0x1e02;
  28415. t.Bdotbelow = 0x1e04;
  28416. t.Becyrillic = 0x0411;
  28417. t.Benarmenian = 0x0532;
  28418. t.Beta = 0x0392;
  28419. t.Bhook = 0x0181;
  28420. t.Blinebelow = 0x1e06;
  28421. t.Bmonospace = 0xff22;
  28422. t.Brevesmall = 0xf6f4;
  28423. t.Bsmall = 0xf762;
  28424. t.Btopbar = 0x0182;
  28425. t.C = 0x0043;
  28426. t.Caarmenian = 0x053e;
  28427. t.Cacute = 0x0106;
  28428. t.Caron = 0xf6ca;
  28429. t.Caronsmall = 0xf6f5;
  28430. t.Ccaron = 0x010c;
  28431. t.Ccedilla = 0x00c7;
  28432. t.Ccedillaacute = 0x1e08;
  28433. t.Ccedillasmall = 0xf7e7;
  28434. t.Ccircle = 0x24b8;
  28435. t.Ccircumflex = 0x0108;
  28436. t.Cdot = 0x010a;
  28437. t.Cdotaccent = 0x010a;
  28438. t.Cedillasmall = 0xf7b8;
  28439. t.Chaarmenian = 0x0549;
  28440. t.Cheabkhasiancyrillic = 0x04bc;
  28441. t.Checyrillic = 0x0427;
  28442. t.Chedescenderabkhasiancyrillic = 0x04be;
  28443. t.Chedescendercyrillic = 0x04b6;
  28444. t.Chedieresiscyrillic = 0x04f4;
  28445. t.Cheharmenian = 0x0543;
  28446. t.Chekhakassiancyrillic = 0x04cb;
  28447. t.Cheverticalstrokecyrillic = 0x04b8;
  28448. t.Chi = 0x03a7;
  28449. t.Chook = 0x0187;
  28450. t.Circumflexsmall = 0xf6f6;
  28451. t.Cmonospace = 0xff23;
  28452. t.Coarmenian = 0x0551;
  28453. t.Csmall = 0xf763;
  28454. t.D = 0x0044;
  28455. t.DZ = 0x01f1;
  28456. t.DZcaron = 0x01c4;
  28457. t.Daarmenian = 0x0534;
  28458. t.Dafrican = 0x0189;
  28459. t.Dcaron = 0x010e;
  28460. t.Dcedilla = 0x1e10;
  28461. t.Dcircle = 0x24b9;
  28462. t.Dcircumflexbelow = 0x1e12;
  28463. t.Dcroat = 0x0110;
  28464. t.Ddotaccent = 0x1e0a;
  28465. t.Ddotbelow = 0x1e0c;
  28466. t.Decyrillic = 0x0414;
  28467. t.Deicoptic = 0x03ee;
  28468. t.Delta = 0x2206;
  28469. t.Deltagreek = 0x0394;
  28470. t.Dhook = 0x018a;
  28471. t.Dieresis = 0xf6cb;
  28472. t.DieresisAcute = 0xf6cc;
  28473. t.DieresisGrave = 0xf6cd;
  28474. t.Dieresissmall = 0xf7a8;
  28475. t.Digammagreek = 0x03dc;
  28476. t.Djecyrillic = 0x0402;
  28477. t.Dlinebelow = 0x1e0e;
  28478. t.Dmonospace = 0xff24;
  28479. t.Dotaccentsmall = 0xf6f7;
  28480. t.Dslash = 0x0110;
  28481. t.Dsmall = 0xf764;
  28482. t.Dtopbar = 0x018b;
  28483. t.Dz = 0x01f2;
  28484. t.Dzcaron = 0x01c5;
  28485. t.Dzeabkhasiancyrillic = 0x04e0;
  28486. t.Dzecyrillic = 0x0405;
  28487. t.Dzhecyrillic = 0x040f;
  28488. t.E = 0x0045;
  28489. t.Eacute = 0x00c9;
  28490. t.Eacutesmall = 0xf7e9;
  28491. t.Ebreve = 0x0114;
  28492. t.Ecaron = 0x011a;
  28493. t.Ecedillabreve = 0x1e1c;
  28494. t.Echarmenian = 0x0535;
  28495. t.Ecircle = 0x24ba;
  28496. t.Ecircumflex = 0x00ca;
  28497. t.Ecircumflexacute = 0x1ebe;
  28498. t.Ecircumflexbelow = 0x1e18;
  28499. t.Ecircumflexdotbelow = 0x1ec6;
  28500. t.Ecircumflexgrave = 0x1ec0;
  28501. t.Ecircumflexhookabove = 0x1ec2;
  28502. t.Ecircumflexsmall = 0xf7ea;
  28503. t.Ecircumflextilde = 0x1ec4;
  28504. t.Ecyrillic = 0x0404;
  28505. t.Edblgrave = 0x0204;
  28506. t.Edieresis = 0x00cb;
  28507. t.Edieresissmall = 0xf7eb;
  28508. t.Edot = 0x0116;
  28509. t.Edotaccent = 0x0116;
  28510. t.Edotbelow = 0x1eb8;
  28511. t.Efcyrillic = 0x0424;
  28512. t.Egrave = 0x00c8;
  28513. t.Egravesmall = 0xf7e8;
  28514. t.Eharmenian = 0x0537;
  28515. t.Ehookabove = 0x1eba;
  28516. t.Eightroman = 0x2167;
  28517. t.Einvertedbreve = 0x0206;
  28518. t.Eiotifiedcyrillic = 0x0464;
  28519. t.Elcyrillic = 0x041b;
  28520. t.Elevenroman = 0x216a;
  28521. t.Emacron = 0x0112;
  28522. t.Emacronacute = 0x1e16;
  28523. t.Emacrongrave = 0x1e14;
  28524. t.Emcyrillic = 0x041c;
  28525. t.Emonospace = 0xff25;
  28526. t.Encyrillic = 0x041d;
  28527. t.Endescendercyrillic = 0x04a2;
  28528. t.Eng = 0x014a;
  28529. t.Enghecyrillic = 0x04a4;
  28530. t.Enhookcyrillic = 0x04c7;
  28531. t.Eogonek = 0x0118;
  28532. t.Eopen = 0x0190;
  28533. t.Epsilon = 0x0395;
  28534. t.Epsilontonos = 0x0388;
  28535. t.Ercyrillic = 0x0420;
  28536. t.Ereversed = 0x018e;
  28537. t.Ereversedcyrillic = 0x042d;
  28538. t.Escyrillic = 0x0421;
  28539. t.Esdescendercyrillic = 0x04aa;
  28540. t.Esh = 0x01a9;
  28541. t.Esmall = 0xf765;
  28542. t.Eta = 0x0397;
  28543. t.Etarmenian = 0x0538;
  28544. t.Etatonos = 0x0389;
  28545. t.Eth = 0x00d0;
  28546. t.Ethsmall = 0xf7f0;
  28547. t.Etilde = 0x1ebc;
  28548. t.Etildebelow = 0x1e1a;
  28549. t.Euro = 0x20ac;
  28550. t.Ezh = 0x01b7;
  28551. t.Ezhcaron = 0x01ee;
  28552. t.Ezhreversed = 0x01b8;
  28553. t.F = 0x0046;
  28554. t.Fcircle = 0x24bb;
  28555. t.Fdotaccent = 0x1e1e;
  28556. t.Feharmenian = 0x0556;
  28557. t.Feicoptic = 0x03e4;
  28558. t.Fhook = 0x0191;
  28559. t.Fitacyrillic = 0x0472;
  28560. t.Fiveroman = 0x2164;
  28561. t.Fmonospace = 0xff26;
  28562. t.Fourroman = 0x2163;
  28563. t.Fsmall = 0xf766;
  28564. t.G = 0x0047;
  28565. t.GBsquare = 0x3387;
  28566. t.Gacute = 0x01f4;
  28567. t.Gamma = 0x0393;
  28568. t.Gammaafrican = 0x0194;
  28569. t.Gangiacoptic = 0x03ea;
  28570. t.Gbreve = 0x011e;
  28571. t.Gcaron = 0x01e6;
  28572. t.Gcedilla = 0x0122;
  28573. t.Gcircle = 0x24bc;
  28574. t.Gcircumflex = 0x011c;
  28575. t.Gcommaaccent = 0x0122;
  28576. t.Gdot = 0x0120;
  28577. t.Gdotaccent = 0x0120;
  28578. t.Gecyrillic = 0x0413;
  28579. t.Ghadarmenian = 0x0542;
  28580. t.Ghemiddlehookcyrillic = 0x0494;
  28581. t.Ghestrokecyrillic = 0x0492;
  28582. t.Gheupturncyrillic = 0x0490;
  28583. t.Ghook = 0x0193;
  28584. t.Gimarmenian = 0x0533;
  28585. t.Gjecyrillic = 0x0403;
  28586. t.Gmacron = 0x1e20;
  28587. t.Gmonospace = 0xff27;
  28588. t.Grave = 0xf6ce;
  28589. t.Gravesmall = 0xf760;
  28590. t.Gsmall = 0xf767;
  28591. t.Gsmallhook = 0x029b;
  28592. t.Gstroke = 0x01e4;
  28593. t.H = 0x0048;
  28594. t.H18533 = 0x25cf;
  28595. t.H18543 = 0x25aa;
  28596. t.H18551 = 0x25ab;
  28597. t.H22073 = 0x25a1;
  28598. t.HPsquare = 0x33cb;
  28599. t.Haabkhasiancyrillic = 0x04a8;
  28600. t.Hadescendercyrillic = 0x04b2;
  28601. t.Hardsigncyrillic = 0x042a;
  28602. t.Hbar = 0x0126;
  28603. t.Hbrevebelow = 0x1e2a;
  28604. t.Hcedilla = 0x1e28;
  28605. t.Hcircle = 0x24bd;
  28606. t.Hcircumflex = 0x0124;
  28607. t.Hdieresis = 0x1e26;
  28608. t.Hdotaccent = 0x1e22;
  28609. t.Hdotbelow = 0x1e24;
  28610. t.Hmonospace = 0xff28;
  28611. t.Hoarmenian = 0x0540;
  28612. t.Horicoptic = 0x03e8;
  28613. t.Hsmall = 0xf768;
  28614. t.Hungarumlaut = 0xf6cf;
  28615. t.Hungarumlautsmall = 0xf6f8;
  28616. t.Hzsquare = 0x3390;
  28617. t.I = 0x0049;
  28618. t.IAcyrillic = 0x042f;
  28619. t.IJ = 0x0132;
  28620. t.IUcyrillic = 0x042e;
  28621. t.Iacute = 0x00cd;
  28622. t.Iacutesmall = 0xf7ed;
  28623. t.Ibreve = 0x012c;
  28624. t.Icaron = 0x01cf;
  28625. t.Icircle = 0x24be;
  28626. t.Icircumflex = 0x00ce;
  28627. t.Icircumflexsmall = 0xf7ee;
  28628. t.Icyrillic = 0x0406;
  28629. t.Idblgrave = 0x0208;
  28630. t.Idieresis = 0x00cf;
  28631. t.Idieresisacute = 0x1e2e;
  28632. t.Idieresiscyrillic = 0x04e4;
  28633. t.Idieresissmall = 0xf7ef;
  28634. t.Idot = 0x0130;
  28635. t.Idotaccent = 0x0130;
  28636. t.Idotbelow = 0x1eca;
  28637. t.Iebrevecyrillic = 0x04d6;
  28638. t.Iecyrillic = 0x0415;
  28639. t.Ifraktur = 0x2111;
  28640. t.Igrave = 0x00cc;
  28641. t.Igravesmall = 0xf7ec;
  28642. t.Ihookabove = 0x1ec8;
  28643. t.Iicyrillic = 0x0418;
  28644. t.Iinvertedbreve = 0x020a;
  28645. t.Iishortcyrillic = 0x0419;
  28646. t.Imacron = 0x012a;
  28647. t.Imacroncyrillic = 0x04e2;
  28648. t.Imonospace = 0xff29;
  28649. t.Iniarmenian = 0x053b;
  28650. t.Iocyrillic = 0x0401;
  28651. t.Iogonek = 0x012e;
  28652. t.Iota = 0x0399;
  28653. t.Iotaafrican = 0x0196;
  28654. t.Iotadieresis = 0x03aa;
  28655. t.Iotatonos = 0x038a;
  28656. t.Ismall = 0xf769;
  28657. t.Istroke = 0x0197;
  28658. t.Itilde = 0x0128;
  28659. t.Itildebelow = 0x1e2c;
  28660. t.Izhitsacyrillic = 0x0474;
  28661. t.Izhitsadblgravecyrillic = 0x0476;
  28662. t.J = 0x004a;
  28663. t.Jaarmenian = 0x0541;
  28664. t.Jcircle = 0x24bf;
  28665. t.Jcircumflex = 0x0134;
  28666. t.Jecyrillic = 0x0408;
  28667. t.Jheharmenian = 0x054b;
  28668. t.Jmonospace = 0xff2a;
  28669. t.Jsmall = 0xf76a;
  28670. t.K = 0x004b;
  28671. t.KBsquare = 0x3385;
  28672. t.KKsquare = 0x33cd;
  28673. t.Kabashkircyrillic = 0x04a0;
  28674. t.Kacute = 0x1e30;
  28675. t.Kacyrillic = 0x041a;
  28676. t.Kadescendercyrillic = 0x049a;
  28677. t.Kahookcyrillic = 0x04c3;
  28678. t.Kappa = 0x039a;
  28679. t.Kastrokecyrillic = 0x049e;
  28680. t.Kaverticalstrokecyrillic = 0x049c;
  28681. t.Kcaron = 0x01e8;
  28682. t.Kcedilla = 0x0136;
  28683. t.Kcircle = 0x24c0;
  28684. t.Kcommaaccent = 0x0136;
  28685. t.Kdotbelow = 0x1e32;
  28686. t.Keharmenian = 0x0554;
  28687. t.Kenarmenian = 0x053f;
  28688. t.Khacyrillic = 0x0425;
  28689. t.Kheicoptic = 0x03e6;
  28690. t.Khook = 0x0198;
  28691. t.Kjecyrillic = 0x040c;
  28692. t.Klinebelow = 0x1e34;
  28693. t.Kmonospace = 0xff2b;
  28694. t.Koppacyrillic = 0x0480;
  28695. t.Koppagreek = 0x03de;
  28696. t.Ksicyrillic = 0x046e;
  28697. t.Ksmall = 0xf76b;
  28698. t.L = 0x004c;
  28699. t.LJ = 0x01c7;
  28700. t.LL = 0xf6bf;
  28701. t.Lacute = 0x0139;
  28702. t.Lambda = 0x039b;
  28703. t.Lcaron = 0x013d;
  28704. t.Lcedilla = 0x013b;
  28705. t.Lcircle = 0x24c1;
  28706. t.Lcircumflexbelow = 0x1e3c;
  28707. t.Lcommaaccent = 0x013b;
  28708. t.Ldot = 0x013f;
  28709. t.Ldotaccent = 0x013f;
  28710. t.Ldotbelow = 0x1e36;
  28711. t.Ldotbelowmacron = 0x1e38;
  28712. t.Liwnarmenian = 0x053c;
  28713. t.Lj = 0x01c8;
  28714. t.Ljecyrillic = 0x0409;
  28715. t.Llinebelow = 0x1e3a;
  28716. t.Lmonospace = 0xff2c;
  28717. t.Lslash = 0x0141;
  28718. t.Lslashsmall = 0xf6f9;
  28719. t.Lsmall = 0xf76c;
  28720. t.M = 0x004d;
  28721. t.MBsquare = 0x3386;
  28722. t.Macron = 0xf6d0;
  28723. t.Macronsmall = 0xf7af;
  28724. t.Macute = 0x1e3e;
  28725. t.Mcircle = 0x24c2;
  28726. t.Mdotaccent = 0x1e40;
  28727. t.Mdotbelow = 0x1e42;
  28728. t.Menarmenian = 0x0544;
  28729. t.Mmonospace = 0xff2d;
  28730. t.Msmall = 0xf76d;
  28731. t.Mturned = 0x019c;
  28732. t.Mu = 0x039c;
  28733. t.N = 0x004e;
  28734. t.NJ = 0x01ca;
  28735. t.Nacute = 0x0143;
  28736. t.Ncaron = 0x0147;
  28737. t.Ncedilla = 0x0145;
  28738. t.Ncircle = 0x24c3;
  28739. t.Ncircumflexbelow = 0x1e4a;
  28740. t.Ncommaaccent = 0x0145;
  28741. t.Ndotaccent = 0x1e44;
  28742. t.Ndotbelow = 0x1e46;
  28743. t.Nhookleft = 0x019d;
  28744. t.Nineroman = 0x2168;
  28745. t.Nj = 0x01cb;
  28746. t.Njecyrillic = 0x040a;
  28747. t.Nlinebelow = 0x1e48;
  28748. t.Nmonospace = 0xff2e;
  28749. t.Nowarmenian = 0x0546;
  28750. t.Nsmall = 0xf76e;
  28751. t.Ntilde = 0x00d1;
  28752. t.Ntildesmall = 0xf7f1;
  28753. t.Nu = 0x039d;
  28754. t.O = 0x004f;
  28755. t.OE = 0x0152;
  28756. t.OEsmall = 0xf6fa;
  28757. t.Oacute = 0x00d3;
  28758. t.Oacutesmall = 0xf7f3;
  28759. t.Obarredcyrillic = 0x04e8;
  28760. t.Obarreddieresiscyrillic = 0x04ea;
  28761. t.Obreve = 0x014e;
  28762. t.Ocaron = 0x01d1;
  28763. t.Ocenteredtilde = 0x019f;
  28764. t.Ocircle = 0x24c4;
  28765. t.Ocircumflex = 0x00d4;
  28766. t.Ocircumflexacute = 0x1ed0;
  28767. t.Ocircumflexdotbelow = 0x1ed8;
  28768. t.Ocircumflexgrave = 0x1ed2;
  28769. t.Ocircumflexhookabove = 0x1ed4;
  28770. t.Ocircumflexsmall = 0xf7f4;
  28771. t.Ocircumflextilde = 0x1ed6;
  28772. t.Ocyrillic = 0x041e;
  28773. t.Odblacute = 0x0150;
  28774. t.Odblgrave = 0x020c;
  28775. t.Odieresis = 0x00d6;
  28776. t.Odieresiscyrillic = 0x04e6;
  28777. t.Odieresissmall = 0xf7f6;
  28778. t.Odotbelow = 0x1ecc;
  28779. t.Ogoneksmall = 0xf6fb;
  28780. t.Ograve = 0x00d2;
  28781. t.Ogravesmall = 0xf7f2;
  28782. t.Oharmenian = 0x0555;
  28783. t.Ohm = 0x2126;
  28784. t.Ohookabove = 0x1ece;
  28785. t.Ohorn = 0x01a0;
  28786. t.Ohornacute = 0x1eda;
  28787. t.Ohorndotbelow = 0x1ee2;
  28788. t.Ohorngrave = 0x1edc;
  28789. t.Ohornhookabove = 0x1ede;
  28790. t.Ohorntilde = 0x1ee0;
  28791. t.Ohungarumlaut = 0x0150;
  28792. t.Oi = 0x01a2;
  28793. t.Oinvertedbreve = 0x020e;
  28794. t.Omacron = 0x014c;
  28795. t.Omacronacute = 0x1e52;
  28796. t.Omacrongrave = 0x1e50;
  28797. t.Omega = 0x2126;
  28798. t.Omegacyrillic = 0x0460;
  28799. t.Omegagreek = 0x03a9;
  28800. t.Omegaroundcyrillic = 0x047a;
  28801. t.Omegatitlocyrillic = 0x047c;
  28802. t.Omegatonos = 0x038f;
  28803. t.Omicron = 0x039f;
  28804. t.Omicrontonos = 0x038c;
  28805. t.Omonospace = 0xff2f;
  28806. t.Oneroman = 0x2160;
  28807. t.Oogonek = 0x01ea;
  28808. t.Oogonekmacron = 0x01ec;
  28809. t.Oopen = 0x0186;
  28810. t.Oslash = 0x00d8;
  28811. t.Oslashacute = 0x01fe;
  28812. t.Oslashsmall = 0xf7f8;
  28813. t.Osmall = 0xf76f;
  28814. t.Ostrokeacute = 0x01fe;
  28815. t.Otcyrillic = 0x047e;
  28816. t.Otilde = 0x00d5;
  28817. t.Otildeacute = 0x1e4c;
  28818. t.Otildedieresis = 0x1e4e;
  28819. t.Otildesmall = 0xf7f5;
  28820. t.P = 0x0050;
  28821. t.Pacute = 0x1e54;
  28822. t.Pcircle = 0x24c5;
  28823. t.Pdotaccent = 0x1e56;
  28824. t.Pecyrillic = 0x041f;
  28825. t.Peharmenian = 0x054a;
  28826. t.Pemiddlehookcyrillic = 0x04a6;
  28827. t.Phi = 0x03a6;
  28828. t.Phook = 0x01a4;
  28829. t.Pi = 0x03a0;
  28830. t.Piwrarmenian = 0x0553;
  28831. t.Pmonospace = 0xff30;
  28832. t.Psi = 0x03a8;
  28833. t.Psicyrillic = 0x0470;
  28834. t.Psmall = 0xf770;
  28835. t.Q = 0x0051;
  28836. t.Qcircle = 0x24c6;
  28837. t.Qmonospace = 0xff31;
  28838. t.Qsmall = 0xf771;
  28839. t.R = 0x0052;
  28840. t.Raarmenian = 0x054c;
  28841. t.Racute = 0x0154;
  28842. t.Rcaron = 0x0158;
  28843. t.Rcedilla = 0x0156;
  28844. t.Rcircle = 0x24c7;
  28845. t.Rcommaaccent = 0x0156;
  28846. t.Rdblgrave = 0x0210;
  28847. t.Rdotaccent = 0x1e58;
  28848. t.Rdotbelow = 0x1e5a;
  28849. t.Rdotbelowmacron = 0x1e5c;
  28850. t.Reharmenian = 0x0550;
  28851. t.Rfraktur = 0x211c;
  28852. t.Rho = 0x03a1;
  28853. t.Ringsmall = 0xf6fc;
  28854. t.Rinvertedbreve = 0x0212;
  28855. t.Rlinebelow = 0x1e5e;
  28856. t.Rmonospace = 0xff32;
  28857. t.Rsmall = 0xf772;
  28858. t.Rsmallinverted = 0x0281;
  28859. t.Rsmallinvertedsuperior = 0x02b6;
  28860. t.S = 0x0053;
  28861. t.SF010000 = 0x250c;
  28862. t.SF020000 = 0x2514;
  28863. t.SF030000 = 0x2510;
  28864. t.SF040000 = 0x2518;
  28865. t.SF050000 = 0x253c;
  28866. t.SF060000 = 0x252c;
  28867. t.SF070000 = 0x2534;
  28868. t.SF080000 = 0x251c;
  28869. t.SF090000 = 0x2524;
  28870. t.SF100000 = 0x2500;
  28871. t.SF110000 = 0x2502;
  28872. t.SF190000 = 0x2561;
  28873. t.SF200000 = 0x2562;
  28874. t.SF210000 = 0x2556;
  28875. t.SF220000 = 0x2555;
  28876. t.SF230000 = 0x2563;
  28877. t.SF240000 = 0x2551;
  28878. t.SF250000 = 0x2557;
  28879. t.SF260000 = 0x255d;
  28880. t.SF270000 = 0x255c;
  28881. t.SF280000 = 0x255b;
  28882. t.SF360000 = 0x255e;
  28883. t.SF370000 = 0x255f;
  28884. t.SF380000 = 0x255a;
  28885. t.SF390000 = 0x2554;
  28886. t.SF400000 = 0x2569;
  28887. t.SF410000 = 0x2566;
  28888. t.SF420000 = 0x2560;
  28889. t.SF430000 = 0x2550;
  28890. t.SF440000 = 0x256c;
  28891. t.SF450000 = 0x2567;
  28892. t.SF460000 = 0x2568;
  28893. t.SF470000 = 0x2564;
  28894. t.SF480000 = 0x2565;
  28895. t.SF490000 = 0x2559;
  28896. t.SF500000 = 0x2558;
  28897. t.SF510000 = 0x2552;
  28898. t.SF520000 = 0x2553;
  28899. t.SF530000 = 0x256b;
  28900. t.SF540000 = 0x256a;
  28901. t.Sacute = 0x015a;
  28902. t.Sacutedotaccent = 0x1e64;
  28903. t.Sampigreek = 0x03e0;
  28904. t.Scaron = 0x0160;
  28905. t.Scarondotaccent = 0x1e66;
  28906. t.Scaronsmall = 0xf6fd;
  28907. t.Scedilla = 0x015e;
  28908. t.Schwa = 0x018f;
  28909. t.Schwacyrillic = 0x04d8;
  28910. t.Schwadieresiscyrillic = 0x04da;
  28911. t.Scircle = 0x24c8;
  28912. t.Scircumflex = 0x015c;
  28913. t.Scommaaccent = 0x0218;
  28914. t.Sdotaccent = 0x1e60;
  28915. t.Sdotbelow = 0x1e62;
  28916. t.Sdotbelowdotaccent = 0x1e68;
  28917. t.Seharmenian = 0x054d;
  28918. t.Sevenroman = 0x2166;
  28919. t.Shaarmenian = 0x0547;
  28920. t.Shacyrillic = 0x0428;
  28921. t.Shchacyrillic = 0x0429;
  28922. t.Sheicoptic = 0x03e2;
  28923. t.Shhacyrillic = 0x04ba;
  28924. t.Shimacoptic = 0x03ec;
  28925. t.Sigma = 0x03a3;
  28926. t.Sixroman = 0x2165;
  28927. t.Smonospace = 0xff33;
  28928. t.Softsigncyrillic = 0x042c;
  28929. t.Ssmall = 0xf773;
  28930. t.Stigmagreek = 0x03da;
  28931. t.T = 0x0054;
  28932. t.Tau = 0x03a4;
  28933. t.Tbar = 0x0166;
  28934. t.Tcaron = 0x0164;
  28935. t.Tcedilla = 0x0162;
  28936. t.Tcircle = 0x24c9;
  28937. t.Tcircumflexbelow = 0x1e70;
  28938. t.Tcommaaccent = 0x0162;
  28939. t.Tdotaccent = 0x1e6a;
  28940. t.Tdotbelow = 0x1e6c;
  28941. t.Tecyrillic = 0x0422;
  28942. t.Tedescendercyrillic = 0x04ac;
  28943. t.Tenroman = 0x2169;
  28944. t.Tetsecyrillic = 0x04b4;
  28945. t.Theta = 0x0398;
  28946. t.Thook = 0x01ac;
  28947. t.Thorn = 0x00de;
  28948. t.Thornsmall = 0xf7fe;
  28949. t.Threeroman = 0x2162;
  28950. t.Tildesmall = 0xf6fe;
  28951. t.Tiwnarmenian = 0x054f;
  28952. t.Tlinebelow = 0x1e6e;
  28953. t.Tmonospace = 0xff34;
  28954. t.Toarmenian = 0x0539;
  28955. t.Tonefive = 0x01bc;
  28956. t.Tonesix = 0x0184;
  28957. t.Tonetwo = 0x01a7;
  28958. t.Tretroflexhook = 0x01ae;
  28959. t.Tsecyrillic = 0x0426;
  28960. t.Tshecyrillic = 0x040b;
  28961. t.Tsmall = 0xf774;
  28962. t.Twelveroman = 0x216b;
  28963. t.Tworoman = 0x2161;
  28964. t.U = 0x0055;
  28965. t.Uacute = 0x00da;
  28966. t.Uacutesmall = 0xf7fa;
  28967. t.Ubreve = 0x016c;
  28968. t.Ucaron = 0x01d3;
  28969. t.Ucircle = 0x24ca;
  28970. t.Ucircumflex = 0x00db;
  28971. t.Ucircumflexbelow = 0x1e76;
  28972. t.Ucircumflexsmall = 0xf7fb;
  28973. t.Ucyrillic = 0x0423;
  28974. t.Udblacute = 0x0170;
  28975. t.Udblgrave = 0x0214;
  28976. t.Udieresis = 0x00dc;
  28977. t.Udieresisacute = 0x01d7;
  28978. t.Udieresisbelow = 0x1e72;
  28979. t.Udieresiscaron = 0x01d9;
  28980. t.Udieresiscyrillic = 0x04f0;
  28981. t.Udieresisgrave = 0x01db;
  28982. t.Udieresismacron = 0x01d5;
  28983. t.Udieresissmall = 0xf7fc;
  28984. t.Udotbelow = 0x1ee4;
  28985. t.Ugrave = 0x00d9;
  28986. t.Ugravesmall = 0xf7f9;
  28987. t.Uhookabove = 0x1ee6;
  28988. t.Uhorn = 0x01af;
  28989. t.Uhornacute = 0x1ee8;
  28990. t.Uhorndotbelow = 0x1ef0;
  28991. t.Uhorngrave = 0x1eea;
  28992. t.Uhornhookabove = 0x1eec;
  28993. t.Uhorntilde = 0x1eee;
  28994. t.Uhungarumlaut = 0x0170;
  28995. t.Uhungarumlautcyrillic = 0x04f2;
  28996. t.Uinvertedbreve = 0x0216;
  28997. t.Ukcyrillic = 0x0478;
  28998. t.Umacron = 0x016a;
  28999. t.Umacroncyrillic = 0x04ee;
  29000. t.Umacrondieresis = 0x1e7a;
  29001. t.Umonospace = 0xff35;
  29002. t.Uogonek = 0x0172;
  29003. t.Upsilon = 0x03a5;
  29004. t.Upsilon1 = 0x03d2;
  29005. t.Upsilonacutehooksymbolgreek = 0x03d3;
  29006. t.Upsilonafrican = 0x01b1;
  29007. t.Upsilondieresis = 0x03ab;
  29008. t.Upsilondieresishooksymbolgreek = 0x03d4;
  29009. t.Upsilonhooksymbol = 0x03d2;
  29010. t.Upsilontonos = 0x038e;
  29011. t.Uring = 0x016e;
  29012. t.Ushortcyrillic = 0x040e;
  29013. t.Usmall = 0xf775;
  29014. t.Ustraightcyrillic = 0x04ae;
  29015. t.Ustraightstrokecyrillic = 0x04b0;
  29016. t.Utilde = 0x0168;
  29017. t.Utildeacute = 0x1e78;
  29018. t.Utildebelow = 0x1e74;
  29019. t.V = 0x0056;
  29020. t.Vcircle = 0x24cb;
  29021. t.Vdotbelow = 0x1e7e;
  29022. t.Vecyrillic = 0x0412;
  29023. t.Vewarmenian = 0x054e;
  29024. t.Vhook = 0x01b2;
  29025. t.Vmonospace = 0xff36;
  29026. t.Voarmenian = 0x0548;
  29027. t.Vsmall = 0xf776;
  29028. t.Vtilde = 0x1e7c;
  29029. t.W = 0x0057;
  29030. t.Wacute = 0x1e82;
  29031. t.Wcircle = 0x24cc;
  29032. t.Wcircumflex = 0x0174;
  29033. t.Wdieresis = 0x1e84;
  29034. t.Wdotaccent = 0x1e86;
  29035. t.Wdotbelow = 0x1e88;
  29036. t.Wgrave = 0x1e80;
  29037. t.Wmonospace = 0xff37;
  29038. t.Wsmall = 0xf777;
  29039. t.X = 0x0058;
  29040. t.Xcircle = 0x24cd;
  29041. t.Xdieresis = 0x1e8c;
  29042. t.Xdotaccent = 0x1e8a;
  29043. t.Xeharmenian = 0x053d;
  29044. t.Xi = 0x039e;
  29045. t.Xmonospace = 0xff38;
  29046. t.Xsmall = 0xf778;
  29047. t.Y = 0x0059;
  29048. t.Yacute = 0x00dd;
  29049. t.Yacutesmall = 0xf7fd;
  29050. t.Yatcyrillic = 0x0462;
  29051. t.Ycircle = 0x24ce;
  29052. t.Ycircumflex = 0x0176;
  29053. t.Ydieresis = 0x0178;
  29054. t.Ydieresissmall = 0xf7ff;
  29055. t.Ydotaccent = 0x1e8e;
  29056. t.Ydotbelow = 0x1ef4;
  29057. t.Yericyrillic = 0x042b;
  29058. t.Yerudieresiscyrillic = 0x04f8;
  29059. t.Ygrave = 0x1ef2;
  29060. t.Yhook = 0x01b3;
  29061. t.Yhookabove = 0x1ef6;
  29062. t.Yiarmenian = 0x0545;
  29063. t.Yicyrillic = 0x0407;
  29064. t.Yiwnarmenian = 0x0552;
  29065. t.Ymonospace = 0xff39;
  29066. t.Ysmall = 0xf779;
  29067. t.Ytilde = 0x1ef8;
  29068. t.Yusbigcyrillic = 0x046a;
  29069. t.Yusbigiotifiedcyrillic = 0x046c;
  29070. t.Yuslittlecyrillic = 0x0466;
  29071. t.Yuslittleiotifiedcyrillic = 0x0468;
  29072. t.Z = 0x005a;
  29073. t.Zaarmenian = 0x0536;
  29074. t.Zacute = 0x0179;
  29075. t.Zcaron = 0x017d;
  29076. t.Zcaronsmall = 0xf6ff;
  29077. t.Zcircle = 0x24cf;
  29078. t.Zcircumflex = 0x1e90;
  29079. t.Zdot = 0x017b;
  29080. t.Zdotaccent = 0x017b;
  29081. t.Zdotbelow = 0x1e92;
  29082. t.Zecyrillic = 0x0417;
  29083. t.Zedescendercyrillic = 0x0498;
  29084. t.Zedieresiscyrillic = 0x04de;
  29085. t.Zeta = 0x0396;
  29086. t.Zhearmenian = 0x053a;
  29087. t.Zhebrevecyrillic = 0x04c1;
  29088. t.Zhecyrillic = 0x0416;
  29089. t.Zhedescendercyrillic = 0x0496;
  29090. t.Zhedieresiscyrillic = 0x04dc;
  29091. t.Zlinebelow = 0x1e94;
  29092. t.Zmonospace = 0xff3a;
  29093. t.Zsmall = 0xf77a;
  29094. t.Zstroke = 0x01b5;
  29095. t.a = 0x0061;
  29096. t.aabengali = 0x0986;
  29097. t.aacute = 0x00e1;
  29098. t.aadeva = 0x0906;
  29099. t.aagujarati = 0x0a86;
  29100. t.aagurmukhi = 0x0a06;
  29101. t.aamatragurmukhi = 0x0a3e;
  29102. t.aarusquare = 0x3303;
  29103. t.aavowelsignbengali = 0x09be;
  29104. t.aavowelsigndeva = 0x093e;
  29105. t.aavowelsigngujarati = 0x0abe;
  29106. t.abbreviationmarkarmenian = 0x055f;
  29107. t.abbreviationsigndeva = 0x0970;
  29108. t.abengali = 0x0985;
  29109. t.abopomofo = 0x311a;
  29110. t.abreve = 0x0103;
  29111. t.abreveacute = 0x1eaf;
  29112. t.abrevecyrillic = 0x04d1;
  29113. t.abrevedotbelow = 0x1eb7;
  29114. t.abrevegrave = 0x1eb1;
  29115. t.abrevehookabove = 0x1eb3;
  29116. t.abrevetilde = 0x1eb5;
  29117. t.acaron = 0x01ce;
  29118. t.acircle = 0x24d0;
  29119. t.acircumflex = 0x00e2;
  29120. t.acircumflexacute = 0x1ea5;
  29121. t.acircumflexdotbelow = 0x1ead;
  29122. t.acircumflexgrave = 0x1ea7;
  29123. t.acircumflexhookabove = 0x1ea9;
  29124. t.acircumflextilde = 0x1eab;
  29125. t.acute = 0x00b4;
  29126. t.acutebelowcmb = 0x0317;
  29127. t.acutecmb = 0x0301;
  29128. t.acutecomb = 0x0301;
  29129. t.acutedeva = 0x0954;
  29130. t.acutelowmod = 0x02cf;
  29131. t.acutetonecmb = 0x0341;
  29132. t.acyrillic = 0x0430;
  29133. t.adblgrave = 0x0201;
  29134. t.addakgurmukhi = 0x0a71;
  29135. t.adeva = 0x0905;
  29136. t.adieresis = 0x00e4;
  29137. t.adieresiscyrillic = 0x04d3;
  29138. t.adieresismacron = 0x01df;
  29139. t.adotbelow = 0x1ea1;
  29140. t.adotmacron = 0x01e1;
  29141. t.ae = 0x00e6;
  29142. t.aeacute = 0x01fd;
  29143. t.aekorean = 0x3150;
  29144. t.aemacron = 0x01e3;
  29145. t.afii00208 = 0x2015;
  29146. t.afii08941 = 0x20a4;
  29147. t.afii10017 = 0x0410;
  29148. t.afii10018 = 0x0411;
  29149. t.afii10019 = 0x0412;
  29150. t.afii10020 = 0x0413;
  29151. t.afii10021 = 0x0414;
  29152. t.afii10022 = 0x0415;
  29153. t.afii10023 = 0x0401;
  29154. t.afii10024 = 0x0416;
  29155. t.afii10025 = 0x0417;
  29156. t.afii10026 = 0x0418;
  29157. t.afii10027 = 0x0419;
  29158. t.afii10028 = 0x041a;
  29159. t.afii10029 = 0x041b;
  29160. t.afii10030 = 0x041c;
  29161. t.afii10031 = 0x041d;
  29162. t.afii10032 = 0x041e;
  29163. t.afii10033 = 0x041f;
  29164. t.afii10034 = 0x0420;
  29165. t.afii10035 = 0x0421;
  29166. t.afii10036 = 0x0422;
  29167. t.afii10037 = 0x0423;
  29168. t.afii10038 = 0x0424;
  29169. t.afii10039 = 0x0425;
  29170. t.afii10040 = 0x0426;
  29171. t.afii10041 = 0x0427;
  29172. t.afii10042 = 0x0428;
  29173. t.afii10043 = 0x0429;
  29174. t.afii10044 = 0x042a;
  29175. t.afii10045 = 0x042b;
  29176. t.afii10046 = 0x042c;
  29177. t.afii10047 = 0x042d;
  29178. t.afii10048 = 0x042e;
  29179. t.afii10049 = 0x042f;
  29180. t.afii10050 = 0x0490;
  29181. t.afii10051 = 0x0402;
  29182. t.afii10052 = 0x0403;
  29183. t.afii10053 = 0x0404;
  29184. t.afii10054 = 0x0405;
  29185. t.afii10055 = 0x0406;
  29186. t.afii10056 = 0x0407;
  29187. t.afii10057 = 0x0408;
  29188. t.afii10058 = 0x0409;
  29189. t.afii10059 = 0x040a;
  29190. t.afii10060 = 0x040b;
  29191. t.afii10061 = 0x040c;
  29192. t.afii10062 = 0x040e;
  29193. t.afii10063 = 0xf6c4;
  29194. t.afii10064 = 0xf6c5;
  29195. t.afii10065 = 0x0430;
  29196. t.afii10066 = 0x0431;
  29197. t.afii10067 = 0x0432;
  29198. t.afii10068 = 0x0433;
  29199. t.afii10069 = 0x0434;
  29200. t.afii10070 = 0x0435;
  29201. t.afii10071 = 0x0451;
  29202. t.afii10072 = 0x0436;
  29203. t.afii10073 = 0x0437;
  29204. t.afii10074 = 0x0438;
  29205. t.afii10075 = 0x0439;
  29206. t.afii10076 = 0x043a;
  29207. t.afii10077 = 0x043b;
  29208. t.afii10078 = 0x043c;
  29209. t.afii10079 = 0x043d;
  29210. t.afii10080 = 0x043e;
  29211. t.afii10081 = 0x043f;
  29212. t.afii10082 = 0x0440;
  29213. t.afii10083 = 0x0441;
  29214. t.afii10084 = 0x0442;
  29215. t.afii10085 = 0x0443;
  29216. t.afii10086 = 0x0444;
  29217. t.afii10087 = 0x0445;
  29218. t.afii10088 = 0x0446;
  29219. t.afii10089 = 0x0447;
  29220. t.afii10090 = 0x0448;
  29221. t.afii10091 = 0x0449;
  29222. t.afii10092 = 0x044a;
  29223. t.afii10093 = 0x044b;
  29224. t.afii10094 = 0x044c;
  29225. t.afii10095 = 0x044d;
  29226. t.afii10096 = 0x044e;
  29227. t.afii10097 = 0x044f;
  29228. t.afii10098 = 0x0491;
  29229. t.afii10099 = 0x0452;
  29230. t.afii10100 = 0x0453;
  29231. t.afii10101 = 0x0454;
  29232. t.afii10102 = 0x0455;
  29233. t.afii10103 = 0x0456;
  29234. t.afii10104 = 0x0457;
  29235. t.afii10105 = 0x0458;
  29236. t.afii10106 = 0x0459;
  29237. t.afii10107 = 0x045a;
  29238. t.afii10108 = 0x045b;
  29239. t.afii10109 = 0x045c;
  29240. t.afii10110 = 0x045e;
  29241. t.afii10145 = 0x040f;
  29242. t.afii10146 = 0x0462;
  29243. t.afii10147 = 0x0472;
  29244. t.afii10148 = 0x0474;
  29245. t.afii10192 = 0xf6c6;
  29246. t.afii10193 = 0x045f;
  29247. t.afii10194 = 0x0463;
  29248. t.afii10195 = 0x0473;
  29249. t.afii10196 = 0x0475;
  29250. t.afii10831 = 0xf6c7;
  29251. t.afii10832 = 0xf6c8;
  29252. t.afii10846 = 0x04d9;
  29253. t.afii299 = 0x200e;
  29254. t.afii300 = 0x200f;
  29255. t.afii301 = 0x200d;
  29256. t.afii57381 = 0x066a;
  29257. t.afii57388 = 0x060c;
  29258. t.afii57392 = 0x0660;
  29259. t.afii57393 = 0x0661;
  29260. t.afii57394 = 0x0662;
  29261. t.afii57395 = 0x0663;
  29262. t.afii57396 = 0x0664;
  29263. t.afii57397 = 0x0665;
  29264. t.afii57398 = 0x0666;
  29265. t.afii57399 = 0x0667;
  29266. t.afii57400 = 0x0668;
  29267. t.afii57401 = 0x0669;
  29268. t.afii57403 = 0x061b;
  29269. t.afii57407 = 0x061f;
  29270. t.afii57409 = 0x0621;
  29271. t.afii57410 = 0x0622;
  29272. t.afii57411 = 0x0623;
  29273. t.afii57412 = 0x0624;
  29274. t.afii57413 = 0x0625;
  29275. t.afii57414 = 0x0626;
  29276. t.afii57415 = 0x0627;
  29277. t.afii57416 = 0x0628;
  29278. t.afii57417 = 0x0629;
  29279. t.afii57418 = 0x062a;
  29280. t.afii57419 = 0x062b;
  29281. t.afii57420 = 0x062c;
  29282. t.afii57421 = 0x062d;
  29283. t.afii57422 = 0x062e;
  29284. t.afii57423 = 0x062f;
  29285. t.afii57424 = 0x0630;
  29286. t.afii57425 = 0x0631;
  29287. t.afii57426 = 0x0632;
  29288. t.afii57427 = 0x0633;
  29289. t.afii57428 = 0x0634;
  29290. t.afii57429 = 0x0635;
  29291. t.afii57430 = 0x0636;
  29292. t.afii57431 = 0x0637;
  29293. t.afii57432 = 0x0638;
  29294. t.afii57433 = 0x0639;
  29295. t.afii57434 = 0x063a;
  29296. t.afii57440 = 0x0640;
  29297. t.afii57441 = 0x0641;
  29298. t.afii57442 = 0x0642;
  29299. t.afii57443 = 0x0643;
  29300. t.afii57444 = 0x0644;
  29301. t.afii57445 = 0x0645;
  29302. t.afii57446 = 0x0646;
  29303. t.afii57448 = 0x0648;
  29304. t.afii57449 = 0x0649;
  29305. t.afii57450 = 0x064a;
  29306. t.afii57451 = 0x064b;
  29307. t.afii57452 = 0x064c;
  29308. t.afii57453 = 0x064d;
  29309. t.afii57454 = 0x064e;
  29310. t.afii57455 = 0x064f;
  29311. t.afii57456 = 0x0650;
  29312. t.afii57457 = 0x0651;
  29313. t.afii57458 = 0x0652;
  29314. t.afii57470 = 0x0647;
  29315. t.afii57505 = 0x06a4;
  29316. t.afii57506 = 0x067e;
  29317. t.afii57507 = 0x0686;
  29318. t.afii57508 = 0x0698;
  29319. t.afii57509 = 0x06af;
  29320. t.afii57511 = 0x0679;
  29321. t.afii57512 = 0x0688;
  29322. t.afii57513 = 0x0691;
  29323. t.afii57514 = 0x06ba;
  29324. t.afii57519 = 0x06d2;
  29325. t.afii57534 = 0x06d5;
  29326. t.afii57636 = 0x20aa;
  29327. t.afii57645 = 0x05be;
  29328. t.afii57658 = 0x05c3;
  29329. t.afii57664 = 0x05d0;
  29330. t.afii57665 = 0x05d1;
  29331. t.afii57666 = 0x05d2;
  29332. t.afii57667 = 0x05d3;
  29333. t.afii57668 = 0x05d4;
  29334. t.afii57669 = 0x05d5;
  29335. t.afii57670 = 0x05d6;
  29336. t.afii57671 = 0x05d7;
  29337. t.afii57672 = 0x05d8;
  29338. t.afii57673 = 0x05d9;
  29339. t.afii57674 = 0x05da;
  29340. t.afii57675 = 0x05db;
  29341. t.afii57676 = 0x05dc;
  29342. t.afii57677 = 0x05dd;
  29343. t.afii57678 = 0x05de;
  29344. t.afii57679 = 0x05df;
  29345. t.afii57680 = 0x05e0;
  29346. t.afii57681 = 0x05e1;
  29347. t.afii57682 = 0x05e2;
  29348. t.afii57683 = 0x05e3;
  29349. t.afii57684 = 0x05e4;
  29350. t.afii57685 = 0x05e5;
  29351. t.afii57686 = 0x05e6;
  29352. t.afii57687 = 0x05e7;
  29353. t.afii57688 = 0x05e8;
  29354. t.afii57689 = 0x05e9;
  29355. t.afii57690 = 0x05ea;
  29356. t.afii57694 = 0xfb2a;
  29357. t.afii57695 = 0xfb2b;
  29358. t.afii57700 = 0xfb4b;
  29359. t.afii57705 = 0xfb1f;
  29360. t.afii57716 = 0x05f0;
  29361. t.afii57717 = 0x05f1;
  29362. t.afii57718 = 0x05f2;
  29363. t.afii57723 = 0xfb35;
  29364. t.afii57793 = 0x05b4;
  29365. t.afii57794 = 0x05b5;
  29366. t.afii57795 = 0x05b6;
  29367. t.afii57796 = 0x05bb;
  29368. t.afii57797 = 0x05b8;
  29369. t.afii57798 = 0x05b7;
  29370. t.afii57799 = 0x05b0;
  29371. t.afii57800 = 0x05b2;
  29372. t.afii57801 = 0x05b1;
  29373. t.afii57802 = 0x05b3;
  29374. t.afii57803 = 0x05c2;
  29375. t.afii57804 = 0x05c1;
  29376. t.afii57806 = 0x05b9;
  29377. t.afii57807 = 0x05bc;
  29378. t.afii57839 = 0x05bd;
  29379. t.afii57841 = 0x05bf;
  29380. t.afii57842 = 0x05c0;
  29381. t.afii57929 = 0x02bc;
  29382. t.afii61248 = 0x2105;
  29383. t.afii61289 = 0x2113;
  29384. t.afii61352 = 0x2116;
  29385. t.afii61573 = 0x202c;
  29386. t.afii61574 = 0x202d;
  29387. t.afii61575 = 0x202e;
  29388. t.afii61664 = 0x200c;
  29389. t.afii63167 = 0x066d;
  29390. t.afii64937 = 0x02bd;
  29391. t.agrave = 0x00e0;
  29392. t.agujarati = 0x0a85;
  29393. t.agurmukhi = 0x0a05;
  29394. t.ahiragana = 0x3042;
  29395. t.ahookabove = 0x1ea3;
  29396. t.aibengali = 0x0990;
  29397. t.aibopomofo = 0x311e;
  29398. t.aideva = 0x0910;
  29399. t.aiecyrillic = 0x04d5;
  29400. t.aigujarati = 0x0a90;
  29401. t.aigurmukhi = 0x0a10;
  29402. t.aimatragurmukhi = 0x0a48;
  29403. t.ainarabic = 0x0639;
  29404. t.ainfinalarabic = 0xfeca;
  29405. t.aininitialarabic = 0xfecb;
  29406. t.ainmedialarabic = 0xfecc;
  29407. t.ainvertedbreve = 0x0203;
  29408. t.aivowelsignbengali = 0x09c8;
  29409. t.aivowelsigndeva = 0x0948;
  29410. t.aivowelsigngujarati = 0x0ac8;
  29411. t.akatakana = 0x30a2;
  29412. t.akatakanahalfwidth = 0xff71;
  29413. t.akorean = 0x314f;
  29414. t.alef = 0x05d0;
  29415. t.alefarabic = 0x0627;
  29416. t.alefdageshhebrew = 0xfb30;
  29417. t.aleffinalarabic = 0xfe8e;
  29418. t.alefhamzaabovearabic = 0x0623;
  29419. t.alefhamzaabovefinalarabic = 0xfe84;
  29420. t.alefhamzabelowarabic = 0x0625;
  29421. t.alefhamzabelowfinalarabic = 0xfe88;
  29422. t.alefhebrew = 0x05d0;
  29423. t.aleflamedhebrew = 0xfb4f;
  29424. t.alefmaddaabovearabic = 0x0622;
  29425. t.alefmaddaabovefinalarabic = 0xfe82;
  29426. t.alefmaksuraarabic = 0x0649;
  29427. t.alefmaksurafinalarabic = 0xfef0;
  29428. t.alefmaksurainitialarabic = 0xfef3;
  29429. t.alefmaksuramedialarabic = 0xfef4;
  29430. t.alefpatahhebrew = 0xfb2e;
  29431. t.alefqamatshebrew = 0xfb2f;
  29432. t.aleph = 0x2135;
  29433. t.allequal = 0x224c;
  29434. t.alpha = 0x03b1;
  29435. t.alphatonos = 0x03ac;
  29436. t.amacron = 0x0101;
  29437. t.amonospace = 0xff41;
  29438. t.ampersand = 0x0026;
  29439. t.ampersandmonospace = 0xff06;
  29440. t.ampersandsmall = 0xf726;
  29441. t.amsquare = 0x33c2;
  29442. t.anbopomofo = 0x3122;
  29443. t.angbopomofo = 0x3124;
  29444. t.angbracketleft = 0x3008;
  29445. t.angbracketright = 0x3009;
  29446. t.angkhankhuthai = 0x0e5a;
  29447. t.angle = 0x2220;
  29448. t.anglebracketleft = 0x3008;
  29449. t.anglebracketleftvertical = 0xfe3f;
  29450. t.anglebracketright = 0x3009;
  29451. t.anglebracketrightvertical = 0xfe40;
  29452. t.angleleft = 0x2329;
  29453. t.angleright = 0x232a;
  29454. t.angstrom = 0x212b;
  29455. t.anoteleia = 0x0387;
  29456. t.anudattadeva = 0x0952;
  29457. t.anusvarabengali = 0x0982;
  29458. t.anusvaradeva = 0x0902;
  29459. t.anusvaragujarati = 0x0a82;
  29460. t.aogonek = 0x0105;
  29461. t.apaatosquare = 0x3300;
  29462. t.aparen = 0x249c;
  29463. t.apostrophearmenian = 0x055a;
  29464. t.apostrophemod = 0x02bc;
  29465. t.apple = 0xf8ff;
  29466. t.approaches = 0x2250;
  29467. t.approxequal = 0x2248;
  29468. t.approxequalorimage = 0x2252;
  29469. t.approximatelyequal = 0x2245;
  29470. t.araeaekorean = 0x318e;
  29471. t.araeakorean = 0x318d;
  29472. t.arc = 0x2312;
  29473. t.arighthalfring = 0x1e9a;
  29474. t.aring = 0x00e5;
  29475. t.aringacute = 0x01fb;
  29476. t.aringbelow = 0x1e01;
  29477. t.arrowboth = 0x2194;
  29478. t.arrowdashdown = 0x21e3;
  29479. t.arrowdashleft = 0x21e0;
  29480. t.arrowdashright = 0x21e2;
  29481. t.arrowdashup = 0x21e1;
  29482. t.arrowdblboth = 0x21d4;
  29483. t.arrowdbldown = 0x21d3;
  29484. t.arrowdblleft = 0x21d0;
  29485. t.arrowdblright = 0x21d2;
  29486. t.arrowdblup = 0x21d1;
  29487. t.arrowdown = 0x2193;
  29488. t.arrowdownleft = 0x2199;
  29489. t.arrowdownright = 0x2198;
  29490. t.arrowdownwhite = 0x21e9;
  29491. t.arrowheaddownmod = 0x02c5;
  29492. t.arrowheadleftmod = 0x02c2;
  29493. t.arrowheadrightmod = 0x02c3;
  29494. t.arrowheadupmod = 0x02c4;
  29495. t.arrowhorizex = 0xf8e7;
  29496. t.arrowleft = 0x2190;
  29497. t.arrowleftdbl = 0x21d0;
  29498. t.arrowleftdblstroke = 0x21cd;
  29499. t.arrowleftoverright = 0x21c6;
  29500. t.arrowleftwhite = 0x21e6;
  29501. t.arrowright = 0x2192;
  29502. t.arrowrightdblstroke = 0x21cf;
  29503. t.arrowrightheavy = 0x279e;
  29504. t.arrowrightoverleft = 0x21c4;
  29505. t.arrowrightwhite = 0x21e8;
  29506. t.arrowtableft = 0x21e4;
  29507. t.arrowtabright = 0x21e5;
  29508. t.arrowup = 0x2191;
  29509. t.arrowupdn = 0x2195;
  29510. t.arrowupdnbse = 0x21a8;
  29511. t.arrowupdownbase = 0x21a8;
  29512. t.arrowupleft = 0x2196;
  29513. t.arrowupleftofdown = 0x21c5;
  29514. t.arrowupright = 0x2197;
  29515. t.arrowupwhite = 0x21e7;
  29516. t.arrowvertex = 0xf8e6;
  29517. t.asciicircum = 0x005e;
  29518. t.asciicircummonospace = 0xff3e;
  29519. t.asciitilde = 0x007e;
  29520. t.asciitildemonospace = 0xff5e;
  29521. t.ascript = 0x0251;
  29522. t.ascriptturned = 0x0252;
  29523. t.asmallhiragana = 0x3041;
  29524. t.asmallkatakana = 0x30a1;
  29525. t.asmallkatakanahalfwidth = 0xff67;
  29526. t.asterisk = 0x002a;
  29527. t.asteriskaltonearabic = 0x066d;
  29528. t.asteriskarabic = 0x066d;
  29529. t.asteriskmath = 0x2217;
  29530. t.asteriskmonospace = 0xff0a;
  29531. t.asterisksmall = 0xfe61;
  29532. t.asterism = 0x2042;
  29533. t.asuperior = 0xf6e9;
  29534. t.asymptoticallyequal = 0x2243;
  29535. t.at = 0x0040;
  29536. t.atilde = 0x00e3;
  29537. t.atmonospace = 0xff20;
  29538. t.atsmall = 0xfe6b;
  29539. t.aturned = 0x0250;
  29540. t.aubengali = 0x0994;
  29541. t.aubopomofo = 0x3120;
  29542. t.audeva = 0x0914;
  29543. t.augujarati = 0x0a94;
  29544. t.augurmukhi = 0x0a14;
  29545. t.aulengthmarkbengali = 0x09d7;
  29546. t.aumatragurmukhi = 0x0a4c;
  29547. t.auvowelsignbengali = 0x09cc;
  29548. t.auvowelsigndeva = 0x094c;
  29549. t.auvowelsigngujarati = 0x0acc;
  29550. t.avagrahadeva = 0x093d;
  29551. t.aybarmenian = 0x0561;
  29552. t.ayin = 0x05e2;
  29553. t.ayinaltonehebrew = 0xfb20;
  29554. t.ayinhebrew = 0x05e2;
  29555. t.b = 0x0062;
  29556. t.babengali = 0x09ac;
  29557. t.backslash = 0x005c;
  29558. t.backslashmonospace = 0xff3c;
  29559. t.badeva = 0x092c;
  29560. t.bagujarati = 0x0aac;
  29561. t.bagurmukhi = 0x0a2c;
  29562. t.bahiragana = 0x3070;
  29563. t.bahtthai = 0x0e3f;
  29564. t.bakatakana = 0x30d0;
  29565. t.bar = 0x007c;
  29566. t.barmonospace = 0xff5c;
  29567. t.bbopomofo = 0x3105;
  29568. t.bcircle = 0x24d1;
  29569. t.bdotaccent = 0x1e03;
  29570. t.bdotbelow = 0x1e05;
  29571. t.beamedsixteenthnotes = 0x266c;
  29572. t.because = 0x2235;
  29573. t.becyrillic = 0x0431;
  29574. t.beharabic = 0x0628;
  29575. t.behfinalarabic = 0xfe90;
  29576. t.behinitialarabic = 0xfe91;
  29577. t.behiragana = 0x3079;
  29578. t.behmedialarabic = 0xfe92;
  29579. t.behmeeminitialarabic = 0xfc9f;
  29580. t.behmeemisolatedarabic = 0xfc08;
  29581. t.behnoonfinalarabic = 0xfc6d;
  29582. t.bekatakana = 0x30d9;
  29583. t.benarmenian = 0x0562;
  29584. t.bet = 0x05d1;
  29585. t.beta = 0x03b2;
  29586. t.betasymbolgreek = 0x03d0;
  29587. t.betdagesh = 0xfb31;
  29588. t.betdageshhebrew = 0xfb31;
  29589. t.bethebrew = 0x05d1;
  29590. t.betrafehebrew = 0xfb4c;
  29591. t.bhabengali = 0x09ad;
  29592. t.bhadeva = 0x092d;
  29593. t.bhagujarati = 0x0aad;
  29594. t.bhagurmukhi = 0x0a2d;
  29595. t.bhook = 0x0253;
  29596. t.bihiragana = 0x3073;
  29597. t.bikatakana = 0x30d3;
  29598. t.bilabialclick = 0x0298;
  29599. t.bindigurmukhi = 0x0a02;
  29600. t.birusquare = 0x3331;
  29601. t.blackcircle = 0x25cf;
  29602. t.blackdiamond = 0x25c6;
  29603. t.blackdownpointingtriangle = 0x25bc;
  29604. t.blackleftpointingpointer = 0x25c4;
  29605. t.blackleftpointingtriangle = 0x25c0;
  29606. t.blacklenticularbracketleft = 0x3010;
  29607. t.blacklenticularbracketleftvertical = 0xfe3b;
  29608. t.blacklenticularbracketright = 0x3011;
  29609. t.blacklenticularbracketrightvertical = 0xfe3c;
  29610. t.blacklowerlefttriangle = 0x25e3;
  29611. t.blacklowerrighttriangle = 0x25e2;
  29612. t.blackrectangle = 0x25ac;
  29613. t.blackrightpointingpointer = 0x25ba;
  29614. t.blackrightpointingtriangle = 0x25b6;
  29615. t.blacksmallsquare = 0x25aa;
  29616. t.blacksmilingface = 0x263b;
  29617. t.blacksquare = 0x25a0;
  29618. t.blackstar = 0x2605;
  29619. t.blackupperlefttriangle = 0x25e4;
  29620. t.blackupperrighttriangle = 0x25e5;
  29621. t.blackuppointingsmalltriangle = 0x25b4;
  29622. t.blackuppointingtriangle = 0x25b2;
  29623. t.blank = 0x2423;
  29624. t.blinebelow = 0x1e07;
  29625. t.block = 0x2588;
  29626. t.bmonospace = 0xff42;
  29627. t.bobaimaithai = 0x0e1a;
  29628. t.bohiragana = 0x307c;
  29629. t.bokatakana = 0x30dc;
  29630. t.bparen = 0x249d;
  29631. t.bqsquare = 0x33c3;
  29632. t.braceex = 0xf8f4;
  29633. t.braceleft = 0x007b;
  29634. t.braceleftbt = 0xf8f3;
  29635. t.braceleftmid = 0xf8f2;
  29636. t.braceleftmonospace = 0xff5b;
  29637. t.braceleftsmall = 0xfe5b;
  29638. t.bracelefttp = 0xf8f1;
  29639. t.braceleftvertical = 0xfe37;
  29640. t.braceright = 0x007d;
  29641. t.bracerightbt = 0xf8fe;
  29642. t.bracerightmid = 0xf8fd;
  29643. t.bracerightmonospace = 0xff5d;
  29644. t.bracerightsmall = 0xfe5c;
  29645. t.bracerighttp = 0xf8fc;
  29646. t.bracerightvertical = 0xfe38;
  29647. t.bracketleft = 0x005b;
  29648. t.bracketleftbt = 0xf8f0;
  29649. t.bracketleftex = 0xf8ef;
  29650. t.bracketleftmonospace = 0xff3b;
  29651. t.bracketlefttp = 0xf8ee;
  29652. t.bracketright = 0x005d;
  29653. t.bracketrightbt = 0xf8fb;
  29654. t.bracketrightex = 0xf8fa;
  29655. t.bracketrightmonospace = 0xff3d;
  29656. t.bracketrighttp = 0xf8f9;
  29657. t.breve = 0x02d8;
  29658. t.brevebelowcmb = 0x032e;
  29659. t.brevecmb = 0x0306;
  29660. t.breveinvertedbelowcmb = 0x032f;
  29661. t.breveinvertedcmb = 0x0311;
  29662. t.breveinverteddoublecmb = 0x0361;
  29663. t.bridgebelowcmb = 0x032a;
  29664. t.bridgeinvertedbelowcmb = 0x033a;
  29665. t.brokenbar = 0x00a6;
  29666. t.bstroke = 0x0180;
  29667. t.bsuperior = 0xf6ea;
  29668. t.btopbar = 0x0183;
  29669. t.buhiragana = 0x3076;
  29670. t.bukatakana = 0x30d6;
  29671. t.bullet = 0x2022;
  29672. t.bulletinverse = 0x25d8;
  29673. t.bulletoperator = 0x2219;
  29674. t.bullseye = 0x25ce;
  29675. t.c = 0x0063;
  29676. t.caarmenian = 0x056e;
  29677. t.cabengali = 0x099a;
  29678. t.cacute = 0x0107;
  29679. t.cadeva = 0x091a;
  29680. t.cagujarati = 0x0a9a;
  29681. t.cagurmukhi = 0x0a1a;
  29682. t.calsquare = 0x3388;
  29683. t.candrabindubengali = 0x0981;
  29684. t.candrabinducmb = 0x0310;
  29685. t.candrabindudeva = 0x0901;
  29686. t.candrabindugujarati = 0x0a81;
  29687. t.capslock = 0x21ea;
  29688. t.careof = 0x2105;
  29689. t.caron = 0x02c7;
  29690. t.caronbelowcmb = 0x032c;
  29691. t.caroncmb = 0x030c;
  29692. t.carriagereturn = 0x21b5;
  29693. t.cbopomofo = 0x3118;
  29694. t.ccaron = 0x010d;
  29695. t.ccedilla = 0x00e7;
  29696. t.ccedillaacute = 0x1e09;
  29697. t.ccircle = 0x24d2;
  29698. t.ccircumflex = 0x0109;
  29699. t.ccurl = 0x0255;
  29700. t.cdot = 0x010b;
  29701. t.cdotaccent = 0x010b;
  29702. t.cdsquare = 0x33c5;
  29703. t.cedilla = 0x00b8;
  29704. t.cedillacmb = 0x0327;
  29705. t.cent = 0x00a2;
  29706. t.centigrade = 0x2103;
  29707. t.centinferior = 0xf6df;
  29708. t.centmonospace = 0xffe0;
  29709. t.centoldstyle = 0xf7a2;
  29710. t.centsuperior = 0xf6e0;
  29711. t.chaarmenian = 0x0579;
  29712. t.chabengali = 0x099b;
  29713. t.chadeva = 0x091b;
  29714. t.chagujarati = 0x0a9b;
  29715. t.chagurmukhi = 0x0a1b;
  29716. t.chbopomofo = 0x3114;
  29717. t.cheabkhasiancyrillic = 0x04bd;
  29718. t.checkmark = 0x2713;
  29719. t.checyrillic = 0x0447;
  29720. t.chedescenderabkhasiancyrillic = 0x04bf;
  29721. t.chedescendercyrillic = 0x04b7;
  29722. t.chedieresiscyrillic = 0x04f5;
  29723. t.cheharmenian = 0x0573;
  29724. t.chekhakassiancyrillic = 0x04cc;
  29725. t.cheverticalstrokecyrillic = 0x04b9;
  29726. t.chi = 0x03c7;
  29727. t.chieuchacirclekorean = 0x3277;
  29728. t.chieuchaparenkorean = 0x3217;
  29729. t.chieuchcirclekorean = 0x3269;
  29730. t.chieuchkorean = 0x314a;
  29731. t.chieuchparenkorean = 0x3209;
  29732. t.chochangthai = 0x0e0a;
  29733. t.chochanthai = 0x0e08;
  29734. t.chochingthai = 0x0e09;
  29735. t.chochoethai = 0x0e0c;
  29736. t.chook = 0x0188;
  29737. t.cieucacirclekorean = 0x3276;
  29738. t.cieucaparenkorean = 0x3216;
  29739. t.cieuccirclekorean = 0x3268;
  29740. t.cieuckorean = 0x3148;
  29741. t.cieucparenkorean = 0x3208;
  29742. t.cieucuparenkorean = 0x321c;
  29743. t.circle = 0x25cb;
  29744. t.circlecopyrt = 0x00a9;
  29745. t.circlemultiply = 0x2297;
  29746. t.circleot = 0x2299;
  29747. t.circleplus = 0x2295;
  29748. t.circlepostalmark = 0x3036;
  29749. t.circlewithlefthalfblack = 0x25d0;
  29750. t.circlewithrighthalfblack = 0x25d1;
  29751. t.circumflex = 0x02c6;
  29752. t.circumflexbelowcmb = 0x032d;
  29753. t.circumflexcmb = 0x0302;
  29754. t.clear = 0x2327;
  29755. t.clickalveolar = 0x01c2;
  29756. t.clickdental = 0x01c0;
  29757. t.clicklateral = 0x01c1;
  29758. t.clickretroflex = 0x01c3;
  29759. t.club = 0x2663;
  29760. t.clubsuitblack = 0x2663;
  29761. t.clubsuitwhite = 0x2667;
  29762. t.cmcubedsquare = 0x33a4;
  29763. t.cmonospace = 0xff43;
  29764. t.cmsquaredsquare = 0x33a0;
  29765. t.coarmenian = 0x0581;
  29766. t.colon = 0x003a;
  29767. t.colonmonetary = 0x20a1;
  29768. t.colonmonospace = 0xff1a;
  29769. t.colonsign = 0x20a1;
  29770. t.colonsmall = 0xfe55;
  29771. t.colontriangularhalfmod = 0x02d1;
  29772. t.colontriangularmod = 0x02d0;
  29773. t.comma = 0x002c;
  29774. t.commaabovecmb = 0x0313;
  29775. t.commaaboverightcmb = 0x0315;
  29776. t.commaaccent = 0xf6c3;
  29777. t.commaarabic = 0x060c;
  29778. t.commaarmenian = 0x055d;
  29779. t.commainferior = 0xf6e1;
  29780. t.commamonospace = 0xff0c;
  29781. t.commareversedabovecmb = 0x0314;
  29782. t.commareversedmod = 0x02bd;
  29783. t.commasmall = 0xfe50;
  29784. t.commasuperior = 0xf6e2;
  29785. t.commaturnedabovecmb = 0x0312;
  29786. t.commaturnedmod = 0x02bb;
  29787. t.compass = 0x263c;
  29788. t.congruent = 0x2245;
  29789. t.contourintegral = 0x222e;
  29790. t.control = 0x2303;
  29791. t.controlACK = 0x0006;
  29792. t.controlBEL = 0x0007;
  29793. t.controlBS = 0x0008;
  29794. t.controlCAN = 0x0018;
  29795. t.controlCR = 0x000d;
  29796. t.controlDC1 = 0x0011;
  29797. t.controlDC2 = 0x0012;
  29798. t.controlDC3 = 0x0013;
  29799. t.controlDC4 = 0x0014;
  29800. t.controlDEL = 0x007f;
  29801. t.controlDLE = 0x0010;
  29802. t.controlEM = 0x0019;
  29803. t.controlENQ = 0x0005;
  29804. t.controlEOT = 0x0004;
  29805. t.controlESC = 0x001b;
  29806. t.controlETB = 0x0017;
  29807. t.controlETX = 0x0003;
  29808. t.controlFF = 0x000c;
  29809. t.controlFS = 0x001c;
  29810. t.controlGS = 0x001d;
  29811. t.controlHT = 0x0009;
  29812. t.controlLF = 0x000a;
  29813. t.controlNAK = 0x0015;
  29814. t.controlNULL = 0x0000;
  29815. t.controlRS = 0x001e;
  29816. t.controlSI = 0x000f;
  29817. t.controlSO = 0x000e;
  29818. t.controlSOT = 0x0002;
  29819. t.controlSTX = 0x0001;
  29820. t.controlSUB = 0x001a;
  29821. t.controlSYN = 0x0016;
  29822. t.controlUS = 0x001f;
  29823. t.controlVT = 0x000b;
  29824. t.copyright = 0x00a9;
  29825. t.copyrightsans = 0xf8e9;
  29826. t.copyrightserif = 0xf6d9;
  29827. t.cornerbracketleft = 0x300c;
  29828. t.cornerbracketlefthalfwidth = 0xff62;
  29829. t.cornerbracketleftvertical = 0xfe41;
  29830. t.cornerbracketright = 0x300d;
  29831. t.cornerbracketrighthalfwidth = 0xff63;
  29832. t.cornerbracketrightvertical = 0xfe42;
  29833. t.corporationsquare = 0x337f;
  29834. t.cosquare = 0x33c7;
  29835. t.coverkgsquare = 0x33c6;
  29836. t.cparen = 0x249e;
  29837. t.cruzeiro = 0x20a2;
  29838. t.cstretched = 0x0297;
  29839. t.curlyand = 0x22cf;
  29840. t.curlyor = 0x22ce;
  29841. t.currency = 0x00a4;
  29842. t.cyrBreve = 0xf6d1;
  29843. t.cyrFlex = 0xf6d2;
  29844. t.cyrbreve = 0xf6d4;
  29845. t.cyrflex = 0xf6d5;
  29846. t.d = 0x0064;
  29847. t.daarmenian = 0x0564;
  29848. t.dabengali = 0x09a6;
  29849. t.dadarabic = 0x0636;
  29850. t.dadeva = 0x0926;
  29851. t.dadfinalarabic = 0xfebe;
  29852. t.dadinitialarabic = 0xfebf;
  29853. t.dadmedialarabic = 0xfec0;
  29854. t.dagesh = 0x05bc;
  29855. t.dageshhebrew = 0x05bc;
  29856. t.dagger = 0x2020;
  29857. t.daggerdbl = 0x2021;
  29858. t.dagujarati = 0x0aa6;
  29859. t.dagurmukhi = 0x0a26;
  29860. t.dahiragana = 0x3060;
  29861. t.dakatakana = 0x30c0;
  29862. t.dalarabic = 0x062f;
  29863. t.dalet = 0x05d3;
  29864. t.daletdagesh = 0xfb33;
  29865. t.daletdageshhebrew = 0xfb33;
  29866. t.dalethebrew = 0x05d3;
  29867. t.dalfinalarabic = 0xfeaa;
  29868. t.dammaarabic = 0x064f;
  29869. t.dammalowarabic = 0x064f;
  29870. t.dammatanaltonearabic = 0x064c;
  29871. t.dammatanarabic = 0x064c;
  29872. t.danda = 0x0964;
  29873. t.dargahebrew = 0x05a7;
  29874. t.dargalefthebrew = 0x05a7;
  29875. t.dasiapneumatacyrilliccmb = 0x0485;
  29876. t.dblGrave = 0xf6d3;
  29877. t.dblanglebracketleft = 0x300a;
  29878. t.dblanglebracketleftvertical = 0xfe3d;
  29879. t.dblanglebracketright = 0x300b;
  29880. t.dblanglebracketrightvertical = 0xfe3e;
  29881. t.dblarchinvertedbelowcmb = 0x032b;
  29882. t.dblarrowleft = 0x21d4;
  29883. t.dblarrowright = 0x21d2;
  29884. t.dbldanda = 0x0965;
  29885. t.dblgrave = 0xf6d6;
  29886. t.dblgravecmb = 0x030f;
  29887. t.dblintegral = 0x222c;
  29888. t.dbllowline = 0x2017;
  29889. t.dbllowlinecmb = 0x0333;
  29890. t.dbloverlinecmb = 0x033f;
  29891. t.dblprimemod = 0x02ba;
  29892. t.dblverticalbar = 0x2016;
  29893. t.dblverticallineabovecmb = 0x030e;
  29894. t.dbopomofo = 0x3109;
  29895. t.dbsquare = 0x33c8;
  29896. t.dcaron = 0x010f;
  29897. t.dcedilla = 0x1e11;
  29898. t.dcircle = 0x24d3;
  29899. t.dcircumflexbelow = 0x1e13;
  29900. t.dcroat = 0x0111;
  29901. t.ddabengali = 0x09a1;
  29902. t.ddadeva = 0x0921;
  29903. t.ddagujarati = 0x0aa1;
  29904. t.ddagurmukhi = 0x0a21;
  29905. t.ddalarabic = 0x0688;
  29906. t.ddalfinalarabic = 0xfb89;
  29907. t.dddhadeva = 0x095c;
  29908. t.ddhabengali = 0x09a2;
  29909. t.ddhadeva = 0x0922;
  29910. t.ddhagujarati = 0x0aa2;
  29911. t.ddhagurmukhi = 0x0a22;
  29912. t.ddotaccent = 0x1e0b;
  29913. t.ddotbelow = 0x1e0d;
  29914. t.decimalseparatorarabic = 0x066b;
  29915. t.decimalseparatorpersian = 0x066b;
  29916. t.decyrillic = 0x0434;
  29917. t.degree = 0x00b0;
  29918. t.dehihebrew = 0x05ad;
  29919. t.dehiragana = 0x3067;
  29920. t.deicoptic = 0x03ef;
  29921. t.dekatakana = 0x30c7;
  29922. t.deleteleft = 0x232b;
  29923. t.deleteright = 0x2326;
  29924. t.delta = 0x03b4;
  29925. t.deltaturned = 0x018d;
  29926. t.denominatorminusonenumeratorbengali = 0x09f8;
  29927. t.dezh = 0x02a4;
  29928. t.dhabengali = 0x09a7;
  29929. t.dhadeva = 0x0927;
  29930. t.dhagujarati = 0x0aa7;
  29931. t.dhagurmukhi = 0x0a27;
  29932. t.dhook = 0x0257;
  29933. t.dialytikatonos = 0x0385;
  29934. t.dialytikatonoscmb = 0x0344;
  29935. t.diamond = 0x2666;
  29936. t.diamondsuitwhite = 0x2662;
  29937. t.dieresis = 0x00a8;
  29938. t.dieresisacute = 0xf6d7;
  29939. t.dieresisbelowcmb = 0x0324;
  29940. t.dieresiscmb = 0x0308;
  29941. t.dieresisgrave = 0xf6d8;
  29942. t.dieresistonos = 0x0385;
  29943. t.dihiragana = 0x3062;
  29944. t.dikatakana = 0x30c2;
  29945. t.dittomark = 0x3003;
  29946. t.divide = 0x00f7;
  29947. t.divides = 0x2223;
  29948. t.divisionslash = 0x2215;
  29949. t.djecyrillic = 0x0452;
  29950. t.dkshade = 0x2593;
  29951. t.dlinebelow = 0x1e0f;
  29952. t.dlsquare = 0x3397;
  29953. t.dmacron = 0x0111;
  29954. t.dmonospace = 0xff44;
  29955. t.dnblock = 0x2584;
  29956. t.dochadathai = 0x0e0e;
  29957. t.dodekthai = 0x0e14;
  29958. t.dohiragana = 0x3069;
  29959. t.dokatakana = 0x30c9;
  29960. t.dollar = 0x0024;
  29961. t.dollarinferior = 0xf6e3;
  29962. t.dollarmonospace = 0xff04;
  29963. t.dollaroldstyle = 0xf724;
  29964. t.dollarsmall = 0xfe69;
  29965. t.dollarsuperior = 0xf6e4;
  29966. t.dong = 0x20ab;
  29967. t.dorusquare = 0x3326;
  29968. t.dotaccent = 0x02d9;
  29969. t.dotaccentcmb = 0x0307;
  29970. t.dotbelowcmb = 0x0323;
  29971. t.dotbelowcomb = 0x0323;
  29972. t.dotkatakana = 0x30fb;
  29973. t.dotlessi = 0x0131;
  29974. t.dotlessj = 0xf6be;
  29975. t.dotlessjstrokehook = 0x0284;
  29976. t.dotmath = 0x22c5;
  29977. t.dottedcircle = 0x25cc;
  29978. t.doubleyodpatah = 0xfb1f;
  29979. t.doubleyodpatahhebrew = 0xfb1f;
  29980. t.downtackbelowcmb = 0x031e;
  29981. t.downtackmod = 0x02d5;
  29982. t.dparen = 0x249f;
  29983. t.dsuperior = 0xf6eb;
  29984. t.dtail = 0x0256;
  29985. t.dtopbar = 0x018c;
  29986. t.duhiragana = 0x3065;
  29987. t.dukatakana = 0x30c5;
  29988. t.dz = 0x01f3;
  29989. t.dzaltone = 0x02a3;
  29990. t.dzcaron = 0x01c6;
  29991. t.dzcurl = 0x02a5;
  29992. t.dzeabkhasiancyrillic = 0x04e1;
  29993. t.dzecyrillic = 0x0455;
  29994. t.dzhecyrillic = 0x045f;
  29995. t.e = 0x0065;
  29996. t.eacute = 0x00e9;
  29997. t.earth = 0x2641;
  29998. t.ebengali = 0x098f;
  29999. t.ebopomofo = 0x311c;
  30000. t.ebreve = 0x0115;
  30001. t.ecandradeva = 0x090d;
  30002. t.ecandragujarati = 0x0a8d;
  30003. t.ecandravowelsigndeva = 0x0945;
  30004. t.ecandravowelsigngujarati = 0x0ac5;
  30005. t.ecaron = 0x011b;
  30006. t.ecedillabreve = 0x1e1d;
  30007. t.echarmenian = 0x0565;
  30008. t.echyiwnarmenian = 0x0587;
  30009. t.ecircle = 0x24d4;
  30010. t.ecircumflex = 0x00ea;
  30011. t.ecircumflexacute = 0x1ebf;
  30012. t.ecircumflexbelow = 0x1e19;
  30013. t.ecircumflexdotbelow = 0x1ec7;
  30014. t.ecircumflexgrave = 0x1ec1;
  30015. t.ecircumflexhookabove = 0x1ec3;
  30016. t.ecircumflextilde = 0x1ec5;
  30017. t.ecyrillic = 0x0454;
  30018. t.edblgrave = 0x0205;
  30019. t.edeva = 0x090f;
  30020. t.edieresis = 0x00eb;
  30021. t.edot = 0x0117;
  30022. t.edotaccent = 0x0117;
  30023. t.edotbelow = 0x1eb9;
  30024. t.eegurmukhi = 0x0a0f;
  30025. t.eematragurmukhi = 0x0a47;
  30026. t.efcyrillic = 0x0444;
  30027. t.egrave = 0x00e8;
  30028. t.egujarati = 0x0a8f;
  30029. t.eharmenian = 0x0567;
  30030. t.ehbopomofo = 0x311d;
  30031. t.ehiragana = 0x3048;
  30032. t.ehookabove = 0x1ebb;
  30033. t.eibopomofo = 0x311f;
  30034. t.eight = 0x0038;
  30035. t.eightarabic = 0x0668;
  30036. t.eightbengali = 0x09ee;
  30037. t.eightcircle = 0x2467;
  30038. t.eightcircleinversesansserif = 0x2791;
  30039. t.eightdeva = 0x096e;
  30040. t.eighteencircle = 0x2471;
  30041. t.eighteenparen = 0x2485;
  30042. t.eighteenperiod = 0x2499;
  30043. t.eightgujarati = 0x0aee;
  30044. t.eightgurmukhi = 0x0a6e;
  30045. t.eighthackarabic = 0x0668;
  30046. t.eighthangzhou = 0x3028;
  30047. t.eighthnotebeamed = 0x266b;
  30048. t.eightideographicparen = 0x3227;
  30049. t.eightinferior = 0x2088;
  30050. t.eightmonospace = 0xff18;
  30051. t.eightoldstyle = 0xf738;
  30052. t.eightparen = 0x247b;
  30053. t.eightperiod = 0x248f;
  30054. t.eightpersian = 0x06f8;
  30055. t.eightroman = 0x2177;
  30056. t.eightsuperior = 0x2078;
  30057. t.eightthai = 0x0e58;
  30058. t.einvertedbreve = 0x0207;
  30059. t.eiotifiedcyrillic = 0x0465;
  30060. t.ekatakana = 0x30a8;
  30061. t.ekatakanahalfwidth = 0xff74;
  30062. t.ekonkargurmukhi = 0x0a74;
  30063. t.ekorean = 0x3154;
  30064. t.elcyrillic = 0x043b;
  30065. t.element = 0x2208;
  30066. t.elevencircle = 0x246a;
  30067. t.elevenparen = 0x247e;
  30068. t.elevenperiod = 0x2492;
  30069. t.elevenroman = 0x217a;
  30070. t.ellipsis = 0x2026;
  30071. t.ellipsisvertical = 0x22ee;
  30072. t.emacron = 0x0113;
  30073. t.emacronacute = 0x1e17;
  30074. t.emacrongrave = 0x1e15;
  30075. t.emcyrillic = 0x043c;
  30076. t.emdash = 0x2014;
  30077. t.emdashvertical = 0xfe31;
  30078. t.emonospace = 0xff45;
  30079. t.emphasismarkarmenian = 0x055b;
  30080. t.emptyset = 0x2205;
  30081. t.enbopomofo = 0x3123;
  30082. t.encyrillic = 0x043d;
  30083. t.endash = 0x2013;
  30084. t.endashvertical = 0xfe32;
  30085. t.endescendercyrillic = 0x04a3;
  30086. t.eng = 0x014b;
  30087. t.engbopomofo = 0x3125;
  30088. t.enghecyrillic = 0x04a5;
  30089. t.enhookcyrillic = 0x04c8;
  30090. t.enspace = 0x2002;
  30091. t.eogonek = 0x0119;
  30092. t.eokorean = 0x3153;
  30093. t.eopen = 0x025b;
  30094. t.eopenclosed = 0x029a;
  30095. t.eopenreversed = 0x025c;
  30096. t.eopenreversedclosed = 0x025e;
  30097. t.eopenreversedhook = 0x025d;
  30098. t.eparen = 0x24a0;
  30099. t.epsilon = 0x03b5;
  30100. t.epsilontonos = 0x03ad;
  30101. t.equal = 0x003d;
  30102. t.equalmonospace = 0xff1d;
  30103. t.equalsmall = 0xfe66;
  30104. t.equalsuperior = 0x207c;
  30105. t.equivalence = 0x2261;
  30106. t.erbopomofo = 0x3126;
  30107. t.ercyrillic = 0x0440;
  30108. t.ereversed = 0x0258;
  30109. t.ereversedcyrillic = 0x044d;
  30110. t.escyrillic = 0x0441;
  30111. t.esdescendercyrillic = 0x04ab;
  30112. t.esh = 0x0283;
  30113. t.eshcurl = 0x0286;
  30114. t.eshortdeva = 0x090e;
  30115. t.eshortvowelsigndeva = 0x0946;
  30116. t.eshreversedloop = 0x01aa;
  30117. t.eshsquatreversed = 0x0285;
  30118. t.esmallhiragana = 0x3047;
  30119. t.esmallkatakana = 0x30a7;
  30120. t.esmallkatakanahalfwidth = 0xff6a;
  30121. t.estimated = 0x212e;
  30122. t.esuperior = 0xf6ec;
  30123. t.eta = 0x03b7;
  30124. t.etarmenian = 0x0568;
  30125. t.etatonos = 0x03ae;
  30126. t.eth = 0x00f0;
  30127. t.etilde = 0x1ebd;
  30128. t.etildebelow = 0x1e1b;
  30129. t.etnahtafoukhhebrew = 0x0591;
  30130. t.etnahtafoukhlefthebrew = 0x0591;
  30131. t.etnahtahebrew = 0x0591;
  30132. t.etnahtalefthebrew = 0x0591;
  30133. t.eturned = 0x01dd;
  30134. t.eukorean = 0x3161;
  30135. t.euro = 0x20ac;
  30136. t.evowelsignbengali = 0x09c7;
  30137. t.evowelsigndeva = 0x0947;
  30138. t.evowelsigngujarati = 0x0ac7;
  30139. t.exclam = 0x0021;
  30140. t.exclamarmenian = 0x055c;
  30141. t.exclamdbl = 0x203c;
  30142. t.exclamdown = 0x00a1;
  30143. t.exclamdownsmall = 0xf7a1;
  30144. t.exclammonospace = 0xff01;
  30145. t.exclamsmall = 0xf721;
  30146. t.existential = 0x2203;
  30147. t.ezh = 0x0292;
  30148. t.ezhcaron = 0x01ef;
  30149. t.ezhcurl = 0x0293;
  30150. t.ezhreversed = 0x01b9;
  30151. t.ezhtail = 0x01ba;
  30152. t.f = 0x0066;
  30153. t.fadeva = 0x095e;
  30154. t.fagurmukhi = 0x0a5e;
  30155. t.fahrenheit = 0x2109;
  30156. t.fathaarabic = 0x064e;
  30157. t.fathalowarabic = 0x064e;
  30158. t.fathatanarabic = 0x064b;
  30159. t.fbopomofo = 0x3108;
  30160. t.fcircle = 0x24d5;
  30161. t.fdotaccent = 0x1e1f;
  30162. t.feharabic = 0x0641;
  30163. t.feharmenian = 0x0586;
  30164. t.fehfinalarabic = 0xfed2;
  30165. t.fehinitialarabic = 0xfed3;
  30166. t.fehmedialarabic = 0xfed4;
  30167. t.feicoptic = 0x03e5;
  30168. t.female = 0x2640;
  30169. t.ff = 0xfb00;
  30170. t.f_f = 0xfb00;
  30171. t.ffi = 0xfb03;
  30172. t.f_f_i = 0xfb03;
  30173. t.ffl = 0xfb04;
  30174. t.f_f_l = 0xfb04;
  30175. t.fi = 0xfb01;
  30176. t.f_i = 0xfb01;
  30177. t.fifteencircle = 0x246e;
  30178. t.fifteenparen = 0x2482;
  30179. t.fifteenperiod = 0x2496;
  30180. t.figuredash = 0x2012;
  30181. t.filledbox = 0x25a0;
  30182. t.filledrect = 0x25ac;
  30183. t.finalkaf = 0x05da;
  30184. t.finalkafdagesh = 0xfb3a;
  30185. t.finalkafdageshhebrew = 0xfb3a;
  30186. t.finalkafhebrew = 0x05da;
  30187. t.finalmem = 0x05dd;
  30188. t.finalmemhebrew = 0x05dd;
  30189. t.finalnun = 0x05df;
  30190. t.finalnunhebrew = 0x05df;
  30191. t.finalpe = 0x05e3;
  30192. t.finalpehebrew = 0x05e3;
  30193. t.finaltsadi = 0x05e5;
  30194. t.finaltsadihebrew = 0x05e5;
  30195. t.firsttonechinese = 0x02c9;
  30196. t.fisheye = 0x25c9;
  30197. t.fitacyrillic = 0x0473;
  30198. t.five = 0x0035;
  30199. t.fivearabic = 0x0665;
  30200. t.fivebengali = 0x09eb;
  30201. t.fivecircle = 0x2464;
  30202. t.fivecircleinversesansserif = 0x278e;
  30203. t.fivedeva = 0x096b;
  30204. t.fiveeighths = 0x215d;
  30205. t.fivegujarati = 0x0aeb;
  30206. t.fivegurmukhi = 0x0a6b;
  30207. t.fivehackarabic = 0x0665;
  30208. t.fivehangzhou = 0x3025;
  30209. t.fiveideographicparen = 0x3224;
  30210. t.fiveinferior = 0x2085;
  30211. t.fivemonospace = 0xff15;
  30212. t.fiveoldstyle = 0xf735;
  30213. t.fiveparen = 0x2478;
  30214. t.fiveperiod = 0x248c;
  30215. t.fivepersian = 0x06f5;
  30216. t.fiveroman = 0x2174;
  30217. t.fivesuperior = 0x2075;
  30218. t.fivethai = 0x0e55;
  30219. t.fl = 0xfb02;
  30220. t.f_l = 0xfb02;
  30221. t.florin = 0x0192;
  30222. t.fmonospace = 0xff46;
  30223. t.fmsquare = 0x3399;
  30224. t.fofanthai = 0x0e1f;
  30225. t.fofathai = 0x0e1d;
  30226. t.fongmanthai = 0x0e4f;
  30227. t.forall = 0x2200;
  30228. t.four = 0x0034;
  30229. t.fourarabic = 0x0664;
  30230. t.fourbengali = 0x09ea;
  30231. t.fourcircle = 0x2463;
  30232. t.fourcircleinversesansserif = 0x278d;
  30233. t.fourdeva = 0x096a;
  30234. t.fourgujarati = 0x0aea;
  30235. t.fourgurmukhi = 0x0a6a;
  30236. t.fourhackarabic = 0x0664;
  30237. t.fourhangzhou = 0x3024;
  30238. t.fourideographicparen = 0x3223;
  30239. t.fourinferior = 0x2084;
  30240. t.fourmonospace = 0xff14;
  30241. t.fournumeratorbengali = 0x09f7;
  30242. t.fouroldstyle = 0xf734;
  30243. t.fourparen = 0x2477;
  30244. t.fourperiod = 0x248b;
  30245. t.fourpersian = 0x06f4;
  30246. t.fourroman = 0x2173;
  30247. t.foursuperior = 0x2074;
  30248. t.fourteencircle = 0x246d;
  30249. t.fourteenparen = 0x2481;
  30250. t.fourteenperiod = 0x2495;
  30251. t.fourthai = 0x0e54;
  30252. t.fourthtonechinese = 0x02cb;
  30253. t.fparen = 0x24a1;
  30254. t.fraction = 0x2044;
  30255. t.franc = 0x20a3;
  30256. t.g = 0x0067;
  30257. t.gabengali = 0x0997;
  30258. t.gacute = 0x01f5;
  30259. t.gadeva = 0x0917;
  30260. t.gafarabic = 0x06af;
  30261. t.gaffinalarabic = 0xfb93;
  30262. t.gafinitialarabic = 0xfb94;
  30263. t.gafmedialarabic = 0xfb95;
  30264. t.gagujarati = 0x0a97;
  30265. t.gagurmukhi = 0x0a17;
  30266. t.gahiragana = 0x304c;
  30267. t.gakatakana = 0x30ac;
  30268. t.gamma = 0x03b3;
  30269. t.gammalatinsmall = 0x0263;
  30270. t.gammasuperior = 0x02e0;
  30271. t.gangiacoptic = 0x03eb;
  30272. t.gbopomofo = 0x310d;
  30273. t.gbreve = 0x011f;
  30274. t.gcaron = 0x01e7;
  30275. t.gcedilla = 0x0123;
  30276. t.gcircle = 0x24d6;
  30277. t.gcircumflex = 0x011d;
  30278. t.gcommaaccent = 0x0123;
  30279. t.gdot = 0x0121;
  30280. t.gdotaccent = 0x0121;
  30281. t.gecyrillic = 0x0433;
  30282. t.gehiragana = 0x3052;
  30283. t.gekatakana = 0x30b2;
  30284. t.geometricallyequal = 0x2251;
  30285. t.gereshaccenthebrew = 0x059c;
  30286. t.gereshhebrew = 0x05f3;
  30287. t.gereshmuqdamhebrew = 0x059d;
  30288. t.germandbls = 0x00df;
  30289. t.gershayimaccenthebrew = 0x059e;
  30290. t.gershayimhebrew = 0x05f4;
  30291. t.getamark = 0x3013;
  30292. t.ghabengali = 0x0998;
  30293. t.ghadarmenian = 0x0572;
  30294. t.ghadeva = 0x0918;
  30295. t.ghagujarati = 0x0a98;
  30296. t.ghagurmukhi = 0x0a18;
  30297. t.ghainarabic = 0x063a;
  30298. t.ghainfinalarabic = 0xfece;
  30299. t.ghaininitialarabic = 0xfecf;
  30300. t.ghainmedialarabic = 0xfed0;
  30301. t.ghemiddlehookcyrillic = 0x0495;
  30302. t.ghestrokecyrillic = 0x0493;
  30303. t.gheupturncyrillic = 0x0491;
  30304. t.ghhadeva = 0x095a;
  30305. t.ghhagurmukhi = 0x0a5a;
  30306. t.ghook = 0x0260;
  30307. t.ghzsquare = 0x3393;
  30308. t.gihiragana = 0x304e;
  30309. t.gikatakana = 0x30ae;
  30310. t.gimarmenian = 0x0563;
  30311. t.gimel = 0x05d2;
  30312. t.gimeldagesh = 0xfb32;
  30313. t.gimeldageshhebrew = 0xfb32;
  30314. t.gimelhebrew = 0x05d2;
  30315. t.gjecyrillic = 0x0453;
  30316. t.glottalinvertedstroke = 0x01be;
  30317. t.glottalstop = 0x0294;
  30318. t.glottalstopinverted = 0x0296;
  30319. t.glottalstopmod = 0x02c0;
  30320. t.glottalstopreversed = 0x0295;
  30321. t.glottalstopreversedmod = 0x02c1;
  30322. t.glottalstopreversedsuperior = 0x02e4;
  30323. t.glottalstopstroke = 0x02a1;
  30324. t.glottalstopstrokereversed = 0x02a2;
  30325. t.gmacron = 0x1e21;
  30326. t.gmonospace = 0xff47;
  30327. t.gohiragana = 0x3054;
  30328. t.gokatakana = 0x30b4;
  30329. t.gparen = 0x24a2;
  30330. t.gpasquare = 0x33ac;
  30331. t.gradient = 0x2207;
  30332. t.grave = 0x0060;
  30333. t.gravebelowcmb = 0x0316;
  30334. t.gravecmb = 0x0300;
  30335. t.gravecomb = 0x0300;
  30336. t.gravedeva = 0x0953;
  30337. t.gravelowmod = 0x02ce;
  30338. t.gravemonospace = 0xff40;
  30339. t.gravetonecmb = 0x0340;
  30340. t.greater = 0x003e;
  30341. t.greaterequal = 0x2265;
  30342. t.greaterequalorless = 0x22db;
  30343. t.greatermonospace = 0xff1e;
  30344. t.greaterorequivalent = 0x2273;
  30345. t.greaterorless = 0x2277;
  30346. t.greateroverequal = 0x2267;
  30347. t.greatersmall = 0xfe65;
  30348. t.gscript = 0x0261;
  30349. t.gstroke = 0x01e5;
  30350. t.guhiragana = 0x3050;
  30351. t.guillemotleft = 0x00ab;
  30352. t.guillemotright = 0x00bb;
  30353. t.guilsinglleft = 0x2039;
  30354. t.guilsinglright = 0x203a;
  30355. t.gukatakana = 0x30b0;
  30356. t.guramusquare = 0x3318;
  30357. t.gysquare = 0x33c9;
  30358. t.h = 0x0068;
  30359. t.haabkhasiancyrillic = 0x04a9;
  30360. t.haaltonearabic = 0x06c1;
  30361. t.habengali = 0x09b9;
  30362. t.hadescendercyrillic = 0x04b3;
  30363. t.hadeva = 0x0939;
  30364. t.hagujarati = 0x0ab9;
  30365. t.hagurmukhi = 0x0a39;
  30366. t.haharabic = 0x062d;
  30367. t.hahfinalarabic = 0xfea2;
  30368. t.hahinitialarabic = 0xfea3;
  30369. t.hahiragana = 0x306f;
  30370. t.hahmedialarabic = 0xfea4;
  30371. t.haitusquare = 0x332a;
  30372. t.hakatakana = 0x30cf;
  30373. t.hakatakanahalfwidth = 0xff8a;
  30374. t.halantgurmukhi = 0x0a4d;
  30375. t.hamzaarabic = 0x0621;
  30376. t.hamzalowarabic = 0x0621;
  30377. t.hangulfiller = 0x3164;
  30378. t.hardsigncyrillic = 0x044a;
  30379. t.harpoonleftbarbup = 0x21bc;
  30380. t.harpoonrightbarbup = 0x21c0;
  30381. t.hasquare = 0x33ca;
  30382. t.hatafpatah = 0x05b2;
  30383. t.hatafpatah16 = 0x05b2;
  30384. t.hatafpatah23 = 0x05b2;
  30385. t.hatafpatah2f = 0x05b2;
  30386. t.hatafpatahhebrew = 0x05b2;
  30387. t.hatafpatahnarrowhebrew = 0x05b2;
  30388. t.hatafpatahquarterhebrew = 0x05b2;
  30389. t.hatafpatahwidehebrew = 0x05b2;
  30390. t.hatafqamats = 0x05b3;
  30391. t.hatafqamats1b = 0x05b3;
  30392. t.hatafqamats28 = 0x05b3;
  30393. t.hatafqamats34 = 0x05b3;
  30394. t.hatafqamatshebrew = 0x05b3;
  30395. t.hatafqamatsnarrowhebrew = 0x05b3;
  30396. t.hatafqamatsquarterhebrew = 0x05b3;
  30397. t.hatafqamatswidehebrew = 0x05b3;
  30398. t.hatafsegol = 0x05b1;
  30399. t.hatafsegol17 = 0x05b1;
  30400. t.hatafsegol24 = 0x05b1;
  30401. t.hatafsegol30 = 0x05b1;
  30402. t.hatafsegolhebrew = 0x05b1;
  30403. t.hatafsegolnarrowhebrew = 0x05b1;
  30404. t.hatafsegolquarterhebrew = 0x05b1;
  30405. t.hatafsegolwidehebrew = 0x05b1;
  30406. t.hbar = 0x0127;
  30407. t.hbopomofo = 0x310f;
  30408. t.hbrevebelow = 0x1e2b;
  30409. t.hcedilla = 0x1e29;
  30410. t.hcircle = 0x24d7;
  30411. t.hcircumflex = 0x0125;
  30412. t.hdieresis = 0x1e27;
  30413. t.hdotaccent = 0x1e23;
  30414. t.hdotbelow = 0x1e25;
  30415. t.he = 0x05d4;
  30416. t.heart = 0x2665;
  30417. t.heartsuitblack = 0x2665;
  30418. t.heartsuitwhite = 0x2661;
  30419. t.hedagesh = 0xfb34;
  30420. t.hedageshhebrew = 0xfb34;
  30421. t.hehaltonearabic = 0x06c1;
  30422. t.heharabic = 0x0647;
  30423. t.hehebrew = 0x05d4;
  30424. t.hehfinalaltonearabic = 0xfba7;
  30425. t.hehfinalalttwoarabic = 0xfeea;
  30426. t.hehfinalarabic = 0xfeea;
  30427. t.hehhamzaabovefinalarabic = 0xfba5;
  30428. t.hehhamzaaboveisolatedarabic = 0xfba4;
  30429. t.hehinitialaltonearabic = 0xfba8;
  30430. t.hehinitialarabic = 0xfeeb;
  30431. t.hehiragana = 0x3078;
  30432. t.hehmedialaltonearabic = 0xfba9;
  30433. t.hehmedialarabic = 0xfeec;
  30434. t.heiseierasquare = 0x337b;
  30435. t.hekatakana = 0x30d8;
  30436. t.hekatakanahalfwidth = 0xff8d;
  30437. t.hekutaarusquare = 0x3336;
  30438. t.henghook = 0x0267;
  30439. t.herutusquare = 0x3339;
  30440. t.het = 0x05d7;
  30441. t.hethebrew = 0x05d7;
  30442. t.hhook = 0x0266;
  30443. t.hhooksuperior = 0x02b1;
  30444. t.hieuhacirclekorean = 0x327b;
  30445. t.hieuhaparenkorean = 0x321b;
  30446. t.hieuhcirclekorean = 0x326d;
  30447. t.hieuhkorean = 0x314e;
  30448. t.hieuhparenkorean = 0x320d;
  30449. t.hihiragana = 0x3072;
  30450. t.hikatakana = 0x30d2;
  30451. t.hikatakanahalfwidth = 0xff8b;
  30452. t.hiriq = 0x05b4;
  30453. t.hiriq14 = 0x05b4;
  30454. t.hiriq21 = 0x05b4;
  30455. t.hiriq2d = 0x05b4;
  30456. t.hiriqhebrew = 0x05b4;
  30457. t.hiriqnarrowhebrew = 0x05b4;
  30458. t.hiriqquarterhebrew = 0x05b4;
  30459. t.hiriqwidehebrew = 0x05b4;
  30460. t.hlinebelow = 0x1e96;
  30461. t.hmonospace = 0xff48;
  30462. t.hoarmenian = 0x0570;
  30463. t.hohipthai = 0x0e2b;
  30464. t.hohiragana = 0x307b;
  30465. t.hokatakana = 0x30db;
  30466. t.hokatakanahalfwidth = 0xff8e;
  30467. t.holam = 0x05b9;
  30468. t.holam19 = 0x05b9;
  30469. t.holam26 = 0x05b9;
  30470. t.holam32 = 0x05b9;
  30471. t.holamhebrew = 0x05b9;
  30472. t.holamnarrowhebrew = 0x05b9;
  30473. t.holamquarterhebrew = 0x05b9;
  30474. t.holamwidehebrew = 0x05b9;
  30475. t.honokhukthai = 0x0e2e;
  30476. t.hookabovecomb = 0x0309;
  30477. t.hookcmb = 0x0309;
  30478. t.hookpalatalizedbelowcmb = 0x0321;
  30479. t.hookretroflexbelowcmb = 0x0322;
  30480. t.hoonsquare = 0x3342;
  30481. t.horicoptic = 0x03e9;
  30482. t.horizontalbar = 0x2015;
  30483. t.horncmb = 0x031b;
  30484. t.hotsprings = 0x2668;
  30485. t.house = 0x2302;
  30486. t.hparen = 0x24a3;
  30487. t.hsuperior = 0x02b0;
  30488. t.hturned = 0x0265;
  30489. t.huhiragana = 0x3075;
  30490. t.huiitosquare = 0x3333;
  30491. t.hukatakana = 0x30d5;
  30492. t.hukatakanahalfwidth = 0xff8c;
  30493. t.hungarumlaut = 0x02dd;
  30494. t.hungarumlautcmb = 0x030b;
  30495. t.hv = 0x0195;
  30496. t.hyphen = 0x002d;
  30497. t.hypheninferior = 0xf6e5;
  30498. t.hyphenmonospace = 0xff0d;
  30499. t.hyphensmall = 0xfe63;
  30500. t.hyphensuperior = 0xf6e6;
  30501. t.hyphentwo = 0x2010;
  30502. t.i = 0x0069;
  30503. t.iacute = 0x00ed;
  30504. t.iacyrillic = 0x044f;
  30505. t.ibengali = 0x0987;
  30506. t.ibopomofo = 0x3127;
  30507. t.ibreve = 0x012d;
  30508. t.icaron = 0x01d0;
  30509. t.icircle = 0x24d8;
  30510. t.icircumflex = 0x00ee;
  30511. t.icyrillic = 0x0456;
  30512. t.idblgrave = 0x0209;
  30513. t.ideographearthcircle = 0x328f;
  30514. t.ideographfirecircle = 0x328b;
  30515. t.ideographicallianceparen = 0x323f;
  30516. t.ideographiccallparen = 0x323a;
  30517. t.ideographiccentrecircle = 0x32a5;
  30518. t.ideographicclose = 0x3006;
  30519. t.ideographiccomma = 0x3001;
  30520. t.ideographiccommaleft = 0xff64;
  30521. t.ideographiccongratulationparen = 0x3237;
  30522. t.ideographiccorrectcircle = 0x32a3;
  30523. t.ideographicearthparen = 0x322f;
  30524. t.ideographicenterpriseparen = 0x323d;
  30525. t.ideographicexcellentcircle = 0x329d;
  30526. t.ideographicfestivalparen = 0x3240;
  30527. t.ideographicfinancialcircle = 0x3296;
  30528. t.ideographicfinancialparen = 0x3236;
  30529. t.ideographicfireparen = 0x322b;
  30530. t.ideographichaveparen = 0x3232;
  30531. t.ideographichighcircle = 0x32a4;
  30532. t.ideographiciterationmark = 0x3005;
  30533. t.ideographiclaborcircle = 0x3298;
  30534. t.ideographiclaborparen = 0x3238;
  30535. t.ideographicleftcircle = 0x32a7;
  30536. t.ideographiclowcircle = 0x32a6;
  30537. t.ideographicmedicinecircle = 0x32a9;
  30538. t.ideographicmetalparen = 0x322e;
  30539. t.ideographicmoonparen = 0x322a;
  30540. t.ideographicnameparen = 0x3234;
  30541. t.ideographicperiod = 0x3002;
  30542. t.ideographicprintcircle = 0x329e;
  30543. t.ideographicreachparen = 0x3243;
  30544. t.ideographicrepresentparen = 0x3239;
  30545. t.ideographicresourceparen = 0x323e;
  30546. t.ideographicrightcircle = 0x32a8;
  30547. t.ideographicsecretcircle = 0x3299;
  30548. t.ideographicselfparen = 0x3242;
  30549. t.ideographicsocietyparen = 0x3233;
  30550. t.ideographicspace = 0x3000;
  30551. t.ideographicspecialparen = 0x3235;
  30552. t.ideographicstockparen = 0x3231;
  30553. t.ideographicstudyparen = 0x323b;
  30554. t.ideographicsunparen = 0x3230;
  30555. t.ideographicsuperviseparen = 0x323c;
  30556. t.ideographicwaterparen = 0x322c;
  30557. t.ideographicwoodparen = 0x322d;
  30558. t.ideographiczero = 0x3007;
  30559. t.ideographmetalcircle = 0x328e;
  30560. t.ideographmooncircle = 0x328a;
  30561. t.ideographnamecircle = 0x3294;
  30562. t.ideographsuncircle = 0x3290;
  30563. t.ideographwatercircle = 0x328c;
  30564. t.ideographwoodcircle = 0x328d;
  30565. t.ideva = 0x0907;
  30566. t.idieresis = 0x00ef;
  30567. t.idieresisacute = 0x1e2f;
  30568. t.idieresiscyrillic = 0x04e5;
  30569. t.idotbelow = 0x1ecb;
  30570. t.iebrevecyrillic = 0x04d7;
  30571. t.iecyrillic = 0x0435;
  30572. t.ieungacirclekorean = 0x3275;
  30573. t.ieungaparenkorean = 0x3215;
  30574. t.ieungcirclekorean = 0x3267;
  30575. t.ieungkorean = 0x3147;
  30576. t.ieungparenkorean = 0x3207;
  30577. t.igrave = 0x00ec;
  30578. t.igujarati = 0x0a87;
  30579. t.igurmukhi = 0x0a07;
  30580. t.ihiragana = 0x3044;
  30581. t.ihookabove = 0x1ec9;
  30582. t.iibengali = 0x0988;
  30583. t.iicyrillic = 0x0438;
  30584. t.iideva = 0x0908;
  30585. t.iigujarati = 0x0a88;
  30586. t.iigurmukhi = 0x0a08;
  30587. t.iimatragurmukhi = 0x0a40;
  30588. t.iinvertedbreve = 0x020b;
  30589. t.iishortcyrillic = 0x0439;
  30590. t.iivowelsignbengali = 0x09c0;
  30591. t.iivowelsigndeva = 0x0940;
  30592. t.iivowelsigngujarati = 0x0ac0;
  30593. t.ij = 0x0133;
  30594. t.ikatakana = 0x30a4;
  30595. t.ikatakanahalfwidth = 0xff72;
  30596. t.ikorean = 0x3163;
  30597. t.ilde = 0x02dc;
  30598. t.iluyhebrew = 0x05ac;
  30599. t.imacron = 0x012b;
  30600. t.imacroncyrillic = 0x04e3;
  30601. t.imageorapproximatelyequal = 0x2253;
  30602. t.imatragurmukhi = 0x0a3f;
  30603. t.imonospace = 0xff49;
  30604. t.increment = 0x2206;
  30605. t.infinity = 0x221e;
  30606. t.iniarmenian = 0x056b;
  30607. t.integral = 0x222b;
  30608. t.integralbottom = 0x2321;
  30609. t.integralbt = 0x2321;
  30610. t.integralex = 0xf8f5;
  30611. t.integraltop = 0x2320;
  30612. t.integraltp = 0x2320;
  30613. t.intersection = 0x2229;
  30614. t.intisquare = 0x3305;
  30615. t.invbullet = 0x25d8;
  30616. t.invcircle = 0x25d9;
  30617. t.invsmileface = 0x263b;
  30618. t.iocyrillic = 0x0451;
  30619. t.iogonek = 0x012f;
  30620. t.iota = 0x03b9;
  30621. t.iotadieresis = 0x03ca;
  30622. t.iotadieresistonos = 0x0390;
  30623. t.iotalatin = 0x0269;
  30624. t.iotatonos = 0x03af;
  30625. t.iparen = 0x24a4;
  30626. t.irigurmukhi = 0x0a72;
  30627. t.ismallhiragana = 0x3043;
  30628. t.ismallkatakana = 0x30a3;
  30629. t.ismallkatakanahalfwidth = 0xff68;
  30630. t.issharbengali = 0x09fa;
  30631. t.istroke = 0x0268;
  30632. t.isuperior = 0xf6ed;
  30633. t.iterationhiragana = 0x309d;
  30634. t.iterationkatakana = 0x30fd;
  30635. t.itilde = 0x0129;
  30636. t.itildebelow = 0x1e2d;
  30637. t.iubopomofo = 0x3129;
  30638. t.iucyrillic = 0x044e;
  30639. t.ivowelsignbengali = 0x09bf;
  30640. t.ivowelsigndeva = 0x093f;
  30641. t.ivowelsigngujarati = 0x0abf;
  30642. t.izhitsacyrillic = 0x0475;
  30643. t.izhitsadblgravecyrillic = 0x0477;
  30644. t.j = 0x006a;
  30645. t.jaarmenian = 0x0571;
  30646. t.jabengali = 0x099c;
  30647. t.jadeva = 0x091c;
  30648. t.jagujarati = 0x0a9c;
  30649. t.jagurmukhi = 0x0a1c;
  30650. t.jbopomofo = 0x3110;
  30651. t.jcaron = 0x01f0;
  30652. t.jcircle = 0x24d9;
  30653. t.jcircumflex = 0x0135;
  30654. t.jcrossedtail = 0x029d;
  30655. t.jdotlessstroke = 0x025f;
  30656. t.jecyrillic = 0x0458;
  30657. t.jeemarabic = 0x062c;
  30658. t.jeemfinalarabic = 0xfe9e;
  30659. t.jeeminitialarabic = 0xfe9f;
  30660. t.jeemmedialarabic = 0xfea0;
  30661. t.jeharabic = 0x0698;
  30662. t.jehfinalarabic = 0xfb8b;
  30663. t.jhabengali = 0x099d;
  30664. t.jhadeva = 0x091d;
  30665. t.jhagujarati = 0x0a9d;
  30666. t.jhagurmukhi = 0x0a1d;
  30667. t.jheharmenian = 0x057b;
  30668. t.jis = 0x3004;
  30669. t.jmonospace = 0xff4a;
  30670. t.jparen = 0x24a5;
  30671. t.jsuperior = 0x02b2;
  30672. t.k = 0x006b;
  30673. t.kabashkircyrillic = 0x04a1;
  30674. t.kabengali = 0x0995;
  30675. t.kacute = 0x1e31;
  30676. t.kacyrillic = 0x043a;
  30677. t.kadescendercyrillic = 0x049b;
  30678. t.kadeva = 0x0915;
  30679. t.kaf = 0x05db;
  30680. t.kafarabic = 0x0643;
  30681. t.kafdagesh = 0xfb3b;
  30682. t.kafdageshhebrew = 0xfb3b;
  30683. t.kaffinalarabic = 0xfeda;
  30684. t.kafhebrew = 0x05db;
  30685. t.kafinitialarabic = 0xfedb;
  30686. t.kafmedialarabic = 0xfedc;
  30687. t.kafrafehebrew = 0xfb4d;
  30688. t.kagujarati = 0x0a95;
  30689. t.kagurmukhi = 0x0a15;
  30690. t.kahiragana = 0x304b;
  30691. t.kahookcyrillic = 0x04c4;
  30692. t.kakatakana = 0x30ab;
  30693. t.kakatakanahalfwidth = 0xff76;
  30694. t.kappa = 0x03ba;
  30695. t.kappasymbolgreek = 0x03f0;
  30696. t.kapyeounmieumkorean = 0x3171;
  30697. t.kapyeounphieuphkorean = 0x3184;
  30698. t.kapyeounpieupkorean = 0x3178;
  30699. t.kapyeounssangpieupkorean = 0x3179;
  30700. t.karoriisquare = 0x330d;
  30701. t.kashidaautoarabic = 0x0640;
  30702. t.kashidaautonosidebearingarabic = 0x0640;
  30703. t.kasmallkatakana = 0x30f5;
  30704. t.kasquare = 0x3384;
  30705. t.kasraarabic = 0x0650;
  30706. t.kasratanarabic = 0x064d;
  30707. t.kastrokecyrillic = 0x049f;
  30708. t.katahiraprolongmarkhalfwidth = 0xff70;
  30709. t.kaverticalstrokecyrillic = 0x049d;
  30710. t.kbopomofo = 0x310e;
  30711. t.kcalsquare = 0x3389;
  30712. t.kcaron = 0x01e9;
  30713. t.kcedilla = 0x0137;
  30714. t.kcircle = 0x24da;
  30715. t.kcommaaccent = 0x0137;
  30716. t.kdotbelow = 0x1e33;
  30717. t.keharmenian = 0x0584;
  30718. t.kehiragana = 0x3051;
  30719. t.kekatakana = 0x30b1;
  30720. t.kekatakanahalfwidth = 0xff79;
  30721. t.kenarmenian = 0x056f;
  30722. t.kesmallkatakana = 0x30f6;
  30723. t.kgreenlandic = 0x0138;
  30724. t.khabengali = 0x0996;
  30725. t.khacyrillic = 0x0445;
  30726. t.khadeva = 0x0916;
  30727. t.khagujarati = 0x0a96;
  30728. t.khagurmukhi = 0x0a16;
  30729. t.khaharabic = 0x062e;
  30730. t.khahfinalarabic = 0xfea6;
  30731. t.khahinitialarabic = 0xfea7;
  30732. t.khahmedialarabic = 0xfea8;
  30733. t.kheicoptic = 0x03e7;
  30734. t.khhadeva = 0x0959;
  30735. t.khhagurmukhi = 0x0a59;
  30736. t.khieukhacirclekorean = 0x3278;
  30737. t.khieukhaparenkorean = 0x3218;
  30738. t.khieukhcirclekorean = 0x326a;
  30739. t.khieukhkorean = 0x314b;
  30740. t.khieukhparenkorean = 0x320a;
  30741. t.khokhaithai = 0x0e02;
  30742. t.khokhonthai = 0x0e05;
  30743. t.khokhuatthai = 0x0e03;
  30744. t.khokhwaithai = 0x0e04;
  30745. t.khomutthai = 0x0e5b;
  30746. t.khook = 0x0199;
  30747. t.khorakhangthai = 0x0e06;
  30748. t.khzsquare = 0x3391;
  30749. t.kihiragana = 0x304d;
  30750. t.kikatakana = 0x30ad;
  30751. t.kikatakanahalfwidth = 0xff77;
  30752. t.kiroguramusquare = 0x3315;
  30753. t.kiromeetorusquare = 0x3316;
  30754. t.kirosquare = 0x3314;
  30755. t.kiyeokacirclekorean = 0x326e;
  30756. t.kiyeokaparenkorean = 0x320e;
  30757. t.kiyeokcirclekorean = 0x3260;
  30758. t.kiyeokkorean = 0x3131;
  30759. t.kiyeokparenkorean = 0x3200;
  30760. t.kiyeoksioskorean = 0x3133;
  30761. t.kjecyrillic = 0x045c;
  30762. t.klinebelow = 0x1e35;
  30763. t.klsquare = 0x3398;
  30764. t.kmcubedsquare = 0x33a6;
  30765. t.kmonospace = 0xff4b;
  30766. t.kmsquaredsquare = 0x33a2;
  30767. t.kohiragana = 0x3053;
  30768. t.kohmsquare = 0x33c0;
  30769. t.kokaithai = 0x0e01;
  30770. t.kokatakana = 0x30b3;
  30771. t.kokatakanahalfwidth = 0xff7a;
  30772. t.kooposquare = 0x331e;
  30773. t.koppacyrillic = 0x0481;
  30774. t.koreanstandardsymbol = 0x327f;
  30775. t.koroniscmb = 0x0343;
  30776. t.kparen = 0x24a6;
  30777. t.kpasquare = 0x33aa;
  30778. t.ksicyrillic = 0x046f;
  30779. t.ktsquare = 0x33cf;
  30780. t.kturned = 0x029e;
  30781. t.kuhiragana = 0x304f;
  30782. t.kukatakana = 0x30af;
  30783. t.kukatakanahalfwidth = 0xff78;
  30784. t.kvsquare = 0x33b8;
  30785. t.kwsquare = 0x33be;
  30786. t.l = 0x006c;
  30787. t.labengali = 0x09b2;
  30788. t.lacute = 0x013a;
  30789. t.ladeva = 0x0932;
  30790. t.lagujarati = 0x0ab2;
  30791. t.lagurmukhi = 0x0a32;
  30792. t.lakkhangyaothai = 0x0e45;
  30793. t.lamaleffinalarabic = 0xfefc;
  30794. t.lamalefhamzaabovefinalarabic = 0xfef8;
  30795. t.lamalefhamzaaboveisolatedarabic = 0xfef7;
  30796. t.lamalefhamzabelowfinalarabic = 0xfefa;
  30797. t.lamalefhamzabelowisolatedarabic = 0xfef9;
  30798. t.lamalefisolatedarabic = 0xfefb;
  30799. t.lamalefmaddaabovefinalarabic = 0xfef6;
  30800. t.lamalefmaddaaboveisolatedarabic = 0xfef5;
  30801. t.lamarabic = 0x0644;
  30802. t.lambda = 0x03bb;
  30803. t.lambdastroke = 0x019b;
  30804. t.lamed = 0x05dc;
  30805. t.lameddagesh = 0xfb3c;
  30806. t.lameddageshhebrew = 0xfb3c;
  30807. t.lamedhebrew = 0x05dc;
  30808. t.lamfinalarabic = 0xfede;
  30809. t.lamhahinitialarabic = 0xfcca;
  30810. t.laminitialarabic = 0xfedf;
  30811. t.lamjeeminitialarabic = 0xfcc9;
  30812. t.lamkhahinitialarabic = 0xfccb;
  30813. t.lamlamhehisolatedarabic = 0xfdf2;
  30814. t.lammedialarabic = 0xfee0;
  30815. t.lammeemhahinitialarabic = 0xfd88;
  30816. t.lammeeminitialarabic = 0xfccc;
  30817. t.largecircle = 0x25ef;
  30818. t.lbar = 0x019a;
  30819. t.lbelt = 0x026c;
  30820. t.lbopomofo = 0x310c;
  30821. t.lcaron = 0x013e;
  30822. t.lcedilla = 0x013c;
  30823. t.lcircle = 0x24db;
  30824. t.lcircumflexbelow = 0x1e3d;
  30825. t.lcommaaccent = 0x013c;
  30826. t.ldot = 0x0140;
  30827. t.ldotaccent = 0x0140;
  30828. t.ldotbelow = 0x1e37;
  30829. t.ldotbelowmacron = 0x1e39;
  30830. t.leftangleabovecmb = 0x031a;
  30831. t.lefttackbelowcmb = 0x0318;
  30832. t.less = 0x003c;
  30833. t.lessequal = 0x2264;
  30834. t.lessequalorgreater = 0x22da;
  30835. t.lessmonospace = 0xff1c;
  30836. t.lessorequivalent = 0x2272;
  30837. t.lessorgreater = 0x2276;
  30838. t.lessoverequal = 0x2266;
  30839. t.lesssmall = 0xfe64;
  30840. t.lezh = 0x026e;
  30841. t.lfblock = 0x258c;
  30842. t.lhookretroflex = 0x026d;
  30843. t.lira = 0x20a4;
  30844. t.liwnarmenian = 0x056c;
  30845. t.lj = 0x01c9;
  30846. t.ljecyrillic = 0x0459;
  30847. t.ll = 0xf6c0;
  30848. t.lladeva = 0x0933;
  30849. t.llagujarati = 0x0ab3;
  30850. t.llinebelow = 0x1e3b;
  30851. t.llladeva = 0x0934;
  30852. t.llvocalicbengali = 0x09e1;
  30853. t.llvocalicdeva = 0x0961;
  30854. t.llvocalicvowelsignbengali = 0x09e3;
  30855. t.llvocalicvowelsigndeva = 0x0963;
  30856. t.lmiddletilde = 0x026b;
  30857. t.lmonospace = 0xff4c;
  30858. t.lmsquare = 0x33d0;
  30859. t.lochulathai = 0x0e2c;
  30860. t.logicaland = 0x2227;
  30861. t.logicalnot = 0x00ac;
  30862. t.logicalnotreversed = 0x2310;
  30863. t.logicalor = 0x2228;
  30864. t.lolingthai = 0x0e25;
  30865. t.longs = 0x017f;
  30866. t.lowlinecenterline = 0xfe4e;
  30867. t.lowlinecmb = 0x0332;
  30868. t.lowlinedashed = 0xfe4d;
  30869. t.lozenge = 0x25ca;
  30870. t.lparen = 0x24a7;
  30871. t.lslash = 0x0142;
  30872. t.lsquare = 0x2113;
  30873. t.lsuperior = 0xf6ee;
  30874. t.ltshade = 0x2591;
  30875. t.luthai = 0x0e26;
  30876. t.lvocalicbengali = 0x098c;
  30877. t.lvocalicdeva = 0x090c;
  30878. t.lvocalicvowelsignbengali = 0x09e2;
  30879. t.lvocalicvowelsigndeva = 0x0962;
  30880. t.lxsquare = 0x33d3;
  30881. t.m = 0x006d;
  30882. t.mabengali = 0x09ae;
  30883. t.macron = 0x00af;
  30884. t.macronbelowcmb = 0x0331;
  30885. t.macroncmb = 0x0304;
  30886. t.macronlowmod = 0x02cd;
  30887. t.macronmonospace = 0xffe3;
  30888. t.macute = 0x1e3f;
  30889. t.madeva = 0x092e;
  30890. t.magujarati = 0x0aae;
  30891. t.magurmukhi = 0x0a2e;
  30892. t.mahapakhhebrew = 0x05a4;
  30893. t.mahapakhlefthebrew = 0x05a4;
  30894. t.mahiragana = 0x307e;
  30895. t.maichattawalowleftthai = 0xf895;
  30896. t.maichattawalowrightthai = 0xf894;
  30897. t.maichattawathai = 0x0e4b;
  30898. t.maichattawaupperleftthai = 0xf893;
  30899. t.maieklowleftthai = 0xf88c;
  30900. t.maieklowrightthai = 0xf88b;
  30901. t.maiekthai = 0x0e48;
  30902. t.maiekupperleftthai = 0xf88a;
  30903. t.maihanakatleftthai = 0xf884;
  30904. t.maihanakatthai = 0x0e31;
  30905. t.maitaikhuleftthai = 0xf889;
  30906. t.maitaikhuthai = 0x0e47;
  30907. t.maitholowleftthai = 0xf88f;
  30908. t.maitholowrightthai = 0xf88e;
  30909. t.maithothai = 0x0e49;
  30910. t.maithoupperleftthai = 0xf88d;
  30911. t.maitrilowleftthai = 0xf892;
  30912. t.maitrilowrightthai = 0xf891;
  30913. t.maitrithai = 0x0e4a;
  30914. t.maitriupperleftthai = 0xf890;
  30915. t.maiyamokthai = 0x0e46;
  30916. t.makatakana = 0x30de;
  30917. t.makatakanahalfwidth = 0xff8f;
  30918. t.male = 0x2642;
  30919. t.mansyonsquare = 0x3347;
  30920. t.maqafhebrew = 0x05be;
  30921. t.mars = 0x2642;
  30922. t.masoracirclehebrew = 0x05af;
  30923. t.masquare = 0x3383;
  30924. t.mbopomofo = 0x3107;
  30925. t.mbsquare = 0x33d4;
  30926. t.mcircle = 0x24dc;
  30927. t.mcubedsquare = 0x33a5;
  30928. t.mdotaccent = 0x1e41;
  30929. t.mdotbelow = 0x1e43;
  30930. t.meemarabic = 0x0645;
  30931. t.meemfinalarabic = 0xfee2;
  30932. t.meeminitialarabic = 0xfee3;
  30933. t.meemmedialarabic = 0xfee4;
  30934. t.meemmeeminitialarabic = 0xfcd1;
  30935. t.meemmeemisolatedarabic = 0xfc48;
  30936. t.meetorusquare = 0x334d;
  30937. t.mehiragana = 0x3081;
  30938. t.meizierasquare = 0x337e;
  30939. t.mekatakana = 0x30e1;
  30940. t.mekatakanahalfwidth = 0xff92;
  30941. t.mem = 0x05de;
  30942. t.memdagesh = 0xfb3e;
  30943. t.memdageshhebrew = 0xfb3e;
  30944. t.memhebrew = 0x05de;
  30945. t.menarmenian = 0x0574;
  30946. t.merkhahebrew = 0x05a5;
  30947. t.merkhakefulahebrew = 0x05a6;
  30948. t.merkhakefulalefthebrew = 0x05a6;
  30949. t.merkhalefthebrew = 0x05a5;
  30950. t.mhook = 0x0271;
  30951. t.mhzsquare = 0x3392;
  30952. t.middledotkatakanahalfwidth = 0xff65;
  30953. t.middot = 0x00b7;
  30954. t.mieumacirclekorean = 0x3272;
  30955. t.mieumaparenkorean = 0x3212;
  30956. t.mieumcirclekorean = 0x3264;
  30957. t.mieumkorean = 0x3141;
  30958. t.mieumpansioskorean = 0x3170;
  30959. t.mieumparenkorean = 0x3204;
  30960. t.mieumpieupkorean = 0x316e;
  30961. t.mieumsioskorean = 0x316f;
  30962. t.mihiragana = 0x307f;
  30963. t.mikatakana = 0x30df;
  30964. t.mikatakanahalfwidth = 0xff90;
  30965. t.minus = 0x2212;
  30966. t.minusbelowcmb = 0x0320;
  30967. t.minuscircle = 0x2296;
  30968. t.minusmod = 0x02d7;
  30969. t.minusplus = 0x2213;
  30970. t.minute = 0x2032;
  30971. t.miribaarusquare = 0x334a;
  30972. t.mirisquare = 0x3349;
  30973. t.mlonglegturned = 0x0270;
  30974. t.mlsquare = 0x3396;
  30975. t.mmcubedsquare = 0x33a3;
  30976. t.mmonospace = 0xff4d;
  30977. t.mmsquaredsquare = 0x339f;
  30978. t.mohiragana = 0x3082;
  30979. t.mohmsquare = 0x33c1;
  30980. t.mokatakana = 0x30e2;
  30981. t.mokatakanahalfwidth = 0xff93;
  30982. t.molsquare = 0x33d6;
  30983. t.momathai = 0x0e21;
  30984. t.moverssquare = 0x33a7;
  30985. t.moverssquaredsquare = 0x33a8;
  30986. t.mparen = 0x24a8;
  30987. t.mpasquare = 0x33ab;
  30988. t.mssquare = 0x33b3;
  30989. t.msuperior = 0xf6ef;
  30990. t.mturned = 0x026f;
  30991. t.mu = 0x00b5;
  30992. t.mu1 = 0x00b5;
  30993. t.muasquare = 0x3382;
  30994. t.muchgreater = 0x226b;
  30995. t.muchless = 0x226a;
  30996. t.mufsquare = 0x338c;
  30997. t.mugreek = 0x03bc;
  30998. t.mugsquare = 0x338d;
  30999. t.muhiragana = 0x3080;
  31000. t.mukatakana = 0x30e0;
  31001. t.mukatakanahalfwidth = 0xff91;
  31002. t.mulsquare = 0x3395;
  31003. t.multiply = 0x00d7;
  31004. t.mumsquare = 0x339b;
  31005. t.munahhebrew = 0x05a3;
  31006. t.munahlefthebrew = 0x05a3;
  31007. t.musicalnote = 0x266a;
  31008. t.musicalnotedbl = 0x266b;
  31009. t.musicflatsign = 0x266d;
  31010. t.musicsharpsign = 0x266f;
  31011. t.mussquare = 0x33b2;
  31012. t.muvsquare = 0x33b6;
  31013. t.muwsquare = 0x33bc;
  31014. t.mvmegasquare = 0x33b9;
  31015. t.mvsquare = 0x33b7;
  31016. t.mwmegasquare = 0x33bf;
  31017. t.mwsquare = 0x33bd;
  31018. t.n = 0x006e;
  31019. t.nabengali = 0x09a8;
  31020. t.nabla = 0x2207;
  31021. t.nacute = 0x0144;
  31022. t.nadeva = 0x0928;
  31023. t.nagujarati = 0x0aa8;
  31024. t.nagurmukhi = 0x0a28;
  31025. t.nahiragana = 0x306a;
  31026. t.nakatakana = 0x30ca;
  31027. t.nakatakanahalfwidth = 0xff85;
  31028. t.napostrophe = 0x0149;
  31029. t.nasquare = 0x3381;
  31030. t.nbopomofo = 0x310b;
  31031. t.nbspace = 0x00a0;
  31032. t.ncaron = 0x0148;
  31033. t.ncedilla = 0x0146;
  31034. t.ncircle = 0x24dd;
  31035. t.ncircumflexbelow = 0x1e4b;
  31036. t.ncommaaccent = 0x0146;
  31037. t.ndotaccent = 0x1e45;
  31038. t.ndotbelow = 0x1e47;
  31039. t.nehiragana = 0x306d;
  31040. t.nekatakana = 0x30cd;
  31041. t.nekatakanahalfwidth = 0xff88;
  31042. t.newsheqelsign = 0x20aa;
  31043. t.nfsquare = 0x338b;
  31044. t.ngabengali = 0x0999;
  31045. t.ngadeva = 0x0919;
  31046. t.ngagujarati = 0x0a99;
  31047. t.ngagurmukhi = 0x0a19;
  31048. t.ngonguthai = 0x0e07;
  31049. t.nhiragana = 0x3093;
  31050. t.nhookleft = 0x0272;
  31051. t.nhookretroflex = 0x0273;
  31052. t.nieunacirclekorean = 0x326f;
  31053. t.nieunaparenkorean = 0x320f;
  31054. t.nieuncieuckorean = 0x3135;
  31055. t.nieuncirclekorean = 0x3261;
  31056. t.nieunhieuhkorean = 0x3136;
  31057. t.nieunkorean = 0x3134;
  31058. t.nieunpansioskorean = 0x3168;
  31059. t.nieunparenkorean = 0x3201;
  31060. t.nieunsioskorean = 0x3167;
  31061. t.nieuntikeutkorean = 0x3166;
  31062. t.nihiragana = 0x306b;
  31063. t.nikatakana = 0x30cb;
  31064. t.nikatakanahalfwidth = 0xff86;
  31065. t.nikhahitleftthai = 0xf899;
  31066. t.nikhahitthai = 0x0e4d;
  31067. t.nine = 0x0039;
  31068. t.ninearabic = 0x0669;
  31069. t.ninebengali = 0x09ef;
  31070. t.ninecircle = 0x2468;
  31071. t.ninecircleinversesansserif = 0x2792;
  31072. t.ninedeva = 0x096f;
  31073. t.ninegujarati = 0x0aef;
  31074. t.ninegurmukhi = 0x0a6f;
  31075. t.ninehackarabic = 0x0669;
  31076. t.ninehangzhou = 0x3029;
  31077. t.nineideographicparen = 0x3228;
  31078. t.nineinferior = 0x2089;
  31079. t.ninemonospace = 0xff19;
  31080. t.nineoldstyle = 0xf739;
  31081. t.nineparen = 0x247c;
  31082. t.nineperiod = 0x2490;
  31083. t.ninepersian = 0x06f9;
  31084. t.nineroman = 0x2178;
  31085. t.ninesuperior = 0x2079;
  31086. t.nineteencircle = 0x2472;
  31087. t.nineteenparen = 0x2486;
  31088. t.nineteenperiod = 0x249a;
  31089. t.ninethai = 0x0e59;
  31090. t.nj = 0x01cc;
  31091. t.njecyrillic = 0x045a;
  31092. t.nkatakana = 0x30f3;
  31093. t.nkatakanahalfwidth = 0xff9d;
  31094. t.nlegrightlong = 0x019e;
  31095. t.nlinebelow = 0x1e49;
  31096. t.nmonospace = 0xff4e;
  31097. t.nmsquare = 0x339a;
  31098. t.nnabengali = 0x09a3;
  31099. t.nnadeva = 0x0923;
  31100. t.nnagujarati = 0x0aa3;
  31101. t.nnagurmukhi = 0x0a23;
  31102. t.nnnadeva = 0x0929;
  31103. t.nohiragana = 0x306e;
  31104. t.nokatakana = 0x30ce;
  31105. t.nokatakanahalfwidth = 0xff89;
  31106. t.nonbreakingspace = 0x00a0;
  31107. t.nonenthai = 0x0e13;
  31108. t.nonuthai = 0x0e19;
  31109. t.noonarabic = 0x0646;
  31110. t.noonfinalarabic = 0xfee6;
  31111. t.noonghunnaarabic = 0x06ba;
  31112. t.noonghunnafinalarabic = 0xfb9f;
  31113. t.nooninitialarabic = 0xfee7;
  31114. t.noonjeeminitialarabic = 0xfcd2;
  31115. t.noonjeemisolatedarabic = 0xfc4b;
  31116. t.noonmedialarabic = 0xfee8;
  31117. t.noonmeeminitialarabic = 0xfcd5;
  31118. t.noonmeemisolatedarabic = 0xfc4e;
  31119. t.noonnoonfinalarabic = 0xfc8d;
  31120. t.notcontains = 0x220c;
  31121. t.notelement = 0x2209;
  31122. t.notelementof = 0x2209;
  31123. t.notequal = 0x2260;
  31124. t.notgreater = 0x226f;
  31125. t.notgreaternorequal = 0x2271;
  31126. t.notgreaternorless = 0x2279;
  31127. t.notidentical = 0x2262;
  31128. t.notless = 0x226e;
  31129. t.notlessnorequal = 0x2270;
  31130. t.notparallel = 0x2226;
  31131. t.notprecedes = 0x2280;
  31132. t.notsubset = 0x2284;
  31133. t.notsucceeds = 0x2281;
  31134. t.notsuperset = 0x2285;
  31135. t.nowarmenian = 0x0576;
  31136. t.nparen = 0x24a9;
  31137. t.nssquare = 0x33b1;
  31138. t.nsuperior = 0x207f;
  31139. t.ntilde = 0x00f1;
  31140. t.nu = 0x03bd;
  31141. t.nuhiragana = 0x306c;
  31142. t.nukatakana = 0x30cc;
  31143. t.nukatakanahalfwidth = 0xff87;
  31144. t.nuktabengali = 0x09bc;
  31145. t.nuktadeva = 0x093c;
  31146. t.nuktagujarati = 0x0abc;
  31147. t.nuktagurmukhi = 0x0a3c;
  31148. t.numbersign = 0x0023;
  31149. t.numbersignmonospace = 0xff03;
  31150. t.numbersignsmall = 0xfe5f;
  31151. t.numeralsigngreek = 0x0374;
  31152. t.numeralsignlowergreek = 0x0375;
  31153. t.numero = 0x2116;
  31154. t.nun = 0x05e0;
  31155. t.nundagesh = 0xfb40;
  31156. t.nundageshhebrew = 0xfb40;
  31157. t.nunhebrew = 0x05e0;
  31158. t.nvsquare = 0x33b5;
  31159. t.nwsquare = 0x33bb;
  31160. t.nyabengali = 0x099e;
  31161. t.nyadeva = 0x091e;
  31162. t.nyagujarati = 0x0a9e;
  31163. t.nyagurmukhi = 0x0a1e;
  31164. t.o = 0x006f;
  31165. t.oacute = 0x00f3;
  31166. t.oangthai = 0x0e2d;
  31167. t.obarred = 0x0275;
  31168. t.obarredcyrillic = 0x04e9;
  31169. t.obarreddieresiscyrillic = 0x04eb;
  31170. t.obengali = 0x0993;
  31171. t.obopomofo = 0x311b;
  31172. t.obreve = 0x014f;
  31173. t.ocandradeva = 0x0911;
  31174. t.ocandragujarati = 0x0a91;
  31175. t.ocandravowelsigndeva = 0x0949;
  31176. t.ocandravowelsigngujarati = 0x0ac9;
  31177. t.ocaron = 0x01d2;
  31178. t.ocircle = 0x24de;
  31179. t.ocircumflex = 0x00f4;
  31180. t.ocircumflexacute = 0x1ed1;
  31181. t.ocircumflexdotbelow = 0x1ed9;
  31182. t.ocircumflexgrave = 0x1ed3;
  31183. t.ocircumflexhookabove = 0x1ed5;
  31184. t.ocircumflextilde = 0x1ed7;
  31185. t.ocyrillic = 0x043e;
  31186. t.odblacute = 0x0151;
  31187. t.odblgrave = 0x020d;
  31188. t.odeva = 0x0913;
  31189. t.odieresis = 0x00f6;
  31190. t.odieresiscyrillic = 0x04e7;
  31191. t.odotbelow = 0x1ecd;
  31192. t.oe = 0x0153;
  31193. t.oekorean = 0x315a;
  31194. t.ogonek = 0x02db;
  31195. t.ogonekcmb = 0x0328;
  31196. t.ograve = 0x00f2;
  31197. t.ogujarati = 0x0a93;
  31198. t.oharmenian = 0x0585;
  31199. t.ohiragana = 0x304a;
  31200. t.ohookabove = 0x1ecf;
  31201. t.ohorn = 0x01a1;
  31202. t.ohornacute = 0x1edb;
  31203. t.ohorndotbelow = 0x1ee3;
  31204. t.ohorngrave = 0x1edd;
  31205. t.ohornhookabove = 0x1edf;
  31206. t.ohorntilde = 0x1ee1;
  31207. t.ohungarumlaut = 0x0151;
  31208. t.oi = 0x01a3;
  31209. t.oinvertedbreve = 0x020f;
  31210. t.okatakana = 0x30aa;
  31211. t.okatakanahalfwidth = 0xff75;
  31212. t.okorean = 0x3157;
  31213. t.olehebrew = 0x05ab;
  31214. t.omacron = 0x014d;
  31215. t.omacronacute = 0x1e53;
  31216. t.omacrongrave = 0x1e51;
  31217. t.omdeva = 0x0950;
  31218. t.omega = 0x03c9;
  31219. t.omega1 = 0x03d6;
  31220. t.omegacyrillic = 0x0461;
  31221. t.omegalatinclosed = 0x0277;
  31222. t.omegaroundcyrillic = 0x047b;
  31223. t.omegatitlocyrillic = 0x047d;
  31224. t.omegatonos = 0x03ce;
  31225. t.omgujarati = 0x0ad0;
  31226. t.omicron = 0x03bf;
  31227. t.omicrontonos = 0x03cc;
  31228. t.omonospace = 0xff4f;
  31229. t.one = 0x0031;
  31230. t.onearabic = 0x0661;
  31231. t.onebengali = 0x09e7;
  31232. t.onecircle = 0x2460;
  31233. t.onecircleinversesansserif = 0x278a;
  31234. t.onedeva = 0x0967;
  31235. t.onedotenleader = 0x2024;
  31236. t.oneeighth = 0x215b;
  31237. t.onefitted = 0xf6dc;
  31238. t.onegujarati = 0x0ae7;
  31239. t.onegurmukhi = 0x0a67;
  31240. t.onehackarabic = 0x0661;
  31241. t.onehalf = 0x00bd;
  31242. t.onehangzhou = 0x3021;
  31243. t.oneideographicparen = 0x3220;
  31244. t.oneinferior = 0x2081;
  31245. t.onemonospace = 0xff11;
  31246. t.onenumeratorbengali = 0x09f4;
  31247. t.oneoldstyle = 0xf731;
  31248. t.oneparen = 0x2474;
  31249. t.oneperiod = 0x2488;
  31250. t.onepersian = 0x06f1;
  31251. t.onequarter = 0x00bc;
  31252. t.oneroman = 0x2170;
  31253. t.onesuperior = 0x00b9;
  31254. t.onethai = 0x0e51;
  31255. t.onethird = 0x2153;
  31256. t.oogonek = 0x01eb;
  31257. t.oogonekmacron = 0x01ed;
  31258. t.oogurmukhi = 0x0a13;
  31259. t.oomatragurmukhi = 0x0a4b;
  31260. t.oopen = 0x0254;
  31261. t.oparen = 0x24aa;
  31262. t.openbullet = 0x25e6;
  31263. t.option = 0x2325;
  31264. t.ordfeminine = 0x00aa;
  31265. t.ordmasculine = 0x00ba;
  31266. t.orthogonal = 0x221f;
  31267. t.oshortdeva = 0x0912;
  31268. t.oshortvowelsigndeva = 0x094a;
  31269. t.oslash = 0x00f8;
  31270. t.oslashacute = 0x01ff;
  31271. t.osmallhiragana = 0x3049;
  31272. t.osmallkatakana = 0x30a9;
  31273. t.osmallkatakanahalfwidth = 0xff6b;
  31274. t.ostrokeacute = 0x01ff;
  31275. t.osuperior = 0xf6f0;
  31276. t.otcyrillic = 0x047f;
  31277. t.otilde = 0x00f5;
  31278. t.otildeacute = 0x1e4d;
  31279. t.otildedieresis = 0x1e4f;
  31280. t.oubopomofo = 0x3121;
  31281. t.overline = 0x203e;
  31282. t.overlinecenterline = 0xfe4a;
  31283. t.overlinecmb = 0x0305;
  31284. t.overlinedashed = 0xfe49;
  31285. t.overlinedblwavy = 0xfe4c;
  31286. t.overlinewavy = 0xfe4b;
  31287. t.overscore = 0x00af;
  31288. t.ovowelsignbengali = 0x09cb;
  31289. t.ovowelsigndeva = 0x094b;
  31290. t.ovowelsigngujarati = 0x0acb;
  31291. t.p = 0x0070;
  31292. t.paampssquare = 0x3380;
  31293. t.paasentosquare = 0x332b;
  31294. t.pabengali = 0x09aa;
  31295. t.pacute = 0x1e55;
  31296. t.padeva = 0x092a;
  31297. t.pagedown = 0x21df;
  31298. t.pageup = 0x21de;
  31299. t.pagujarati = 0x0aaa;
  31300. t.pagurmukhi = 0x0a2a;
  31301. t.pahiragana = 0x3071;
  31302. t.paiyannoithai = 0x0e2f;
  31303. t.pakatakana = 0x30d1;
  31304. t.palatalizationcyrilliccmb = 0x0484;
  31305. t.palochkacyrillic = 0x04c0;
  31306. t.pansioskorean = 0x317f;
  31307. t.paragraph = 0x00b6;
  31308. t.parallel = 0x2225;
  31309. t.parenleft = 0x0028;
  31310. t.parenleftaltonearabic = 0xfd3e;
  31311. t.parenleftbt = 0xf8ed;
  31312. t.parenleftex = 0xf8ec;
  31313. t.parenleftinferior = 0x208d;
  31314. t.parenleftmonospace = 0xff08;
  31315. t.parenleftsmall = 0xfe59;
  31316. t.parenleftsuperior = 0x207d;
  31317. t.parenlefttp = 0xf8eb;
  31318. t.parenleftvertical = 0xfe35;
  31319. t.parenright = 0x0029;
  31320. t.parenrightaltonearabic = 0xfd3f;
  31321. t.parenrightbt = 0xf8f8;
  31322. t.parenrightex = 0xf8f7;
  31323. t.parenrightinferior = 0x208e;
  31324. t.parenrightmonospace = 0xff09;
  31325. t.parenrightsmall = 0xfe5a;
  31326. t.parenrightsuperior = 0x207e;
  31327. t.parenrighttp = 0xf8f6;
  31328. t.parenrightvertical = 0xfe36;
  31329. t.partialdiff = 0x2202;
  31330. t.paseqhebrew = 0x05c0;
  31331. t.pashtahebrew = 0x0599;
  31332. t.pasquare = 0x33a9;
  31333. t.patah = 0x05b7;
  31334. t.patah11 = 0x05b7;
  31335. t.patah1d = 0x05b7;
  31336. t.patah2a = 0x05b7;
  31337. t.patahhebrew = 0x05b7;
  31338. t.patahnarrowhebrew = 0x05b7;
  31339. t.patahquarterhebrew = 0x05b7;
  31340. t.patahwidehebrew = 0x05b7;
  31341. t.pazerhebrew = 0x05a1;
  31342. t.pbopomofo = 0x3106;
  31343. t.pcircle = 0x24df;
  31344. t.pdotaccent = 0x1e57;
  31345. t.pe = 0x05e4;
  31346. t.pecyrillic = 0x043f;
  31347. t.pedagesh = 0xfb44;
  31348. t.pedageshhebrew = 0xfb44;
  31349. t.peezisquare = 0x333b;
  31350. t.pefinaldageshhebrew = 0xfb43;
  31351. t.peharabic = 0x067e;
  31352. t.peharmenian = 0x057a;
  31353. t.pehebrew = 0x05e4;
  31354. t.pehfinalarabic = 0xfb57;
  31355. t.pehinitialarabic = 0xfb58;
  31356. t.pehiragana = 0x307a;
  31357. t.pehmedialarabic = 0xfb59;
  31358. t.pekatakana = 0x30da;
  31359. t.pemiddlehookcyrillic = 0x04a7;
  31360. t.perafehebrew = 0xfb4e;
  31361. t.percent = 0x0025;
  31362. t.percentarabic = 0x066a;
  31363. t.percentmonospace = 0xff05;
  31364. t.percentsmall = 0xfe6a;
  31365. t.period = 0x002e;
  31366. t.periodarmenian = 0x0589;
  31367. t.periodcentered = 0x00b7;
  31368. t.periodhalfwidth = 0xff61;
  31369. t.periodinferior = 0xf6e7;
  31370. t.periodmonospace = 0xff0e;
  31371. t.periodsmall = 0xfe52;
  31372. t.periodsuperior = 0xf6e8;
  31373. t.perispomenigreekcmb = 0x0342;
  31374. t.perpendicular = 0x22a5;
  31375. t.perthousand = 0x2030;
  31376. t.peseta = 0x20a7;
  31377. t.pfsquare = 0x338a;
  31378. t.phabengali = 0x09ab;
  31379. t.phadeva = 0x092b;
  31380. t.phagujarati = 0x0aab;
  31381. t.phagurmukhi = 0x0a2b;
  31382. t.phi = 0x03c6;
  31383. t.phi1 = 0x03d5;
  31384. t.phieuphacirclekorean = 0x327a;
  31385. t.phieuphaparenkorean = 0x321a;
  31386. t.phieuphcirclekorean = 0x326c;
  31387. t.phieuphkorean = 0x314d;
  31388. t.phieuphparenkorean = 0x320c;
  31389. t.philatin = 0x0278;
  31390. t.phinthuthai = 0x0e3a;
  31391. t.phisymbolgreek = 0x03d5;
  31392. t.phook = 0x01a5;
  31393. t.phophanthai = 0x0e1e;
  31394. t.phophungthai = 0x0e1c;
  31395. t.phosamphaothai = 0x0e20;
  31396. t.pi = 0x03c0;
  31397. t.pieupacirclekorean = 0x3273;
  31398. t.pieupaparenkorean = 0x3213;
  31399. t.pieupcieuckorean = 0x3176;
  31400. t.pieupcirclekorean = 0x3265;
  31401. t.pieupkiyeokkorean = 0x3172;
  31402. t.pieupkorean = 0x3142;
  31403. t.pieupparenkorean = 0x3205;
  31404. t.pieupsioskiyeokkorean = 0x3174;
  31405. t.pieupsioskorean = 0x3144;
  31406. t.pieupsiostikeutkorean = 0x3175;
  31407. t.pieupthieuthkorean = 0x3177;
  31408. t.pieuptikeutkorean = 0x3173;
  31409. t.pihiragana = 0x3074;
  31410. t.pikatakana = 0x30d4;
  31411. t.pisymbolgreek = 0x03d6;
  31412. t.piwrarmenian = 0x0583;
  31413. t.planckover2pi = 0x210f;
  31414. t.planckover2pi1 = 0x210f;
  31415. t.plus = 0x002b;
  31416. t.plusbelowcmb = 0x031f;
  31417. t.pluscircle = 0x2295;
  31418. t.plusminus = 0x00b1;
  31419. t.plusmod = 0x02d6;
  31420. t.plusmonospace = 0xff0b;
  31421. t.plussmall = 0xfe62;
  31422. t.plussuperior = 0x207a;
  31423. t.pmonospace = 0xff50;
  31424. t.pmsquare = 0x33d8;
  31425. t.pohiragana = 0x307d;
  31426. t.pointingindexdownwhite = 0x261f;
  31427. t.pointingindexleftwhite = 0x261c;
  31428. t.pointingindexrightwhite = 0x261e;
  31429. t.pointingindexupwhite = 0x261d;
  31430. t.pokatakana = 0x30dd;
  31431. t.poplathai = 0x0e1b;
  31432. t.postalmark = 0x3012;
  31433. t.postalmarkface = 0x3020;
  31434. t.pparen = 0x24ab;
  31435. t.precedes = 0x227a;
  31436. t.prescription = 0x211e;
  31437. t.primemod = 0x02b9;
  31438. t.primereversed = 0x2035;
  31439. t.product = 0x220f;
  31440. t.projective = 0x2305;
  31441. t.prolongedkana = 0x30fc;
  31442. t.propellor = 0x2318;
  31443. t.propersubset = 0x2282;
  31444. t.propersuperset = 0x2283;
  31445. t.proportion = 0x2237;
  31446. t.proportional = 0x221d;
  31447. t.psi = 0x03c8;
  31448. t.psicyrillic = 0x0471;
  31449. t.psilipneumatacyrilliccmb = 0x0486;
  31450. t.pssquare = 0x33b0;
  31451. t.puhiragana = 0x3077;
  31452. t.pukatakana = 0x30d7;
  31453. t.pvsquare = 0x33b4;
  31454. t.pwsquare = 0x33ba;
  31455. t.q = 0x0071;
  31456. t.qadeva = 0x0958;
  31457. t.qadmahebrew = 0x05a8;
  31458. t.qafarabic = 0x0642;
  31459. t.qaffinalarabic = 0xfed6;
  31460. t.qafinitialarabic = 0xfed7;
  31461. t.qafmedialarabic = 0xfed8;
  31462. t.qamats = 0x05b8;
  31463. t.qamats10 = 0x05b8;
  31464. t.qamats1a = 0x05b8;
  31465. t.qamats1c = 0x05b8;
  31466. t.qamats27 = 0x05b8;
  31467. t.qamats29 = 0x05b8;
  31468. t.qamats33 = 0x05b8;
  31469. t.qamatsde = 0x05b8;
  31470. t.qamatshebrew = 0x05b8;
  31471. t.qamatsnarrowhebrew = 0x05b8;
  31472. t.qamatsqatanhebrew = 0x05b8;
  31473. t.qamatsqatannarrowhebrew = 0x05b8;
  31474. t.qamatsqatanquarterhebrew = 0x05b8;
  31475. t.qamatsqatanwidehebrew = 0x05b8;
  31476. t.qamatsquarterhebrew = 0x05b8;
  31477. t.qamatswidehebrew = 0x05b8;
  31478. t.qarneyparahebrew = 0x059f;
  31479. t.qbopomofo = 0x3111;
  31480. t.qcircle = 0x24e0;
  31481. t.qhook = 0x02a0;
  31482. t.qmonospace = 0xff51;
  31483. t.qof = 0x05e7;
  31484. t.qofdagesh = 0xfb47;
  31485. t.qofdageshhebrew = 0xfb47;
  31486. t.qofhebrew = 0x05e7;
  31487. t.qparen = 0x24ac;
  31488. t.quarternote = 0x2669;
  31489. t.qubuts = 0x05bb;
  31490. t.qubuts18 = 0x05bb;
  31491. t.qubuts25 = 0x05bb;
  31492. t.qubuts31 = 0x05bb;
  31493. t.qubutshebrew = 0x05bb;
  31494. t.qubutsnarrowhebrew = 0x05bb;
  31495. t.qubutsquarterhebrew = 0x05bb;
  31496. t.qubutswidehebrew = 0x05bb;
  31497. t.question = 0x003f;
  31498. t.questionarabic = 0x061f;
  31499. t.questionarmenian = 0x055e;
  31500. t.questiondown = 0x00bf;
  31501. t.questiondownsmall = 0xf7bf;
  31502. t.questiongreek = 0x037e;
  31503. t.questionmonospace = 0xff1f;
  31504. t.questionsmall = 0xf73f;
  31505. t.quotedbl = 0x0022;
  31506. t.quotedblbase = 0x201e;
  31507. t.quotedblleft = 0x201c;
  31508. t.quotedblmonospace = 0xff02;
  31509. t.quotedblprime = 0x301e;
  31510. t.quotedblprimereversed = 0x301d;
  31511. t.quotedblright = 0x201d;
  31512. t.quoteleft = 0x2018;
  31513. t.quoteleftreversed = 0x201b;
  31514. t.quotereversed = 0x201b;
  31515. t.quoteright = 0x2019;
  31516. t.quoterightn = 0x0149;
  31517. t.quotesinglbase = 0x201a;
  31518. t.quotesingle = 0x0027;
  31519. t.quotesinglemonospace = 0xff07;
  31520. t.r = 0x0072;
  31521. t.raarmenian = 0x057c;
  31522. t.rabengali = 0x09b0;
  31523. t.racute = 0x0155;
  31524. t.radeva = 0x0930;
  31525. t.radical = 0x221a;
  31526. t.radicalex = 0xf8e5;
  31527. t.radoverssquare = 0x33ae;
  31528. t.radoverssquaredsquare = 0x33af;
  31529. t.radsquare = 0x33ad;
  31530. t.rafe = 0x05bf;
  31531. t.rafehebrew = 0x05bf;
  31532. t.ragujarati = 0x0ab0;
  31533. t.ragurmukhi = 0x0a30;
  31534. t.rahiragana = 0x3089;
  31535. t.rakatakana = 0x30e9;
  31536. t.rakatakanahalfwidth = 0xff97;
  31537. t.ralowerdiagonalbengali = 0x09f1;
  31538. t.ramiddlediagonalbengali = 0x09f0;
  31539. t.ramshorn = 0x0264;
  31540. t.ratio = 0x2236;
  31541. t.rbopomofo = 0x3116;
  31542. t.rcaron = 0x0159;
  31543. t.rcedilla = 0x0157;
  31544. t.rcircle = 0x24e1;
  31545. t.rcommaaccent = 0x0157;
  31546. t.rdblgrave = 0x0211;
  31547. t.rdotaccent = 0x1e59;
  31548. t.rdotbelow = 0x1e5b;
  31549. t.rdotbelowmacron = 0x1e5d;
  31550. t.referencemark = 0x203b;
  31551. t.reflexsubset = 0x2286;
  31552. t.reflexsuperset = 0x2287;
  31553. t.registered = 0x00ae;
  31554. t.registersans = 0xf8e8;
  31555. t.registerserif = 0xf6da;
  31556. t.reharabic = 0x0631;
  31557. t.reharmenian = 0x0580;
  31558. t.rehfinalarabic = 0xfeae;
  31559. t.rehiragana = 0x308c;
  31560. t.rekatakana = 0x30ec;
  31561. t.rekatakanahalfwidth = 0xff9a;
  31562. t.resh = 0x05e8;
  31563. t.reshdageshhebrew = 0xfb48;
  31564. t.reshhebrew = 0x05e8;
  31565. t.reversedtilde = 0x223d;
  31566. t.reviahebrew = 0x0597;
  31567. t.reviamugrashhebrew = 0x0597;
  31568. t.revlogicalnot = 0x2310;
  31569. t.rfishhook = 0x027e;
  31570. t.rfishhookreversed = 0x027f;
  31571. t.rhabengali = 0x09dd;
  31572. t.rhadeva = 0x095d;
  31573. t.rho = 0x03c1;
  31574. t.rhook = 0x027d;
  31575. t.rhookturned = 0x027b;
  31576. t.rhookturnedsuperior = 0x02b5;
  31577. t.rhosymbolgreek = 0x03f1;
  31578. t.rhotichookmod = 0x02de;
  31579. t.rieulacirclekorean = 0x3271;
  31580. t.rieulaparenkorean = 0x3211;
  31581. t.rieulcirclekorean = 0x3263;
  31582. t.rieulhieuhkorean = 0x3140;
  31583. t.rieulkiyeokkorean = 0x313a;
  31584. t.rieulkiyeoksioskorean = 0x3169;
  31585. t.rieulkorean = 0x3139;
  31586. t.rieulmieumkorean = 0x313b;
  31587. t.rieulpansioskorean = 0x316c;
  31588. t.rieulparenkorean = 0x3203;
  31589. t.rieulphieuphkorean = 0x313f;
  31590. t.rieulpieupkorean = 0x313c;
  31591. t.rieulpieupsioskorean = 0x316b;
  31592. t.rieulsioskorean = 0x313d;
  31593. t.rieulthieuthkorean = 0x313e;
  31594. t.rieultikeutkorean = 0x316a;
  31595. t.rieulyeorinhieuhkorean = 0x316d;
  31596. t.rightangle = 0x221f;
  31597. t.righttackbelowcmb = 0x0319;
  31598. t.righttriangle = 0x22bf;
  31599. t.rihiragana = 0x308a;
  31600. t.rikatakana = 0x30ea;
  31601. t.rikatakanahalfwidth = 0xff98;
  31602. t.ring = 0x02da;
  31603. t.ringbelowcmb = 0x0325;
  31604. t.ringcmb = 0x030a;
  31605. t.ringhalfleft = 0x02bf;
  31606. t.ringhalfleftarmenian = 0x0559;
  31607. t.ringhalfleftbelowcmb = 0x031c;
  31608. t.ringhalfleftcentered = 0x02d3;
  31609. t.ringhalfright = 0x02be;
  31610. t.ringhalfrightbelowcmb = 0x0339;
  31611. t.ringhalfrightcentered = 0x02d2;
  31612. t.rinvertedbreve = 0x0213;
  31613. t.rittorusquare = 0x3351;
  31614. t.rlinebelow = 0x1e5f;
  31615. t.rlongleg = 0x027c;
  31616. t.rlonglegturned = 0x027a;
  31617. t.rmonospace = 0xff52;
  31618. t.rohiragana = 0x308d;
  31619. t.rokatakana = 0x30ed;
  31620. t.rokatakanahalfwidth = 0xff9b;
  31621. t.roruathai = 0x0e23;
  31622. t.rparen = 0x24ad;
  31623. t.rrabengali = 0x09dc;
  31624. t.rradeva = 0x0931;
  31625. t.rragurmukhi = 0x0a5c;
  31626. t.rreharabic = 0x0691;
  31627. t.rrehfinalarabic = 0xfb8d;
  31628. t.rrvocalicbengali = 0x09e0;
  31629. t.rrvocalicdeva = 0x0960;
  31630. t.rrvocalicgujarati = 0x0ae0;
  31631. t.rrvocalicvowelsignbengali = 0x09c4;
  31632. t.rrvocalicvowelsigndeva = 0x0944;
  31633. t.rrvocalicvowelsigngujarati = 0x0ac4;
  31634. t.rsuperior = 0xf6f1;
  31635. t.rtblock = 0x2590;
  31636. t.rturned = 0x0279;
  31637. t.rturnedsuperior = 0x02b4;
  31638. t.ruhiragana = 0x308b;
  31639. t.rukatakana = 0x30eb;
  31640. t.rukatakanahalfwidth = 0xff99;
  31641. t.rupeemarkbengali = 0x09f2;
  31642. t.rupeesignbengali = 0x09f3;
  31643. t.rupiah = 0xf6dd;
  31644. t.ruthai = 0x0e24;
  31645. t.rvocalicbengali = 0x098b;
  31646. t.rvocalicdeva = 0x090b;
  31647. t.rvocalicgujarati = 0x0a8b;
  31648. t.rvocalicvowelsignbengali = 0x09c3;
  31649. t.rvocalicvowelsigndeva = 0x0943;
  31650. t.rvocalicvowelsigngujarati = 0x0ac3;
  31651. t.s = 0x0073;
  31652. t.sabengali = 0x09b8;
  31653. t.sacute = 0x015b;
  31654. t.sacutedotaccent = 0x1e65;
  31655. t.sadarabic = 0x0635;
  31656. t.sadeva = 0x0938;
  31657. t.sadfinalarabic = 0xfeba;
  31658. t.sadinitialarabic = 0xfebb;
  31659. t.sadmedialarabic = 0xfebc;
  31660. t.sagujarati = 0x0ab8;
  31661. t.sagurmukhi = 0x0a38;
  31662. t.sahiragana = 0x3055;
  31663. t.sakatakana = 0x30b5;
  31664. t.sakatakanahalfwidth = 0xff7b;
  31665. t.sallallahoualayhewasallamarabic = 0xfdfa;
  31666. t.samekh = 0x05e1;
  31667. t.samekhdagesh = 0xfb41;
  31668. t.samekhdageshhebrew = 0xfb41;
  31669. t.samekhhebrew = 0x05e1;
  31670. t.saraaathai = 0x0e32;
  31671. t.saraaethai = 0x0e41;
  31672. t.saraaimaimalaithai = 0x0e44;
  31673. t.saraaimaimuanthai = 0x0e43;
  31674. t.saraamthai = 0x0e33;
  31675. t.saraathai = 0x0e30;
  31676. t.saraethai = 0x0e40;
  31677. t.saraiileftthai = 0xf886;
  31678. t.saraiithai = 0x0e35;
  31679. t.saraileftthai = 0xf885;
  31680. t.saraithai = 0x0e34;
  31681. t.saraothai = 0x0e42;
  31682. t.saraueeleftthai = 0xf888;
  31683. t.saraueethai = 0x0e37;
  31684. t.saraueleftthai = 0xf887;
  31685. t.sarauethai = 0x0e36;
  31686. t.sarauthai = 0x0e38;
  31687. t.sarauuthai = 0x0e39;
  31688. t.sbopomofo = 0x3119;
  31689. t.scaron = 0x0161;
  31690. t.scarondotaccent = 0x1e67;
  31691. t.scedilla = 0x015f;
  31692. t.schwa = 0x0259;
  31693. t.schwacyrillic = 0x04d9;
  31694. t.schwadieresiscyrillic = 0x04db;
  31695. t.schwahook = 0x025a;
  31696. t.scircle = 0x24e2;
  31697. t.scircumflex = 0x015d;
  31698. t.scommaaccent = 0x0219;
  31699. t.sdotaccent = 0x1e61;
  31700. t.sdotbelow = 0x1e63;
  31701. t.sdotbelowdotaccent = 0x1e69;
  31702. t.seagullbelowcmb = 0x033c;
  31703. t.second = 0x2033;
  31704. t.secondtonechinese = 0x02ca;
  31705. t.section = 0x00a7;
  31706. t.seenarabic = 0x0633;
  31707. t.seenfinalarabic = 0xfeb2;
  31708. t.seeninitialarabic = 0xfeb3;
  31709. t.seenmedialarabic = 0xfeb4;
  31710. t.segol = 0x05b6;
  31711. t.segol13 = 0x05b6;
  31712. t.segol1f = 0x05b6;
  31713. t.segol2c = 0x05b6;
  31714. t.segolhebrew = 0x05b6;
  31715. t.segolnarrowhebrew = 0x05b6;
  31716. t.segolquarterhebrew = 0x05b6;
  31717. t.segoltahebrew = 0x0592;
  31718. t.segolwidehebrew = 0x05b6;
  31719. t.seharmenian = 0x057d;
  31720. t.sehiragana = 0x305b;
  31721. t.sekatakana = 0x30bb;
  31722. t.sekatakanahalfwidth = 0xff7e;
  31723. t.semicolon = 0x003b;
  31724. t.semicolonarabic = 0x061b;
  31725. t.semicolonmonospace = 0xff1b;
  31726. t.semicolonsmall = 0xfe54;
  31727. t.semivoicedmarkkana = 0x309c;
  31728. t.semivoicedmarkkanahalfwidth = 0xff9f;
  31729. t.sentisquare = 0x3322;
  31730. t.sentosquare = 0x3323;
  31731. t.seven = 0x0037;
  31732. t.sevenarabic = 0x0667;
  31733. t.sevenbengali = 0x09ed;
  31734. t.sevencircle = 0x2466;
  31735. t.sevencircleinversesansserif = 0x2790;
  31736. t.sevendeva = 0x096d;
  31737. t.seveneighths = 0x215e;
  31738. t.sevengujarati = 0x0aed;
  31739. t.sevengurmukhi = 0x0a6d;
  31740. t.sevenhackarabic = 0x0667;
  31741. t.sevenhangzhou = 0x3027;
  31742. t.sevenideographicparen = 0x3226;
  31743. t.seveninferior = 0x2087;
  31744. t.sevenmonospace = 0xff17;
  31745. t.sevenoldstyle = 0xf737;
  31746. t.sevenparen = 0x247a;
  31747. t.sevenperiod = 0x248e;
  31748. t.sevenpersian = 0x06f7;
  31749. t.sevenroman = 0x2176;
  31750. t.sevensuperior = 0x2077;
  31751. t.seventeencircle = 0x2470;
  31752. t.seventeenparen = 0x2484;
  31753. t.seventeenperiod = 0x2498;
  31754. t.seventhai = 0x0e57;
  31755. t.sfthyphen = 0x00ad;
  31756. t.shaarmenian = 0x0577;
  31757. t.shabengali = 0x09b6;
  31758. t.shacyrillic = 0x0448;
  31759. t.shaddaarabic = 0x0651;
  31760. t.shaddadammaarabic = 0xfc61;
  31761. t.shaddadammatanarabic = 0xfc5e;
  31762. t.shaddafathaarabic = 0xfc60;
  31763. t.shaddakasraarabic = 0xfc62;
  31764. t.shaddakasratanarabic = 0xfc5f;
  31765. t.shade = 0x2592;
  31766. t.shadedark = 0x2593;
  31767. t.shadelight = 0x2591;
  31768. t.shademedium = 0x2592;
  31769. t.shadeva = 0x0936;
  31770. t.shagujarati = 0x0ab6;
  31771. t.shagurmukhi = 0x0a36;
  31772. t.shalshelethebrew = 0x0593;
  31773. t.shbopomofo = 0x3115;
  31774. t.shchacyrillic = 0x0449;
  31775. t.sheenarabic = 0x0634;
  31776. t.sheenfinalarabic = 0xfeb6;
  31777. t.sheeninitialarabic = 0xfeb7;
  31778. t.sheenmedialarabic = 0xfeb8;
  31779. t.sheicoptic = 0x03e3;
  31780. t.sheqel = 0x20aa;
  31781. t.sheqelhebrew = 0x20aa;
  31782. t.sheva = 0x05b0;
  31783. t.sheva115 = 0x05b0;
  31784. t.sheva15 = 0x05b0;
  31785. t.sheva22 = 0x05b0;
  31786. t.sheva2e = 0x05b0;
  31787. t.shevahebrew = 0x05b0;
  31788. t.shevanarrowhebrew = 0x05b0;
  31789. t.shevaquarterhebrew = 0x05b0;
  31790. t.shevawidehebrew = 0x05b0;
  31791. t.shhacyrillic = 0x04bb;
  31792. t.shimacoptic = 0x03ed;
  31793. t.shin = 0x05e9;
  31794. t.shindagesh = 0xfb49;
  31795. t.shindageshhebrew = 0xfb49;
  31796. t.shindageshshindot = 0xfb2c;
  31797. t.shindageshshindothebrew = 0xfb2c;
  31798. t.shindageshsindot = 0xfb2d;
  31799. t.shindageshsindothebrew = 0xfb2d;
  31800. t.shindothebrew = 0x05c1;
  31801. t.shinhebrew = 0x05e9;
  31802. t.shinshindot = 0xfb2a;
  31803. t.shinshindothebrew = 0xfb2a;
  31804. t.shinsindot = 0xfb2b;
  31805. t.shinsindothebrew = 0xfb2b;
  31806. t.shook = 0x0282;
  31807. t.sigma = 0x03c3;
  31808. t.sigma1 = 0x03c2;
  31809. t.sigmafinal = 0x03c2;
  31810. t.sigmalunatesymbolgreek = 0x03f2;
  31811. t.sihiragana = 0x3057;
  31812. t.sikatakana = 0x30b7;
  31813. t.sikatakanahalfwidth = 0xff7c;
  31814. t.siluqhebrew = 0x05bd;
  31815. t.siluqlefthebrew = 0x05bd;
  31816. t.similar = 0x223c;
  31817. t.sindothebrew = 0x05c2;
  31818. t.siosacirclekorean = 0x3274;
  31819. t.siosaparenkorean = 0x3214;
  31820. t.sioscieuckorean = 0x317e;
  31821. t.sioscirclekorean = 0x3266;
  31822. t.sioskiyeokkorean = 0x317a;
  31823. t.sioskorean = 0x3145;
  31824. t.siosnieunkorean = 0x317b;
  31825. t.siosparenkorean = 0x3206;
  31826. t.siospieupkorean = 0x317d;
  31827. t.siostikeutkorean = 0x317c;
  31828. t.six = 0x0036;
  31829. t.sixarabic = 0x0666;
  31830. t.sixbengali = 0x09ec;
  31831. t.sixcircle = 0x2465;
  31832. t.sixcircleinversesansserif = 0x278f;
  31833. t.sixdeva = 0x096c;
  31834. t.sixgujarati = 0x0aec;
  31835. t.sixgurmukhi = 0x0a6c;
  31836. t.sixhackarabic = 0x0666;
  31837. t.sixhangzhou = 0x3026;
  31838. t.sixideographicparen = 0x3225;
  31839. t.sixinferior = 0x2086;
  31840. t.sixmonospace = 0xff16;
  31841. t.sixoldstyle = 0xf736;
  31842. t.sixparen = 0x2479;
  31843. t.sixperiod = 0x248d;
  31844. t.sixpersian = 0x06f6;
  31845. t.sixroman = 0x2175;
  31846. t.sixsuperior = 0x2076;
  31847. t.sixteencircle = 0x246f;
  31848. t.sixteencurrencydenominatorbengali = 0x09f9;
  31849. t.sixteenparen = 0x2483;
  31850. t.sixteenperiod = 0x2497;
  31851. t.sixthai = 0x0e56;
  31852. t.slash = 0x002f;
  31853. t.slashmonospace = 0xff0f;
  31854. t.slong = 0x017f;
  31855. t.slongdotaccent = 0x1e9b;
  31856. t.smileface = 0x263a;
  31857. t.smonospace = 0xff53;
  31858. t.sofpasuqhebrew = 0x05c3;
  31859. t.softhyphen = 0x00ad;
  31860. t.softsigncyrillic = 0x044c;
  31861. t.sohiragana = 0x305d;
  31862. t.sokatakana = 0x30bd;
  31863. t.sokatakanahalfwidth = 0xff7f;
  31864. t.soliduslongoverlaycmb = 0x0338;
  31865. t.solidusshortoverlaycmb = 0x0337;
  31866. t.sorusithai = 0x0e29;
  31867. t.sosalathai = 0x0e28;
  31868. t.sosothai = 0x0e0b;
  31869. t.sosuathai = 0x0e2a;
  31870. t.space = 0x0020;
  31871. t.spacehackarabic = 0x0020;
  31872. t.spade = 0x2660;
  31873. t.spadesuitblack = 0x2660;
  31874. t.spadesuitwhite = 0x2664;
  31875. t.sparen = 0x24ae;
  31876. t.squarebelowcmb = 0x033b;
  31877. t.squarecc = 0x33c4;
  31878. t.squarecm = 0x339d;
  31879. t.squarediagonalcrosshatchfill = 0x25a9;
  31880. t.squarehorizontalfill = 0x25a4;
  31881. t.squarekg = 0x338f;
  31882. t.squarekm = 0x339e;
  31883. t.squarekmcapital = 0x33ce;
  31884. t.squareln = 0x33d1;
  31885. t.squarelog = 0x33d2;
  31886. t.squaremg = 0x338e;
  31887. t.squaremil = 0x33d5;
  31888. t.squaremm = 0x339c;
  31889. t.squaremsquared = 0x33a1;
  31890. t.squareorthogonalcrosshatchfill = 0x25a6;
  31891. t.squareupperlefttolowerrightfill = 0x25a7;
  31892. t.squareupperrighttolowerleftfill = 0x25a8;
  31893. t.squareverticalfill = 0x25a5;
  31894. t.squarewhitewithsmallblack = 0x25a3;
  31895. t.srsquare = 0x33db;
  31896. t.ssabengali = 0x09b7;
  31897. t.ssadeva = 0x0937;
  31898. t.ssagujarati = 0x0ab7;
  31899. t.ssangcieuckorean = 0x3149;
  31900. t.ssanghieuhkorean = 0x3185;
  31901. t.ssangieungkorean = 0x3180;
  31902. t.ssangkiyeokkorean = 0x3132;
  31903. t.ssangnieunkorean = 0x3165;
  31904. t.ssangpieupkorean = 0x3143;
  31905. t.ssangsioskorean = 0x3146;
  31906. t.ssangtikeutkorean = 0x3138;
  31907. t.ssuperior = 0xf6f2;
  31908. t.sterling = 0x00a3;
  31909. t.sterlingmonospace = 0xffe1;
  31910. t.strokelongoverlaycmb = 0x0336;
  31911. t.strokeshortoverlaycmb = 0x0335;
  31912. t.subset = 0x2282;
  31913. t.subsetnotequal = 0x228a;
  31914. t.subsetorequal = 0x2286;
  31915. t.succeeds = 0x227b;
  31916. t.suchthat = 0x220b;
  31917. t.suhiragana = 0x3059;
  31918. t.sukatakana = 0x30b9;
  31919. t.sukatakanahalfwidth = 0xff7d;
  31920. t.sukunarabic = 0x0652;
  31921. t.summation = 0x2211;
  31922. t.sun = 0x263c;
  31923. t.superset = 0x2283;
  31924. t.supersetnotequal = 0x228b;
  31925. t.supersetorequal = 0x2287;
  31926. t.svsquare = 0x33dc;
  31927. t.syouwaerasquare = 0x337c;
  31928. t.t = 0x0074;
  31929. t.tabengali = 0x09a4;
  31930. t.tackdown = 0x22a4;
  31931. t.tackleft = 0x22a3;
  31932. t.tadeva = 0x0924;
  31933. t.tagujarati = 0x0aa4;
  31934. t.tagurmukhi = 0x0a24;
  31935. t.taharabic = 0x0637;
  31936. t.tahfinalarabic = 0xfec2;
  31937. t.tahinitialarabic = 0xfec3;
  31938. t.tahiragana = 0x305f;
  31939. t.tahmedialarabic = 0xfec4;
  31940. t.taisyouerasquare = 0x337d;
  31941. t.takatakana = 0x30bf;
  31942. t.takatakanahalfwidth = 0xff80;
  31943. t.tatweelarabic = 0x0640;
  31944. t.tau = 0x03c4;
  31945. t.tav = 0x05ea;
  31946. t.tavdages = 0xfb4a;
  31947. t.tavdagesh = 0xfb4a;
  31948. t.tavdageshhebrew = 0xfb4a;
  31949. t.tavhebrew = 0x05ea;
  31950. t.tbar = 0x0167;
  31951. t.tbopomofo = 0x310a;
  31952. t.tcaron = 0x0165;
  31953. t.tccurl = 0x02a8;
  31954. t.tcedilla = 0x0163;
  31955. t.tcheharabic = 0x0686;
  31956. t.tchehfinalarabic = 0xfb7b;
  31957. t.tchehinitialarabic = 0xfb7c;
  31958. t.tchehmedialarabic = 0xfb7d;
  31959. t.tcircle = 0x24e3;
  31960. t.tcircumflexbelow = 0x1e71;
  31961. t.tcommaaccent = 0x0163;
  31962. t.tdieresis = 0x1e97;
  31963. t.tdotaccent = 0x1e6b;
  31964. t.tdotbelow = 0x1e6d;
  31965. t.tecyrillic = 0x0442;
  31966. t.tedescendercyrillic = 0x04ad;
  31967. t.teharabic = 0x062a;
  31968. t.tehfinalarabic = 0xfe96;
  31969. t.tehhahinitialarabic = 0xfca2;
  31970. t.tehhahisolatedarabic = 0xfc0c;
  31971. t.tehinitialarabic = 0xfe97;
  31972. t.tehiragana = 0x3066;
  31973. t.tehjeeminitialarabic = 0xfca1;
  31974. t.tehjeemisolatedarabic = 0xfc0b;
  31975. t.tehmarbutaarabic = 0x0629;
  31976. t.tehmarbutafinalarabic = 0xfe94;
  31977. t.tehmedialarabic = 0xfe98;
  31978. t.tehmeeminitialarabic = 0xfca4;
  31979. t.tehmeemisolatedarabic = 0xfc0e;
  31980. t.tehnoonfinalarabic = 0xfc73;
  31981. t.tekatakana = 0x30c6;
  31982. t.tekatakanahalfwidth = 0xff83;
  31983. t.telephone = 0x2121;
  31984. t.telephoneblack = 0x260e;
  31985. t.telishagedolahebrew = 0x05a0;
  31986. t.telishaqetanahebrew = 0x05a9;
  31987. t.tencircle = 0x2469;
  31988. t.tenideographicparen = 0x3229;
  31989. t.tenparen = 0x247d;
  31990. t.tenperiod = 0x2491;
  31991. t.tenroman = 0x2179;
  31992. t.tesh = 0x02a7;
  31993. t.tet = 0x05d8;
  31994. t.tetdagesh = 0xfb38;
  31995. t.tetdageshhebrew = 0xfb38;
  31996. t.tethebrew = 0x05d8;
  31997. t.tetsecyrillic = 0x04b5;
  31998. t.tevirhebrew = 0x059b;
  31999. t.tevirlefthebrew = 0x059b;
  32000. t.thabengali = 0x09a5;
  32001. t.thadeva = 0x0925;
  32002. t.thagujarati = 0x0aa5;
  32003. t.thagurmukhi = 0x0a25;
  32004. t.thalarabic = 0x0630;
  32005. t.thalfinalarabic = 0xfeac;
  32006. t.thanthakhatlowleftthai = 0xf898;
  32007. t.thanthakhatlowrightthai = 0xf897;
  32008. t.thanthakhatthai = 0x0e4c;
  32009. t.thanthakhatupperleftthai = 0xf896;
  32010. t.theharabic = 0x062b;
  32011. t.thehfinalarabic = 0xfe9a;
  32012. t.thehinitialarabic = 0xfe9b;
  32013. t.thehmedialarabic = 0xfe9c;
  32014. t.thereexists = 0x2203;
  32015. t.therefore = 0x2234;
  32016. t.theta = 0x03b8;
  32017. t.theta1 = 0x03d1;
  32018. t.thetasymbolgreek = 0x03d1;
  32019. t.thieuthacirclekorean = 0x3279;
  32020. t.thieuthaparenkorean = 0x3219;
  32021. t.thieuthcirclekorean = 0x326b;
  32022. t.thieuthkorean = 0x314c;
  32023. t.thieuthparenkorean = 0x320b;
  32024. t.thirteencircle = 0x246c;
  32025. t.thirteenparen = 0x2480;
  32026. t.thirteenperiod = 0x2494;
  32027. t.thonangmonthothai = 0x0e11;
  32028. t.thook = 0x01ad;
  32029. t.thophuthaothai = 0x0e12;
  32030. t.thorn = 0x00fe;
  32031. t.thothahanthai = 0x0e17;
  32032. t.thothanthai = 0x0e10;
  32033. t.thothongthai = 0x0e18;
  32034. t.thothungthai = 0x0e16;
  32035. t.thousandcyrillic = 0x0482;
  32036. t.thousandsseparatorarabic = 0x066c;
  32037. t.thousandsseparatorpersian = 0x066c;
  32038. t.three = 0x0033;
  32039. t.threearabic = 0x0663;
  32040. t.threebengali = 0x09e9;
  32041. t.threecircle = 0x2462;
  32042. t.threecircleinversesansserif = 0x278c;
  32043. t.threedeva = 0x0969;
  32044. t.threeeighths = 0x215c;
  32045. t.threegujarati = 0x0ae9;
  32046. t.threegurmukhi = 0x0a69;
  32047. t.threehackarabic = 0x0663;
  32048. t.threehangzhou = 0x3023;
  32049. t.threeideographicparen = 0x3222;
  32050. t.threeinferior = 0x2083;
  32051. t.threemonospace = 0xff13;
  32052. t.threenumeratorbengali = 0x09f6;
  32053. t.threeoldstyle = 0xf733;
  32054. t.threeparen = 0x2476;
  32055. t.threeperiod = 0x248a;
  32056. t.threepersian = 0x06f3;
  32057. t.threequarters = 0x00be;
  32058. t.threequartersemdash = 0xf6de;
  32059. t.threeroman = 0x2172;
  32060. t.threesuperior = 0x00b3;
  32061. t.threethai = 0x0e53;
  32062. t.thzsquare = 0x3394;
  32063. t.tihiragana = 0x3061;
  32064. t.tikatakana = 0x30c1;
  32065. t.tikatakanahalfwidth = 0xff81;
  32066. t.tikeutacirclekorean = 0x3270;
  32067. t.tikeutaparenkorean = 0x3210;
  32068. t.tikeutcirclekorean = 0x3262;
  32069. t.tikeutkorean = 0x3137;
  32070. t.tikeutparenkorean = 0x3202;
  32071. t.tilde = 0x02dc;
  32072. t.tildebelowcmb = 0x0330;
  32073. t.tildecmb = 0x0303;
  32074. t.tildecomb = 0x0303;
  32075. t.tildedoublecmb = 0x0360;
  32076. t.tildeoperator = 0x223c;
  32077. t.tildeoverlaycmb = 0x0334;
  32078. t.tildeverticalcmb = 0x033e;
  32079. t.timescircle = 0x2297;
  32080. t.tipehahebrew = 0x0596;
  32081. t.tipehalefthebrew = 0x0596;
  32082. t.tippigurmukhi = 0x0a70;
  32083. t.titlocyrilliccmb = 0x0483;
  32084. t.tiwnarmenian = 0x057f;
  32085. t.tlinebelow = 0x1e6f;
  32086. t.tmonospace = 0xff54;
  32087. t.toarmenian = 0x0569;
  32088. t.tohiragana = 0x3068;
  32089. t.tokatakana = 0x30c8;
  32090. t.tokatakanahalfwidth = 0xff84;
  32091. t.tonebarextrahighmod = 0x02e5;
  32092. t.tonebarextralowmod = 0x02e9;
  32093. t.tonebarhighmod = 0x02e6;
  32094. t.tonebarlowmod = 0x02e8;
  32095. t.tonebarmidmod = 0x02e7;
  32096. t.tonefive = 0x01bd;
  32097. t.tonesix = 0x0185;
  32098. t.tonetwo = 0x01a8;
  32099. t.tonos = 0x0384;
  32100. t.tonsquare = 0x3327;
  32101. t.topatakthai = 0x0e0f;
  32102. t.tortoiseshellbracketleft = 0x3014;
  32103. t.tortoiseshellbracketleftsmall = 0xfe5d;
  32104. t.tortoiseshellbracketleftvertical = 0xfe39;
  32105. t.tortoiseshellbracketright = 0x3015;
  32106. t.tortoiseshellbracketrightsmall = 0xfe5e;
  32107. t.tortoiseshellbracketrightvertical = 0xfe3a;
  32108. t.totaothai = 0x0e15;
  32109. t.tpalatalhook = 0x01ab;
  32110. t.tparen = 0x24af;
  32111. t.trademark = 0x2122;
  32112. t.trademarksans = 0xf8ea;
  32113. t.trademarkserif = 0xf6db;
  32114. t.tretroflexhook = 0x0288;
  32115. t.triagdn = 0x25bc;
  32116. t.triaglf = 0x25c4;
  32117. t.triagrt = 0x25ba;
  32118. t.triagup = 0x25b2;
  32119. t.ts = 0x02a6;
  32120. t.tsadi = 0x05e6;
  32121. t.tsadidagesh = 0xfb46;
  32122. t.tsadidageshhebrew = 0xfb46;
  32123. t.tsadihebrew = 0x05e6;
  32124. t.tsecyrillic = 0x0446;
  32125. t.tsere = 0x05b5;
  32126. t.tsere12 = 0x05b5;
  32127. t.tsere1e = 0x05b5;
  32128. t.tsere2b = 0x05b5;
  32129. t.tserehebrew = 0x05b5;
  32130. t.tserenarrowhebrew = 0x05b5;
  32131. t.tserequarterhebrew = 0x05b5;
  32132. t.tserewidehebrew = 0x05b5;
  32133. t.tshecyrillic = 0x045b;
  32134. t.tsuperior = 0xf6f3;
  32135. t.ttabengali = 0x099f;
  32136. t.ttadeva = 0x091f;
  32137. t.ttagujarati = 0x0a9f;
  32138. t.ttagurmukhi = 0x0a1f;
  32139. t.tteharabic = 0x0679;
  32140. t.ttehfinalarabic = 0xfb67;
  32141. t.ttehinitialarabic = 0xfb68;
  32142. t.ttehmedialarabic = 0xfb69;
  32143. t.tthabengali = 0x09a0;
  32144. t.tthadeva = 0x0920;
  32145. t.tthagujarati = 0x0aa0;
  32146. t.tthagurmukhi = 0x0a20;
  32147. t.tturned = 0x0287;
  32148. t.tuhiragana = 0x3064;
  32149. t.tukatakana = 0x30c4;
  32150. t.tukatakanahalfwidth = 0xff82;
  32151. t.tusmallhiragana = 0x3063;
  32152. t.tusmallkatakana = 0x30c3;
  32153. t.tusmallkatakanahalfwidth = 0xff6f;
  32154. t.twelvecircle = 0x246b;
  32155. t.twelveparen = 0x247f;
  32156. t.twelveperiod = 0x2493;
  32157. t.twelveroman = 0x217b;
  32158. t.twentycircle = 0x2473;
  32159. t.twentyhangzhou = 0x5344;
  32160. t.twentyparen = 0x2487;
  32161. t.twentyperiod = 0x249b;
  32162. t.two = 0x0032;
  32163. t.twoarabic = 0x0662;
  32164. t.twobengali = 0x09e8;
  32165. t.twocircle = 0x2461;
  32166. t.twocircleinversesansserif = 0x278b;
  32167. t.twodeva = 0x0968;
  32168. t.twodotenleader = 0x2025;
  32169. t.twodotleader = 0x2025;
  32170. t.twodotleadervertical = 0xfe30;
  32171. t.twogujarati = 0x0ae8;
  32172. t.twogurmukhi = 0x0a68;
  32173. t.twohackarabic = 0x0662;
  32174. t.twohangzhou = 0x3022;
  32175. t.twoideographicparen = 0x3221;
  32176. t.twoinferior = 0x2082;
  32177. t.twomonospace = 0xff12;
  32178. t.twonumeratorbengali = 0x09f5;
  32179. t.twooldstyle = 0xf732;
  32180. t.twoparen = 0x2475;
  32181. t.twoperiod = 0x2489;
  32182. t.twopersian = 0x06f2;
  32183. t.tworoman = 0x2171;
  32184. t.twostroke = 0x01bb;
  32185. t.twosuperior = 0x00b2;
  32186. t.twothai = 0x0e52;
  32187. t.twothirds = 0x2154;
  32188. t.u = 0x0075;
  32189. t.uacute = 0x00fa;
  32190. t.ubar = 0x0289;
  32191. t.ubengali = 0x0989;
  32192. t.ubopomofo = 0x3128;
  32193. t.ubreve = 0x016d;
  32194. t.ucaron = 0x01d4;
  32195. t.ucircle = 0x24e4;
  32196. t.ucircumflex = 0x00fb;
  32197. t.ucircumflexbelow = 0x1e77;
  32198. t.ucyrillic = 0x0443;
  32199. t.udattadeva = 0x0951;
  32200. t.udblacute = 0x0171;
  32201. t.udblgrave = 0x0215;
  32202. t.udeva = 0x0909;
  32203. t.udieresis = 0x00fc;
  32204. t.udieresisacute = 0x01d8;
  32205. t.udieresisbelow = 0x1e73;
  32206. t.udieresiscaron = 0x01da;
  32207. t.udieresiscyrillic = 0x04f1;
  32208. t.udieresisgrave = 0x01dc;
  32209. t.udieresismacron = 0x01d6;
  32210. t.udotbelow = 0x1ee5;
  32211. t.ugrave = 0x00f9;
  32212. t.ugujarati = 0x0a89;
  32213. t.ugurmukhi = 0x0a09;
  32214. t.uhiragana = 0x3046;
  32215. t.uhookabove = 0x1ee7;
  32216. t.uhorn = 0x01b0;
  32217. t.uhornacute = 0x1ee9;
  32218. t.uhorndotbelow = 0x1ef1;
  32219. t.uhorngrave = 0x1eeb;
  32220. t.uhornhookabove = 0x1eed;
  32221. t.uhorntilde = 0x1eef;
  32222. t.uhungarumlaut = 0x0171;
  32223. t.uhungarumlautcyrillic = 0x04f3;
  32224. t.uinvertedbreve = 0x0217;
  32225. t.ukatakana = 0x30a6;
  32226. t.ukatakanahalfwidth = 0xff73;
  32227. t.ukcyrillic = 0x0479;
  32228. t.ukorean = 0x315c;
  32229. t.umacron = 0x016b;
  32230. t.umacroncyrillic = 0x04ef;
  32231. t.umacrondieresis = 0x1e7b;
  32232. t.umatragurmukhi = 0x0a41;
  32233. t.umonospace = 0xff55;
  32234. t.underscore = 0x005f;
  32235. t.underscoredbl = 0x2017;
  32236. t.underscoremonospace = 0xff3f;
  32237. t.underscorevertical = 0xfe33;
  32238. t.underscorewavy = 0xfe4f;
  32239. t.union = 0x222a;
  32240. t.universal = 0x2200;
  32241. t.uogonek = 0x0173;
  32242. t.uparen = 0x24b0;
  32243. t.upblock = 0x2580;
  32244. t.upperdothebrew = 0x05c4;
  32245. t.upsilon = 0x03c5;
  32246. t.upsilondieresis = 0x03cb;
  32247. t.upsilondieresistonos = 0x03b0;
  32248. t.upsilonlatin = 0x028a;
  32249. t.upsilontonos = 0x03cd;
  32250. t.uptackbelowcmb = 0x031d;
  32251. t.uptackmod = 0x02d4;
  32252. t.uragurmukhi = 0x0a73;
  32253. t.uring = 0x016f;
  32254. t.ushortcyrillic = 0x045e;
  32255. t.usmallhiragana = 0x3045;
  32256. t.usmallkatakana = 0x30a5;
  32257. t.usmallkatakanahalfwidth = 0xff69;
  32258. t.ustraightcyrillic = 0x04af;
  32259. t.ustraightstrokecyrillic = 0x04b1;
  32260. t.utilde = 0x0169;
  32261. t.utildeacute = 0x1e79;
  32262. t.utildebelow = 0x1e75;
  32263. t.uubengali = 0x098a;
  32264. t.uudeva = 0x090a;
  32265. t.uugujarati = 0x0a8a;
  32266. t.uugurmukhi = 0x0a0a;
  32267. t.uumatragurmukhi = 0x0a42;
  32268. t.uuvowelsignbengali = 0x09c2;
  32269. t.uuvowelsigndeva = 0x0942;
  32270. t.uuvowelsigngujarati = 0x0ac2;
  32271. t.uvowelsignbengali = 0x09c1;
  32272. t.uvowelsigndeva = 0x0941;
  32273. t.uvowelsigngujarati = 0x0ac1;
  32274. t.v = 0x0076;
  32275. t.vadeva = 0x0935;
  32276. t.vagujarati = 0x0ab5;
  32277. t.vagurmukhi = 0x0a35;
  32278. t.vakatakana = 0x30f7;
  32279. t.vav = 0x05d5;
  32280. t.vavdagesh = 0xfb35;
  32281. t.vavdagesh65 = 0xfb35;
  32282. t.vavdageshhebrew = 0xfb35;
  32283. t.vavhebrew = 0x05d5;
  32284. t.vavholam = 0xfb4b;
  32285. t.vavholamhebrew = 0xfb4b;
  32286. t.vavvavhebrew = 0x05f0;
  32287. t.vavyodhebrew = 0x05f1;
  32288. t.vcircle = 0x24e5;
  32289. t.vdotbelow = 0x1e7f;
  32290. t.vecyrillic = 0x0432;
  32291. t.veharabic = 0x06a4;
  32292. t.vehfinalarabic = 0xfb6b;
  32293. t.vehinitialarabic = 0xfb6c;
  32294. t.vehmedialarabic = 0xfb6d;
  32295. t.vekatakana = 0x30f9;
  32296. t.venus = 0x2640;
  32297. t.verticalbar = 0x007c;
  32298. t.verticallineabovecmb = 0x030d;
  32299. t.verticallinebelowcmb = 0x0329;
  32300. t.verticallinelowmod = 0x02cc;
  32301. t.verticallinemod = 0x02c8;
  32302. t.vewarmenian = 0x057e;
  32303. t.vhook = 0x028b;
  32304. t.vikatakana = 0x30f8;
  32305. t.viramabengali = 0x09cd;
  32306. t.viramadeva = 0x094d;
  32307. t.viramagujarati = 0x0acd;
  32308. t.visargabengali = 0x0983;
  32309. t.visargadeva = 0x0903;
  32310. t.visargagujarati = 0x0a83;
  32311. t.vmonospace = 0xff56;
  32312. t.voarmenian = 0x0578;
  32313. t.voicediterationhiragana = 0x309e;
  32314. t.voicediterationkatakana = 0x30fe;
  32315. t.voicedmarkkana = 0x309b;
  32316. t.voicedmarkkanahalfwidth = 0xff9e;
  32317. t.vokatakana = 0x30fa;
  32318. t.vparen = 0x24b1;
  32319. t.vtilde = 0x1e7d;
  32320. t.vturned = 0x028c;
  32321. t.vuhiragana = 0x3094;
  32322. t.vukatakana = 0x30f4;
  32323. t.w = 0x0077;
  32324. t.wacute = 0x1e83;
  32325. t.waekorean = 0x3159;
  32326. t.wahiragana = 0x308f;
  32327. t.wakatakana = 0x30ef;
  32328. t.wakatakanahalfwidth = 0xff9c;
  32329. t.wakorean = 0x3158;
  32330. t.wasmallhiragana = 0x308e;
  32331. t.wasmallkatakana = 0x30ee;
  32332. t.wattosquare = 0x3357;
  32333. t.wavedash = 0x301c;
  32334. t.wavyunderscorevertical = 0xfe34;
  32335. t.wawarabic = 0x0648;
  32336. t.wawfinalarabic = 0xfeee;
  32337. t.wawhamzaabovearabic = 0x0624;
  32338. t.wawhamzaabovefinalarabic = 0xfe86;
  32339. t.wbsquare = 0x33dd;
  32340. t.wcircle = 0x24e6;
  32341. t.wcircumflex = 0x0175;
  32342. t.wdieresis = 0x1e85;
  32343. t.wdotaccent = 0x1e87;
  32344. t.wdotbelow = 0x1e89;
  32345. t.wehiragana = 0x3091;
  32346. t.weierstrass = 0x2118;
  32347. t.wekatakana = 0x30f1;
  32348. t.wekorean = 0x315e;
  32349. t.weokorean = 0x315d;
  32350. t.wgrave = 0x1e81;
  32351. t.whitebullet = 0x25e6;
  32352. t.whitecircle = 0x25cb;
  32353. t.whitecircleinverse = 0x25d9;
  32354. t.whitecornerbracketleft = 0x300e;
  32355. t.whitecornerbracketleftvertical = 0xfe43;
  32356. t.whitecornerbracketright = 0x300f;
  32357. t.whitecornerbracketrightvertical = 0xfe44;
  32358. t.whitediamond = 0x25c7;
  32359. t.whitediamondcontainingblacksmalldiamond = 0x25c8;
  32360. t.whitedownpointingsmalltriangle = 0x25bf;
  32361. t.whitedownpointingtriangle = 0x25bd;
  32362. t.whiteleftpointingsmalltriangle = 0x25c3;
  32363. t.whiteleftpointingtriangle = 0x25c1;
  32364. t.whitelenticularbracketleft = 0x3016;
  32365. t.whitelenticularbracketright = 0x3017;
  32366. t.whiterightpointingsmalltriangle = 0x25b9;
  32367. t.whiterightpointingtriangle = 0x25b7;
  32368. t.whitesmallsquare = 0x25ab;
  32369. t.whitesmilingface = 0x263a;
  32370. t.whitesquare = 0x25a1;
  32371. t.whitestar = 0x2606;
  32372. t.whitetelephone = 0x260f;
  32373. t.whitetortoiseshellbracketleft = 0x3018;
  32374. t.whitetortoiseshellbracketright = 0x3019;
  32375. t.whiteuppointingsmalltriangle = 0x25b5;
  32376. t.whiteuppointingtriangle = 0x25b3;
  32377. t.wihiragana = 0x3090;
  32378. t.wikatakana = 0x30f0;
  32379. t.wikorean = 0x315f;
  32380. t.wmonospace = 0xff57;
  32381. t.wohiragana = 0x3092;
  32382. t.wokatakana = 0x30f2;
  32383. t.wokatakanahalfwidth = 0xff66;
  32384. t.won = 0x20a9;
  32385. t.wonmonospace = 0xffe6;
  32386. t.wowaenthai = 0x0e27;
  32387. t.wparen = 0x24b2;
  32388. t.wring = 0x1e98;
  32389. t.wsuperior = 0x02b7;
  32390. t.wturned = 0x028d;
  32391. t.wynn = 0x01bf;
  32392. t.x = 0x0078;
  32393. t.xabovecmb = 0x033d;
  32394. t.xbopomofo = 0x3112;
  32395. t.xcircle = 0x24e7;
  32396. t.xdieresis = 0x1e8d;
  32397. t.xdotaccent = 0x1e8b;
  32398. t.xeharmenian = 0x056d;
  32399. t.xi = 0x03be;
  32400. t.xmonospace = 0xff58;
  32401. t.xparen = 0x24b3;
  32402. t.xsuperior = 0x02e3;
  32403. t.y = 0x0079;
  32404. t.yaadosquare = 0x334e;
  32405. t.yabengali = 0x09af;
  32406. t.yacute = 0x00fd;
  32407. t.yadeva = 0x092f;
  32408. t.yaekorean = 0x3152;
  32409. t.yagujarati = 0x0aaf;
  32410. t.yagurmukhi = 0x0a2f;
  32411. t.yahiragana = 0x3084;
  32412. t.yakatakana = 0x30e4;
  32413. t.yakatakanahalfwidth = 0xff94;
  32414. t.yakorean = 0x3151;
  32415. t.yamakkanthai = 0x0e4e;
  32416. t.yasmallhiragana = 0x3083;
  32417. t.yasmallkatakana = 0x30e3;
  32418. t.yasmallkatakanahalfwidth = 0xff6c;
  32419. t.yatcyrillic = 0x0463;
  32420. t.ycircle = 0x24e8;
  32421. t.ycircumflex = 0x0177;
  32422. t.ydieresis = 0x00ff;
  32423. t.ydotaccent = 0x1e8f;
  32424. t.ydotbelow = 0x1ef5;
  32425. t.yeharabic = 0x064a;
  32426. t.yehbarreearabic = 0x06d2;
  32427. t.yehbarreefinalarabic = 0xfbaf;
  32428. t.yehfinalarabic = 0xfef2;
  32429. t.yehhamzaabovearabic = 0x0626;
  32430. t.yehhamzaabovefinalarabic = 0xfe8a;
  32431. t.yehhamzaaboveinitialarabic = 0xfe8b;
  32432. t.yehhamzaabovemedialarabic = 0xfe8c;
  32433. t.yehinitialarabic = 0xfef3;
  32434. t.yehmedialarabic = 0xfef4;
  32435. t.yehmeeminitialarabic = 0xfcdd;
  32436. t.yehmeemisolatedarabic = 0xfc58;
  32437. t.yehnoonfinalarabic = 0xfc94;
  32438. t.yehthreedotsbelowarabic = 0x06d1;
  32439. t.yekorean = 0x3156;
  32440. t.yen = 0x00a5;
  32441. t.yenmonospace = 0xffe5;
  32442. t.yeokorean = 0x3155;
  32443. t.yeorinhieuhkorean = 0x3186;
  32444. t.yerahbenyomohebrew = 0x05aa;
  32445. t.yerahbenyomolefthebrew = 0x05aa;
  32446. t.yericyrillic = 0x044b;
  32447. t.yerudieresiscyrillic = 0x04f9;
  32448. t.yesieungkorean = 0x3181;
  32449. t.yesieungpansioskorean = 0x3183;
  32450. t.yesieungsioskorean = 0x3182;
  32451. t.yetivhebrew = 0x059a;
  32452. t.ygrave = 0x1ef3;
  32453. t.yhook = 0x01b4;
  32454. t.yhookabove = 0x1ef7;
  32455. t.yiarmenian = 0x0575;
  32456. t.yicyrillic = 0x0457;
  32457. t.yikorean = 0x3162;
  32458. t.yinyang = 0x262f;
  32459. t.yiwnarmenian = 0x0582;
  32460. t.ymonospace = 0xff59;
  32461. t.yod = 0x05d9;
  32462. t.yoddagesh = 0xfb39;
  32463. t.yoddageshhebrew = 0xfb39;
  32464. t.yodhebrew = 0x05d9;
  32465. t.yodyodhebrew = 0x05f2;
  32466. t.yodyodpatahhebrew = 0xfb1f;
  32467. t.yohiragana = 0x3088;
  32468. t.yoikorean = 0x3189;
  32469. t.yokatakana = 0x30e8;
  32470. t.yokatakanahalfwidth = 0xff96;
  32471. t.yokorean = 0x315b;
  32472. t.yosmallhiragana = 0x3087;
  32473. t.yosmallkatakana = 0x30e7;
  32474. t.yosmallkatakanahalfwidth = 0xff6e;
  32475. t.yotgreek = 0x03f3;
  32476. t.yoyaekorean = 0x3188;
  32477. t.yoyakorean = 0x3187;
  32478. t.yoyakthai = 0x0e22;
  32479. t.yoyingthai = 0x0e0d;
  32480. t.yparen = 0x24b4;
  32481. t.ypogegrammeni = 0x037a;
  32482. t.ypogegrammenigreekcmb = 0x0345;
  32483. t.yr = 0x01a6;
  32484. t.yring = 0x1e99;
  32485. t.ysuperior = 0x02b8;
  32486. t.ytilde = 0x1ef9;
  32487. t.yturned = 0x028e;
  32488. t.yuhiragana = 0x3086;
  32489. t.yuikorean = 0x318c;
  32490. t.yukatakana = 0x30e6;
  32491. t.yukatakanahalfwidth = 0xff95;
  32492. t.yukorean = 0x3160;
  32493. t.yusbigcyrillic = 0x046b;
  32494. t.yusbigiotifiedcyrillic = 0x046d;
  32495. t.yuslittlecyrillic = 0x0467;
  32496. t.yuslittleiotifiedcyrillic = 0x0469;
  32497. t.yusmallhiragana = 0x3085;
  32498. t.yusmallkatakana = 0x30e5;
  32499. t.yusmallkatakanahalfwidth = 0xff6d;
  32500. t.yuyekorean = 0x318b;
  32501. t.yuyeokorean = 0x318a;
  32502. t.yyabengali = 0x09df;
  32503. t.yyadeva = 0x095f;
  32504. t.z = 0x007a;
  32505. t.zaarmenian = 0x0566;
  32506. t.zacute = 0x017a;
  32507. t.zadeva = 0x095b;
  32508. t.zagurmukhi = 0x0a5b;
  32509. t.zaharabic = 0x0638;
  32510. t.zahfinalarabic = 0xfec6;
  32511. t.zahinitialarabic = 0xfec7;
  32512. t.zahiragana = 0x3056;
  32513. t.zahmedialarabic = 0xfec8;
  32514. t.zainarabic = 0x0632;
  32515. t.zainfinalarabic = 0xfeb0;
  32516. t.zakatakana = 0x30b6;
  32517. t.zaqefgadolhebrew = 0x0595;
  32518. t.zaqefqatanhebrew = 0x0594;
  32519. t.zarqahebrew = 0x0598;
  32520. t.zayin = 0x05d6;
  32521. t.zayindagesh = 0xfb36;
  32522. t.zayindageshhebrew = 0xfb36;
  32523. t.zayinhebrew = 0x05d6;
  32524. t.zbopomofo = 0x3117;
  32525. t.zcaron = 0x017e;
  32526. t.zcircle = 0x24e9;
  32527. t.zcircumflex = 0x1e91;
  32528. t.zcurl = 0x0291;
  32529. t.zdot = 0x017c;
  32530. t.zdotaccent = 0x017c;
  32531. t.zdotbelow = 0x1e93;
  32532. t.zecyrillic = 0x0437;
  32533. t.zedescendercyrillic = 0x0499;
  32534. t.zedieresiscyrillic = 0x04df;
  32535. t.zehiragana = 0x305c;
  32536. t.zekatakana = 0x30bc;
  32537. t.zero = 0x0030;
  32538. t.zeroarabic = 0x0660;
  32539. t.zerobengali = 0x09e6;
  32540. t.zerodeva = 0x0966;
  32541. t.zerogujarati = 0x0ae6;
  32542. t.zerogurmukhi = 0x0a66;
  32543. t.zerohackarabic = 0x0660;
  32544. t.zeroinferior = 0x2080;
  32545. t.zeromonospace = 0xff10;
  32546. t.zerooldstyle = 0xf730;
  32547. t.zeropersian = 0x06f0;
  32548. t.zerosuperior = 0x2070;
  32549. t.zerothai = 0x0e50;
  32550. t.zerowidthjoiner = 0xfeff;
  32551. t.zerowidthnonjoiner = 0x200c;
  32552. t.zerowidthspace = 0x200b;
  32553. t.zeta = 0x03b6;
  32554. t.zhbopomofo = 0x3113;
  32555. t.zhearmenian = 0x056a;
  32556. t.zhebrevecyrillic = 0x04c2;
  32557. t.zhecyrillic = 0x0436;
  32558. t.zhedescendercyrillic = 0x0497;
  32559. t.zhedieresiscyrillic = 0x04dd;
  32560. t.zihiragana = 0x3058;
  32561. t.zikatakana = 0x30b8;
  32562. t.zinorhebrew = 0x05ae;
  32563. t.zlinebelow = 0x1e95;
  32564. t.zmonospace = 0xff5a;
  32565. t.zohiragana = 0x305e;
  32566. t.zokatakana = 0x30be;
  32567. t.zparen = 0x24b5;
  32568. t.zretroflexhook = 0x0290;
  32569. t.zstroke = 0x01b6;
  32570. t.zuhiragana = 0x305a;
  32571. t.zukatakana = 0x30ba;
  32572. t[".notdef"] = 0x0000;
  32573. t.angbracketleftbig = 0x2329;
  32574. t.angbracketleftBig = 0x2329;
  32575. t.angbracketleftbigg = 0x2329;
  32576. t.angbracketleftBigg = 0x2329;
  32577. t.angbracketrightBig = 0x232a;
  32578. t.angbracketrightbig = 0x232a;
  32579. t.angbracketrightBigg = 0x232a;
  32580. t.angbracketrightbigg = 0x232a;
  32581. t.arrowhookleft = 0x21aa;
  32582. t.arrowhookright = 0x21a9;
  32583. t.arrowlefttophalf = 0x21bc;
  32584. t.arrowleftbothalf = 0x21bd;
  32585. t.arrownortheast = 0x2197;
  32586. t.arrownorthwest = 0x2196;
  32587. t.arrowrighttophalf = 0x21c0;
  32588. t.arrowrightbothalf = 0x21c1;
  32589. t.arrowsoutheast = 0x2198;
  32590. t.arrowsouthwest = 0x2199;
  32591. t.backslashbig = 0x2216;
  32592. t.backslashBig = 0x2216;
  32593. t.backslashBigg = 0x2216;
  32594. t.backslashbigg = 0x2216;
  32595. t.bardbl = 0x2016;
  32596. t.bracehtipdownleft = 0xfe37;
  32597. t.bracehtipdownright = 0xfe37;
  32598. t.bracehtipupleft = 0xfe38;
  32599. t.bracehtipupright = 0xfe38;
  32600. t.braceleftBig = 0x007b;
  32601. t.braceleftbig = 0x007b;
  32602. t.braceleftbigg = 0x007b;
  32603. t.braceleftBigg = 0x007b;
  32604. t.bracerightBig = 0x007d;
  32605. t.bracerightbig = 0x007d;
  32606. t.bracerightbigg = 0x007d;
  32607. t.bracerightBigg = 0x007d;
  32608. t.bracketleftbig = 0x005b;
  32609. t.bracketleftBig = 0x005b;
  32610. t.bracketleftbigg = 0x005b;
  32611. t.bracketleftBigg = 0x005b;
  32612. t.bracketrightBig = 0x005d;
  32613. t.bracketrightbig = 0x005d;
  32614. t.bracketrightbigg = 0x005d;
  32615. t.bracketrightBigg = 0x005d;
  32616. t.ceilingleftbig = 0x2308;
  32617. t.ceilingleftBig = 0x2308;
  32618. t.ceilingleftBigg = 0x2308;
  32619. t.ceilingleftbigg = 0x2308;
  32620. t.ceilingrightbig = 0x2309;
  32621. t.ceilingrightBig = 0x2309;
  32622. t.ceilingrightbigg = 0x2309;
  32623. t.ceilingrightBigg = 0x2309;
  32624. t.circledotdisplay = 0x2299;
  32625. t.circledottext = 0x2299;
  32626. t.circlemultiplydisplay = 0x2297;
  32627. t.circlemultiplytext = 0x2297;
  32628. t.circleplusdisplay = 0x2295;
  32629. t.circleplustext = 0x2295;
  32630. t.contintegraldisplay = 0x222e;
  32631. t.contintegraltext = 0x222e;
  32632. t.coproductdisplay = 0x2210;
  32633. t.coproducttext = 0x2210;
  32634. t.floorleftBig = 0x230a;
  32635. t.floorleftbig = 0x230a;
  32636. t.floorleftbigg = 0x230a;
  32637. t.floorleftBigg = 0x230a;
  32638. t.floorrightbig = 0x230b;
  32639. t.floorrightBig = 0x230b;
  32640. t.floorrightBigg = 0x230b;
  32641. t.floorrightbigg = 0x230b;
  32642. t.hatwide = 0x0302;
  32643. t.hatwider = 0x0302;
  32644. t.hatwidest = 0x0302;
  32645. t.intercal = 0x1d40;
  32646. t.integraldisplay = 0x222b;
  32647. t.integraltext = 0x222b;
  32648. t.intersectiondisplay = 0x22c2;
  32649. t.intersectiontext = 0x22c2;
  32650. t.logicalanddisplay = 0x2227;
  32651. t.logicalandtext = 0x2227;
  32652. t.logicalordisplay = 0x2228;
  32653. t.logicalortext = 0x2228;
  32654. t.parenleftBig = 0x0028;
  32655. t.parenleftbig = 0x0028;
  32656. t.parenleftBigg = 0x0028;
  32657. t.parenleftbigg = 0x0028;
  32658. t.parenrightBig = 0x0029;
  32659. t.parenrightbig = 0x0029;
  32660. t.parenrightBigg = 0x0029;
  32661. t.parenrightbigg = 0x0029;
  32662. t.prime = 0x2032;
  32663. t.productdisplay = 0x220f;
  32664. t.producttext = 0x220f;
  32665. t.radicalbig = 0x221a;
  32666. t.radicalBig = 0x221a;
  32667. t.radicalBigg = 0x221a;
  32668. t.radicalbigg = 0x221a;
  32669. t.radicalbt = 0x221a;
  32670. t.radicaltp = 0x221a;
  32671. t.radicalvertex = 0x221a;
  32672. t.slashbig = 0x002f;
  32673. t.slashBig = 0x002f;
  32674. t.slashBigg = 0x002f;
  32675. t.slashbigg = 0x002f;
  32676. t.summationdisplay = 0x2211;
  32677. t.summationtext = 0x2211;
  32678. t.tildewide = 0x02dc;
  32679. t.tildewider = 0x02dc;
  32680. t.tildewidest = 0x02dc;
  32681. t.uniondisplay = 0x22c3;
  32682. t.unionmultidisplay = 0x228e;
  32683. t.unionmultitext = 0x228e;
  32684. t.unionsqdisplay = 0x2294;
  32685. t.unionsqtext = 0x2294;
  32686. t.uniontext = 0x22c3;
  32687. t.vextenddouble = 0x2225;
  32688. t.vextendsingle = 0x2223;
  32689. });
  32690. exports.getGlyphsUnicode = getGlyphsUnicode;
  32691. const getDingbatsGlyphsUnicode = (0, _core_utils.getLookupTableFactory)(function (t) {
  32692. t.space = 0x0020;
  32693. t.a1 = 0x2701;
  32694. t.a2 = 0x2702;
  32695. t.a202 = 0x2703;
  32696. t.a3 = 0x2704;
  32697. t.a4 = 0x260e;
  32698. t.a5 = 0x2706;
  32699. t.a119 = 0x2707;
  32700. t.a118 = 0x2708;
  32701. t.a117 = 0x2709;
  32702. t.a11 = 0x261b;
  32703. t.a12 = 0x261e;
  32704. t.a13 = 0x270c;
  32705. t.a14 = 0x270d;
  32706. t.a15 = 0x270e;
  32707. t.a16 = 0x270f;
  32708. t.a105 = 0x2710;
  32709. t.a17 = 0x2711;
  32710. t.a18 = 0x2712;
  32711. t.a19 = 0x2713;
  32712. t.a20 = 0x2714;
  32713. t.a21 = 0x2715;
  32714. t.a22 = 0x2716;
  32715. t.a23 = 0x2717;
  32716. t.a24 = 0x2718;
  32717. t.a25 = 0x2719;
  32718. t.a26 = 0x271a;
  32719. t.a27 = 0x271b;
  32720. t.a28 = 0x271c;
  32721. t.a6 = 0x271d;
  32722. t.a7 = 0x271e;
  32723. t.a8 = 0x271f;
  32724. t.a9 = 0x2720;
  32725. t.a10 = 0x2721;
  32726. t.a29 = 0x2722;
  32727. t.a30 = 0x2723;
  32728. t.a31 = 0x2724;
  32729. t.a32 = 0x2725;
  32730. t.a33 = 0x2726;
  32731. t.a34 = 0x2727;
  32732. t.a35 = 0x2605;
  32733. t.a36 = 0x2729;
  32734. t.a37 = 0x272a;
  32735. t.a38 = 0x272b;
  32736. t.a39 = 0x272c;
  32737. t.a40 = 0x272d;
  32738. t.a41 = 0x272e;
  32739. t.a42 = 0x272f;
  32740. t.a43 = 0x2730;
  32741. t.a44 = 0x2731;
  32742. t.a45 = 0x2732;
  32743. t.a46 = 0x2733;
  32744. t.a47 = 0x2734;
  32745. t.a48 = 0x2735;
  32746. t.a49 = 0x2736;
  32747. t.a50 = 0x2737;
  32748. t.a51 = 0x2738;
  32749. t.a52 = 0x2739;
  32750. t.a53 = 0x273a;
  32751. t.a54 = 0x273b;
  32752. t.a55 = 0x273c;
  32753. t.a56 = 0x273d;
  32754. t.a57 = 0x273e;
  32755. t.a58 = 0x273f;
  32756. t.a59 = 0x2740;
  32757. t.a60 = 0x2741;
  32758. t.a61 = 0x2742;
  32759. t.a62 = 0x2743;
  32760. t.a63 = 0x2744;
  32761. t.a64 = 0x2745;
  32762. t.a65 = 0x2746;
  32763. t.a66 = 0x2747;
  32764. t.a67 = 0x2748;
  32765. t.a68 = 0x2749;
  32766. t.a69 = 0x274a;
  32767. t.a70 = 0x274b;
  32768. t.a71 = 0x25cf;
  32769. t.a72 = 0x274d;
  32770. t.a73 = 0x25a0;
  32771. t.a74 = 0x274f;
  32772. t.a203 = 0x2750;
  32773. t.a75 = 0x2751;
  32774. t.a204 = 0x2752;
  32775. t.a76 = 0x25b2;
  32776. t.a77 = 0x25bc;
  32777. t.a78 = 0x25c6;
  32778. t.a79 = 0x2756;
  32779. t.a81 = 0x25d7;
  32780. t.a82 = 0x2758;
  32781. t.a83 = 0x2759;
  32782. t.a84 = 0x275a;
  32783. t.a97 = 0x275b;
  32784. t.a98 = 0x275c;
  32785. t.a99 = 0x275d;
  32786. t.a100 = 0x275e;
  32787. t.a101 = 0x2761;
  32788. t.a102 = 0x2762;
  32789. t.a103 = 0x2763;
  32790. t.a104 = 0x2764;
  32791. t.a106 = 0x2765;
  32792. t.a107 = 0x2766;
  32793. t.a108 = 0x2767;
  32794. t.a112 = 0x2663;
  32795. t.a111 = 0x2666;
  32796. t.a110 = 0x2665;
  32797. t.a109 = 0x2660;
  32798. t.a120 = 0x2460;
  32799. t.a121 = 0x2461;
  32800. t.a122 = 0x2462;
  32801. t.a123 = 0x2463;
  32802. t.a124 = 0x2464;
  32803. t.a125 = 0x2465;
  32804. t.a126 = 0x2466;
  32805. t.a127 = 0x2467;
  32806. t.a128 = 0x2468;
  32807. t.a129 = 0x2469;
  32808. t.a130 = 0x2776;
  32809. t.a131 = 0x2777;
  32810. t.a132 = 0x2778;
  32811. t.a133 = 0x2779;
  32812. t.a134 = 0x277a;
  32813. t.a135 = 0x277b;
  32814. t.a136 = 0x277c;
  32815. t.a137 = 0x277d;
  32816. t.a138 = 0x277e;
  32817. t.a139 = 0x277f;
  32818. t.a140 = 0x2780;
  32819. t.a141 = 0x2781;
  32820. t.a142 = 0x2782;
  32821. t.a143 = 0x2783;
  32822. t.a144 = 0x2784;
  32823. t.a145 = 0x2785;
  32824. t.a146 = 0x2786;
  32825. t.a147 = 0x2787;
  32826. t.a148 = 0x2788;
  32827. t.a149 = 0x2789;
  32828. t.a150 = 0x278a;
  32829. t.a151 = 0x278b;
  32830. t.a152 = 0x278c;
  32831. t.a153 = 0x278d;
  32832. t.a154 = 0x278e;
  32833. t.a155 = 0x278f;
  32834. t.a156 = 0x2790;
  32835. t.a157 = 0x2791;
  32836. t.a158 = 0x2792;
  32837. t.a159 = 0x2793;
  32838. t.a160 = 0x2794;
  32839. t.a161 = 0x2192;
  32840. t.a163 = 0x2194;
  32841. t.a164 = 0x2195;
  32842. t.a196 = 0x2798;
  32843. t.a165 = 0x2799;
  32844. t.a192 = 0x279a;
  32845. t.a166 = 0x279b;
  32846. t.a167 = 0x279c;
  32847. t.a168 = 0x279d;
  32848. t.a169 = 0x279e;
  32849. t.a170 = 0x279f;
  32850. t.a171 = 0x27a0;
  32851. t.a172 = 0x27a1;
  32852. t.a173 = 0x27a2;
  32853. t.a162 = 0x27a3;
  32854. t.a174 = 0x27a4;
  32855. t.a175 = 0x27a5;
  32856. t.a176 = 0x27a6;
  32857. t.a177 = 0x27a7;
  32858. t.a178 = 0x27a8;
  32859. t.a179 = 0x27a9;
  32860. t.a193 = 0x27aa;
  32861. t.a180 = 0x27ab;
  32862. t.a199 = 0x27ac;
  32863. t.a181 = 0x27ad;
  32864. t.a200 = 0x27ae;
  32865. t.a182 = 0x27af;
  32866. t.a201 = 0x27b1;
  32867. t.a183 = 0x27b2;
  32868. t.a184 = 0x27b3;
  32869. t.a197 = 0x27b4;
  32870. t.a185 = 0x27b5;
  32871. t.a194 = 0x27b6;
  32872. t.a198 = 0x27b7;
  32873. t.a186 = 0x27b8;
  32874. t.a195 = 0x27b9;
  32875. t.a187 = 0x27ba;
  32876. t.a188 = 0x27bb;
  32877. t.a189 = 0x27bc;
  32878. t.a190 = 0x27bd;
  32879. t.a191 = 0x27be;
  32880. t.a89 = 0x2768;
  32881. t.a90 = 0x2769;
  32882. t.a93 = 0x276a;
  32883. t.a94 = 0x276b;
  32884. t.a91 = 0x276c;
  32885. t.a92 = 0x276d;
  32886. t.a205 = 0x276e;
  32887. t.a85 = 0x276f;
  32888. t.a206 = 0x2770;
  32889. t.a86 = 0x2771;
  32890. t.a87 = 0x2772;
  32891. t.a88 = 0x2773;
  32892. t.a95 = 0x2774;
  32893. t.a96 = 0x2775;
  32894. t[".notdef"] = 0x0000;
  32895. });
  32896. exports.getDingbatsGlyphsUnicode = getDingbatsGlyphsUnicode;
  32897. /***/ }),
  32898. /* 191 */
  32899. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  32900. Object.defineProperty(exports, "__esModule", ({
  32901. value: true
  32902. }));
  32903. exports.clearUnicodeCaches = clearUnicodeCaches;
  32904. exports.getCharUnicodeCategory = getCharUnicodeCategory;
  32905. exports.getUnicodeForGlyph = getUnicodeForGlyph;
  32906. exports.getUnicodeRangeFor = getUnicodeRangeFor;
  32907. exports.mapSpecialUnicodeValues = mapSpecialUnicodeValues;
  32908. var _core_utils = __w_pdfjs_require__(150);
  32909. const getSpecialPUASymbols = (0, _core_utils.getLookupTableFactory)(function (t) {
  32910. t[63721] = 0x00a9;
  32911. t[63193] = 0x00a9;
  32912. t[63720] = 0x00ae;
  32913. t[63194] = 0x00ae;
  32914. t[63722] = 0x2122;
  32915. t[63195] = 0x2122;
  32916. t[63729] = 0x23a7;
  32917. t[63730] = 0x23a8;
  32918. t[63731] = 0x23a9;
  32919. t[63740] = 0x23ab;
  32920. t[63741] = 0x23ac;
  32921. t[63742] = 0x23ad;
  32922. t[63726] = 0x23a1;
  32923. t[63727] = 0x23a2;
  32924. t[63728] = 0x23a3;
  32925. t[63737] = 0x23a4;
  32926. t[63738] = 0x23a5;
  32927. t[63739] = 0x23a6;
  32928. t[63723] = 0x239b;
  32929. t[63724] = 0x239c;
  32930. t[63725] = 0x239d;
  32931. t[63734] = 0x239e;
  32932. t[63735] = 0x239f;
  32933. t[63736] = 0x23a0;
  32934. });
  32935. function mapSpecialUnicodeValues(code) {
  32936. if (code >= 0xfff0 && code <= 0xffff) {
  32937. return 0;
  32938. } else if (code >= 0xf600 && code <= 0xf8ff) {
  32939. return getSpecialPUASymbols()[code] || code;
  32940. } else if (code === 0x00ad) {
  32941. return 0x002d;
  32942. }
  32943. return code;
  32944. }
  32945. function getUnicodeForGlyph(name, glyphsUnicodeMap) {
  32946. let unicode = glyphsUnicodeMap[name];
  32947. if (unicode !== undefined) {
  32948. return unicode;
  32949. }
  32950. if (!name) {
  32951. return -1;
  32952. }
  32953. if (name[0] === "u") {
  32954. const nameLen = name.length;
  32955. let hexStr;
  32956. if (nameLen === 7 && name[1] === "n" && name[2] === "i") {
  32957. hexStr = name.substring(3);
  32958. } else if (nameLen >= 5 && nameLen <= 7) {
  32959. hexStr = name.substring(1);
  32960. } else {
  32961. return -1;
  32962. }
  32963. if (hexStr === hexStr.toUpperCase()) {
  32964. unicode = parseInt(hexStr, 16);
  32965. if (unicode >= 0) {
  32966. return unicode;
  32967. }
  32968. }
  32969. }
  32970. return -1;
  32971. }
  32972. 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]];
  32973. function getUnicodeRangeFor(value) {
  32974. let lastPosition = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : -1;
  32975. if (lastPosition !== -1) {
  32976. const range = UnicodeRanges[lastPosition];
  32977. for (let i = 0, ii = range.length; i < ii; i += 2) {
  32978. if (value >= range[i] && value <= range[i + 1]) {
  32979. return lastPosition;
  32980. }
  32981. }
  32982. }
  32983. for (let i = 0, ii = UnicodeRanges.length; i < ii; i++) {
  32984. const range = UnicodeRanges[i];
  32985. for (let j = 0, jj = range.length; j < jj; j += 2) {
  32986. if (value >= range[j] && value <= range[j + 1]) {
  32987. return i;
  32988. }
  32989. }
  32990. }
  32991. return -1;
  32992. }
  32993. const SpecialCharRegExp = new RegExp("^(\\s)|(\\p{Mn})|(\\p{Cf})$", "u");
  32994. const CategoryCache = new Map();
  32995. function getCharUnicodeCategory(char) {
  32996. const cachedCategory = CategoryCache.get(char);
  32997. if (cachedCategory) {
  32998. return cachedCategory;
  32999. }
  33000. const groups = char.match(SpecialCharRegExp);
  33001. const category = {
  33002. isWhitespace: !!groups?.[1],
  33003. isZeroWidthDiacritic: !!groups?.[2],
  33004. isInvisibleFormatMark: !!groups?.[3]
  33005. };
  33006. CategoryCache.set(char, category);
  33007. return category;
  33008. }
  33009. function clearUnicodeCaches() {
  33010. CategoryCache.clear();
  33011. }
  33012. /***/ }),
  33013. /* 192 */
  33014. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  33015. Object.defineProperty(exports, "__esModule", ({
  33016. value: true
  33017. }));
  33018. exports.getSerifFonts = exports.getNonStdFontMap = exports.getGlyphMapForStandardFonts = exports.getFontNameToFileMap = void 0;
  33019. exports.getStandardFontName = getStandardFontName;
  33020. exports.getSymbolsFonts = exports.getSupplementalGlyphMapForCalibri = exports.getSupplementalGlyphMapForArialBlack = exports.getStdFontMap = void 0;
  33021. exports.isKnownFontName = isKnownFontName;
  33022. var _core_utils = __w_pdfjs_require__(150);
  33023. var _fonts_utils = __w_pdfjs_require__(189);
  33024. const getStdFontMap = (0, _core_utils.getLookupTableFactory)(function (t) {
  33025. t["Times-Roman"] = "Times-Roman";
  33026. t.Helvetica = "Helvetica";
  33027. t.Courier = "Courier";
  33028. t.Symbol = "Symbol";
  33029. t["Times-Bold"] = "Times-Bold";
  33030. t["Helvetica-Bold"] = "Helvetica-Bold";
  33031. t["Courier-Bold"] = "Courier-Bold";
  33032. t.ZapfDingbats = "ZapfDingbats";
  33033. t["Times-Italic"] = "Times-Italic";
  33034. t["Helvetica-Oblique"] = "Helvetica-Oblique";
  33035. t["Courier-Oblique"] = "Courier-Oblique";
  33036. t["Times-BoldItalic"] = "Times-BoldItalic";
  33037. t["Helvetica-BoldOblique"] = "Helvetica-BoldOblique";
  33038. t["Courier-BoldOblique"] = "Courier-BoldOblique";
  33039. t.ArialNarrow = "Helvetica";
  33040. t["ArialNarrow-Bold"] = "Helvetica-Bold";
  33041. t["ArialNarrow-BoldItalic"] = "Helvetica-BoldOblique";
  33042. t["ArialNarrow-Italic"] = "Helvetica-Oblique";
  33043. t.ArialBlack = "Helvetica";
  33044. t["ArialBlack-Bold"] = "Helvetica-Bold";
  33045. t["ArialBlack-BoldItalic"] = "Helvetica-BoldOblique";
  33046. t["ArialBlack-Italic"] = "Helvetica-Oblique";
  33047. t["Arial-Black"] = "Helvetica";
  33048. t["Arial-Black-Bold"] = "Helvetica-Bold";
  33049. t["Arial-Black-BoldItalic"] = "Helvetica-BoldOblique";
  33050. t["Arial-Black-Italic"] = "Helvetica-Oblique";
  33051. t.Arial = "Helvetica";
  33052. t["Arial-Bold"] = "Helvetica-Bold";
  33053. t["Arial-BoldItalic"] = "Helvetica-BoldOblique";
  33054. t["Arial-Italic"] = "Helvetica-Oblique";
  33055. t.ArialMT = "Helvetica";
  33056. t["Arial-BoldItalicMT"] = "Helvetica-BoldOblique";
  33057. t["Arial-BoldMT"] = "Helvetica-Bold";
  33058. t["Arial-ItalicMT"] = "Helvetica-Oblique";
  33059. t["Arial-BoldItalicMT-BoldItalic"] = "Helvetica-BoldOblique";
  33060. t["Arial-BoldMT-Bold"] = "Helvetica-Bold";
  33061. t["Arial-ItalicMT-Italic"] = "Helvetica-Oblique";
  33062. t.ArialUnicodeMS = "Helvetica";
  33063. t["ArialUnicodeMS-Bold"] = "Helvetica-Bold";
  33064. t["ArialUnicodeMS-BoldItalic"] = "Helvetica-BoldOblique";
  33065. t["ArialUnicodeMS-Italic"] = "Helvetica-Oblique";
  33066. t["Courier-BoldItalic"] = "Courier-BoldOblique";
  33067. t["Courier-Italic"] = "Courier-Oblique";
  33068. t.CourierNew = "Courier";
  33069. t["CourierNew-Bold"] = "Courier-Bold";
  33070. t["CourierNew-BoldItalic"] = "Courier-BoldOblique";
  33071. t["CourierNew-Italic"] = "Courier-Oblique";
  33072. t["CourierNewPS-BoldItalicMT"] = "Courier-BoldOblique";
  33073. t["CourierNewPS-BoldMT"] = "Courier-Bold";
  33074. t["CourierNewPS-ItalicMT"] = "Courier-Oblique";
  33075. t.CourierNewPSMT = "Courier";
  33076. t["Helvetica-BoldItalic"] = "Helvetica-BoldOblique";
  33077. t["Helvetica-Italic"] = "Helvetica-Oblique";
  33078. t["Symbol-Bold"] = "Symbol";
  33079. t["Symbol-BoldItalic"] = "Symbol";
  33080. t["Symbol-Italic"] = "Symbol";
  33081. t.TimesNewRoman = "Times-Roman";
  33082. t["TimesNewRoman-Bold"] = "Times-Bold";
  33083. t["TimesNewRoman-BoldItalic"] = "Times-BoldItalic";
  33084. t["TimesNewRoman-Italic"] = "Times-Italic";
  33085. t.TimesNewRomanPS = "Times-Roman";
  33086. t["TimesNewRomanPS-Bold"] = "Times-Bold";
  33087. t["TimesNewRomanPS-BoldItalic"] = "Times-BoldItalic";
  33088. t["TimesNewRomanPS-BoldItalicMT"] = "Times-BoldItalic";
  33089. t["TimesNewRomanPS-BoldMT"] = "Times-Bold";
  33090. t["TimesNewRomanPS-Italic"] = "Times-Italic";
  33091. t["TimesNewRomanPS-ItalicMT"] = "Times-Italic";
  33092. t.TimesNewRomanPSMT = "Times-Roman";
  33093. t["TimesNewRomanPSMT-Bold"] = "Times-Bold";
  33094. t["TimesNewRomanPSMT-BoldItalic"] = "Times-BoldItalic";
  33095. t["TimesNewRomanPSMT-Italic"] = "Times-Italic";
  33096. });
  33097. exports.getStdFontMap = getStdFontMap;
  33098. const getFontNameToFileMap = (0, _core_utils.getLookupTableFactory)(function (t) {
  33099. t.Courier = "FoxitFixed.pfb";
  33100. t["Courier-Bold"] = "FoxitFixedBold.pfb";
  33101. t["Courier-BoldOblique"] = "FoxitFixedBoldItalic.pfb";
  33102. t["Courier-Oblique"] = "FoxitFixedItalic.pfb";
  33103. t.Helvetica = "LiberationSans-Regular.ttf";
  33104. t["Helvetica-Bold"] = "LiberationSans-Bold.ttf";
  33105. t["Helvetica-BoldOblique"] = "LiberationSans-BoldItalic.ttf";
  33106. t["Helvetica-Oblique"] = "LiberationSans-Italic.ttf";
  33107. t["Times-Roman"] = "FoxitSerif.pfb";
  33108. t["Times-Bold"] = "FoxitSerifBold.pfb";
  33109. t["Times-BoldItalic"] = "FoxitSerifBoldItalic.pfb";
  33110. t["Times-Italic"] = "FoxitSerifItalic.pfb";
  33111. t.Symbol = "FoxitSymbol.pfb";
  33112. t.ZapfDingbats = "FoxitDingbats.pfb";
  33113. t["LiberationSans-Regular"] = "LiberationSans-Regular.ttf";
  33114. t["LiberationSans-Bold"] = "LiberationSans-Bold.ttf";
  33115. t["LiberationSans-Italic"] = "LiberationSans-Italic.ttf";
  33116. t["LiberationSans-BoldItalic"] = "LiberationSans-BoldItalic.ttf";
  33117. });
  33118. exports.getFontNameToFileMap = getFontNameToFileMap;
  33119. const getNonStdFontMap = (0, _core_utils.getLookupTableFactory)(function (t) {
  33120. t.Calibri = "Helvetica";
  33121. t["Calibri-Bold"] = "Helvetica-Bold";
  33122. t["Calibri-BoldItalic"] = "Helvetica-BoldOblique";
  33123. t["Calibri-Italic"] = "Helvetica-Oblique";
  33124. t.CenturyGothic = "Helvetica";
  33125. t["CenturyGothic-Bold"] = "Helvetica-Bold";
  33126. t["CenturyGothic-BoldItalic"] = "Helvetica-BoldOblique";
  33127. t["CenturyGothic-Italic"] = "Helvetica-Oblique";
  33128. t.ComicSansMS = "Comic Sans MS";
  33129. t["ComicSansMS-Bold"] = "Comic Sans MS-Bold";
  33130. t["ComicSansMS-BoldItalic"] = "Comic Sans MS-BoldItalic";
  33131. t["ComicSansMS-Italic"] = "Comic Sans MS-Italic";
  33132. t.Impact = "Helvetica";
  33133. t["ItcSymbol-Bold"] = "Helvetica-Bold";
  33134. t["ItcSymbol-BoldItalic"] = "Helvetica-BoldOblique";
  33135. t["ItcSymbol-Book"] = "Helvetica";
  33136. t["ItcSymbol-BookItalic"] = "Helvetica-Oblique";
  33137. t["ItcSymbol-Medium"] = "Helvetica";
  33138. t["ItcSymbol-MediumItalic"] = "Helvetica-Oblique";
  33139. t.LucidaConsole = "Courier";
  33140. t["LucidaConsole-Bold"] = "Courier-Bold";
  33141. t["LucidaConsole-BoldItalic"] = "Courier-BoldOblique";
  33142. t["LucidaConsole-Italic"] = "Courier-Oblique";
  33143. t["LucidaSans-Demi"] = "Helvetica-Bold";
  33144. t["MS-Gothic"] = "MS Gothic";
  33145. t["MS-Gothic-Bold"] = "MS Gothic-Bold";
  33146. t["MS-Gothic-BoldItalic"] = "MS Gothic-BoldItalic";
  33147. t["MS-Gothic-Italic"] = "MS Gothic-Italic";
  33148. t["MS-Mincho"] = "MS Mincho";
  33149. t["MS-Mincho-Bold"] = "MS Mincho-Bold";
  33150. t["MS-Mincho-BoldItalic"] = "MS Mincho-BoldItalic";
  33151. t["MS-Mincho-Italic"] = "MS Mincho-Italic";
  33152. t["MS-PGothic"] = "MS PGothic";
  33153. t["MS-PGothic-Bold"] = "MS PGothic-Bold";
  33154. t["MS-PGothic-BoldItalic"] = "MS PGothic-BoldItalic";
  33155. t["MS-PGothic-Italic"] = "MS PGothic-Italic";
  33156. t["MS-PMincho"] = "MS PMincho";
  33157. t["MS-PMincho-Bold"] = "MS PMincho-Bold";
  33158. t["MS-PMincho-BoldItalic"] = "MS PMincho-BoldItalic";
  33159. t["MS-PMincho-Italic"] = "MS PMincho-Italic";
  33160. t.NuptialScript = "Times-Italic";
  33161. t.SegoeUISymbol = "Helvetica";
  33162. });
  33163. exports.getNonStdFontMap = getNonStdFontMap;
  33164. const getSerifFonts = (0, _core_utils.getLookupTableFactory)(function (t) {
  33165. t["Adobe Jenson"] = true;
  33166. t["Adobe Text"] = true;
  33167. t.Albertus = true;
  33168. t.Aldus = true;
  33169. t.Alexandria = true;
  33170. t.Algerian = true;
  33171. t["American Typewriter"] = true;
  33172. t.Antiqua = true;
  33173. t.Apex = true;
  33174. t.Arno = true;
  33175. t.Aster = true;
  33176. t.Aurora = true;
  33177. t.Baskerville = true;
  33178. t.Bell = true;
  33179. t.Bembo = true;
  33180. t["Bembo Schoolbook"] = true;
  33181. t.Benguiat = true;
  33182. t["Berkeley Old Style"] = true;
  33183. t["Bernhard Modern"] = true;
  33184. t["Berthold City"] = true;
  33185. t.Bodoni = true;
  33186. t["Bauer Bodoni"] = true;
  33187. t["Book Antiqua"] = true;
  33188. t.Bookman = true;
  33189. t["Bordeaux Roman"] = true;
  33190. t["Californian FB"] = true;
  33191. t.Calisto = true;
  33192. t.Calvert = true;
  33193. t.Capitals = true;
  33194. t.Cambria = true;
  33195. t.Cartier = true;
  33196. t.Caslon = true;
  33197. t.Catull = true;
  33198. t.Centaur = true;
  33199. t["Century Old Style"] = true;
  33200. t["Century Schoolbook"] = true;
  33201. t.Chaparral = true;
  33202. t["Charis SIL"] = true;
  33203. t.Cheltenham = true;
  33204. t["Cholla Slab"] = true;
  33205. t.Clarendon = true;
  33206. t.Clearface = true;
  33207. t.Cochin = true;
  33208. t.Colonna = true;
  33209. t["Computer Modern"] = true;
  33210. t["Concrete Roman"] = true;
  33211. t.Constantia = true;
  33212. t["Cooper Black"] = true;
  33213. t.Corona = true;
  33214. t.Ecotype = true;
  33215. t.Egyptienne = true;
  33216. t.Elephant = true;
  33217. t.Excelsior = true;
  33218. t.Fairfield = true;
  33219. t["FF Scala"] = true;
  33220. t.Folkard = true;
  33221. t.Footlight = true;
  33222. t.FreeSerif = true;
  33223. t["Friz Quadrata"] = true;
  33224. t.Garamond = true;
  33225. t.Gentium = true;
  33226. t.Georgia = true;
  33227. t.Gloucester = true;
  33228. t["Goudy Old Style"] = true;
  33229. t["Goudy Schoolbook"] = true;
  33230. t["Goudy Pro Font"] = true;
  33231. t.Granjon = true;
  33232. t["Guardian Egyptian"] = true;
  33233. t.Heather = true;
  33234. t.Hercules = true;
  33235. t["High Tower Text"] = true;
  33236. t.Hiroshige = true;
  33237. t["Hoefler Text"] = true;
  33238. t["Humana Serif"] = true;
  33239. t.Imprint = true;
  33240. t["Ionic No. 5"] = true;
  33241. t.Janson = true;
  33242. t.Joanna = true;
  33243. t.Korinna = true;
  33244. t.Lexicon = true;
  33245. t.LiberationSerif = true;
  33246. t["Liberation Serif"] = true;
  33247. t["Linux Libertine"] = true;
  33248. t.Literaturnaya = true;
  33249. t.Lucida = true;
  33250. t["Lucida Bright"] = true;
  33251. t.Melior = true;
  33252. t.Memphis = true;
  33253. t.Miller = true;
  33254. t.Minion = true;
  33255. t.Modern = true;
  33256. t["Mona Lisa"] = true;
  33257. t["Mrs Eaves"] = true;
  33258. t["MS Serif"] = true;
  33259. t["Museo Slab"] = true;
  33260. t["New York"] = true;
  33261. t["Nimbus Roman"] = true;
  33262. t["NPS Rawlinson Roadway"] = true;
  33263. t.NuptialScript = true;
  33264. t.Palatino = true;
  33265. t.Perpetua = true;
  33266. t.Plantin = true;
  33267. t["Plantin Schoolbook"] = true;
  33268. t.Playbill = true;
  33269. t["Poor Richard"] = true;
  33270. t["Rawlinson Roadway"] = true;
  33271. t.Renault = true;
  33272. t.Requiem = true;
  33273. t.Rockwell = true;
  33274. t.Roman = true;
  33275. t["Rotis Serif"] = true;
  33276. t.Sabon = true;
  33277. t.Scala = true;
  33278. t.Seagull = true;
  33279. t.Sistina = true;
  33280. t.Souvenir = true;
  33281. t.STIX = true;
  33282. t["Stone Informal"] = true;
  33283. t["Stone Serif"] = true;
  33284. t.Sylfaen = true;
  33285. t.Times = true;
  33286. t.Trajan = true;
  33287. t["Trinité"] = true;
  33288. t["Trump Mediaeval"] = true;
  33289. t.Utopia = true;
  33290. t["Vale Type"] = true;
  33291. t["Bitstream Vera"] = true;
  33292. t["Vera Serif"] = true;
  33293. t.Versailles = true;
  33294. t.Wanted = true;
  33295. t.Weiss = true;
  33296. t["Wide Latin"] = true;
  33297. t.Windsor = true;
  33298. t.XITS = true;
  33299. });
  33300. exports.getSerifFonts = getSerifFonts;
  33301. const getSymbolsFonts = (0, _core_utils.getLookupTableFactory)(function (t) {
  33302. t.Dingbats = true;
  33303. t.Symbol = true;
  33304. t.ZapfDingbats = true;
  33305. t.Wingdings = true;
  33306. t["Wingdings-Bold"] = true;
  33307. t["Wingdings-Regular"] = true;
  33308. });
  33309. exports.getSymbolsFonts = getSymbolsFonts;
  33310. const getGlyphMapForStandardFonts = (0, _core_utils.getLookupTableFactory)(function (t) {
  33311. t[2] = 10;
  33312. t[3] = 32;
  33313. t[4] = 33;
  33314. t[5] = 34;
  33315. t[6] = 35;
  33316. t[7] = 36;
  33317. t[8] = 37;
  33318. t[9] = 38;
  33319. t[10] = 39;
  33320. t[11] = 40;
  33321. t[12] = 41;
  33322. t[13] = 42;
  33323. t[14] = 43;
  33324. t[15] = 44;
  33325. t[16] = 45;
  33326. t[17] = 46;
  33327. t[18] = 47;
  33328. t[19] = 48;
  33329. t[20] = 49;
  33330. t[21] = 50;
  33331. t[22] = 51;
  33332. t[23] = 52;
  33333. t[24] = 53;
  33334. t[25] = 54;
  33335. t[26] = 55;
  33336. t[27] = 56;
  33337. t[28] = 57;
  33338. t[29] = 58;
  33339. t[30] = 894;
  33340. t[31] = 60;
  33341. t[32] = 61;
  33342. t[33] = 62;
  33343. t[34] = 63;
  33344. t[35] = 64;
  33345. t[36] = 65;
  33346. t[37] = 66;
  33347. t[38] = 67;
  33348. t[39] = 68;
  33349. t[40] = 69;
  33350. t[41] = 70;
  33351. t[42] = 71;
  33352. t[43] = 72;
  33353. t[44] = 73;
  33354. t[45] = 74;
  33355. t[46] = 75;
  33356. t[47] = 76;
  33357. t[48] = 77;
  33358. t[49] = 78;
  33359. t[50] = 79;
  33360. t[51] = 80;
  33361. t[52] = 81;
  33362. t[53] = 82;
  33363. t[54] = 83;
  33364. t[55] = 84;
  33365. t[56] = 85;
  33366. t[57] = 86;
  33367. t[58] = 87;
  33368. t[59] = 88;
  33369. t[60] = 89;
  33370. t[61] = 90;
  33371. t[62] = 91;
  33372. t[63] = 92;
  33373. t[64] = 93;
  33374. t[65] = 94;
  33375. t[66] = 95;
  33376. t[67] = 96;
  33377. t[68] = 97;
  33378. t[69] = 98;
  33379. t[70] = 99;
  33380. t[71] = 100;
  33381. t[72] = 101;
  33382. t[73] = 102;
  33383. t[74] = 103;
  33384. t[75] = 104;
  33385. t[76] = 105;
  33386. t[77] = 106;
  33387. t[78] = 107;
  33388. t[79] = 108;
  33389. t[80] = 109;
  33390. t[81] = 110;
  33391. t[82] = 111;
  33392. t[83] = 112;
  33393. t[84] = 113;
  33394. t[85] = 114;
  33395. t[86] = 115;
  33396. t[87] = 116;
  33397. t[88] = 117;
  33398. t[89] = 118;
  33399. t[90] = 119;
  33400. t[91] = 120;
  33401. t[92] = 121;
  33402. t[93] = 122;
  33403. t[94] = 123;
  33404. t[95] = 124;
  33405. t[96] = 125;
  33406. t[97] = 126;
  33407. t[98] = 196;
  33408. t[99] = 197;
  33409. t[100] = 199;
  33410. t[101] = 201;
  33411. t[102] = 209;
  33412. t[103] = 214;
  33413. t[104] = 220;
  33414. t[105] = 225;
  33415. t[106] = 224;
  33416. t[107] = 226;
  33417. t[108] = 228;
  33418. t[109] = 227;
  33419. t[110] = 229;
  33420. t[111] = 231;
  33421. t[112] = 233;
  33422. t[113] = 232;
  33423. t[114] = 234;
  33424. t[115] = 235;
  33425. t[116] = 237;
  33426. t[117] = 236;
  33427. t[118] = 238;
  33428. t[119] = 239;
  33429. t[120] = 241;
  33430. t[121] = 243;
  33431. t[122] = 242;
  33432. t[123] = 244;
  33433. t[124] = 246;
  33434. t[125] = 245;
  33435. t[126] = 250;
  33436. t[127] = 249;
  33437. t[128] = 251;
  33438. t[129] = 252;
  33439. t[130] = 8224;
  33440. t[131] = 176;
  33441. t[132] = 162;
  33442. t[133] = 163;
  33443. t[134] = 167;
  33444. t[135] = 8226;
  33445. t[136] = 182;
  33446. t[137] = 223;
  33447. t[138] = 174;
  33448. t[139] = 169;
  33449. t[140] = 8482;
  33450. t[141] = 180;
  33451. t[142] = 168;
  33452. t[143] = 8800;
  33453. t[144] = 198;
  33454. t[145] = 216;
  33455. t[146] = 8734;
  33456. t[147] = 177;
  33457. t[148] = 8804;
  33458. t[149] = 8805;
  33459. t[150] = 165;
  33460. t[151] = 181;
  33461. t[152] = 8706;
  33462. t[153] = 8721;
  33463. t[154] = 8719;
  33464. t[156] = 8747;
  33465. t[157] = 170;
  33466. t[158] = 186;
  33467. t[159] = 8486;
  33468. t[160] = 230;
  33469. t[161] = 248;
  33470. t[162] = 191;
  33471. t[163] = 161;
  33472. t[164] = 172;
  33473. t[165] = 8730;
  33474. t[166] = 402;
  33475. t[167] = 8776;
  33476. t[168] = 8710;
  33477. t[169] = 171;
  33478. t[170] = 187;
  33479. t[171] = 8230;
  33480. t[179] = 8220;
  33481. t[180] = 8221;
  33482. t[181] = 8216;
  33483. t[182] = 8217;
  33484. t[200] = 193;
  33485. t[203] = 205;
  33486. t[207] = 211;
  33487. t[210] = 218;
  33488. t[223] = 711;
  33489. t[224] = 321;
  33490. t[225] = 322;
  33491. t[226] = 352;
  33492. t[227] = 353;
  33493. t[228] = 381;
  33494. t[229] = 382;
  33495. t[233] = 221;
  33496. t[234] = 253;
  33497. t[252] = 263;
  33498. t[253] = 268;
  33499. t[254] = 269;
  33500. t[258] = 258;
  33501. t[260] = 260;
  33502. t[261] = 261;
  33503. t[265] = 280;
  33504. t[266] = 281;
  33505. t[267] = 282;
  33506. t[268] = 283;
  33507. t[269] = 313;
  33508. t[275] = 323;
  33509. t[276] = 324;
  33510. t[278] = 328;
  33511. t[283] = 344;
  33512. t[284] = 345;
  33513. t[285] = 346;
  33514. t[286] = 347;
  33515. t[292] = 367;
  33516. t[295] = 377;
  33517. t[296] = 378;
  33518. t[298] = 380;
  33519. t[305] = 963;
  33520. t[306] = 964;
  33521. t[307] = 966;
  33522. t[308] = 8215;
  33523. t[309] = 8252;
  33524. t[310] = 8319;
  33525. t[311] = 8359;
  33526. t[312] = 8592;
  33527. t[313] = 8593;
  33528. t[337] = 9552;
  33529. t[493] = 1039;
  33530. t[494] = 1040;
  33531. t[672] = 1488;
  33532. t[673] = 1489;
  33533. t[674] = 1490;
  33534. t[675] = 1491;
  33535. t[676] = 1492;
  33536. t[677] = 1493;
  33537. t[678] = 1494;
  33538. t[679] = 1495;
  33539. t[680] = 1496;
  33540. t[681] = 1497;
  33541. t[682] = 1498;
  33542. t[683] = 1499;
  33543. t[684] = 1500;
  33544. t[685] = 1501;
  33545. t[686] = 1502;
  33546. t[687] = 1503;
  33547. t[688] = 1504;
  33548. t[689] = 1505;
  33549. t[690] = 1506;
  33550. t[691] = 1507;
  33551. t[692] = 1508;
  33552. t[693] = 1509;
  33553. t[694] = 1510;
  33554. t[695] = 1511;
  33555. t[696] = 1512;
  33556. t[697] = 1513;
  33557. t[698] = 1514;
  33558. t[705] = 1524;
  33559. t[706] = 8362;
  33560. t[710] = 64288;
  33561. t[711] = 64298;
  33562. t[759] = 1617;
  33563. t[761] = 1776;
  33564. t[763] = 1778;
  33565. t[775] = 1652;
  33566. t[777] = 1764;
  33567. t[778] = 1780;
  33568. t[779] = 1781;
  33569. t[780] = 1782;
  33570. t[782] = 771;
  33571. t[783] = 64726;
  33572. t[786] = 8363;
  33573. t[788] = 8532;
  33574. t[790] = 768;
  33575. t[791] = 769;
  33576. t[792] = 768;
  33577. t[795] = 803;
  33578. t[797] = 64336;
  33579. t[798] = 64337;
  33580. t[799] = 64342;
  33581. t[800] = 64343;
  33582. t[801] = 64344;
  33583. t[802] = 64345;
  33584. t[803] = 64362;
  33585. t[804] = 64363;
  33586. t[805] = 64364;
  33587. t[2424] = 7821;
  33588. t[2425] = 7822;
  33589. t[2426] = 7823;
  33590. t[2427] = 7824;
  33591. t[2428] = 7825;
  33592. t[2429] = 7826;
  33593. t[2430] = 7827;
  33594. t[2433] = 7682;
  33595. t[2678] = 8045;
  33596. t[2679] = 8046;
  33597. t[2830] = 1552;
  33598. t[2838] = 686;
  33599. t[2840] = 751;
  33600. t[2842] = 753;
  33601. t[2843] = 754;
  33602. t[2844] = 755;
  33603. t[2846] = 757;
  33604. t[2856] = 767;
  33605. t[2857] = 848;
  33606. t[2858] = 849;
  33607. t[2862] = 853;
  33608. t[2863] = 854;
  33609. t[2864] = 855;
  33610. t[2865] = 861;
  33611. t[2866] = 862;
  33612. t[2906] = 7460;
  33613. t[2908] = 7462;
  33614. t[2909] = 7463;
  33615. t[2910] = 7464;
  33616. t[2912] = 7466;
  33617. t[2913] = 7467;
  33618. t[2914] = 7468;
  33619. t[2916] = 7470;
  33620. t[2917] = 7471;
  33621. t[2918] = 7472;
  33622. t[2920] = 7474;
  33623. t[2921] = 7475;
  33624. t[2922] = 7476;
  33625. t[2924] = 7478;
  33626. t[2925] = 7479;
  33627. t[2926] = 7480;
  33628. t[2928] = 7482;
  33629. t[2929] = 7483;
  33630. t[2930] = 7484;
  33631. t[2932] = 7486;
  33632. t[2933] = 7487;
  33633. t[2934] = 7488;
  33634. t[2936] = 7490;
  33635. t[2937] = 7491;
  33636. t[2938] = 7492;
  33637. t[2940] = 7494;
  33638. t[2941] = 7495;
  33639. t[2942] = 7496;
  33640. t[2944] = 7498;
  33641. t[2946] = 7500;
  33642. t[2948] = 7502;
  33643. t[2950] = 7504;
  33644. t[2951] = 7505;
  33645. t[2952] = 7506;
  33646. t[2954] = 7508;
  33647. t[2955] = 7509;
  33648. t[2956] = 7510;
  33649. t[2958] = 7512;
  33650. t[2959] = 7513;
  33651. t[2960] = 7514;
  33652. t[2962] = 7516;
  33653. t[2963] = 7517;
  33654. t[2964] = 7518;
  33655. t[2966] = 7520;
  33656. t[2967] = 7521;
  33657. t[2968] = 7522;
  33658. t[2970] = 7524;
  33659. t[2971] = 7525;
  33660. t[2972] = 7526;
  33661. t[2974] = 7528;
  33662. t[2975] = 7529;
  33663. t[2976] = 7530;
  33664. t[2978] = 1537;
  33665. t[2979] = 1538;
  33666. t[2980] = 1539;
  33667. t[2982] = 1549;
  33668. t[2983] = 1551;
  33669. t[2984] = 1552;
  33670. t[2986] = 1554;
  33671. t[2987] = 1555;
  33672. t[2988] = 1556;
  33673. t[2990] = 1623;
  33674. t[2991] = 1624;
  33675. t[2995] = 1775;
  33676. t[2999] = 1791;
  33677. t[3002] = 64290;
  33678. t[3003] = 64291;
  33679. t[3004] = 64292;
  33680. t[3006] = 64294;
  33681. t[3007] = 64295;
  33682. t[3008] = 64296;
  33683. t[3011] = 1900;
  33684. t[3014] = 8223;
  33685. t[3015] = 8244;
  33686. t[3017] = 7532;
  33687. t[3018] = 7533;
  33688. t[3019] = 7534;
  33689. t[3075] = 7590;
  33690. t[3076] = 7591;
  33691. t[3079] = 7594;
  33692. t[3080] = 7595;
  33693. t[3083] = 7598;
  33694. t[3084] = 7599;
  33695. t[3087] = 7602;
  33696. t[3088] = 7603;
  33697. t[3091] = 7606;
  33698. t[3092] = 7607;
  33699. t[3095] = 7610;
  33700. t[3096] = 7611;
  33701. t[3099] = 7614;
  33702. t[3100] = 7615;
  33703. t[3103] = 7618;
  33704. t[3104] = 7619;
  33705. t[3107] = 8337;
  33706. t[3108] = 8338;
  33707. t[3116] = 1884;
  33708. t[3119] = 1885;
  33709. t[3120] = 1885;
  33710. t[3123] = 1886;
  33711. t[3124] = 1886;
  33712. t[3127] = 1887;
  33713. t[3128] = 1887;
  33714. t[3131] = 1888;
  33715. t[3132] = 1888;
  33716. t[3135] = 1889;
  33717. t[3136] = 1889;
  33718. t[3139] = 1890;
  33719. t[3140] = 1890;
  33720. t[3143] = 1891;
  33721. t[3144] = 1891;
  33722. t[3147] = 1892;
  33723. t[3148] = 1892;
  33724. t[3153] = 580;
  33725. t[3154] = 581;
  33726. t[3157] = 584;
  33727. t[3158] = 585;
  33728. t[3161] = 588;
  33729. t[3162] = 589;
  33730. t[3165] = 891;
  33731. t[3166] = 892;
  33732. t[3169] = 1274;
  33733. t[3170] = 1275;
  33734. t[3173] = 1278;
  33735. t[3174] = 1279;
  33736. t[3181] = 7622;
  33737. t[3182] = 7623;
  33738. t[3282] = 11799;
  33739. t[3316] = 578;
  33740. t[3379] = 42785;
  33741. t[3393] = 1159;
  33742. t[3416] = 8377;
  33743. });
  33744. exports.getGlyphMapForStandardFonts = getGlyphMapForStandardFonts;
  33745. const getSupplementalGlyphMapForArialBlack = (0, _core_utils.getLookupTableFactory)(function (t) {
  33746. t[227] = 322;
  33747. t[264] = 261;
  33748. t[291] = 346;
  33749. });
  33750. exports.getSupplementalGlyphMapForArialBlack = getSupplementalGlyphMapForArialBlack;
  33751. const getSupplementalGlyphMapForCalibri = (0, _core_utils.getLookupTableFactory)(function (t) {
  33752. t[1] = 32;
  33753. t[4] = 65;
  33754. t[5] = 192;
  33755. t[6] = 193;
  33756. t[9] = 196;
  33757. t[17] = 66;
  33758. t[18] = 67;
  33759. t[21] = 268;
  33760. t[24] = 68;
  33761. t[28] = 69;
  33762. t[29] = 200;
  33763. t[30] = 201;
  33764. t[32] = 282;
  33765. t[38] = 70;
  33766. t[39] = 71;
  33767. t[44] = 72;
  33768. t[47] = 73;
  33769. t[48] = 204;
  33770. t[49] = 205;
  33771. t[58] = 74;
  33772. t[60] = 75;
  33773. t[62] = 76;
  33774. t[68] = 77;
  33775. t[69] = 78;
  33776. t[75] = 79;
  33777. t[76] = 210;
  33778. t[80] = 214;
  33779. t[87] = 80;
  33780. t[89] = 81;
  33781. t[90] = 82;
  33782. t[92] = 344;
  33783. t[94] = 83;
  33784. t[97] = 352;
  33785. t[100] = 84;
  33786. t[104] = 85;
  33787. t[109] = 220;
  33788. t[115] = 86;
  33789. t[116] = 87;
  33790. t[121] = 88;
  33791. t[122] = 89;
  33792. t[124] = 221;
  33793. t[127] = 90;
  33794. t[129] = 381;
  33795. t[258] = 97;
  33796. t[259] = 224;
  33797. t[260] = 225;
  33798. t[263] = 228;
  33799. t[268] = 261;
  33800. t[271] = 98;
  33801. t[272] = 99;
  33802. t[273] = 263;
  33803. t[275] = 269;
  33804. t[282] = 100;
  33805. t[286] = 101;
  33806. t[287] = 232;
  33807. t[288] = 233;
  33808. t[290] = 283;
  33809. t[295] = 281;
  33810. t[296] = 102;
  33811. t[336] = 103;
  33812. t[346] = 104;
  33813. t[349] = 105;
  33814. t[350] = 236;
  33815. t[351] = 237;
  33816. t[361] = 106;
  33817. t[364] = 107;
  33818. t[367] = 108;
  33819. t[371] = 322;
  33820. t[373] = 109;
  33821. t[374] = 110;
  33822. t[381] = 111;
  33823. t[382] = 242;
  33824. t[383] = 243;
  33825. t[386] = 246;
  33826. t[393] = 112;
  33827. t[395] = 113;
  33828. t[396] = 114;
  33829. t[398] = 345;
  33830. t[400] = 115;
  33831. t[401] = 347;
  33832. t[403] = 353;
  33833. t[410] = 116;
  33834. t[437] = 117;
  33835. t[442] = 252;
  33836. t[448] = 118;
  33837. t[449] = 119;
  33838. t[454] = 120;
  33839. t[455] = 121;
  33840. t[457] = 253;
  33841. t[460] = 122;
  33842. t[462] = 382;
  33843. t[463] = 380;
  33844. t[853] = 44;
  33845. t[855] = 58;
  33846. t[856] = 46;
  33847. t[876] = 47;
  33848. t[878] = 45;
  33849. t[882] = 45;
  33850. t[894] = 40;
  33851. t[895] = 41;
  33852. t[896] = 91;
  33853. t[897] = 93;
  33854. t[923] = 64;
  33855. t[1004] = 48;
  33856. t[1005] = 49;
  33857. t[1006] = 50;
  33858. t[1007] = 51;
  33859. t[1008] = 52;
  33860. t[1009] = 53;
  33861. t[1010] = 54;
  33862. t[1011] = 55;
  33863. t[1012] = 56;
  33864. t[1013] = 57;
  33865. t[1081] = 37;
  33866. t[1085] = 43;
  33867. t[1086] = 45;
  33868. });
  33869. exports.getSupplementalGlyphMapForCalibri = getSupplementalGlyphMapForCalibri;
  33870. function getStandardFontName(name) {
  33871. const fontName = (0, _fonts_utils.normalizeFontName)(name);
  33872. const stdFontMap = getStdFontMap();
  33873. return stdFontMap[fontName];
  33874. }
  33875. function isKnownFontName(name) {
  33876. const fontName = (0, _fonts_utils.normalizeFontName)(name);
  33877. return !!(getStdFontMap()[fontName] || getNonStdFontMap()[fontName] || getSerifFonts()[fontName] || getSymbolsFonts()[fontName]);
  33878. }
  33879. /***/ }),
  33880. /* 193 */
  33881. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  33882. Object.defineProperty(exports, "__esModule", ({
  33883. value: true
  33884. }));
  33885. exports.ToUnicodeMap = exports.IdentityToUnicodeMap = void 0;
  33886. var _util = __w_pdfjs_require__(145);
  33887. class ToUnicodeMap {
  33888. constructor() {
  33889. let cmap = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
  33890. this._map = cmap;
  33891. }
  33892. get length() {
  33893. return this._map.length;
  33894. }
  33895. forEach(callback) {
  33896. for (const charCode in this._map) {
  33897. callback(charCode, this._map[charCode].charCodeAt(0));
  33898. }
  33899. }
  33900. has(i) {
  33901. return this._map[i] !== undefined;
  33902. }
  33903. get(i) {
  33904. return this._map[i];
  33905. }
  33906. charCodeOf(value) {
  33907. const map = this._map;
  33908. if (map.length <= 0x10000) {
  33909. return map.indexOf(value);
  33910. }
  33911. for (const charCode in map) {
  33912. if (map[charCode] === value) {
  33913. return charCode | 0;
  33914. }
  33915. }
  33916. return -1;
  33917. }
  33918. amend(map) {
  33919. for (const charCode in map) {
  33920. this._map[charCode] = map[charCode];
  33921. }
  33922. }
  33923. }
  33924. exports.ToUnicodeMap = ToUnicodeMap;
  33925. class IdentityToUnicodeMap {
  33926. constructor(firstChar, lastChar) {
  33927. this.firstChar = firstChar;
  33928. this.lastChar = lastChar;
  33929. }
  33930. get length() {
  33931. return this.lastChar + 1 - this.firstChar;
  33932. }
  33933. forEach(callback) {
  33934. for (let i = this.firstChar, ii = this.lastChar; i <= ii; i++) {
  33935. callback(i, i);
  33936. }
  33937. }
  33938. has(i) {
  33939. return this.firstChar <= i && i <= this.lastChar;
  33940. }
  33941. get(i) {
  33942. if (this.firstChar <= i && i <= this.lastChar) {
  33943. return String.fromCharCode(i);
  33944. }
  33945. return undefined;
  33946. }
  33947. charCodeOf(v) {
  33948. return Number.isInteger(v) && v >= this.firstChar && v <= this.lastChar ? v : -1;
  33949. }
  33950. amend(map) {
  33951. (0, _util.unreachable)("Should not call amend()");
  33952. }
  33953. }
  33954. exports.IdentityToUnicodeMap = IdentityToUnicodeMap;
  33955. /***/ }),
  33956. /* 194 */
  33957. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  33958. Object.defineProperty(exports, "__esModule", ({
  33959. value: true
  33960. }));
  33961. exports.CFFFont = void 0;
  33962. var _cff_parser = __w_pdfjs_require__(186);
  33963. var _fonts_utils = __w_pdfjs_require__(189);
  33964. var _util = __w_pdfjs_require__(145);
  33965. class CFFFont {
  33966. constructor(file, properties) {
  33967. this.properties = properties;
  33968. const parser = new _cff_parser.CFFParser(file, properties, _fonts_utils.SEAC_ANALYSIS_ENABLED);
  33969. this.cff = parser.parse();
  33970. this.cff.duplicateFirstGlyph();
  33971. const compiler = new _cff_parser.CFFCompiler(this.cff);
  33972. this.seacs = this.cff.seacs;
  33973. try {
  33974. this.data = compiler.compile();
  33975. } catch {
  33976. (0, _util.warn)("Failed to compile font " + properties.loadedName);
  33977. this.data = file;
  33978. }
  33979. this._createBuiltInEncoding();
  33980. }
  33981. get numGlyphs() {
  33982. return this.cff.charStrings.count;
  33983. }
  33984. getCharset() {
  33985. return this.cff.charset.charset;
  33986. }
  33987. getGlyphMapping() {
  33988. const cff = this.cff;
  33989. const properties = this.properties;
  33990. const {
  33991. cidToGidMap,
  33992. cMap
  33993. } = properties;
  33994. const charsets = cff.charset.charset;
  33995. let charCodeToGlyphId;
  33996. let glyphId;
  33997. if (properties.composite) {
  33998. let invCidToGidMap;
  33999. if (cidToGidMap?.length > 0) {
  34000. invCidToGidMap = Object.create(null);
  34001. for (let i = 0, ii = cidToGidMap.length; i < ii; i++) {
  34002. const gid = cidToGidMap[i];
  34003. if (gid !== undefined) {
  34004. invCidToGidMap[gid] = i;
  34005. }
  34006. }
  34007. }
  34008. charCodeToGlyphId = Object.create(null);
  34009. let charCode;
  34010. if (cff.isCIDFont) {
  34011. for (glyphId = 0; glyphId < charsets.length; glyphId++) {
  34012. const cid = charsets[glyphId];
  34013. charCode = cMap.charCodeOf(cid);
  34014. if (invCidToGidMap?.[charCode] !== undefined) {
  34015. charCode = invCidToGidMap[charCode];
  34016. }
  34017. charCodeToGlyphId[charCode] = glyphId;
  34018. }
  34019. } else {
  34020. for (glyphId = 0; glyphId < cff.charStrings.count; glyphId++) {
  34021. charCode = cMap.charCodeOf(glyphId);
  34022. charCodeToGlyphId[charCode] = glyphId;
  34023. }
  34024. }
  34025. return charCodeToGlyphId;
  34026. }
  34027. let encoding = cff.encoding ? cff.encoding.encoding : null;
  34028. if (properties.isInternalFont) {
  34029. encoding = properties.defaultEncoding;
  34030. }
  34031. charCodeToGlyphId = (0, _fonts_utils.type1FontGlyphMapping)(properties, encoding, charsets);
  34032. return charCodeToGlyphId;
  34033. }
  34034. hasGlyphId(id) {
  34035. return this.cff.hasGlyphId(id);
  34036. }
  34037. _createBuiltInEncoding() {
  34038. const {
  34039. charset,
  34040. encoding
  34041. } = this.cff;
  34042. if (!charset || !encoding) {
  34043. return;
  34044. }
  34045. const charsets = charset.charset,
  34046. encodings = encoding.encoding;
  34047. const map = [];
  34048. for (const charCode in encodings) {
  34049. const glyphId = encodings[charCode];
  34050. if (glyphId >= 0) {
  34051. const glyphName = charsets[glyphId];
  34052. if (glyphName) {
  34053. map[charCode] = glyphName;
  34054. }
  34055. }
  34056. }
  34057. if (map.length > 0) {
  34058. this.properties.builtInEncoding = map;
  34059. }
  34060. }
  34061. }
  34062. exports.CFFFont = CFFFont;
  34063. /***/ }),
  34064. /* 195 */
  34065. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  34066. Object.defineProperty(exports, "__esModule", ({
  34067. value: true
  34068. }));
  34069. exports.FontRendererFactory = void 0;
  34070. __w_pdfjs_require__(140);
  34071. __w_pdfjs_require__(158);
  34072. __w_pdfjs_require__(160);
  34073. __w_pdfjs_require__(84);
  34074. __w_pdfjs_require__(93);
  34075. __w_pdfjs_require__(94);
  34076. __w_pdfjs_require__(97);
  34077. __w_pdfjs_require__(99);
  34078. __w_pdfjs_require__(101);
  34079. __w_pdfjs_require__(105);
  34080. __w_pdfjs_require__(108);
  34081. __w_pdfjs_require__(115);
  34082. var _util = __w_pdfjs_require__(145);
  34083. var _cff_parser = __w_pdfjs_require__(186);
  34084. var _glyphlist = __w_pdfjs_require__(190);
  34085. var _encodings = __w_pdfjs_require__(188);
  34086. var _stream = __w_pdfjs_require__(155);
  34087. function getUint32(data, offset) {
  34088. return (data[offset] << 24 | data[offset + 1] << 16 | data[offset + 2] << 8 | data[offset + 3]) >>> 0;
  34089. }
  34090. function getUint16(data, offset) {
  34091. return data[offset] << 8 | data[offset + 1];
  34092. }
  34093. function getInt16(data, offset) {
  34094. return (data[offset] << 24 | data[offset + 1] << 16) >> 16;
  34095. }
  34096. function getInt8(data, offset) {
  34097. return data[offset] << 24 >> 24;
  34098. }
  34099. function getFloat214(data, offset) {
  34100. return getInt16(data, offset) / 16384;
  34101. }
  34102. function getSubroutineBias(subrs) {
  34103. const numSubrs = subrs.length;
  34104. let bias = 32768;
  34105. if (numSubrs < 1240) {
  34106. bias = 107;
  34107. } else if (numSubrs < 33900) {
  34108. bias = 1131;
  34109. }
  34110. return bias;
  34111. }
  34112. function parseCmap(data, start, end) {
  34113. const offset = getUint16(data, start + 2) === 1 ? getUint32(data, start + 8) : getUint32(data, start + 16);
  34114. const format = getUint16(data, start + offset);
  34115. let ranges, p, i;
  34116. if (format === 4) {
  34117. getUint16(data, start + offset + 2);
  34118. const segCount = getUint16(data, start + offset + 6) >> 1;
  34119. p = start + offset + 14;
  34120. ranges = [];
  34121. for (i = 0; i < segCount; i++, p += 2) {
  34122. ranges[i] = {
  34123. end: getUint16(data, p)
  34124. };
  34125. }
  34126. p += 2;
  34127. for (i = 0; i < segCount; i++, p += 2) {
  34128. ranges[i].start = getUint16(data, p);
  34129. }
  34130. for (i = 0; i < segCount; i++, p += 2) {
  34131. ranges[i].idDelta = getUint16(data, p);
  34132. }
  34133. for (i = 0; i < segCount; i++, p += 2) {
  34134. let idOffset = getUint16(data, p);
  34135. if (idOffset === 0) {
  34136. continue;
  34137. }
  34138. ranges[i].ids = [];
  34139. for (let j = 0, jj = ranges[i].end - ranges[i].start + 1; j < jj; j++) {
  34140. ranges[i].ids[j] = getUint16(data, p + idOffset);
  34141. idOffset += 2;
  34142. }
  34143. }
  34144. return ranges;
  34145. } else if (format === 12) {
  34146. const groups = getUint32(data, start + offset + 12);
  34147. p = start + offset + 16;
  34148. ranges = [];
  34149. for (i = 0; i < groups; i++) {
  34150. start = getUint32(data, p);
  34151. ranges.push({
  34152. start,
  34153. end: getUint32(data, p + 4),
  34154. idDelta: getUint32(data, p + 8) - start
  34155. });
  34156. p += 12;
  34157. }
  34158. return ranges;
  34159. }
  34160. throw new _util.FormatError(`unsupported cmap: ${format}`);
  34161. }
  34162. function parseCff(data, start, end, seacAnalysisEnabled) {
  34163. const properties = {};
  34164. const parser = new _cff_parser.CFFParser(new _stream.Stream(data, start, end - start), properties, seacAnalysisEnabled);
  34165. const cff = parser.parse();
  34166. return {
  34167. glyphs: cff.charStrings.objects,
  34168. subrs: cff.topDict.privateDict?.subrsIndex?.objects,
  34169. gsubrs: cff.globalSubrIndex?.objects,
  34170. isCFFCIDFont: cff.isCIDFont,
  34171. fdSelect: cff.fdSelect,
  34172. fdArray: cff.fdArray
  34173. };
  34174. }
  34175. function parseGlyfTable(glyf, loca, isGlyphLocationsLong) {
  34176. let itemSize, itemDecode;
  34177. if (isGlyphLocationsLong) {
  34178. itemSize = 4;
  34179. itemDecode = getUint32;
  34180. } else {
  34181. itemSize = 2;
  34182. itemDecode = (data, offset) => 2 * getUint16(data, offset);
  34183. }
  34184. const glyphs = [];
  34185. let startOffset = itemDecode(loca, 0);
  34186. for (let j = itemSize; j < loca.length; j += itemSize) {
  34187. const endOffset = itemDecode(loca, j);
  34188. glyphs.push(glyf.subarray(startOffset, endOffset));
  34189. startOffset = endOffset;
  34190. }
  34191. return glyphs;
  34192. }
  34193. function lookupCmap(ranges, unicode) {
  34194. const code = unicode.codePointAt(0);
  34195. let gid = 0,
  34196. l = 0,
  34197. r = ranges.length - 1;
  34198. while (l < r) {
  34199. const c = l + r + 1 >> 1;
  34200. if (code < ranges[c].start) {
  34201. r = c - 1;
  34202. } else {
  34203. l = c;
  34204. }
  34205. }
  34206. if (ranges[l].start <= code && code <= ranges[l].end) {
  34207. gid = ranges[l].idDelta + (ranges[l].ids ? ranges[l].ids[code - ranges[l].start] : code) & 0xffff;
  34208. }
  34209. return {
  34210. charCode: code,
  34211. glyphId: gid
  34212. };
  34213. }
  34214. function compileGlyf(code, cmds, font) {
  34215. function moveTo(x, y) {
  34216. cmds.push({
  34217. cmd: "moveTo",
  34218. args: [x, y]
  34219. });
  34220. }
  34221. function lineTo(x, y) {
  34222. cmds.push({
  34223. cmd: "lineTo",
  34224. args: [x, y]
  34225. });
  34226. }
  34227. function quadraticCurveTo(xa, ya, x, y) {
  34228. cmds.push({
  34229. cmd: "quadraticCurveTo",
  34230. args: [xa, ya, x, y]
  34231. });
  34232. }
  34233. let i = 0;
  34234. const numberOfContours = getInt16(code, i);
  34235. let flags;
  34236. let x = 0,
  34237. y = 0;
  34238. i += 10;
  34239. if (numberOfContours < 0) {
  34240. do {
  34241. flags = getUint16(code, i);
  34242. const glyphIndex = getUint16(code, i + 2);
  34243. i += 4;
  34244. let arg1, arg2;
  34245. if (flags & 0x01) {
  34246. if (flags & 0x02) {
  34247. arg1 = getInt16(code, i);
  34248. arg2 = getInt16(code, i + 2);
  34249. } else {
  34250. arg1 = getUint16(code, i);
  34251. arg2 = getUint16(code, i + 2);
  34252. }
  34253. i += 4;
  34254. } else if (flags & 0x02) {
  34255. arg1 = getInt8(code, i++);
  34256. arg2 = getInt8(code, i++);
  34257. } else {
  34258. arg1 = code[i++];
  34259. arg2 = code[i++];
  34260. }
  34261. if (flags & 0x02) {
  34262. x = arg1;
  34263. y = arg2;
  34264. } else {
  34265. x = 0;
  34266. y = 0;
  34267. }
  34268. let scaleX = 1,
  34269. scaleY = 1,
  34270. scale01 = 0,
  34271. scale10 = 0;
  34272. if (flags & 0x08) {
  34273. scaleX = scaleY = getFloat214(code, i);
  34274. i += 2;
  34275. } else if (flags & 0x40) {
  34276. scaleX = getFloat214(code, i);
  34277. scaleY = getFloat214(code, i + 2);
  34278. i += 4;
  34279. } else if (flags & 0x80) {
  34280. scaleX = getFloat214(code, i);
  34281. scale01 = getFloat214(code, i + 2);
  34282. scale10 = getFloat214(code, i + 4);
  34283. scaleY = getFloat214(code, i + 6);
  34284. i += 8;
  34285. }
  34286. const subglyph = font.glyphs[glyphIndex];
  34287. if (subglyph) {
  34288. cmds.push({
  34289. cmd: "save"
  34290. }, {
  34291. cmd: "transform",
  34292. args: [scaleX, scale01, scale10, scaleY, x, y]
  34293. });
  34294. if (!(flags & 0x02)) {}
  34295. compileGlyf(subglyph, cmds, font);
  34296. cmds.push({
  34297. cmd: "restore"
  34298. });
  34299. }
  34300. } while (flags & 0x20);
  34301. } else {
  34302. const endPtsOfContours = [];
  34303. let j, jj;
  34304. for (j = 0; j < numberOfContours; j++) {
  34305. endPtsOfContours.push(getUint16(code, i));
  34306. i += 2;
  34307. }
  34308. const instructionLength = getUint16(code, i);
  34309. i += 2 + instructionLength;
  34310. const numberOfPoints = endPtsOfContours.at(-1) + 1;
  34311. const points = [];
  34312. while (points.length < numberOfPoints) {
  34313. flags = code[i++];
  34314. let repeat = 1;
  34315. if (flags & 0x08) {
  34316. repeat += code[i++];
  34317. }
  34318. while (repeat-- > 0) {
  34319. points.push({
  34320. flags
  34321. });
  34322. }
  34323. }
  34324. for (j = 0; j < numberOfPoints; j++) {
  34325. switch (points[j].flags & 0x12) {
  34326. case 0x00:
  34327. x += getInt16(code, i);
  34328. i += 2;
  34329. break;
  34330. case 0x02:
  34331. x -= code[i++];
  34332. break;
  34333. case 0x12:
  34334. x += code[i++];
  34335. break;
  34336. }
  34337. points[j].x = x;
  34338. }
  34339. for (j = 0; j < numberOfPoints; j++) {
  34340. switch (points[j].flags & 0x24) {
  34341. case 0x00:
  34342. y += getInt16(code, i);
  34343. i += 2;
  34344. break;
  34345. case 0x04:
  34346. y -= code[i++];
  34347. break;
  34348. case 0x24:
  34349. y += code[i++];
  34350. break;
  34351. }
  34352. points[j].y = y;
  34353. }
  34354. let startPoint = 0;
  34355. for (i = 0; i < numberOfContours; i++) {
  34356. const endPoint = endPtsOfContours[i];
  34357. const contour = points.slice(startPoint, endPoint + 1);
  34358. if (contour[0].flags & 1) {
  34359. contour.push(contour[0]);
  34360. } else if (contour.at(-1).flags & 1) {
  34361. contour.unshift(contour.at(-1));
  34362. } else {
  34363. const p = {
  34364. flags: 1,
  34365. x: (contour[0].x + contour.at(-1).x) / 2,
  34366. y: (contour[0].y + contour.at(-1).y) / 2
  34367. };
  34368. contour.unshift(p);
  34369. contour.push(p);
  34370. }
  34371. moveTo(contour[0].x, contour[0].y);
  34372. for (j = 1, jj = contour.length; j < jj; j++) {
  34373. if (contour[j].flags & 1) {
  34374. lineTo(contour[j].x, contour[j].y);
  34375. } else if (contour[j + 1].flags & 1) {
  34376. quadraticCurveTo(contour[j].x, contour[j].y, contour[j + 1].x, contour[j + 1].y);
  34377. j++;
  34378. } else {
  34379. quadraticCurveTo(contour[j].x, contour[j].y, (contour[j].x + contour[j + 1].x) / 2, (contour[j].y + contour[j + 1].y) / 2);
  34380. }
  34381. }
  34382. startPoint = endPoint + 1;
  34383. }
  34384. }
  34385. }
  34386. function compileCharString(charStringCode, cmds, font, glyphId) {
  34387. function moveTo(x, y) {
  34388. cmds.push({
  34389. cmd: "moveTo",
  34390. args: [x, y]
  34391. });
  34392. }
  34393. function lineTo(x, y) {
  34394. cmds.push({
  34395. cmd: "lineTo",
  34396. args: [x, y]
  34397. });
  34398. }
  34399. function bezierCurveTo(x1, y1, x2, y2, x, y) {
  34400. cmds.push({
  34401. cmd: "bezierCurveTo",
  34402. args: [x1, y1, x2, y2, x, y]
  34403. });
  34404. }
  34405. const stack = [];
  34406. let x = 0,
  34407. y = 0;
  34408. let stems = 0;
  34409. function parse(code) {
  34410. let i = 0;
  34411. while (i < code.length) {
  34412. let stackClean = false;
  34413. let v = code[i++];
  34414. let xa, xb, ya, yb, y1, y2, y3, n, subrCode;
  34415. switch (v) {
  34416. case 1:
  34417. stems += stack.length >> 1;
  34418. stackClean = true;
  34419. break;
  34420. case 3:
  34421. stems += stack.length >> 1;
  34422. stackClean = true;
  34423. break;
  34424. case 4:
  34425. y += stack.pop();
  34426. moveTo(x, y);
  34427. stackClean = true;
  34428. break;
  34429. case 5:
  34430. while (stack.length > 0) {
  34431. x += stack.shift();
  34432. y += stack.shift();
  34433. lineTo(x, y);
  34434. }
  34435. break;
  34436. case 6:
  34437. while (stack.length > 0) {
  34438. x += stack.shift();
  34439. lineTo(x, y);
  34440. if (stack.length === 0) {
  34441. break;
  34442. }
  34443. y += stack.shift();
  34444. lineTo(x, y);
  34445. }
  34446. break;
  34447. case 7:
  34448. while (stack.length > 0) {
  34449. y += stack.shift();
  34450. lineTo(x, y);
  34451. if (stack.length === 0) {
  34452. break;
  34453. }
  34454. x += stack.shift();
  34455. lineTo(x, y);
  34456. }
  34457. break;
  34458. case 8:
  34459. while (stack.length > 0) {
  34460. xa = x + stack.shift();
  34461. ya = y + stack.shift();
  34462. xb = xa + stack.shift();
  34463. yb = ya + stack.shift();
  34464. x = xb + stack.shift();
  34465. y = yb + stack.shift();
  34466. bezierCurveTo(xa, ya, xb, yb, x, y);
  34467. }
  34468. break;
  34469. case 10:
  34470. n = stack.pop();
  34471. subrCode = null;
  34472. if (font.isCFFCIDFont) {
  34473. const fdIndex = font.fdSelect.getFDIndex(glyphId);
  34474. if (fdIndex >= 0 && fdIndex < font.fdArray.length) {
  34475. const fontDict = font.fdArray[fdIndex];
  34476. let subrs;
  34477. if (fontDict.privateDict?.subrsIndex) {
  34478. subrs = fontDict.privateDict.subrsIndex.objects;
  34479. }
  34480. if (subrs) {
  34481. n += getSubroutineBias(subrs);
  34482. subrCode = subrs[n];
  34483. }
  34484. } else {
  34485. (0, _util.warn)("Invalid fd index for glyph index.");
  34486. }
  34487. } else {
  34488. subrCode = font.subrs[n + font.subrsBias];
  34489. }
  34490. if (subrCode) {
  34491. parse(subrCode);
  34492. }
  34493. break;
  34494. case 11:
  34495. return;
  34496. case 12:
  34497. v = code[i++];
  34498. switch (v) {
  34499. case 34:
  34500. xa = x + stack.shift();
  34501. xb = xa + stack.shift();
  34502. y1 = y + stack.shift();
  34503. x = xb + stack.shift();
  34504. bezierCurveTo(xa, y, xb, y1, x, y1);
  34505. xa = x + stack.shift();
  34506. xb = xa + stack.shift();
  34507. x = xb + stack.shift();
  34508. bezierCurveTo(xa, y1, xb, y, x, y);
  34509. break;
  34510. case 35:
  34511. xa = x + stack.shift();
  34512. ya = y + stack.shift();
  34513. xb = xa + stack.shift();
  34514. yb = ya + stack.shift();
  34515. x = xb + stack.shift();
  34516. y = yb + stack.shift();
  34517. bezierCurveTo(xa, ya, xb, yb, x, y);
  34518. xa = x + stack.shift();
  34519. ya = y + stack.shift();
  34520. xb = xa + stack.shift();
  34521. yb = ya + stack.shift();
  34522. x = xb + stack.shift();
  34523. y = yb + stack.shift();
  34524. bezierCurveTo(xa, ya, xb, yb, x, y);
  34525. stack.pop();
  34526. break;
  34527. case 36:
  34528. xa = x + stack.shift();
  34529. y1 = y + stack.shift();
  34530. xb = xa + stack.shift();
  34531. y2 = y1 + stack.shift();
  34532. x = xb + stack.shift();
  34533. bezierCurveTo(xa, y1, xb, y2, x, y2);
  34534. xa = x + stack.shift();
  34535. xb = xa + stack.shift();
  34536. y3 = y2 + stack.shift();
  34537. x = xb + stack.shift();
  34538. bezierCurveTo(xa, y2, xb, y3, x, y);
  34539. break;
  34540. case 37:
  34541. const x0 = x,
  34542. y0 = y;
  34543. xa = x + stack.shift();
  34544. ya = y + stack.shift();
  34545. xb = xa + stack.shift();
  34546. yb = ya + stack.shift();
  34547. x = xb + stack.shift();
  34548. y = yb + stack.shift();
  34549. bezierCurveTo(xa, ya, xb, yb, x, y);
  34550. xa = x + stack.shift();
  34551. ya = y + stack.shift();
  34552. xb = xa + stack.shift();
  34553. yb = ya + stack.shift();
  34554. x = xb;
  34555. y = yb;
  34556. if (Math.abs(x - x0) > Math.abs(y - y0)) {
  34557. x += stack.shift();
  34558. } else {
  34559. y += stack.shift();
  34560. }
  34561. bezierCurveTo(xa, ya, xb, yb, x, y);
  34562. break;
  34563. default:
  34564. throw new _util.FormatError(`unknown operator: 12 ${v}`);
  34565. }
  34566. break;
  34567. case 14:
  34568. if (stack.length >= 4) {
  34569. const achar = stack.pop();
  34570. const bchar = stack.pop();
  34571. y = stack.pop();
  34572. x = stack.pop();
  34573. cmds.push({
  34574. cmd: "save"
  34575. }, {
  34576. cmd: "translate",
  34577. args: [x, y]
  34578. });
  34579. let cmap = lookupCmap(font.cmap, String.fromCharCode(font.glyphNameMap[_encodings.StandardEncoding[achar]]));
  34580. compileCharString(font.glyphs[cmap.glyphId], cmds, font, cmap.glyphId);
  34581. cmds.push({
  34582. cmd: "restore"
  34583. });
  34584. cmap = lookupCmap(font.cmap, String.fromCharCode(font.glyphNameMap[_encodings.StandardEncoding[bchar]]));
  34585. compileCharString(font.glyphs[cmap.glyphId], cmds, font, cmap.glyphId);
  34586. }
  34587. return;
  34588. case 18:
  34589. stems += stack.length >> 1;
  34590. stackClean = true;
  34591. break;
  34592. case 19:
  34593. stems += stack.length >> 1;
  34594. i += stems + 7 >> 3;
  34595. stackClean = true;
  34596. break;
  34597. case 20:
  34598. stems += stack.length >> 1;
  34599. i += stems + 7 >> 3;
  34600. stackClean = true;
  34601. break;
  34602. case 21:
  34603. y += stack.pop();
  34604. x += stack.pop();
  34605. moveTo(x, y);
  34606. stackClean = true;
  34607. break;
  34608. case 22:
  34609. x += stack.pop();
  34610. moveTo(x, y);
  34611. stackClean = true;
  34612. break;
  34613. case 23:
  34614. stems += stack.length >> 1;
  34615. stackClean = true;
  34616. break;
  34617. case 24:
  34618. while (stack.length > 2) {
  34619. xa = x + stack.shift();
  34620. ya = y + stack.shift();
  34621. xb = xa + stack.shift();
  34622. yb = ya + stack.shift();
  34623. x = xb + stack.shift();
  34624. y = yb + stack.shift();
  34625. bezierCurveTo(xa, ya, xb, yb, x, y);
  34626. }
  34627. x += stack.shift();
  34628. y += stack.shift();
  34629. lineTo(x, y);
  34630. break;
  34631. case 25:
  34632. while (stack.length > 6) {
  34633. x += stack.shift();
  34634. y += stack.shift();
  34635. lineTo(x, y);
  34636. }
  34637. xa = x + stack.shift();
  34638. ya = y + stack.shift();
  34639. xb = xa + stack.shift();
  34640. yb = ya + stack.shift();
  34641. x = xb + stack.shift();
  34642. y = yb + stack.shift();
  34643. bezierCurveTo(xa, ya, xb, yb, x, y);
  34644. break;
  34645. case 26:
  34646. if (stack.length % 2) {
  34647. x += stack.shift();
  34648. }
  34649. while (stack.length > 0) {
  34650. xa = x;
  34651. ya = y + stack.shift();
  34652. xb = xa + stack.shift();
  34653. yb = ya + stack.shift();
  34654. x = xb;
  34655. y = yb + stack.shift();
  34656. bezierCurveTo(xa, ya, xb, yb, x, y);
  34657. }
  34658. break;
  34659. case 27:
  34660. if (stack.length % 2) {
  34661. y += stack.shift();
  34662. }
  34663. while (stack.length > 0) {
  34664. xa = x + stack.shift();
  34665. ya = y;
  34666. xb = xa + stack.shift();
  34667. yb = ya + stack.shift();
  34668. x = xb + stack.shift();
  34669. y = yb;
  34670. bezierCurveTo(xa, ya, xb, yb, x, y);
  34671. }
  34672. break;
  34673. case 28:
  34674. stack.push((code[i] << 24 | code[i + 1] << 16) >> 16);
  34675. i += 2;
  34676. break;
  34677. case 29:
  34678. n = stack.pop() + font.gsubrsBias;
  34679. subrCode = font.gsubrs[n];
  34680. if (subrCode) {
  34681. parse(subrCode);
  34682. }
  34683. break;
  34684. case 30:
  34685. while (stack.length > 0) {
  34686. xa = x;
  34687. ya = y + stack.shift();
  34688. xb = xa + stack.shift();
  34689. yb = ya + stack.shift();
  34690. x = xb + stack.shift();
  34691. y = yb + (stack.length === 1 ? stack.shift() : 0);
  34692. bezierCurveTo(xa, ya, xb, yb, x, y);
  34693. if (stack.length === 0) {
  34694. break;
  34695. }
  34696. xa = x + stack.shift();
  34697. ya = y;
  34698. xb = xa + stack.shift();
  34699. yb = ya + stack.shift();
  34700. y = yb + stack.shift();
  34701. x = xb + (stack.length === 1 ? stack.shift() : 0);
  34702. bezierCurveTo(xa, ya, xb, yb, x, y);
  34703. }
  34704. break;
  34705. case 31:
  34706. while (stack.length > 0) {
  34707. xa = x + stack.shift();
  34708. ya = y;
  34709. xb = xa + stack.shift();
  34710. yb = ya + stack.shift();
  34711. y = yb + stack.shift();
  34712. x = xb + (stack.length === 1 ? stack.shift() : 0);
  34713. bezierCurveTo(xa, ya, xb, yb, x, y);
  34714. if (stack.length === 0) {
  34715. break;
  34716. }
  34717. xa = x;
  34718. ya = y + stack.shift();
  34719. xb = xa + stack.shift();
  34720. yb = ya + stack.shift();
  34721. x = xb + stack.shift();
  34722. y = yb + (stack.length === 1 ? stack.shift() : 0);
  34723. bezierCurveTo(xa, ya, xb, yb, x, y);
  34724. }
  34725. break;
  34726. default:
  34727. if (v < 32) {
  34728. throw new _util.FormatError(`unknown operator: ${v}`);
  34729. }
  34730. if (v < 247) {
  34731. stack.push(v - 139);
  34732. } else if (v < 251) {
  34733. stack.push((v - 247) * 256 + code[i++] + 108);
  34734. } else if (v < 255) {
  34735. stack.push(-(v - 251) * 256 - code[i++] - 108);
  34736. } else {
  34737. stack.push((code[i] << 24 | code[i + 1] << 16 | code[i + 2] << 8 | code[i + 3]) / 65536);
  34738. i += 4;
  34739. }
  34740. break;
  34741. }
  34742. if (stackClean) {
  34743. stack.length = 0;
  34744. }
  34745. }
  34746. }
  34747. parse(charStringCode);
  34748. }
  34749. const NOOP = [];
  34750. class CompiledFont {
  34751. constructor(fontMatrix) {
  34752. if (this.constructor === CompiledFont) {
  34753. (0, _util.unreachable)("Cannot initialize CompiledFont.");
  34754. }
  34755. this.fontMatrix = fontMatrix;
  34756. this.compiledGlyphs = Object.create(null);
  34757. this.compiledCharCodeToGlyphId = Object.create(null);
  34758. }
  34759. getPathJs(unicode) {
  34760. const {
  34761. charCode,
  34762. glyphId
  34763. } = lookupCmap(this.cmap, unicode);
  34764. let fn = this.compiledGlyphs[glyphId];
  34765. if (!fn) {
  34766. try {
  34767. fn = this.compileGlyph(this.glyphs[glyphId], glyphId);
  34768. this.compiledGlyphs[glyphId] = fn;
  34769. } catch (ex) {
  34770. this.compiledGlyphs[glyphId] = NOOP;
  34771. if (this.compiledCharCodeToGlyphId[charCode] === undefined) {
  34772. this.compiledCharCodeToGlyphId[charCode] = glyphId;
  34773. }
  34774. throw ex;
  34775. }
  34776. }
  34777. if (this.compiledCharCodeToGlyphId[charCode] === undefined) {
  34778. this.compiledCharCodeToGlyphId[charCode] = glyphId;
  34779. }
  34780. return fn;
  34781. }
  34782. compileGlyph(code, glyphId) {
  34783. if (!code || code.length === 0 || code[0] === 14) {
  34784. return NOOP;
  34785. }
  34786. let fontMatrix = this.fontMatrix;
  34787. if (this.isCFFCIDFont) {
  34788. const fdIndex = this.fdSelect.getFDIndex(glyphId);
  34789. if (fdIndex >= 0 && fdIndex < this.fdArray.length) {
  34790. const fontDict = this.fdArray[fdIndex];
  34791. fontMatrix = fontDict.getByName("FontMatrix") || _util.FONT_IDENTITY_MATRIX;
  34792. } else {
  34793. (0, _util.warn)("Invalid fd index for glyph index.");
  34794. }
  34795. }
  34796. const cmds = [{
  34797. cmd: "save"
  34798. }, {
  34799. cmd: "transform",
  34800. args: fontMatrix.slice()
  34801. }, {
  34802. cmd: "scale",
  34803. args: ["size", "-size"]
  34804. }];
  34805. this.compileGlyphImpl(code, cmds, glyphId);
  34806. cmds.push({
  34807. cmd: "restore"
  34808. });
  34809. return cmds;
  34810. }
  34811. compileGlyphImpl() {
  34812. (0, _util.unreachable)("Children classes should implement this.");
  34813. }
  34814. hasBuiltPath(unicode) {
  34815. const {
  34816. charCode,
  34817. glyphId
  34818. } = lookupCmap(this.cmap, unicode);
  34819. return this.compiledGlyphs[glyphId] !== undefined && this.compiledCharCodeToGlyphId[charCode] !== undefined;
  34820. }
  34821. }
  34822. class TrueTypeCompiled extends CompiledFont {
  34823. constructor(glyphs, cmap, fontMatrix) {
  34824. super(fontMatrix || [0.000488, 0, 0, 0.000488, 0, 0]);
  34825. this.glyphs = glyphs;
  34826. this.cmap = cmap;
  34827. }
  34828. compileGlyphImpl(code, cmds) {
  34829. compileGlyf(code, cmds, this);
  34830. }
  34831. }
  34832. class Type2Compiled extends CompiledFont {
  34833. constructor(cffInfo, cmap, fontMatrix, glyphNameMap) {
  34834. super(fontMatrix || [0.001, 0, 0, 0.001, 0, 0]);
  34835. this.glyphs = cffInfo.glyphs;
  34836. this.gsubrs = cffInfo.gsubrs || [];
  34837. this.subrs = cffInfo.subrs || [];
  34838. this.cmap = cmap;
  34839. this.glyphNameMap = glyphNameMap || (0, _glyphlist.getGlyphsUnicode)();
  34840. this.gsubrsBias = getSubroutineBias(this.gsubrs);
  34841. this.subrsBias = getSubroutineBias(this.subrs);
  34842. this.isCFFCIDFont = cffInfo.isCFFCIDFont;
  34843. this.fdSelect = cffInfo.fdSelect;
  34844. this.fdArray = cffInfo.fdArray;
  34845. }
  34846. compileGlyphImpl(code, cmds, glyphId) {
  34847. compileCharString(code, cmds, this, glyphId);
  34848. }
  34849. }
  34850. class FontRendererFactory {
  34851. static create(font, seacAnalysisEnabled) {
  34852. const data = new Uint8Array(font.data);
  34853. let cmap, glyf, loca, cff, indexToLocFormat, unitsPerEm;
  34854. const numTables = getUint16(data, 4);
  34855. for (let i = 0, p = 12; i < numTables; i++, p += 16) {
  34856. const tag = (0, _util.bytesToString)(data.subarray(p, p + 4));
  34857. const offset = getUint32(data, p + 8);
  34858. const length = getUint32(data, p + 12);
  34859. switch (tag) {
  34860. case "cmap":
  34861. cmap = parseCmap(data, offset, offset + length);
  34862. break;
  34863. case "glyf":
  34864. glyf = data.subarray(offset, offset + length);
  34865. break;
  34866. case "loca":
  34867. loca = data.subarray(offset, offset + length);
  34868. break;
  34869. case "head":
  34870. unitsPerEm = getUint16(data, offset + 18);
  34871. indexToLocFormat = getUint16(data, offset + 50);
  34872. break;
  34873. case "CFF ":
  34874. cff = parseCff(data, offset, offset + length, seacAnalysisEnabled);
  34875. break;
  34876. }
  34877. }
  34878. if (glyf) {
  34879. const fontMatrix = !unitsPerEm ? font.fontMatrix : [1 / unitsPerEm, 0, 0, 1 / unitsPerEm, 0, 0];
  34880. return new TrueTypeCompiled(parseGlyfTable(glyf, loca, indexToLocFormat), cmap, fontMatrix);
  34881. }
  34882. return new Type2Compiled(cff, cmap, font.fontMatrix, font.glyphNameMap);
  34883. }
  34884. }
  34885. exports.FontRendererFactory = FontRendererFactory;
  34886. /***/ }),
  34887. /* 196 */
  34888. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  34889. Object.defineProperty(exports, "__esModule", ({
  34890. value: true
  34891. }));
  34892. exports.getMetrics = exports.getFontBasicMetrics = void 0;
  34893. var _core_utils = __w_pdfjs_require__(150);
  34894. const getMetrics = (0, _core_utils.getLookupTableFactory)(function (t) {
  34895. t.Courier = 600;
  34896. t["Courier-Bold"] = 600;
  34897. t["Courier-BoldOblique"] = 600;
  34898. t["Courier-Oblique"] = 600;
  34899. t.Helvetica = (0, _core_utils.getLookupTableFactory)(function (t) {
  34900. t.space = 278;
  34901. t.exclam = 278;
  34902. t.quotedbl = 355;
  34903. t.numbersign = 556;
  34904. t.dollar = 556;
  34905. t.percent = 889;
  34906. t.ampersand = 667;
  34907. t.quoteright = 222;
  34908. t.parenleft = 333;
  34909. t.parenright = 333;
  34910. t.asterisk = 389;
  34911. t.plus = 584;
  34912. t.comma = 278;
  34913. t.hyphen = 333;
  34914. t.period = 278;
  34915. t.slash = 278;
  34916. t.zero = 556;
  34917. t.one = 556;
  34918. t.two = 556;
  34919. t.three = 556;
  34920. t.four = 556;
  34921. t.five = 556;
  34922. t.six = 556;
  34923. t.seven = 556;
  34924. t.eight = 556;
  34925. t.nine = 556;
  34926. t.colon = 278;
  34927. t.semicolon = 278;
  34928. t.less = 584;
  34929. t.equal = 584;
  34930. t.greater = 584;
  34931. t.question = 556;
  34932. t.at = 1015;
  34933. t.A = 667;
  34934. t.B = 667;
  34935. t.C = 722;
  34936. t.D = 722;
  34937. t.E = 667;
  34938. t.F = 611;
  34939. t.G = 778;
  34940. t.H = 722;
  34941. t.I = 278;
  34942. t.J = 500;
  34943. t.K = 667;
  34944. t.L = 556;
  34945. t.M = 833;
  34946. t.N = 722;
  34947. t.O = 778;
  34948. t.P = 667;
  34949. t.Q = 778;
  34950. t.R = 722;
  34951. t.S = 667;
  34952. t.T = 611;
  34953. t.U = 722;
  34954. t.V = 667;
  34955. t.W = 944;
  34956. t.X = 667;
  34957. t.Y = 667;
  34958. t.Z = 611;
  34959. t.bracketleft = 278;
  34960. t.backslash = 278;
  34961. t.bracketright = 278;
  34962. t.asciicircum = 469;
  34963. t.underscore = 556;
  34964. t.quoteleft = 222;
  34965. t.a = 556;
  34966. t.b = 556;
  34967. t.c = 500;
  34968. t.d = 556;
  34969. t.e = 556;
  34970. t.f = 278;
  34971. t.g = 556;
  34972. t.h = 556;
  34973. t.i = 222;
  34974. t.j = 222;
  34975. t.k = 500;
  34976. t.l = 222;
  34977. t.m = 833;
  34978. t.n = 556;
  34979. t.o = 556;
  34980. t.p = 556;
  34981. t.q = 556;
  34982. t.r = 333;
  34983. t.s = 500;
  34984. t.t = 278;
  34985. t.u = 556;
  34986. t.v = 500;
  34987. t.w = 722;
  34988. t.x = 500;
  34989. t.y = 500;
  34990. t.z = 500;
  34991. t.braceleft = 334;
  34992. t.bar = 260;
  34993. t.braceright = 334;
  34994. t.asciitilde = 584;
  34995. t.exclamdown = 333;
  34996. t.cent = 556;
  34997. t.sterling = 556;
  34998. t.fraction = 167;
  34999. t.yen = 556;
  35000. t.florin = 556;
  35001. t.section = 556;
  35002. t.currency = 556;
  35003. t.quotesingle = 191;
  35004. t.quotedblleft = 333;
  35005. t.guillemotleft = 556;
  35006. t.guilsinglleft = 333;
  35007. t.guilsinglright = 333;
  35008. t.fi = 500;
  35009. t.fl = 500;
  35010. t.endash = 556;
  35011. t.dagger = 556;
  35012. t.daggerdbl = 556;
  35013. t.periodcentered = 278;
  35014. t.paragraph = 537;
  35015. t.bullet = 350;
  35016. t.quotesinglbase = 222;
  35017. t.quotedblbase = 333;
  35018. t.quotedblright = 333;
  35019. t.guillemotright = 556;
  35020. t.ellipsis = 1000;
  35021. t.perthousand = 1000;
  35022. t.questiondown = 611;
  35023. t.grave = 333;
  35024. t.acute = 333;
  35025. t.circumflex = 333;
  35026. t.tilde = 333;
  35027. t.macron = 333;
  35028. t.breve = 333;
  35029. t.dotaccent = 333;
  35030. t.dieresis = 333;
  35031. t.ring = 333;
  35032. t.cedilla = 333;
  35033. t.hungarumlaut = 333;
  35034. t.ogonek = 333;
  35035. t.caron = 333;
  35036. t.emdash = 1000;
  35037. t.AE = 1000;
  35038. t.ordfeminine = 370;
  35039. t.Lslash = 556;
  35040. t.Oslash = 778;
  35041. t.OE = 1000;
  35042. t.ordmasculine = 365;
  35043. t.ae = 889;
  35044. t.dotlessi = 278;
  35045. t.lslash = 222;
  35046. t.oslash = 611;
  35047. t.oe = 944;
  35048. t.germandbls = 611;
  35049. t.Idieresis = 278;
  35050. t.eacute = 556;
  35051. t.abreve = 556;
  35052. t.uhungarumlaut = 556;
  35053. t.ecaron = 556;
  35054. t.Ydieresis = 667;
  35055. t.divide = 584;
  35056. t.Yacute = 667;
  35057. t.Acircumflex = 667;
  35058. t.aacute = 556;
  35059. t.Ucircumflex = 722;
  35060. t.yacute = 500;
  35061. t.scommaaccent = 500;
  35062. t.ecircumflex = 556;
  35063. t.Uring = 722;
  35064. t.Udieresis = 722;
  35065. t.aogonek = 556;
  35066. t.Uacute = 722;
  35067. t.uogonek = 556;
  35068. t.Edieresis = 667;
  35069. t.Dcroat = 722;
  35070. t.commaaccent = 250;
  35071. t.copyright = 737;
  35072. t.Emacron = 667;
  35073. t.ccaron = 500;
  35074. t.aring = 556;
  35075. t.Ncommaaccent = 722;
  35076. t.lacute = 222;
  35077. t.agrave = 556;
  35078. t.Tcommaaccent = 611;
  35079. t.Cacute = 722;
  35080. t.atilde = 556;
  35081. t.Edotaccent = 667;
  35082. t.scaron = 500;
  35083. t.scedilla = 500;
  35084. t.iacute = 278;
  35085. t.lozenge = 471;
  35086. t.Rcaron = 722;
  35087. t.Gcommaaccent = 778;
  35088. t.ucircumflex = 556;
  35089. t.acircumflex = 556;
  35090. t.Amacron = 667;
  35091. t.rcaron = 333;
  35092. t.ccedilla = 500;
  35093. t.Zdotaccent = 611;
  35094. t.Thorn = 667;
  35095. t.Omacron = 778;
  35096. t.Racute = 722;
  35097. t.Sacute = 667;
  35098. t.dcaron = 643;
  35099. t.Umacron = 722;
  35100. t.uring = 556;
  35101. t.threesuperior = 333;
  35102. t.Ograve = 778;
  35103. t.Agrave = 667;
  35104. t.Abreve = 667;
  35105. t.multiply = 584;
  35106. t.uacute = 556;
  35107. t.Tcaron = 611;
  35108. t.partialdiff = 476;
  35109. t.ydieresis = 500;
  35110. t.Nacute = 722;
  35111. t.icircumflex = 278;
  35112. t.Ecircumflex = 667;
  35113. t.adieresis = 556;
  35114. t.edieresis = 556;
  35115. t.cacute = 500;
  35116. t.nacute = 556;
  35117. t.umacron = 556;
  35118. t.Ncaron = 722;
  35119. t.Iacute = 278;
  35120. t.plusminus = 584;
  35121. t.brokenbar = 260;
  35122. t.registered = 737;
  35123. t.Gbreve = 778;
  35124. t.Idotaccent = 278;
  35125. t.summation = 600;
  35126. t.Egrave = 667;
  35127. t.racute = 333;
  35128. t.omacron = 556;
  35129. t.Zacute = 611;
  35130. t.Zcaron = 611;
  35131. t.greaterequal = 549;
  35132. t.Eth = 722;
  35133. t.Ccedilla = 722;
  35134. t.lcommaaccent = 222;
  35135. t.tcaron = 317;
  35136. t.eogonek = 556;
  35137. t.Uogonek = 722;
  35138. t.Aacute = 667;
  35139. t.Adieresis = 667;
  35140. t.egrave = 556;
  35141. t.zacute = 500;
  35142. t.iogonek = 222;
  35143. t.Oacute = 778;
  35144. t.oacute = 556;
  35145. t.amacron = 556;
  35146. t.sacute = 500;
  35147. t.idieresis = 278;
  35148. t.Ocircumflex = 778;
  35149. t.Ugrave = 722;
  35150. t.Delta = 612;
  35151. t.thorn = 556;
  35152. t.twosuperior = 333;
  35153. t.Odieresis = 778;
  35154. t.mu = 556;
  35155. t.igrave = 278;
  35156. t.ohungarumlaut = 556;
  35157. t.Eogonek = 667;
  35158. t.dcroat = 556;
  35159. t.threequarters = 834;
  35160. t.Scedilla = 667;
  35161. t.lcaron = 299;
  35162. t.Kcommaaccent = 667;
  35163. t.Lacute = 556;
  35164. t.trademark = 1000;
  35165. t.edotaccent = 556;
  35166. t.Igrave = 278;
  35167. t.Imacron = 278;
  35168. t.Lcaron = 556;
  35169. t.onehalf = 834;
  35170. t.lessequal = 549;
  35171. t.ocircumflex = 556;
  35172. t.ntilde = 556;
  35173. t.Uhungarumlaut = 722;
  35174. t.Eacute = 667;
  35175. t.emacron = 556;
  35176. t.gbreve = 556;
  35177. t.onequarter = 834;
  35178. t.Scaron = 667;
  35179. t.Scommaaccent = 667;
  35180. t.Ohungarumlaut = 778;
  35181. t.degree = 400;
  35182. t.ograve = 556;
  35183. t.Ccaron = 722;
  35184. t.ugrave = 556;
  35185. t.radical = 453;
  35186. t.Dcaron = 722;
  35187. t.rcommaaccent = 333;
  35188. t.Ntilde = 722;
  35189. t.otilde = 556;
  35190. t.Rcommaaccent = 722;
  35191. t.Lcommaaccent = 556;
  35192. t.Atilde = 667;
  35193. t.Aogonek = 667;
  35194. t.Aring = 667;
  35195. t.Otilde = 778;
  35196. t.zdotaccent = 500;
  35197. t.Ecaron = 667;
  35198. t.Iogonek = 278;
  35199. t.kcommaaccent = 500;
  35200. t.minus = 584;
  35201. t.Icircumflex = 278;
  35202. t.ncaron = 556;
  35203. t.tcommaaccent = 278;
  35204. t.logicalnot = 584;
  35205. t.odieresis = 556;
  35206. t.udieresis = 556;
  35207. t.notequal = 549;
  35208. t.gcommaaccent = 556;
  35209. t.eth = 556;
  35210. t.zcaron = 500;
  35211. t.ncommaaccent = 556;
  35212. t.onesuperior = 333;
  35213. t.imacron = 278;
  35214. t.Euro = 556;
  35215. });
  35216. t["Helvetica-Bold"] = (0, _core_utils.getLookupTableFactory)(function (t) {
  35217. t.space = 278;
  35218. t.exclam = 333;
  35219. t.quotedbl = 474;
  35220. t.numbersign = 556;
  35221. t.dollar = 556;
  35222. t.percent = 889;
  35223. t.ampersand = 722;
  35224. t.quoteright = 278;
  35225. t.parenleft = 333;
  35226. t.parenright = 333;
  35227. t.asterisk = 389;
  35228. t.plus = 584;
  35229. t.comma = 278;
  35230. t.hyphen = 333;
  35231. t.period = 278;
  35232. t.slash = 278;
  35233. t.zero = 556;
  35234. t.one = 556;
  35235. t.two = 556;
  35236. t.three = 556;
  35237. t.four = 556;
  35238. t.five = 556;
  35239. t.six = 556;
  35240. t.seven = 556;
  35241. t.eight = 556;
  35242. t.nine = 556;
  35243. t.colon = 333;
  35244. t.semicolon = 333;
  35245. t.less = 584;
  35246. t.equal = 584;
  35247. t.greater = 584;
  35248. t.question = 611;
  35249. t.at = 975;
  35250. t.A = 722;
  35251. t.B = 722;
  35252. t.C = 722;
  35253. t.D = 722;
  35254. t.E = 667;
  35255. t.F = 611;
  35256. t.G = 778;
  35257. t.H = 722;
  35258. t.I = 278;
  35259. t.J = 556;
  35260. t.K = 722;
  35261. t.L = 611;
  35262. t.M = 833;
  35263. t.N = 722;
  35264. t.O = 778;
  35265. t.P = 667;
  35266. t.Q = 778;
  35267. t.R = 722;
  35268. t.S = 667;
  35269. t.T = 611;
  35270. t.U = 722;
  35271. t.V = 667;
  35272. t.W = 944;
  35273. t.X = 667;
  35274. t.Y = 667;
  35275. t.Z = 611;
  35276. t.bracketleft = 333;
  35277. t.backslash = 278;
  35278. t.bracketright = 333;
  35279. t.asciicircum = 584;
  35280. t.underscore = 556;
  35281. t.quoteleft = 278;
  35282. t.a = 556;
  35283. t.b = 611;
  35284. t.c = 556;
  35285. t.d = 611;
  35286. t.e = 556;
  35287. t.f = 333;
  35288. t.g = 611;
  35289. t.h = 611;
  35290. t.i = 278;
  35291. t.j = 278;
  35292. t.k = 556;
  35293. t.l = 278;
  35294. t.m = 889;
  35295. t.n = 611;
  35296. t.o = 611;
  35297. t.p = 611;
  35298. t.q = 611;
  35299. t.r = 389;
  35300. t.s = 556;
  35301. t.t = 333;
  35302. t.u = 611;
  35303. t.v = 556;
  35304. t.w = 778;
  35305. t.x = 556;
  35306. t.y = 556;
  35307. t.z = 500;
  35308. t.braceleft = 389;
  35309. t.bar = 280;
  35310. t.braceright = 389;
  35311. t.asciitilde = 584;
  35312. t.exclamdown = 333;
  35313. t.cent = 556;
  35314. t.sterling = 556;
  35315. t.fraction = 167;
  35316. t.yen = 556;
  35317. t.florin = 556;
  35318. t.section = 556;
  35319. t.currency = 556;
  35320. t.quotesingle = 238;
  35321. t.quotedblleft = 500;
  35322. t.guillemotleft = 556;
  35323. t.guilsinglleft = 333;
  35324. t.guilsinglright = 333;
  35325. t.fi = 611;
  35326. t.fl = 611;
  35327. t.endash = 556;
  35328. t.dagger = 556;
  35329. t.daggerdbl = 556;
  35330. t.periodcentered = 278;
  35331. t.paragraph = 556;
  35332. t.bullet = 350;
  35333. t.quotesinglbase = 278;
  35334. t.quotedblbase = 500;
  35335. t.quotedblright = 500;
  35336. t.guillemotright = 556;
  35337. t.ellipsis = 1000;
  35338. t.perthousand = 1000;
  35339. t.questiondown = 611;
  35340. t.grave = 333;
  35341. t.acute = 333;
  35342. t.circumflex = 333;
  35343. t.tilde = 333;
  35344. t.macron = 333;
  35345. t.breve = 333;
  35346. t.dotaccent = 333;
  35347. t.dieresis = 333;
  35348. t.ring = 333;
  35349. t.cedilla = 333;
  35350. t.hungarumlaut = 333;
  35351. t.ogonek = 333;
  35352. t.caron = 333;
  35353. t.emdash = 1000;
  35354. t.AE = 1000;
  35355. t.ordfeminine = 370;
  35356. t.Lslash = 611;
  35357. t.Oslash = 778;
  35358. t.OE = 1000;
  35359. t.ordmasculine = 365;
  35360. t.ae = 889;
  35361. t.dotlessi = 278;
  35362. t.lslash = 278;
  35363. t.oslash = 611;
  35364. t.oe = 944;
  35365. t.germandbls = 611;
  35366. t.Idieresis = 278;
  35367. t.eacute = 556;
  35368. t.abreve = 556;
  35369. t.uhungarumlaut = 611;
  35370. t.ecaron = 556;
  35371. t.Ydieresis = 667;
  35372. t.divide = 584;
  35373. t.Yacute = 667;
  35374. t.Acircumflex = 722;
  35375. t.aacute = 556;
  35376. t.Ucircumflex = 722;
  35377. t.yacute = 556;
  35378. t.scommaaccent = 556;
  35379. t.ecircumflex = 556;
  35380. t.Uring = 722;
  35381. t.Udieresis = 722;
  35382. t.aogonek = 556;
  35383. t.Uacute = 722;
  35384. t.uogonek = 611;
  35385. t.Edieresis = 667;
  35386. t.Dcroat = 722;
  35387. t.commaaccent = 250;
  35388. t.copyright = 737;
  35389. t.Emacron = 667;
  35390. t.ccaron = 556;
  35391. t.aring = 556;
  35392. t.Ncommaaccent = 722;
  35393. t.lacute = 278;
  35394. t.agrave = 556;
  35395. t.Tcommaaccent = 611;
  35396. t.Cacute = 722;
  35397. t.atilde = 556;
  35398. t.Edotaccent = 667;
  35399. t.scaron = 556;
  35400. t.scedilla = 556;
  35401. t.iacute = 278;
  35402. t.lozenge = 494;
  35403. t.Rcaron = 722;
  35404. t.Gcommaaccent = 778;
  35405. t.ucircumflex = 611;
  35406. t.acircumflex = 556;
  35407. t.Amacron = 722;
  35408. t.rcaron = 389;
  35409. t.ccedilla = 556;
  35410. t.Zdotaccent = 611;
  35411. t.Thorn = 667;
  35412. t.Omacron = 778;
  35413. t.Racute = 722;
  35414. t.Sacute = 667;
  35415. t.dcaron = 743;
  35416. t.Umacron = 722;
  35417. t.uring = 611;
  35418. t.threesuperior = 333;
  35419. t.Ograve = 778;
  35420. t.Agrave = 722;
  35421. t.Abreve = 722;
  35422. t.multiply = 584;
  35423. t.uacute = 611;
  35424. t.Tcaron = 611;
  35425. t.partialdiff = 494;
  35426. t.ydieresis = 556;
  35427. t.Nacute = 722;
  35428. t.icircumflex = 278;
  35429. t.Ecircumflex = 667;
  35430. t.adieresis = 556;
  35431. t.edieresis = 556;
  35432. t.cacute = 556;
  35433. t.nacute = 611;
  35434. t.umacron = 611;
  35435. t.Ncaron = 722;
  35436. t.Iacute = 278;
  35437. t.plusminus = 584;
  35438. t.brokenbar = 280;
  35439. t.registered = 737;
  35440. t.Gbreve = 778;
  35441. t.Idotaccent = 278;
  35442. t.summation = 600;
  35443. t.Egrave = 667;
  35444. t.racute = 389;
  35445. t.omacron = 611;
  35446. t.Zacute = 611;
  35447. t.Zcaron = 611;
  35448. t.greaterequal = 549;
  35449. t.Eth = 722;
  35450. t.Ccedilla = 722;
  35451. t.lcommaaccent = 278;
  35452. t.tcaron = 389;
  35453. t.eogonek = 556;
  35454. t.Uogonek = 722;
  35455. t.Aacute = 722;
  35456. t.Adieresis = 722;
  35457. t.egrave = 556;
  35458. t.zacute = 500;
  35459. t.iogonek = 278;
  35460. t.Oacute = 778;
  35461. t.oacute = 611;
  35462. t.amacron = 556;
  35463. t.sacute = 556;
  35464. t.idieresis = 278;
  35465. t.Ocircumflex = 778;
  35466. t.Ugrave = 722;
  35467. t.Delta = 612;
  35468. t.thorn = 611;
  35469. t.twosuperior = 333;
  35470. t.Odieresis = 778;
  35471. t.mu = 611;
  35472. t.igrave = 278;
  35473. t.ohungarumlaut = 611;
  35474. t.Eogonek = 667;
  35475. t.dcroat = 611;
  35476. t.threequarters = 834;
  35477. t.Scedilla = 667;
  35478. t.lcaron = 400;
  35479. t.Kcommaaccent = 722;
  35480. t.Lacute = 611;
  35481. t.trademark = 1000;
  35482. t.edotaccent = 556;
  35483. t.Igrave = 278;
  35484. t.Imacron = 278;
  35485. t.Lcaron = 611;
  35486. t.onehalf = 834;
  35487. t.lessequal = 549;
  35488. t.ocircumflex = 611;
  35489. t.ntilde = 611;
  35490. t.Uhungarumlaut = 722;
  35491. t.Eacute = 667;
  35492. t.emacron = 556;
  35493. t.gbreve = 611;
  35494. t.onequarter = 834;
  35495. t.Scaron = 667;
  35496. t.Scommaaccent = 667;
  35497. t.Ohungarumlaut = 778;
  35498. t.degree = 400;
  35499. t.ograve = 611;
  35500. t.Ccaron = 722;
  35501. t.ugrave = 611;
  35502. t.radical = 549;
  35503. t.Dcaron = 722;
  35504. t.rcommaaccent = 389;
  35505. t.Ntilde = 722;
  35506. t.otilde = 611;
  35507. t.Rcommaaccent = 722;
  35508. t.Lcommaaccent = 611;
  35509. t.Atilde = 722;
  35510. t.Aogonek = 722;
  35511. t.Aring = 722;
  35512. t.Otilde = 778;
  35513. t.zdotaccent = 500;
  35514. t.Ecaron = 667;
  35515. t.Iogonek = 278;
  35516. t.kcommaaccent = 556;
  35517. t.minus = 584;
  35518. t.Icircumflex = 278;
  35519. t.ncaron = 611;
  35520. t.tcommaaccent = 333;
  35521. t.logicalnot = 584;
  35522. t.odieresis = 611;
  35523. t.udieresis = 611;
  35524. t.notequal = 549;
  35525. t.gcommaaccent = 611;
  35526. t.eth = 611;
  35527. t.zcaron = 500;
  35528. t.ncommaaccent = 611;
  35529. t.onesuperior = 333;
  35530. t.imacron = 278;
  35531. t.Euro = 556;
  35532. });
  35533. t["Helvetica-BoldOblique"] = (0, _core_utils.getLookupTableFactory)(function (t) {
  35534. t.space = 278;
  35535. t.exclam = 333;
  35536. t.quotedbl = 474;
  35537. t.numbersign = 556;
  35538. t.dollar = 556;
  35539. t.percent = 889;
  35540. t.ampersand = 722;
  35541. t.quoteright = 278;
  35542. t.parenleft = 333;
  35543. t.parenright = 333;
  35544. t.asterisk = 389;
  35545. t.plus = 584;
  35546. t.comma = 278;
  35547. t.hyphen = 333;
  35548. t.period = 278;
  35549. t.slash = 278;
  35550. t.zero = 556;
  35551. t.one = 556;
  35552. t.two = 556;
  35553. t.three = 556;
  35554. t.four = 556;
  35555. t.five = 556;
  35556. t.six = 556;
  35557. t.seven = 556;
  35558. t.eight = 556;
  35559. t.nine = 556;
  35560. t.colon = 333;
  35561. t.semicolon = 333;
  35562. t.less = 584;
  35563. t.equal = 584;
  35564. t.greater = 584;
  35565. t.question = 611;
  35566. t.at = 975;
  35567. t.A = 722;
  35568. t.B = 722;
  35569. t.C = 722;
  35570. t.D = 722;
  35571. t.E = 667;
  35572. t.F = 611;
  35573. t.G = 778;
  35574. t.H = 722;
  35575. t.I = 278;
  35576. t.J = 556;
  35577. t.K = 722;
  35578. t.L = 611;
  35579. t.M = 833;
  35580. t.N = 722;
  35581. t.O = 778;
  35582. t.P = 667;
  35583. t.Q = 778;
  35584. t.R = 722;
  35585. t.S = 667;
  35586. t.T = 611;
  35587. t.U = 722;
  35588. t.V = 667;
  35589. t.W = 944;
  35590. t.X = 667;
  35591. t.Y = 667;
  35592. t.Z = 611;
  35593. t.bracketleft = 333;
  35594. t.backslash = 278;
  35595. t.bracketright = 333;
  35596. t.asciicircum = 584;
  35597. t.underscore = 556;
  35598. t.quoteleft = 278;
  35599. t.a = 556;
  35600. t.b = 611;
  35601. t.c = 556;
  35602. t.d = 611;
  35603. t.e = 556;
  35604. t.f = 333;
  35605. t.g = 611;
  35606. t.h = 611;
  35607. t.i = 278;
  35608. t.j = 278;
  35609. t.k = 556;
  35610. t.l = 278;
  35611. t.m = 889;
  35612. t.n = 611;
  35613. t.o = 611;
  35614. t.p = 611;
  35615. t.q = 611;
  35616. t.r = 389;
  35617. t.s = 556;
  35618. t.t = 333;
  35619. t.u = 611;
  35620. t.v = 556;
  35621. t.w = 778;
  35622. t.x = 556;
  35623. t.y = 556;
  35624. t.z = 500;
  35625. t.braceleft = 389;
  35626. t.bar = 280;
  35627. t.braceright = 389;
  35628. t.asciitilde = 584;
  35629. t.exclamdown = 333;
  35630. t.cent = 556;
  35631. t.sterling = 556;
  35632. t.fraction = 167;
  35633. t.yen = 556;
  35634. t.florin = 556;
  35635. t.section = 556;
  35636. t.currency = 556;
  35637. t.quotesingle = 238;
  35638. t.quotedblleft = 500;
  35639. t.guillemotleft = 556;
  35640. t.guilsinglleft = 333;
  35641. t.guilsinglright = 333;
  35642. t.fi = 611;
  35643. t.fl = 611;
  35644. t.endash = 556;
  35645. t.dagger = 556;
  35646. t.daggerdbl = 556;
  35647. t.periodcentered = 278;
  35648. t.paragraph = 556;
  35649. t.bullet = 350;
  35650. t.quotesinglbase = 278;
  35651. t.quotedblbase = 500;
  35652. t.quotedblright = 500;
  35653. t.guillemotright = 556;
  35654. t.ellipsis = 1000;
  35655. t.perthousand = 1000;
  35656. t.questiondown = 611;
  35657. t.grave = 333;
  35658. t.acute = 333;
  35659. t.circumflex = 333;
  35660. t.tilde = 333;
  35661. t.macron = 333;
  35662. t.breve = 333;
  35663. t.dotaccent = 333;
  35664. t.dieresis = 333;
  35665. t.ring = 333;
  35666. t.cedilla = 333;
  35667. t.hungarumlaut = 333;
  35668. t.ogonek = 333;
  35669. t.caron = 333;
  35670. t.emdash = 1000;
  35671. t.AE = 1000;
  35672. t.ordfeminine = 370;
  35673. t.Lslash = 611;
  35674. t.Oslash = 778;
  35675. t.OE = 1000;
  35676. t.ordmasculine = 365;
  35677. t.ae = 889;
  35678. t.dotlessi = 278;
  35679. t.lslash = 278;
  35680. t.oslash = 611;
  35681. t.oe = 944;
  35682. t.germandbls = 611;
  35683. t.Idieresis = 278;
  35684. t.eacute = 556;
  35685. t.abreve = 556;
  35686. t.uhungarumlaut = 611;
  35687. t.ecaron = 556;
  35688. t.Ydieresis = 667;
  35689. t.divide = 584;
  35690. t.Yacute = 667;
  35691. t.Acircumflex = 722;
  35692. t.aacute = 556;
  35693. t.Ucircumflex = 722;
  35694. t.yacute = 556;
  35695. t.scommaaccent = 556;
  35696. t.ecircumflex = 556;
  35697. t.Uring = 722;
  35698. t.Udieresis = 722;
  35699. t.aogonek = 556;
  35700. t.Uacute = 722;
  35701. t.uogonek = 611;
  35702. t.Edieresis = 667;
  35703. t.Dcroat = 722;
  35704. t.commaaccent = 250;
  35705. t.copyright = 737;
  35706. t.Emacron = 667;
  35707. t.ccaron = 556;
  35708. t.aring = 556;
  35709. t.Ncommaaccent = 722;
  35710. t.lacute = 278;
  35711. t.agrave = 556;
  35712. t.Tcommaaccent = 611;
  35713. t.Cacute = 722;
  35714. t.atilde = 556;
  35715. t.Edotaccent = 667;
  35716. t.scaron = 556;
  35717. t.scedilla = 556;
  35718. t.iacute = 278;
  35719. t.lozenge = 494;
  35720. t.Rcaron = 722;
  35721. t.Gcommaaccent = 778;
  35722. t.ucircumflex = 611;
  35723. t.acircumflex = 556;
  35724. t.Amacron = 722;
  35725. t.rcaron = 389;
  35726. t.ccedilla = 556;
  35727. t.Zdotaccent = 611;
  35728. t.Thorn = 667;
  35729. t.Omacron = 778;
  35730. t.Racute = 722;
  35731. t.Sacute = 667;
  35732. t.dcaron = 743;
  35733. t.Umacron = 722;
  35734. t.uring = 611;
  35735. t.threesuperior = 333;
  35736. t.Ograve = 778;
  35737. t.Agrave = 722;
  35738. t.Abreve = 722;
  35739. t.multiply = 584;
  35740. t.uacute = 611;
  35741. t.Tcaron = 611;
  35742. t.partialdiff = 494;
  35743. t.ydieresis = 556;
  35744. t.Nacute = 722;
  35745. t.icircumflex = 278;
  35746. t.Ecircumflex = 667;
  35747. t.adieresis = 556;
  35748. t.edieresis = 556;
  35749. t.cacute = 556;
  35750. t.nacute = 611;
  35751. t.umacron = 611;
  35752. t.Ncaron = 722;
  35753. t.Iacute = 278;
  35754. t.plusminus = 584;
  35755. t.brokenbar = 280;
  35756. t.registered = 737;
  35757. t.Gbreve = 778;
  35758. t.Idotaccent = 278;
  35759. t.summation = 600;
  35760. t.Egrave = 667;
  35761. t.racute = 389;
  35762. t.omacron = 611;
  35763. t.Zacute = 611;
  35764. t.Zcaron = 611;
  35765. t.greaterequal = 549;
  35766. t.Eth = 722;
  35767. t.Ccedilla = 722;
  35768. t.lcommaaccent = 278;
  35769. t.tcaron = 389;
  35770. t.eogonek = 556;
  35771. t.Uogonek = 722;
  35772. t.Aacute = 722;
  35773. t.Adieresis = 722;
  35774. t.egrave = 556;
  35775. t.zacute = 500;
  35776. t.iogonek = 278;
  35777. t.Oacute = 778;
  35778. t.oacute = 611;
  35779. t.amacron = 556;
  35780. t.sacute = 556;
  35781. t.idieresis = 278;
  35782. t.Ocircumflex = 778;
  35783. t.Ugrave = 722;
  35784. t.Delta = 612;
  35785. t.thorn = 611;
  35786. t.twosuperior = 333;
  35787. t.Odieresis = 778;
  35788. t.mu = 611;
  35789. t.igrave = 278;
  35790. t.ohungarumlaut = 611;
  35791. t.Eogonek = 667;
  35792. t.dcroat = 611;
  35793. t.threequarters = 834;
  35794. t.Scedilla = 667;
  35795. t.lcaron = 400;
  35796. t.Kcommaaccent = 722;
  35797. t.Lacute = 611;
  35798. t.trademark = 1000;
  35799. t.edotaccent = 556;
  35800. t.Igrave = 278;
  35801. t.Imacron = 278;
  35802. t.Lcaron = 611;
  35803. t.onehalf = 834;
  35804. t.lessequal = 549;
  35805. t.ocircumflex = 611;
  35806. t.ntilde = 611;
  35807. t.Uhungarumlaut = 722;
  35808. t.Eacute = 667;
  35809. t.emacron = 556;
  35810. t.gbreve = 611;
  35811. t.onequarter = 834;
  35812. t.Scaron = 667;
  35813. t.Scommaaccent = 667;
  35814. t.Ohungarumlaut = 778;
  35815. t.degree = 400;
  35816. t.ograve = 611;
  35817. t.Ccaron = 722;
  35818. t.ugrave = 611;
  35819. t.radical = 549;
  35820. t.Dcaron = 722;
  35821. t.rcommaaccent = 389;
  35822. t.Ntilde = 722;
  35823. t.otilde = 611;
  35824. t.Rcommaaccent = 722;
  35825. t.Lcommaaccent = 611;
  35826. t.Atilde = 722;
  35827. t.Aogonek = 722;
  35828. t.Aring = 722;
  35829. t.Otilde = 778;
  35830. t.zdotaccent = 500;
  35831. t.Ecaron = 667;
  35832. t.Iogonek = 278;
  35833. t.kcommaaccent = 556;
  35834. t.minus = 584;
  35835. t.Icircumflex = 278;
  35836. t.ncaron = 611;
  35837. t.tcommaaccent = 333;
  35838. t.logicalnot = 584;
  35839. t.odieresis = 611;
  35840. t.udieresis = 611;
  35841. t.notequal = 549;
  35842. t.gcommaaccent = 611;
  35843. t.eth = 611;
  35844. t.zcaron = 500;
  35845. t.ncommaaccent = 611;
  35846. t.onesuperior = 333;
  35847. t.imacron = 278;
  35848. t.Euro = 556;
  35849. });
  35850. t["Helvetica-Oblique"] = (0, _core_utils.getLookupTableFactory)(function (t) {
  35851. t.space = 278;
  35852. t.exclam = 278;
  35853. t.quotedbl = 355;
  35854. t.numbersign = 556;
  35855. t.dollar = 556;
  35856. t.percent = 889;
  35857. t.ampersand = 667;
  35858. t.quoteright = 222;
  35859. t.parenleft = 333;
  35860. t.parenright = 333;
  35861. t.asterisk = 389;
  35862. t.plus = 584;
  35863. t.comma = 278;
  35864. t.hyphen = 333;
  35865. t.period = 278;
  35866. t.slash = 278;
  35867. t.zero = 556;
  35868. t.one = 556;
  35869. t.two = 556;
  35870. t.three = 556;
  35871. t.four = 556;
  35872. t.five = 556;
  35873. t.six = 556;
  35874. t.seven = 556;
  35875. t.eight = 556;
  35876. t.nine = 556;
  35877. t.colon = 278;
  35878. t.semicolon = 278;
  35879. t.less = 584;
  35880. t.equal = 584;
  35881. t.greater = 584;
  35882. t.question = 556;
  35883. t.at = 1015;
  35884. t.A = 667;
  35885. t.B = 667;
  35886. t.C = 722;
  35887. t.D = 722;
  35888. t.E = 667;
  35889. t.F = 611;
  35890. t.G = 778;
  35891. t.H = 722;
  35892. t.I = 278;
  35893. t.J = 500;
  35894. t.K = 667;
  35895. t.L = 556;
  35896. t.M = 833;
  35897. t.N = 722;
  35898. t.O = 778;
  35899. t.P = 667;
  35900. t.Q = 778;
  35901. t.R = 722;
  35902. t.S = 667;
  35903. t.T = 611;
  35904. t.U = 722;
  35905. t.V = 667;
  35906. t.W = 944;
  35907. t.X = 667;
  35908. t.Y = 667;
  35909. t.Z = 611;
  35910. t.bracketleft = 278;
  35911. t.backslash = 278;
  35912. t.bracketright = 278;
  35913. t.asciicircum = 469;
  35914. t.underscore = 556;
  35915. t.quoteleft = 222;
  35916. t.a = 556;
  35917. t.b = 556;
  35918. t.c = 500;
  35919. t.d = 556;
  35920. t.e = 556;
  35921. t.f = 278;
  35922. t.g = 556;
  35923. t.h = 556;
  35924. t.i = 222;
  35925. t.j = 222;
  35926. t.k = 500;
  35927. t.l = 222;
  35928. t.m = 833;
  35929. t.n = 556;
  35930. t.o = 556;
  35931. t.p = 556;
  35932. t.q = 556;
  35933. t.r = 333;
  35934. t.s = 500;
  35935. t.t = 278;
  35936. t.u = 556;
  35937. t.v = 500;
  35938. t.w = 722;
  35939. t.x = 500;
  35940. t.y = 500;
  35941. t.z = 500;
  35942. t.braceleft = 334;
  35943. t.bar = 260;
  35944. t.braceright = 334;
  35945. t.asciitilde = 584;
  35946. t.exclamdown = 333;
  35947. t.cent = 556;
  35948. t.sterling = 556;
  35949. t.fraction = 167;
  35950. t.yen = 556;
  35951. t.florin = 556;
  35952. t.section = 556;
  35953. t.currency = 556;
  35954. t.quotesingle = 191;
  35955. t.quotedblleft = 333;
  35956. t.guillemotleft = 556;
  35957. t.guilsinglleft = 333;
  35958. t.guilsinglright = 333;
  35959. t.fi = 500;
  35960. t.fl = 500;
  35961. t.endash = 556;
  35962. t.dagger = 556;
  35963. t.daggerdbl = 556;
  35964. t.periodcentered = 278;
  35965. t.paragraph = 537;
  35966. t.bullet = 350;
  35967. t.quotesinglbase = 222;
  35968. t.quotedblbase = 333;
  35969. t.quotedblright = 333;
  35970. t.guillemotright = 556;
  35971. t.ellipsis = 1000;
  35972. t.perthousand = 1000;
  35973. t.questiondown = 611;
  35974. t.grave = 333;
  35975. t.acute = 333;
  35976. t.circumflex = 333;
  35977. t.tilde = 333;
  35978. t.macron = 333;
  35979. t.breve = 333;
  35980. t.dotaccent = 333;
  35981. t.dieresis = 333;
  35982. t.ring = 333;
  35983. t.cedilla = 333;
  35984. t.hungarumlaut = 333;
  35985. t.ogonek = 333;
  35986. t.caron = 333;
  35987. t.emdash = 1000;
  35988. t.AE = 1000;
  35989. t.ordfeminine = 370;
  35990. t.Lslash = 556;
  35991. t.Oslash = 778;
  35992. t.OE = 1000;
  35993. t.ordmasculine = 365;
  35994. t.ae = 889;
  35995. t.dotlessi = 278;
  35996. t.lslash = 222;
  35997. t.oslash = 611;
  35998. t.oe = 944;
  35999. t.germandbls = 611;
  36000. t.Idieresis = 278;
  36001. t.eacute = 556;
  36002. t.abreve = 556;
  36003. t.uhungarumlaut = 556;
  36004. t.ecaron = 556;
  36005. t.Ydieresis = 667;
  36006. t.divide = 584;
  36007. t.Yacute = 667;
  36008. t.Acircumflex = 667;
  36009. t.aacute = 556;
  36010. t.Ucircumflex = 722;
  36011. t.yacute = 500;
  36012. t.scommaaccent = 500;
  36013. t.ecircumflex = 556;
  36014. t.Uring = 722;
  36015. t.Udieresis = 722;
  36016. t.aogonek = 556;
  36017. t.Uacute = 722;
  36018. t.uogonek = 556;
  36019. t.Edieresis = 667;
  36020. t.Dcroat = 722;
  36021. t.commaaccent = 250;
  36022. t.copyright = 737;
  36023. t.Emacron = 667;
  36024. t.ccaron = 500;
  36025. t.aring = 556;
  36026. t.Ncommaaccent = 722;
  36027. t.lacute = 222;
  36028. t.agrave = 556;
  36029. t.Tcommaaccent = 611;
  36030. t.Cacute = 722;
  36031. t.atilde = 556;
  36032. t.Edotaccent = 667;
  36033. t.scaron = 500;
  36034. t.scedilla = 500;
  36035. t.iacute = 278;
  36036. t.lozenge = 471;
  36037. t.Rcaron = 722;
  36038. t.Gcommaaccent = 778;
  36039. t.ucircumflex = 556;
  36040. t.acircumflex = 556;
  36041. t.Amacron = 667;
  36042. t.rcaron = 333;
  36043. t.ccedilla = 500;
  36044. t.Zdotaccent = 611;
  36045. t.Thorn = 667;
  36046. t.Omacron = 778;
  36047. t.Racute = 722;
  36048. t.Sacute = 667;
  36049. t.dcaron = 643;
  36050. t.Umacron = 722;
  36051. t.uring = 556;
  36052. t.threesuperior = 333;
  36053. t.Ograve = 778;
  36054. t.Agrave = 667;
  36055. t.Abreve = 667;
  36056. t.multiply = 584;
  36057. t.uacute = 556;
  36058. t.Tcaron = 611;
  36059. t.partialdiff = 476;
  36060. t.ydieresis = 500;
  36061. t.Nacute = 722;
  36062. t.icircumflex = 278;
  36063. t.Ecircumflex = 667;
  36064. t.adieresis = 556;
  36065. t.edieresis = 556;
  36066. t.cacute = 500;
  36067. t.nacute = 556;
  36068. t.umacron = 556;
  36069. t.Ncaron = 722;
  36070. t.Iacute = 278;
  36071. t.plusminus = 584;
  36072. t.brokenbar = 260;
  36073. t.registered = 737;
  36074. t.Gbreve = 778;
  36075. t.Idotaccent = 278;
  36076. t.summation = 600;
  36077. t.Egrave = 667;
  36078. t.racute = 333;
  36079. t.omacron = 556;
  36080. t.Zacute = 611;
  36081. t.Zcaron = 611;
  36082. t.greaterequal = 549;
  36083. t.Eth = 722;
  36084. t.Ccedilla = 722;
  36085. t.lcommaaccent = 222;
  36086. t.tcaron = 317;
  36087. t.eogonek = 556;
  36088. t.Uogonek = 722;
  36089. t.Aacute = 667;
  36090. t.Adieresis = 667;
  36091. t.egrave = 556;
  36092. t.zacute = 500;
  36093. t.iogonek = 222;
  36094. t.Oacute = 778;
  36095. t.oacute = 556;
  36096. t.amacron = 556;
  36097. t.sacute = 500;
  36098. t.idieresis = 278;
  36099. t.Ocircumflex = 778;
  36100. t.Ugrave = 722;
  36101. t.Delta = 612;
  36102. t.thorn = 556;
  36103. t.twosuperior = 333;
  36104. t.Odieresis = 778;
  36105. t.mu = 556;
  36106. t.igrave = 278;
  36107. t.ohungarumlaut = 556;
  36108. t.Eogonek = 667;
  36109. t.dcroat = 556;
  36110. t.threequarters = 834;
  36111. t.Scedilla = 667;
  36112. t.lcaron = 299;
  36113. t.Kcommaaccent = 667;
  36114. t.Lacute = 556;
  36115. t.trademark = 1000;
  36116. t.edotaccent = 556;
  36117. t.Igrave = 278;
  36118. t.Imacron = 278;
  36119. t.Lcaron = 556;
  36120. t.onehalf = 834;
  36121. t.lessequal = 549;
  36122. t.ocircumflex = 556;
  36123. t.ntilde = 556;
  36124. t.Uhungarumlaut = 722;
  36125. t.Eacute = 667;
  36126. t.emacron = 556;
  36127. t.gbreve = 556;
  36128. t.onequarter = 834;
  36129. t.Scaron = 667;
  36130. t.Scommaaccent = 667;
  36131. t.Ohungarumlaut = 778;
  36132. t.degree = 400;
  36133. t.ograve = 556;
  36134. t.Ccaron = 722;
  36135. t.ugrave = 556;
  36136. t.radical = 453;
  36137. t.Dcaron = 722;
  36138. t.rcommaaccent = 333;
  36139. t.Ntilde = 722;
  36140. t.otilde = 556;
  36141. t.Rcommaaccent = 722;
  36142. t.Lcommaaccent = 556;
  36143. t.Atilde = 667;
  36144. t.Aogonek = 667;
  36145. t.Aring = 667;
  36146. t.Otilde = 778;
  36147. t.zdotaccent = 500;
  36148. t.Ecaron = 667;
  36149. t.Iogonek = 278;
  36150. t.kcommaaccent = 500;
  36151. t.minus = 584;
  36152. t.Icircumflex = 278;
  36153. t.ncaron = 556;
  36154. t.tcommaaccent = 278;
  36155. t.logicalnot = 584;
  36156. t.odieresis = 556;
  36157. t.udieresis = 556;
  36158. t.notequal = 549;
  36159. t.gcommaaccent = 556;
  36160. t.eth = 556;
  36161. t.zcaron = 500;
  36162. t.ncommaaccent = 556;
  36163. t.onesuperior = 333;
  36164. t.imacron = 278;
  36165. t.Euro = 556;
  36166. });
  36167. t.Symbol = (0, _core_utils.getLookupTableFactory)(function (t) {
  36168. t.space = 250;
  36169. t.exclam = 333;
  36170. t.universal = 713;
  36171. t.numbersign = 500;
  36172. t.existential = 549;
  36173. t.percent = 833;
  36174. t.ampersand = 778;
  36175. t.suchthat = 439;
  36176. t.parenleft = 333;
  36177. t.parenright = 333;
  36178. t.asteriskmath = 500;
  36179. t.plus = 549;
  36180. t.comma = 250;
  36181. t.minus = 549;
  36182. t.period = 250;
  36183. t.slash = 278;
  36184. t.zero = 500;
  36185. t.one = 500;
  36186. t.two = 500;
  36187. t.three = 500;
  36188. t.four = 500;
  36189. t.five = 500;
  36190. t.six = 500;
  36191. t.seven = 500;
  36192. t.eight = 500;
  36193. t.nine = 500;
  36194. t.colon = 278;
  36195. t.semicolon = 278;
  36196. t.less = 549;
  36197. t.equal = 549;
  36198. t.greater = 549;
  36199. t.question = 444;
  36200. t.congruent = 549;
  36201. t.Alpha = 722;
  36202. t.Beta = 667;
  36203. t.Chi = 722;
  36204. t.Delta = 612;
  36205. t.Epsilon = 611;
  36206. t.Phi = 763;
  36207. t.Gamma = 603;
  36208. t.Eta = 722;
  36209. t.Iota = 333;
  36210. t.theta1 = 631;
  36211. t.Kappa = 722;
  36212. t.Lambda = 686;
  36213. t.Mu = 889;
  36214. t.Nu = 722;
  36215. t.Omicron = 722;
  36216. t.Pi = 768;
  36217. t.Theta = 741;
  36218. t.Rho = 556;
  36219. t.Sigma = 592;
  36220. t.Tau = 611;
  36221. t.Upsilon = 690;
  36222. t.sigma1 = 439;
  36223. t.Omega = 768;
  36224. t.Xi = 645;
  36225. t.Psi = 795;
  36226. t.Zeta = 611;
  36227. t.bracketleft = 333;
  36228. t.therefore = 863;
  36229. t.bracketright = 333;
  36230. t.perpendicular = 658;
  36231. t.underscore = 500;
  36232. t.radicalex = 500;
  36233. t.alpha = 631;
  36234. t.beta = 549;
  36235. t.chi = 549;
  36236. t.delta = 494;
  36237. t.epsilon = 439;
  36238. t.phi = 521;
  36239. t.gamma = 411;
  36240. t.eta = 603;
  36241. t.iota = 329;
  36242. t.phi1 = 603;
  36243. t.kappa = 549;
  36244. t.lambda = 549;
  36245. t.mu = 576;
  36246. t.nu = 521;
  36247. t.omicron = 549;
  36248. t.pi = 549;
  36249. t.theta = 521;
  36250. t.rho = 549;
  36251. t.sigma = 603;
  36252. t.tau = 439;
  36253. t.upsilon = 576;
  36254. t.omega1 = 713;
  36255. t.omega = 686;
  36256. t.xi = 493;
  36257. t.psi = 686;
  36258. t.zeta = 494;
  36259. t.braceleft = 480;
  36260. t.bar = 200;
  36261. t.braceright = 480;
  36262. t.similar = 549;
  36263. t.Euro = 750;
  36264. t.Upsilon1 = 620;
  36265. t.minute = 247;
  36266. t.lessequal = 549;
  36267. t.fraction = 167;
  36268. t.infinity = 713;
  36269. t.florin = 500;
  36270. t.club = 753;
  36271. t.diamond = 753;
  36272. t.heart = 753;
  36273. t.spade = 753;
  36274. t.arrowboth = 1042;
  36275. t.arrowleft = 987;
  36276. t.arrowup = 603;
  36277. t.arrowright = 987;
  36278. t.arrowdown = 603;
  36279. t.degree = 400;
  36280. t.plusminus = 549;
  36281. t.second = 411;
  36282. t.greaterequal = 549;
  36283. t.multiply = 549;
  36284. t.proportional = 713;
  36285. t.partialdiff = 494;
  36286. t.bullet = 460;
  36287. t.divide = 549;
  36288. t.notequal = 549;
  36289. t.equivalence = 549;
  36290. t.approxequal = 549;
  36291. t.ellipsis = 1000;
  36292. t.arrowvertex = 603;
  36293. t.arrowhorizex = 1000;
  36294. t.carriagereturn = 658;
  36295. t.aleph = 823;
  36296. t.Ifraktur = 686;
  36297. t.Rfraktur = 795;
  36298. t.weierstrass = 987;
  36299. t.circlemultiply = 768;
  36300. t.circleplus = 768;
  36301. t.emptyset = 823;
  36302. t.intersection = 768;
  36303. t.union = 768;
  36304. t.propersuperset = 713;
  36305. t.reflexsuperset = 713;
  36306. t.notsubset = 713;
  36307. t.propersubset = 713;
  36308. t.reflexsubset = 713;
  36309. t.element = 713;
  36310. t.notelement = 713;
  36311. t.angle = 768;
  36312. t.gradient = 713;
  36313. t.registerserif = 790;
  36314. t.copyrightserif = 790;
  36315. t.trademarkserif = 890;
  36316. t.product = 823;
  36317. t.radical = 549;
  36318. t.dotmath = 250;
  36319. t.logicalnot = 713;
  36320. t.logicaland = 603;
  36321. t.logicalor = 603;
  36322. t.arrowdblboth = 1042;
  36323. t.arrowdblleft = 987;
  36324. t.arrowdblup = 603;
  36325. t.arrowdblright = 987;
  36326. t.arrowdbldown = 603;
  36327. t.lozenge = 494;
  36328. t.angleleft = 329;
  36329. t.registersans = 790;
  36330. t.copyrightsans = 790;
  36331. t.trademarksans = 786;
  36332. t.summation = 713;
  36333. t.parenlefttp = 384;
  36334. t.parenleftex = 384;
  36335. t.parenleftbt = 384;
  36336. t.bracketlefttp = 384;
  36337. t.bracketleftex = 384;
  36338. t.bracketleftbt = 384;
  36339. t.bracelefttp = 494;
  36340. t.braceleftmid = 494;
  36341. t.braceleftbt = 494;
  36342. t.braceex = 494;
  36343. t.angleright = 329;
  36344. t.integral = 274;
  36345. t.integraltp = 686;
  36346. t.integralex = 686;
  36347. t.integralbt = 686;
  36348. t.parenrighttp = 384;
  36349. t.parenrightex = 384;
  36350. t.parenrightbt = 384;
  36351. t.bracketrighttp = 384;
  36352. t.bracketrightex = 384;
  36353. t.bracketrightbt = 384;
  36354. t.bracerighttp = 494;
  36355. t.bracerightmid = 494;
  36356. t.bracerightbt = 494;
  36357. t.apple = 790;
  36358. });
  36359. t["Times-Roman"] = (0, _core_utils.getLookupTableFactory)(function (t) {
  36360. t.space = 250;
  36361. t.exclam = 333;
  36362. t.quotedbl = 408;
  36363. t.numbersign = 500;
  36364. t.dollar = 500;
  36365. t.percent = 833;
  36366. t.ampersand = 778;
  36367. t.quoteright = 333;
  36368. t.parenleft = 333;
  36369. t.parenright = 333;
  36370. t.asterisk = 500;
  36371. t.plus = 564;
  36372. t.comma = 250;
  36373. t.hyphen = 333;
  36374. t.period = 250;
  36375. t.slash = 278;
  36376. t.zero = 500;
  36377. t.one = 500;
  36378. t.two = 500;
  36379. t.three = 500;
  36380. t.four = 500;
  36381. t.five = 500;
  36382. t.six = 500;
  36383. t.seven = 500;
  36384. t.eight = 500;
  36385. t.nine = 500;
  36386. t.colon = 278;
  36387. t.semicolon = 278;
  36388. t.less = 564;
  36389. t.equal = 564;
  36390. t.greater = 564;
  36391. t.question = 444;
  36392. t.at = 921;
  36393. t.A = 722;
  36394. t.B = 667;
  36395. t.C = 667;
  36396. t.D = 722;
  36397. t.E = 611;
  36398. t.F = 556;
  36399. t.G = 722;
  36400. t.H = 722;
  36401. t.I = 333;
  36402. t.J = 389;
  36403. t.K = 722;
  36404. t.L = 611;
  36405. t.M = 889;
  36406. t.N = 722;
  36407. t.O = 722;
  36408. t.P = 556;
  36409. t.Q = 722;
  36410. t.R = 667;
  36411. t.S = 556;
  36412. t.T = 611;
  36413. t.U = 722;
  36414. t.V = 722;
  36415. t.W = 944;
  36416. t.X = 722;
  36417. t.Y = 722;
  36418. t.Z = 611;
  36419. t.bracketleft = 333;
  36420. t.backslash = 278;
  36421. t.bracketright = 333;
  36422. t.asciicircum = 469;
  36423. t.underscore = 500;
  36424. t.quoteleft = 333;
  36425. t.a = 444;
  36426. t.b = 500;
  36427. t.c = 444;
  36428. t.d = 500;
  36429. t.e = 444;
  36430. t.f = 333;
  36431. t.g = 500;
  36432. t.h = 500;
  36433. t.i = 278;
  36434. t.j = 278;
  36435. t.k = 500;
  36436. t.l = 278;
  36437. t.m = 778;
  36438. t.n = 500;
  36439. t.o = 500;
  36440. t.p = 500;
  36441. t.q = 500;
  36442. t.r = 333;
  36443. t.s = 389;
  36444. t.t = 278;
  36445. t.u = 500;
  36446. t.v = 500;
  36447. t.w = 722;
  36448. t.x = 500;
  36449. t.y = 500;
  36450. t.z = 444;
  36451. t.braceleft = 480;
  36452. t.bar = 200;
  36453. t.braceright = 480;
  36454. t.asciitilde = 541;
  36455. t.exclamdown = 333;
  36456. t.cent = 500;
  36457. t.sterling = 500;
  36458. t.fraction = 167;
  36459. t.yen = 500;
  36460. t.florin = 500;
  36461. t.section = 500;
  36462. t.currency = 500;
  36463. t.quotesingle = 180;
  36464. t.quotedblleft = 444;
  36465. t.guillemotleft = 500;
  36466. t.guilsinglleft = 333;
  36467. t.guilsinglright = 333;
  36468. t.fi = 556;
  36469. t.fl = 556;
  36470. t.endash = 500;
  36471. t.dagger = 500;
  36472. t.daggerdbl = 500;
  36473. t.periodcentered = 250;
  36474. t.paragraph = 453;
  36475. t.bullet = 350;
  36476. t.quotesinglbase = 333;
  36477. t.quotedblbase = 444;
  36478. t.quotedblright = 444;
  36479. t.guillemotright = 500;
  36480. t.ellipsis = 1000;
  36481. t.perthousand = 1000;
  36482. t.questiondown = 444;
  36483. t.grave = 333;
  36484. t.acute = 333;
  36485. t.circumflex = 333;
  36486. t.tilde = 333;
  36487. t.macron = 333;
  36488. t.breve = 333;
  36489. t.dotaccent = 333;
  36490. t.dieresis = 333;
  36491. t.ring = 333;
  36492. t.cedilla = 333;
  36493. t.hungarumlaut = 333;
  36494. t.ogonek = 333;
  36495. t.caron = 333;
  36496. t.emdash = 1000;
  36497. t.AE = 889;
  36498. t.ordfeminine = 276;
  36499. t.Lslash = 611;
  36500. t.Oslash = 722;
  36501. t.OE = 889;
  36502. t.ordmasculine = 310;
  36503. t.ae = 667;
  36504. t.dotlessi = 278;
  36505. t.lslash = 278;
  36506. t.oslash = 500;
  36507. t.oe = 722;
  36508. t.germandbls = 500;
  36509. t.Idieresis = 333;
  36510. t.eacute = 444;
  36511. t.abreve = 444;
  36512. t.uhungarumlaut = 500;
  36513. t.ecaron = 444;
  36514. t.Ydieresis = 722;
  36515. t.divide = 564;
  36516. t.Yacute = 722;
  36517. t.Acircumflex = 722;
  36518. t.aacute = 444;
  36519. t.Ucircumflex = 722;
  36520. t.yacute = 500;
  36521. t.scommaaccent = 389;
  36522. t.ecircumflex = 444;
  36523. t.Uring = 722;
  36524. t.Udieresis = 722;
  36525. t.aogonek = 444;
  36526. t.Uacute = 722;
  36527. t.uogonek = 500;
  36528. t.Edieresis = 611;
  36529. t.Dcroat = 722;
  36530. t.commaaccent = 250;
  36531. t.copyright = 760;
  36532. t.Emacron = 611;
  36533. t.ccaron = 444;
  36534. t.aring = 444;
  36535. t.Ncommaaccent = 722;
  36536. t.lacute = 278;
  36537. t.agrave = 444;
  36538. t.Tcommaaccent = 611;
  36539. t.Cacute = 667;
  36540. t.atilde = 444;
  36541. t.Edotaccent = 611;
  36542. t.scaron = 389;
  36543. t.scedilla = 389;
  36544. t.iacute = 278;
  36545. t.lozenge = 471;
  36546. t.Rcaron = 667;
  36547. t.Gcommaaccent = 722;
  36548. t.ucircumflex = 500;
  36549. t.acircumflex = 444;
  36550. t.Amacron = 722;
  36551. t.rcaron = 333;
  36552. t.ccedilla = 444;
  36553. t.Zdotaccent = 611;
  36554. t.Thorn = 556;
  36555. t.Omacron = 722;
  36556. t.Racute = 667;
  36557. t.Sacute = 556;
  36558. t.dcaron = 588;
  36559. t.Umacron = 722;
  36560. t.uring = 500;
  36561. t.threesuperior = 300;
  36562. t.Ograve = 722;
  36563. t.Agrave = 722;
  36564. t.Abreve = 722;
  36565. t.multiply = 564;
  36566. t.uacute = 500;
  36567. t.Tcaron = 611;
  36568. t.partialdiff = 476;
  36569. t.ydieresis = 500;
  36570. t.Nacute = 722;
  36571. t.icircumflex = 278;
  36572. t.Ecircumflex = 611;
  36573. t.adieresis = 444;
  36574. t.edieresis = 444;
  36575. t.cacute = 444;
  36576. t.nacute = 500;
  36577. t.umacron = 500;
  36578. t.Ncaron = 722;
  36579. t.Iacute = 333;
  36580. t.plusminus = 564;
  36581. t.brokenbar = 200;
  36582. t.registered = 760;
  36583. t.Gbreve = 722;
  36584. t.Idotaccent = 333;
  36585. t.summation = 600;
  36586. t.Egrave = 611;
  36587. t.racute = 333;
  36588. t.omacron = 500;
  36589. t.Zacute = 611;
  36590. t.Zcaron = 611;
  36591. t.greaterequal = 549;
  36592. t.Eth = 722;
  36593. t.Ccedilla = 667;
  36594. t.lcommaaccent = 278;
  36595. t.tcaron = 326;
  36596. t.eogonek = 444;
  36597. t.Uogonek = 722;
  36598. t.Aacute = 722;
  36599. t.Adieresis = 722;
  36600. t.egrave = 444;
  36601. t.zacute = 444;
  36602. t.iogonek = 278;
  36603. t.Oacute = 722;
  36604. t.oacute = 500;
  36605. t.amacron = 444;
  36606. t.sacute = 389;
  36607. t.idieresis = 278;
  36608. t.Ocircumflex = 722;
  36609. t.Ugrave = 722;
  36610. t.Delta = 612;
  36611. t.thorn = 500;
  36612. t.twosuperior = 300;
  36613. t.Odieresis = 722;
  36614. t.mu = 500;
  36615. t.igrave = 278;
  36616. t.ohungarumlaut = 500;
  36617. t.Eogonek = 611;
  36618. t.dcroat = 500;
  36619. t.threequarters = 750;
  36620. t.Scedilla = 556;
  36621. t.lcaron = 344;
  36622. t.Kcommaaccent = 722;
  36623. t.Lacute = 611;
  36624. t.trademark = 980;
  36625. t.edotaccent = 444;
  36626. t.Igrave = 333;
  36627. t.Imacron = 333;
  36628. t.Lcaron = 611;
  36629. t.onehalf = 750;
  36630. t.lessequal = 549;
  36631. t.ocircumflex = 500;
  36632. t.ntilde = 500;
  36633. t.Uhungarumlaut = 722;
  36634. t.Eacute = 611;
  36635. t.emacron = 444;
  36636. t.gbreve = 500;
  36637. t.onequarter = 750;
  36638. t.Scaron = 556;
  36639. t.Scommaaccent = 556;
  36640. t.Ohungarumlaut = 722;
  36641. t.degree = 400;
  36642. t.ograve = 500;
  36643. t.Ccaron = 667;
  36644. t.ugrave = 500;
  36645. t.radical = 453;
  36646. t.Dcaron = 722;
  36647. t.rcommaaccent = 333;
  36648. t.Ntilde = 722;
  36649. t.otilde = 500;
  36650. t.Rcommaaccent = 667;
  36651. t.Lcommaaccent = 611;
  36652. t.Atilde = 722;
  36653. t.Aogonek = 722;
  36654. t.Aring = 722;
  36655. t.Otilde = 722;
  36656. t.zdotaccent = 444;
  36657. t.Ecaron = 611;
  36658. t.Iogonek = 333;
  36659. t.kcommaaccent = 500;
  36660. t.minus = 564;
  36661. t.Icircumflex = 333;
  36662. t.ncaron = 500;
  36663. t.tcommaaccent = 278;
  36664. t.logicalnot = 564;
  36665. t.odieresis = 500;
  36666. t.udieresis = 500;
  36667. t.notequal = 549;
  36668. t.gcommaaccent = 500;
  36669. t.eth = 500;
  36670. t.zcaron = 444;
  36671. t.ncommaaccent = 500;
  36672. t.onesuperior = 300;
  36673. t.imacron = 278;
  36674. t.Euro = 500;
  36675. });
  36676. t["Times-Bold"] = (0, _core_utils.getLookupTableFactory)(function (t) {
  36677. t.space = 250;
  36678. t.exclam = 333;
  36679. t.quotedbl = 555;
  36680. t.numbersign = 500;
  36681. t.dollar = 500;
  36682. t.percent = 1000;
  36683. t.ampersand = 833;
  36684. t.quoteright = 333;
  36685. t.parenleft = 333;
  36686. t.parenright = 333;
  36687. t.asterisk = 500;
  36688. t.plus = 570;
  36689. t.comma = 250;
  36690. t.hyphen = 333;
  36691. t.period = 250;
  36692. t.slash = 278;
  36693. t.zero = 500;
  36694. t.one = 500;
  36695. t.two = 500;
  36696. t.three = 500;
  36697. t.four = 500;
  36698. t.five = 500;
  36699. t.six = 500;
  36700. t.seven = 500;
  36701. t.eight = 500;
  36702. t.nine = 500;
  36703. t.colon = 333;
  36704. t.semicolon = 333;
  36705. t.less = 570;
  36706. t.equal = 570;
  36707. t.greater = 570;
  36708. t.question = 500;
  36709. t.at = 930;
  36710. t.A = 722;
  36711. t.B = 667;
  36712. t.C = 722;
  36713. t.D = 722;
  36714. t.E = 667;
  36715. t.F = 611;
  36716. t.G = 778;
  36717. t.H = 778;
  36718. t.I = 389;
  36719. t.J = 500;
  36720. t.K = 778;
  36721. t.L = 667;
  36722. t.M = 944;
  36723. t.N = 722;
  36724. t.O = 778;
  36725. t.P = 611;
  36726. t.Q = 778;
  36727. t.R = 722;
  36728. t.S = 556;
  36729. t.T = 667;
  36730. t.U = 722;
  36731. t.V = 722;
  36732. t.W = 1000;
  36733. t.X = 722;
  36734. t.Y = 722;
  36735. t.Z = 667;
  36736. t.bracketleft = 333;
  36737. t.backslash = 278;
  36738. t.bracketright = 333;
  36739. t.asciicircum = 581;
  36740. t.underscore = 500;
  36741. t.quoteleft = 333;
  36742. t.a = 500;
  36743. t.b = 556;
  36744. t.c = 444;
  36745. t.d = 556;
  36746. t.e = 444;
  36747. t.f = 333;
  36748. t.g = 500;
  36749. t.h = 556;
  36750. t.i = 278;
  36751. t.j = 333;
  36752. t.k = 556;
  36753. t.l = 278;
  36754. t.m = 833;
  36755. t.n = 556;
  36756. t.o = 500;
  36757. t.p = 556;
  36758. t.q = 556;
  36759. t.r = 444;
  36760. t.s = 389;
  36761. t.t = 333;
  36762. t.u = 556;
  36763. t.v = 500;
  36764. t.w = 722;
  36765. t.x = 500;
  36766. t.y = 500;
  36767. t.z = 444;
  36768. t.braceleft = 394;
  36769. t.bar = 220;
  36770. t.braceright = 394;
  36771. t.asciitilde = 520;
  36772. t.exclamdown = 333;
  36773. t.cent = 500;
  36774. t.sterling = 500;
  36775. t.fraction = 167;
  36776. t.yen = 500;
  36777. t.florin = 500;
  36778. t.section = 500;
  36779. t.currency = 500;
  36780. t.quotesingle = 278;
  36781. t.quotedblleft = 500;
  36782. t.guillemotleft = 500;
  36783. t.guilsinglleft = 333;
  36784. t.guilsinglright = 333;
  36785. t.fi = 556;
  36786. t.fl = 556;
  36787. t.endash = 500;
  36788. t.dagger = 500;
  36789. t.daggerdbl = 500;
  36790. t.periodcentered = 250;
  36791. t.paragraph = 540;
  36792. t.bullet = 350;
  36793. t.quotesinglbase = 333;
  36794. t.quotedblbase = 500;
  36795. t.quotedblright = 500;
  36796. t.guillemotright = 500;
  36797. t.ellipsis = 1000;
  36798. t.perthousand = 1000;
  36799. t.questiondown = 500;
  36800. t.grave = 333;
  36801. t.acute = 333;
  36802. t.circumflex = 333;
  36803. t.tilde = 333;
  36804. t.macron = 333;
  36805. t.breve = 333;
  36806. t.dotaccent = 333;
  36807. t.dieresis = 333;
  36808. t.ring = 333;
  36809. t.cedilla = 333;
  36810. t.hungarumlaut = 333;
  36811. t.ogonek = 333;
  36812. t.caron = 333;
  36813. t.emdash = 1000;
  36814. t.AE = 1000;
  36815. t.ordfeminine = 300;
  36816. t.Lslash = 667;
  36817. t.Oslash = 778;
  36818. t.OE = 1000;
  36819. t.ordmasculine = 330;
  36820. t.ae = 722;
  36821. t.dotlessi = 278;
  36822. t.lslash = 278;
  36823. t.oslash = 500;
  36824. t.oe = 722;
  36825. t.germandbls = 556;
  36826. t.Idieresis = 389;
  36827. t.eacute = 444;
  36828. t.abreve = 500;
  36829. t.uhungarumlaut = 556;
  36830. t.ecaron = 444;
  36831. t.Ydieresis = 722;
  36832. t.divide = 570;
  36833. t.Yacute = 722;
  36834. t.Acircumflex = 722;
  36835. t.aacute = 500;
  36836. t.Ucircumflex = 722;
  36837. t.yacute = 500;
  36838. t.scommaaccent = 389;
  36839. t.ecircumflex = 444;
  36840. t.Uring = 722;
  36841. t.Udieresis = 722;
  36842. t.aogonek = 500;
  36843. t.Uacute = 722;
  36844. t.uogonek = 556;
  36845. t.Edieresis = 667;
  36846. t.Dcroat = 722;
  36847. t.commaaccent = 250;
  36848. t.copyright = 747;
  36849. t.Emacron = 667;
  36850. t.ccaron = 444;
  36851. t.aring = 500;
  36852. t.Ncommaaccent = 722;
  36853. t.lacute = 278;
  36854. t.agrave = 500;
  36855. t.Tcommaaccent = 667;
  36856. t.Cacute = 722;
  36857. t.atilde = 500;
  36858. t.Edotaccent = 667;
  36859. t.scaron = 389;
  36860. t.scedilla = 389;
  36861. t.iacute = 278;
  36862. t.lozenge = 494;
  36863. t.Rcaron = 722;
  36864. t.Gcommaaccent = 778;
  36865. t.ucircumflex = 556;
  36866. t.acircumflex = 500;
  36867. t.Amacron = 722;
  36868. t.rcaron = 444;
  36869. t.ccedilla = 444;
  36870. t.Zdotaccent = 667;
  36871. t.Thorn = 611;
  36872. t.Omacron = 778;
  36873. t.Racute = 722;
  36874. t.Sacute = 556;
  36875. t.dcaron = 672;
  36876. t.Umacron = 722;
  36877. t.uring = 556;
  36878. t.threesuperior = 300;
  36879. t.Ograve = 778;
  36880. t.Agrave = 722;
  36881. t.Abreve = 722;
  36882. t.multiply = 570;
  36883. t.uacute = 556;
  36884. t.Tcaron = 667;
  36885. t.partialdiff = 494;
  36886. t.ydieresis = 500;
  36887. t.Nacute = 722;
  36888. t.icircumflex = 278;
  36889. t.Ecircumflex = 667;
  36890. t.adieresis = 500;
  36891. t.edieresis = 444;
  36892. t.cacute = 444;
  36893. t.nacute = 556;
  36894. t.umacron = 556;
  36895. t.Ncaron = 722;
  36896. t.Iacute = 389;
  36897. t.plusminus = 570;
  36898. t.brokenbar = 220;
  36899. t.registered = 747;
  36900. t.Gbreve = 778;
  36901. t.Idotaccent = 389;
  36902. t.summation = 600;
  36903. t.Egrave = 667;
  36904. t.racute = 444;
  36905. t.omacron = 500;
  36906. t.Zacute = 667;
  36907. t.Zcaron = 667;
  36908. t.greaterequal = 549;
  36909. t.Eth = 722;
  36910. t.Ccedilla = 722;
  36911. t.lcommaaccent = 278;
  36912. t.tcaron = 416;
  36913. t.eogonek = 444;
  36914. t.Uogonek = 722;
  36915. t.Aacute = 722;
  36916. t.Adieresis = 722;
  36917. t.egrave = 444;
  36918. t.zacute = 444;
  36919. t.iogonek = 278;
  36920. t.Oacute = 778;
  36921. t.oacute = 500;
  36922. t.amacron = 500;
  36923. t.sacute = 389;
  36924. t.idieresis = 278;
  36925. t.Ocircumflex = 778;
  36926. t.Ugrave = 722;
  36927. t.Delta = 612;
  36928. t.thorn = 556;
  36929. t.twosuperior = 300;
  36930. t.Odieresis = 778;
  36931. t.mu = 556;
  36932. t.igrave = 278;
  36933. t.ohungarumlaut = 500;
  36934. t.Eogonek = 667;
  36935. t.dcroat = 556;
  36936. t.threequarters = 750;
  36937. t.Scedilla = 556;
  36938. t.lcaron = 394;
  36939. t.Kcommaaccent = 778;
  36940. t.Lacute = 667;
  36941. t.trademark = 1000;
  36942. t.edotaccent = 444;
  36943. t.Igrave = 389;
  36944. t.Imacron = 389;
  36945. t.Lcaron = 667;
  36946. t.onehalf = 750;
  36947. t.lessequal = 549;
  36948. t.ocircumflex = 500;
  36949. t.ntilde = 556;
  36950. t.Uhungarumlaut = 722;
  36951. t.Eacute = 667;
  36952. t.emacron = 444;
  36953. t.gbreve = 500;
  36954. t.onequarter = 750;
  36955. t.Scaron = 556;
  36956. t.Scommaaccent = 556;
  36957. t.Ohungarumlaut = 778;
  36958. t.degree = 400;
  36959. t.ograve = 500;
  36960. t.Ccaron = 722;
  36961. t.ugrave = 556;
  36962. t.radical = 549;
  36963. t.Dcaron = 722;
  36964. t.rcommaaccent = 444;
  36965. t.Ntilde = 722;
  36966. t.otilde = 500;
  36967. t.Rcommaaccent = 722;
  36968. t.Lcommaaccent = 667;
  36969. t.Atilde = 722;
  36970. t.Aogonek = 722;
  36971. t.Aring = 722;
  36972. t.Otilde = 778;
  36973. t.zdotaccent = 444;
  36974. t.Ecaron = 667;
  36975. t.Iogonek = 389;
  36976. t.kcommaaccent = 556;
  36977. t.minus = 570;
  36978. t.Icircumflex = 389;
  36979. t.ncaron = 556;
  36980. t.tcommaaccent = 333;
  36981. t.logicalnot = 570;
  36982. t.odieresis = 500;
  36983. t.udieresis = 556;
  36984. t.notequal = 549;
  36985. t.gcommaaccent = 500;
  36986. t.eth = 500;
  36987. t.zcaron = 444;
  36988. t.ncommaaccent = 556;
  36989. t.onesuperior = 300;
  36990. t.imacron = 278;
  36991. t.Euro = 500;
  36992. });
  36993. t["Times-BoldItalic"] = (0, _core_utils.getLookupTableFactory)(function (t) {
  36994. t.space = 250;
  36995. t.exclam = 389;
  36996. t.quotedbl = 555;
  36997. t.numbersign = 500;
  36998. t.dollar = 500;
  36999. t.percent = 833;
  37000. t.ampersand = 778;
  37001. t.quoteright = 333;
  37002. t.parenleft = 333;
  37003. t.parenright = 333;
  37004. t.asterisk = 500;
  37005. t.plus = 570;
  37006. t.comma = 250;
  37007. t.hyphen = 333;
  37008. t.period = 250;
  37009. t.slash = 278;
  37010. t.zero = 500;
  37011. t.one = 500;
  37012. t.two = 500;
  37013. t.three = 500;
  37014. t.four = 500;
  37015. t.five = 500;
  37016. t.six = 500;
  37017. t.seven = 500;
  37018. t.eight = 500;
  37019. t.nine = 500;
  37020. t.colon = 333;
  37021. t.semicolon = 333;
  37022. t.less = 570;
  37023. t.equal = 570;
  37024. t.greater = 570;
  37025. t.question = 500;
  37026. t.at = 832;
  37027. t.A = 667;
  37028. t.B = 667;
  37029. t.C = 667;
  37030. t.D = 722;
  37031. t.E = 667;
  37032. t.F = 667;
  37033. t.G = 722;
  37034. t.H = 778;
  37035. t.I = 389;
  37036. t.J = 500;
  37037. t.K = 667;
  37038. t.L = 611;
  37039. t.M = 889;
  37040. t.N = 722;
  37041. t.O = 722;
  37042. t.P = 611;
  37043. t.Q = 722;
  37044. t.R = 667;
  37045. t.S = 556;
  37046. t.T = 611;
  37047. t.U = 722;
  37048. t.V = 667;
  37049. t.W = 889;
  37050. t.X = 667;
  37051. t.Y = 611;
  37052. t.Z = 611;
  37053. t.bracketleft = 333;
  37054. t.backslash = 278;
  37055. t.bracketright = 333;
  37056. t.asciicircum = 570;
  37057. t.underscore = 500;
  37058. t.quoteleft = 333;
  37059. t.a = 500;
  37060. t.b = 500;
  37061. t.c = 444;
  37062. t.d = 500;
  37063. t.e = 444;
  37064. t.f = 333;
  37065. t.g = 500;
  37066. t.h = 556;
  37067. t.i = 278;
  37068. t.j = 278;
  37069. t.k = 500;
  37070. t.l = 278;
  37071. t.m = 778;
  37072. t.n = 556;
  37073. t.o = 500;
  37074. t.p = 500;
  37075. t.q = 500;
  37076. t.r = 389;
  37077. t.s = 389;
  37078. t.t = 278;
  37079. t.u = 556;
  37080. t.v = 444;
  37081. t.w = 667;
  37082. t.x = 500;
  37083. t.y = 444;
  37084. t.z = 389;
  37085. t.braceleft = 348;
  37086. t.bar = 220;
  37087. t.braceright = 348;
  37088. t.asciitilde = 570;
  37089. t.exclamdown = 389;
  37090. t.cent = 500;
  37091. t.sterling = 500;
  37092. t.fraction = 167;
  37093. t.yen = 500;
  37094. t.florin = 500;
  37095. t.section = 500;
  37096. t.currency = 500;
  37097. t.quotesingle = 278;
  37098. t.quotedblleft = 500;
  37099. t.guillemotleft = 500;
  37100. t.guilsinglleft = 333;
  37101. t.guilsinglright = 333;
  37102. t.fi = 556;
  37103. t.fl = 556;
  37104. t.endash = 500;
  37105. t.dagger = 500;
  37106. t.daggerdbl = 500;
  37107. t.periodcentered = 250;
  37108. t.paragraph = 500;
  37109. t.bullet = 350;
  37110. t.quotesinglbase = 333;
  37111. t.quotedblbase = 500;
  37112. t.quotedblright = 500;
  37113. t.guillemotright = 500;
  37114. t.ellipsis = 1000;
  37115. t.perthousand = 1000;
  37116. t.questiondown = 500;
  37117. t.grave = 333;
  37118. t.acute = 333;
  37119. t.circumflex = 333;
  37120. t.tilde = 333;
  37121. t.macron = 333;
  37122. t.breve = 333;
  37123. t.dotaccent = 333;
  37124. t.dieresis = 333;
  37125. t.ring = 333;
  37126. t.cedilla = 333;
  37127. t.hungarumlaut = 333;
  37128. t.ogonek = 333;
  37129. t.caron = 333;
  37130. t.emdash = 1000;
  37131. t.AE = 944;
  37132. t.ordfeminine = 266;
  37133. t.Lslash = 611;
  37134. t.Oslash = 722;
  37135. t.OE = 944;
  37136. t.ordmasculine = 300;
  37137. t.ae = 722;
  37138. t.dotlessi = 278;
  37139. t.lslash = 278;
  37140. t.oslash = 500;
  37141. t.oe = 722;
  37142. t.germandbls = 500;
  37143. t.Idieresis = 389;
  37144. t.eacute = 444;
  37145. t.abreve = 500;
  37146. t.uhungarumlaut = 556;
  37147. t.ecaron = 444;
  37148. t.Ydieresis = 611;
  37149. t.divide = 570;
  37150. t.Yacute = 611;
  37151. t.Acircumflex = 667;
  37152. t.aacute = 500;
  37153. t.Ucircumflex = 722;
  37154. t.yacute = 444;
  37155. t.scommaaccent = 389;
  37156. t.ecircumflex = 444;
  37157. t.Uring = 722;
  37158. t.Udieresis = 722;
  37159. t.aogonek = 500;
  37160. t.Uacute = 722;
  37161. t.uogonek = 556;
  37162. t.Edieresis = 667;
  37163. t.Dcroat = 722;
  37164. t.commaaccent = 250;
  37165. t.copyright = 747;
  37166. t.Emacron = 667;
  37167. t.ccaron = 444;
  37168. t.aring = 500;
  37169. t.Ncommaaccent = 722;
  37170. t.lacute = 278;
  37171. t.agrave = 500;
  37172. t.Tcommaaccent = 611;
  37173. t.Cacute = 667;
  37174. t.atilde = 500;
  37175. t.Edotaccent = 667;
  37176. t.scaron = 389;
  37177. t.scedilla = 389;
  37178. t.iacute = 278;
  37179. t.lozenge = 494;
  37180. t.Rcaron = 667;
  37181. t.Gcommaaccent = 722;
  37182. t.ucircumflex = 556;
  37183. t.acircumflex = 500;
  37184. t.Amacron = 667;
  37185. t.rcaron = 389;
  37186. t.ccedilla = 444;
  37187. t.Zdotaccent = 611;
  37188. t.Thorn = 611;
  37189. t.Omacron = 722;
  37190. t.Racute = 667;
  37191. t.Sacute = 556;
  37192. t.dcaron = 608;
  37193. t.Umacron = 722;
  37194. t.uring = 556;
  37195. t.threesuperior = 300;
  37196. t.Ograve = 722;
  37197. t.Agrave = 667;
  37198. t.Abreve = 667;
  37199. t.multiply = 570;
  37200. t.uacute = 556;
  37201. t.Tcaron = 611;
  37202. t.partialdiff = 494;
  37203. t.ydieresis = 444;
  37204. t.Nacute = 722;
  37205. t.icircumflex = 278;
  37206. t.Ecircumflex = 667;
  37207. t.adieresis = 500;
  37208. t.edieresis = 444;
  37209. t.cacute = 444;
  37210. t.nacute = 556;
  37211. t.umacron = 556;
  37212. t.Ncaron = 722;
  37213. t.Iacute = 389;
  37214. t.plusminus = 570;
  37215. t.brokenbar = 220;
  37216. t.registered = 747;
  37217. t.Gbreve = 722;
  37218. t.Idotaccent = 389;
  37219. t.summation = 600;
  37220. t.Egrave = 667;
  37221. t.racute = 389;
  37222. t.omacron = 500;
  37223. t.Zacute = 611;
  37224. t.Zcaron = 611;
  37225. t.greaterequal = 549;
  37226. t.Eth = 722;
  37227. t.Ccedilla = 667;
  37228. t.lcommaaccent = 278;
  37229. t.tcaron = 366;
  37230. t.eogonek = 444;
  37231. t.Uogonek = 722;
  37232. t.Aacute = 667;
  37233. t.Adieresis = 667;
  37234. t.egrave = 444;
  37235. t.zacute = 389;
  37236. t.iogonek = 278;
  37237. t.Oacute = 722;
  37238. t.oacute = 500;
  37239. t.amacron = 500;
  37240. t.sacute = 389;
  37241. t.idieresis = 278;
  37242. t.Ocircumflex = 722;
  37243. t.Ugrave = 722;
  37244. t.Delta = 612;
  37245. t.thorn = 500;
  37246. t.twosuperior = 300;
  37247. t.Odieresis = 722;
  37248. t.mu = 576;
  37249. t.igrave = 278;
  37250. t.ohungarumlaut = 500;
  37251. t.Eogonek = 667;
  37252. t.dcroat = 500;
  37253. t.threequarters = 750;
  37254. t.Scedilla = 556;
  37255. t.lcaron = 382;
  37256. t.Kcommaaccent = 667;
  37257. t.Lacute = 611;
  37258. t.trademark = 1000;
  37259. t.edotaccent = 444;
  37260. t.Igrave = 389;
  37261. t.Imacron = 389;
  37262. t.Lcaron = 611;
  37263. t.onehalf = 750;
  37264. t.lessequal = 549;
  37265. t.ocircumflex = 500;
  37266. t.ntilde = 556;
  37267. t.Uhungarumlaut = 722;
  37268. t.Eacute = 667;
  37269. t.emacron = 444;
  37270. t.gbreve = 500;
  37271. t.onequarter = 750;
  37272. t.Scaron = 556;
  37273. t.Scommaaccent = 556;
  37274. t.Ohungarumlaut = 722;
  37275. t.degree = 400;
  37276. t.ograve = 500;
  37277. t.Ccaron = 667;
  37278. t.ugrave = 556;
  37279. t.radical = 549;
  37280. t.Dcaron = 722;
  37281. t.rcommaaccent = 389;
  37282. t.Ntilde = 722;
  37283. t.otilde = 500;
  37284. t.Rcommaaccent = 667;
  37285. t.Lcommaaccent = 611;
  37286. t.Atilde = 667;
  37287. t.Aogonek = 667;
  37288. t.Aring = 667;
  37289. t.Otilde = 722;
  37290. t.zdotaccent = 389;
  37291. t.Ecaron = 667;
  37292. t.Iogonek = 389;
  37293. t.kcommaaccent = 500;
  37294. t.minus = 606;
  37295. t.Icircumflex = 389;
  37296. t.ncaron = 556;
  37297. t.tcommaaccent = 278;
  37298. t.logicalnot = 606;
  37299. t.odieresis = 500;
  37300. t.udieresis = 556;
  37301. t.notequal = 549;
  37302. t.gcommaaccent = 500;
  37303. t.eth = 500;
  37304. t.zcaron = 389;
  37305. t.ncommaaccent = 556;
  37306. t.onesuperior = 300;
  37307. t.imacron = 278;
  37308. t.Euro = 500;
  37309. });
  37310. t["Times-Italic"] = (0, _core_utils.getLookupTableFactory)(function (t) {
  37311. t.space = 250;
  37312. t.exclam = 333;
  37313. t.quotedbl = 420;
  37314. t.numbersign = 500;
  37315. t.dollar = 500;
  37316. t.percent = 833;
  37317. t.ampersand = 778;
  37318. t.quoteright = 333;
  37319. t.parenleft = 333;
  37320. t.parenright = 333;
  37321. t.asterisk = 500;
  37322. t.plus = 675;
  37323. t.comma = 250;
  37324. t.hyphen = 333;
  37325. t.period = 250;
  37326. t.slash = 278;
  37327. t.zero = 500;
  37328. t.one = 500;
  37329. t.two = 500;
  37330. t.three = 500;
  37331. t.four = 500;
  37332. t.five = 500;
  37333. t.six = 500;
  37334. t.seven = 500;
  37335. t.eight = 500;
  37336. t.nine = 500;
  37337. t.colon = 333;
  37338. t.semicolon = 333;
  37339. t.less = 675;
  37340. t.equal = 675;
  37341. t.greater = 675;
  37342. t.question = 500;
  37343. t.at = 920;
  37344. t.A = 611;
  37345. t.B = 611;
  37346. t.C = 667;
  37347. t.D = 722;
  37348. t.E = 611;
  37349. t.F = 611;
  37350. t.G = 722;
  37351. t.H = 722;
  37352. t.I = 333;
  37353. t.J = 444;
  37354. t.K = 667;
  37355. t.L = 556;
  37356. t.M = 833;
  37357. t.N = 667;
  37358. t.O = 722;
  37359. t.P = 611;
  37360. t.Q = 722;
  37361. t.R = 611;
  37362. t.S = 500;
  37363. t.T = 556;
  37364. t.U = 722;
  37365. t.V = 611;
  37366. t.W = 833;
  37367. t.X = 611;
  37368. t.Y = 556;
  37369. t.Z = 556;
  37370. t.bracketleft = 389;
  37371. t.backslash = 278;
  37372. t.bracketright = 389;
  37373. t.asciicircum = 422;
  37374. t.underscore = 500;
  37375. t.quoteleft = 333;
  37376. t.a = 500;
  37377. t.b = 500;
  37378. t.c = 444;
  37379. t.d = 500;
  37380. t.e = 444;
  37381. t.f = 278;
  37382. t.g = 500;
  37383. t.h = 500;
  37384. t.i = 278;
  37385. t.j = 278;
  37386. t.k = 444;
  37387. t.l = 278;
  37388. t.m = 722;
  37389. t.n = 500;
  37390. t.o = 500;
  37391. t.p = 500;
  37392. t.q = 500;
  37393. t.r = 389;
  37394. t.s = 389;
  37395. t.t = 278;
  37396. t.u = 500;
  37397. t.v = 444;
  37398. t.w = 667;
  37399. t.x = 444;
  37400. t.y = 444;
  37401. t.z = 389;
  37402. t.braceleft = 400;
  37403. t.bar = 275;
  37404. t.braceright = 400;
  37405. t.asciitilde = 541;
  37406. t.exclamdown = 389;
  37407. t.cent = 500;
  37408. t.sterling = 500;
  37409. t.fraction = 167;
  37410. t.yen = 500;
  37411. t.florin = 500;
  37412. t.section = 500;
  37413. t.currency = 500;
  37414. t.quotesingle = 214;
  37415. t.quotedblleft = 556;
  37416. t.guillemotleft = 500;
  37417. t.guilsinglleft = 333;
  37418. t.guilsinglright = 333;
  37419. t.fi = 500;
  37420. t.fl = 500;
  37421. t.endash = 500;
  37422. t.dagger = 500;
  37423. t.daggerdbl = 500;
  37424. t.periodcentered = 250;
  37425. t.paragraph = 523;
  37426. t.bullet = 350;
  37427. t.quotesinglbase = 333;
  37428. t.quotedblbase = 556;
  37429. t.quotedblright = 556;
  37430. t.guillemotright = 500;
  37431. t.ellipsis = 889;
  37432. t.perthousand = 1000;
  37433. t.questiondown = 500;
  37434. t.grave = 333;
  37435. t.acute = 333;
  37436. t.circumflex = 333;
  37437. t.tilde = 333;
  37438. t.macron = 333;
  37439. t.breve = 333;
  37440. t.dotaccent = 333;
  37441. t.dieresis = 333;
  37442. t.ring = 333;
  37443. t.cedilla = 333;
  37444. t.hungarumlaut = 333;
  37445. t.ogonek = 333;
  37446. t.caron = 333;
  37447. t.emdash = 889;
  37448. t.AE = 889;
  37449. t.ordfeminine = 276;
  37450. t.Lslash = 556;
  37451. t.Oslash = 722;
  37452. t.OE = 944;
  37453. t.ordmasculine = 310;
  37454. t.ae = 667;
  37455. t.dotlessi = 278;
  37456. t.lslash = 278;
  37457. t.oslash = 500;
  37458. t.oe = 667;
  37459. t.germandbls = 500;
  37460. t.Idieresis = 333;
  37461. t.eacute = 444;
  37462. t.abreve = 500;
  37463. t.uhungarumlaut = 500;
  37464. t.ecaron = 444;
  37465. t.Ydieresis = 556;
  37466. t.divide = 675;
  37467. t.Yacute = 556;
  37468. t.Acircumflex = 611;
  37469. t.aacute = 500;
  37470. t.Ucircumflex = 722;
  37471. t.yacute = 444;
  37472. t.scommaaccent = 389;
  37473. t.ecircumflex = 444;
  37474. t.Uring = 722;
  37475. t.Udieresis = 722;
  37476. t.aogonek = 500;
  37477. t.Uacute = 722;
  37478. t.uogonek = 500;
  37479. t.Edieresis = 611;
  37480. t.Dcroat = 722;
  37481. t.commaaccent = 250;
  37482. t.copyright = 760;
  37483. t.Emacron = 611;
  37484. t.ccaron = 444;
  37485. t.aring = 500;
  37486. t.Ncommaaccent = 667;
  37487. t.lacute = 278;
  37488. t.agrave = 500;
  37489. t.Tcommaaccent = 556;
  37490. t.Cacute = 667;
  37491. t.atilde = 500;
  37492. t.Edotaccent = 611;
  37493. t.scaron = 389;
  37494. t.scedilla = 389;
  37495. t.iacute = 278;
  37496. t.lozenge = 471;
  37497. t.Rcaron = 611;
  37498. t.Gcommaaccent = 722;
  37499. t.ucircumflex = 500;
  37500. t.acircumflex = 500;
  37501. t.Amacron = 611;
  37502. t.rcaron = 389;
  37503. t.ccedilla = 444;
  37504. t.Zdotaccent = 556;
  37505. t.Thorn = 611;
  37506. t.Omacron = 722;
  37507. t.Racute = 611;
  37508. t.Sacute = 500;
  37509. t.dcaron = 544;
  37510. t.Umacron = 722;
  37511. t.uring = 500;
  37512. t.threesuperior = 300;
  37513. t.Ograve = 722;
  37514. t.Agrave = 611;
  37515. t.Abreve = 611;
  37516. t.multiply = 675;
  37517. t.uacute = 500;
  37518. t.Tcaron = 556;
  37519. t.partialdiff = 476;
  37520. t.ydieresis = 444;
  37521. t.Nacute = 667;
  37522. t.icircumflex = 278;
  37523. t.Ecircumflex = 611;
  37524. t.adieresis = 500;
  37525. t.edieresis = 444;
  37526. t.cacute = 444;
  37527. t.nacute = 500;
  37528. t.umacron = 500;
  37529. t.Ncaron = 667;
  37530. t.Iacute = 333;
  37531. t.plusminus = 675;
  37532. t.brokenbar = 275;
  37533. t.registered = 760;
  37534. t.Gbreve = 722;
  37535. t.Idotaccent = 333;
  37536. t.summation = 600;
  37537. t.Egrave = 611;
  37538. t.racute = 389;
  37539. t.omacron = 500;
  37540. t.Zacute = 556;
  37541. t.Zcaron = 556;
  37542. t.greaterequal = 549;
  37543. t.Eth = 722;
  37544. t.Ccedilla = 667;
  37545. t.lcommaaccent = 278;
  37546. t.tcaron = 300;
  37547. t.eogonek = 444;
  37548. t.Uogonek = 722;
  37549. t.Aacute = 611;
  37550. t.Adieresis = 611;
  37551. t.egrave = 444;
  37552. t.zacute = 389;
  37553. t.iogonek = 278;
  37554. t.Oacute = 722;
  37555. t.oacute = 500;
  37556. t.amacron = 500;
  37557. t.sacute = 389;
  37558. t.idieresis = 278;
  37559. t.Ocircumflex = 722;
  37560. t.Ugrave = 722;
  37561. t.Delta = 612;
  37562. t.thorn = 500;
  37563. t.twosuperior = 300;
  37564. t.Odieresis = 722;
  37565. t.mu = 500;
  37566. t.igrave = 278;
  37567. t.ohungarumlaut = 500;
  37568. t.Eogonek = 611;
  37569. t.dcroat = 500;
  37570. t.threequarters = 750;
  37571. t.Scedilla = 500;
  37572. t.lcaron = 300;
  37573. t.Kcommaaccent = 667;
  37574. t.Lacute = 556;
  37575. t.trademark = 980;
  37576. t.edotaccent = 444;
  37577. t.Igrave = 333;
  37578. t.Imacron = 333;
  37579. t.Lcaron = 611;
  37580. t.onehalf = 750;
  37581. t.lessequal = 549;
  37582. t.ocircumflex = 500;
  37583. t.ntilde = 500;
  37584. t.Uhungarumlaut = 722;
  37585. t.Eacute = 611;
  37586. t.emacron = 444;
  37587. t.gbreve = 500;
  37588. t.onequarter = 750;
  37589. t.Scaron = 500;
  37590. t.Scommaaccent = 500;
  37591. t.Ohungarumlaut = 722;
  37592. t.degree = 400;
  37593. t.ograve = 500;
  37594. t.Ccaron = 667;
  37595. t.ugrave = 500;
  37596. t.radical = 453;
  37597. t.Dcaron = 722;
  37598. t.rcommaaccent = 389;
  37599. t.Ntilde = 667;
  37600. t.otilde = 500;
  37601. t.Rcommaaccent = 611;
  37602. t.Lcommaaccent = 556;
  37603. t.Atilde = 611;
  37604. t.Aogonek = 611;
  37605. t.Aring = 611;
  37606. t.Otilde = 722;
  37607. t.zdotaccent = 389;
  37608. t.Ecaron = 611;
  37609. t.Iogonek = 333;
  37610. t.kcommaaccent = 444;
  37611. t.minus = 675;
  37612. t.Icircumflex = 333;
  37613. t.ncaron = 500;
  37614. t.tcommaaccent = 278;
  37615. t.logicalnot = 675;
  37616. t.odieresis = 500;
  37617. t.udieresis = 500;
  37618. t.notequal = 549;
  37619. t.gcommaaccent = 500;
  37620. t.eth = 500;
  37621. t.zcaron = 389;
  37622. t.ncommaaccent = 500;
  37623. t.onesuperior = 300;
  37624. t.imacron = 278;
  37625. t.Euro = 500;
  37626. });
  37627. t.ZapfDingbats = (0, _core_utils.getLookupTableFactory)(function (t) {
  37628. t.space = 278;
  37629. t.a1 = 974;
  37630. t.a2 = 961;
  37631. t.a202 = 974;
  37632. t.a3 = 980;
  37633. t.a4 = 719;
  37634. t.a5 = 789;
  37635. t.a119 = 790;
  37636. t.a118 = 791;
  37637. t.a117 = 690;
  37638. t.a11 = 960;
  37639. t.a12 = 939;
  37640. t.a13 = 549;
  37641. t.a14 = 855;
  37642. t.a15 = 911;
  37643. t.a16 = 933;
  37644. t.a105 = 911;
  37645. t.a17 = 945;
  37646. t.a18 = 974;
  37647. t.a19 = 755;
  37648. t.a20 = 846;
  37649. t.a21 = 762;
  37650. t.a22 = 761;
  37651. t.a23 = 571;
  37652. t.a24 = 677;
  37653. t.a25 = 763;
  37654. t.a26 = 760;
  37655. t.a27 = 759;
  37656. t.a28 = 754;
  37657. t.a6 = 494;
  37658. t.a7 = 552;
  37659. t.a8 = 537;
  37660. t.a9 = 577;
  37661. t.a10 = 692;
  37662. t.a29 = 786;
  37663. t.a30 = 788;
  37664. t.a31 = 788;
  37665. t.a32 = 790;
  37666. t.a33 = 793;
  37667. t.a34 = 794;
  37668. t.a35 = 816;
  37669. t.a36 = 823;
  37670. t.a37 = 789;
  37671. t.a38 = 841;
  37672. t.a39 = 823;
  37673. t.a40 = 833;
  37674. t.a41 = 816;
  37675. t.a42 = 831;
  37676. t.a43 = 923;
  37677. t.a44 = 744;
  37678. t.a45 = 723;
  37679. t.a46 = 749;
  37680. t.a47 = 790;
  37681. t.a48 = 792;
  37682. t.a49 = 695;
  37683. t.a50 = 776;
  37684. t.a51 = 768;
  37685. t.a52 = 792;
  37686. t.a53 = 759;
  37687. t.a54 = 707;
  37688. t.a55 = 708;
  37689. t.a56 = 682;
  37690. t.a57 = 701;
  37691. t.a58 = 826;
  37692. t.a59 = 815;
  37693. t.a60 = 789;
  37694. t.a61 = 789;
  37695. t.a62 = 707;
  37696. t.a63 = 687;
  37697. t.a64 = 696;
  37698. t.a65 = 689;
  37699. t.a66 = 786;
  37700. t.a67 = 787;
  37701. t.a68 = 713;
  37702. t.a69 = 791;
  37703. t.a70 = 785;
  37704. t.a71 = 791;
  37705. t.a72 = 873;
  37706. t.a73 = 761;
  37707. t.a74 = 762;
  37708. t.a203 = 762;
  37709. t.a75 = 759;
  37710. t.a204 = 759;
  37711. t.a76 = 892;
  37712. t.a77 = 892;
  37713. t.a78 = 788;
  37714. t.a79 = 784;
  37715. t.a81 = 438;
  37716. t.a82 = 138;
  37717. t.a83 = 277;
  37718. t.a84 = 415;
  37719. t.a97 = 392;
  37720. t.a98 = 392;
  37721. t.a99 = 668;
  37722. t.a100 = 668;
  37723. t.a89 = 390;
  37724. t.a90 = 390;
  37725. t.a93 = 317;
  37726. t.a94 = 317;
  37727. t.a91 = 276;
  37728. t.a92 = 276;
  37729. t.a205 = 509;
  37730. t.a85 = 509;
  37731. t.a206 = 410;
  37732. t.a86 = 410;
  37733. t.a87 = 234;
  37734. t.a88 = 234;
  37735. t.a95 = 334;
  37736. t.a96 = 334;
  37737. t.a101 = 732;
  37738. t.a102 = 544;
  37739. t.a103 = 544;
  37740. t.a104 = 910;
  37741. t.a106 = 667;
  37742. t.a107 = 760;
  37743. t.a108 = 760;
  37744. t.a112 = 776;
  37745. t.a111 = 595;
  37746. t.a110 = 694;
  37747. t.a109 = 626;
  37748. t.a120 = 788;
  37749. t.a121 = 788;
  37750. t.a122 = 788;
  37751. t.a123 = 788;
  37752. t.a124 = 788;
  37753. t.a125 = 788;
  37754. t.a126 = 788;
  37755. t.a127 = 788;
  37756. t.a128 = 788;
  37757. t.a129 = 788;
  37758. t.a130 = 788;
  37759. t.a131 = 788;
  37760. t.a132 = 788;
  37761. t.a133 = 788;
  37762. t.a134 = 788;
  37763. t.a135 = 788;
  37764. t.a136 = 788;
  37765. t.a137 = 788;
  37766. t.a138 = 788;
  37767. t.a139 = 788;
  37768. t.a140 = 788;
  37769. t.a141 = 788;
  37770. t.a142 = 788;
  37771. t.a143 = 788;
  37772. t.a144 = 788;
  37773. t.a145 = 788;
  37774. t.a146 = 788;
  37775. t.a147 = 788;
  37776. t.a148 = 788;
  37777. t.a149 = 788;
  37778. t.a150 = 788;
  37779. t.a151 = 788;
  37780. t.a152 = 788;
  37781. t.a153 = 788;
  37782. t.a154 = 788;
  37783. t.a155 = 788;
  37784. t.a156 = 788;
  37785. t.a157 = 788;
  37786. t.a158 = 788;
  37787. t.a159 = 788;
  37788. t.a160 = 894;
  37789. t.a161 = 838;
  37790. t.a163 = 1016;
  37791. t.a164 = 458;
  37792. t.a196 = 748;
  37793. t.a165 = 924;
  37794. t.a192 = 748;
  37795. t.a166 = 918;
  37796. t.a167 = 927;
  37797. t.a168 = 928;
  37798. t.a169 = 928;
  37799. t.a170 = 834;
  37800. t.a171 = 873;
  37801. t.a172 = 828;
  37802. t.a173 = 924;
  37803. t.a162 = 924;
  37804. t.a174 = 917;
  37805. t.a175 = 930;
  37806. t.a176 = 931;
  37807. t.a177 = 463;
  37808. t.a178 = 883;
  37809. t.a179 = 836;
  37810. t.a193 = 836;
  37811. t.a180 = 867;
  37812. t.a199 = 867;
  37813. t.a181 = 696;
  37814. t.a200 = 696;
  37815. t.a182 = 874;
  37816. t.a201 = 874;
  37817. t.a183 = 760;
  37818. t.a184 = 946;
  37819. t.a197 = 771;
  37820. t.a185 = 865;
  37821. t.a194 = 771;
  37822. t.a198 = 888;
  37823. t.a186 = 967;
  37824. t.a195 = 888;
  37825. t.a187 = 831;
  37826. t.a188 = 873;
  37827. t.a189 = 927;
  37828. t.a190 = 970;
  37829. t.a191 = 918;
  37830. });
  37831. });
  37832. exports.getMetrics = getMetrics;
  37833. const getFontBasicMetrics = (0, _core_utils.getLookupTableFactory)(function (t) {
  37834. t.Courier = {
  37835. ascent: 629,
  37836. descent: -157,
  37837. capHeight: 562,
  37838. xHeight: -426
  37839. };
  37840. t["Courier-Bold"] = {
  37841. ascent: 629,
  37842. descent: -157,
  37843. capHeight: 562,
  37844. xHeight: 439
  37845. };
  37846. t["Courier-Oblique"] = {
  37847. ascent: 629,
  37848. descent: -157,
  37849. capHeight: 562,
  37850. xHeight: 426
  37851. };
  37852. t["Courier-BoldOblique"] = {
  37853. ascent: 629,
  37854. descent: -157,
  37855. capHeight: 562,
  37856. xHeight: 426
  37857. };
  37858. t.Helvetica = {
  37859. ascent: 718,
  37860. descent: -207,
  37861. capHeight: 718,
  37862. xHeight: 523
  37863. };
  37864. t["Helvetica-Bold"] = {
  37865. ascent: 718,
  37866. descent: -207,
  37867. capHeight: 718,
  37868. xHeight: 532
  37869. };
  37870. t["Helvetica-Oblique"] = {
  37871. ascent: 718,
  37872. descent: -207,
  37873. capHeight: 718,
  37874. xHeight: 523
  37875. };
  37876. t["Helvetica-BoldOblique"] = {
  37877. ascent: 718,
  37878. descent: -207,
  37879. capHeight: 718,
  37880. xHeight: 532
  37881. };
  37882. t["Times-Roman"] = {
  37883. ascent: 683,
  37884. descent: -217,
  37885. capHeight: 662,
  37886. xHeight: 450
  37887. };
  37888. t["Times-Bold"] = {
  37889. ascent: 683,
  37890. descent: -217,
  37891. capHeight: 676,
  37892. xHeight: 461
  37893. };
  37894. t["Times-Italic"] = {
  37895. ascent: 683,
  37896. descent: -217,
  37897. capHeight: 653,
  37898. xHeight: 441
  37899. };
  37900. t["Times-BoldItalic"] = {
  37901. ascent: 683,
  37902. descent: -217,
  37903. capHeight: 669,
  37904. xHeight: 462
  37905. };
  37906. t.Symbol = {
  37907. ascent: Math.NaN,
  37908. descent: Math.NaN,
  37909. capHeight: Math.NaN,
  37910. xHeight: Math.NaN
  37911. };
  37912. t.ZapfDingbats = {
  37913. ascent: Math.NaN,
  37914. descent: Math.NaN,
  37915. capHeight: Math.NaN,
  37916. xHeight: Math.NaN
  37917. };
  37918. });
  37919. exports.getFontBasicMetrics = getFontBasicMetrics;
  37920. /***/ }),
  37921. /* 197 */
  37922. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  37923. Object.defineProperty(exports, "__esModule", ({
  37924. value: true
  37925. }));
  37926. exports.GlyfTable = void 0;
  37927. __w_pdfjs_require__(140);
  37928. __w_pdfjs_require__(84);
  37929. __w_pdfjs_require__(93);
  37930. __w_pdfjs_require__(94);
  37931. __w_pdfjs_require__(97);
  37932. __w_pdfjs_require__(99);
  37933. __w_pdfjs_require__(101);
  37934. __w_pdfjs_require__(105);
  37935. __w_pdfjs_require__(108);
  37936. __w_pdfjs_require__(115);
  37937. __w_pdfjs_require__(158);
  37938. const ON_CURVE_POINT = 1 << 0;
  37939. const X_SHORT_VECTOR = 1 << 1;
  37940. const Y_SHORT_VECTOR = 1 << 2;
  37941. const REPEAT_FLAG = 1 << 3;
  37942. const X_IS_SAME_OR_POSITIVE_X_SHORT_VECTOR = 1 << 4;
  37943. const Y_IS_SAME_OR_POSITIVE_Y_SHORT_VECTOR = 1 << 5;
  37944. const OVERLAP_SIMPLE = 1 << 6;
  37945. const ARG_1_AND_2_ARE_WORDS = 1 << 0;
  37946. const ARGS_ARE_XY_VALUES = 1 << 1;
  37947. const WE_HAVE_A_SCALE = 1 << 3;
  37948. const MORE_COMPONENTS = 1 << 5;
  37949. const WE_HAVE_AN_X_AND_Y_SCALE = 1 << 6;
  37950. const WE_HAVE_A_TWO_BY_TWO = 1 << 7;
  37951. const WE_HAVE_INSTRUCTIONS = 1 << 8;
  37952. class GlyfTable {
  37953. constructor(_ref) {
  37954. let {
  37955. glyfTable,
  37956. isGlyphLocationsLong,
  37957. locaTable,
  37958. numGlyphs
  37959. } = _ref;
  37960. this.glyphs = [];
  37961. const loca = new DataView(locaTable.buffer, locaTable.byteOffset, locaTable.byteLength);
  37962. const glyf = new DataView(glyfTable.buffer, glyfTable.byteOffset, glyfTable.byteLength);
  37963. const offsetSize = isGlyphLocationsLong ? 4 : 2;
  37964. let prev = isGlyphLocationsLong ? loca.getUint32(0) : 2 * loca.getUint16(0);
  37965. let pos = 0;
  37966. for (let i = 0; i < numGlyphs; i++) {
  37967. pos += offsetSize;
  37968. const next = isGlyphLocationsLong ? loca.getUint32(pos) : 2 * loca.getUint16(pos);
  37969. if (next === prev) {
  37970. this.glyphs.push(new Glyph({}));
  37971. continue;
  37972. }
  37973. const glyph = Glyph.parse(prev, glyf);
  37974. this.glyphs.push(glyph);
  37975. prev = next;
  37976. }
  37977. }
  37978. getSize() {
  37979. return this.glyphs.reduce((a, g) => {
  37980. const size = g.getSize();
  37981. return a + (size + 3 & ~3);
  37982. }, 0);
  37983. }
  37984. write() {
  37985. const totalSize = this.getSize();
  37986. const glyfTable = new DataView(new ArrayBuffer(totalSize));
  37987. const isLocationLong = totalSize > 0x1fffe;
  37988. const offsetSize = isLocationLong ? 4 : 2;
  37989. const locaTable = new DataView(new ArrayBuffer((this.glyphs.length + 1) * offsetSize));
  37990. if (isLocationLong) {
  37991. locaTable.setUint32(0, 0);
  37992. } else {
  37993. locaTable.setUint16(0, 0);
  37994. }
  37995. let pos = 0;
  37996. let locaIndex = 0;
  37997. for (const glyph of this.glyphs) {
  37998. pos += glyph.write(pos, glyfTable);
  37999. pos = pos + 3 & ~3;
  38000. locaIndex += offsetSize;
  38001. if (isLocationLong) {
  38002. locaTable.setUint32(locaIndex, pos);
  38003. } else {
  38004. locaTable.setUint16(locaIndex, pos >> 1);
  38005. }
  38006. }
  38007. return {
  38008. isLocationLong,
  38009. loca: new Uint8Array(locaTable.buffer),
  38010. glyf: new Uint8Array(glyfTable.buffer)
  38011. };
  38012. }
  38013. scale(factors) {
  38014. for (let i = 0, ii = this.glyphs.length; i < ii; i++) {
  38015. this.glyphs[i].scale(factors[i]);
  38016. }
  38017. }
  38018. }
  38019. exports.GlyfTable = GlyfTable;
  38020. class Glyph {
  38021. constructor(_ref2) {
  38022. let {
  38023. header = null,
  38024. simple = null,
  38025. composites = null
  38026. } = _ref2;
  38027. this.header = header;
  38028. this.simple = simple;
  38029. this.composites = composites;
  38030. }
  38031. static parse(pos, glyf) {
  38032. const [read, header] = GlyphHeader.parse(pos, glyf);
  38033. pos += read;
  38034. if (header.numberOfContours < 0) {
  38035. const composites = [];
  38036. while (true) {
  38037. const [n, composite] = CompositeGlyph.parse(pos, glyf);
  38038. pos += n;
  38039. composites.push(composite);
  38040. if (!(composite.flags & MORE_COMPONENTS)) {
  38041. break;
  38042. }
  38043. }
  38044. return new Glyph({
  38045. header,
  38046. composites
  38047. });
  38048. }
  38049. const simple = SimpleGlyph.parse(pos, glyf, header.numberOfContours);
  38050. return new Glyph({
  38051. header,
  38052. simple
  38053. });
  38054. }
  38055. getSize() {
  38056. if (!this.header) {
  38057. return 0;
  38058. }
  38059. const size = this.simple ? this.simple.getSize() : this.composites.reduce((a, c) => a + c.getSize(), 0);
  38060. return this.header.getSize() + size;
  38061. }
  38062. write(pos, buf) {
  38063. if (!this.header) {
  38064. return 0;
  38065. }
  38066. const spos = pos;
  38067. pos += this.header.write(pos, buf);
  38068. if (this.simple) {
  38069. pos += this.simple.write(pos, buf);
  38070. } else {
  38071. for (const composite of this.composites) {
  38072. pos += composite.write(pos, buf);
  38073. }
  38074. }
  38075. return pos - spos;
  38076. }
  38077. scale(factor) {
  38078. if (!this.header) {
  38079. return;
  38080. }
  38081. const xMiddle = (this.header.xMin + this.header.xMax) / 2;
  38082. this.header.scale(xMiddle, factor);
  38083. if (this.simple) {
  38084. this.simple.scale(xMiddle, factor);
  38085. } else {
  38086. for (const composite of this.composites) {
  38087. composite.scale(xMiddle, factor);
  38088. }
  38089. }
  38090. }
  38091. }
  38092. class GlyphHeader {
  38093. constructor(_ref3) {
  38094. let {
  38095. numberOfContours,
  38096. xMin,
  38097. yMin,
  38098. xMax,
  38099. yMax
  38100. } = _ref3;
  38101. this.numberOfContours = numberOfContours;
  38102. this.xMin = xMin;
  38103. this.yMin = yMin;
  38104. this.xMax = xMax;
  38105. this.yMax = yMax;
  38106. }
  38107. static parse(pos, glyf) {
  38108. return [10, new GlyphHeader({
  38109. numberOfContours: glyf.getInt16(pos),
  38110. xMin: glyf.getInt16(pos + 2),
  38111. yMin: glyf.getInt16(pos + 4),
  38112. xMax: glyf.getInt16(pos + 6),
  38113. yMax: glyf.getInt16(pos + 8)
  38114. })];
  38115. }
  38116. getSize() {
  38117. return 10;
  38118. }
  38119. write(pos, buf) {
  38120. buf.setInt16(pos, this.numberOfContours);
  38121. buf.setInt16(pos + 2, this.xMin);
  38122. buf.setInt16(pos + 4, this.yMin);
  38123. buf.setInt16(pos + 6, this.xMax);
  38124. buf.setInt16(pos + 8, this.yMax);
  38125. return 10;
  38126. }
  38127. scale(x, factor) {
  38128. this.xMin = Math.round(x + (this.xMin - x) * factor);
  38129. this.xMax = Math.round(x + (this.xMax - x) * factor);
  38130. }
  38131. }
  38132. class Contour {
  38133. constructor(_ref4) {
  38134. let {
  38135. flags,
  38136. xCoordinates,
  38137. yCoordinates
  38138. } = _ref4;
  38139. this.xCoordinates = xCoordinates;
  38140. this.yCoordinates = yCoordinates;
  38141. this.flags = flags;
  38142. }
  38143. }
  38144. class SimpleGlyph {
  38145. constructor(_ref5) {
  38146. let {
  38147. contours,
  38148. instructions
  38149. } = _ref5;
  38150. this.contours = contours;
  38151. this.instructions = instructions;
  38152. }
  38153. static parse(pos, glyf, numberOfContours) {
  38154. const endPtsOfContours = [];
  38155. for (let i = 0; i < numberOfContours; i++) {
  38156. const endPt = glyf.getUint16(pos);
  38157. pos += 2;
  38158. endPtsOfContours.push(endPt);
  38159. }
  38160. const numberOfPt = endPtsOfContours[numberOfContours - 1] + 1;
  38161. const instructionLength = glyf.getUint16(pos);
  38162. pos += 2;
  38163. const instructions = new Uint8Array(glyf).slice(pos, pos + instructionLength);
  38164. pos += instructionLength;
  38165. const flags = [];
  38166. for (let i = 0; i < numberOfPt; pos++, i++) {
  38167. let flag = glyf.getUint8(pos);
  38168. flags.push(flag);
  38169. if (flag & REPEAT_FLAG) {
  38170. const count = glyf.getUint8(++pos);
  38171. flag ^= REPEAT_FLAG;
  38172. for (let m = 0; m < count; m++) {
  38173. flags.push(flag);
  38174. }
  38175. i += count;
  38176. }
  38177. }
  38178. const allXCoordinates = [];
  38179. let xCoordinates = [];
  38180. let yCoordinates = [];
  38181. let pointFlags = [];
  38182. const contours = [];
  38183. let endPtsOfContoursIndex = 0;
  38184. let lastCoordinate = 0;
  38185. for (let i = 0; i < numberOfPt; i++) {
  38186. const flag = flags[i];
  38187. if (flag & X_SHORT_VECTOR) {
  38188. const x = glyf.getUint8(pos++);
  38189. lastCoordinate += flag & X_IS_SAME_OR_POSITIVE_X_SHORT_VECTOR ? x : -x;
  38190. xCoordinates.push(lastCoordinate);
  38191. } else if (flag & X_IS_SAME_OR_POSITIVE_X_SHORT_VECTOR) {
  38192. xCoordinates.push(lastCoordinate);
  38193. } else {
  38194. lastCoordinate += glyf.getInt16(pos);
  38195. pos += 2;
  38196. xCoordinates.push(lastCoordinate);
  38197. }
  38198. if (endPtsOfContours[endPtsOfContoursIndex] === i) {
  38199. endPtsOfContoursIndex++;
  38200. allXCoordinates.push(xCoordinates);
  38201. xCoordinates = [];
  38202. }
  38203. }
  38204. lastCoordinate = 0;
  38205. endPtsOfContoursIndex = 0;
  38206. for (let i = 0; i < numberOfPt; i++) {
  38207. const flag = flags[i];
  38208. if (flag & Y_SHORT_VECTOR) {
  38209. const y = glyf.getUint8(pos++);
  38210. lastCoordinate += flag & Y_IS_SAME_OR_POSITIVE_Y_SHORT_VECTOR ? y : -y;
  38211. yCoordinates.push(lastCoordinate);
  38212. } else if (flag & Y_IS_SAME_OR_POSITIVE_Y_SHORT_VECTOR) {
  38213. yCoordinates.push(lastCoordinate);
  38214. } else {
  38215. lastCoordinate += glyf.getInt16(pos);
  38216. pos += 2;
  38217. yCoordinates.push(lastCoordinate);
  38218. }
  38219. pointFlags.push(flag & ON_CURVE_POINT | flag & OVERLAP_SIMPLE);
  38220. if (endPtsOfContours[endPtsOfContoursIndex] === i) {
  38221. xCoordinates = allXCoordinates[endPtsOfContoursIndex];
  38222. endPtsOfContoursIndex++;
  38223. contours.push(new Contour({
  38224. flags: pointFlags,
  38225. xCoordinates,
  38226. yCoordinates
  38227. }));
  38228. yCoordinates = [];
  38229. pointFlags = [];
  38230. }
  38231. }
  38232. return new SimpleGlyph({
  38233. contours,
  38234. instructions
  38235. });
  38236. }
  38237. getSize() {
  38238. let size = this.contours.length * 2 + 2 + this.instructions.length;
  38239. let lastX = 0;
  38240. let lastY = 0;
  38241. for (const contour of this.contours) {
  38242. size += contour.flags.length;
  38243. for (let i = 0, ii = contour.xCoordinates.length; i < ii; i++) {
  38244. const x = contour.xCoordinates[i];
  38245. const y = contour.yCoordinates[i];
  38246. let abs = Math.abs(x - lastX);
  38247. if (abs > 255) {
  38248. size += 2;
  38249. } else if (abs > 0) {
  38250. size += 1;
  38251. }
  38252. lastX = x;
  38253. abs = Math.abs(y - lastY);
  38254. if (abs > 255) {
  38255. size += 2;
  38256. } else if (abs > 0) {
  38257. size += 1;
  38258. }
  38259. lastY = y;
  38260. }
  38261. }
  38262. return size;
  38263. }
  38264. write(pos, buf) {
  38265. const spos = pos;
  38266. const xCoordinates = [];
  38267. const yCoordinates = [];
  38268. const flags = [];
  38269. let lastX = 0;
  38270. let lastY = 0;
  38271. for (const contour of this.contours) {
  38272. for (let i = 0, ii = contour.xCoordinates.length; i < ii; i++) {
  38273. let flag = contour.flags[i];
  38274. const x = contour.xCoordinates[i];
  38275. let delta = x - lastX;
  38276. if (delta === 0) {
  38277. flag |= X_IS_SAME_OR_POSITIVE_X_SHORT_VECTOR;
  38278. xCoordinates.push(0);
  38279. } else {
  38280. const abs = Math.abs(delta);
  38281. if (abs <= 255) {
  38282. flag |= delta >= 0 ? X_SHORT_VECTOR | X_IS_SAME_OR_POSITIVE_X_SHORT_VECTOR : X_SHORT_VECTOR;
  38283. xCoordinates.push(abs);
  38284. } else {
  38285. xCoordinates.push(delta);
  38286. }
  38287. }
  38288. lastX = x;
  38289. const y = contour.yCoordinates[i];
  38290. delta = y - lastY;
  38291. if (delta === 0) {
  38292. flag |= Y_IS_SAME_OR_POSITIVE_Y_SHORT_VECTOR;
  38293. yCoordinates.push(0);
  38294. } else {
  38295. const abs = Math.abs(delta);
  38296. if (abs <= 255) {
  38297. flag |= delta >= 0 ? Y_SHORT_VECTOR | Y_IS_SAME_OR_POSITIVE_Y_SHORT_VECTOR : Y_SHORT_VECTOR;
  38298. yCoordinates.push(abs);
  38299. } else {
  38300. yCoordinates.push(delta);
  38301. }
  38302. }
  38303. lastY = y;
  38304. flags.push(flag);
  38305. }
  38306. buf.setUint16(pos, xCoordinates.length - 1);
  38307. pos += 2;
  38308. }
  38309. buf.setUint16(pos, this.instructions.length);
  38310. pos += 2;
  38311. if (this.instructions.length) {
  38312. new Uint8Array(buf.buffer, 0, buf.buffer.byteLength).set(this.instructions, pos);
  38313. pos += this.instructions.length;
  38314. }
  38315. for (const flag of flags) {
  38316. buf.setUint8(pos++, flag);
  38317. }
  38318. for (let i = 0, ii = xCoordinates.length; i < ii; i++) {
  38319. const x = xCoordinates[i];
  38320. const flag = flags[i];
  38321. if (flag & X_SHORT_VECTOR) {
  38322. buf.setUint8(pos++, x);
  38323. } else if (!(flag & X_IS_SAME_OR_POSITIVE_X_SHORT_VECTOR)) {
  38324. buf.setInt16(pos, x);
  38325. pos += 2;
  38326. }
  38327. }
  38328. for (let i = 0, ii = yCoordinates.length; i < ii; i++) {
  38329. const y = yCoordinates[i];
  38330. const flag = flags[i];
  38331. if (flag & Y_SHORT_VECTOR) {
  38332. buf.setUint8(pos++, y);
  38333. } else if (!(flag & Y_IS_SAME_OR_POSITIVE_Y_SHORT_VECTOR)) {
  38334. buf.setInt16(pos, y);
  38335. pos += 2;
  38336. }
  38337. }
  38338. return pos - spos;
  38339. }
  38340. scale(x, factor) {
  38341. for (const contour of this.contours) {
  38342. if (contour.xCoordinates.length === 0) {
  38343. continue;
  38344. }
  38345. for (let i = 0, ii = contour.xCoordinates.length; i < ii; i++) {
  38346. contour.xCoordinates[i] = Math.round(x + (contour.xCoordinates[i] - x) * factor);
  38347. }
  38348. }
  38349. }
  38350. }
  38351. class CompositeGlyph {
  38352. constructor(_ref6) {
  38353. let {
  38354. flags,
  38355. glyphIndex,
  38356. argument1,
  38357. argument2,
  38358. transf,
  38359. instructions
  38360. } = _ref6;
  38361. this.flags = flags;
  38362. this.glyphIndex = glyphIndex;
  38363. this.argument1 = argument1;
  38364. this.argument2 = argument2;
  38365. this.transf = transf;
  38366. this.instructions = instructions;
  38367. }
  38368. static parse(pos, glyf) {
  38369. const spos = pos;
  38370. const transf = [];
  38371. let flags = glyf.getUint16(pos);
  38372. const glyphIndex = glyf.getUint16(pos + 2);
  38373. pos += 4;
  38374. let argument1, argument2;
  38375. if (flags & ARG_1_AND_2_ARE_WORDS) {
  38376. if (flags & ARGS_ARE_XY_VALUES) {
  38377. argument1 = glyf.getInt16(pos);
  38378. argument2 = glyf.getInt16(pos + 2);
  38379. } else {
  38380. argument1 = glyf.getUint16(pos);
  38381. argument2 = glyf.getUint16(pos + 2);
  38382. }
  38383. pos += 4;
  38384. flags ^= ARG_1_AND_2_ARE_WORDS;
  38385. } else {
  38386. if (flags & ARGS_ARE_XY_VALUES) {
  38387. argument1 = glyf.getInt8(pos);
  38388. argument2 = glyf.getInt8(pos + 1);
  38389. } else {
  38390. argument1 = glyf.getUint8(pos);
  38391. argument2 = glyf.getUint8(pos + 1);
  38392. }
  38393. pos += 2;
  38394. }
  38395. if (flags & WE_HAVE_A_SCALE) {
  38396. transf.push(glyf.getUint16(pos));
  38397. pos += 2;
  38398. } else if (flags & WE_HAVE_AN_X_AND_Y_SCALE) {
  38399. transf.push(glyf.getUint16(pos), glyf.getUint16(pos + 2));
  38400. pos += 4;
  38401. } else if (flags & WE_HAVE_A_TWO_BY_TWO) {
  38402. transf.push(glyf.getUint16(pos), glyf.getUint16(pos + 2), glyf.getUint16(pos + 4), glyf.getUint16(pos + 6));
  38403. pos += 8;
  38404. }
  38405. let instructions = null;
  38406. if (flags & WE_HAVE_INSTRUCTIONS) {
  38407. const instructionLength = glyf.getUint16(pos);
  38408. pos += 2;
  38409. instructions = new Uint8Array(glyf).slice(pos, pos + instructionLength);
  38410. pos += instructionLength;
  38411. }
  38412. return [pos - spos, new CompositeGlyph({
  38413. flags,
  38414. glyphIndex,
  38415. argument1,
  38416. argument2,
  38417. transf,
  38418. instructions
  38419. })];
  38420. }
  38421. getSize() {
  38422. let size = 2 + 2 + this.transf.length * 2;
  38423. if (this.flags & WE_HAVE_INSTRUCTIONS) {
  38424. size += 2 + this.instructions.length;
  38425. }
  38426. size += 2;
  38427. if (this.flags & 2) {
  38428. if (!(this.argument1 >= -128 && this.argument1 <= 127 && this.argument2 >= -128 && this.argument2 <= 127)) {
  38429. size += 2;
  38430. }
  38431. } else if (!(this.argument1 >= 0 && this.argument1 <= 255 && this.argument2 >= 0 && this.argument2 <= 255)) {
  38432. size += 2;
  38433. }
  38434. return size;
  38435. }
  38436. write(pos, buf) {
  38437. const spos = pos;
  38438. if (this.flags & ARGS_ARE_XY_VALUES) {
  38439. if (!(this.argument1 >= -128 && this.argument1 <= 127 && this.argument2 >= -128 && this.argument2 <= 127)) {
  38440. this.flags |= ARG_1_AND_2_ARE_WORDS;
  38441. }
  38442. } else if (!(this.argument1 >= 0 && this.argument1 <= 255 && this.argument2 >= 0 && this.argument2 <= 255)) {
  38443. this.flags |= ARG_1_AND_2_ARE_WORDS;
  38444. }
  38445. buf.setUint16(pos, this.flags);
  38446. buf.setUint16(pos + 2, this.glyphIndex);
  38447. pos += 4;
  38448. if (this.flags & ARG_1_AND_2_ARE_WORDS) {
  38449. if (this.flags & ARGS_ARE_XY_VALUES) {
  38450. buf.setInt16(pos, this.argument1);
  38451. buf.setInt16(pos + 2, this.argument2);
  38452. } else {
  38453. buf.setUint16(pos, this.argument1);
  38454. buf.setUint16(pos + 2, this.argument2);
  38455. }
  38456. pos += 4;
  38457. } else {
  38458. buf.setUint8(pos, this.argument1);
  38459. buf.setUint8(pos + 1, this.argument2);
  38460. pos += 2;
  38461. }
  38462. if (this.flags & WE_HAVE_INSTRUCTIONS) {
  38463. buf.setUint16(pos, this.instructions.length);
  38464. pos += 2;
  38465. if (this.instructions.length) {
  38466. new Uint8Array(buf.buffer, 0, buf.buffer.byteLength).set(this.instructions, pos);
  38467. pos += this.instructions.length;
  38468. }
  38469. }
  38470. return pos - spos;
  38471. }
  38472. scale(x, factor) {}
  38473. }
  38474. /***/ }),
  38475. /* 198 */
  38476. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  38477. Object.defineProperty(exports, "__esModule", ({
  38478. value: true
  38479. }));
  38480. exports.OpenTypeFileBuilder = void 0;
  38481. __w_pdfjs_require__(84);
  38482. __w_pdfjs_require__(93);
  38483. __w_pdfjs_require__(94);
  38484. __w_pdfjs_require__(97);
  38485. __w_pdfjs_require__(99);
  38486. __w_pdfjs_require__(101);
  38487. __w_pdfjs_require__(105);
  38488. __w_pdfjs_require__(108);
  38489. __w_pdfjs_require__(115);
  38490. __w_pdfjs_require__(140);
  38491. __w_pdfjs_require__(2);
  38492. var _core_utils = __w_pdfjs_require__(150);
  38493. var _util = __w_pdfjs_require__(145);
  38494. function writeInt16(dest, offset, num) {
  38495. dest[offset] = num >> 8 & 0xff;
  38496. dest[offset + 1] = num & 0xff;
  38497. }
  38498. function writeInt32(dest, offset, num) {
  38499. dest[offset] = num >> 24 & 0xff;
  38500. dest[offset + 1] = num >> 16 & 0xff;
  38501. dest[offset + 2] = num >> 8 & 0xff;
  38502. dest[offset + 3] = num & 0xff;
  38503. }
  38504. function writeData(dest, offset, data) {
  38505. if (data instanceof Uint8Array) {
  38506. dest.set(data, offset);
  38507. } else if (typeof data === "string") {
  38508. for (let i = 0, ii = data.length; i < ii; i++) {
  38509. dest[offset++] = data.charCodeAt(i) & 0xff;
  38510. }
  38511. } else {
  38512. for (const num of data) {
  38513. dest[offset++] = num & 0xff;
  38514. }
  38515. }
  38516. }
  38517. const OTF_HEADER_SIZE = 12;
  38518. const OTF_TABLE_ENTRY_SIZE = 16;
  38519. class OpenTypeFileBuilder {
  38520. constructor(sfnt) {
  38521. this.sfnt = sfnt;
  38522. this.tables = Object.create(null);
  38523. }
  38524. static getSearchParams(entriesCount, entrySize) {
  38525. let maxPower2 = 1,
  38526. log2 = 0;
  38527. while ((maxPower2 ^ entriesCount) > maxPower2) {
  38528. maxPower2 <<= 1;
  38529. log2++;
  38530. }
  38531. const searchRange = maxPower2 * entrySize;
  38532. return {
  38533. range: searchRange,
  38534. entry: log2,
  38535. rangeShift: entrySize * entriesCount - searchRange
  38536. };
  38537. }
  38538. toArray() {
  38539. let sfnt = this.sfnt;
  38540. const tables = this.tables;
  38541. const tablesNames = Object.keys(tables);
  38542. tablesNames.sort();
  38543. const numTables = tablesNames.length;
  38544. let i, j, jj, table, tableName;
  38545. let offset = OTF_HEADER_SIZE + numTables * OTF_TABLE_ENTRY_SIZE;
  38546. const tableOffsets = [offset];
  38547. for (i = 0; i < numTables; i++) {
  38548. table = tables[tablesNames[i]];
  38549. const paddedLength = (table.length + 3 & ~3) >>> 0;
  38550. offset += paddedLength;
  38551. tableOffsets.push(offset);
  38552. }
  38553. const file = new Uint8Array(offset);
  38554. for (i = 0; i < numTables; i++) {
  38555. table = tables[tablesNames[i]];
  38556. writeData(file, tableOffsets[i], table);
  38557. }
  38558. if (sfnt === "true") {
  38559. sfnt = (0, _util.string32)(0x00010000);
  38560. }
  38561. file[0] = sfnt.charCodeAt(0) & 0xff;
  38562. file[1] = sfnt.charCodeAt(1) & 0xff;
  38563. file[2] = sfnt.charCodeAt(2) & 0xff;
  38564. file[3] = sfnt.charCodeAt(3) & 0xff;
  38565. writeInt16(file, 4, numTables);
  38566. const searchParams = OpenTypeFileBuilder.getSearchParams(numTables, 16);
  38567. writeInt16(file, 6, searchParams.range);
  38568. writeInt16(file, 8, searchParams.entry);
  38569. writeInt16(file, 10, searchParams.rangeShift);
  38570. offset = OTF_HEADER_SIZE;
  38571. for (i = 0; i < numTables; i++) {
  38572. tableName = tablesNames[i];
  38573. file[offset] = tableName.charCodeAt(0) & 0xff;
  38574. file[offset + 1] = tableName.charCodeAt(1) & 0xff;
  38575. file[offset + 2] = tableName.charCodeAt(2) & 0xff;
  38576. file[offset + 3] = tableName.charCodeAt(3) & 0xff;
  38577. let checksum = 0;
  38578. for (j = tableOffsets[i], jj = tableOffsets[i + 1]; j < jj; j += 4) {
  38579. const quad = (0, _core_utils.readUint32)(file, j);
  38580. checksum = checksum + quad >>> 0;
  38581. }
  38582. writeInt32(file, offset + 4, checksum);
  38583. writeInt32(file, offset + 8, tableOffsets[i]);
  38584. writeInt32(file, offset + 12, tables[tableName].length);
  38585. offset += OTF_TABLE_ENTRY_SIZE;
  38586. }
  38587. return file;
  38588. }
  38589. addTable(tag, data) {
  38590. if (tag in this.tables) {
  38591. throw new Error("Table " + tag + " already exists");
  38592. }
  38593. this.tables[tag] = data;
  38594. }
  38595. }
  38596. exports.OpenTypeFileBuilder = OpenTypeFileBuilder;
  38597. /***/ }),
  38598. /* 199 */
  38599. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  38600. Object.defineProperty(exports, "__esModule", ({
  38601. value: true
  38602. }));
  38603. exports.Type1Font = void 0;
  38604. __w_pdfjs_require__(140);
  38605. var _cff_parser = __w_pdfjs_require__(186);
  38606. var _util = __w_pdfjs_require__(145);
  38607. var _fonts_utils = __w_pdfjs_require__(189);
  38608. var _core_utils = __w_pdfjs_require__(150);
  38609. var _stream = __w_pdfjs_require__(155);
  38610. var _type1_parser = __w_pdfjs_require__(200);
  38611. function findBlock(streamBytes, signature, startIndex) {
  38612. const streamBytesLength = streamBytes.length;
  38613. const signatureLength = signature.length;
  38614. const scanLength = streamBytesLength - signatureLength;
  38615. let i = startIndex,
  38616. found = false;
  38617. while (i < scanLength) {
  38618. let j = 0;
  38619. while (j < signatureLength && streamBytes[i + j] === signature[j]) {
  38620. j++;
  38621. }
  38622. if (j >= signatureLength) {
  38623. i += j;
  38624. while (i < streamBytesLength && (0, _core_utils.isWhiteSpace)(streamBytes[i])) {
  38625. i++;
  38626. }
  38627. found = true;
  38628. break;
  38629. }
  38630. i++;
  38631. }
  38632. return {
  38633. found,
  38634. length: i
  38635. };
  38636. }
  38637. function getHeaderBlock(stream, suggestedLength) {
  38638. const EEXEC_SIGNATURE = [0x65, 0x65, 0x78, 0x65, 0x63];
  38639. const streamStartPos = stream.pos;
  38640. let headerBytes, headerBytesLength, block;
  38641. try {
  38642. headerBytes = stream.getBytes(suggestedLength);
  38643. headerBytesLength = headerBytes.length;
  38644. } catch {}
  38645. if (headerBytesLength === suggestedLength) {
  38646. block = findBlock(headerBytes, EEXEC_SIGNATURE, suggestedLength - 2 * EEXEC_SIGNATURE.length);
  38647. if (block.found && block.length === suggestedLength) {
  38648. return {
  38649. stream: new _stream.Stream(headerBytes),
  38650. length: suggestedLength
  38651. };
  38652. }
  38653. }
  38654. (0, _util.warn)('Invalid "Length1" property in Type1 font -- trying to recover.');
  38655. stream.pos = streamStartPos;
  38656. const SCAN_BLOCK_LENGTH = 2048;
  38657. let actualLength;
  38658. while (true) {
  38659. const scanBytes = stream.peekBytes(SCAN_BLOCK_LENGTH);
  38660. block = findBlock(scanBytes, EEXEC_SIGNATURE, 0);
  38661. if (block.length === 0) {
  38662. break;
  38663. }
  38664. stream.pos += block.length;
  38665. if (block.found) {
  38666. actualLength = stream.pos - streamStartPos;
  38667. break;
  38668. }
  38669. }
  38670. stream.pos = streamStartPos;
  38671. if (actualLength) {
  38672. return {
  38673. stream: new _stream.Stream(stream.getBytes(actualLength)),
  38674. length: actualLength
  38675. };
  38676. }
  38677. (0, _util.warn)('Unable to recover "Length1" property in Type1 font -- using as is.');
  38678. return {
  38679. stream: new _stream.Stream(stream.getBytes(suggestedLength)),
  38680. length: suggestedLength
  38681. };
  38682. }
  38683. function getEexecBlock(stream, suggestedLength) {
  38684. const eexecBytes = stream.getBytes();
  38685. if (eexecBytes.length === 0) {
  38686. throw new _util.FormatError("getEexecBlock - no font program found.");
  38687. }
  38688. return {
  38689. stream: new _stream.Stream(eexecBytes),
  38690. length: eexecBytes.length
  38691. };
  38692. }
  38693. class Type1Font {
  38694. constructor(name, file, properties) {
  38695. const PFB_HEADER_SIZE = 6;
  38696. let headerBlockLength = properties.length1;
  38697. let eexecBlockLength = properties.length2;
  38698. let pfbHeader = file.peekBytes(PFB_HEADER_SIZE);
  38699. const pfbHeaderPresent = pfbHeader[0] === 0x80 && pfbHeader[1] === 0x01;
  38700. if (pfbHeaderPresent) {
  38701. file.skip(PFB_HEADER_SIZE);
  38702. headerBlockLength = pfbHeader[5] << 24 | pfbHeader[4] << 16 | pfbHeader[3] << 8 | pfbHeader[2];
  38703. }
  38704. const headerBlock = getHeaderBlock(file, headerBlockLength);
  38705. const headerBlockParser = new _type1_parser.Type1Parser(headerBlock.stream, false, _fonts_utils.SEAC_ANALYSIS_ENABLED);
  38706. headerBlockParser.extractFontHeader(properties);
  38707. if (pfbHeaderPresent) {
  38708. pfbHeader = file.getBytes(PFB_HEADER_SIZE);
  38709. eexecBlockLength = pfbHeader[5] << 24 | pfbHeader[4] << 16 | pfbHeader[3] << 8 | pfbHeader[2];
  38710. }
  38711. const eexecBlock = getEexecBlock(file, eexecBlockLength);
  38712. const eexecBlockParser = new _type1_parser.Type1Parser(eexecBlock.stream, true, _fonts_utils.SEAC_ANALYSIS_ENABLED);
  38713. const data = eexecBlockParser.extractFontProgram(properties);
  38714. for (const key in data.properties) {
  38715. properties[key] = data.properties[key];
  38716. }
  38717. const charstrings = data.charstrings;
  38718. const type2Charstrings = this.getType2Charstrings(charstrings);
  38719. const subrs = this.getType2Subrs(data.subrs);
  38720. this.charstrings = charstrings;
  38721. this.data = this.wrap(name, type2Charstrings, this.charstrings, subrs, properties);
  38722. this.seacs = this.getSeacs(data.charstrings);
  38723. }
  38724. get numGlyphs() {
  38725. return this.charstrings.length + 1;
  38726. }
  38727. getCharset() {
  38728. const charset = [".notdef"];
  38729. for (const {
  38730. glyphName
  38731. } of this.charstrings) {
  38732. charset.push(glyphName);
  38733. }
  38734. return charset;
  38735. }
  38736. getGlyphMapping(properties) {
  38737. const charstrings = this.charstrings;
  38738. if (properties.composite) {
  38739. const charCodeToGlyphId = Object.create(null);
  38740. for (let glyphId = 0, charstringsLen = charstrings.length; glyphId < charstringsLen; glyphId++) {
  38741. const charCode = properties.cMap.charCodeOf(glyphId);
  38742. charCodeToGlyphId[charCode] = glyphId + 1;
  38743. }
  38744. return charCodeToGlyphId;
  38745. }
  38746. const glyphNames = [".notdef"];
  38747. let builtInEncoding, glyphId;
  38748. for (glyphId = 0; glyphId < charstrings.length; glyphId++) {
  38749. glyphNames.push(charstrings[glyphId].glyphName);
  38750. }
  38751. const encoding = properties.builtInEncoding;
  38752. if (encoding) {
  38753. builtInEncoding = Object.create(null);
  38754. for (const charCode in encoding) {
  38755. glyphId = glyphNames.indexOf(encoding[charCode]);
  38756. if (glyphId >= 0) {
  38757. builtInEncoding[charCode] = glyphId;
  38758. }
  38759. }
  38760. }
  38761. return (0, _fonts_utils.type1FontGlyphMapping)(properties, builtInEncoding, glyphNames);
  38762. }
  38763. hasGlyphId(id) {
  38764. if (id < 0 || id >= this.numGlyphs) {
  38765. return false;
  38766. }
  38767. if (id === 0) {
  38768. return true;
  38769. }
  38770. const glyph = this.charstrings[id - 1];
  38771. return glyph.charstring.length > 0;
  38772. }
  38773. getSeacs(charstrings) {
  38774. const seacMap = [];
  38775. for (let i = 0, ii = charstrings.length; i < ii; i++) {
  38776. const charstring = charstrings[i];
  38777. if (charstring.seac) {
  38778. seacMap[i + 1] = charstring.seac;
  38779. }
  38780. }
  38781. return seacMap;
  38782. }
  38783. getType2Charstrings(type1Charstrings) {
  38784. const type2Charstrings = [];
  38785. for (const type1Charstring of type1Charstrings) {
  38786. type2Charstrings.push(type1Charstring.charstring);
  38787. }
  38788. return type2Charstrings;
  38789. }
  38790. getType2Subrs(type1Subrs) {
  38791. let bias = 0;
  38792. const count = type1Subrs.length;
  38793. if (count < 1133) {
  38794. bias = 107;
  38795. } else if (count < 33769) {
  38796. bias = 1131;
  38797. } else {
  38798. bias = 32768;
  38799. }
  38800. const type2Subrs = [];
  38801. let i;
  38802. for (i = 0; i < bias; i++) {
  38803. type2Subrs.push([0x0b]);
  38804. }
  38805. for (i = 0; i < count; i++) {
  38806. type2Subrs.push(type1Subrs[i]);
  38807. }
  38808. return type2Subrs;
  38809. }
  38810. wrap(name, glyphs, charstrings, subrs, properties) {
  38811. const cff = new _cff_parser.CFF();
  38812. cff.header = new _cff_parser.CFFHeader(1, 0, 4, 4);
  38813. cff.names = [name];
  38814. const topDict = new _cff_parser.CFFTopDict();
  38815. topDict.setByName("version", 391);
  38816. topDict.setByName("Notice", 392);
  38817. topDict.setByName("FullName", 393);
  38818. topDict.setByName("FamilyName", 394);
  38819. topDict.setByName("Weight", 395);
  38820. topDict.setByName("Encoding", null);
  38821. topDict.setByName("FontMatrix", properties.fontMatrix);
  38822. topDict.setByName("FontBBox", properties.bbox);
  38823. topDict.setByName("charset", null);
  38824. topDict.setByName("CharStrings", null);
  38825. topDict.setByName("Private", null);
  38826. cff.topDict = topDict;
  38827. const strings = new _cff_parser.CFFStrings();
  38828. strings.add("Version 0.11");
  38829. strings.add("See original notice");
  38830. strings.add(name);
  38831. strings.add(name);
  38832. strings.add("Medium");
  38833. cff.strings = strings;
  38834. cff.globalSubrIndex = new _cff_parser.CFFIndex();
  38835. const count = glyphs.length;
  38836. const charsetArray = [".notdef"];
  38837. let i, ii;
  38838. for (i = 0; i < count; i++) {
  38839. const glyphName = charstrings[i].glyphName;
  38840. const index = _cff_parser.CFFStandardStrings.indexOf(glyphName);
  38841. if (index === -1) {
  38842. strings.add(glyphName);
  38843. }
  38844. charsetArray.push(glyphName);
  38845. }
  38846. cff.charset = new _cff_parser.CFFCharset(false, 0, charsetArray);
  38847. const charStringsIndex = new _cff_parser.CFFIndex();
  38848. charStringsIndex.add([0x8b, 0x0e]);
  38849. for (i = 0; i < count; i++) {
  38850. charStringsIndex.add(glyphs[i]);
  38851. }
  38852. cff.charStrings = charStringsIndex;
  38853. const privateDict = new _cff_parser.CFFPrivateDict();
  38854. privateDict.setByName("Subrs", null);
  38855. const fields = ["BlueValues", "OtherBlues", "FamilyBlues", "FamilyOtherBlues", "StemSnapH", "StemSnapV", "BlueShift", "BlueFuzz", "BlueScale", "LanguageGroup", "ExpansionFactor", "ForceBold", "StdHW", "StdVW"];
  38856. for (i = 0, ii = fields.length; i < ii; i++) {
  38857. const field = fields[i];
  38858. if (!(field in properties.privateData)) {
  38859. continue;
  38860. }
  38861. const value = properties.privateData[field];
  38862. if (Array.isArray(value)) {
  38863. for (let j = value.length - 1; j > 0; j--) {
  38864. value[j] -= value[j - 1];
  38865. }
  38866. }
  38867. privateDict.setByName(field, value);
  38868. }
  38869. cff.topDict.privateDict = privateDict;
  38870. const subrIndex = new _cff_parser.CFFIndex();
  38871. for (i = 0, ii = subrs.length; i < ii; i++) {
  38872. subrIndex.add(subrs[i]);
  38873. }
  38874. privateDict.subrsIndex = subrIndex;
  38875. const compiler = new _cff_parser.CFFCompiler(cff);
  38876. return compiler.compile();
  38877. }
  38878. }
  38879. exports.Type1Font = Type1Font;
  38880. /***/ }),
  38881. /* 200 */
  38882. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  38883. Object.defineProperty(exports, "__esModule", ({
  38884. value: true
  38885. }));
  38886. exports.Type1Parser = void 0;
  38887. __w_pdfjs_require__(140);
  38888. __w_pdfjs_require__(84);
  38889. __w_pdfjs_require__(93);
  38890. __w_pdfjs_require__(94);
  38891. __w_pdfjs_require__(97);
  38892. __w_pdfjs_require__(99);
  38893. __w_pdfjs_require__(101);
  38894. __w_pdfjs_require__(105);
  38895. __w_pdfjs_require__(108);
  38896. __w_pdfjs_require__(115);
  38897. __w_pdfjs_require__(160);
  38898. var _encodings = __w_pdfjs_require__(188);
  38899. var _core_utils = __w_pdfjs_require__(150);
  38900. var _stream = __w_pdfjs_require__(155);
  38901. var _util = __w_pdfjs_require__(145);
  38902. const HINTING_ENABLED = false;
  38903. const COMMAND_MAP = {
  38904. hstem: [1],
  38905. vstem: [3],
  38906. vmoveto: [4],
  38907. rlineto: [5],
  38908. hlineto: [6],
  38909. vlineto: [7],
  38910. rrcurveto: [8],
  38911. callsubr: [10],
  38912. flex: [12, 35],
  38913. drop: [12, 18],
  38914. endchar: [14],
  38915. rmoveto: [21],
  38916. hmoveto: [22],
  38917. vhcurveto: [30],
  38918. hvcurveto: [31]
  38919. };
  38920. class Type1CharString {
  38921. constructor() {
  38922. this.width = 0;
  38923. this.lsb = 0;
  38924. this.flexing = false;
  38925. this.output = [];
  38926. this.stack = [];
  38927. }
  38928. convert(encoded, subrs, seacAnalysisEnabled) {
  38929. const count = encoded.length;
  38930. let error = false;
  38931. let wx, sbx, subrNumber;
  38932. for (let i = 0; i < count; i++) {
  38933. let value = encoded[i];
  38934. if (value < 32) {
  38935. if (value === 12) {
  38936. value = (value << 8) + encoded[++i];
  38937. }
  38938. switch (value) {
  38939. case 1:
  38940. if (!HINTING_ENABLED) {
  38941. this.stack = [];
  38942. break;
  38943. }
  38944. error = this.executeCommand(2, COMMAND_MAP.hstem);
  38945. break;
  38946. case 3:
  38947. if (!HINTING_ENABLED) {
  38948. this.stack = [];
  38949. break;
  38950. }
  38951. error = this.executeCommand(2, COMMAND_MAP.vstem);
  38952. break;
  38953. case 4:
  38954. if (this.flexing) {
  38955. if (this.stack.length < 1) {
  38956. error = true;
  38957. break;
  38958. }
  38959. const dy = this.stack.pop();
  38960. this.stack.push(0, dy);
  38961. break;
  38962. }
  38963. error = this.executeCommand(1, COMMAND_MAP.vmoveto);
  38964. break;
  38965. case 5:
  38966. error = this.executeCommand(2, COMMAND_MAP.rlineto);
  38967. break;
  38968. case 6:
  38969. error = this.executeCommand(1, COMMAND_MAP.hlineto);
  38970. break;
  38971. case 7:
  38972. error = this.executeCommand(1, COMMAND_MAP.vlineto);
  38973. break;
  38974. case 8:
  38975. error = this.executeCommand(6, COMMAND_MAP.rrcurveto);
  38976. break;
  38977. case 9:
  38978. this.stack = [];
  38979. break;
  38980. case 10:
  38981. if (this.stack.length < 1) {
  38982. error = true;
  38983. break;
  38984. }
  38985. subrNumber = this.stack.pop();
  38986. if (!subrs[subrNumber]) {
  38987. error = true;
  38988. break;
  38989. }
  38990. error = this.convert(subrs[subrNumber], subrs, seacAnalysisEnabled);
  38991. break;
  38992. case 11:
  38993. return error;
  38994. case 13:
  38995. if (this.stack.length < 2) {
  38996. error = true;
  38997. break;
  38998. }
  38999. wx = this.stack.pop();
  39000. sbx = this.stack.pop();
  39001. this.lsb = sbx;
  39002. this.width = wx;
  39003. this.stack.push(wx, sbx);
  39004. error = this.executeCommand(2, COMMAND_MAP.hmoveto);
  39005. break;
  39006. case 14:
  39007. this.output.push(COMMAND_MAP.endchar[0]);
  39008. break;
  39009. case 21:
  39010. if (this.flexing) {
  39011. break;
  39012. }
  39013. error = this.executeCommand(2, COMMAND_MAP.rmoveto);
  39014. break;
  39015. case 22:
  39016. if (this.flexing) {
  39017. this.stack.push(0);
  39018. break;
  39019. }
  39020. error = this.executeCommand(1, COMMAND_MAP.hmoveto);
  39021. break;
  39022. case 30:
  39023. error = this.executeCommand(4, COMMAND_MAP.vhcurveto);
  39024. break;
  39025. case 31:
  39026. error = this.executeCommand(4, COMMAND_MAP.hvcurveto);
  39027. break;
  39028. case (12 << 8) + 0:
  39029. this.stack = [];
  39030. break;
  39031. case (12 << 8) + 1:
  39032. if (!HINTING_ENABLED) {
  39033. this.stack = [];
  39034. break;
  39035. }
  39036. error = this.executeCommand(2, COMMAND_MAP.vstem);
  39037. break;
  39038. case (12 << 8) + 2:
  39039. if (!HINTING_ENABLED) {
  39040. this.stack = [];
  39041. break;
  39042. }
  39043. error = this.executeCommand(2, COMMAND_MAP.hstem);
  39044. break;
  39045. case (12 << 8) + 6:
  39046. if (seacAnalysisEnabled) {
  39047. const asb = this.stack.at(-5);
  39048. this.seac = this.stack.splice(-4, 4);
  39049. this.seac[0] += this.lsb - asb;
  39050. error = this.executeCommand(0, COMMAND_MAP.endchar);
  39051. } else {
  39052. error = this.executeCommand(4, COMMAND_MAP.endchar);
  39053. }
  39054. break;
  39055. case (12 << 8) + 7:
  39056. if (this.stack.length < 4) {
  39057. error = true;
  39058. break;
  39059. }
  39060. this.stack.pop();
  39061. wx = this.stack.pop();
  39062. const sby = this.stack.pop();
  39063. sbx = this.stack.pop();
  39064. this.lsb = sbx;
  39065. this.width = wx;
  39066. this.stack.push(wx, sbx, sby);
  39067. error = this.executeCommand(3, COMMAND_MAP.rmoveto);
  39068. break;
  39069. case (12 << 8) + 12:
  39070. if (this.stack.length < 2) {
  39071. error = true;
  39072. break;
  39073. }
  39074. const num2 = this.stack.pop();
  39075. const num1 = this.stack.pop();
  39076. this.stack.push(num1 / num2);
  39077. break;
  39078. case (12 << 8) + 16:
  39079. if (this.stack.length < 2) {
  39080. error = true;
  39081. break;
  39082. }
  39083. subrNumber = this.stack.pop();
  39084. const numArgs = this.stack.pop();
  39085. if (subrNumber === 0 && numArgs === 3) {
  39086. const flexArgs = this.stack.splice(-17, 17);
  39087. 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]);
  39088. error = this.executeCommand(13, COMMAND_MAP.flex, true);
  39089. this.flexing = false;
  39090. this.stack.push(flexArgs[15], flexArgs[16]);
  39091. } else if (subrNumber === 1 && numArgs === 0) {
  39092. this.flexing = true;
  39093. }
  39094. break;
  39095. case (12 << 8) + 17:
  39096. break;
  39097. case (12 << 8) + 33:
  39098. this.stack = [];
  39099. break;
  39100. default:
  39101. (0, _util.warn)('Unknown type 1 charstring command of "' + value + '"');
  39102. break;
  39103. }
  39104. if (error) {
  39105. break;
  39106. }
  39107. continue;
  39108. } else if (value <= 246) {
  39109. value -= 139;
  39110. } else if (value <= 250) {
  39111. value = (value - 247) * 256 + encoded[++i] + 108;
  39112. } else if (value <= 254) {
  39113. value = -((value - 251) * 256) - encoded[++i] - 108;
  39114. } else {
  39115. value = (encoded[++i] & 0xff) << 24 | (encoded[++i] & 0xff) << 16 | (encoded[++i] & 0xff) << 8 | (encoded[++i] & 0xff) << 0;
  39116. }
  39117. this.stack.push(value);
  39118. }
  39119. return error;
  39120. }
  39121. executeCommand(howManyArgs, command, keepStack) {
  39122. const stackLength = this.stack.length;
  39123. if (howManyArgs > stackLength) {
  39124. return true;
  39125. }
  39126. const start = stackLength - howManyArgs;
  39127. for (let i = start; i < stackLength; i++) {
  39128. let value = this.stack[i];
  39129. if (Number.isInteger(value)) {
  39130. this.output.push(28, value >> 8 & 0xff, value & 0xff);
  39131. } else {
  39132. value = 65536 * value | 0;
  39133. this.output.push(255, value >> 24 & 0xff, value >> 16 & 0xff, value >> 8 & 0xff, value & 0xff);
  39134. }
  39135. }
  39136. this.output.push(...command);
  39137. if (keepStack) {
  39138. this.stack.splice(start, howManyArgs);
  39139. } else {
  39140. this.stack.length = 0;
  39141. }
  39142. return false;
  39143. }
  39144. }
  39145. const EEXEC_ENCRYPT_KEY = 55665;
  39146. const CHAR_STRS_ENCRYPT_KEY = 4330;
  39147. function isHexDigit(code) {
  39148. return code >= 48 && code <= 57 || code >= 65 && code <= 70 || code >= 97 && code <= 102;
  39149. }
  39150. function decrypt(data, key, discardNumber) {
  39151. if (discardNumber >= data.length) {
  39152. return new Uint8Array(0);
  39153. }
  39154. const c1 = 52845,
  39155. c2 = 22719;
  39156. let r = key | 0,
  39157. i,
  39158. j;
  39159. for (i = 0; i < discardNumber; i++) {
  39160. r = (data[i] + r) * c1 + c2 & (1 << 16) - 1;
  39161. }
  39162. const count = data.length - discardNumber;
  39163. const decrypted = new Uint8Array(count);
  39164. for (i = discardNumber, j = 0; j < count; i++, j++) {
  39165. const value = data[i];
  39166. decrypted[j] = value ^ r >> 8;
  39167. r = (value + r) * c1 + c2 & (1 << 16) - 1;
  39168. }
  39169. return decrypted;
  39170. }
  39171. function decryptAscii(data, key, discardNumber) {
  39172. const c1 = 52845,
  39173. c2 = 22719;
  39174. let r = key | 0;
  39175. const count = data.length,
  39176. maybeLength = count >>> 1;
  39177. const decrypted = new Uint8Array(maybeLength);
  39178. let i, j;
  39179. for (i = 0, j = 0; i < count; i++) {
  39180. const digit1 = data[i];
  39181. if (!isHexDigit(digit1)) {
  39182. continue;
  39183. }
  39184. i++;
  39185. let digit2;
  39186. while (i < count && !isHexDigit(digit2 = data[i])) {
  39187. i++;
  39188. }
  39189. if (i < count) {
  39190. const value = parseInt(String.fromCharCode(digit1, digit2), 16);
  39191. decrypted[j++] = value ^ r >> 8;
  39192. r = (value + r) * c1 + c2 & (1 << 16) - 1;
  39193. }
  39194. }
  39195. return decrypted.slice(discardNumber, j);
  39196. }
  39197. function isSpecial(c) {
  39198. return c === 0x2f || c === 0x5b || c === 0x5d || c === 0x7b || c === 0x7d || c === 0x28 || c === 0x29;
  39199. }
  39200. class Type1Parser {
  39201. constructor(stream, encrypted, seacAnalysisEnabled) {
  39202. if (encrypted) {
  39203. const data = stream.getBytes();
  39204. 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]));
  39205. stream = new _stream.Stream(isBinary ? decrypt(data, EEXEC_ENCRYPT_KEY, 4) : decryptAscii(data, EEXEC_ENCRYPT_KEY, 4));
  39206. }
  39207. this.seacAnalysisEnabled = !!seacAnalysisEnabled;
  39208. this.stream = stream;
  39209. this.nextChar();
  39210. }
  39211. readNumberArray() {
  39212. this.getToken();
  39213. const array = [];
  39214. while (true) {
  39215. const token = this.getToken();
  39216. if (token === null || token === "]" || token === "}") {
  39217. break;
  39218. }
  39219. array.push(parseFloat(token || 0));
  39220. }
  39221. return array;
  39222. }
  39223. readNumber() {
  39224. const token = this.getToken();
  39225. return parseFloat(token || 0);
  39226. }
  39227. readInt() {
  39228. const token = this.getToken();
  39229. return parseInt(token || 0, 10) | 0;
  39230. }
  39231. readBoolean() {
  39232. const token = this.getToken();
  39233. return token === "true" ? 1 : 0;
  39234. }
  39235. nextChar() {
  39236. return this.currentChar = this.stream.getByte();
  39237. }
  39238. prevChar() {
  39239. this.stream.skip(-2);
  39240. return this.currentChar = this.stream.getByte();
  39241. }
  39242. getToken() {
  39243. let comment = false;
  39244. let ch = this.currentChar;
  39245. while (true) {
  39246. if (ch === -1) {
  39247. return null;
  39248. }
  39249. if (comment) {
  39250. if (ch === 0x0a || ch === 0x0d) {
  39251. comment = false;
  39252. }
  39253. } else if (ch === 0x25) {
  39254. comment = true;
  39255. } else if (!(0, _core_utils.isWhiteSpace)(ch)) {
  39256. break;
  39257. }
  39258. ch = this.nextChar();
  39259. }
  39260. if (isSpecial(ch)) {
  39261. this.nextChar();
  39262. return String.fromCharCode(ch);
  39263. }
  39264. let token = "";
  39265. do {
  39266. token += String.fromCharCode(ch);
  39267. ch = this.nextChar();
  39268. } while (ch >= 0 && !(0, _core_utils.isWhiteSpace)(ch) && !isSpecial(ch));
  39269. return token;
  39270. }
  39271. readCharStrings(bytes, lenIV) {
  39272. if (lenIV === -1) {
  39273. return bytes;
  39274. }
  39275. return decrypt(bytes, CHAR_STRS_ENCRYPT_KEY, lenIV);
  39276. }
  39277. extractFontProgram(properties) {
  39278. const stream = this.stream;
  39279. const subrs = [],
  39280. charstrings = [];
  39281. const privateData = Object.create(null);
  39282. privateData.lenIV = 4;
  39283. const program = {
  39284. subrs: [],
  39285. charstrings: [],
  39286. properties: {
  39287. privateData
  39288. }
  39289. };
  39290. let token, length, data, lenIV;
  39291. while ((token = this.getToken()) !== null) {
  39292. if (token !== "/") {
  39293. continue;
  39294. }
  39295. token = this.getToken();
  39296. switch (token) {
  39297. case "CharStrings":
  39298. this.getToken();
  39299. this.getToken();
  39300. this.getToken();
  39301. this.getToken();
  39302. while (true) {
  39303. token = this.getToken();
  39304. if (token === null || token === "end") {
  39305. break;
  39306. }
  39307. if (token !== "/") {
  39308. continue;
  39309. }
  39310. const glyph = this.getToken();
  39311. length = this.readInt();
  39312. this.getToken();
  39313. data = length > 0 ? stream.getBytes(length) : new Uint8Array(0);
  39314. lenIV = program.properties.privateData.lenIV;
  39315. const encoded = this.readCharStrings(data, lenIV);
  39316. this.nextChar();
  39317. token = this.getToken();
  39318. if (token === "noaccess") {
  39319. this.getToken();
  39320. } else if (token === "/") {
  39321. this.prevChar();
  39322. }
  39323. charstrings.push({
  39324. glyph,
  39325. encoded
  39326. });
  39327. }
  39328. break;
  39329. case "Subrs":
  39330. this.readInt();
  39331. this.getToken();
  39332. while (this.getToken() === "dup") {
  39333. const index = this.readInt();
  39334. length = this.readInt();
  39335. this.getToken();
  39336. data = length > 0 ? stream.getBytes(length) : new Uint8Array(0);
  39337. lenIV = program.properties.privateData.lenIV;
  39338. const encoded = this.readCharStrings(data, lenIV);
  39339. this.nextChar();
  39340. token = this.getToken();
  39341. if (token === "noaccess") {
  39342. this.getToken();
  39343. }
  39344. subrs[index] = encoded;
  39345. }
  39346. break;
  39347. case "BlueValues":
  39348. case "OtherBlues":
  39349. case "FamilyBlues":
  39350. case "FamilyOtherBlues":
  39351. const blueArray = this.readNumberArray();
  39352. if (blueArray.length > 0 && blueArray.length % 2 === 0 && HINTING_ENABLED) {
  39353. program.properties.privateData[token] = blueArray;
  39354. }
  39355. break;
  39356. case "StemSnapH":
  39357. case "StemSnapV":
  39358. program.properties.privateData[token] = this.readNumberArray();
  39359. break;
  39360. case "StdHW":
  39361. case "StdVW":
  39362. program.properties.privateData[token] = this.readNumberArray()[0];
  39363. break;
  39364. case "BlueShift":
  39365. case "lenIV":
  39366. case "BlueFuzz":
  39367. case "BlueScale":
  39368. case "LanguageGroup":
  39369. program.properties.privateData[token] = this.readNumber();
  39370. break;
  39371. case "ExpansionFactor":
  39372. program.properties.privateData[token] = this.readNumber() || 0.06;
  39373. break;
  39374. case "ForceBold":
  39375. program.properties.privateData[token] = this.readBoolean();
  39376. break;
  39377. }
  39378. }
  39379. for (const {
  39380. encoded,
  39381. glyph
  39382. } of charstrings) {
  39383. const charString = new Type1CharString();
  39384. const error = charString.convert(encoded, subrs, this.seacAnalysisEnabled);
  39385. let output = charString.output;
  39386. if (error) {
  39387. output = [14];
  39388. }
  39389. const charStringObject = {
  39390. glyphName: glyph,
  39391. charstring: output,
  39392. width: charString.width,
  39393. lsb: charString.lsb,
  39394. seac: charString.seac
  39395. };
  39396. if (glyph === ".notdef") {
  39397. program.charstrings.unshift(charStringObject);
  39398. } else {
  39399. program.charstrings.push(charStringObject);
  39400. }
  39401. if (properties.builtInEncoding) {
  39402. const index = properties.builtInEncoding.indexOf(glyph);
  39403. if (index > -1 && properties.widths[index] === undefined && index >= properties.firstChar && index <= properties.lastChar) {
  39404. properties.widths[index] = charString.width;
  39405. }
  39406. }
  39407. }
  39408. return program;
  39409. }
  39410. extractFontHeader(properties) {
  39411. let token;
  39412. while ((token = this.getToken()) !== null) {
  39413. if (token !== "/") {
  39414. continue;
  39415. }
  39416. token = this.getToken();
  39417. switch (token) {
  39418. case "FontMatrix":
  39419. const matrix = this.readNumberArray();
  39420. properties.fontMatrix = matrix;
  39421. break;
  39422. case "Encoding":
  39423. const encodingArg = this.getToken();
  39424. let encoding;
  39425. if (!/^\d+$/.test(encodingArg)) {
  39426. encoding = (0, _encodings.getEncoding)(encodingArg);
  39427. } else {
  39428. encoding = [];
  39429. const size = parseInt(encodingArg, 10) | 0;
  39430. this.getToken();
  39431. for (let j = 0; j < size; j++) {
  39432. token = this.getToken();
  39433. while (token !== "dup" && token !== "def") {
  39434. token = this.getToken();
  39435. if (token === null) {
  39436. return;
  39437. }
  39438. }
  39439. if (token === "def") {
  39440. break;
  39441. }
  39442. const index = this.readInt();
  39443. this.getToken();
  39444. const glyph = this.getToken();
  39445. encoding[index] = glyph;
  39446. this.getToken();
  39447. }
  39448. }
  39449. properties.builtInEncoding = encoding;
  39450. break;
  39451. case "FontBBox":
  39452. const fontBBox = this.readNumberArray();
  39453. properties.ascent = Math.max(fontBBox[3], fontBBox[1]);
  39454. properties.descent = Math.min(fontBBox[1], fontBBox[3]);
  39455. properties.ascentScaled = true;
  39456. break;
  39457. }
  39458. }
  39459. }
  39460. }
  39461. exports.Type1Parser = Type1Parser;
  39462. /***/ }),
  39463. /* 201 */
  39464. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  39465. Object.defineProperty(exports, "__esModule", ({
  39466. value: true
  39467. }));
  39468. exports.Pattern = void 0;
  39469. exports.getTilingPatternIR = getTilingPatternIR;
  39470. __w_pdfjs_require__(84);
  39471. __w_pdfjs_require__(93);
  39472. __w_pdfjs_require__(94);
  39473. __w_pdfjs_require__(97);
  39474. __w_pdfjs_require__(99);
  39475. __w_pdfjs_require__(101);
  39476. __w_pdfjs_require__(105);
  39477. __w_pdfjs_require__(108);
  39478. __w_pdfjs_require__(115);
  39479. __w_pdfjs_require__(140);
  39480. __w_pdfjs_require__(160);
  39481. var _util = __w_pdfjs_require__(145);
  39482. var _base_stream = __w_pdfjs_require__(152);
  39483. var _colorspace = __w_pdfjs_require__(163);
  39484. var _core_utils = __w_pdfjs_require__(150);
  39485. const ShadingType = {
  39486. FUNCTION_BASED: 1,
  39487. AXIAL: 2,
  39488. RADIAL: 3,
  39489. FREE_FORM_MESH: 4,
  39490. LATTICE_FORM_MESH: 5,
  39491. COONS_PATCH_MESH: 6,
  39492. TENSOR_PATCH_MESH: 7
  39493. };
  39494. class Pattern {
  39495. constructor() {
  39496. (0, _util.unreachable)("Cannot initialize Pattern.");
  39497. }
  39498. static parseShading(shading, xref, res, pdfFunctionFactory, localColorSpaceCache) {
  39499. const dict = shading instanceof _base_stream.BaseStream ? shading.dict : shading;
  39500. const type = dict.get("ShadingType");
  39501. try {
  39502. switch (type) {
  39503. case ShadingType.AXIAL:
  39504. case ShadingType.RADIAL:
  39505. return new RadialAxialShading(dict, xref, res, pdfFunctionFactory, localColorSpaceCache);
  39506. case ShadingType.FREE_FORM_MESH:
  39507. case ShadingType.LATTICE_FORM_MESH:
  39508. case ShadingType.COONS_PATCH_MESH:
  39509. case ShadingType.TENSOR_PATCH_MESH:
  39510. return new MeshShading(shading, xref, res, pdfFunctionFactory, localColorSpaceCache);
  39511. default:
  39512. throw new _util.FormatError("Unsupported ShadingType: " + type);
  39513. }
  39514. } catch (ex) {
  39515. if (ex instanceof _core_utils.MissingDataException) {
  39516. throw ex;
  39517. }
  39518. (0, _util.warn)(ex);
  39519. return new DummyShading();
  39520. }
  39521. }
  39522. }
  39523. exports.Pattern = Pattern;
  39524. class BaseShading {
  39525. static SMALL_NUMBER = 1e-6;
  39526. constructor() {
  39527. if (this.constructor === BaseShading) {
  39528. (0, _util.unreachable)("Cannot initialize BaseShading.");
  39529. }
  39530. }
  39531. getIR() {
  39532. (0, _util.unreachable)("Abstract method `getIR` called.");
  39533. }
  39534. }
  39535. class RadialAxialShading extends BaseShading {
  39536. constructor(dict, xref, resources, pdfFunctionFactory, localColorSpaceCache) {
  39537. super();
  39538. this.coordsArr = dict.getArray("Coords");
  39539. this.shadingType = dict.get("ShadingType");
  39540. const cs = _colorspace.ColorSpace.parse({
  39541. cs: dict.getRaw("CS") || dict.getRaw("ColorSpace"),
  39542. xref,
  39543. resources,
  39544. pdfFunctionFactory,
  39545. localColorSpaceCache
  39546. });
  39547. const bbox = dict.getArray("BBox");
  39548. this.bbox = Array.isArray(bbox) && bbox.length === 4 ? _util.Util.normalizeRect(bbox) : null;
  39549. let t0 = 0.0,
  39550. t1 = 1.0;
  39551. if (dict.has("Domain")) {
  39552. const domainArr = dict.getArray("Domain");
  39553. t0 = domainArr[0];
  39554. t1 = domainArr[1];
  39555. }
  39556. let extendStart = false,
  39557. extendEnd = false;
  39558. if (dict.has("Extend")) {
  39559. const extendArr = dict.getArray("Extend");
  39560. extendStart = extendArr[0];
  39561. extendEnd = extendArr[1];
  39562. }
  39563. if (this.shadingType === ShadingType.RADIAL && (!extendStart || !extendEnd)) {
  39564. const [x1, y1, r1, x2, y2, r2] = this.coordsArr;
  39565. const distance = Math.hypot(x1 - x2, y1 - y2);
  39566. if (r1 <= r2 + distance && r2 <= r1 + distance) {
  39567. (0, _util.warn)("Unsupported radial gradient.");
  39568. }
  39569. }
  39570. this.extendStart = extendStart;
  39571. this.extendEnd = extendEnd;
  39572. const fnObj = dict.getRaw("Function");
  39573. const fn = pdfFunctionFactory.createFromArray(fnObj);
  39574. const NUMBER_OF_SAMPLES = 840;
  39575. const step = (t1 - t0) / NUMBER_OF_SAMPLES;
  39576. const colorStops = this.colorStops = [];
  39577. if (t0 >= t1 || step <= 0) {
  39578. (0, _util.info)("Bad shading domain.");
  39579. return;
  39580. }
  39581. const color = new Float32Array(cs.numComps),
  39582. ratio = new Float32Array(1);
  39583. let rgbColor;
  39584. let iBase = 0;
  39585. ratio[0] = t0;
  39586. fn(ratio, 0, color, 0);
  39587. let rgbBase = cs.getRgb(color, 0);
  39588. const cssColorBase = _util.Util.makeHexColor(rgbBase[0], rgbBase[1], rgbBase[2]);
  39589. colorStops.push([0, cssColorBase]);
  39590. let iPrev = 1;
  39591. ratio[0] = t0 + step;
  39592. fn(ratio, 0, color, 0);
  39593. let rgbPrev = cs.getRgb(color, 0);
  39594. let maxSlopeR = rgbPrev[0] - rgbBase[0] + 1;
  39595. let maxSlopeG = rgbPrev[1] - rgbBase[1] + 1;
  39596. let maxSlopeB = rgbPrev[2] - rgbBase[2] + 1;
  39597. let minSlopeR = rgbPrev[0] - rgbBase[0] - 1;
  39598. let minSlopeG = rgbPrev[1] - rgbBase[1] - 1;
  39599. let minSlopeB = rgbPrev[2] - rgbBase[2] - 1;
  39600. for (let i = 2; i < NUMBER_OF_SAMPLES; i++) {
  39601. ratio[0] = t0 + i * step;
  39602. fn(ratio, 0, color, 0);
  39603. rgbColor = cs.getRgb(color, 0);
  39604. const run = i - iBase;
  39605. maxSlopeR = Math.min(maxSlopeR, (rgbColor[0] - rgbBase[0] + 1) / run);
  39606. maxSlopeG = Math.min(maxSlopeG, (rgbColor[1] - rgbBase[1] + 1) / run);
  39607. maxSlopeB = Math.min(maxSlopeB, (rgbColor[2] - rgbBase[2] + 1) / run);
  39608. minSlopeR = Math.max(minSlopeR, (rgbColor[0] - rgbBase[0] - 1) / run);
  39609. minSlopeG = Math.max(minSlopeG, (rgbColor[1] - rgbBase[1] - 1) / run);
  39610. minSlopeB = Math.max(minSlopeB, (rgbColor[2] - rgbBase[2] - 1) / run);
  39611. const slopesExist = minSlopeR <= maxSlopeR && minSlopeG <= maxSlopeG && minSlopeB <= maxSlopeB;
  39612. if (!slopesExist) {
  39613. const cssColor = _util.Util.makeHexColor(rgbPrev[0], rgbPrev[1], rgbPrev[2]);
  39614. colorStops.push([iPrev / NUMBER_OF_SAMPLES, cssColor]);
  39615. maxSlopeR = rgbColor[0] - rgbPrev[0] + 1;
  39616. maxSlopeG = rgbColor[1] - rgbPrev[1] + 1;
  39617. maxSlopeB = rgbColor[2] - rgbPrev[2] + 1;
  39618. minSlopeR = rgbColor[0] - rgbPrev[0] - 1;
  39619. minSlopeG = rgbColor[1] - rgbPrev[1] - 1;
  39620. minSlopeB = rgbColor[2] - rgbPrev[2] - 1;
  39621. iBase = iPrev;
  39622. rgbBase = rgbPrev;
  39623. }
  39624. iPrev = i;
  39625. rgbPrev = rgbColor;
  39626. }
  39627. const cssColor = _util.Util.makeHexColor(rgbPrev[0], rgbPrev[1], rgbPrev[2]);
  39628. colorStops.push([1, cssColor]);
  39629. let background = "transparent";
  39630. if (dict.has("Background")) {
  39631. rgbColor = cs.getRgb(dict.get("Background"), 0);
  39632. background = _util.Util.makeHexColor(rgbColor[0], rgbColor[1], rgbColor[2]);
  39633. }
  39634. if (!extendStart) {
  39635. colorStops.unshift([0, background]);
  39636. colorStops[1][0] += BaseShading.SMALL_NUMBER;
  39637. }
  39638. if (!extendEnd) {
  39639. colorStops.at(-1)[0] -= BaseShading.SMALL_NUMBER;
  39640. colorStops.push([1, background]);
  39641. }
  39642. this.colorStops = colorStops;
  39643. }
  39644. getIR() {
  39645. const coordsArr = this.coordsArr;
  39646. const shadingType = this.shadingType;
  39647. let type, p0, p1, r0, r1;
  39648. if (shadingType === ShadingType.AXIAL) {
  39649. p0 = [coordsArr[0], coordsArr[1]];
  39650. p1 = [coordsArr[2], coordsArr[3]];
  39651. r0 = null;
  39652. r1 = null;
  39653. type = "axial";
  39654. } else if (shadingType === ShadingType.RADIAL) {
  39655. p0 = [coordsArr[0], coordsArr[1]];
  39656. p1 = [coordsArr[3], coordsArr[4]];
  39657. r0 = coordsArr[2];
  39658. r1 = coordsArr[5];
  39659. type = "radial";
  39660. } else {
  39661. (0, _util.unreachable)(`getPattern type unknown: ${shadingType}`);
  39662. }
  39663. return ["RadialAxial", type, this.bbox, this.colorStops, p0, p1, r0, r1];
  39664. }
  39665. }
  39666. class MeshStreamReader {
  39667. constructor(stream, context) {
  39668. this.stream = stream;
  39669. this.context = context;
  39670. this.buffer = 0;
  39671. this.bufferLength = 0;
  39672. const numComps = context.numComps;
  39673. this.tmpCompsBuf = new Float32Array(numComps);
  39674. const csNumComps = context.colorSpace.numComps;
  39675. this.tmpCsCompsBuf = context.colorFn ? new Float32Array(csNumComps) : this.tmpCompsBuf;
  39676. }
  39677. get hasData() {
  39678. if (this.stream.end) {
  39679. return this.stream.pos < this.stream.end;
  39680. }
  39681. if (this.bufferLength > 0) {
  39682. return true;
  39683. }
  39684. const nextByte = this.stream.getByte();
  39685. if (nextByte < 0) {
  39686. return false;
  39687. }
  39688. this.buffer = nextByte;
  39689. this.bufferLength = 8;
  39690. return true;
  39691. }
  39692. readBits(n) {
  39693. let buffer = this.buffer;
  39694. let bufferLength = this.bufferLength;
  39695. if (n === 32) {
  39696. if (bufferLength === 0) {
  39697. return (this.stream.getByte() << 24 | this.stream.getByte() << 16 | this.stream.getByte() << 8 | this.stream.getByte()) >>> 0;
  39698. }
  39699. buffer = buffer << 24 | this.stream.getByte() << 16 | this.stream.getByte() << 8 | this.stream.getByte();
  39700. const nextByte = this.stream.getByte();
  39701. this.buffer = nextByte & (1 << bufferLength) - 1;
  39702. return (buffer << 8 - bufferLength | (nextByte & 0xff) >> bufferLength) >>> 0;
  39703. }
  39704. if (n === 8 && bufferLength === 0) {
  39705. return this.stream.getByte();
  39706. }
  39707. while (bufferLength < n) {
  39708. buffer = buffer << 8 | this.stream.getByte();
  39709. bufferLength += 8;
  39710. }
  39711. bufferLength -= n;
  39712. this.bufferLength = bufferLength;
  39713. this.buffer = buffer & (1 << bufferLength) - 1;
  39714. return buffer >> bufferLength;
  39715. }
  39716. align() {
  39717. this.buffer = 0;
  39718. this.bufferLength = 0;
  39719. }
  39720. readFlag() {
  39721. return this.readBits(this.context.bitsPerFlag);
  39722. }
  39723. readCoordinate() {
  39724. const bitsPerCoordinate = this.context.bitsPerCoordinate;
  39725. const xi = this.readBits(bitsPerCoordinate);
  39726. const yi = this.readBits(bitsPerCoordinate);
  39727. const decode = this.context.decode;
  39728. const scale = bitsPerCoordinate < 32 ? 1 / ((1 << bitsPerCoordinate) - 1) : 2.3283064365386963e-10;
  39729. return [xi * scale * (decode[1] - decode[0]) + decode[0], yi * scale * (decode[3] - decode[2]) + decode[2]];
  39730. }
  39731. readComponents() {
  39732. const numComps = this.context.numComps;
  39733. const bitsPerComponent = this.context.bitsPerComponent;
  39734. const scale = bitsPerComponent < 32 ? 1 / ((1 << bitsPerComponent) - 1) : 2.3283064365386963e-10;
  39735. const decode = this.context.decode;
  39736. const components = this.tmpCompsBuf;
  39737. for (let i = 0, j = 4; i < numComps; i++, j += 2) {
  39738. const ci = this.readBits(bitsPerComponent);
  39739. components[i] = ci * scale * (decode[j + 1] - decode[j]) + decode[j];
  39740. }
  39741. const color = this.tmpCsCompsBuf;
  39742. if (this.context.colorFn) {
  39743. this.context.colorFn(components, 0, color, 0);
  39744. }
  39745. return this.context.colorSpace.getRgb(color, 0);
  39746. }
  39747. }
  39748. const getB = function getBClosure() {
  39749. function buildB(count) {
  39750. const lut = [];
  39751. for (let i = 0; i <= count; i++) {
  39752. const t = i / count,
  39753. t_ = 1 - t;
  39754. lut.push(new Float32Array([t_ * t_ * t_, 3 * t * t_ * t_, 3 * t * t * t_, t * t * t]));
  39755. }
  39756. return lut;
  39757. }
  39758. const cache = Object.create(null);
  39759. return function (count) {
  39760. return cache[count] ||= buildB(count);
  39761. };
  39762. }();
  39763. class MeshShading extends BaseShading {
  39764. static MIN_SPLIT_PATCH_CHUNKS_AMOUNT = 3;
  39765. static MAX_SPLIT_PATCH_CHUNKS_AMOUNT = 20;
  39766. static TRIANGLE_DENSITY = 20;
  39767. constructor(stream, xref, resources, pdfFunctionFactory, localColorSpaceCache) {
  39768. super();
  39769. if (!(stream instanceof _base_stream.BaseStream)) {
  39770. throw new _util.FormatError("Mesh data is not a stream");
  39771. }
  39772. const dict = stream.dict;
  39773. this.shadingType = dict.get("ShadingType");
  39774. const bbox = dict.getArray("BBox");
  39775. this.bbox = Array.isArray(bbox) && bbox.length === 4 ? _util.Util.normalizeRect(bbox) : null;
  39776. const cs = _colorspace.ColorSpace.parse({
  39777. cs: dict.getRaw("CS") || dict.getRaw("ColorSpace"),
  39778. xref,
  39779. resources,
  39780. pdfFunctionFactory,
  39781. localColorSpaceCache
  39782. });
  39783. this.background = dict.has("Background") ? cs.getRgb(dict.get("Background"), 0) : null;
  39784. const fnObj = dict.getRaw("Function");
  39785. const fn = fnObj ? pdfFunctionFactory.createFromArray(fnObj) : null;
  39786. this.coords = [];
  39787. this.colors = [];
  39788. this.figures = [];
  39789. const decodeContext = {
  39790. bitsPerCoordinate: dict.get("BitsPerCoordinate"),
  39791. bitsPerComponent: dict.get("BitsPerComponent"),
  39792. bitsPerFlag: dict.get("BitsPerFlag"),
  39793. decode: dict.getArray("Decode"),
  39794. colorFn: fn,
  39795. colorSpace: cs,
  39796. numComps: fn ? 1 : cs.numComps
  39797. };
  39798. const reader = new MeshStreamReader(stream, decodeContext);
  39799. let patchMesh = false;
  39800. switch (this.shadingType) {
  39801. case ShadingType.FREE_FORM_MESH:
  39802. this._decodeType4Shading(reader);
  39803. break;
  39804. case ShadingType.LATTICE_FORM_MESH:
  39805. const verticesPerRow = dict.get("VerticesPerRow") | 0;
  39806. if (verticesPerRow < 2) {
  39807. throw new _util.FormatError("Invalid VerticesPerRow");
  39808. }
  39809. this._decodeType5Shading(reader, verticesPerRow);
  39810. break;
  39811. case ShadingType.COONS_PATCH_MESH:
  39812. this._decodeType6Shading(reader);
  39813. patchMesh = true;
  39814. break;
  39815. case ShadingType.TENSOR_PATCH_MESH:
  39816. this._decodeType7Shading(reader);
  39817. patchMesh = true;
  39818. break;
  39819. default:
  39820. (0, _util.unreachable)("Unsupported mesh type.");
  39821. break;
  39822. }
  39823. if (patchMesh) {
  39824. this._updateBounds();
  39825. for (let i = 0, ii = this.figures.length; i < ii; i++) {
  39826. this._buildFigureFromPatch(i);
  39827. }
  39828. }
  39829. this._updateBounds();
  39830. this._packData();
  39831. }
  39832. _decodeType4Shading(reader) {
  39833. const coords = this.coords;
  39834. const colors = this.colors;
  39835. const operators = [];
  39836. const ps = [];
  39837. let verticesLeft = 0;
  39838. while (reader.hasData) {
  39839. const f = reader.readFlag();
  39840. const coord = reader.readCoordinate();
  39841. const color = reader.readComponents();
  39842. if (verticesLeft === 0) {
  39843. if (!(0 <= f && f <= 2)) {
  39844. throw new _util.FormatError("Unknown type4 flag");
  39845. }
  39846. switch (f) {
  39847. case 0:
  39848. verticesLeft = 3;
  39849. break;
  39850. case 1:
  39851. ps.push(ps.at(-2), ps.at(-1));
  39852. verticesLeft = 1;
  39853. break;
  39854. case 2:
  39855. ps.push(ps.at(-3), ps.at(-1));
  39856. verticesLeft = 1;
  39857. break;
  39858. }
  39859. operators.push(f);
  39860. }
  39861. ps.push(coords.length);
  39862. coords.push(coord);
  39863. colors.push(color);
  39864. verticesLeft--;
  39865. reader.align();
  39866. }
  39867. this.figures.push({
  39868. type: "triangles",
  39869. coords: new Int32Array(ps),
  39870. colors: new Int32Array(ps)
  39871. });
  39872. }
  39873. _decodeType5Shading(reader, verticesPerRow) {
  39874. const coords = this.coords;
  39875. const colors = this.colors;
  39876. const ps = [];
  39877. while (reader.hasData) {
  39878. const coord = reader.readCoordinate();
  39879. const color = reader.readComponents();
  39880. ps.push(coords.length);
  39881. coords.push(coord);
  39882. colors.push(color);
  39883. }
  39884. this.figures.push({
  39885. type: "lattice",
  39886. coords: new Int32Array(ps),
  39887. colors: new Int32Array(ps),
  39888. verticesPerRow
  39889. });
  39890. }
  39891. _decodeType6Shading(reader) {
  39892. const coords = this.coords;
  39893. const colors = this.colors;
  39894. const ps = new Int32Array(16);
  39895. const cs = new Int32Array(4);
  39896. while (reader.hasData) {
  39897. const f = reader.readFlag();
  39898. if (!(0 <= f && f <= 3)) {
  39899. throw new _util.FormatError("Unknown type6 flag");
  39900. }
  39901. const pi = coords.length;
  39902. for (let i = 0, ii = f !== 0 ? 8 : 12; i < ii; i++) {
  39903. coords.push(reader.readCoordinate());
  39904. }
  39905. const ci = colors.length;
  39906. for (let i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) {
  39907. colors.push(reader.readComponents());
  39908. }
  39909. let tmp1, tmp2, tmp3, tmp4;
  39910. switch (f) {
  39911. case 0:
  39912. ps[12] = pi + 3;
  39913. ps[13] = pi + 4;
  39914. ps[14] = pi + 5;
  39915. ps[15] = pi + 6;
  39916. ps[8] = pi + 2;
  39917. ps[11] = pi + 7;
  39918. ps[4] = pi + 1;
  39919. ps[7] = pi + 8;
  39920. ps[0] = pi;
  39921. ps[1] = pi + 11;
  39922. ps[2] = pi + 10;
  39923. ps[3] = pi + 9;
  39924. cs[2] = ci + 1;
  39925. cs[3] = ci + 2;
  39926. cs[0] = ci;
  39927. cs[1] = ci + 3;
  39928. break;
  39929. case 1:
  39930. tmp1 = ps[12];
  39931. tmp2 = ps[13];
  39932. tmp3 = ps[14];
  39933. tmp4 = ps[15];
  39934. ps[12] = tmp4;
  39935. ps[13] = pi + 0;
  39936. ps[14] = pi + 1;
  39937. ps[15] = pi + 2;
  39938. ps[8] = tmp3;
  39939. ps[11] = pi + 3;
  39940. ps[4] = tmp2;
  39941. ps[7] = pi + 4;
  39942. ps[0] = tmp1;
  39943. ps[1] = pi + 7;
  39944. ps[2] = pi + 6;
  39945. ps[3] = pi + 5;
  39946. tmp1 = cs[2];
  39947. tmp2 = cs[3];
  39948. cs[2] = tmp2;
  39949. cs[3] = ci;
  39950. cs[0] = tmp1;
  39951. cs[1] = ci + 1;
  39952. break;
  39953. case 2:
  39954. tmp1 = ps[15];
  39955. tmp2 = ps[11];
  39956. ps[12] = ps[3];
  39957. ps[13] = pi + 0;
  39958. ps[14] = pi + 1;
  39959. ps[15] = pi + 2;
  39960. ps[8] = ps[7];
  39961. ps[11] = pi + 3;
  39962. ps[4] = tmp2;
  39963. ps[7] = pi + 4;
  39964. ps[0] = tmp1;
  39965. ps[1] = pi + 7;
  39966. ps[2] = pi + 6;
  39967. ps[3] = pi + 5;
  39968. tmp1 = cs[3];
  39969. cs[2] = cs[1];
  39970. cs[3] = ci;
  39971. cs[0] = tmp1;
  39972. cs[1] = ci + 1;
  39973. break;
  39974. case 3:
  39975. ps[12] = ps[0];
  39976. ps[13] = pi + 0;
  39977. ps[14] = pi + 1;
  39978. ps[15] = pi + 2;
  39979. ps[8] = ps[1];
  39980. ps[11] = pi + 3;
  39981. ps[4] = ps[2];
  39982. ps[7] = pi + 4;
  39983. ps[0] = ps[3];
  39984. ps[1] = pi + 7;
  39985. ps[2] = pi + 6;
  39986. ps[3] = pi + 5;
  39987. cs[2] = cs[0];
  39988. cs[3] = ci;
  39989. cs[0] = cs[1];
  39990. cs[1] = ci + 1;
  39991. break;
  39992. }
  39993. ps[5] = coords.length;
  39994. 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]);
  39995. ps[6] = coords.length;
  39996. 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]);
  39997. ps[9] = coords.length;
  39998. 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]);
  39999. ps[10] = coords.length;
  40000. 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]);
  40001. this.figures.push({
  40002. type: "patch",
  40003. coords: new Int32Array(ps),
  40004. colors: new Int32Array(cs)
  40005. });
  40006. }
  40007. }
  40008. _decodeType7Shading(reader) {
  40009. const coords = this.coords;
  40010. const colors = this.colors;
  40011. const ps = new Int32Array(16);
  40012. const cs = new Int32Array(4);
  40013. while (reader.hasData) {
  40014. const f = reader.readFlag();
  40015. if (!(0 <= f && f <= 3)) {
  40016. throw new _util.FormatError("Unknown type7 flag");
  40017. }
  40018. const pi = coords.length;
  40019. for (let i = 0, ii = f !== 0 ? 12 : 16; i < ii; i++) {
  40020. coords.push(reader.readCoordinate());
  40021. }
  40022. const ci = colors.length;
  40023. for (let i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) {
  40024. colors.push(reader.readComponents());
  40025. }
  40026. let tmp1, tmp2, tmp3, tmp4;
  40027. switch (f) {
  40028. case 0:
  40029. ps[12] = pi + 3;
  40030. ps[13] = pi + 4;
  40031. ps[14] = pi + 5;
  40032. ps[15] = pi + 6;
  40033. ps[8] = pi + 2;
  40034. ps[9] = pi + 13;
  40035. ps[10] = pi + 14;
  40036. ps[11] = pi + 7;
  40037. ps[4] = pi + 1;
  40038. ps[5] = pi + 12;
  40039. ps[6] = pi + 15;
  40040. ps[7] = pi + 8;
  40041. ps[0] = pi;
  40042. ps[1] = pi + 11;
  40043. ps[2] = pi + 10;
  40044. ps[3] = pi + 9;
  40045. cs[2] = ci + 1;
  40046. cs[3] = ci + 2;
  40047. cs[0] = ci;
  40048. cs[1] = ci + 3;
  40049. break;
  40050. case 1:
  40051. tmp1 = ps[12];
  40052. tmp2 = ps[13];
  40053. tmp3 = ps[14];
  40054. tmp4 = ps[15];
  40055. ps[12] = tmp4;
  40056. ps[13] = pi + 0;
  40057. ps[14] = pi + 1;
  40058. ps[15] = pi + 2;
  40059. ps[8] = tmp3;
  40060. ps[9] = pi + 9;
  40061. ps[10] = pi + 10;
  40062. ps[11] = pi + 3;
  40063. ps[4] = tmp2;
  40064. ps[5] = pi + 8;
  40065. ps[6] = pi + 11;
  40066. ps[7] = pi + 4;
  40067. ps[0] = tmp1;
  40068. ps[1] = pi + 7;
  40069. ps[2] = pi + 6;
  40070. ps[3] = pi + 5;
  40071. tmp1 = cs[2];
  40072. tmp2 = cs[3];
  40073. cs[2] = tmp2;
  40074. cs[3] = ci;
  40075. cs[0] = tmp1;
  40076. cs[1] = ci + 1;
  40077. break;
  40078. case 2:
  40079. tmp1 = ps[15];
  40080. tmp2 = ps[11];
  40081. ps[12] = ps[3];
  40082. ps[13] = pi + 0;
  40083. ps[14] = pi + 1;
  40084. ps[15] = pi + 2;
  40085. ps[8] = ps[7];
  40086. ps[9] = pi + 9;
  40087. ps[10] = pi + 10;
  40088. ps[11] = pi + 3;
  40089. ps[4] = tmp2;
  40090. ps[5] = pi + 8;
  40091. ps[6] = pi + 11;
  40092. ps[7] = pi + 4;
  40093. ps[0] = tmp1;
  40094. ps[1] = pi + 7;
  40095. ps[2] = pi + 6;
  40096. ps[3] = pi + 5;
  40097. tmp1 = cs[3];
  40098. cs[2] = cs[1];
  40099. cs[3] = ci;
  40100. cs[0] = tmp1;
  40101. cs[1] = ci + 1;
  40102. break;
  40103. case 3:
  40104. ps[12] = ps[0];
  40105. ps[13] = pi + 0;
  40106. ps[14] = pi + 1;
  40107. ps[15] = pi + 2;
  40108. ps[8] = ps[1];
  40109. ps[9] = pi + 9;
  40110. ps[10] = pi + 10;
  40111. ps[11] = pi + 3;
  40112. ps[4] = ps[2];
  40113. ps[5] = pi + 8;
  40114. ps[6] = pi + 11;
  40115. ps[7] = pi + 4;
  40116. ps[0] = ps[3];
  40117. ps[1] = pi + 7;
  40118. ps[2] = pi + 6;
  40119. ps[3] = pi + 5;
  40120. cs[2] = cs[0];
  40121. cs[3] = ci;
  40122. cs[0] = cs[1];
  40123. cs[1] = ci + 1;
  40124. break;
  40125. }
  40126. this.figures.push({
  40127. type: "patch",
  40128. coords: new Int32Array(ps),
  40129. colors: new Int32Array(cs)
  40130. });
  40131. }
  40132. }
  40133. _buildFigureFromPatch(index) {
  40134. const figure = this.figures[index];
  40135. (0, _util.assert)(figure.type === "patch", "Unexpected patch mesh figure");
  40136. const coords = this.coords,
  40137. colors = this.colors;
  40138. const pi = figure.coords;
  40139. const ci = figure.colors;
  40140. const figureMinX = Math.min(coords[pi[0]][0], coords[pi[3]][0], coords[pi[12]][0], coords[pi[15]][0]);
  40141. const figureMinY = Math.min(coords[pi[0]][1], coords[pi[3]][1], coords[pi[12]][1], coords[pi[15]][1]);
  40142. const figureMaxX = Math.max(coords[pi[0]][0], coords[pi[3]][0], coords[pi[12]][0], coords[pi[15]][0]);
  40143. const figureMaxY = Math.max(coords[pi[0]][1], coords[pi[3]][1], coords[pi[12]][1], coords[pi[15]][1]);
  40144. let splitXBy = Math.ceil((figureMaxX - figureMinX) * MeshShading.TRIANGLE_DENSITY / (this.bounds[2] - this.bounds[0]));
  40145. splitXBy = Math.max(MeshShading.MIN_SPLIT_PATCH_CHUNKS_AMOUNT, Math.min(MeshShading.MAX_SPLIT_PATCH_CHUNKS_AMOUNT, splitXBy));
  40146. let splitYBy = Math.ceil((figureMaxY - figureMinY) * MeshShading.TRIANGLE_DENSITY / (this.bounds[3] - this.bounds[1]));
  40147. splitYBy = Math.max(MeshShading.MIN_SPLIT_PATCH_CHUNKS_AMOUNT, Math.min(MeshShading.MAX_SPLIT_PATCH_CHUNKS_AMOUNT, splitYBy));
  40148. const verticesPerRow = splitXBy + 1;
  40149. const figureCoords = new Int32Array((splitYBy + 1) * verticesPerRow);
  40150. const figureColors = new Int32Array((splitYBy + 1) * verticesPerRow);
  40151. let k = 0;
  40152. const cl = new Uint8Array(3),
  40153. cr = new Uint8Array(3);
  40154. const c0 = colors[ci[0]],
  40155. c1 = colors[ci[1]],
  40156. c2 = colors[ci[2]],
  40157. c3 = colors[ci[3]];
  40158. const bRow = getB(splitYBy),
  40159. bCol = getB(splitXBy);
  40160. for (let row = 0; row <= splitYBy; row++) {
  40161. cl[0] = (c0[0] * (splitYBy - row) + c2[0] * row) / splitYBy | 0;
  40162. cl[1] = (c0[1] * (splitYBy - row) + c2[1] * row) / splitYBy | 0;
  40163. cl[2] = (c0[2] * (splitYBy - row) + c2[2] * row) / splitYBy | 0;
  40164. cr[0] = (c1[0] * (splitYBy - row) + c3[0] * row) / splitYBy | 0;
  40165. cr[1] = (c1[1] * (splitYBy - row) + c3[1] * row) / splitYBy | 0;
  40166. cr[2] = (c1[2] * (splitYBy - row) + c3[2] * row) / splitYBy | 0;
  40167. for (let col = 0; col <= splitXBy; col++, k++) {
  40168. if ((row === 0 || row === splitYBy) && (col === 0 || col === splitXBy)) {
  40169. continue;
  40170. }
  40171. let x = 0,
  40172. y = 0;
  40173. let q = 0;
  40174. for (let i = 0; i <= 3; i++) {
  40175. for (let j = 0; j <= 3; j++, q++) {
  40176. const m = bRow[row][i] * bCol[col][j];
  40177. x += coords[pi[q]][0] * m;
  40178. y += coords[pi[q]][1] * m;
  40179. }
  40180. }
  40181. figureCoords[k] = coords.length;
  40182. coords.push([x, y]);
  40183. figureColors[k] = colors.length;
  40184. const newColor = new Uint8Array(3);
  40185. newColor[0] = (cl[0] * (splitXBy - col) + cr[0] * col) / splitXBy | 0;
  40186. newColor[1] = (cl[1] * (splitXBy - col) + cr[1] * col) / splitXBy | 0;
  40187. newColor[2] = (cl[2] * (splitXBy - col) + cr[2] * col) / splitXBy | 0;
  40188. colors.push(newColor);
  40189. }
  40190. }
  40191. figureCoords[0] = pi[0];
  40192. figureColors[0] = ci[0];
  40193. figureCoords[splitXBy] = pi[3];
  40194. figureColors[splitXBy] = ci[1];
  40195. figureCoords[verticesPerRow * splitYBy] = pi[12];
  40196. figureColors[verticesPerRow * splitYBy] = ci[2];
  40197. figureCoords[verticesPerRow * splitYBy + splitXBy] = pi[15];
  40198. figureColors[verticesPerRow * splitYBy + splitXBy] = ci[3];
  40199. this.figures[index] = {
  40200. type: "lattice",
  40201. coords: figureCoords,
  40202. colors: figureColors,
  40203. verticesPerRow
  40204. };
  40205. }
  40206. _updateBounds() {
  40207. let minX = this.coords[0][0],
  40208. minY = this.coords[0][1],
  40209. maxX = minX,
  40210. maxY = minY;
  40211. for (let i = 1, ii = this.coords.length; i < ii; i++) {
  40212. const x = this.coords[i][0],
  40213. y = this.coords[i][1];
  40214. minX = minX > x ? x : minX;
  40215. minY = minY > y ? y : minY;
  40216. maxX = maxX < x ? x : maxX;
  40217. maxY = maxY < y ? y : maxY;
  40218. }
  40219. this.bounds = [minX, minY, maxX, maxY];
  40220. }
  40221. _packData() {
  40222. let i, ii, j, jj;
  40223. const coords = this.coords;
  40224. const coordsPacked = new Float32Array(coords.length * 2);
  40225. for (i = 0, j = 0, ii = coords.length; i < ii; i++) {
  40226. const xy = coords[i];
  40227. coordsPacked[j++] = xy[0];
  40228. coordsPacked[j++] = xy[1];
  40229. }
  40230. this.coords = coordsPacked;
  40231. const colors = this.colors;
  40232. const colorsPacked = new Uint8Array(colors.length * 3);
  40233. for (i = 0, j = 0, ii = colors.length; i < ii; i++) {
  40234. const c = colors[i];
  40235. colorsPacked[j++] = c[0];
  40236. colorsPacked[j++] = c[1];
  40237. colorsPacked[j++] = c[2];
  40238. }
  40239. this.colors = colorsPacked;
  40240. const figures = this.figures;
  40241. for (i = 0, ii = figures.length; i < ii; i++) {
  40242. const figure = figures[i],
  40243. ps = figure.coords,
  40244. cs = figure.colors;
  40245. for (j = 0, jj = ps.length; j < jj; j++) {
  40246. ps[j] *= 2;
  40247. cs[j] *= 3;
  40248. }
  40249. }
  40250. }
  40251. getIR() {
  40252. return ["Mesh", this.shadingType, this.coords, this.colors, this.figures, this.bounds, this.bbox, this.background];
  40253. }
  40254. }
  40255. class DummyShading extends BaseShading {
  40256. getIR() {
  40257. return ["Dummy"];
  40258. }
  40259. }
  40260. function getTilingPatternIR(operatorList, dict, color) {
  40261. const matrix = dict.getArray("Matrix");
  40262. const bbox = _util.Util.normalizeRect(dict.getArray("BBox"));
  40263. const xstep = dict.get("XStep");
  40264. const ystep = dict.get("YStep");
  40265. const paintType = dict.get("PaintType");
  40266. const tilingType = dict.get("TilingType");
  40267. if (bbox[2] - bbox[0] === 0 || bbox[3] - bbox[1] === 0) {
  40268. throw new _util.FormatError(`Invalid getTilingPatternIR /BBox array: [${bbox}].`);
  40269. }
  40270. return ["TilingPattern", color, operatorList, matrix, bbox, xstep, ystep, paintType, tilingType];
  40271. }
  40272. /***/ }),
  40273. /* 202 */
  40274. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  40275. Object.defineProperty(exports, "__esModule", ({
  40276. value: true
  40277. }));
  40278. exports.getXfaFontDict = getXfaFontDict;
  40279. exports.getXfaFontName = getXfaFontName;
  40280. __w_pdfjs_require__(140);
  40281. var _calibri_factors = __w_pdfjs_require__(203);
  40282. var _primitives = __w_pdfjs_require__(151);
  40283. var _helvetica_factors = __w_pdfjs_require__(204);
  40284. var _liberationsans_widths = __w_pdfjs_require__(205);
  40285. var _myriadpro_factors = __w_pdfjs_require__(206);
  40286. var _segoeui_factors = __w_pdfjs_require__(207);
  40287. var _core_utils = __w_pdfjs_require__(150);
  40288. var _fonts_utils = __w_pdfjs_require__(189);
  40289. const getXFAFontMap = (0, _core_utils.getLookupTableFactory)(function (t) {
  40290. t["MyriadPro-Regular"] = t["PdfJS-Fallback-Regular"] = {
  40291. name: "LiberationSans-Regular",
  40292. factors: _myriadpro_factors.MyriadProRegularFactors,
  40293. baseWidths: _liberationsans_widths.LiberationSansRegularWidths,
  40294. baseMapping: _liberationsans_widths.LiberationSansRegularMapping,
  40295. metrics: _myriadpro_factors.MyriadProRegularMetrics
  40296. };
  40297. t["MyriadPro-Bold"] = t["PdfJS-Fallback-Bold"] = {
  40298. name: "LiberationSans-Bold",
  40299. factors: _myriadpro_factors.MyriadProBoldFactors,
  40300. baseWidths: _liberationsans_widths.LiberationSansBoldWidths,
  40301. baseMapping: _liberationsans_widths.LiberationSansBoldMapping,
  40302. metrics: _myriadpro_factors.MyriadProBoldMetrics
  40303. };
  40304. t["MyriadPro-It"] = t["MyriadPro-Italic"] = t["PdfJS-Fallback-Italic"] = {
  40305. name: "LiberationSans-Italic",
  40306. factors: _myriadpro_factors.MyriadProItalicFactors,
  40307. baseWidths: _liberationsans_widths.LiberationSansItalicWidths,
  40308. baseMapping: _liberationsans_widths.LiberationSansItalicMapping,
  40309. metrics: _myriadpro_factors.MyriadProItalicMetrics
  40310. };
  40311. t["MyriadPro-BoldIt"] = t["MyriadPro-BoldItalic"] = t["PdfJS-Fallback-BoldItalic"] = {
  40312. name: "LiberationSans-BoldItalic",
  40313. factors: _myriadpro_factors.MyriadProBoldItalicFactors,
  40314. baseWidths: _liberationsans_widths.LiberationSansBoldItalicWidths,
  40315. baseMapping: _liberationsans_widths.LiberationSansBoldItalicMapping,
  40316. metrics: _myriadpro_factors.MyriadProBoldItalicMetrics
  40317. };
  40318. t.ArialMT = t.Arial = t["Arial-Regular"] = {
  40319. name: "LiberationSans-Regular",
  40320. baseWidths: _liberationsans_widths.LiberationSansRegularWidths,
  40321. baseMapping: _liberationsans_widths.LiberationSansRegularMapping
  40322. };
  40323. t["Arial-BoldMT"] = t["Arial-Bold"] = {
  40324. name: "LiberationSans-Bold",
  40325. baseWidths: _liberationsans_widths.LiberationSansBoldWidths,
  40326. baseMapping: _liberationsans_widths.LiberationSansBoldMapping
  40327. };
  40328. t["Arial-ItalicMT"] = t["Arial-Italic"] = {
  40329. name: "LiberationSans-Italic",
  40330. baseWidths: _liberationsans_widths.LiberationSansItalicWidths,
  40331. baseMapping: _liberationsans_widths.LiberationSansItalicMapping
  40332. };
  40333. t["Arial-BoldItalicMT"] = t["Arial-BoldItalic"] = {
  40334. name: "LiberationSans-BoldItalic",
  40335. baseWidths: _liberationsans_widths.LiberationSansBoldItalicWidths,
  40336. baseMapping: _liberationsans_widths.LiberationSansBoldItalicMapping
  40337. };
  40338. t["Calibri-Regular"] = {
  40339. name: "LiberationSans-Regular",
  40340. factors: _calibri_factors.CalibriRegularFactors,
  40341. baseWidths: _liberationsans_widths.LiberationSansRegularWidths,
  40342. baseMapping: _liberationsans_widths.LiberationSansRegularMapping,
  40343. metrics: _calibri_factors.CalibriRegularMetrics
  40344. };
  40345. t["Calibri-Bold"] = {
  40346. name: "LiberationSans-Bold",
  40347. factors: _calibri_factors.CalibriBoldFactors,
  40348. baseWidths: _liberationsans_widths.LiberationSansBoldWidths,
  40349. baseMapping: _liberationsans_widths.LiberationSansBoldMapping,
  40350. metrics: _calibri_factors.CalibriBoldMetrics
  40351. };
  40352. t["Calibri-Italic"] = {
  40353. name: "LiberationSans-Italic",
  40354. factors: _calibri_factors.CalibriItalicFactors,
  40355. baseWidths: _liberationsans_widths.LiberationSansItalicWidths,
  40356. baseMapping: _liberationsans_widths.LiberationSansItalicMapping,
  40357. metrics: _calibri_factors.CalibriItalicMetrics
  40358. };
  40359. t["Calibri-BoldItalic"] = {
  40360. name: "LiberationSans-BoldItalic",
  40361. factors: _calibri_factors.CalibriBoldItalicFactors,
  40362. baseWidths: _liberationsans_widths.LiberationSansBoldItalicWidths,
  40363. baseMapping: _liberationsans_widths.LiberationSansBoldItalicMapping,
  40364. metrics: _calibri_factors.CalibriBoldItalicMetrics
  40365. };
  40366. t["Segoeui-Regular"] = {
  40367. name: "LiberationSans-Regular",
  40368. factors: _segoeui_factors.SegoeuiRegularFactors,
  40369. baseWidths: _liberationsans_widths.LiberationSansRegularWidths,
  40370. baseMapping: _liberationsans_widths.LiberationSansRegularMapping,
  40371. metrics: _segoeui_factors.SegoeuiRegularMetrics
  40372. };
  40373. t["Segoeui-Bold"] = {
  40374. name: "LiberationSans-Bold",
  40375. factors: _segoeui_factors.SegoeuiBoldFactors,
  40376. baseWidths: _liberationsans_widths.LiberationSansBoldWidths,
  40377. baseMapping: _liberationsans_widths.LiberationSansBoldMapping,
  40378. metrics: _segoeui_factors.SegoeuiBoldMetrics
  40379. };
  40380. t["Segoeui-Italic"] = {
  40381. name: "LiberationSans-Italic",
  40382. factors: _segoeui_factors.SegoeuiItalicFactors,
  40383. baseWidths: _liberationsans_widths.LiberationSansItalicWidths,
  40384. baseMapping: _liberationsans_widths.LiberationSansItalicMapping,
  40385. metrics: _segoeui_factors.SegoeuiItalicMetrics
  40386. };
  40387. t["Segoeui-BoldItalic"] = {
  40388. name: "LiberationSans-BoldItalic",
  40389. factors: _segoeui_factors.SegoeuiBoldItalicFactors,
  40390. baseWidths: _liberationsans_widths.LiberationSansBoldItalicWidths,
  40391. baseMapping: _liberationsans_widths.LiberationSansBoldItalicMapping,
  40392. metrics: _segoeui_factors.SegoeuiBoldItalicMetrics
  40393. };
  40394. t["Helvetica-Regular"] = t.Helvetica = {
  40395. name: "LiberationSans-Regular",
  40396. factors: _helvetica_factors.HelveticaRegularFactors,
  40397. baseWidths: _liberationsans_widths.LiberationSansRegularWidths,
  40398. baseMapping: _liberationsans_widths.LiberationSansRegularMapping,
  40399. metrics: _helvetica_factors.HelveticaRegularMetrics
  40400. };
  40401. t["Helvetica-Bold"] = {
  40402. name: "LiberationSans-Bold",
  40403. factors: _helvetica_factors.HelveticaBoldFactors,
  40404. baseWidths: _liberationsans_widths.LiberationSansBoldWidths,
  40405. baseMapping: _liberationsans_widths.LiberationSansBoldMapping,
  40406. metrics: _helvetica_factors.HelveticaBoldMetrics
  40407. };
  40408. t["Helvetica-Italic"] = {
  40409. name: "LiberationSans-Italic",
  40410. factors: _helvetica_factors.HelveticaItalicFactors,
  40411. baseWidths: _liberationsans_widths.LiberationSansItalicWidths,
  40412. baseMapping: _liberationsans_widths.LiberationSansItalicMapping,
  40413. metrics: _helvetica_factors.HelveticaItalicMetrics
  40414. };
  40415. t["Helvetica-BoldItalic"] = {
  40416. name: "LiberationSans-BoldItalic",
  40417. factors: _helvetica_factors.HelveticaBoldItalicFactors,
  40418. baseWidths: _liberationsans_widths.LiberationSansBoldItalicWidths,
  40419. baseMapping: _liberationsans_widths.LiberationSansBoldItalicMapping,
  40420. metrics: _helvetica_factors.HelveticaBoldItalicMetrics
  40421. };
  40422. });
  40423. function getXfaFontName(name) {
  40424. const fontName = (0, _fonts_utils.normalizeFontName)(name);
  40425. const fontMap = getXFAFontMap();
  40426. return fontMap[fontName];
  40427. }
  40428. function getXfaFontWidths(name) {
  40429. const info = getXfaFontName(name);
  40430. if (!info) {
  40431. return null;
  40432. }
  40433. const {
  40434. baseWidths,
  40435. baseMapping,
  40436. factors
  40437. } = info;
  40438. const rescaledBaseWidths = !factors ? baseWidths : baseWidths.map((w, i) => w * factors[i]);
  40439. let currentCode = -2;
  40440. let currentArray;
  40441. const newWidths = [];
  40442. for (const [unicode, glyphIndex] of baseMapping.map((charUnicode, index) => [charUnicode, index]).sort((_ref, _ref2) => {
  40443. let [unicode1] = _ref;
  40444. let [unicode2] = _ref2;
  40445. return unicode1 - unicode2;
  40446. })) {
  40447. if (unicode === -1) {
  40448. continue;
  40449. }
  40450. if (unicode === currentCode + 1) {
  40451. currentArray.push(rescaledBaseWidths[glyphIndex]);
  40452. currentCode += 1;
  40453. } else {
  40454. currentCode = unicode;
  40455. currentArray = [rescaledBaseWidths[glyphIndex]];
  40456. newWidths.push(unicode, currentArray);
  40457. }
  40458. }
  40459. return newWidths;
  40460. }
  40461. function getXfaFontDict(name) {
  40462. const widths = getXfaFontWidths(name);
  40463. const dict = new _primitives.Dict(null);
  40464. dict.set("BaseFont", _primitives.Name.get(name));
  40465. dict.set("Type", _primitives.Name.get("Font"));
  40466. dict.set("Subtype", _primitives.Name.get("CIDFontType2"));
  40467. dict.set("Encoding", _primitives.Name.get("Identity-H"));
  40468. dict.set("CIDToGIDMap", _primitives.Name.get("Identity"));
  40469. dict.set("W", widths);
  40470. dict.set("FirstChar", widths[0]);
  40471. dict.set("LastChar", widths.at(-2) + widths.at(-1).length - 1);
  40472. const descriptor = new _primitives.Dict(null);
  40473. dict.set("FontDescriptor", descriptor);
  40474. const systemInfo = new _primitives.Dict(null);
  40475. systemInfo.set("Ordering", "Identity");
  40476. systemInfo.set("Registry", "Adobe");
  40477. systemInfo.set("Supplement", 0);
  40478. dict.set("CIDSystemInfo", systemInfo);
  40479. return dict;
  40480. }
  40481. /***/ }),
  40482. /* 203 */
  40483. /***/ ((__unused_webpack_module, exports) => {
  40484. Object.defineProperty(exports, "__esModule", ({
  40485. value: true
  40486. }));
  40487. exports.CalibriRegularMetrics = exports.CalibriRegularFactors = exports.CalibriItalicMetrics = exports.CalibriItalicFactors = exports.CalibriBoldMetrics = exports.CalibriBoldItalicMetrics = exports.CalibriBoldItalicFactors = exports.CalibriBoldFactors = void 0;
  40488. 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];
  40489. exports.CalibriBoldFactors = CalibriBoldFactors;
  40490. const CalibriBoldMetrics = {
  40491. lineHeight: 1.2207,
  40492. lineGap: 0.2207
  40493. };
  40494. exports.CalibriBoldMetrics = CalibriBoldMetrics;
  40495. 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];
  40496. exports.CalibriBoldItalicFactors = CalibriBoldItalicFactors;
  40497. const CalibriBoldItalicMetrics = {
  40498. lineHeight: 1.2207,
  40499. lineGap: 0.2207
  40500. };
  40501. exports.CalibriBoldItalicMetrics = CalibriBoldItalicMetrics;
  40502. 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];
  40503. exports.CalibriItalicFactors = CalibriItalicFactors;
  40504. const CalibriItalicMetrics = {
  40505. lineHeight: 1.2207,
  40506. lineGap: 0.2207
  40507. };
  40508. exports.CalibriItalicMetrics = CalibriItalicMetrics;
  40509. 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];
  40510. exports.CalibriRegularFactors = CalibriRegularFactors;
  40511. const CalibriRegularMetrics = {
  40512. lineHeight: 1.2207,
  40513. lineGap: 0.2207
  40514. };
  40515. exports.CalibriRegularMetrics = CalibriRegularMetrics;
  40516. /***/ }),
  40517. /* 204 */
  40518. /***/ ((__unused_webpack_module, exports) => {
  40519. Object.defineProperty(exports, "__esModule", ({
  40520. value: true
  40521. }));
  40522. exports.HelveticaRegularMetrics = exports.HelveticaRegularFactors = exports.HelveticaItalicMetrics = exports.HelveticaItalicFactors = exports.HelveticaBoldMetrics = exports.HelveticaBoldItalicMetrics = exports.HelveticaBoldItalicFactors = exports.HelveticaBoldFactors = void 0;
  40523. 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];
  40524. exports.HelveticaBoldFactors = HelveticaBoldFactors;
  40525. const HelveticaBoldMetrics = {
  40526. lineHeight: 1.2,
  40527. lineGap: 0.2
  40528. };
  40529. exports.HelveticaBoldMetrics = HelveticaBoldMetrics;
  40530. 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];
  40531. exports.HelveticaBoldItalicFactors = HelveticaBoldItalicFactors;
  40532. const HelveticaBoldItalicMetrics = {
  40533. lineHeight: 1.35,
  40534. lineGap: 0.2
  40535. };
  40536. exports.HelveticaBoldItalicMetrics = HelveticaBoldItalicMetrics;
  40537. 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];
  40538. exports.HelveticaItalicFactors = HelveticaItalicFactors;
  40539. const HelveticaItalicMetrics = {
  40540. lineHeight: 1.35,
  40541. lineGap: 0.2
  40542. };
  40543. exports.HelveticaItalicMetrics = HelveticaItalicMetrics;
  40544. 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];
  40545. exports.HelveticaRegularFactors = HelveticaRegularFactors;
  40546. const HelveticaRegularMetrics = {
  40547. lineHeight: 1.2,
  40548. lineGap: 0.2
  40549. };
  40550. exports.HelveticaRegularMetrics = HelveticaRegularMetrics;
  40551. /***/ }),
  40552. /* 205 */
  40553. /***/ ((__unused_webpack_module, exports) => {
  40554. Object.defineProperty(exports, "__esModule", ({
  40555. value: true
  40556. }));
  40557. exports.LiberationSansRegularWidths = exports.LiberationSansRegularMapping = exports.LiberationSansItalicWidths = exports.LiberationSansItalicMapping = exports.LiberationSansBoldWidths = exports.LiberationSansBoldMapping = exports.LiberationSansBoldItalicWidths = exports.LiberationSansBoldItalicMapping = void 0;
  40558. 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];
  40559. exports.LiberationSansBoldWidths = LiberationSansBoldWidths;
  40560. 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];
  40561. exports.LiberationSansBoldMapping = LiberationSansBoldMapping;
  40562. 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];
  40563. exports.LiberationSansBoldItalicWidths = LiberationSansBoldItalicWidths;
  40564. 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];
  40565. exports.LiberationSansBoldItalicMapping = LiberationSansBoldItalicMapping;
  40566. 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];
  40567. exports.LiberationSansItalicWidths = LiberationSansItalicWidths;
  40568. 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];
  40569. exports.LiberationSansItalicMapping = LiberationSansItalicMapping;
  40570. 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];
  40571. exports.LiberationSansRegularWidths = LiberationSansRegularWidths;
  40572. 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];
  40573. exports.LiberationSansRegularMapping = LiberationSansRegularMapping;
  40574. /***/ }),
  40575. /* 206 */
  40576. /***/ ((__unused_webpack_module, exports) => {
  40577. Object.defineProperty(exports, "__esModule", ({
  40578. value: true
  40579. }));
  40580. exports.MyriadProRegularMetrics = exports.MyriadProRegularFactors = exports.MyriadProItalicMetrics = exports.MyriadProItalicFactors = exports.MyriadProBoldMetrics = exports.MyriadProBoldItalicMetrics = exports.MyriadProBoldItalicFactors = exports.MyriadProBoldFactors = void 0;
  40581. 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];
  40582. exports.MyriadProBoldFactors = MyriadProBoldFactors;
  40583. const MyriadProBoldMetrics = {
  40584. lineHeight: 1.2,
  40585. lineGap: 0.2
  40586. };
  40587. exports.MyriadProBoldMetrics = MyriadProBoldMetrics;
  40588. 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];
  40589. exports.MyriadProBoldItalicFactors = MyriadProBoldItalicFactors;
  40590. const MyriadProBoldItalicMetrics = {
  40591. lineHeight: 1.2,
  40592. lineGap: 0.2
  40593. };
  40594. exports.MyriadProBoldItalicMetrics = MyriadProBoldItalicMetrics;
  40595. 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];
  40596. exports.MyriadProItalicFactors = MyriadProItalicFactors;
  40597. const MyriadProItalicMetrics = {
  40598. lineHeight: 1.2,
  40599. lineGap: 0.2
  40600. };
  40601. exports.MyriadProItalicMetrics = MyriadProItalicMetrics;
  40602. 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];
  40603. exports.MyriadProRegularFactors = MyriadProRegularFactors;
  40604. const MyriadProRegularMetrics = {
  40605. lineHeight: 1.2,
  40606. lineGap: 0.2
  40607. };
  40608. exports.MyriadProRegularMetrics = MyriadProRegularMetrics;
  40609. /***/ }),
  40610. /* 207 */
  40611. /***/ ((__unused_webpack_module, exports) => {
  40612. Object.defineProperty(exports, "__esModule", ({
  40613. value: true
  40614. }));
  40615. exports.SegoeuiRegularMetrics = exports.SegoeuiRegularFactors = exports.SegoeuiItalicMetrics = exports.SegoeuiItalicFactors = exports.SegoeuiBoldMetrics = exports.SegoeuiBoldItalicMetrics = exports.SegoeuiBoldItalicFactors = exports.SegoeuiBoldFactors = void 0;
  40616. 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];
  40617. exports.SegoeuiBoldFactors = SegoeuiBoldFactors;
  40618. const SegoeuiBoldMetrics = {
  40619. lineHeight: 1.33008,
  40620. lineGap: 0
  40621. };
  40622. exports.SegoeuiBoldMetrics = SegoeuiBoldMetrics;
  40623. 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];
  40624. exports.SegoeuiBoldItalicFactors = SegoeuiBoldItalicFactors;
  40625. const SegoeuiBoldItalicMetrics = {
  40626. lineHeight: 1.33008,
  40627. lineGap: 0
  40628. };
  40629. exports.SegoeuiBoldItalicMetrics = SegoeuiBoldItalicMetrics;
  40630. 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];
  40631. exports.SegoeuiItalicFactors = SegoeuiItalicFactors;
  40632. const SegoeuiItalicMetrics = {
  40633. lineHeight: 1.33008,
  40634. lineGap: 0
  40635. };
  40636. exports.SegoeuiItalicMetrics = SegoeuiItalicMetrics;
  40637. 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];
  40638. exports.SegoeuiRegularFactors = SegoeuiRegularFactors;
  40639. const SegoeuiRegularMetrics = {
  40640. lineHeight: 1.33008,
  40641. lineGap: 0
  40642. };
  40643. exports.SegoeuiRegularMetrics = SegoeuiRegularMetrics;
  40644. /***/ }),
  40645. /* 208 */
  40646. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  40647. Object.defineProperty(exports, "__esModule", ({
  40648. value: true
  40649. }));
  40650. exports.PostScriptEvaluator = exports.PostScriptCompiler = exports.PDFFunctionFactory = void 0;
  40651. exports.isPDFFunction = isPDFFunction;
  40652. __w_pdfjs_require__(2);
  40653. __w_pdfjs_require__(140);
  40654. __w_pdfjs_require__(84);
  40655. __w_pdfjs_require__(93);
  40656. __w_pdfjs_require__(94);
  40657. __w_pdfjs_require__(97);
  40658. __w_pdfjs_require__(99);
  40659. __w_pdfjs_require__(101);
  40660. __w_pdfjs_require__(105);
  40661. __w_pdfjs_require__(108);
  40662. __w_pdfjs_require__(115);
  40663. __w_pdfjs_require__(160);
  40664. var _primitives = __w_pdfjs_require__(151);
  40665. var _util = __w_pdfjs_require__(145);
  40666. var _ps_parser = __w_pdfjs_require__(209);
  40667. var _base_stream = __w_pdfjs_require__(152);
  40668. var _image_utils = __w_pdfjs_require__(210);
  40669. class PDFFunctionFactory {
  40670. constructor(_ref) {
  40671. let {
  40672. xref,
  40673. isEvalSupported = true
  40674. } = _ref;
  40675. this.xref = xref;
  40676. this.isEvalSupported = isEvalSupported !== false;
  40677. }
  40678. create(fn) {
  40679. const cachedFunction = this.getCached(fn);
  40680. if (cachedFunction) {
  40681. return cachedFunction;
  40682. }
  40683. const parsedFunction = PDFFunction.parse({
  40684. xref: this.xref,
  40685. isEvalSupported: this.isEvalSupported,
  40686. fn: fn instanceof _primitives.Ref ? this.xref.fetch(fn) : fn
  40687. });
  40688. this._cache(fn, parsedFunction);
  40689. return parsedFunction;
  40690. }
  40691. createFromArray(fnObj) {
  40692. const cachedFunction = this.getCached(fnObj);
  40693. if (cachedFunction) {
  40694. return cachedFunction;
  40695. }
  40696. const parsedFunction = PDFFunction.parseArray({
  40697. xref: this.xref,
  40698. isEvalSupported: this.isEvalSupported,
  40699. fnObj: fnObj instanceof _primitives.Ref ? this.xref.fetch(fnObj) : fnObj
  40700. });
  40701. this._cache(fnObj, parsedFunction);
  40702. return parsedFunction;
  40703. }
  40704. getCached(cacheKey) {
  40705. let fnRef;
  40706. if (cacheKey instanceof _primitives.Ref) {
  40707. fnRef = cacheKey;
  40708. } else if (cacheKey instanceof _primitives.Dict) {
  40709. fnRef = cacheKey.objId;
  40710. } else if (cacheKey instanceof _base_stream.BaseStream) {
  40711. fnRef = cacheKey.dict?.objId;
  40712. }
  40713. if (fnRef) {
  40714. const localFunction = this._localFunctionCache.getByRef(fnRef);
  40715. if (localFunction) {
  40716. return localFunction;
  40717. }
  40718. }
  40719. return null;
  40720. }
  40721. _cache(cacheKey, parsedFunction) {
  40722. if (!parsedFunction) {
  40723. throw new Error('PDFFunctionFactory._cache - expected "parsedFunction" argument.');
  40724. }
  40725. let fnRef;
  40726. if (cacheKey instanceof _primitives.Ref) {
  40727. fnRef = cacheKey;
  40728. } else if (cacheKey instanceof _primitives.Dict) {
  40729. fnRef = cacheKey.objId;
  40730. } else if (cacheKey instanceof _base_stream.BaseStream) {
  40731. fnRef = cacheKey.dict?.objId;
  40732. }
  40733. if (fnRef) {
  40734. this._localFunctionCache.set(null, fnRef, parsedFunction);
  40735. }
  40736. }
  40737. get _localFunctionCache() {
  40738. return (0, _util.shadow)(this, "_localFunctionCache", new _image_utils.LocalFunctionCache());
  40739. }
  40740. }
  40741. exports.PDFFunctionFactory = PDFFunctionFactory;
  40742. function toNumberArray(arr) {
  40743. if (!Array.isArray(arr)) {
  40744. return null;
  40745. }
  40746. const length = arr.length;
  40747. for (let i = 0; i < length; i++) {
  40748. if (typeof arr[i] !== "number") {
  40749. const result = new Array(length);
  40750. for (let j = 0; j < length; j++) {
  40751. result[j] = +arr[j];
  40752. }
  40753. return result;
  40754. }
  40755. }
  40756. return arr;
  40757. }
  40758. class PDFFunction {
  40759. static getSampleArray(size, outputSize, bps, stream) {
  40760. let i, ii;
  40761. let length = 1;
  40762. for (i = 0, ii = size.length; i < ii; i++) {
  40763. length *= size[i];
  40764. }
  40765. length *= outputSize;
  40766. const array = new Array(length);
  40767. let codeSize = 0;
  40768. let codeBuf = 0;
  40769. const sampleMul = 1.0 / (2.0 ** bps - 1);
  40770. const strBytes = stream.getBytes((length * bps + 7) / 8);
  40771. let strIdx = 0;
  40772. for (i = 0; i < length; i++) {
  40773. while (codeSize < bps) {
  40774. codeBuf <<= 8;
  40775. codeBuf |= strBytes[strIdx++];
  40776. codeSize += 8;
  40777. }
  40778. codeSize -= bps;
  40779. array[i] = (codeBuf >> codeSize) * sampleMul;
  40780. codeBuf &= (1 << codeSize) - 1;
  40781. }
  40782. return array;
  40783. }
  40784. static parse(_ref2) {
  40785. let {
  40786. xref,
  40787. isEvalSupported,
  40788. fn
  40789. } = _ref2;
  40790. const dict = fn.dict || fn;
  40791. const typeNum = dict.get("FunctionType");
  40792. switch (typeNum) {
  40793. case 0:
  40794. return this.constructSampled({
  40795. xref,
  40796. isEvalSupported,
  40797. fn,
  40798. dict
  40799. });
  40800. case 1:
  40801. break;
  40802. case 2:
  40803. return this.constructInterpolated({
  40804. xref,
  40805. isEvalSupported,
  40806. dict
  40807. });
  40808. case 3:
  40809. return this.constructStiched({
  40810. xref,
  40811. isEvalSupported,
  40812. dict
  40813. });
  40814. case 4:
  40815. return this.constructPostScript({
  40816. xref,
  40817. isEvalSupported,
  40818. fn,
  40819. dict
  40820. });
  40821. }
  40822. throw new _util.FormatError("Unknown type of function");
  40823. }
  40824. static parseArray(_ref3) {
  40825. let {
  40826. xref,
  40827. isEvalSupported,
  40828. fnObj
  40829. } = _ref3;
  40830. if (!Array.isArray(fnObj)) {
  40831. return this.parse({
  40832. xref,
  40833. isEvalSupported,
  40834. fn: fnObj
  40835. });
  40836. }
  40837. const fnArray = [];
  40838. for (const fn of fnObj) {
  40839. fnArray.push(this.parse({
  40840. xref,
  40841. isEvalSupported,
  40842. fn: xref.fetchIfRef(fn)
  40843. }));
  40844. }
  40845. return function (src, srcOffset, dest, destOffset) {
  40846. for (let i = 0, ii = fnArray.length; i < ii; i++) {
  40847. fnArray[i](src, srcOffset, dest, destOffset + i);
  40848. }
  40849. };
  40850. }
  40851. static constructSampled(_ref4) {
  40852. let {
  40853. xref,
  40854. isEvalSupported,
  40855. fn,
  40856. dict
  40857. } = _ref4;
  40858. function toMultiArray(arr) {
  40859. const inputLength = arr.length;
  40860. const out = [];
  40861. let index = 0;
  40862. for (let i = 0; i < inputLength; i += 2) {
  40863. out[index++] = [arr[i], arr[i + 1]];
  40864. }
  40865. return out;
  40866. }
  40867. function interpolate(x, xmin, xmax, ymin, ymax) {
  40868. return ymin + (x - xmin) * ((ymax - ymin) / (xmax - xmin));
  40869. }
  40870. let domain = toNumberArray(dict.getArray("Domain"));
  40871. let range = toNumberArray(dict.getArray("Range"));
  40872. if (!domain || !range) {
  40873. throw new _util.FormatError("No domain or range");
  40874. }
  40875. const inputSize = domain.length / 2;
  40876. const outputSize = range.length / 2;
  40877. domain = toMultiArray(domain);
  40878. range = toMultiArray(range);
  40879. const size = toNumberArray(dict.getArray("Size"));
  40880. const bps = dict.get("BitsPerSample");
  40881. const order = dict.get("Order") || 1;
  40882. if (order !== 1) {
  40883. (0, _util.info)("No support for cubic spline interpolation: " + order);
  40884. }
  40885. let encode = toNumberArray(dict.getArray("Encode"));
  40886. if (!encode) {
  40887. encode = [];
  40888. for (let i = 0; i < inputSize; ++i) {
  40889. encode.push([0, size[i] - 1]);
  40890. }
  40891. } else {
  40892. encode = toMultiArray(encode);
  40893. }
  40894. let decode = toNumberArray(dict.getArray("Decode"));
  40895. decode = !decode ? range : toMultiArray(decode);
  40896. const samples = this.getSampleArray(size, outputSize, bps, fn);
  40897. return function constructSampledFn(src, srcOffset, dest, destOffset) {
  40898. const cubeVertices = 1 << inputSize;
  40899. const cubeN = new Float64Array(cubeVertices);
  40900. const cubeVertex = new Uint32Array(cubeVertices);
  40901. let i, j;
  40902. for (j = 0; j < cubeVertices; j++) {
  40903. cubeN[j] = 1;
  40904. }
  40905. let k = outputSize,
  40906. pos = 1;
  40907. for (i = 0; i < inputSize; ++i) {
  40908. const domain_2i = domain[i][0];
  40909. const domain_2i_1 = domain[i][1];
  40910. const xi = Math.min(Math.max(src[srcOffset + i], domain_2i), domain_2i_1);
  40911. let e = interpolate(xi, domain_2i, domain_2i_1, encode[i][0], encode[i][1]);
  40912. const size_i = size[i];
  40913. e = Math.min(Math.max(e, 0), size_i - 1);
  40914. const e0 = e < size_i - 1 ? Math.floor(e) : e - 1;
  40915. const n0 = e0 + 1 - e;
  40916. const n1 = e - e0;
  40917. const offset0 = e0 * k;
  40918. const offset1 = offset0 + k;
  40919. for (j = 0; j < cubeVertices; j++) {
  40920. if (j & pos) {
  40921. cubeN[j] *= n1;
  40922. cubeVertex[j] += offset1;
  40923. } else {
  40924. cubeN[j] *= n0;
  40925. cubeVertex[j] += offset0;
  40926. }
  40927. }
  40928. k *= size_i;
  40929. pos <<= 1;
  40930. }
  40931. for (j = 0; j < outputSize; ++j) {
  40932. let rj = 0;
  40933. for (i = 0; i < cubeVertices; i++) {
  40934. rj += samples[cubeVertex[i] + j] * cubeN[i];
  40935. }
  40936. rj = interpolate(rj, 0, 1, decode[j][0], decode[j][1]);
  40937. dest[destOffset + j] = Math.min(Math.max(rj, range[j][0]), range[j][1]);
  40938. }
  40939. };
  40940. }
  40941. static constructInterpolated(_ref5) {
  40942. let {
  40943. xref,
  40944. isEvalSupported,
  40945. dict
  40946. } = _ref5;
  40947. const c0 = toNumberArray(dict.getArray("C0")) || [0];
  40948. const c1 = toNumberArray(dict.getArray("C1")) || [1];
  40949. const n = dict.get("N");
  40950. const diff = [];
  40951. for (let i = 0, ii = c0.length; i < ii; ++i) {
  40952. diff.push(c1[i] - c0[i]);
  40953. }
  40954. const length = diff.length;
  40955. return function constructInterpolatedFn(src, srcOffset, dest, destOffset) {
  40956. const x = n === 1 ? src[srcOffset] : src[srcOffset] ** n;
  40957. for (let j = 0; j < length; ++j) {
  40958. dest[destOffset + j] = c0[j] + x * diff[j];
  40959. }
  40960. };
  40961. }
  40962. static constructStiched(_ref6) {
  40963. let {
  40964. xref,
  40965. isEvalSupported,
  40966. dict
  40967. } = _ref6;
  40968. const domain = toNumberArray(dict.getArray("Domain"));
  40969. if (!domain) {
  40970. throw new _util.FormatError("No domain");
  40971. }
  40972. const inputSize = domain.length / 2;
  40973. if (inputSize !== 1) {
  40974. throw new _util.FormatError("Bad domain for stiched function");
  40975. }
  40976. const fns = [];
  40977. for (const fn of dict.get("Functions")) {
  40978. fns.push(this.parse({
  40979. xref,
  40980. isEvalSupported,
  40981. fn: xref.fetchIfRef(fn)
  40982. }));
  40983. }
  40984. const bounds = toNumberArray(dict.getArray("Bounds"));
  40985. const encode = toNumberArray(dict.getArray("Encode"));
  40986. const tmpBuf = new Float32Array(1);
  40987. return function constructStichedFn(src, srcOffset, dest, destOffset) {
  40988. const clip = function constructStichedFromIRClip(v, min, max) {
  40989. if (v > max) {
  40990. v = max;
  40991. } else if (v < min) {
  40992. v = min;
  40993. }
  40994. return v;
  40995. };
  40996. const v = clip(src[srcOffset], domain[0], domain[1]);
  40997. const length = bounds.length;
  40998. let i;
  40999. for (i = 0; i < length; ++i) {
  41000. if (v < bounds[i]) {
  41001. break;
  41002. }
  41003. }
  41004. let dmin = domain[0];
  41005. if (i > 0) {
  41006. dmin = bounds[i - 1];
  41007. }
  41008. let dmax = domain[1];
  41009. if (i < bounds.length) {
  41010. dmax = bounds[i];
  41011. }
  41012. const rmin = encode[2 * i];
  41013. const rmax = encode[2 * i + 1];
  41014. tmpBuf[0] = dmin === dmax ? rmin : rmin + (v - dmin) * (rmax - rmin) / (dmax - dmin);
  41015. fns[i](tmpBuf, 0, dest, destOffset);
  41016. };
  41017. }
  41018. static constructPostScript(_ref7) {
  41019. let {
  41020. xref,
  41021. isEvalSupported,
  41022. fn,
  41023. dict
  41024. } = _ref7;
  41025. const domain = toNumberArray(dict.getArray("Domain"));
  41026. const range = toNumberArray(dict.getArray("Range"));
  41027. if (!domain) {
  41028. throw new _util.FormatError("No domain.");
  41029. }
  41030. if (!range) {
  41031. throw new _util.FormatError("No range.");
  41032. }
  41033. const lexer = new _ps_parser.PostScriptLexer(fn);
  41034. const parser = new _ps_parser.PostScriptParser(lexer);
  41035. const code = parser.parse();
  41036. if (isEvalSupported && _util.FeatureTest.isEvalSupported) {
  41037. const compiled = new PostScriptCompiler().compile(code, domain, range);
  41038. if (compiled) {
  41039. return new Function("src", "srcOffset", "dest", "destOffset", compiled);
  41040. }
  41041. }
  41042. (0, _util.info)("Unable to compile PS function");
  41043. const numOutputs = range.length >> 1;
  41044. const numInputs = domain.length >> 1;
  41045. const evaluator = new PostScriptEvaluator(code);
  41046. const cache = Object.create(null);
  41047. const MAX_CACHE_SIZE = 2048 * 4;
  41048. let cache_available = MAX_CACHE_SIZE;
  41049. const tmpBuf = new Float32Array(numInputs);
  41050. return function constructPostScriptFn(src, srcOffset, dest, destOffset) {
  41051. let i, value;
  41052. let key = "";
  41053. const input = tmpBuf;
  41054. for (i = 0; i < numInputs; i++) {
  41055. value = src[srcOffset + i];
  41056. input[i] = value;
  41057. key += value + "_";
  41058. }
  41059. const cachedValue = cache[key];
  41060. if (cachedValue !== undefined) {
  41061. dest.set(cachedValue, destOffset);
  41062. return;
  41063. }
  41064. const output = new Float32Array(numOutputs);
  41065. const stack = evaluator.execute(input);
  41066. const stackIndex = stack.length - numOutputs;
  41067. for (i = 0; i < numOutputs; i++) {
  41068. value = stack[stackIndex + i];
  41069. let bound = range[i * 2];
  41070. if (value < bound) {
  41071. value = bound;
  41072. } else {
  41073. bound = range[i * 2 + 1];
  41074. if (value > bound) {
  41075. value = bound;
  41076. }
  41077. }
  41078. output[i] = value;
  41079. }
  41080. if (cache_available > 0) {
  41081. cache_available--;
  41082. cache[key] = output;
  41083. }
  41084. dest.set(output, destOffset);
  41085. };
  41086. }
  41087. }
  41088. function isPDFFunction(v) {
  41089. let fnDict;
  41090. if (v instanceof _primitives.Dict) {
  41091. fnDict = v;
  41092. } else if (v instanceof _base_stream.BaseStream) {
  41093. fnDict = v.dict;
  41094. } else {
  41095. return false;
  41096. }
  41097. return fnDict.has("FunctionType");
  41098. }
  41099. class PostScriptStack {
  41100. static MAX_STACK_SIZE = 100;
  41101. constructor(initialStack) {
  41102. this.stack = initialStack ? Array.from(initialStack) : [];
  41103. }
  41104. push(value) {
  41105. if (this.stack.length >= PostScriptStack.MAX_STACK_SIZE) {
  41106. throw new Error("PostScript function stack overflow.");
  41107. }
  41108. this.stack.push(value);
  41109. }
  41110. pop() {
  41111. if (this.stack.length <= 0) {
  41112. throw new Error("PostScript function stack underflow.");
  41113. }
  41114. return this.stack.pop();
  41115. }
  41116. copy(n) {
  41117. if (this.stack.length + n >= PostScriptStack.MAX_STACK_SIZE) {
  41118. throw new Error("PostScript function stack overflow.");
  41119. }
  41120. const stack = this.stack;
  41121. for (let i = stack.length - n, j = n - 1; j >= 0; j--, i++) {
  41122. stack.push(stack[i]);
  41123. }
  41124. }
  41125. index(n) {
  41126. this.push(this.stack[this.stack.length - n - 1]);
  41127. }
  41128. roll(n, p) {
  41129. const stack = this.stack;
  41130. const l = stack.length - n;
  41131. const r = stack.length - 1;
  41132. const c = l + (p - Math.floor(p / n) * n);
  41133. for (let i = l, j = r; i < j; i++, j--) {
  41134. const t = stack[i];
  41135. stack[i] = stack[j];
  41136. stack[j] = t;
  41137. }
  41138. for (let i = l, j = c - 1; i < j; i++, j--) {
  41139. const t = stack[i];
  41140. stack[i] = stack[j];
  41141. stack[j] = t;
  41142. }
  41143. for (let i = c, j = r; i < j; i++, j--) {
  41144. const t = stack[i];
  41145. stack[i] = stack[j];
  41146. stack[j] = t;
  41147. }
  41148. }
  41149. }
  41150. class PostScriptEvaluator {
  41151. constructor(operators) {
  41152. this.operators = operators;
  41153. }
  41154. execute(initialStack) {
  41155. const stack = new PostScriptStack(initialStack);
  41156. let counter = 0;
  41157. const operators = this.operators;
  41158. const length = operators.length;
  41159. let operator, a, b;
  41160. while (counter < length) {
  41161. operator = operators[counter++];
  41162. if (typeof operator === "number") {
  41163. stack.push(operator);
  41164. continue;
  41165. }
  41166. switch (operator) {
  41167. case "jz":
  41168. b = stack.pop();
  41169. a = stack.pop();
  41170. if (!a) {
  41171. counter = b;
  41172. }
  41173. break;
  41174. case "j":
  41175. a = stack.pop();
  41176. counter = a;
  41177. break;
  41178. case "abs":
  41179. a = stack.pop();
  41180. stack.push(Math.abs(a));
  41181. break;
  41182. case "add":
  41183. b = stack.pop();
  41184. a = stack.pop();
  41185. stack.push(a + b);
  41186. break;
  41187. case "and":
  41188. b = stack.pop();
  41189. a = stack.pop();
  41190. if (typeof a === "boolean" && typeof b === "boolean") {
  41191. stack.push(a && b);
  41192. } else {
  41193. stack.push(a & b);
  41194. }
  41195. break;
  41196. case "atan":
  41197. b = stack.pop();
  41198. a = stack.pop();
  41199. a = Math.atan2(a, b) / Math.PI * 180;
  41200. if (a < 0) {
  41201. a += 360;
  41202. }
  41203. stack.push(a);
  41204. break;
  41205. case "bitshift":
  41206. b = stack.pop();
  41207. a = stack.pop();
  41208. if (a > 0) {
  41209. stack.push(a << b);
  41210. } else {
  41211. stack.push(a >> b);
  41212. }
  41213. break;
  41214. case "ceiling":
  41215. a = stack.pop();
  41216. stack.push(Math.ceil(a));
  41217. break;
  41218. case "copy":
  41219. a = stack.pop();
  41220. stack.copy(a);
  41221. break;
  41222. case "cos":
  41223. a = stack.pop();
  41224. stack.push(Math.cos(a % 360 / 180 * Math.PI));
  41225. break;
  41226. case "cvi":
  41227. a = stack.pop() | 0;
  41228. stack.push(a);
  41229. break;
  41230. case "cvr":
  41231. break;
  41232. case "div":
  41233. b = stack.pop();
  41234. a = stack.pop();
  41235. stack.push(a / b);
  41236. break;
  41237. case "dup":
  41238. stack.copy(1);
  41239. break;
  41240. case "eq":
  41241. b = stack.pop();
  41242. a = stack.pop();
  41243. stack.push(a === b);
  41244. break;
  41245. case "exch":
  41246. stack.roll(2, 1);
  41247. break;
  41248. case "exp":
  41249. b = stack.pop();
  41250. a = stack.pop();
  41251. stack.push(a ** b);
  41252. break;
  41253. case "false":
  41254. stack.push(false);
  41255. break;
  41256. case "floor":
  41257. a = stack.pop();
  41258. stack.push(Math.floor(a));
  41259. break;
  41260. case "ge":
  41261. b = stack.pop();
  41262. a = stack.pop();
  41263. stack.push(a >= b);
  41264. break;
  41265. case "gt":
  41266. b = stack.pop();
  41267. a = stack.pop();
  41268. stack.push(a > b);
  41269. break;
  41270. case "idiv":
  41271. b = stack.pop();
  41272. a = stack.pop();
  41273. stack.push(a / b | 0);
  41274. break;
  41275. case "index":
  41276. a = stack.pop();
  41277. stack.index(a);
  41278. break;
  41279. case "le":
  41280. b = stack.pop();
  41281. a = stack.pop();
  41282. stack.push(a <= b);
  41283. break;
  41284. case "ln":
  41285. a = stack.pop();
  41286. stack.push(Math.log(a));
  41287. break;
  41288. case "log":
  41289. a = stack.pop();
  41290. stack.push(Math.log10(a));
  41291. break;
  41292. case "lt":
  41293. b = stack.pop();
  41294. a = stack.pop();
  41295. stack.push(a < b);
  41296. break;
  41297. case "mod":
  41298. b = stack.pop();
  41299. a = stack.pop();
  41300. stack.push(a % b);
  41301. break;
  41302. case "mul":
  41303. b = stack.pop();
  41304. a = stack.pop();
  41305. stack.push(a * b);
  41306. break;
  41307. case "ne":
  41308. b = stack.pop();
  41309. a = stack.pop();
  41310. stack.push(a !== b);
  41311. break;
  41312. case "neg":
  41313. a = stack.pop();
  41314. stack.push(-a);
  41315. break;
  41316. case "not":
  41317. a = stack.pop();
  41318. if (typeof a === "boolean") {
  41319. stack.push(!a);
  41320. } else {
  41321. stack.push(~a);
  41322. }
  41323. break;
  41324. case "or":
  41325. b = stack.pop();
  41326. a = stack.pop();
  41327. if (typeof a === "boolean" && typeof b === "boolean") {
  41328. stack.push(a || b);
  41329. } else {
  41330. stack.push(a | b);
  41331. }
  41332. break;
  41333. case "pop":
  41334. stack.pop();
  41335. break;
  41336. case "roll":
  41337. b = stack.pop();
  41338. a = stack.pop();
  41339. stack.roll(a, b);
  41340. break;
  41341. case "round":
  41342. a = stack.pop();
  41343. stack.push(Math.round(a));
  41344. break;
  41345. case "sin":
  41346. a = stack.pop();
  41347. stack.push(Math.sin(a % 360 / 180 * Math.PI));
  41348. break;
  41349. case "sqrt":
  41350. a = stack.pop();
  41351. stack.push(Math.sqrt(a));
  41352. break;
  41353. case "sub":
  41354. b = stack.pop();
  41355. a = stack.pop();
  41356. stack.push(a - b);
  41357. break;
  41358. case "true":
  41359. stack.push(true);
  41360. break;
  41361. case "truncate":
  41362. a = stack.pop();
  41363. a = a < 0 ? Math.ceil(a) : Math.floor(a);
  41364. stack.push(a);
  41365. break;
  41366. case "xor":
  41367. b = stack.pop();
  41368. a = stack.pop();
  41369. if (typeof a === "boolean" && typeof b === "boolean") {
  41370. stack.push(a !== b);
  41371. } else {
  41372. stack.push(a ^ b);
  41373. }
  41374. break;
  41375. default:
  41376. throw new _util.FormatError(`Unknown operator ${operator}`);
  41377. }
  41378. }
  41379. return stack.stack;
  41380. }
  41381. }
  41382. exports.PostScriptEvaluator = PostScriptEvaluator;
  41383. class AstNode {
  41384. constructor(type) {
  41385. this.type = type;
  41386. }
  41387. visit(visitor) {
  41388. (0, _util.unreachable)("abstract method");
  41389. }
  41390. }
  41391. class AstArgument extends AstNode {
  41392. constructor(index, min, max) {
  41393. super("args");
  41394. this.index = index;
  41395. this.min = min;
  41396. this.max = max;
  41397. }
  41398. visit(visitor) {
  41399. visitor.visitArgument(this);
  41400. }
  41401. }
  41402. class AstLiteral extends AstNode {
  41403. constructor(number) {
  41404. super("literal");
  41405. this.number = number;
  41406. this.min = number;
  41407. this.max = number;
  41408. }
  41409. visit(visitor) {
  41410. visitor.visitLiteral(this);
  41411. }
  41412. }
  41413. class AstBinaryOperation extends AstNode {
  41414. constructor(op, arg1, arg2, min, max) {
  41415. super("binary");
  41416. this.op = op;
  41417. this.arg1 = arg1;
  41418. this.arg2 = arg2;
  41419. this.min = min;
  41420. this.max = max;
  41421. }
  41422. visit(visitor) {
  41423. visitor.visitBinaryOperation(this);
  41424. }
  41425. }
  41426. class AstMin extends AstNode {
  41427. constructor(arg, max) {
  41428. super("max");
  41429. this.arg = arg;
  41430. this.min = arg.min;
  41431. this.max = max;
  41432. }
  41433. visit(visitor) {
  41434. visitor.visitMin(this);
  41435. }
  41436. }
  41437. class AstVariable extends AstNode {
  41438. constructor(index, min, max) {
  41439. super("var");
  41440. this.index = index;
  41441. this.min = min;
  41442. this.max = max;
  41443. }
  41444. visit(visitor) {
  41445. visitor.visitVariable(this);
  41446. }
  41447. }
  41448. class AstVariableDefinition extends AstNode {
  41449. constructor(variable, arg) {
  41450. super("definition");
  41451. this.variable = variable;
  41452. this.arg = arg;
  41453. }
  41454. visit(visitor) {
  41455. visitor.visitVariableDefinition(this);
  41456. }
  41457. }
  41458. class ExpressionBuilderVisitor {
  41459. constructor() {
  41460. this.parts = [];
  41461. }
  41462. visitArgument(arg) {
  41463. this.parts.push("Math.max(", arg.min, ", Math.min(", arg.max, ", src[srcOffset + ", arg.index, "]))");
  41464. }
  41465. visitVariable(variable) {
  41466. this.parts.push("v", variable.index);
  41467. }
  41468. visitLiteral(literal) {
  41469. this.parts.push(literal.number);
  41470. }
  41471. visitBinaryOperation(operation) {
  41472. this.parts.push("(");
  41473. operation.arg1.visit(this);
  41474. this.parts.push(" ", operation.op, " ");
  41475. operation.arg2.visit(this);
  41476. this.parts.push(")");
  41477. }
  41478. visitVariableDefinition(definition) {
  41479. this.parts.push("var ");
  41480. definition.variable.visit(this);
  41481. this.parts.push(" = ");
  41482. definition.arg.visit(this);
  41483. this.parts.push(";");
  41484. }
  41485. visitMin(max) {
  41486. this.parts.push("Math.min(");
  41487. max.arg.visit(this);
  41488. this.parts.push(", ", max.max, ")");
  41489. }
  41490. toString() {
  41491. return this.parts.join("");
  41492. }
  41493. }
  41494. function buildAddOperation(num1, num2) {
  41495. if (num2.type === "literal" && num2.number === 0) {
  41496. return num1;
  41497. }
  41498. if (num1.type === "literal" && num1.number === 0) {
  41499. return num2;
  41500. }
  41501. if (num2.type === "literal" && num1.type === "literal") {
  41502. return new AstLiteral(num1.number + num2.number);
  41503. }
  41504. return new AstBinaryOperation("+", num1, num2, num1.min + num2.min, num1.max + num2.max);
  41505. }
  41506. function buildMulOperation(num1, num2) {
  41507. if (num2.type === "literal") {
  41508. if (num2.number === 0) {
  41509. return new AstLiteral(0);
  41510. } else if (num2.number === 1) {
  41511. return num1;
  41512. } else if (num1.type === "literal") {
  41513. return new AstLiteral(num1.number * num2.number);
  41514. }
  41515. }
  41516. if (num1.type === "literal") {
  41517. if (num1.number === 0) {
  41518. return new AstLiteral(0);
  41519. } else if (num1.number === 1) {
  41520. return num2;
  41521. }
  41522. }
  41523. const min = Math.min(num1.min * num2.min, num1.min * num2.max, num1.max * num2.min, num1.max * num2.max);
  41524. const max = Math.max(num1.min * num2.min, num1.min * num2.max, num1.max * num2.min, num1.max * num2.max);
  41525. return new AstBinaryOperation("*", num1, num2, min, max);
  41526. }
  41527. function buildSubOperation(num1, num2) {
  41528. if (num2.type === "literal") {
  41529. if (num2.number === 0) {
  41530. return num1;
  41531. } else if (num1.type === "literal") {
  41532. return new AstLiteral(num1.number - num2.number);
  41533. }
  41534. }
  41535. if (num2.type === "binary" && num2.op === "-" && num1.type === "literal" && num1.number === 1 && num2.arg1.type === "literal" && num2.arg1.number === 1) {
  41536. return num2.arg2;
  41537. }
  41538. return new AstBinaryOperation("-", num1, num2, num1.min - num2.max, num1.max - num2.min);
  41539. }
  41540. function buildMinOperation(num1, max) {
  41541. if (num1.min >= max) {
  41542. return new AstLiteral(max);
  41543. } else if (num1.max <= max) {
  41544. return num1;
  41545. }
  41546. return new AstMin(num1, max);
  41547. }
  41548. class PostScriptCompiler {
  41549. compile(code, domain, range) {
  41550. const stack = [];
  41551. const instructions = [];
  41552. const inputSize = domain.length >> 1,
  41553. outputSize = range.length >> 1;
  41554. let lastRegister = 0;
  41555. let n, j;
  41556. let num1, num2, ast1, ast2, tmpVar, item;
  41557. for (let i = 0; i < inputSize; i++) {
  41558. stack.push(new AstArgument(i, domain[i * 2], domain[i * 2 + 1]));
  41559. }
  41560. for (let i = 0, ii = code.length; i < ii; i++) {
  41561. item = code[i];
  41562. if (typeof item === "number") {
  41563. stack.push(new AstLiteral(item));
  41564. continue;
  41565. }
  41566. switch (item) {
  41567. case "add":
  41568. if (stack.length < 2) {
  41569. return null;
  41570. }
  41571. num2 = stack.pop();
  41572. num1 = stack.pop();
  41573. stack.push(buildAddOperation(num1, num2));
  41574. break;
  41575. case "cvr":
  41576. if (stack.length < 1) {
  41577. return null;
  41578. }
  41579. break;
  41580. case "mul":
  41581. if (stack.length < 2) {
  41582. return null;
  41583. }
  41584. num2 = stack.pop();
  41585. num1 = stack.pop();
  41586. stack.push(buildMulOperation(num1, num2));
  41587. break;
  41588. case "sub":
  41589. if (stack.length < 2) {
  41590. return null;
  41591. }
  41592. num2 = stack.pop();
  41593. num1 = stack.pop();
  41594. stack.push(buildSubOperation(num1, num2));
  41595. break;
  41596. case "exch":
  41597. if (stack.length < 2) {
  41598. return null;
  41599. }
  41600. ast1 = stack.pop();
  41601. ast2 = stack.pop();
  41602. stack.push(ast1, ast2);
  41603. break;
  41604. case "pop":
  41605. if (stack.length < 1) {
  41606. return null;
  41607. }
  41608. stack.pop();
  41609. break;
  41610. case "index":
  41611. if (stack.length < 1) {
  41612. return null;
  41613. }
  41614. num1 = stack.pop();
  41615. if (num1.type !== "literal") {
  41616. return null;
  41617. }
  41618. n = num1.number;
  41619. if (n < 0 || !Number.isInteger(n) || stack.length < n) {
  41620. return null;
  41621. }
  41622. ast1 = stack[stack.length - n - 1];
  41623. if (ast1.type === "literal" || ast1.type === "var") {
  41624. stack.push(ast1);
  41625. break;
  41626. }
  41627. tmpVar = new AstVariable(lastRegister++, ast1.min, ast1.max);
  41628. stack[stack.length - n - 1] = tmpVar;
  41629. stack.push(tmpVar);
  41630. instructions.push(new AstVariableDefinition(tmpVar, ast1));
  41631. break;
  41632. case "dup":
  41633. if (stack.length < 1) {
  41634. return null;
  41635. }
  41636. 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]) {
  41637. num1 = stack.pop();
  41638. stack.push(buildMinOperation(num1, code[i + 1]));
  41639. i += 6;
  41640. break;
  41641. }
  41642. ast1 = stack.at(-1);
  41643. if (ast1.type === "literal" || ast1.type === "var") {
  41644. stack.push(ast1);
  41645. break;
  41646. }
  41647. tmpVar = new AstVariable(lastRegister++, ast1.min, ast1.max);
  41648. stack[stack.length - 1] = tmpVar;
  41649. stack.push(tmpVar);
  41650. instructions.push(new AstVariableDefinition(tmpVar, ast1));
  41651. break;
  41652. case "roll":
  41653. if (stack.length < 2) {
  41654. return null;
  41655. }
  41656. num2 = stack.pop();
  41657. num1 = stack.pop();
  41658. if (num2.type !== "literal" || num1.type !== "literal") {
  41659. return null;
  41660. }
  41661. j = num2.number;
  41662. n = num1.number;
  41663. if (n <= 0 || !Number.isInteger(n) || !Number.isInteger(j) || stack.length < n) {
  41664. return null;
  41665. }
  41666. j = (j % n + n) % n;
  41667. if (j === 0) {
  41668. break;
  41669. }
  41670. stack.push(...stack.splice(stack.length - n, n - j));
  41671. break;
  41672. default:
  41673. return null;
  41674. }
  41675. }
  41676. if (stack.length !== outputSize) {
  41677. return null;
  41678. }
  41679. const result = [];
  41680. for (const instruction of instructions) {
  41681. const statementBuilder = new ExpressionBuilderVisitor();
  41682. instruction.visit(statementBuilder);
  41683. result.push(statementBuilder.toString());
  41684. }
  41685. for (let i = 0, ii = stack.length; i < ii; i++) {
  41686. const expr = stack[i],
  41687. statementBuilder = new ExpressionBuilderVisitor();
  41688. expr.visit(statementBuilder);
  41689. const min = range[i * 2],
  41690. max = range[i * 2 + 1];
  41691. const out = [statementBuilder.toString()];
  41692. if (min > expr.min) {
  41693. out.unshift("Math.max(", min, ", ");
  41694. out.push(")");
  41695. }
  41696. if (max < expr.max) {
  41697. out.unshift("Math.min(", max, ", ");
  41698. out.push(")");
  41699. }
  41700. out.unshift("dest[destOffset + ", i, "] = ");
  41701. out.push(";");
  41702. result.push(out.join(""));
  41703. }
  41704. return result.join("\n");
  41705. }
  41706. }
  41707. exports.PostScriptCompiler = PostScriptCompiler;
  41708. /***/ }),
  41709. /* 209 */
  41710. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  41711. Object.defineProperty(exports, "__esModule", ({
  41712. value: true
  41713. }));
  41714. exports.PostScriptParser = exports.PostScriptLexer = void 0;
  41715. __w_pdfjs_require__(140);
  41716. var _util = __w_pdfjs_require__(145);
  41717. var _primitives = __w_pdfjs_require__(151);
  41718. var _core_utils = __w_pdfjs_require__(150);
  41719. class PostScriptParser {
  41720. constructor(lexer) {
  41721. this.lexer = lexer;
  41722. this.operators = [];
  41723. this.token = null;
  41724. this.prev = null;
  41725. }
  41726. nextToken() {
  41727. this.prev = this.token;
  41728. this.token = this.lexer.getToken();
  41729. }
  41730. accept(type) {
  41731. if (this.token.type === type) {
  41732. this.nextToken();
  41733. return true;
  41734. }
  41735. return false;
  41736. }
  41737. expect(type) {
  41738. if (this.accept(type)) {
  41739. return true;
  41740. }
  41741. throw new _util.FormatError(`Unexpected symbol: found ${this.token.type} expected ${type}.`);
  41742. }
  41743. parse() {
  41744. this.nextToken();
  41745. this.expect(PostScriptTokenTypes.LBRACE);
  41746. this.parseBlock();
  41747. this.expect(PostScriptTokenTypes.RBRACE);
  41748. return this.operators;
  41749. }
  41750. parseBlock() {
  41751. while (true) {
  41752. if (this.accept(PostScriptTokenTypes.NUMBER)) {
  41753. this.operators.push(this.prev.value);
  41754. } else if (this.accept(PostScriptTokenTypes.OPERATOR)) {
  41755. this.operators.push(this.prev.value);
  41756. } else if (this.accept(PostScriptTokenTypes.LBRACE)) {
  41757. this.parseCondition();
  41758. } else {
  41759. return;
  41760. }
  41761. }
  41762. }
  41763. parseCondition() {
  41764. const conditionLocation = this.operators.length;
  41765. this.operators.push(null, null);
  41766. this.parseBlock();
  41767. this.expect(PostScriptTokenTypes.RBRACE);
  41768. if (this.accept(PostScriptTokenTypes.IF)) {
  41769. this.operators[conditionLocation] = this.operators.length;
  41770. this.operators[conditionLocation + 1] = "jz";
  41771. } else if (this.accept(PostScriptTokenTypes.LBRACE)) {
  41772. const jumpLocation = this.operators.length;
  41773. this.operators.push(null, null);
  41774. const endOfTrue = this.operators.length;
  41775. this.parseBlock();
  41776. this.expect(PostScriptTokenTypes.RBRACE);
  41777. this.expect(PostScriptTokenTypes.IFELSE);
  41778. this.operators[jumpLocation] = this.operators.length;
  41779. this.operators[jumpLocation + 1] = "j";
  41780. this.operators[conditionLocation] = endOfTrue;
  41781. this.operators[conditionLocation + 1] = "jz";
  41782. } else {
  41783. throw new _util.FormatError("PS Function: error parsing conditional.");
  41784. }
  41785. }
  41786. }
  41787. exports.PostScriptParser = PostScriptParser;
  41788. const PostScriptTokenTypes = {
  41789. LBRACE: 0,
  41790. RBRACE: 1,
  41791. NUMBER: 2,
  41792. OPERATOR: 3,
  41793. IF: 4,
  41794. IFELSE: 5
  41795. };
  41796. class PostScriptToken {
  41797. static get opCache() {
  41798. return (0, _util.shadow)(this, "opCache", Object.create(null));
  41799. }
  41800. constructor(type, value) {
  41801. this.type = type;
  41802. this.value = value;
  41803. }
  41804. static getOperator(op) {
  41805. return PostScriptToken.opCache[op] ||= new PostScriptToken(PostScriptTokenTypes.OPERATOR, op);
  41806. }
  41807. static get LBRACE() {
  41808. return (0, _util.shadow)(this, "LBRACE", new PostScriptToken(PostScriptTokenTypes.LBRACE, "{"));
  41809. }
  41810. static get RBRACE() {
  41811. return (0, _util.shadow)(this, "RBRACE", new PostScriptToken(PostScriptTokenTypes.RBRACE, "}"));
  41812. }
  41813. static get IF() {
  41814. return (0, _util.shadow)(this, "IF", new PostScriptToken(PostScriptTokenTypes.IF, "IF"));
  41815. }
  41816. static get IFELSE() {
  41817. return (0, _util.shadow)(this, "IFELSE", new PostScriptToken(PostScriptTokenTypes.IFELSE, "IFELSE"));
  41818. }
  41819. }
  41820. class PostScriptLexer {
  41821. constructor(stream) {
  41822. this.stream = stream;
  41823. this.nextChar();
  41824. this.strBuf = [];
  41825. }
  41826. nextChar() {
  41827. return this.currentChar = this.stream.getByte();
  41828. }
  41829. getToken() {
  41830. let comment = false;
  41831. let ch = this.currentChar;
  41832. while (true) {
  41833. if (ch < 0) {
  41834. return _primitives.EOF;
  41835. }
  41836. if (comment) {
  41837. if (ch === 0x0a || ch === 0x0d) {
  41838. comment = false;
  41839. }
  41840. } else if (ch === 0x25) {
  41841. comment = true;
  41842. } else if (!(0, _core_utils.isWhiteSpace)(ch)) {
  41843. break;
  41844. }
  41845. ch = this.nextChar();
  41846. }
  41847. switch (ch | 0) {
  41848. case 0x30:
  41849. case 0x31:
  41850. case 0x32:
  41851. case 0x33:
  41852. case 0x34:
  41853. case 0x35:
  41854. case 0x36:
  41855. case 0x37:
  41856. case 0x38:
  41857. case 0x39:
  41858. case 0x2b:
  41859. case 0x2d:
  41860. case 0x2e:
  41861. return new PostScriptToken(PostScriptTokenTypes.NUMBER, this.getNumber());
  41862. case 0x7b:
  41863. this.nextChar();
  41864. return PostScriptToken.LBRACE;
  41865. case 0x7d:
  41866. this.nextChar();
  41867. return PostScriptToken.RBRACE;
  41868. }
  41869. const strBuf = this.strBuf;
  41870. strBuf.length = 0;
  41871. strBuf[0] = String.fromCharCode(ch);
  41872. while ((ch = this.nextChar()) >= 0 && (ch >= 0x41 && ch <= 0x5a || ch >= 0x61 && ch <= 0x7a)) {
  41873. strBuf.push(String.fromCharCode(ch));
  41874. }
  41875. const str = strBuf.join("");
  41876. switch (str.toLowerCase()) {
  41877. case "if":
  41878. return PostScriptToken.IF;
  41879. case "ifelse":
  41880. return PostScriptToken.IFELSE;
  41881. default:
  41882. return PostScriptToken.getOperator(str);
  41883. }
  41884. }
  41885. getNumber() {
  41886. let ch = this.currentChar;
  41887. const strBuf = this.strBuf;
  41888. strBuf.length = 0;
  41889. strBuf[0] = String.fromCharCode(ch);
  41890. while ((ch = this.nextChar()) >= 0) {
  41891. if (ch >= 0x30 && ch <= 0x39 || ch === 0x2d || ch === 0x2e) {
  41892. strBuf.push(String.fromCharCode(ch));
  41893. } else {
  41894. break;
  41895. }
  41896. }
  41897. const value = parseFloat(strBuf.join(""));
  41898. if (isNaN(value)) {
  41899. throw new _util.FormatError(`Invalid floating point number: ${value}`);
  41900. }
  41901. return value;
  41902. }
  41903. }
  41904. exports.PostScriptLexer = PostScriptLexer;
  41905. /***/ }),
  41906. /* 210 */
  41907. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  41908. Object.defineProperty(exports, "__esModule", ({
  41909. value: true
  41910. }));
  41911. exports.RegionalImageCache = exports.LocalTilingPatternCache = exports.LocalImageCache = exports.LocalGStateCache = exports.LocalFunctionCache = exports.LocalColorSpaceCache = exports.GlobalImageCache = void 0;
  41912. __w_pdfjs_require__(2);
  41913. __w_pdfjs_require__(116);
  41914. __w_pdfjs_require__(127);
  41915. __w_pdfjs_require__(129);
  41916. __w_pdfjs_require__(132);
  41917. __w_pdfjs_require__(134);
  41918. __w_pdfjs_require__(136);
  41919. __w_pdfjs_require__(138);
  41920. var _util = __w_pdfjs_require__(145);
  41921. var _primitives = __w_pdfjs_require__(151);
  41922. class BaseLocalCache {
  41923. constructor(options) {
  41924. if (this.constructor === BaseLocalCache) {
  41925. (0, _util.unreachable)("Cannot initialize BaseLocalCache.");
  41926. }
  41927. this._onlyRefs = options?.onlyRefs === true;
  41928. if (!this._onlyRefs) {
  41929. this._nameRefMap = new Map();
  41930. this._imageMap = new Map();
  41931. }
  41932. this._imageCache = new _primitives.RefSetCache();
  41933. }
  41934. getByName(name) {
  41935. if (this._onlyRefs) {
  41936. (0, _util.unreachable)("Should not call `getByName` method.");
  41937. }
  41938. const ref = this._nameRefMap.get(name);
  41939. if (ref) {
  41940. return this.getByRef(ref);
  41941. }
  41942. return this._imageMap.get(name) || null;
  41943. }
  41944. getByRef(ref) {
  41945. return this._imageCache.get(ref) || null;
  41946. }
  41947. set(name, ref, data) {
  41948. (0, _util.unreachable)("Abstract method `set` called.");
  41949. }
  41950. }
  41951. class LocalImageCache extends BaseLocalCache {
  41952. set(name) {
  41953. let ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  41954. let data = arguments.length > 2 ? arguments[2] : undefined;
  41955. if (typeof name !== "string") {
  41956. throw new Error('LocalImageCache.set - expected "name" argument.');
  41957. }
  41958. if (ref) {
  41959. if (this._imageCache.has(ref)) {
  41960. return;
  41961. }
  41962. this._nameRefMap.set(name, ref);
  41963. this._imageCache.put(ref, data);
  41964. return;
  41965. }
  41966. if (this._imageMap.has(name)) {
  41967. return;
  41968. }
  41969. this._imageMap.set(name, data);
  41970. }
  41971. }
  41972. exports.LocalImageCache = LocalImageCache;
  41973. class LocalColorSpaceCache extends BaseLocalCache {
  41974. set() {
  41975. let name = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
  41976. let ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  41977. let data = arguments.length > 2 ? arguments[2] : undefined;
  41978. if (typeof name !== "string" && !ref) {
  41979. throw new Error('LocalColorSpaceCache.set - expected "name" and/or "ref" argument.');
  41980. }
  41981. if (ref) {
  41982. if (this._imageCache.has(ref)) {
  41983. return;
  41984. }
  41985. if (name !== null) {
  41986. this._nameRefMap.set(name, ref);
  41987. }
  41988. this._imageCache.put(ref, data);
  41989. return;
  41990. }
  41991. if (this._imageMap.has(name)) {
  41992. return;
  41993. }
  41994. this._imageMap.set(name, data);
  41995. }
  41996. }
  41997. exports.LocalColorSpaceCache = LocalColorSpaceCache;
  41998. class LocalFunctionCache extends BaseLocalCache {
  41999. constructor(options) {
  42000. super({
  42001. onlyRefs: true
  42002. });
  42003. }
  42004. set() {
  42005. let name = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
  42006. let ref = arguments.length > 1 ? arguments[1] : undefined;
  42007. let data = arguments.length > 2 ? arguments[2] : undefined;
  42008. if (!ref) {
  42009. throw new Error('LocalFunctionCache.set - expected "ref" argument.');
  42010. }
  42011. if (this._imageCache.has(ref)) {
  42012. return;
  42013. }
  42014. this._imageCache.put(ref, data);
  42015. }
  42016. }
  42017. exports.LocalFunctionCache = LocalFunctionCache;
  42018. class LocalGStateCache extends BaseLocalCache {
  42019. set(name) {
  42020. let ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  42021. let data = arguments.length > 2 ? arguments[2] : undefined;
  42022. if (typeof name !== "string") {
  42023. throw new Error('LocalGStateCache.set - expected "name" argument.');
  42024. }
  42025. if (ref) {
  42026. if (this._imageCache.has(ref)) {
  42027. return;
  42028. }
  42029. this._nameRefMap.set(name, ref);
  42030. this._imageCache.put(ref, data);
  42031. return;
  42032. }
  42033. if (this._imageMap.has(name)) {
  42034. return;
  42035. }
  42036. this._imageMap.set(name, data);
  42037. }
  42038. }
  42039. exports.LocalGStateCache = LocalGStateCache;
  42040. class LocalTilingPatternCache extends BaseLocalCache {
  42041. constructor(options) {
  42042. super({
  42043. onlyRefs: true
  42044. });
  42045. }
  42046. set() {
  42047. let name = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
  42048. let ref = arguments.length > 1 ? arguments[1] : undefined;
  42049. let data = arguments.length > 2 ? arguments[2] : undefined;
  42050. if (!ref) {
  42051. throw new Error('LocalTilingPatternCache.set - expected "ref" argument.');
  42052. }
  42053. if (this._imageCache.has(ref)) {
  42054. return;
  42055. }
  42056. this._imageCache.put(ref, data);
  42057. }
  42058. }
  42059. exports.LocalTilingPatternCache = LocalTilingPatternCache;
  42060. class RegionalImageCache extends BaseLocalCache {
  42061. constructor(options) {
  42062. super({
  42063. onlyRefs: true
  42064. });
  42065. }
  42066. set() {
  42067. let name = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
  42068. let ref = arguments.length > 1 ? arguments[1] : undefined;
  42069. let data = arguments.length > 2 ? arguments[2] : undefined;
  42070. if (!ref) {
  42071. throw new Error('RegionalImageCache.set - expected "ref" argument.');
  42072. }
  42073. if (this._imageCache.has(ref)) {
  42074. return;
  42075. }
  42076. this._imageCache.put(ref, data);
  42077. }
  42078. }
  42079. exports.RegionalImageCache = RegionalImageCache;
  42080. class GlobalImageCache {
  42081. static NUM_PAGES_THRESHOLD = 2;
  42082. static MIN_IMAGES_TO_CACHE = 10;
  42083. static MAX_BYTE_SIZE = 5 * _util.MAX_IMAGE_SIZE_TO_CACHE;
  42084. constructor() {
  42085. this._refCache = new _primitives.RefSetCache();
  42086. this._imageCache = new _primitives.RefSetCache();
  42087. }
  42088. get _byteSize() {
  42089. let byteSize = 0;
  42090. for (const imageData of this._imageCache) {
  42091. byteSize += imageData.byteSize;
  42092. }
  42093. return byteSize;
  42094. }
  42095. get _cacheLimitReached() {
  42096. if (this._imageCache.size < GlobalImageCache.MIN_IMAGES_TO_CACHE) {
  42097. return false;
  42098. }
  42099. if (this._byteSize < GlobalImageCache.MAX_BYTE_SIZE) {
  42100. return false;
  42101. }
  42102. return true;
  42103. }
  42104. shouldCache(ref, pageIndex) {
  42105. let pageIndexSet = this._refCache.get(ref);
  42106. if (!pageIndexSet) {
  42107. pageIndexSet = new Set();
  42108. this._refCache.put(ref, pageIndexSet);
  42109. }
  42110. pageIndexSet.add(pageIndex);
  42111. if (pageIndexSet.size < GlobalImageCache.NUM_PAGES_THRESHOLD) {
  42112. return false;
  42113. }
  42114. if (!this._imageCache.has(ref) && this._cacheLimitReached) {
  42115. return false;
  42116. }
  42117. return true;
  42118. }
  42119. addByteSize(ref, byteSize) {
  42120. const imageData = this._imageCache.get(ref);
  42121. if (!imageData) {
  42122. return;
  42123. }
  42124. if (imageData.byteSize) {
  42125. return;
  42126. }
  42127. imageData.byteSize = byteSize;
  42128. }
  42129. getData(ref, pageIndex) {
  42130. const pageIndexSet = this._refCache.get(ref);
  42131. if (!pageIndexSet) {
  42132. return null;
  42133. }
  42134. if (pageIndexSet.size < GlobalImageCache.NUM_PAGES_THRESHOLD) {
  42135. return null;
  42136. }
  42137. const imageData = this._imageCache.get(ref);
  42138. if (!imageData) {
  42139. return null;
  42140. }
  42141. pageIndexSet.add(pageIndex);
  42142. return imageData;
  42143. }
  42144. setData(ref, data) {
  42145. if (!this._refCache.has(ref)) {
  42146. throw new Error('GlobalImageCache.setData - expected "shouldCache" to have been called.');
  42147. }
  42148. if (this._imageCache.has(ref)) {
  42149. return;
  42150. }
  42151. if (this._cacheLimitReached) {
  42152. (0, _util.warn)("GlobalImageCache.setData - cache limit reached.");
  42153. return;
  42154. }
  42155. this._imageCache.put(ref, data);
  42156. }
  42157. clear() {
  42158. let onlyData = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  42159. if (!onlyData) {
  42160. this._refCache.clear();
  42161. }
  42162. this._imageCache.clear();
  42163. }
  42164. }
  42165. exports.GlobalImageCache = GlobalImageCache;
  42166. /***/ }),
  42167. /* 211 */
  42168. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  42169. Object.defineProperty(exports, "__esModule", ({
  42170. value: true
  42171. }));
  42172. exports.bidi = bidi;
  42173. var _util = __w_pdfjs_require__(145);
  42174. 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"];
  42175. 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"];
  42176. function isOdd(i) {
  42177. return (i & 1) !== 0;
  42178. }
  42179. function isEven(i) {
  42180. return (i & 1) === 0;
  42181. }
  42182. function findUnequal(arr, start, value) {
  42183. let j, jj;
  42184. for (j = start, jj = arr.length; j < jj; ++j) {
  42185. if (arr[j] !== value) {
  42186. return j;
  42187. }
  42188. }
  42189. return j;
  42190. }
  42191. function setValues(arr, start, end, value) {
  42192. for (let j = start; j < end; ++j) {
  42193. arr[j] = value;
  42194. }
  42195. }
  42196. function reverseValues(arr, start, end) {
  42197. for (let i = start, j = end - 1; i < j; ++i, --j) {
  42198. const temp = arr[i];
  42199. arr[i] = arr[j];
  42200. arr[j] = temp;
  42201. }
  42202. }
  42203. function createBidiText(str, isLTR) {
  42204. let vertical = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  42205. let dir = "ltr";
  42206. if (vertical) {
  42207. dir = "ttb";
  42208. } else if (!isLTR) {
  42209. dir = "rtl";
  42210. }
  42211. return {
  42212. str,
  42213. dir
  42214. };
  42215. }
  42216. const chars = [];
  42217. const types = [];
  42218. function bidi(str) {
  42219. let startLevel = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : -1;
  42220. let vertical = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  42221. let isLTR = true;
  42222. const strLength = str.length;
  42223. if (strLength === 0 || vertical) {
  42224. return createBidiText(str, isLTR, vertical);
  42225. }
  42226. chars.length = strLength;
  42227. types.length = strLength;
  42228. let numBidi = 0;
  42229. let i, ii;
  42230. for (i = 0; i < strLength; ++i) {
  42231. chars[i] = str.charAt(i);
  42232. const charCode = str.charCodeAt(i);
  42233. let charType = "L";
  42234. if (charCode <= 0x00ff) {
  42235. charType = baseTypes[charCode];
  42236. } else if (0x0590 <= charCode && charCode <= 0x05f4) {
  42237. charType = "R";
  42238. } else if (0x0600 <= charCode && charCode <= 0x06ff) {
  42239. charType = arabicTypes[charCode & 0xff];
  42240. if (!charType) {
  42241. (0, _util.warn)("Bidi: invalid Unicode character " + charCode.toString(16));
  42242. }
  42243. } else if (0x0700 <= charCode && charCode <= 0x08ac || 0xfb50 <= charCode && charCode <= 0xfdff || 0xfe70 <= charCode && charCode <= 0xfeff) {
  42244. charType = "AL";
  42245. }
  42246. if (charType === "R" || charType === "AL" || charType === "AN") {
  42247. numBidi++;
  42248. }
  42249. types[i] = charType;
  42250. }
  42251. if (numBidi === 0) {
  42252. isLTR = true;
  42253. return createBidiText(str, isLTR);
  42254. }
  42255. if (startLevel === -1) {
  42256. if (numBidi / strLength < 0.3 && strLength > 4) {
  42257. isLTR = true;
  42258. startLevel = 0;
  42259. } else {
  42260. isLTR = false;
  42261. startLevel = 1;
  42262. }
  42263. }
  42264. const levels = [];
  42265. for (i = 0; i < strLength; ++i) {
  42266. levels[i] = startLevel;
  42267. }
  42268. const e = isOdd(startLevel) ? "R" : "L";
  42269. const sor = e;
  42270. const eor = sor;
  42271. let lastType = sor;
  42272. for (i = 0; i < strLength; ++i) {
  42273. if (types[i] === "NSM") {
  42274. types[i] = lastType;
  42275. } else {
  42276. lastType = types[i];
  42277. }
  42278. }
  42279. lastType = sor;
  42280. let t;
  42281. for (i = 0; i < strLength; ++i) {
  42282. t = types[i];
  42283. if (t === "EN") {
  42284. types[i] = lastType === "AL" ? "AN" : "EN";
  42285. } else if (t === "R" || t === "L" || t === "AL") {
  42286. lastType = t;
  42287. }
  42288. }
  42289. for (i = 0; i < strLength; ++i) {
  42290. t = types[i];
  42291. if (t === "AL") {
  42292. types[i] = "R";
  42293. }
  42294. }
  42295. for (i = 1; i < strLength - 1; ++i) {
  42296. if (types[i] === "ES" && types[i - 1] === "EN" && types[i + 1] === "EN") {
  42297. types[i] = "EN";
  42298. }
  42299. if (types[i] === "CS" && (types[i - 1] === "EN" || types[i - 1] === "AN") && types[i + 1] === types[i - 1]) {
  42300. types[i] = types[i - 1];
  42301. }
  42302. }
  42303. for (i = 0; i < strLength; ++i) {
  42304. if (types[i] === "EN") {
  42305. for (let j = i - 1; j >= 0; --j) {
  42306. if (types[j] !== "ET") {
  42307. break;
  42308. }
  42309. types[j] = "EN";
  42310. }
  42311. for (let j = i + 1; j < strLength; ++j) {
  42312. if (types[j] !== "ET") {
  42313. break;
  42314. }
  42315. types[j] = "EN";
  42316. }
  42317. }
  42318. }
  42319. for (i = 0; i < strLength; ++i) {
  42320. t = types[i];
  42321. if (t === "WS" || t === "ES" || t === "ET" || t === "CS") {
  42322. types[i] = "ON";
  42323. }
  42324. }
  42325. lastType = sor;
  42326. for (i = 0; i < strLength; ++i) {
  42327. t = types[i];
  42328. if (t === "EN") {
  42329. types[i] = lastType === "L" ? "L" : "EN";
  42330. } else if (t === "R" || t === "L") {
  42331. lastType = t;
  42332. }
  42333. }
  42334. for (i = 0; i < strLength; ++i) {
  42335. if (types[i] === "ON") {
  42336. const end = findUnequal(types, i + 1, "ON");
  42337. let before = sor;
  42338. if (i > 0) {
  42339. before = types[i - 1];
  42340. }
  42341. let after = eor;
  42342. if (end + 1 < strLength) {
  42343. after = types[end + 1];
  42344. }
  42345. if (before !== "L") {
  42346. before = "R";
  42347. }
  42348. if (after !== "L") {
  42349. after = "R";
  42350. }
  42351. if (before === after) {
  42352. setValues(types, i, end, before);
  42353. }
  42354. i = end - 1;
  42355. }
  42356. }
  42357. for (i = 0; i < strLength; ++i) {
  42358. if (types[i] === "ON") {
  42359. types[i] = e;
  42360. }
  42361. }
  42362. for (i = 0; i < strLength; ++i) {
  42363. t = types[i];
  42364. if (isEven(levels[i])) {
  42365. if (t === "R") {
  42366. levels[i] += 1;
  42367. } else if (t === "AN" || t === "EN") {
  42368. levels[i] += 2;
  42369. }
  42370. } else if (t === "L" || t === "AN" || t === "EN") {
  42371. levels[i] += 1;
  42372. }
  42373. }
  42374. let highestLevel = -1;
  42375. let lowestOddLevel = 99;
  42376. let level;
  42377. for (i = 0, ii = levels.length; i < ii; ++i) {
  42378. level = levels[i];
  42379. if (highestLevel < level) {
  42380. highestLevel = level;
  42381. }
  42382. if (lowestOddLevel > level && isOdd(level)) {
  42383. lowestOddLevel = level;
  42384. }
  42385. }
  42386. for (level = highestLevel; level >= lowestOddLevel; --level) {
  42387. let start = -1;
  42388. for (i = 0, ii = levels.length; i < ii; ++i) {
  42389. if (levels[i] < level) {
  42390. if (start >= 0) {
  42391. reverseValues(chars, start, i);
  42392. start = -1;
  42393. }
  42394. } else if (start < 0) {
  42395. start = i;
  42396. }
  42397. }
  42398. if (start >= 0) {
  42399. reverseValues(chars, start, levels.length);
  42400. }
  42401. }
  42402. for (i = 0, ii = chars.length; i < ii; ++i) {
  42403. const ch = chars[i];
  42404. if (ch === "<" || ch === ">") {
  42405. chars[i] = "";
  42406. }
  42407. }
  42408. return createBidiText(chars.join(""), isLTR);
  42409. }
  42410. /***/ }),
  42411. /* 212 */
  42412. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  42413. Object.defineProperty(exports, "__esModule", ({
  42414. value: true
  42415. }));
  42416. exports.getFontSubstitution = getFontSubstitution;
  42417. __w_pdfjs_require__(140);
  42418. var _fonts_utils = __w_pdfjs_require__(189);
  42419. var _core_utils = __w_pdfjs_require__(150);
  42420. const NORMAL = {
  42421. style: "normal",
  42422. weight: "normal"
  42423. };
  42424. const BOLD = {
  42425. style: "normal",
  42426. weight: "bold"
  42427. };
  42428. const ITALIC = {
  42429. style: "italic",
  42430. weight: "normal"
  42431. };
  42432. const BOLDITALIC = {
  42433. style: "italic",
  42434. weight: "bold"
  42435. };
  42436. const substitutionMap = new Map([["Times-Roman", {
  42437. 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"],
  42438. style: NORMAL,
  42439. ultimate: "serif"
  42440. }], ["Times-Bold", {
  42441. alias: "Times-Roman",
  42442. style: BOLD,
  42443. ultimate: "serif"
  42444. }], ["Times-Italic", {
  42445. alias: "Times-Roman",
  42446. style: ITALIC,
  42447. ultimate: "serif"
  42448. }], ["Times-BoldItalic", {
  42449. alias: "Times-Roman",
  42450. style: BOLDITALIC,
  42451. ultimate: "serif"
  42452. }], ["Helvetica", {
  42453. 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"],
  42454. path: "LiberationSans-Regular.ttf",
  42455. style: NORMAL,
  42456. ultimate: "sans-serif"
  42457. }], ["Helvetica-Bold", {
  42458. alias: "Helvetica",
  42459. path: "LiberationSans-Bold.ttf",
  42460. style: BOLD,
  42461. ultimate: "sans-serif"
  42462. }], ["Helvetica-Oblique", {
  42463. alias: "Helvetica",
  42464. path: "LiberationSans-Italic.ttf",
  42465. style: ITALIC,
  42466. ultimate: "sans-serif"
  42467. }], ["Helvetica-BoldOblique", {
  42468. alias: "Helvetica",
  42469. path: "LiberationSans-BoldItalic.ttf",
  42470. style: BOLDITALIC,
  42471. ultimate: "sans-serif"
  42472. }], ["Courier", {
  42473. local: ["Courier", "Courier New", "Liberation Mono", "Nimbus Mono", "Nimbus Mono L", "Cousine", "Cumberland", "TeX Gyre Cursor", "FreeMono"],
  42474. style: NORMAL,
  42475. ultimate: "monospace"
  42476. }], ["Courier-Bold", {
  42477. alias: "Courier",
  42478. style: BOLD,
  42479. ultimate: "monospace"
  42480. }], ["Courier-Oblique", {
  42481. alias: "Courier",
  42482. style: ITALIC,
  42483. ultimate: "monospace"
  42484. }], ["Courier-BoldOblique", {
  42485. alias: "Courier",
  42486. style: BOLDITALIC,
  42487. ultimate: "monospace"
  42488. }], ["ArialBlack", {
  42489. local: ["Arial Black"],
  42490. style: {
  42491. style: "normal",
  42492. weight: "900"
  42493. },
  42494. fallback: "Helvetica-Bold"
  42495. }], ["ArialBlack-Bold", {
  42496. alias: "ArialBlack"
  42497. }], ["ArialBlack-Italic", {
  42498. alias: "ArialBlack",
  42499. style: {
  42500. style: "italic",
  42501. weight: "900"
  42502. },
  42503. fallback: "Helvetica-BoldOblique"
  42504. }], ["ArialBlack-BoldItalic", {
  42505. alias: "ArialBlack-Italic"
  42506. }], ["ArialNarrow", {
  42507. local: ["Arial Narrow", "Liberation Sans Narrow", "Helvetica Condensed", "Nimbus Sans Narrow", "TeX Gyre Heros Cn"],
  42508. style: NORMAL,
  42509. fallback: "Helvetica"
  42510. }], ["ArialNarrow-Bold", {
  42511. alias: "ArialNarrow",
  42512. style: BOLD,
  42513. fallback: "Helvetica-Bold"
  42514. }], ["ArialNarrow-Italic", {
  42515. alias: "ArialNarrow",
  42516. style: ITALIC,
  42517. fallback: "Helvetica-Oblique"
  42518. }], ["ArialNarrow-BoldItalic", {
  42519. alias: "ArialNarrow",
  42520. style: BOLDITALIC,
  42521. fallback: "Helvetica-BoldOblique"
  42522. }], ["Calibri", {
  42523. local: ["Calibri", "Carlito"],
  42524. style: NORMAL,
  42525. fallback: "Helvetica"
  42526. }], ["Calibri-Bold", {
  42527. alias: "Calibri",
  42528. style: BOLD,
  42529. fallback: "Helvetica-Bold"
  42530. }], ["Calibri-Italic", {
  42531. alias: "Calibri",
  42532. style: ITALIC,
  42533. fallback: "Helvetica-Oblique"
  42534. }], ["Calibri-BoldItalic", {
  42535. alias: "Calibri",
  42536. style: BOLDITALIC,
  42537. fallback: "Helvetica-BoldOblique"
  42538. }], ["Wingdings", {
  42539. local: ["Wingdings", "URW Dingbats"],
  42540. style: NORMAL
  42541. }], ["Wingdings-Regular", {
  42542. alias: "Wingdings"
  42543. }], ["Wingdings-Bold", {
  42544. alias: "Wingdings"
  42545. }]]);
  42546. const fontAliases = new Map([["Arial-Black", "ArialBlack"]]);
  42547. function getStyleToAppend(style) {
  42548. switch (style) {
  42549. case BOLD:
  42550. return "Bold";
  42551. case ITALIC:
  42552. return "Italic";
  42553. case BOLDITALIC:
  42554. return "Bold Italic";
  42555. default:
  42556. if (style?.weight === "bold") {
  42557. return "Bold";
  42558. }
  42559. if (style?.style === "italic") {
  42560. return "Italic";
  42561. }
  42562. }
  42563. return "";
  42564. }
  42565. function generateFont(_ref, src, localFontPath) {
  42566. let {
  42567. alias,
  42568. local,
  42569. path,
  42570. fallback,
  42571. style,
  42572. ultimate
  42573. } = _ref;
  42574. let useFallback = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : true;
  42575. let usePath = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : true;
  42576. let append = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : "";
  42577. const result = {
  42578. style: null,
  42579. ultimate: null
  42580. };
  42581. if (local) {
  42582. const extra = append ? ` ${append}` : "";
  42583. for (const name of local) {
  42584. src.push(`local(${name}${extra})`);
  42585. }
  42586. }
  42587. if (alias) {
  42588. const substitution = substitutionMap.get(alias);
  42589. const aliasAppend = append || getStyleToAppend(style);
  42590. Object.assign(result, generateFont(substitution, src, localFontPath, useFallback && !fallback, usePath && !path, aliasAppend));
  42591. }
  42592. if (style) {
  42593. result.style = style;
  42594. }
  42595. if (ultimate) {
  42596. result.ultimate = ultimate;
  42597. }
  42598. if (useFallback && fallback) {
  42599. const fallbackInfo = substitutionMap.get(fallback);
  42600. const {
  42601. ultimate: fallbackUltimate
  42602. } = generateFont(fallbackInfo, src, localFontPath, useFallback, usePath && !path, append);
  42603. result.ultimate ||= fallbackUltimate;
  42604. }
  42605. if (usePath && path && localFontPath) {
  42606. src.push(`url(${localFontPath}${path})`);
  42607. }
  42608. return result;
  42609. }
  42610. function getFontSubstitution(systemFontCache, idFactory, localFontPath, baseFontName, standardFontName) {
  42611. baseFontName = (0, _fonts_utils.normalizeFontName)(baseFontName);
  42612. const key = baseFontName;
  42613. let substitutionInfo = systemFontCache.get(key);
  42614. if (substitutionInfo) {
  42615. return substitutionInfo;
  42616. }
  42617. let substitution = substitutionMap.get(baseFontName);
  42618. if (!substitution) {
  42619. for (const [alias, subst] of fontAliases) {
  42620. if (baseFontName.startsWith(alias)) {
  42621. baseFontName = `${subst}${baseFontName.substring(alias.length)}`;
  42622. substitution = substitutionMap.get(baseFontName);
  42623. break;
  42624. }
  42625. }
  42626. }
  42627. let mustAddBaseFont = false;
  42628. if (!substitution) {
  42629. substitution = substitutionMap.get(standardFontName);
  42630. mustAddBaseFont = true;
  42631. }
  42632. const loadedName = `${idFactory.getDocId()}_s${idFactory.createFontId()}`;
  42633. if (!substitution) {
  42634. if (!(0, _core_utils.validateFontName)(baseFontName)) {
  42635. systemFontCache.set(key, null);
  42636. return null;
  42637. }
  42638. const bold = /bold/gi.test(baseFontName);
  42639. const italic = /oblique|italic/gi.test(baseFontName);
  42640. const style = bold && italic && BOLDITALIC || bold && BOLD || italic && ITALIC || NORMAL;
  42641. substitutionInfo = {
  42642. css: loadedName,
  42643. guessFallback: true,
  42644. loadedName,
  42645. baseFontName,
  42646. src: `local(${baseFontName})`,
  42647. style
  42648. };
  42649. systemFontCache.set(key, substitutionInfo);
  42650. return substitutionInfo;
  42651. }
  42652. const src = [];
  42653. if (mustAddBaseFont && (0, _core_utils.validateFontName)(baseFontName)) {
  42654. src.push(`local(${baseFontName})`);
  42655. }
  42656. const {
  42657. style,
  42658. ultimate
  42659. } = generateFont(substitution, src, localFontPath);
  42660. const guessFallback = ultimate === null;
  42661. const fallback = guessFallback ? "" : `,${ultimate}`;
  42662. substitutionInfo = {
  42663. css: `${loadedName}${fallback}`,
  42664. guessFallback,
  42665. loadedName,
  42666. baseFontName,
  42667. src: src.join(","),
  42668. style
  42669. };
  42670. systemFontCache.set(key, substitutionInfo);
  42671. return substitutionInfo;
  42672. }
  42673. /***/ }),
  42674. /* 213 */
  42675. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  42676. Object.defineProperty(exports, "__esModule", ({
  42677. value: true
  42678. }));
  42679. exports.ImageResizer = void 0;
  42680. __w_pdfjs_require__(84);
  42681. __w_pdfjs_require__(93);
  42682. __w_pdfjs_require__(94);
  42683. __w_pdfjs_require__(97);
  42684. __w_pdfjs_require__(99);
  42685. __w_pdfjs_require__(101);
  42686. __w_pdfjs_require__(105);
  42687. __w_pdfjs_require__(108);
  42688. __w_pdfjs_require__(115);
  42689. __w_pdfjs_require__(2);
  42690. var _util = __w_pdfjs_require__(145);
  42691. const MIN_IMAGE_DIM = 2048;
  42692. const MAX_IMAGE_DIM = 65537;
  42693. const MAX_ERROR = 128;
  42694. class ImageResizer {
  42695. constructor(imgData, isMask) {
  42696. this._imgData = imgData;
  42697. this._isMask = isMask;
  42698. }
  42699. static needsToBeResized(width, height) {
  42700. if (width <= this._goodSquareLength && height <= this._goodSquareLength) {
  42701. return false;
  42702. }
  42703. const {
  42704. MAX_DIM
  42705. } = this;
  42706. if (width > MAX_DIM || height > MAX_DIM) {
  42707. return true;
  42708. }
  42709. const area = width * height;
  42710. if (this._hasMaxArea) {
  42711. return area > this.MAX_AREA;
  42712. }
  42713. if (area < this._goodSquareLength ** 2) {
  42714. return false;
  42715. }
  42716. if (this._areGoodDims(width, height)) {
  42717. this._goodSquareLength = Math.max(this._goodSquareLength, Math.floor(Math.sqrt(width * height)));
  42718. return false;
  42719. }
  42720. this._goodSquareLength = this._guessMax(this._goodSquareLength, MAX_DIM, MAX_ERROR, 0);
  42721. const maxArea = this.MAX_AREA = this._goodSquareLength ** 2;
  42722. return area > maxArea;
  42723. }
  42724. static get MAX_DIM() {
  42725. return (0, _util.shadow)(this, "MAX_DIM", this._guessMax(MIN_IMAGE_DIM, MAX_IMAGE_DIM, 0, 1));
  42726. }
  42727. static get MAX_AREA() {
  42728. this._hasMaxArea = true;
  42729. return (0, _util.shadow)(this, "MAX_AREA", this._guessMax(ImageResizer._goodSquareLength, this.MAX_DIM, MAX_ERROR, 0) ** 2);
  42730. }
  42731. static set MAX_AREA(area) {
  42732. if (area >= 0) {
  42733. this._hasMaxArea = true;
  42734. (0, _util.shadow)(this, "MAX_AREA", area);
  42735. }
  42736. }
  42737. static setMaxArea(area) {
  42738. if (!this._hasMaxArea) {
  42739. this.MAX_AREA = area >> 2;
  42740. }
  42741. }
  42742. static _areGoodDims(width, height) {
  42743. try {
  42744. const canvas = new OffscreenCanvas(width, height);
  42745. const ctx = canvas.getContext("2d");
  42746. ctx.fillRect(0, 0, 1, 1);
  42747. const opacity = ctx.getImageData(0, 0, 1, 1).data[3];
  42748. canvas.width = canvas.height = 1;
  42749. return opacity !== 0;
  42750. } catch {
  42751. return false;
  42752. }
  42753. }
  42754. static _guessMax(start, end, tolerance, defaultHeight) {
  42755. while (start + tolerance + 1 < end) {
  42756. const middle = Math.floor((start + end) / 2);
  42757. const height = defaultHeight || middle;
  42758. if (this._areGoodDims(middle, height)) {
  42759. start = middle;
  42760. } else {
  42761. end = middle;
  42762. }
  42763. }
  42764. return start;
  42765. }
  42766. static async createImage(imgData) {
  42767. let isMask = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  42768. return new ImageResizer(imgData, isMask)._createImage();
  42769. }
  42770. async _createImage() {
  42771. const data = this._encodeBMP();
  42772. const blob = new Blob([data.buffer], {
  42773. type: "image/bmp"
  42774. });
  42775. const bitmapPromise = createImageBitmap(blob);
  42776. const {
  42777. MAX_AREA,
  42778. MAX_DIM
  42779. } = ImageResizer;
  42780. const {
  42781. _imgData: imgData
  42782. } = this;
  42783. const {
  42784. width,
  42785. height
  42786. } = imgData;
  42787. const minFactor = Math.max(width / MAX_DIM, height / MAX_DIM, Math.sqrt(width * height / MAX_AREA));
  42788. const firstFactor = Math.max(minFactor, 2);
  42789. const factor = Math.round(10 * (minFactor + 1.25)) / 10 / firstFactor;
  42790. const N = Math.floor(Math.log2(factor));
  42791. const steps = new Array(N + 2).fill(2);
  42792. steps[0] = firstFactor;
  42793. steps.splice(-1, 1, factor / (1 << N));
  42794. let newWidth = width;
  42795. let newHeight = height;
  42796. let bitmap = await bitmapPromise;
  42797. for (const step of steps) {
  42798. const prevWidth = newWidth;
  42799. const prevHeight = newHeight;
  42800. newWidth = Math.floor(newWidth / step) - 1;
  42801. newHeight = Math.floor(newHeight / step) - 1;
  42802. const canvas = new OffscreenCanvas(newWidth, newHeight);
  42803. const ctx = canvas.getContext("2d");
  42804. ctx.drawImage(bitmap, 0, 0, prevWidth, prevHeight, 0, 0, newWidth, newHeight);
  42805. bitmap = canvas.transferToImageBitmap();
  42806. }
  42807. imgData.data = null;
  42808. imgData.bitmap = bitmap;
  42809. imgData.width = newWidth;
  42810. imgData.height = newHeight;
  42811. return imgData;
  42812. }
  42813. _encodeBMP() {
  42814. const {
  42815. width,
  42816. height,
  42817. kind
  42818. } = this._imgData;
  42819. let data = this._imgData.data;
  42820. let bitPerPixel;
  42821. let colorTable = new Uint8Array(0);
  42822. let maskTable = colorTable;
  42823. let compression = 0;
  42824. switch (kind) {
  42825. case _util.ImageKind.GRAYSCALE_1BPP:
  42826. {
  42827. bitPerPixel = 1;
  42828. colorTable = new Uint8Array(this._isMask ? [255, 255, 255, 255, 0, 0, 0, 0] : [0, 0, 0, 0, 255, 255, 255, 255]);
  42829. const rowLen = width + 7 >> 3;
  42830. const rowSize = rowLen + 3 & -4;
  42831. if (rowLen !== rowSize) {
  42832. const newData = new Uint8Array(rowSize * height);
  42833. let k = 0;
  42834. for (let i = 0, ii = height * rowLen; i < ii; i += rowLen, k += rowSize) {
  42835. newData.set(data.subarray(i, i + rowLen), k);
  42836. }
  42837. data = newData;
  42838. }
  42839. break;
  42840. }
  42841. case _util.ImageKind.RGB_24BPP:
  42842. {
  42843. bitPerPixel = 24;
  42844. if (width & 3) {
  42845. const rowLen = 3 * width;
  42846. const rowSize = rowLen + 3 & -4;
  42847. const extraLen = rowSize - rowLen;
  42848. const newData = new Uint8Array(rowSize * height);
  42849. let k = 0;
  42850. for (let i = 0, ii = height * rowLen; i < ii; i += rowLen) {
  42851. const row = data.subarray(i, i + rowLen);
  42852. for (let j = 0; j < rowLen; j += 3) {
  42853. newData[k++] = row[j + 2];
  42854. newData[k++] = row[j + 1];
  42855. newData[k++] = row[j];
  42856. }
  42857. k += extraLen;
  42858. }
  42859. data = newData;
  42860. } else {
  42861. for (let i = 0, ii = data.length; i < ii; i += 3) {
  42862. const tmp = data[i];
  42863. data[i] = data[i + 2];
  42864. data[i + 2] = tmp;
  42865. }
  42866. }
  42867. break;
  42868. }
  42869. case _util.ImageKind.RGBA_32BPP:
  42870. bitPerPixel = 32;
  42871. compression = 3;
  42872. maskTable = new Uint8Array(4 + 4 + 4 + 4 + 52);
  42873. const view = new DataView(maskTable.buffer);
  42874. if (_util.FeatureTest.isLittleEndian) {
  42875. view.setUint32(0, 0x000000ff, true);
  42876. view.setUint32(4, 0x0000ff00, true);
  42877. view.setUint32(8, 0x00ff0000, true);
  42878. view.setUint32(12, 0xff000000, true);
  42879. } else {
  42880. view.setUint32(0, 0xff000000, true);
  42881. view.setUint32(4, 0x00ff0000, true);
  42882. view.setUint32(8, 0x0000ff00, true);
  42883. view.setUint32(12, 0x000000ff, true);
  42884. }
  42885. break;
  42886. default:
  42887. throw new Error("invalid format");
  42888. }
  42889. let i = 0;
  42890. const headerLength = 40 + maskTable.length;
  42891. const fileLength = 14 + headerLength + colorTable.length + data.length;
  42892. const bmpData = new Uint8Array(fileLength);
  42893. const view = new DataView(bmpData.buffer);
  42894. view.setUint16(i, 0x4d42, true);
  42895. i += 2;
  42896. view.setUint32(i, fileLength, true);
  42897. i += 4;
  42898. view.setUint32(i, 0, true);
  42899. i += 4;
  42900. view.setUint32(i, 14 + headerLength + colorTable.length, true);
  42901. i += 4;
  42902. view.setUint32(i, headerLength, true);
  42903. i += 4;
  42904. view.setInt32(i, width, true);
  42905. i += 4;
  42906. view.setInt32(i, -height, true);
  42907. i += 4;
  42908. view.setUint16(i, 1, true);
  42909. i += 2;
  42910. view.setUint16(i, bitPerPixel, true);
  42911. i += 2;
  42912. view.setUint32(i, compression, true);
  42913. i += 4;
  42914. view.setUint32(i, 0, true);
  42915. i += 4;
  42916. view.setInt32(i, 0, true);
  42917. i += 4;
  42918. view.setInt32(i, 0, true);
  42919. i += 4;
  42920. view.setUint32(i, colorTable.length / 4, true);
  42921. i += 4;
  42922. view.setUint32(i, 0, true);
  42923. i += 4;
  42924. bmpData.set(maskTable, i);
  42925. i += maskTable.length;
  42926. bmpData.set(colorTable, i);
  42927. i += colorTable.length;
  42928. bmpData.set(data, i);
  42929. return bmpData;
  42930. }
  42931. }
  42932. exports.ImageResizer = ImageResizer;
  42933. ImageResizer._goodSquareLength = MIN_IMAGE_DIM;
  42934. /***/ }),
  42935. /* 214 */
  42936. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  42937. Object.defineProperty(exports, "__esModule", ({
  42938. value: true
  42939. }));
  42940. exports.MurmurHash3_64 = void 0;
  42941. __w_pdfjs_require__(84);
  42942. __w_pdfjs_require__(93);
  42943. __w_pdfjs_require__(94);
  42944. __w_pdfjs_require__(97);
  42945. __w_pdfjs_require__(99);
  42946. __w_pdfjs_require__(101);
  42947. __w_pdfjs_require__(105);
  42948. __w_pdfjs_require__(108);
  42949. __w_pdfjs_require__(115);
  42950. __w_pdfjs_require__(2);
  42951. var _util = __w_pdfjs_require__(145);
  42952. const SEED = 0xc3d2e1f0;
  42953. const MASK_HIGH = 0xffff0000;
  42954. const MASK_LOW = 0xffff;
  42955. class MurmurHash3_64 {
  42956. constructor(seed) {
  42957. this.h1 = seed ? seed & 0xffffffff : SEED;
  42958. this.h2 = seed ? seed & 0xffffffff : SEED;
  42959. }
  42960. update(input) {
  42961. let data, length;
  42962. if (typeof input === "string") {
  42963. data = new Uint8Array(input.length * 2);
  42964. length = 0;
  42965. for (let i = 0, ii = input.length; i < ii; i++) {
  42966. const code = input.charCodeAt(i);
  42967. if (code <= 0xff) {
  42968. data[length++] = code;
  42969. } else {
  42970. data[length++] = code >>> 8;
  42971. data[length++] = code & 0xff;
  42972. }
  42973. }
  42974. } else if ((0, _util.isArrayBuffer)(input)) {
  42975. data = input.slice();
  42976. length = data.byteLength;
  42977. } else {
  42978. throw new Error("Wrong data format in MurmurHash3_64_update. " + "Input must be a string or array.");
  42979. }
  42980. const blockCounts = length >> 2;
  42981. const tailLength = length - blockCounts * 4;
  42982. const dataUint32 = new Uint32Array(data.buffer, 0, blockCounts);
  42983. let k1 = 0,
  42984. k2 = 0;
  42985. let h1 = this.h1,
  42986. h2 = this.h2;
  42987. const C1 = 0xcc9e2d51,
  42988. C2 = 0x1b873593;
  42989. const C1_LOW = C1 & MASK_LOW,
  42990. C2_LOW = C2 & MASK_LOW;
  42991. for (let i = 0; i < blockCounts; i++) {
  42992. if (i & 1) {
  42993. k1 = dataUint32[i];
  42994. k1 = k1 * C1 & MASK_HIGH | k1 * C1_LOW & MASK_LOW;
  42995. k1 = k1 << 15 | k1 >>> 17;
  42996. k1 = k1 * C2 & MASK_HIGH | k1 * C2_LOW & MASK_LOW;
  42997. h1 ^= k1;
  42998. h1 = h1 << 13 | h1 >>> 19;
  42999. h1 = h1 * 5 + 0xe6546b64;
  43000. } else {
  43001. k2 = dataUint32[i];
  43002. k2 = k2 * C1 & MASK_HIGH | k2 * C1_LOW & MASK_LOW;
  43003. k2 = k2 << 15 | k2 >>> 17;
  43004. k2 = k2 * C2 & MASK_HIGH | k2 * C2_LOW & MASK_LOW;
  43005. h2 ^= k2;
  43006. h2 = h2 << 13 | h2 >>> 19;
  43007. h2 = h2 * 5 + 0xe6546b64;
  43008. }
  43009. }
  43010. k1 = 0;
  43011. switch (tailLength) {
  43012. case 3:
  43013. k1 ^= data[blockCounts * 4 + 2] << 16;
  43014. case 2:
  43015. k1 ^= data[blockCounts * 4 + 1] << 8;
  43016. case 1:
  43017. k1 ^= data[blockCounts * 4];
  43018. k1 = k1 * C1 & MASK_HIGH | k1 * C1_LOW & MASK_LOW;
  43019. k1 = k1 << 15 | k1 >>> 17;
  43020. k1 = k1 * C2 & MASK_HIGH | k1 * C2_LOW & MASK_LOW;
  43021. if (blockCounts & 1) {
  43022. h1 ^= k1;
  43023. } else {
  43024. h2 ^= k1;
  43025. }
  43026. }
  43027. this.h1 = h1;
  43028. this.h2 = h2;
  43029. }
  43030. hexdigest() {
  43031. let h1 = this.h1,
  43032. h2 = this.h2;
  43033. h1 ^= h2 >>> 1;
  43034. h1 = h1 * 0xed558ccd & MASK_HIGH | h1 * 0x8ccd & MASK_LOW;
  43035. h2 = h2 * 0xff51afd7 & MASK_HIGH | ((h2 << 16 | h1 >>> 16) * 0xafd7ed55 & MASK_HIGH) >>> 16;
  43036. h1 ^= h2 >>> 1;
  43037. h1 = h1 * 0x1a85ec53 & MASK_HIGH | h1 * 0xec53 & MASK_LOW;
  43038. h2 = h2 * 0xc4ceb9fe & MASK_HIGH | ((h2 << 16 | h1 >>> 16) * 0xb9fe1a85 & MASK_HIGH) >>> 16;
  43039. h1 ^= h2 >>> 1;
  43040. return (h1 >>> 0).toString(16).padStart(8, "0") + (h2 >>> 0).toString(16).padStart(8, "0");
  43041. }
  43042. }
  43043. exports.MurmurHash3_64 = MurmurHash3_64;
  43044. /***/ }),
  43045. /* 215 */
  43046. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  43047. Object.defineProperty(exports, "__esModule", ({
  43048. value: true
  43049. }));
  43050. exports.OperatorList = void 0;
  43051. __w_pdfjs_require__(2);
  43052. __w_pdfjs_require__(140);
  43053. __w_pdfjs_require__(84);
  43054. __w_pdfjs_require__(93);
  43055. __w_pdfjs_require__(94);
  43056. __w_pdfjs_require__(97);
  43057. __w_pdfjs_require__(99);
  43058. __w_pdfjs_require__(101);
  43059. __w_pdfjs_require__(105);
  43060. __w_pdfjs_require__(108);
  43061. __w_pdfjs_require__(115);
  43062. __w_pdfjs_require__(116);
  43063. __w_pdfjs_require__(127);
  43064. __w_pdfjs_require__(129);
  43065. __w_pdfjs_require__(132);
  43066. __w_pdfjs_require__(134);
  43067. __w_pdfjs_require__(136);
  43068. __w_pdfjs_require__(138);
  43069. var _util = __w_pdfjs_require__(145);
  43070. function addState(parentState, pattern, checkFn, iterateFn, processFn) {
  43071. let state = parentState;
  43072. for (let i = 0, ii = pattern.length - 1; i < ii; i++) {
  43073. const item = pattern[i];
  43074. state = state[item] ||= [];
  43075. }
  43076. state[pattern.at(-1)] = {
  43077. checkFn,
  43078. iterateFn,
  43079. processFn
  43080. };
  43081. }
  43082. const InitialState = [];
  43083. addState(InitialState, [_util.OPS.save, _util.OPS.transform, _util.OPS.paintInlineImageXObject, _util.OPS.restore], null, function iterateInlineImageGroup(context, i) {
  43084. const fnArray = context.fnArray;
  43085. const iFirstSave = context.iCurr - 3;
  43086. const pos = (i - iFirstSave) % 4;
  43087. switch (pos) {
  43088. case 0:
  43089. return fnArray[i] === _util.OPS.save;
  43090. case 1:
  43091. return fnArray[i] === _util.OPS.transform;
  43092. case 2:
  43093. return fnArray[i] === _util.OPS.paintInlineImageXObject;
  43094. case 3:
  43095. return fnArray[i] === _util.OPS.restore;
  43096. }
  43097. throw new Error(`iterateInlineImageGroup - invalid pos: ${pos}`);
  43098. }, function foundInlineImageGroup(context, i) {
  43099. const MIN_IMAGES_IN_INLINE_IMAGES_BLOCK = 10;
  43100. const MAX_IMAGES_IN_INLINE_IMAGES_BLOCK = 200;
  43101. const MAX_WIDTH = 1000;
  43102. const IMAGE_PADDING = 1;
  43103. const fnArray = context.fnArray,
  43104. argsArray = context.argsArray;
  43105. const curr = context.iCurr;
  43106. const iFirstSave = curr - 3;
  43107. const iFirstTransform = curr - 2;
  43108. const iFirstPIIXO = curr - 1;
  43109. const count = Math.min(Math.floor((i - iFirstSave) / 4), MAX_IMAGES_IN_INLINE_IMAGES_BLOCK);
  43110. if (count < MIN_IMAGES_IN_INLINE_IMAGES_BLOCK) {
  43111. return i - (i - iFirstSave) % 4;
  43112. }
  43113. let maxX = 0;
  43114. const map = [];
  43115. let maxLineHeight = 0;
  43116. let currentX = IMAGE_PADDING,
  43117. currentY = IMAGE_PADDING;
  43118. for (let q = 0; q < count; q++) {
  43119. const transform = argsArray[iFirstTransform + (q << 2)];
  43120. const img = argsArray[iFirstPIIXO + (q << 2)][0];
  43121. if (currentX + img.width > MAX_WIDTH) {
  43122. maxX = Math.max(maxX, currentX);
  43123. currentY += maxLineHeight + 2 * IMAGE_PADDING;
  43124. currentX = 0;
  43125. maxLineHeight = 0;
  43126. }
  43127. map.push({
  43128. transform,
  43129. x: currentX,
  43130. y: currentY,
  43131. w: img.width,
  43132. h: img.height
  43133. });
  43134. currentX += img.width + 2 * IMAGE_PADDING;
  43135. maxLineHeight = Math.max(maxLineHeight, img.height);
  43136. }
  43137. const imgWidth = Math.max(maxX, currentX) + IMAGE_PADDING;
  43138. const imgHeight = currentY + maxLineHeight + IMAGE_PADDING;
  43139. const imgData = new Uint8Array(imgWidth * imgHeight * 4);
  43140. const imgRowSize = imgWidth << 2;
  43141. for (let q = 0; q < count; q++) {
  43142. const data = argsArray[iFirstPIIXO + (q << 2)][0].data;
  43143. const rowSize = map[q].w << 2;
  43144. let dataOffset = 0;
  43145. let offset = map[q].x + map[q].y * imgWidth << 2;
  43146. imgData.set(data.subarray(0, rowSize), offset - imgRowSize);
  43147. for (let k = 0, kk = map[q].h; k < kk; k++) {
  43148. imgData.set(data.subarray(dataOffset, dataOffset + rowSize), offset);
  43149. dataOffset += rowSize;
  43150. offset += imgRowSize;
  43151. }
  43152. imgData.set(data.subarray(dataOffset - rowSize, dataOffset), offset);
  43153. while (offset >= 0) {
  43154. data[offset - 4] = data[offset];
  43155. data[offset - 3] = data[offset + 1];
  43156. data[offset - 2] = data[offset + 2];
  43157. data[offset - 1] = data[offset + 3];
  43158. data[offset + rowSize] = data[offset + rowSize - 4];
  43159. data[offset + rowSize + 1] = data[offset + rowSize - 3];
  43160. data[offset + rowSize + 2] = data[offset + rowSize - 2];
  43161. data[offset + rowSize + 3] = data[offset + rowSize - 1];
  43162. offset -= imgRowSize;
  43163. }
  43164. }
  43165. const img = {
  43166. width: imgWidth,
  43167. height: imgHeight
  43168. };
  43169. if (context.isOffscreenCanvasSupported) {
  43170. const canvas = new OffscreenCanvas(imgWidth, imgHeight);
  43171. const ctx = canvas.getContext("2d");
  43172. ctx.putImageData(new ImageData(new Uint8ClampedArray(imgData.buffer), imgWidth, imgHeight), 0, 0);
  43173. img.bitmap = canvas.transferToImageBitmap();
  43174. img.data = null;
  43175. } else {
  43176. img.kind = _util.ImageKind.RGBA_32BPP;
  43177. img.data = imgData;
  43178. }
  43179. fnArray.splice(iFirstSave, count * 4, _util.OPS.paintInlineImageXObjectGroup);
  43180. argsArray.splice(iFirstSave, count * 4, [img, map]);
  43181. return iFirstSave + 1;
  43182. });
  43183. addState(InitialState, [_util.OPS.save, _util.OPS.transform, _util.OPS.paintImageMaskXObject, _util.OPS.restore], null, function iterateImageMaskGroup(context, i) {
  43184. const fnArray = context.fnArray;
  43185. const iFirstSave = context.iCurr - 3;
  43186. const pos = (i - iFirstSave) % 4;
  43187. switch (pos) {
  43188. case 0:
  43189. return fnArray[i] === _util.OPS.save;
  43190. case 1:
  43191. return fnArray[i] === _util.OPS.transform;
  43192. case 2:
  43193. return fnArray[i] === _util.OPS.paintImageMaskXObject;
  43194. case 3:
  43195. return fnArray[i] === _util.OPS.restore;
  43196. }
  43197. throw new Error(`iterateImageMaskGroup - invalid pos: ${pos}`);
  43198. }, function foundImageMaskGroup(context, i) {
  43199. const MIN_IMAGES_IN_MASKS_BLOCK = 10;
  43200. const MAX_IMAGES_IN_MASKS_BLOCK = 100;
  43201. const MAX_SAME_IMAGES_IN_MASKS_BLOCK = 1000;
  43202. const fnArray = context.fnArray,
  43203. argsArray = context.argsArray;
  43204. const curr = context.iCurr;
  43205. const iFirstSave = curr - 3;
  43206. const iFirstTransform = curr - 2;
  43207. const iFirstPIMXO = curr - 1;
  43208. let count = Math.floor((i - iFirstSave) / 4);
  43209. if (count < MIN_IMAGES_IN_MASKS_BLOCK) {
  43210. return i - (i - iFirstSave) % 4;
  43211. }
  43212. let isSameImage = false;
  43213. let iTransform, transformArgs;
  43214. const firstPIMXOArg0 = argsArray[iFirstPIMXO][0];
  43215. const firstTransformArg0 = argsArray[iFirstTransform][0],
  43216. firstTransformArg1 = argsArray[iFirstTransform][1],
  43217. firstTransformArg2 = argsArray[iFirstTransform][2],
  43218. firstTransformArg3 = argsArray[iFirstTransform][3];
  43219. if (firstTransformArg1 === firstTransformArg2) {
  43220. isSameImage = true;
  43221. iTransform = iFirstTransform + 4;
  43222. let iPIMXO = iFirstPIMXO + 4;
  43223. for (let q = 1; q < count; q++, iTransform += 4, iPIMXO += 4) {
  43224. transformArgs = argsArray[iTransform];
  43225. if (argsArray[iPIMXO][0] !== firstPIMXOArg0 || transformArgs[0] !== firstTransformArg0 || transformArgs[1] !== firstTransformArg1 || transformArgs[2] !== firstTransformArg2 || transformArgs[3] !== firstTransformArg3) {
  43226. if (q < MIN_IMAGES_IN_MASKS_BLOCK) {
  43227. isSameImage = false;
  43228. } else {
  43229. count = q;
  43230. }
  43231. break;
  43232. }
  43233. }
  43234. }
  43235. if (isSameImage) {
  43236. count = Math.min(count, MAX_SAME_IMAGES_IN_MASKS_BLOCK);
  43237. const positions = new Float32Array(count * 2);
  43238. iTransform = iFirstTransform;
  43239. for (let q = 0; q < count; q++, iTransform += 4) {
  43240. transformArgs = argsArray[iTransform];
  43241. positions[q << 1] = transformArgs[4];
  43242. positions[(q << 1) + 1] = transformArgs[5];
  43243. }
  43244. fnArray.splice(iFirstSave, count * 4, _util.OPS.paintImageMaskXObjectRepeat);
  43245. argsArray.splice(iFirstSave, count * 4, [firstPIMXOArg0, firstTransformArg0, firstTransformArg1, firstTransformArg2, firstTransformArg3, positions]);
  43246. } else {
  43247. count = Math.min(count, MAX_IMAGES_IN_MASKS_BLOCK);
  43248. const images = [];
  43249. for (let q = 0; q < count; q++) {
  43250. transformArgs = argsArray[iFirstTransform + (q << 2)];
  43251. const maskParams = argsArray[iFirstPIMXO + (q << 2)][0];
  43252. images.push({
  43253. data: maskParams.data,
  43254. width: maskParams.width,
  43255. height: maskParams.height,
  43256. interpolate: maskParams.interpolate,
  43257. count: maskParams.count,
  43258. transform: transformArgs
  43259. });
  43260. }
  43261. fnArray.splice(iFirstSave, count * 4, _util.OPS.paintImageMaskXObjectGroup);
  43262. argsArray.splice(iFirstSave, count * 4, [images]);
  43263. }
  43264. return iFirstSave + 1;
  43265. });
  43266. addState(InitialState, [_util.OPS.save, _util.OPS.transform, _util.OPS.paintImageXObject, _util.OPS.restore], function (context) {
  43267. const argsArray = context.argsArray;
  43268. const iFirstTransform = context.iCurr - 2;
  43269. return argsArray[iFirstTransform][1] === 0 && argsArray[iFirstTransform][2] === 0;
  43270. }, function iterateImageGroup(context, i) {
  43271. const fnArray = context.fnArray,
  43272. argsArray = context.argsArray;
  43273. const iFirstSave = context.iCurr - 3;
  43274. const pos = (i - iFirstSave) % 4;
  43275. switch (pos) {
  43276. case 0:
  43277. return fnArray[i] === _util.OPS.save;
  43278. case 1:
  43279. if (fnArray[i] !== _util.OPS.transform) {
  43280. return false;
  43281. }
  43282. const iFirstTransform = context.iCurr - 2;
  43283. const firstTransformArg0 = argsArray[iFirstTransform][0];
  43284. const firstTransformArg3 = argsArray[iFirstTransform][3];
  43285. if (argsArray[i][0] !== firstTransformArg0 || argsArray[i][1] !== 0 || argsArray[i][2] !== 0 || argsArray[i][3] !== firstTransformArg3) {
  43286. return false;
  43287. }
  43288. return true;
  43289. case 2:
  43290. if (fnArray[i] !== _util.OPS.paintImageXObject) {
  43291. return false;
  43292. }
  43293. const iFirstPIXO = context.iCurr - 1;
  43294. const firstPIXOArg0 = argsArray[iFirstPIXO][0];
  43295. if (argsArray[i][0] !== firstPIXOArg0) {
  43296. return false;
  43297. }
  43298. return true;
  43299. case 3:
  43300. return fnArray[i] === _util.OPS.restore;
  43301. }
  43302. throw new Error(`iterateImageGroup - invalid pos: ${pos}`);
  43303. }, function (context, i) {
  43304. const MIN_IMAGES_IN_BLOCK = 3;
  43305. const MAX_IMAGES_IN_BLOCK = 1000;
  43306. const fnArray = context.fnArray,
  43307. argsArray = context.argsArray;
  43308. const curr = context.iCurr;
  43309. const iFirstSave = curr - 3;
  43310. const iFirstTransform = curr - 2;
  43311. const iFirstPIXO = curr - 1;
  43312. const firstPIXOArg0 = argsArray[iFirstPIXO][0];
  43313. const firstTransformArg0 = argsArray[iFirstTransform][0];
  43314. const firstTransformArg3 = argsArray[iFirstTransform][3];
  43315. const count = Math.min(Math.floor((i - iFirstSave) / 4), MAX_IMAGES_IN_BLOCK);
  43316. if (count < MIN_IMAGES_IN_BLOCK) {
  43317. return i - (i - iFirstSave) % 4;
  43318. }
  43319. const positions = new Float32Array(count * 2);
  43320. let iTransform = iFirstTransform;
  43321. for (let q = 0; q < count; q++, iTransform += 4) {
  43322. const transformArgs = argsArray[iTransform];
  43323. positions[q << 1] = transformArgs[4];
  43324. positions[(q << 1) + 1] = transformArgs[5];
  43325. }
  43326. const args = [firstPIXOArg0, firstTransformArg0, firstTransformArg3, positions];
  43327. fnArray.splice(iFirstSave, count * 4, _util.OPS.paintImageXObjectRepeat);
  43328. argsArray.splice(iFirstSave, count * 4, args);
  43329. return iFirstSave + 1;
  43330. });
  43331. addState(InitialState, [_util.OPS.beginText, _util.OPS.setFont, _util.OPS.setTextMatrix, _util.OPS.showText, _util.OPS.endText], null, function iterateShowTextGroup(context, i) {
  43332. const fnArray = context.fnArray,
  43333. argsArray = context.argsArray;
  43334. const iFirstSave = context.iCurr - 4;
  43335. const pos = (i - iFirstSave) % 5;
  43336. switch (pos) {
  43337. case 0:
  43338. return fnArray[i] === _util.OPS.beginText;
  43339. case 1:
  43340. return fnArray[i] === _util.OPS.setFont;
  43341. case 2:
  43342. return fnArray[i] === _util.OPS.setTextMatrix;
  43343. case 3:
  43344. if (fnArray[i] !== _util.OPS.showText) {
  43345. return false;
  43346. }
  43347. const iFirstSetFont = context.iCurr - 3;
  43348. const firstSetFontArg0 = argsArray[iFirstSetFont][0];
  43349. const firstSetFontArg1 = argsArray[iFirstSetFont][1];
  43350. if (argsArray[i][0] !== firstSetFontArg0 || argsArray[i][1] !== firstSetFontArg1) {
  43351. return false;
  43352. }
  43353. return true;
  43354. case 4:
  43355. return fnArray[i] === _util.OPS.endText;
  43356. }
  43357. throw new Error(`iterateShowTextGroup - invalid pos: ${pos}`);
  43358. }, function (context, i) {
  43359. const MIN_CHARS_IN_BLOCK = 3;
  43360. const MAX_CHARS_IN_BLOCK = 1000;
  43361. const fnArray = context.fnArray,
  43362. argsArray = context.argsArray;
  43363. const curr = context.iCurr;
  43364. const iFirstBeginText = curr - 4;
  43365. const iFirstSetFont = curr - 3;
  43366. const iFirstSetTextMatrix = curr - 2;
  43367. const iFirstShowText = curr - 1;
  43368. const iFirstEndText = curr;
  43369. const firstSetFontArg0 = argsArray[iFirstSetFont][0];
  43370. const firstSetFontArg1 = argsArray[iFirstSetFont][1];
  43371. let count = Math.min(Math.floor((i - iFirstBeginText) / 5), MAX_CHARS_IN_BLOCK);
  43372. if (count < MIN_CHARS_IN_BLOCK) {
  43373. return i - (i - iFirstBeginText) % 5;
  43374. }
  43375. let iFirst = iFirstBeginText;
  43376. 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) {
  43377. count++;
  43378. iFirst -= 5;
  43379. }
  43380. let iEndText = iFirst + 4;
  43381. for (let q = 1; q < count; q++) {
  43382. fnArray.splice(iEndText, 3);
  43383. argsArray.splice(iEndText, 3);
  43384. iEndText += 2;
  43385. }
  43386. return iEndText + 1;
  43387. });
  43388. class NullOptimizer {
  43389. constructor(queue) {
  43390. this.queue = queue;
  43391. }
  43392. _optimize() {}
  43393. push(fn, args) {
  43394. this.queue.fnArray.push(fn);
  43395. this.queue.argsArray.push(args);
  43396. this._optimize();
  43397. }
  43398. flush() {}
  43399. reset() {}
  43400. }
  43401. class QueueOptimizer extends NullOptimizer {
  43402. constructor(queue) {
  43403. super(queue);
  43404. this.state = null;
  43405. this.context = {
  43406. iCurr: 0,
  43407. fnArray: queue.fnArray,
  43408. argsArray: queue.argsArray,
  43409. isOffscreenCanvasSupported: false
  43410. };
  43411. this.match = null;
  43412. this.lastProcessed = 0;
  43413. }
  43414. set isOffscreenCanvasSupported(value) {
  43415. this.context.isOffscreenCanvasSupported = value;
  43416. }
  43417. _optimize() {
  43418. const fnArray = this.queue.fnArray;
  43419. let i = this.lastProcessed,
  43420. ii = fnArray.length;
  43421. let state = this.state;
  43422. let match = this.match;
  43423. if (!state && !match && i + 1 === ii && !InitialState[fnArray[i]]) {
  43424. this.lastProcessed = ii;
  43425. return;
  43426. }
  43427. const context = this.context;
  43428. while (i < ii) {
  43429. if (match) {
  43430. const iterate = (0, match.iterateFn)(context, i);
  43431. if (iterate) {
  43432. i++;
  43433. continue;
  43434. }
  43435. i = (0, match.processFn)(context, i + 1);
  43436. ii = fnArray.length;
  43437. match = null;
  43438. state = null;
  43439. if (i >= ii) {
  43440. break;
  43441. }
  43442. }
  43443. state = (state || InitialState)[fnArray[i]];
  43444. if (!state || Array.isArray(state)) {
  43445. i++;
  43446. continue;
  43447. }
  43448. context.iCurr = i;
  43449. i++;
  43450. if (state.checkFn && !(0, state.checkFn)(context)) {
  43451. state = null;
  43452. continue;
  43453. }
  43454. match = state;
  43455. state = null;
  43456. }
  43457. this.state = state;
  43458. this.match = match;
  43459. this.lastProcessed = i;
  43460. }
  43461. flush() {
  43462. while (this.match) {
  43463. const length = this.queue.fnArray.length;
  43464. this.lastProcessed = (0, this.match.processFn)(this.context, length);
  43465. this.match = null;
  43466. this.state = null;
  43467. this._optimize();
  43468. }
  43469. }
  43470. reset() {
  43471. this.state = null;
  43472. this.match = null;
  43473. this.lastProcessed = 0;
  43474. }
  43475. }
  43476. class OperatorList {
  43477. static CHUNK_SIZE = 1000;
  43478. static CHUNK_SIZE_ABOUT = this.CHUNK_SIZE - 5;
  43479. constructor() {
  43480. let intent = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
  43481. let streamSink = arguments.length > 1 ? arguments[1] : undefined;
  43482. this._streamSink = streamSink;
  43483. this.fnArray = [];
  43484. this.argsArray = [];
  43485. this.optimizer = streamSink && !(intent & _util.RenderingIntentFlag.OPLIST) ? new QueueOptimizer(this) : new NullOptimizer(this);
  43486. this.dependencies = new Set();
  43487. this._totalLength = 0;
  43488. this.weight = 0;
  43489. this._resolved = streamSink ? null : Promise.resolve();
  43490. }
  43491. set isOffscreenCanvasSupported(value) {
  43492. this.optimizer.isOffscreenCanvasSupported = value;
  43493. }
  43494. get length() {
  43495. return this.argsArray.length;
  43496. }
  43497. get ready() {
  43498. return this._resolved || this._streamSink.ready;
  43499. }
  43500. get totalLength() {
  43501. return this._totalLength + this.length;
  43502. }
  43503. addOp(fn, args) {
  43504. this.optimizer.push(fn, args);
  43505. this.weight++;
  43506. if (this._streamSink) {
  43507. if (this.weight >= OperatorList.CHUNK_SIZE) {
  43508. this.flush();
  43509. } else if (this.weight >= OperatorList.CHUNK_SIZE_ABOUT && (fn === _util.OPS.restore || fn === _util.OPS.endText)) {
  43510. this.flush();
  43511. }
  43512. }
  43513. }
  43514. addImageOps(fn, args, optionalContent) {
  43515. if (optionalContent !== undefined) {
  43516. this.addOp(_util.OPS.beginMarkedContentProps, ["OC", optionalContent]);
  43517. }
  43518. this.addOp(fn, args);
  43519. if (optionalContent !== undefined) {
  43520. this.addOp(_util.OPS.endMarkedContent, []);
  43521. }
  43522. }
  43523. addDependency(dependency) {
  43524. if (this.dependencies.has(dependency)) {
  43525. return;
  43526. }
  43527. this.dependencies.add(dependency);
  43528. this.addOp(_util.OPS.dependency, [dependency]);
  43529. }
  43530. addDependencies(dependencies) {
  43531. for (const dependency of dependencies) {
  43532. this.addDependency(dependency);
  43533. }
  43534. }
  43535. addOpList(opList) {
  43536. if (!(opList instanceof OperatorList)) {
  43537. (0, _util.warn)('addOpList - ignoring invalid "opList" parameter.');
  43538. return;
  43539. }
  43540. for (const dependency of opList.dependencies) {
  43541. this.dependencies.add(dependency);
  43542. }
  43543. for (let i = 0, ii = opList.length; i < ii; i++) {
  43544. this.addOp(opList.fnArray[i], opList.argsArray[i]);
  43545. }
  43546. }
  43547. getIR() {
  43548. return {
  43549. fnArray: this.fnArray,
  43550. argsArray: this.argsArray,
  43551. length: this.length
  43552. };
  43553. }
  43554. get _transfers() {
  43555. const transfers = [];
  43556. const {
  43557. fnArray,
  43558. argsArray,
  43559. length
  43560. } = this;
  43561. for (let i = 0; i < length; i++) {
  43562. switch (fnArray[i]) {
  43563. case _util.OPS.paintInlineImageXObject:
  43564. case _util.OPS.paintInlineImageXObjectGroup:
  43565. case _util.OPS.paintImageMaskXObject:
  43566. const arg = argsArray[i][0];
  43567. if (!arg.cached && arg.data?.buffer instanceof ArrayBuffer) {
  43568. transfers.push(arg.data.buffer);
  43569. }
  43570. break;
  43571. }
  43572. }
  43573. return transfers;
  43574. }
  43575. flush() {
  43576. let lastChunk = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  43577. let separateAnnots = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  43578. this.optimizer.flush();
  43579. const length = this.length;
  43580. this._totalLength += length;
  43581. this._streamSink.enqueue({
  43582. fnArray: this.fnArray,
  43583. argsArray: this.argsArray,
  43584. lastChunk,
  43585. separateAnnots,
  43586. length
  43587. }, 1, this._transfers);
  43588. this.dependencies.clear();
  43589. this.fnArray.length = 0;
  43590. this.argsArray.length = 0;
  43591. this.weight = 0;
  43592. this.optimizer.reset();
  43593. }
  43594. }
  43595. exports.OperatorList = OperatorList;
  43596. /***/ }),
  43597. /* 216 */
  43598. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  43599. Object.defineProperty(exports, "__esModule", ({
  43600. value: true
  43601. }));
  43602. exports.PDFImage = void 0;
  43603. __w_pdfjs_require__(84);
  43604. __w_pdfjs_require__(93);
  43605. __w_pdfjs_require__(94);
  43606. __w_pdfjs_require__(97);
  43607. __w_pdfjs_require__(99);
  43608. __w_pdfjs_require__(101);
  43609. __w_pdfjs_require__(105);
  43610. __w_pdfjs_require__(108);
  43611. __w_pdfjs_require__(115);
  43612. __w_pdfjs_require__(2);
  43613. var _util = __w_pdfjs_require__(145);
  43614. var _image_utils = __w_pdfjs_require__(179);
  43615. var _base_stream = __w_pdfjs_require__(152);
  43616. var _colorspace = __w_pdfjs_require__(163);
  43617. var _decode_stream = __w_pdfjs_require__(169);
  43618. var _image_resizer = __w_pdfjs_require__(213);
  43619. var _jpeg_stream = __w_pdfjs_require__(177);
  43620. var _jpx = __w_pdfjs_require__(181);
  43621. var _primitives = __w_pdfjs_require__(151);
  43622. function decodeAndClamp(value, addend, coefficient, max) {
  43623. value = addend + value * coefficient;
  43624. if (value < 0) {
  43625. value = 0;
  43626. } else if (value > max) {
  43627. value = max;
  43628. }
  43629. return value;
  43630. }
  43631. function resizeImageMask(src, bpc, w1, h1, w2, h2) {
  43632. const length = w2 * h2;
  43633. let dest;
  43634. if (bpc <= 8) {
  43635. dest = new Uint8Array(length);
  43636. } else if (bpc <= 16) {
  43637. dest = new Uint16Array(length);
  43638. } else {
  43639. dest = new Uint32Array(length);
  43640. }
  43641. const xRatio = w1 / w2;
  43642. const yRatio = h1 / h2;
  43643. let i,
  43644. j,
  43645. py,
  43646. newIndex = 0,
  43647. oldIndex;
  43648. const xScaled = new Uint16Array(w2);
  43649. const w1Scanline = w1;
  43650. for (i = 0; i < w2; i++) {
  43651. xScaled[i] = Math.floor(i * xRatio);
  43652. }
  43653. for (i = 0; i < h2; i++) {
  43654. py = Math.floor(i * yRatio) * w1Scanline;
  43655. for (j = 0; j < w2; j++) {
  43656. oldIndex = py + xScaled[j];
  43657. dest[newIndex++] = src[oldIndex];
  43658. }
  43659. }
  43660. return dest;
  43661. }
  43662. class PDFImage {
  43663. constructor(_ref) {
  43664. let {
  43665. xref,
  43666. res,
  43667. image,
  43668. isInline = false,
  43669. smask = null,
  43670. mask = null,
  43671. isMask = false,
  43672. pdfFunctionFactory,
  43673. localColorSpaceCache
  43674. } = _ref;
  43675. this.image = image;
  43676. const dict = image.dict;
  43677. const filter = dict.get("F", "Filter");
  43678. let filterName;
  43679. if (filter instanceof _primitives.Name) {
  43680. filterName = filter.name;
  43681. } else if (Array.isArray(filter)) {
  43682. const filterZero = xref.fetchIfRef(filter[0]);
  43683. if (filterZero instanceof _primitives.Name) {
  43684. filterName = filterZero.name;
  43685. }
  43686. }
  43687. switch (filterName) {
  43688. case "JPXDecode":
  43689. const jpxImage = new _jpx.JpxImage();
  43690. jpxImage.parseImageProperties(image.stream);
  43691. image.stream.reset();
  43692. image.width = jpxImage.width;
  43693. image.height = jpxImage.height;
  43694. image.bitsPerComponent = jpxImage.bitsPerComponent;
  43695. image.numComps = jpxImage.componentsCount;
  43696. break;
  43697. case "JBIG2Decode":
  43698. image.bitsPerComponent = 1;
  43699. image.numComps = 1;
  43700. break;
  43701. }
  43702. let width = dict.get("W", "Width");
  43703. let height = dict.get("H", "Height");
  43704. if (Number.isInteger(image.width) && image.width > 0 && Number.isInteger(image.height) && image.height > 0 && (image.width !== width || image.height !== height)) {
  43705. (0, _util.warn)("PDFImage - using the Width/Height of the image data, " + "rather than the image dictionary.");
  43706. width = image.width;
  43707. height = image.height;
  43708. }
  43709. if (width < 1 || height < 1) {
  43710. throw new _util.FormatError(`Invalid image width: ${width} or height: ${height}`);
  43711. }
  43712. this.width = width;
  43713. this.height = height;
  43714. this.interpolate = dict.get("I", "Interpolate");
  43715. this.imageMask = dict.get("IM", "ImageMask") || false;
  43716. this.matte = dict.get("Matte") || false;
  43717. let bitsPerComponent = image.bitsPerComponent;
  43718. if (!bitsPerComponent) {
  43719. bitsPerComponent = dict.get("BPC", "BitsPerComponent");
  43720. if (!bitsPerComponent) {
  43721. if (this.imageMask) {
  43722. bitsPerComponent = 1;
  43723. } else {
  43724. throw new _util.FormatError(`Bits per component missing in image: ${this.imageMask}`);
  43725. }
  43726. }
  43727. }
  43728. this.bpc = bitsPerComponent;
  43729. if (!this.imageMask) {
  43730. let colorSpace = dict.getRaw("CS") || dict.getRaw("ColorSpace");
  43731. if (!colorSpace) {
  43732. (0, _util.info)("JPX images (which do not require color spaces)");
  43733. switch (image.numComps) {
  43734. case 1:
  43735. colorSpace = _primitives.Name.get("DeviceGray");
  43736. break;
  43737. case 3:
  43738. colorSpace = _primitives.Name.get("DeviceRGB");
  43739. break;
  43740. case 4:
  43741. colorSpace = _primitives.Name.get("DeviceCMYK");
  43742. break;
  43743. default:
  43744. throw new Error(`JPX images with ${image.numComps} color components not supported.`);
  43745. }
  43746. }
  43747. this.colorSpace = _colorspace.ColorSpace.parse({
  43748. cs: colorSpace,
  43749. xref,
  43750. resources: isInline ? res : null,
  43751. pdfFunctionFactory,
  43752. localColorSpaceCache
  43753. });
  43754. this.numComps = this.colorSpace.numComps;
  43755. }
  43756. this.decode = dict.getArray("D", "Decode");
  43757. this.needsDecode = false;
  43758. if (this.decode && (this.colorSpace && !this.colorSpace.isDefaultDecode(this.decode, bitsPerComponent) || isMask && !_colorspace.ColorSpace.isDefaultDecode(this.decode, 1))) {
  43759. this.needsDecode = true;
  43760. const max = (1 << bitsPerComponent) - 1;
  43761. this.decodeCoefficients = [];
  43762. this.decodeAddends = [];
  43763. const isIndexed = this.colorSpace?.name === "Indexed";
  43764. for (let i = 0, j = 0; i < this.decode.length; i += 2, ++j) {
  43765. const dmin = this.decode[i];
  43766. const dmax = this.decode[i + 1];
  43767. this.decodeCoefficients[j] = isIndexed ? (dmax - dmin) / max : dmax - dmin;
  43768. this.decodeAddends[j] = isIndexed ? dmin : max * dmin;
  43769. }
  43770. }
  43771. if (smask) {
  43772. this.smask = new PDFImage({
  43773. xref,
  43774. res,
  43775. image: smask,
  43776. isInline,
  43777. pdfFunctionFactory,
  43778. localColorSpaceCache
  43779. });
  43780. } else if (mask) {
  43781. if (mask instanceof _base_stream.BaseStream) {
  43782. const maskDict = mask.dict,
  43783. imageMask = maskDict.get("IM", "ImageMask");
  43784. if (!imageMask) {
  43785. (0, _util.warn)("Ignoring /Mask in image without /ImageMask.");
  43786. } else {
  43787. this.mask = new PDFImage({
  43788. xref,
  43789. res,
  43790. image: mask,
  43791. isInline,
  43792. isMask: true,
  43793. pdfFunctionFactory,
  43794. localColorSpaceCache
  43795. });
  43796. }
  43797. } else {
  43798. this.mask = mask;
  43799. }
  43800. }
  43801. }
  43802. static async buildImage(_ref2) {
  43803. let {
  43804. xref,
  43805. res,
  43806. image,
  43807. isInline = false,
  43808. pdfFunctionFactory,
  43809. localColorSpaceCache
  43810. } = _ref2;
  43811. const imageData = image;
  43812. let smaskData = null;
  43813. let maskData = null;
  43814. const smask = image.dict.get("SMask");
  43815. const mask = image.dict.get("Mask");
  43816. if (smask) {
  43817. if (smask instanceof _base_stream.BaseStream) {
  43818. smaskData = smask;
  43819. } else {
  43820. (0, _util.warn)("Unsupported /SMask format.");
  43821. }
  43822. } else if (mask) {
  43823. if (mask instanceof _base_stream.BaseStream || Array.isArray(mask)) {
  43824. maskData = mask;
  43825. } else {
  43826. (0, _util.warn)("Unsupported /Mask format.");
  43827. }
  43828. }
  43829. return new PDFImage({
  43830. xref,
  43831. res,
  43832. image: imageData,
  43833. isInline,
  43834. smask: smaskData,
  43835. mask: maskData,
  43836. pdfFunctionFactory,
  43837. localColorSpaceCache
  43838. });
  43839. }
  43840. static createRawMask(_ref3) {
  43841. let {
  43842. imgArray,
  43843. width,
  43844. height,
  43845. imageIsFromDecodeStream,
  43846. inverseDecode,
  43847. interpolate
  43848. } = _ref3;
  43849. const computedLength = (width + 7 >> 3) * height;
  43850. const actualLength = imgArray.byteLength;
  43851. const haveFullData = computedLength === actualLength;
  43852. let data, i;
  43853. if (imageIsFromDecodeStream && (!inverseDecode || haveFullData)) {
  43854. data = imgArray;
  43855. } else if (!inverseDecode) {
  43856. data = new Uint8Array(imgArray);
  43857. } else {
  43858. data = new Uint8Array(computedLength);
  43859. data.set(imgArray);
  43860. data.fill(0xff, actualLength);
  43861. }
  43862. if (inverseDecode) {
  43863. for (i = 0; i < actualLength; i++) {
  43864. data[i] ^= 0xff;
  43865. }
  43866. }
  43867. return {
  43868. data,
  43869. width,
  43870. height,
  43871. interpolate
  43872. };
  43873. }
  43874. static async createMask(_ref4) {
  43875. let {
  43876. imgArray,
  43877. width,
  43878. height,
  43879. imageIsFromDecodeStream,
  43880. inverseDecode,
  43881. interpolate,
  43882. isOffscreenCanvasSupported = false
  43883. } = _ref4;
  43884. const isSingleOpaquePixel = width === 1 && height === 1 && inverseDecode === (imgArray.length === 0 || !!(imgArray[0] & 128));
  43885. if (isSingleOpaquePixel) {
  43886. return {
  43887. isSingleOpaquePixel
  43888. };
  43889. }
  43890. if (isOffscreenCanvasSupported) {
  43891. if (_image_resizer.ImageResizer.needsToBeResized(width, height)) {
  43892. const data = new Uint8ClampedArray(width * height * 4);
  43893. (0, _image_utils.convertBlackAndWhiteToRGBA)({
  43894. src: imgArray,
  43895. dest: data,
  43896. width,
  43897. height,
  43898. nonBlackColor: 0,
  43899. inverseDecode
  43900. });
  43901. return _image_resizer.ImageResizer.createImage({
  43902. kind: _util.ImageKind.RGBA_32BPP,
  43903. data,
  43904. width,
  43905. height,
  43906. interpolate
  43907. });
  43908. }
  43909. const canvas = new OffscreenCanvas(width, height);
  43910. const ctx = canvas.getContext("2d");
  43911. const imgData = ctx.createImageData(width, height);
  43912. (0, _image_utils.convertBlackAndWhiteToRGBA)({
  43913. src: imgArray,
  43914. dest: imgData.data,
  43915. width,
  43916. height,
  43917. nonBlackColor: 0,
  43918. inverseDecode
  43919. });
  43920. ctx.putImageData(imgData, 0, 0);
  43921. const bitmap = canvas.transferToImageBitmap();
  43922. return {
  43923. data: null,
  43924. width,
  43925. height,
  43926. interpolate,
  43927. bitmap
  43928. };
  43929. }
  43930. return this.createRawMask({
  43931. imgArray,
  43932. width,
  43933. height,
  43934. inverseDecode,
  43935. imageIsFromDecodeStream,
  43936. interpolate
  43937. });
  43938. }
  43939. get drawWidth() {
  43940. return Math.max(this.width, this.smask?.width || 0, this.mask?.width || 0);
  43941. }
  43942. get drawHeight() {
  43943. return Math.max(this.height, this.smask?.height || 0, this.mask?.height || 0);
  43944. }
  43945. decodeBuffer(buffer) {
  43946. const bpc = this.bpc;
  43947. const numComps = this.numComps;
  43948. const decodeAddends = this.decodeAddends;
  43949. const decodeCoefficients = this.decodeCoefficients;
  43950. const max = (1 << bpc) - 1;
  43951. let i, ii;
  43952. if (bpc === 1) {
  43953. for (i = 0, ii = buffer.length; i < ii; i++) {
  43954. buffer[i] = +!buffer[i];
  43955. }
  43956. return;
  43957. }
  43958. let index = 0;
  43959. for (i = 0, ii = this.width * this.height; i < ii; i++) {
  43960. for (let j = 0; j < numComps; j++) {
  43961. buffer[index] = decodeAndClamp(buffer[index], decodeAddends[j], decodeCoefficients[j], max);
  43962. index++;
  43963. }
  43964. }
  43965. }
  43966. getComponents(buffer) {
  43967. const bpc = this.bpc;
  43968. if (bpc === 8) {
  43969. return buffer;
  43970. }
  43971. const width = this.width;
  43972. const height = this.height;
  43973. const numComps = this.numComps;
  43974. const length = width * height * numComps;
  43975. let bufferPos = 0;
  43976. let output;
  43977. if (bpc <= 8) {
  43978. output = new Uint8Array(length);
  43979. } else if (bpc <= 16) {
  43980. output = new Uint16Array(length);
  43981. } else {
  43982. output = new Uint32Array(length);
  43983. }
  43984. const rowComps = width * numComps;
  43985. const max = (1 << bpc) - 1;
  43986. let i = 0,
  43987. ii,
  43988. buf;
  43989. if (bpc === 1) {
  43990. let mask, loop1End, loop2End;
  43991. for (let j = 0; j < height; j++) {
  43992. loop1End = i + (rowComps & ~7);
  43993. loop2End = i + rowComps;
  43994. while (i < loop1End) {
  43995. buf = buffer[bufferPos++];
  43996. output[i] = buf >> 7 & 1;
  43997. output[i + 1] = buf >> 6 & 1;
  43998. output[i + 2] = buf >> 5 & 1;
  43999. output[i + 3] = buf >> 4 & 1;
  44000. output[i + 4] = buf >> 3 & 1;
  44001. output[i + 5] = buf >> 2 & 1;
  44002. output[i + 6] = buf >> 1 & 1;
  44003. output[i + 7] = buf & 1;
  44004. i += 8;
  44005. }
  44006. if (i < loop2End) {
  44007. buf = buffer[bufferPos++];
  44008. mask = 128;
  44009. while (i < loop2End) {
  44010. output[i++] = +!!(buf & mask);
  44011. mask >>= 1;
  44012. }
  44013. }
  44014. }
  44015. } else {
  44016. let bits = 0;
  44017. buf = 0;
  44018. for (i = 0, ii = length; i < ii; ++i) {
  44019. if (i % rowComps === 0) {
  44020. buf = 0;
  44021. bits = 0;
  44022. }
  44023. while (bits < bpc) {
  44024. buf = buf << 8 | buffer[bufferPos++];
  44025. bits += 8;
  44026. }
  44027. const remainingBits = bits - bpc;
  44028. let value = buf >> remainingBits;
  44029. if (value < 0) {
  44030. value = 0;
  44031. } else if (value > max) {
  44032. value = max;
  44033. }
  44034. output[i] = value;
  44035. buf &= (1 << remainingBits) - 1;
  44036. bits = remainingBits;
  44037. }
  44038. }
  44039. return output;
  44040. }
  44041. fillOpacity(rgbaBuf, width, height, actualHeight, image) {
  44042. const smask = this.smask;
  44043. const mask = this.mask;
  44044. let alphaBuf, sw, sh, i, ii, j;
  44045. if (smask) {
  44046. sw = smask.width;
  44047. sh = smask.height;
  44048. alphaBuf = new Uint8ClampedArray(sw * sh);
  44049. smask.fillGrayBuffer(alphaBuf);
  44050. if (sw !== width || sh !== height) {
  44051. alphaBuf = resizeImageMask(alphaBuf, smask.bpc, sw, sh, width, height);
  44052. }
  44053. } else if (mask) {
  44054. if (mask instanceof PDFImage) {
  44055. sw = mask.width;
  44056. sh = mask.height;
  44057. alphaBuf = new Uint8ClampedArray(sw * sh);
  44058. mask.numComps = 1;
  44059. mask.fillGrayBuffer(alphaBuf);
  44060. for (i = 0, ii = sw * sh; i < ii; ++i) {
  44061. alphaBuf[i] = 255 - alphaBuf[i];
  44062. }
  44063. if (sw !== width || sh !== height) {
  44064. alphaBuf = resizeImageMask(alphaBuf, mask.bpc, sw, sh, width, height);
  44065. }
  44066. } else if (Array.isArray(mask)) {
  44067. alphaBuf = new Uint8ClampedArray(width * height);
  44068. const numComps = this.numComps;
  44069. for (i = 0, ii = width * height; i < ii; ++i) {
  44070. let opacity = 0;
  44071. const imageOffset = i * numComps;
  44072. for (j = 0; j < numComps; ++j) {
  44073. const color = image[imageOffset + j];
  44074. const maskOffset = j * 2;
  44075. if (color < mask[maskOffset] || color > mask[maskOffset + 1]) {
  44076. opacity = 255;
  44077. break;
  44078. }
  44079. }
  44080. alphaBuf[i] = opacity;
  44081. }
  44082. } else {
  44083. throw new _util.FormatError("Unknown mask format.");
  44084. }
  44085. }
  44086. if (alphaBuf) {
  44087. for (i = 0, j = 3, ii = width * actualHeight; i < ii; ++i, j += 4) {
  44088. rgbaBuf[j] = alphaBuf[i];
  44089. }
  44090. } else {
  44091. for (i = 0, j = 3, ii = width * actualHeight; i < ii; ++i, j += 4) {
  44092. rgbaBuf[j] = 255;
  44093. }
  44094. }
  44095. }
  44096. undoPreblend(buffer, width, height) {
  44097. const matte = this.smask?.matte;
  44098. if (!matte) {
  44099. return;
  44100. }
  44101. const matteRgb = this.colorSpace.getRgb(matte, 0);
  44102. const matteR = matteRgb[0];
  44103. const matteG = matteRgb[1];
  44104. const matteB = matteRgb[2];
  44105. const length = width * height * 4;
  44106. for (let i = 0; i < length; i += 4) {
  44107. const alpha = buffer[i + 3];
  44108. if (alpha === 0) {
  44109. buffer[i] = 255;
  44110. buffer[i + 1] = 255;
  44111. buffer[i + 2] = 255;
  44112. continue;
  44113. }
  44114. const k = 255 / alpha;
  44115. buffer[i] = (buffer[i] - matteR) * k + matteR;
  44116. buffer[i + 1] = (buffer[i + 1] - matteG) * k + matteG;
  44117. buffer[i + 2] = (buffer[i + 2] - matteB) * k + matteB;
  44118. }
  44119. }
  44120. async createImageData() {
  44121. let forceRGBA = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  44122. let isOffscreenCanvasSupported = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  44123. const drawWidth = this.drawWidth;
  44124. const drawHeight = this.drawHeight;
  44125. const imgData = {
  44126. width: drawWidth,
  44127. height: drawHeight,
  44128. interpolate: this.interpolate,
  44129. kind: 0,
  44130. data: null
  44131. };
  44132. const numComps = this.numComps;
  44133. const originalWidth = this.width;
  44134. const originalHeight = this.height;
  44135. const bpc = this.bpc;
  44136. const rowBytes = originalWidth * numComps * bpc + 7 >> 3;
  44137. const mustBeResized = isOffscreenCanvasSupported && _image_resizer.ImageResizer.needsToBeResized(drawWidth, drawHeight);
  44138. if (!forceRGBA) {
  44139. let kind;
  44140. if (this.colorSpace.name === "DeviceGray" && bpc === 1) {
  44141. kind = _util.ImageKind.GRAYSCALE_1BPP;
  44142. } else if (this.colorSpace.name === "DeviceRGB" && bpc === 8 && !this.needsDecode) {
  44143. kind = _util.ImageKind.RGB_24BPP;
  44144. }
  44145. if (kind && !this.smask && !this.mask && drawWidth === originalWidth && drawHeight === originalHeight) {
  44146. const data = this.getImageBytes(originalHeight * rowBytes, {});
  44147. if (isOffscreenCanvasSupported) {
  44148. if (mustBeResized) {
  44149. return _image_resizer.ImageResizer.createImage({
  44150. data,
  44151. kind,
  44152. width: drawWidth,
  44153. height: drawHeight,
  44154. interpolate: this.interpolate
  44155. }, this.needsDecode);
  44156. }
  44157. return this.createBitmap(kind, originalWidth, originalHeight, data);
  44158. }
  44159. imgData.kind = kind;
  44160. imgData.data = data;
  44161. if (this.needsDecode) {
  44162. (0, _util.assert)(kind === _util.ImageKind.GRAYSCALE_1BPP, "PDFImage.createImageData: The image must be grayscale.");
  44163. const buffer = imgData.data;
  44164. for (let i = 0, ii = buffer.length; i < ii; i++) {
  44165. buffer[i] ^= 0xff;
  44166. }
  44167. }
  44168. return imgData;
  44169. }
  44170. if (this.image instanceof _jpeg_stream.JpegStream && !this.smask && !this.mask && !this.needsDecode) {
  44171. let imageLength = originalHeight * rowBytes;
  44172. if (isOffscreenCanvasSupported && !mustBeResized) {
  44173. let isHandled = false;
  44174. switch (this.colorSpace.name) {
  44175. case "DeviceGray":
  44176. imageLength *= 4;
  44177. isHandled = true;
  44178. break;
  44179. case "DeviceRGB":
  44180. imageLength = imageLength / 3 * 4;
  44181. isHandled = true;
  44182. break;
  44183. case "DeviceCMYK":
  44184. isHandled = true;
  44185. break;
  44186. }
  44187. if (isHandled) {
  44188. const rgba = this.getImageBytes(imageLength, {
  44189. drawWidth,
  44190. drawHeight,
  44191. forceRGBA: true
  44192. });
  44193. return this.createBitmap(_util.ImageKind.RGBA_32BPP, drawWidth, drawHeight, rgba);
  44194. }
  44195. } else {
  44196. switch (this.colorSpace.name) {
  44197. case "DeviceGray":
  44198. imageLength *= 3;
  44199. case "DeviceRGB":
  44200. case "DeviceCMYK":
  44201. imgData.kind = _util.ImageKind.RGB_24BPP;
  44202. imgData.data = this.getImageBytes(imageLength, {
  44203. drawWidth,
  44204. drawHeight,
  44205. forceRGB: true
  44206. });
  44207. if (mustBeResized) {
  44208. return _image_resizer.ImageResizer.createImage(imgData);
  44209. }
  44210. return imgData;
  44211. }
  44212. }
  44213. }
  44214. }
  44215. const imgArray = this.getImageBytes(originalHeight * rowBytes, {
  44216. internal: true
  44217. });
  44218. const actualHeight = 0 | imgArray.length / rowBytes * drawHeight / originalHeight;
  44219. const comps = this.getComponents(imgArray);
  44220. let alpha01, maybeUndoPreblend;
  44221. let canvas, ctx, canvasImgData, data;
  44222. if (isOffscreenCanvasSupported && !mustBeResized) {
  44223. canvas = new OffscreenCanvas(drawWidth, drawHeight);
  44224. ctx = canvas.getContext("2d");
  44225. canvasImgData = ctx.createImageData(drawWidth, drawHeight);
  44226. data = canvasImgData.data;
  44227. }
  44228. imgData.kind = _util.ImageKind.RGBA_32BPP;
  44229. if (!forceRGBA && !this.smask && !this.mask) {
  44230. if (!isOffscreenCanvasSupported || mustBeResized) {
  44231. imgData.kind = _util.ImageKind.RGB_24BPP;
  44232. data = new Uint8ClampedArray(drawWidth * drawHeight * 3);
  44233. alpha01 = 0;
  44234. } else {
  44235. const arr = new Uint32Array(data.buffer);
  44236. arr.fill(_util.FeatureTest.isLittleEndian ? 0xff000000 : 0x000000ff);
  44237. alpha01 = 1;
  44238. }
  44239. maybeUndoPreblend = false;
  44240. } else {
  44241. if (!isOffscreenCanvasSupported || mustBeResized) {
  44242. data = new Uint8ClampedArray(drawWidth * drawHeight * 4);
  44243. }
  44244. alpha01 = 1;
  44245. maybeUndoPreblend = true;
  44246. this.fillOpacity(data, drawWidth, drawHeight, actualHeight, comps);
  44247. }
  44248. if (this.needsDecode) {
  44249. this.decodeBuffer(comps);
  44250. }
  44251. this.colorSpace.fillRgb(data, originalWidth, originalHeight, drawWidth, drawHeight, actualHeight, bpc, comps, alpha01);
  44252. if (maybeUndoPreblend) {
  44253. this.undoPreblend(data, drawWidth, actualHeight);
  44254. }
  44255. if (isOffscreenCanvasSupported && !mustBeResized) {
  44256. ctx.putImageData(canvasImgData, 0, 0);
  44257. const bitmap = canvas.transferToImageBitmap();
  44258. return {
  44259. data: null,
  44260. width: drawWidth,
  44261. height: drawHeight,
  44262. bitmap,
  44263. interpolate: this.interpolate
  44264. };
  44265. }
  44266. imgData.data = data;
  44267. if (mustBeResized) {
  44268. return _image_resizer.ImageResizer.createImage(imgData);
  44269. }
  44270. return imgData;
  44271. }
  44272. fillGrayBuffer(buffer) {
  44273. const numComps = this.numComps;
  44274. if (numComps !== 1) {
  44275. throw new _util.FormatError(`Reading gray scale from a color image: ${numComps}`);
  44276. }
  44277. const width = this.width;
  44278. const height = this.height;
  44279. const bpc = this.bpc;
  44280. const rowBytes = width * numComps * bpc + 7 >> 3;
  44281. const imgArray = this.getImageBytes(height * rowBytes, {
  44282. internal: true
  44283. });
  44284. const comps = this.getComponents(imgArray);
  44285. let i, length;
  44286. if (bpc === 1) {
  44287. length = width * height;
  44288. if (this.needsDecode) {
  44289. for (i = 0; i < length; ++i) {
  44290. buffer[i] = comps[i] - 1 & 255;
  44291. }
  44292. } else {
  44293. for (i = 0; i < length; ++i) {
  44294. buffer[i] = -comps[i] & 255;
  44295. }
  44296. }
  44297. return;
  44298. }
  44299. if (this.needsDecode) {
  44300. this.decodeBuffer(comps);
  44301. }
  44302. length = width * height;
  44303. const scale = 255 / ((1 << bpc) - 1);
  44304. for (i = 0; i < length; ++i) {
  44305. buffer[i] = scale * comps[i];
  44306. }
  44307. }
  44308. createBitmap(kind, width, height, src) {
  44309. const canvas = new OffscreenCanvas(width, height);
  44310. const ctx = canvas.getContext("2d");
  44311. let imgData;
  44312. if (kind === _util.ImageKind.RGBA_32BPP) {
  44313. imgData = new ImageData(src, width, height);
  44314. } else {
  44315. imgData = ctx.createImageData(width, height);
  44316. (0, _image_utils.convertToRGBA)({
  44317. kind,
  44318. src,
  44319. dest: new Uint32Array(imgData.data.buffer),
  44320. width,
  44321. height,
  44322. inverseDecode: this.needsDecode
  44323. });
  44324. }
  44325. ctx.putImageData(imgData, 0, 0);
  44326. const bitmap = canvas.transferToImageBitmap();
  44327. return {
  44328. data: null,
  44329. width,
  44330. height,
  44331. bitmap,
  44332. interpolate: this.interpolate
  44333. };
  44334. }
  44335. getImageBytes(length, _ref5) {
  44336. let {
  44337. drawWidth,
  44338. drawHeight,
  44339. forceRGBA = false,
  44340. forceRGB = false,
  44341. internal = false
  44342. } = _ref5;
  44343. this.image.reset();
  44344. this.image.drawWidth = drawWidth || this.width;
  44345. this.image.drawHeight = drawHeight || this.height;
  44346. this.image.forceRGBA = !!forceRGBA;
  44347. this.image.forceRGB = !!forceRGB;
  44348. const imageBytes = this.image.getBytes(length);
  44349. if (internal || this.image instanceof _decode_stream.DecodeStream) {
  44350. return imageBytes;
  44351. }
  44352. (0, _util.assert)(imageBytes instanceof Uint8Array, 'PDFImage.getImageBytes: Unsupported "imageBytes" type.');
  44353. return new Uint8Array(imageBytes);
  44354. }
  44355. }
  44356. exports.PDFImage = PDFImage;
  44357. /***/ }),
  44358. /* 217 */
  44359. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  44360. Object.defineProperty(exports, "__esModule", ({
  44361. value: true
  44362. }));
  44363. exports.incrementalUpdate = incrementalUpdate;
  44364. exports.writeDict = writeDict;
  44365. exports.writeObject = writeObject;
  44366. __w_pdfjs_require__(140);
  44367. __w_pdfjs_require__(84);
  44368. __w_pdfjs_require__(93);
  44369. __w_pdfjs_require__(94);
  44370. __w_pdfjs_require__(97);
  44371. __w_pdfjs_require__(99);
  44372. __w_pdfjs_require__(101);
  44373. __w_pdfjs_require__(105);
  44374. __w_pdfjs_require__(108);
  44375. __w_pdfjs_require__(115);
  44376. var _util = __w_pdfjs_require__(145);
  44377. var _primitives = __w_pdfjs_require__(151);
  44378. var _core_utils = __w_pdfjs_require__(150);
  44379. var _xml_parser = __w_pdfjs_require__(218);
  44380. var _base_stream = __w_pdfjs_require__(152);
  44381. var _crypto = __w_pdfjs_require__(219);
  44382. async function writeObject(ref, obj, buffer, transform) {
  44383. buffer.push(`${ref.num} ${ref.gen} obj\n`);
  44384. if (obj instanceof _primitives.Dict) {
  44385. await writeDict(obj, buffer, transform);
  44386. } else if (obj instanceof _base_stream.BaseStream) {
  44387. await writeStream(obj, buffer, transform);
  44388. }
  44389. buffer.push("\nendobj\n");
  44390. }
  44391. async function writeDict(dict, buffer, transform) {
  44392. buffer.push("<<");
  44393. for (const key of dict.getKeys()) {
  44394. buffer.push(` /${(0, _core_utils.escapePDFName)(key)} `);
  44395. await writeValue(dict.getRaw(key), buffer, transform);
  44396. }
  44397. buffer.push(">>");
  44398. }
  44399. async function writeStream(stream, buffer, transform) {
  44400. let string = stream.getString();
  44401. const {
  44402. dict
  44403. } = stream;
  44404. const [filter, params] = await Promise.all([dict.getAsync("Filter"), dict.getAsync("DecodeParms")]);
  44405. const filterZero = Array.isArray(filter) ? await dict.xref.fetchIfRefAsync(filter[0]) : filter;
  44406. const isFilterZeroFlateDecode = (0, _primitives.isName)(filterZero, "FlateDecode");
  44407. const MIN_LENGTH_FOR_COMPRESSING = 256;
  44408. if (typeof CompressionStream !== "undefined" && (string.length >= MIN_LENGTH_FOR_COMPRESSING || isFilterZeroFlateDecode)) {
  44409. try {
  44410. const byteArray = (0, _util.stringToBytes)(string);
  44411. const cs = new CompressionStream("deflate");
  44412. const writer = cs.writable.getWriter();
  44413. writer.write(byteArray);
  44414. writer.close();
  44415. const buf = await new Response(cs.readable).arrayBuffer();
  44416. string = (0, _util.bytesToString)(new Uint8Array(buf));
  44417. let newFilter, newParams;
  44418. if (!filter) {
  44419. newFilter = _primitives.Name.get("FlateDecode");
  44420. } else if (!isFilterZeroFlateDecode) {
  44421. newFilter = Array.isArray(filter) ? [_primitives.Name.get("FlateDecode"), ...filter] : [_primitives.Name.get("FlateDecode"), filter];
  44422. if (params) {
  44423. newParams = Array.isArray(params) ? [null, ...params] : [null, params];
  44424. }
  44425. }
  44426. if (newFilter) {
  44427. dict.set("Filter", newFilter);
  44428. }
  44429. if (newParams) {
  44430. dict.set("DecodeParms", newParams);
  44431. }
  44432. } catch (ex) {
  44433. (0, _util.info)(`writeStream - cannot compress data: "${ex}".`);
  44434. }
  44435. }
  44436. if (transform !== null) {
  44437. string = transform.encryptString(string);
  44438. }
  44439. dict.set("Length", string.length);
  44440. await writeDict(dict, buffer, transform);
  44441. buffer.push(" stream\n", string, "\nendstream");
  44442. }
  44443. async function writeArray(array, buffer, transform) {
  44444. buffer.push("[");
  44445. let first = true;
  44446. for (const val of array) {
  44447. if (!first) {
  44448. buffer.push(" ");
  44449. } else {
  44450. first = false;
  44451. }
  44452. await writeValue(val, buffer, transform);
  44453. }
  44454. buffer.push("]");
  44455. }
  44456. async function writeValue(value, buffer, transform) {
  44457. if (value instanceof _primitives.Name) {
  44458. buffer.push(`/${(0, _core_utils.escapePDFName)(value.name)}`);
  44459. } else if (value instanceof _primitives.Ref) {
  44460. buffer.push(`${value.num} ${value.gen} R`);
  44461. } else if (Array.isArray(value)) {
  44462. await writeArray(value, buffer, transform);
  44463. } else if (typeof value === "string") {
  44464. if (transform !== null) {
  44465. value = transform.encryptString(value);
  44466. }
  44467. buffer.push(`(${(0, _core_utils.escapeString)(value)})`);
  44468. } else if (typeof value === "number") {
  44469. buffer.push((0, _core_utils.numberToString)(value));
  44470. } else if (typeof value === "boolean") {
  44471. buffer.push(value.toString());
  44472. } else if (value instanceof _primitives.Dict) {
  44473. await writeDict(value, buffer, transform);
  44474. } else if (value instanceof _base_stream.BaseStream) {
  44475. await writeStream(value, buffer, transform);
  44476. } else if (value === null) {
  44477. buffer.push("null");
  44478. } else {
  44479. (0, _util.warn)(`Unhandled value in writer: ${typeof value}, please file a bug.`);
  44480. }
  44481. }
  44482. function writeInt(number, size, offset, buffer) {
  44483. for (let i = size + offset - 1; i > offset - 1; i--) {
  44484. buffer[i] = number & 0xff;
  44485. number >>= 8;
  44486. }
  44487. return offset + size;
  44488. }
  44489. function writeString(string, offset, buffer) {
  44490. for (let i = 0, len = string.length; i < len; i++) {
  44491. buffer[offset + i] = string.charCodeAt(i) & 0xff;
  44492. }
  44493. }
  44494. function computeMD5(filesize, xrefInfo) {
  44495. const time = Math.floor(Date.now() / 1000);
  44496. const filename = xrefInfo.filename || "";
  44497. const md5Buffer = [time.toString(), filename, filesize.toString()];
  44498. let md5BufferLen = md5Buffer.reduce((a, str) => a + str.length, 0);
  44499. for (const value of Object.values(xrefInfo.info)) {
  44500. md5Buffer.push(value);
  44501. md5BufferLen += value.length;
  44502. }
  44503. const array = new Uint8Array(md5BufferLen);
  44504. let offset = 0;
  44505. for (const str of md5Buffer) {
  44506. writeString(str, offset, array);
  44507. offset += str.length;
  44508. }
  44509. return (0, _util.bytesToString)((0, _crypto.calculateMD5)(array));
  44510. }
  44511. function writeXFADataForAcroform(str, newRefs) {
  44512. const xml = new _xml_parser.SimpleXMLParser({
  44513. hasAttributes: true
  44514. }).parseFromString(str);
  44515. for (const {
  44516. xfa
  44517. } of newRefs) {
  44518. if (!xfa) {
  44519. continue;
  44520. }
  44521. const {
  44522. path,
  44523. value
  44524. } = xfa;
  44525. if (!path) {
  44526. continue;
  44527. }
  44528. const nodePath = (0, _core_utils.parseXFAPath)(path);
  44529. let node = xml.documentElement.searchNode(nodePath, 0);
  44530. if (!node && nodePath.length > 1) {
  44531. node = xml.documentElement.searchNode([nodePath.at(-1)], 0);
  44532. }
  44533. if (node) {
  44534. node.childNodes = Array.isArray(value) ? value.map(val => new _xml_parser.SimpleDOMNode("value", val)) : [new _xml_parser.SimpleDOMNode("#text", value)];
  44535. } else {
  44536. (0, _util.warn)(`Node not found for path: ${path}`);
  44537. }
  44538. }
  44539. const buffer = [];
  44540. xml.documentElement.dump(buffer);
  44541. return buffer.join("");
  44542. }
  44543. async function updateAcroform(_ref) {
  44544. let {
  44545. xref,
  44546. acroForm,
  44547. acroFormRef,
  44548. hasXfa,
  44549. hasXfaDatasetsEntry,
  44550. xfaDatasetsRef,
  44551. needAppearances,
  44552. newRefs
  44553. } = _ref;
  44554. if (hasXfa && !hasXfaDatasetsEntry && !xfaDatasetsRef) {
  44555. (0, _util.warn)("XFA - Cannot save it");
  44556. }
  44557. if (!needAppearances && (!hasXfa || !xfaDatasetsRef || hasXfaDatasetsEntry)) {
  44558. return;
  44559. }
  44560. const dict = new _primitives.Dict(xref);
  44561. for (const key of acroForm.getKeys()) {
  44562. dict.set(key, acroForm.getRaw(key));
  44563. }
  44564. if (hasXfa && !hasXfaDatasetsEntry) {
  44565. const newXfa = acroForm.get("XFA").slice();
  44566. newXfa.splice(2, 0, "datasets");
  44567. newXfa.splice(3, 0, xfaDatasetsRef);
  44568. dict.set("XFA", newXfa);
  44569. }
  44570. if (needAppearances) {
  44571. dict.set("NeedAppearances", true);
  44572. }
  44573. const encrypt = xref.encrypt;
  44574. let transform = null;
  44575. if (encrypt) {
  44576. transform = encrypt.createCipherTransform(acroFormRef.num, acroFormRef.gen);
  44577. }
  44578. const buffer = [];
  44579. await writeObject(acroFormRef, dict, buffer, transform);
  44580. newRefs.push({
  44581. ref: acroFormRef,
  44582. data: buffer.join("")
  44583. });
  44584. }
  44585. function updateXFA(_ref2) {
  44586. let {
  44587. xfaData,
  44588. xfaDatasetsRef,
  44589. newRefs,
  44590. xref
  44591. } = _ref2;
  44592. if (xfaData === null) {
  44593. const datasets = xref.fetchIfRef(xfaDatasetsRef);
  44594. xfaData = writeXFADataForAcroform(datasets.getString(), newRefs);
  44595. }
  44596. const encrypt = xref.encrypt;
  44597. if (encrypt) {
  44598. const transform = encrypt.createCipherTransform(xfaDatasetsRef.num, xfaDatasetsRef.gen);
  44599. xfaData = transform.encryptString(xfaData);
  44600. }
  44601. const data = `${xfaDatasetsRef.num} ${xfaDatasetsRef.gen} obj\n` + `<< /Type /EmbeddedFile /Length ${xfaData.length}>>\nstream\n` + xfaData + "\nendstream\nendobj\n";
  44602. newRefs.push({
  44603. ref: xfaDatasetsRef,
  44604. data
  44605. });
  44606. }
  44607. async function incrementalUpdate(_ref3) {
  44608. let {
  44609. originalData,
  44610. xrefInfo,
  44611. newRefs,
  44612. xref = null,
  44613. hasXfa = false,
  44614. xfaDatasetsRef = null,
  44615. hasXfaDatasetsEntry = false,
  44616. needAppearances,
  44617. acroFormRef = null,
  44618. acroForm = null,
  44619. xfaData = null
  44620. } = _ref3;
  44621. await updateAcroform({
  44622. xref,
  44623. acroForm,
  44624. acroFormRef,
  44625. hasXfa,
  44626. hasXfaDatasetsEntry,
  44627. xfaDatasetsRef,
  44628. needAppearances,
  44629. newRefs
  44630. });
  44631. if (hasXfa) {
  44632. updateXFA({
  44633. xfaData,
  44634. xfaDatasetsRef,
  44635. newRefs,
  44636. xref
  44637. });
  44638. }
  44639. const newXref = new _primitives.Dict(null);
  44640. const refForXrefTable = xrefInfo.newRef;
  44641. let buffer, baseOffset;
  44642. const lastByte = originalData.at(-1);
  44643. if (lastByte === 0x0a || lastByte === 0x0d) {
  44644. buffer = [];
  44645. baseOffset = originalData.length;
  44646. } else {
  44647. buffer = ["\n"];
  44648. baseOffset = originalData.length + 1;
  44649. }
  44650. newXref.set("Size", refForXrefTable.num + 1);
  44651. newXref.set("Prev", xrefInfo.startXRef);
  44652. newXref.set("Type", _primitives.Name.get("XRef"));
  44653. if (xrefInfo.rootRef !== null) {
  44654. newXref.set("Root", xrefInfo.rootRef);
  44655. }
  44656. if (xrefInfo.infoRef !== null) {
  44657. newXref.set("Info", xrefInfo.infoRef);
  44658. }
  44659. if (xrefInfo.encryptRef !== null) {
  44660. newXref.set("Encrypt", xrefInfo.encryptRef);
  44661. }
  44662. newRefs.push({
  44663. ref: refForXrefTable,
  44664. data: ""
  44665. });
  44666. newRefs = newRefs.sort((a, b) => {
  44667. return a.ref.num - b.ref.num;
  44668. });
  44669. const xrefTableData = [[0, 1, 0xffff]];
  44670. const indexes = [0, 1];
  44671. let maxOffset = 0;
  44672. for (const {
  44673. ref,
  44674. data
  44675. } of newRefs) {
  44676. maxOffset = Math.max(maxOffset, baseOffset);
  44677. xrefTableData.push([1, baseOffset, Math.min(ref.gen, 0xffff)]);
  44678. baseOffset += data.length;
  44679. indexes.push(ref.num, 1);
  44680. buffer.push(data);
  44681. }
  44682. newXref.set("Index", indexes);
  44683. if (Array.isArray(xrefInfo.fileIds) && xrefInfo.fileIds.length > 0) {
  44684. const md5 = computeMD5(baseOffset, xrefInfo);
  44685. newXref.set("ID", [xrefInfo.fileIds[0], md5]);
  44686. }
  44687. const offsetSize = Math.ceil(Math.log2(maxOffset) / 8);
  44688. const sizes = [1, offsetSize, 2];
  44689. const structSize = sizes[0] + sizes[1] + sizes[2];
  44690. const tableLength = structSize * xrefTableData.length;
  44691. newXref.set("W", sizes);
  44692. newXref.set("Length", tableLength);
  44693. buffer.push(`${refForXrefTable.num} ${refForXrefTable.gen} obj\n`);
  44694. await writeDict(newXref, buffer, null);
  44695. buffer.push(" stream\n");
  44696. const bufferLen = buffer.reduce((a, str) => a + str.length, 0);
  44697. const footer = `\nendstream\nendobj\nstartxref\n${baseOffset}\n%%EOF\n`;
  44698. const array = new Uint8Array(originalData.length + bufferLen + tableLength + footer.length);
  44699. array.set(originalData);
  44700. let offset = originalData.length;
  44701. for (const str of buffer) {
  44702. writeString(str, offset, array);
  44703. offset += str.length;
  44704. }
  44705. for (const [type, objOffset, gen] of xrefTableData) {
  44706. offset = writeInt(type, sizes[0], offset, array);
  44707. offset = writeInt(objOffset, sizes[1], offset, array);
  44708. offset = writeInt(gen, sizes[2], offset, array);
  44709. }
  44710. writeString(footer, offset, array);
  44711. return array;
  44712. }
  44713. /***/ }),
  44714. /* 218 */
  44715. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  44716. Object.defineProperty(exports, "__esModule", ({
  44717. value: true
  44718. }));
  44719. exports.XMLParserErrorCode = exports.XMLParserBase = exports.SimpleXMLParser = exports.SimpleDOMNode = void 0;
  44720. __w_pdfjs_require__(140);
  44721. var _core_utils = __w_pdfjs_require__(150);
  44722. const XMLParserErrorCode = {
  44723. NoError: 0,
  44724. EndOfDocument: -1,
  44725. UnterminatedCdat: -2,
  44726. UnterminatedXmlDeclaration: -3,
  44727. UnterminatedDoctypeDeclaration: -4,
  44728. UnterminatedComment: -5,
  44729. MalformedElement: -6,
  44730. OutOfMemory: -7,
  44731. UnterminatedAttributeValue: -8,
  44732. UnterminatedElement: -9,
  44733. ElementNeverBegun: -10
  44734. };
  44735. exports.XMLParserErrorCode = XMLParserErrorCode;
  44736. function isWhitespace(s, index) {
  44737. const ch = s[index];
  44738. return ch === " " || ch === "\n" || ch === "\r" || ch === "\t";
  44739. }
  44740. function isWhitespaceString(s) {
  44741. for (let i = 0, ii = s.length; i < ii; i++) {
  44742. if (!isWhitespace(s, i)) {
  44743. return false;
  44744. }
  44745. }
  44746. return true;
  44747. }
  44748. class XMLParserBase {
  44749. _resolveEntities(s) {
  44750. return s.replaceAll(/&([^;]+);/g, (all, entity) => {
  44751. if (entity.substring(0, 2) === "#x") {
  44752. return String.fromCodePoint(parseInt(entity.substring(2), 16));
  44753. } else if (entity.substring(0, 1) === "#") {
  44754. return String.fromCodePoint(parseInt(entity.substring(1), 10));
  44755. }
  44756. switch (entity) {
  44757. case "lt":
  44758. return "<";
  44759. case "gt":
  44760. return ">";
  44761. case "amp":
  44762. return "&";
  44763. case "quot":
  44764. return '"';
  44765. case "apos":
  44766. return "'";
  44767. }
  44768. return this.onResolveEntity(entity);
  44769. });
  44770. }
  44771. _parseContent(s, start) {
  44772. const attributes = [];
  44773. let pos = start;
  44774. function skipWs() {
  44775. while (pos < s.length && isWhitespace(s, pos)) {
  44776. ++pos;
  44777. }
  44778. }
  44779. while (pos < s.length && !isWhitespace(s, pos) && s[pos] !== ">" && s[pos] !== "/") {
  44780. ++pos;
  44781. }
  44782. const name = s.substring(start, pos);
  44783. skipWs();
  44784. while (pos < s.length && s[pos] !== ">" && s[pos] !== "/" && s[pos] !== "?") {
  44785. skipWs();
  44786. let attrName = "",
  44787. attrValue = "";
  44788. while (pos < s.length && !isWhitespace(s, pos) && s[pos] !== "=") {
  44789. attrName += s[pos];
  44790. ++pos;
  44791. }
  44792. skipWs();
  44793. if (s[pos] !== "=") {
  44794. return null;
  44795. }
  44796. ++pos;
  44797. skipWs();
  44798. const attrEndChar = s[pos];
  44799. if (attrEndChar !== '"' && attrEndChar !== "'") {
  44800. return null;
  44801. }
  44802. const attrEndIndex = s.indexOf(attrEndChar, ++pos);
  44803. if (attrEndIndex < 0) {
  44804. return null;
  44805. }
  44806. attrValue = s.substring(pos, attrEndIndex);
  44807. attributes.push({
  44808. name: attrName,
  44809. value: this._resolveEntities(attrValue)
  44810. });
  44811. pos = attrEndIndex + 1;
  44812. skipWs();
  44813. }
  44814. return {
  44815. name,
  44816. attributes,
  44817. parsed: pos - start
  44818. };
  44819. }
  44820. _parseProcessingInstruction(s, start) {
  44821. let pos = start;
  44822. function skipWs() {
  44823. while (pos < s.length && isWhitespace(s, pos)) {
  44824. ++pos;
  44825. }
  44826. }
  44827. while (pos < s.length && !isWhitespace(s, pos) && s[pos] !== ">" && s[pos] !== "?" && s[pos] !== "/") {
  44828. ++pos;
  44829. }
  44830. const name = s.substring(start, pos);
  44831. skipWs();
  44832. const attrStart = pos;
  44833. while (pos < s.length && (s[pos] !== "?" || s[pos + 1] !== ">")) {
  44834. ++pos;
  44835. }
  44836. const value = s.substring(attrStart, pos);
  44837. return {
  44838. name,
  44839. value,
  44840. parsed: pos - start
  44841. };
  44842. }
  44843. parseXml(s) {
  44844. let i = 0;
  44845. while (i < s.length) {
  44846. const ch = s[i];
  44847. let j = i;
  44848. if (ch === "<") {
  44849. ++j;
  44850. const ch2 = s[j];
  44851. let q;
  44852. switch (ch2) {
  44853. case "/":
  44854. ++j;
  44855. q = s.indexOf(">", j);
  44856. if (q < 0) {
  44857. this.onError(XMLParserErrorCode.UnterminatedElement);
  44858. return;
  44859. }
  44860. this.onEndElement(s.substring(j, q));
  44861. j = q + 1;
  44862. break;
  44863. case "?":
  44864. ++j;
  44865. const pi = this._parseProcessingInstruction(s, j);
  44866. if (s.substring(j + pi.parsed, j + pi.parsed + 2) !== "?>") {
  44867. this.onError(XMLParserErrorCode.UnterminatedXmlDeclaration);
  44868. return;
  44869. }
  44870. this.onPi(pi.name, pi.value);
  44871. j += pi.parsed + 2;
  44872. break;
  44873. case "!":
  44874. if (s.substring(j + 1, j + 3) === "--") {
  44875. q = s.indexOf("-->", j + 3);
  44876. if (q < 0) {
  44877. this.onError(XMLParserErrorCode.UnterminatedComment);
  44878. return;
  44879. }
  44880. this.onComment(s.substring(j + 3, q));
  44881. j = q + 3;
  44882. } else if (s.substring(j + 1, j + 8) === "[CDATA[") {
  44883. q = s.indexOf("]]>", j + 8);
  44884. if (q < 0) {
  44885. this.onError(XMLParserErrorCode.UnterminatedCdat);
  44886. return;
  44887. }
  44888. this.onCdata(s.substring(j + 8, q));
  44889. j = q + 3;
  44890. } else if (s.substring(j + 1, j + 8) === "DOCTYPE") {
  44891. const q2 = s.indexOf("[", j + 8);
  44892. let complexDoctype = false;
  44893. q = s.indexOf(">", j + 8);
  44894. if (q < 0) {
  44895. this.onError(XMLParserErrorCode.UnterminatedDoctypeDeclaration);
  44896. return;
  44897. }
  44898. if (q2 > 0 && q > q2) {
  44899. q = s.indexOf("]>", j + 8);
  44900. if (q < 0) {
  44901. this.onError(XMLParserErrorCode.UnterminatedDoctypeDeclaration);
  44902. return;
  44903. }
  44904. complexDoctype = true;
  44905. }
  44906. const doctypeContent = s.substring(j + 8, q + (complexDoctype ? 1 : 0));
  44907. this.onDoctype(doctypeContent);
  44908. j = q + (complexDoctype ? 2 : 1);
  44909. } else {
  44910. this.onError(XMLParserErrorCode.MalformedElement);
  44911. return;
  44912. }
  44913. break;
  44914. default:
  44915. const content = this._parseContent(s, j);
  44916. if (content === null) {
  44917. this.onError(XMLParserErrorCode.MalformedElement);
  44918. return;
  44919. }
  44920. let isClosed = false;
  44921. if (s.substring(j + content.parsed, j + content.parsed + 2) === "/>") {
  44922. isClosed = true;
  44923. } else if (s.substring(j + content.parsed, j + content.parsed + 1) !== ">") {
  44924. this.onError(XMLParserErrorCode.UnterminatedElement);
  44925. return;
  44926. }
  44927. this.onBeginElement(content.name, content.attributes, isClosed);
  44928. j += content.parsed + (isClosed ? 2 : 1);
  44929. break;
  44930. }
  44931. } else {
  44932. while (j < s.length && s[j] !== "<") {
  44933. j++;
  44934. }
  44935. const text = s.substring(i, j);
  44936. this.onText(this._resolveEntities(text));
  44937. }
  44938. i = j;
  44939. }
  44940. }
  44941. onResolveEntity(name) {
  44942. return `&${name};`;
  44943. }
  44944. onPi(name, value) {}
  44945. onComment(text) {}
  44946. onCdata(text) {}
  44947. onDoctype(doctypeContent) {}
  44948. onText(text) {}
  44949. onBeginElement(name, attributes, isEmpty) {}
  44950. onEndElement(name) {}
  44951. onError(code) {}
  44952. }
  44953. exports.XMLParserBase = XMLParserBase;
  44954. class SimpleDOMNode {
  44955. constructor(nodeName, nodeValue) {
  44956. this.nodeName = nodeName;
  44957. this.nodeValue = nodeValue;
  44958. Object.defineProperty(this, "parentNode", {
  44959. value: null,
  44960. writable: true
  44961. });
  44962. }
  44963. get firstChild() {
  44964. return this.childNodes?.[0];
  44965. }
  44966. get nextSibling() {
  44967. const childNodes = this.parentNode.childNodes;
  44968. if (!childNodes) {
  44969. return undefined;
  44970. }
  44971. const index = childNodes.indexOf(this);
  44972. if (index === -1) {
  44973. return undefined;
  44974. }
  44975. return childNodes[index + 1];
  44976. }
  44977. get textContent() {
  44978. if (!this.childNodes) {
  44979. return this.nodeValue || "";
  44980. }
  44981. return this.childNodes.map(function (child) {
  44982. return child.textContent;
  44983. }).join("");
  44984. }
  44985. get children() {
  44986. return this.childNodes || [];
  44987. }
  44988. hasChildNodes() {
  44989. return this.childNodes?.length > 0;
  44990. }
  44991. searchNode(paths, pos) {
  44992. if (pos >= paths.length) {
  44993. return this;
  44994. }
  44995. const component = paths[pos];
  44996. const stack = [];
  44997. let node = this;
  44998. while (true) {
  44999. if (component.name === node.nodeName) {
  45000. if (component.pos === 0) {
  45001. const res = node.searchNode(paths, pos + 1);
  45002. if (res !== null) {
  45003. return res;
  45004. }
  45005. } else if (stack.length === 0) {
  45006. return null;
  45007. } else {
  45008. const [parent] = stack.pop();
  45009. let siblingPos = 0;
  45010. for (const child of parent.childNodes) {
  45011. if (component.name === child.nodeName) {
  45012. if (siblingPos === component.pos) {
  45013. return child.searchNode(paths, pos + 1);
  45014. }
  45015. siblingPos++;
  45016. }
  45017. }
  45018. return node.searchNode(paths, pos + 1);
  45019. }
  45020. }
  45021. if (node.childNodes?.length > 0) {
  45022. stack.push([node, 0]);
  45023. node = node.childNodes[0];
  45024. } else if (stack.length === 0) {
  45025. return null;
  45026. } else {
  45027. while (stack.length !== 0) {
  45028. const [parent, currentPos] = stack.pop();
  45029. const newPos = currentPos + 1;
  45030. if (newPos < parent.childNodes.length) {
  45031. stack.push([parent, newPos]);
  45032. node = parent.childNodes[newPos];
  45033. break;
  45034. }
  45035. }
  45036. if (stack.length === 0) {
  45037. return null;
  45038. }
  45039. }
  45040. }
  45041. }
  45042. dump(buffer) {
  45043. if (this.nodeName === "#text") {
  45044. buffer.push((0, _core_utils.encodeToXmlString)(this.nodeValue));
  45045. return;
  45046. }
  45047. buffer.push(`<${this.nodeName}`);
  45048. if (this.attributes) {
  45049. for (const attribute of this.attributes) {
  45050. buffer.push(` ${attribute.name}="${(0, _core_utils.encodeToXmlString)(attribute.value)}"`);
  45051. }
  45052. }
  45053. if (this.hasChildNodes()) {
  45054. buffer.push(">");
  45055. for (const child of this.childNodes) {
  45056. child.dump(buffer);
  45057. }
  45058. buffer.push(`</${this.nodeName}>`);
  45059. } else if (this.nodeValue) {
  45060. buffer.push(`>${(0, _core_utils.encodeToXmlString)(this.nodeValue)}</${this.nodeName}>`);
  45061. } else {
  45062. buffer.push("/>");
  45063. }
  45064. }
  45065. }
  45066. exports.SimpleDOMNode = SimpleDOMNode;
  45067. class SimpleXMLParser extends XMLParserBase {
  45068. constructor(_ref) {
  45069. let {
  45070. hasAttributes = false,
  45071. lowerCaseName = false
  45072. } = _ref;
  45073. super();
  45074. this._currentFragment = null;
  45075. this._stack = null;
  45076. this._errorCode = XMLParserErrorCode.NoError;
  45077. this._hasAttributes = hasAttributes;
  45078. this._lowerCaseName = lowerCaseName;
  45079. }
  45080. parseFromString(data) {
  45081. this._currentFragment = [];
  45082. this._stack = [];
  45083. this._errorCode = XMLParserErrorCode.NoError;
  45084. this.parseXml(data);
  45085. if (this._errorCode !== XMLParserErrorCode.NoError) {
  45086. return undefined;
  45087. }
  45088. const [documentElement] = this._currentFragment;
  45089. if (!documentElement) {
  45090. return undefined;
  45091. }
  45092. return {
  45093. documentElement
  45094. };
  45095. }
  45096. onText(text) {
  45097. if (isWhitespaceString(text)) {
  45098. return;
  45099. }
  45100. const node = new SimpleDOMNode("#text", text);
  45101. this._currentFragment.push(node);
  45102. }
  45103. onCdata(text) {
  45104. const node = new SimpleDOMNode("#text", text);
  45105. this._currentFragment.push(node);
  45106. }
  45107. onBeginElement(name, attributes, isEmpty) {
  45108. if (this._lowerCaseName) {
  45109. name = name.toLowerCase();
  45110. }
  45111. const node = new SimpleDOMNode(name);
  45112. node.childNodes = [];
  45113. if (this._hasAttributes) {
  45114. node.attributes = attributes;
  45115. }
  45116. this._currentFragment.push(node);
  45117. if (isEmpty) {
  45118. return;
  45119. }
  45120. this._stack.push(this._currentFragment);
  45121. this._currentFragment = node.childNodes;
  45122. }
  45123. onEndElement(name) {
  45124. this._currentFragment = this._stack.pop() || [];
  45125. const lastElement = this._currentFragment.at(-1);
  45126. if (!lastElement) {
  45127. return null;
  45128. }
  45129. for (const childNode of lastElement.childNodes) {
  45130. childNode.parentNode = lastElement;
  45131. }
  45132. return lastElement;
  45133. }
  45134. onError(code) {
  45135. this._errorCode = code;
  45136. }
  45137. }
  45138. exports.SimpleXMLParser = SimpleXMLParser;
  45139. /***/ }),
  45140. /* 219 */
  45141. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  45142. Object.defineProperty(exports, "__esModule", ({
  45143. value: true
  45144. }));
  45145. exports.calculateSHA256 = exports.calculateMD5 = exports.PDF20 = exports.PDF17 = exports.CipherTransformFactory = exports.ARCFourCipher = exports.AES256Cipher = exports.AES128Cipher = void 0;
  45146. exports.calculateSHA384 = calculateSHA384;
  45147. exports.calculateSHA512 = void 0;
  45148. __w_pdfjs_require__(84);
  45149. __w_pdfjs_require__(93);
  45150. __w_pdfjs_require__(94);
  45151. __w_pdfjs_require__(97);
  45152. __w_pdfjs_require__(99);
  45153. __w_pdfjs_require__(101);
  45154. __w_pdfjs_require__(105);
  45155. __w_pdfjs_require__(108);
  45156. __w_pdfjs_require__(115);
  45157. __w_pdfjs_require__(140);
  45158. var _util = __w_pdfjs_require__(145);
  45159. var _primitives = __w_pdfjs_require__(151);
  45160. var _decrypt_stream = __w_pdfjs_require__(220);
  45161. class ARCFourCipher {
  45162. constructor(key) {
  45163. this.a = 0;
  45164. this.b = 0;
  45165. const s = new Uint8Array(256);
  45166. const keyLength = key.length;
  45167. for (let i = 0; i < 256; ++i) {
  45168. s[i] = i;
  45169. }
  45170. for (let i = 0, j = 0; i < 256; ++i) {
  45171. const tmp = s[i];
  45172. j = j + tmp + key[i % keyLength] & 0xff;
  45173. s[i] = s[j];
  45174. s[j] = tmp;
  45175. }
  45176. this.s = s;
  45177. }
  45178. encryptBlock(data) {
  45179. let a = this.a,
  45180. b = this.b;
  45181. const s = this.s;
  45182. const n = data.length;
  45183. const output = new Uint8Array(n);
  45184. for (let i = 0; i < n; ++i) {
  45185. a = a + 1 & 0xff;
  45186. const tmp = s[a];
  45187. b = b + tmp & 0xff;
  45188. const tmp2 = s[b];
  45189. s[a] = tmp2;
  45190. s[b] = tmp;
  45191. output[i] = data[i] ^ s[tmp + tmp2 & 0xff];
  45192. }
  45193. this.a = a;
  45194. this.b = b;
  45195. return output;
  45196. }
  45197. decryptBlock(data) {
  45198. return this.encryptBlock(data);
  45199. }
  45200. encrypt(data) {
  45201. return this.encryptBlock(data);
  45202. }
  45203. }
  45204. exports.ARCFourCipher = ARCFourCipher;
  45205. const calculateMD5 = function calculateMD5Closure() {
  45206. 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]);
  45207. 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]);
  45208. function hash(data, offset, length) {
  45209. let h0 = 1732584193,
  45210. h1 = -271733879,
  45211. h2 = -1732584194,
  45212. h3 = 271733878;
  45213. const paddedLength = length + 72 & ~63;
  45214. const padded = new Uint8Array(paddedLength);
  45215. let i, j;
  45216. for (i = 0; i < length; ++i) {
  45217. padded[i] = data[offset++];
  45218. }
  45219. padded[i++] = 0x80;
  45220. const n = paddedLength - 8;
  45221. while (i < n) {
  45222. padded[i++] = 0;
  45223. }
  45224. padded[i++] = length << 3 & 0xff;
  45225. padded[i++] = length >> 5 & 0xff;
  45226. padded[i++] = length >> 13 & 0xff;
  45227. padded[i++] = length >> 21 & 0xff;
  45228. padded[i++] = length >>> 29 & 0xff;
  45229. padded[i++] = 0;
  45230. padded[i++] = 0;
  45231. padded[i++] = 0;
  45232. const w = new Int32Array(16);
  45233. for (i = 0; i < paddedLength;) {
  45234. for (j = 0; j < 16; ++j, i += 4) {
  45235. w[j] = padded[i] | padded[i + 1] << 8 | padded[i + 2] << 16 | padded[i + 3] << 24;
  45236. }
  45237. let a = h0,
  45238. b = h1,
  45239. c = h2,
  45240. d = h3,
  45241. f,
  45242. g;
  45243. for (j = 0; j < 64; ++j) {
  45244. if (j < 16) {
  45245. f = b & c | ~b & d;
  45246. g = j;
  45247. } else if (j < 32) {
  45248. f = d & b | ~d & c;
  45249. g = 5 * j + 1 & 15;
  45250. } else if (j < 48) {
  45251. f = b ^ c ^ d;
  45252. g = 3 * j + 5 & 15;
  45253. } else {
  45254. f = c ^ (b | ~d);
  45255. g = 7 * j & 15;
  45256. }
  45257. const tmp = d,
  45258. rotateArg = a + f + k[j] + w[g] | 0,
  45259. rotate = r[j];
  45260. d = c;
  45261. c = b;
  45262. b = b + (rotateArg << rotate | rotateArg >>> 32 - rotate) | 0;
  45263. a = tmp;
  45264. }
  45265. h0 = h0 + a | 0;
  45266. h1 = h1 + b | 0;
  45267. h2 = h2 + c | 0;
  45268. h3 = h3 + d | 0;
  45269. }
  45270. 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]);
  45271. }
  45272. return hash;
  45273. }();
  45274. exports.calculateMD5 = calculateMD5;
  45275. class Word64 {
  45276. constructor(highInteger, lowInteger) {
  45277. this.high = highInteger | 0;
  45278. this.low = lowInteger | 0;
  45279. }
  45280. and(word) {
  45281. this.high &= word.high;
  45282. this.low &= word.low;
  45283. }
  45284. xor(word) {
  45285. this.high ^= word.high;
  45286. this.low ^= word.low;
  45287. }
  45288. or(word) {
  45289. this.high |= word.high;
  45290. this.low |= word.low;
  45291. }
  45292. shiftRight(places) {
  45293. if (places >= 32) {
  45294. this.low = this.high >>> places - 32 | 0;
  45295. this.high = 0;
  45296. } else {
  45297. this.low = this.low >>> places | this.high << 32 - places;
  45298. this.high = this.high >>> places | 0;
  45299. }
  45300. }
  45301. shiftLeft(places) {
  45302. if (places >= 32) {
  45303. this.high = this.low << places - 32;
  45304. this.low = 0;
  45305. } else {
  45306. this.high = this.high << places | this.low >>> 32 - places;
  45307. this.low <<= places;
  45308. }
  45309. }
  45310. rotateRight(places) {
  45311. let low, high;
  45312. if (places & 32) {
  45313. high = this.low;
  45314. low = this.high;
  45315. } else {
  45316. low = this.low;
  45317. high = this.high;
  45318. }
  45319. places &= 31;
  45320. this.low = low >>> places | high << 32 - places;
  45321. this.high = high >>> places | low << 32 - places;
  45322. }
  45323. not() {
  45324. this.high = ~this.high;
  45325. this.low = ~this.low;
  45326. }
  45327. add(word) {
  45328. const lowAdd = (this.low >>> 0) + (word.low >>> 0);
  45329. let highAdd = (this.high >>> 0) + (word.high >>> 0);
  45330. if (lowAdd > 0xffffffff) {
  45331. highAdd += 1;
  45332. }
  45333. this.low = lowAdd | 0;
  45334. this.high = highAdd | 0;
  45335. }
  45336. copyTo(bytes, offset) {
  45337. bytes[offset] = this.high >>> 24 & 0xff;
  45338. bytes[offset + 1] = this.high >> 16 & 0xff;
  45339. bytes[offset + 2] = this.high >> 8 & 0xff;
  45340. bytes[offset + 3] = this.high & 0xff;
  45341. bytes[offset + 4] = this.low >>> 24 & 0xff;
  45342. bytes[offset + 5] = this.low >> 16 & 0xff;
  45343. bytes[offset + 6] = this.low >> 8 & 0xff;
  45344. bytes[offset + 7] = this.low & 0xff;
  45345. }
  45346. assign(word) {
  45347. this.high = word.high;
  45348. this.low = word.low;
  45349. }
  45350. }
  45351. const calculateSHA256 = function calculateSHA256Closure() {
  45352. function rotr(x, n) {
  45353. return x >>> n | x << 32 - n;
  45354. }
  45355. function ch(x, y, z) {
  45356. return x & y ^ ~x & z;
  45357. }
  45358. function maj(x, y, z) {
  45359. return x & y ^ x & z ^ y & z;
  45360. }
  45361. function sigma(x) {
  45362. return rotr(x, 2) ^ rotr(x, 13) ^ rotr(x, 22);
  45363. }
  45364. function sigmaPrime(x) {
  45365. return rotr(x, 6) ^ rotr(x, 11) ^ rotr(x, 25);
  45366. }
  45367. function littleSigma(x) {
  45368. return rotr(x, 7) ^ rotr(x, 18) ^ x >>> 3;
  45369. }
  45370. function littleSigmaPrime(x) {
  45371. return rotr(x, 17) ^ rotr(x, 19) ^ x >>> 10;
  45372. }
  45373. 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];
  45374. function hash(data, offset, length) {
  45375. let h0 = 0x6a09e667,
  45376. h1 = 0xbb67ae85,
  45377. h2 = 0x3c6ef372,
  45378. h3 = 0xa54ff53a,
  45379. h4 = 0x510e527f,
  45380. h5 = 0x9b05688c,
  45381. h6 = 0x1f83d9ab,
  45382. h7 = 0x5be0cd19;
  45383. const paddedLength = Math.ceil((length + 9) / 64) * 64;
  45384. const padded = new Uint8Array(paddedLength);
  45385. let i, j;
  45386. for (i = 0; i < length; ++i) {
  45387. padded[i] = data[offset++];
  45388. }
  45389. padded[i++] = 0x80;
  45390. const n = paddedLength - 8;
  45391. while (i < n) {
  45392. padded[i++] = 0;
  45393. }
  45394. padded[i++] = 0;
  45395. padded[i++] = 0;
  45396. padded[i++] = 0;
  45397. padded[i++] = length >>> 29 & 0xff;
  45398. padded[i++] = length >> 21 & 0xff;
  45399. padded[i++] = length >> 13 & 0xff;
  45400. padded[i++] = length >> 5 & 0xff;
  45401. padded[i++] = length << 3 & 0xff;
  45402. const w = new Uint32Array(64);
  45403. for (i = 0; i < paddedLength;) {
  45404. for (j = 0; j < 16; ++j) {
  45405. w[j] = padded[i] << 24 | padded[i + 1] << 16 | padded[i + 2] << 8 | padded[i + 3];
  45406. i += 4;
  45407. }
  45408. for (j = 16; j < 64; ++j) {
  45409. w[j] = littleSigmaPrime(w[j - 2]) + w[j - 7] + littleSigma(w[j - 15]) + w[j - 16] | 0;
  45410. }
  45411. let a = h0,
  45412. b = h1,
  45413. c = h2,
  45414. d = h3,
  45415. e = h4,
  45416. f = h5,
  45417. g = h6,
  45418. h = h7,
  45419. t1,
  45420. t2;
  45421. for (j = 0; j < 64; ++j) {
  45422. t1 = h + sigmaPrime(e) + ch(e, f, g) + k[j] + w[j];
  45423. t2 = sigma(a) + maj(a, b, c);
  45424. h = g;
  45425. g = f;
  45426. f = e;
  45427. e = d + t1 | 0;
  45428. d = c;
  45429. c = b;
  45430. b = a;
  45431. a = t1 + t2 | 0;
  45432. }
  45433. h0 = h0 + a | 0;
  45434. h1 = h1 + b | 0;
  45435. h2 = h2 + c | 0;
  45436. h3 = h3 + d | 0;
  45437. h4 = h4 + e | 0;
  45438. h5 = h5 + f | 0;
  45439. h6 = h6 + g | 0;
  45440. h7 = h7 + h | 0;
  45441. }
  45442. 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]);
  45443. }
  45444. return hash;
  45445. }();
  45446. exports.calculateSHA256 = calculateSHA256;
  45447. const calculateSHA512 = function calculateSHA512Closure() {
  45448. function ch(result, x, y, z, tmp) {
  45449. result.assign(x);
  45450. result.and(y);
  45451. tmp.assign(x);
  45452. tmp.not();
  45453. tmp.and(z);
  45454. result.xor(tmp);
  45455. }
  45456. function maj(result, x, y, z, tmp) {
  45457. result.assign(x);
  45458. result.and(y);
  45459. tmp.assign(x);
  45460. tmp.and(z);
  45461. result.xor(tmp);
  45462. tmp.assign(y);
  45463. tmp.and(z);
  45464. result.xor(tmp);
  45465. }
  45466. function sigma(result, x, tmp) {
  45467. result.assign(x);
  45468. result.rotateRight(28);
  45469. tmp.assign(x);
  45470. tmp.rotateRight(34);
  45471. result.xor(tmp);
  45472. tmp.assign(x);
  45473. tmp.rotateRight(39);
  45474. result.xor(tmp);
  45475. }
  45476. function sigmaPrime(result, x, tmp) {
  45477. result.assign(x);
  45478. result.rotateRight(14);
  45479. tmp.assign(x);
  45480. tmp.rotateRight(18);
  45481. result.xor(tmp);
  45482. tmp.assign(x);
  45483. tmp.rotateRight(41);
  45484. result.xor(tmp);
  45485. }
  45486. function littleSigma(result, x, tmp) {
  45487. result.assign(x);
  45488. result.rotateRight(1);
  45489. tmp.assign(x);
  45490. tmp.rotateRight(8);
  45491. result.xor(tmp);
  45492. tmp.assign(x);
  45493. tmp.shiftRight(7);
  45494. result.xor(tmp);
  45495. }
  45496. function littleSigmaPrime(result, x, tmp) {
  45497. result.assign(x);
  45498. result.rotateRight(19);
  45499. tmp.assign(x);
  45500. tmp.rotateRight(61);
  45501. result.xor(tmp);
  45502. tmp.assign(x);
  45503. tmp.shiftRight(6);
  45504. result.xor(tmp);
  45505. }
  45506. 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)];
  45507. function hash(data, offset, length) {
  45508. let mode384 = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
  45509. let h0, h1, h2, h3, h4, h5, h6, h7;
  45510. if (!mode384) {
  45511. h0 = new Word64(0x6a09e667, 0xf3bcc908);
  45512. h1 = new Word64(0xbb67ae85, 0x84caa73b);
  45513. h2 = new Word64(0x3c6ef372, 0xfe94f82b);
  45514. h3 = new Word64(0xa54ff53a, 0x5f1d36f1);
  45515. h4 = new Word64(0x510e527f, 0xade682d1);
  45516. h5 = new Word64(0x9b05688c, 0x2b3e6c1f);
  45517. h6 = new Word64(0x1f83d9ab, 0xfb41bd6b);
  45518. h7 = new Word64(0x5be0cd19, 0x137e2179);
  45519. } else {
  45520. h0 = new Word64(0xcbbb9d5d, 0xc1059ed8);
  45521. h1 = new Word64(0x629a292a, 0x367cd507);
  45522. h2 = new Word64(0x9159015a, 0x3070dd17);
  45523. h3 = new Word64(0x152fecd8, 0xf70e5939);
  45524. h4 = new Word64(0x67332667, 0xffc00b31);
  45525. h5 = new Word64(0x8eb44a87, 0x68581511);
  45526. h6 = new Word64(0xdb0c2e0d, 0x64f98fa7);
  45527. h7 = new Word64(0x47b5481d, 0xbefa4fa4);
  45528. }
  45529. const paddedLength = Math.ceil((length + 17) / 128) * 128;
  45530. const padded = new Uint8Array(paddedLength);
  45531. let i, j;
  45532. for (i = 0; i < length; ++i) {
  45533. padded[i] = data[offset++];
  45534. }
  45535. padded[i++] = 0x80;
  45536. const n = paddedLength - 16;
  45537. while (i < n) {
  45538. padded[i++] = 0;
  45539. }
  45540. padded[i++] = 0;
  45541. padded[i++] = 0;
  45542. padded[i++] = 0;
  45543. padded[i++] = 0;
  45544. padded[i++] = 0;
  45545. padded[i++] = 0;
  45546. padded[i++] = 0;
  45547. padded[i++] = 0;
  45548. padded[i++] = 0;
  45549. padded[i++] = 0;
  45550. padded[i++] = 0;
  45551. padded[i++] = length >>> 29 & 0xff;
  45552. padded[i++] = length >> 21 & 0xff;
  45553. padded[i++] = length >> 13 & 0xff;
  45554. padded[i++] = length >> 5 & 0xff;
  45555. padded[i++] = length << 3 & 0xff;
  45556. const w = new Array(80);
  45557. for (i = 0; i < 80; i++) {
  45558. w[i] = new Word64(0, 0);
  45559. }
  45560. let a = new Word64(0, 0),
  45561. b = new Word64(0, 0),
  45562. c = new Word64(0, 0);
  45563. let d = new Word64(0, 0),
  45564. e = new Word64(0, 0),
  45565. f = new Word64(0, 0);
  45566. let g = new Word64(0, 0),
  45567. h = new Word64(0, 0);
  45568. const t1 = new Word64(0, 0),
  45569. t2 = new Word64(0, 0);
  45570. const tmp1 = new Word64(0, 0),
  45571. tmp2 = new Word64(0, 0);
  45572. let tmp3;
  45573. for (i = 0; i < paddedLength;) {
  45574. for (j = 0; j < 16; ++j) {
  45575. w[j].high = padded[i] << 24 | padded[i + 1] << 16 | padded[i + 2] << 8 | padded[i + 3];
  45576. w[j].low = padded[i + 4] << 24 | padded[i + 5] << 16 | padded[i + 6] << 8 | padded[i + 7];
  45577. i += 8;
  45578. }
  45579. for (j = 16; j < 80; ++j) {
  45580. tmp3 = w[j];
  45581. littleSigmaPrime(tmp3, w[j - 2], tmp2);
  45582. tmp3.add(w[j - 7]);
  45583. littleSigma(tmp1, w[j - 15], tmp2);
  45584. tmp3.add(tmp1);
  45585. tmp3.add(w[j - 16]);
  45586. }
  45587. a.assign(h0);
  45588. b.assign(h1);
  45589. c.assign(h2);
  45590. d.assign(h3);
  45591. e.assign(h4);
  45592. f.assign(h5);
  45593. g.assign(h6);
  45594. h.assign(h7);
  45595. for (j = 0; j < 80; ++j) {
  45596. t1.assign(h);
  45597. sigmaPrime(tmp1, e, tmp2);
  45598. t1.add(tmp1);
  45599. ch(tmp1, e, f, g, tmp2);
  45600. t1.add(tmp1);
  45601. t1.add(k[j]);
  45602. t1.add(w[j]);
  45603. sigma(t2, a, tmp2);
  45604. maj(tmp1, a, b, c, tmp2);
  45605. t2.add(tmp1);
  45606. tmp3 = h;
  45607. h = g;
  45608. g = f;
  45609. f = e;
  45610. d.add(t1);
  45611. e = d;
  45612. d = c;
  45613. c = b;
  45614. b = a;
  45615. tmp3.assign(t1);
  45616. tmp3.add(t2);
  45617. a = tmp3;
  45618. }
  45619. h0.add(a);
  45620. h1.add(b);
  45621. h2.add(c);
  45622. h3.add(d);
  45623. h4.add(e);
  45624. h5.add(f);
  45625. h6.add(g);
  45626. h7.add(h);
  45627. }
  45628. let result;
  45629. if (!mode384) {
  45630. result = new Uint8Array(64);
  45631. h0.copyTo(result, 0);
  45632. h1.copyTo(result, 8);
  45633. h2.copyTo(result, 16);
  45634. h3.copyTo(result, 24);
  45635. h4.copyTo(result, 32);
  45636. h5.copyTo(result, 40);
  45637. h6.copyTo(result, 48);
  45638. h7.copyTo(result, 56);
  45639. } else {
  45640. result = new Uint8Array(48);
  45641. h0.copyTo(result, 0);
  45642. h1.copyTo(result, 8);
  45643. h2.copyTo(result, 16);
  45644. h3.copyTo(result, 24);
  45645. h4.copyTo(result, 32);
  45646. h5.copyTo(result, 40);
  45647. }
  45648. return result;
  45649. }
  45650. return hash;
  45651. }();
  45652. exports.calculateSHA512 = calculateSHA512;
  45653. function calculateSHA384(data, offset, length) {
  45654. return calculateSHA512(data, offset, length, true);
  45655. }
  45656. class NullCipher {
  45657. decryptBlock(data) {
  45658. return data;
  45659. }
  45660. encrypt(data) {
  45661. return data;
  45662. }
  45663. }
  45664. class AESBaseCipher {
  45665. constructor() {
  45666. if (this.constructor === AESBaseCipher) {
  45667. (0, _util.unreachable)("Cannot initialize AESBaseCipher.");
  45668. }
  45669. 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]);
  45670. 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]);
  45671. 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]);
  45672. this._mixCol = new Uint8Array(256);
  45673. for (let i = 0; i < 256; i++) {
  45674. this._mixCol[i] = i < 128 ? i << 1 : i << 1 ^ 0x1b;
  45675. }
  45676. this.buffer = new Uint8Array(16);
  45677. this.bufferPosition = 0;
  45678. }
  45679. _expandKey(cipherKey) {
  45680. (0, _util.unreachable)("Cannot call `_expandKey` on the base class");
  45681. }
  45682. _decrypt(input, key) {
  45683. let t, u, v;
  45684. const state = new Uint8Array(16);
  45685. state.set(input);
  45686. for (let j = 0, k = this._keySize; j < 16; ++j, ++k) {
  45687. state[j] ^= key[k];
  45688. }
  45689. for (let i = this._cyclesOfRepetition - 1; i >= 1; --i) {
  45690. t = state[13];
  45691. state[13] = state[9];
  45692. state[9] = state[5];
  45693. state[5] = state[1];
  45694. state[1] = t;
  45695. t = state[14];
  45696. u = state[10];
  45697. state[14] = state[6];
  45698. state[10] = state[2];
  45699. state[6] = t;
  45700. state[2] = u;
  45701. t = state[15];
  45702. u = state[11];
  45703. v = state[7];
  45704. state[15] = state[3];
  45705. state[11] = t;
  45706. state[7] = u;
  45707. state[3] = v;
  45708. for (let j = 0; j < 16; ++j) {
  45709. state[j] = this._inv_s[state[j]];
  45710. }
  45711. for (let j = 0, k = i * 16; j < 16; ++j, ++k) {
  45712. state[j] ^= key[k];
  45713. }
  45714. for (let j = 0; j < 16; j += 4) {
  45715. const s0 = this._mix[state[j]];
  45716. const s1 = this._mix[state[j + 1]];
  45717. const s2 = this._mix[state[j + 2]];
  45718. const s3 = this._mix[state[j + 3]];
  45719. t = s0 ^ s1 >>> 8 ^ s1 << 24 ^ s2 >>> 16 ^ s2 << 16 ^ s3 >>> 24 ^ s3 << 8;
  45720. state[j] = t >>> 24 & 0xff;
  45721. state[j + 1] = t >> 16 & 0xff;
  45722. state[j + 2] = t >> 8 & 0xff;
  45723. state[j + 3] = t & 0xff;
  45724. }
  45725. }
  45726. t = state[13];
  45727. state[13] = state[9];
  45728. state[9] = state[5];
  45729. state[5] = state[1];
  45730. state[1] = t;
  45731. t = state[14];
  45732. u = state[10];
  45733. state[14] = state[6];
  45734. state[10] = state[2];
  45735. state[6] = t;
  45736. state[2] = u;
  45737. t = state[15];
  45738. u = state[11];
  45739. v = state[7];
  45740. state[15] = state[3];
  45741. state[11] = t;
  45742. state[7] = u;
  45743. state[3] = v;
  45744. for (let j = 0; j < 16; ++j) {
  45745. state[j] = this._inv_s[state[j]];
  45746. state[j] ^= key[j];
  45747. }
  45748. return state;
  45749. }
  45750. _encrypt(input, key) {
  45751. const s = this._s;
  45752. let t, u, v;
  45753. const state = new Uint8Array(16);
  45754. state.set(input);
  45755. for (let j = 0; j < 16; ++j) {
  45756. state[j] ^= key[j];
  45757. }
  45758. for (let i = 1; i < this._cyclesOfRepetition; i++) {
  45759. for (let j = 0; j < 16; ++j) {
  45760. state[j] = s[state[j]];
  45761. }
  45762. v = state[1];
  45763. state[1] = state[5];
  45764. state[5] = state[9];
  45765. state[9] = state[13];
  45766. state[13] = v;
  45767. v = state[2];
  45768. u = state[6];
  45769. state[2] = state[10];
  45770. state[6] = state[14];
  45771. state[10] = v;
  45772. state[14] = u;
  45773. v = state[3];
  45774. u = state[7];
  45775. t = state[11];
  45776. state[3] = state[15];
  45777. state[7] = v;
  45778. state[11] = u;
  45779. state[15] = t;
  45780. for (let j = 0; j < 16; j += 4) {
  45781. const s0 = state[j + 0];
  45782. const s1 = state[j + 1];
  45783. const s2 = state[j + 2];
  45784. const s3 = state[j + 3];
  45785. t = s0 ^ s1 ^ s2 ^ s3;
  45786. state[j + 0] ^= t ^ this._mixCol[s0 ^ s1];
  45787. state[j + 1] ^= t ^ this._mixCol[s1 ^ s2];
  45788. state[j + 2] ^= t ^ this._mixCol[s2 ^ s3];
  45789. state[j + 3] ^= t ^ this._mixCol[s3 ^ s0];
  45790. }
  45791. for (let j = 0, k = i * 16; j < 16; ++j, ++k) {
  45792. state[j] ^= key[k];
  45793. }
  45794. }
  45795. for (let j = 0; j < 16; ++j) {
  45796. state[j] = s[state[j]];
  45797. }
  45798. v = state[1];
  45799. state[1] = state[5];
  45800. state[5] = state[9];
  45801. state[9] = state[13];
  45802. state[13] = v;
  45803. v = state[2];
  45804. u = state[6];
  45805. state[2] = state[10];
  45806. state[6] = state[14];
  45807. state[10] = v;
  45808. state[14] = u;
  45809. v = state[3];
  45810. u = state[7];
  45811. t = state[11];
  45812. state[3] = state[15];
  45813. state[7] = v;
  45814. state[11] = u;
  45815. state[15] = t;
  45816. for (let j = 0, k = this._keySize; j < 16; ++j, ++k) {
  45817. state[j] ^= key[k];
  45818. }
  45819. return state;
  45820. }
  45821. _decryptBlock2(data, finalize) {
  45822. const sourceLength = data.length;
  45823. let buffer = this.buffer,
  45824. bufferLength = this.bufferPosition;
  45825. const result = [];
  45826. let iv = this.iv;
  45827. for (let i = 0; i < sourceLength; ++i) {
  45828. buffer[bufferLength] = data[i];
  45829. ++bufferLength;
  45830. if (bufferLength < 16) {
  45831. continue;
  45832. }
  45833. const plain = this._decrypt(buffer, this._key);
  45834. for (let j = 0; j < 16; ++j) {
  45835. plain[j] ^= iv[j];
  45836. }
  45837. iv = buffer;
  45838. result.push(plain);
  45839. buffer = new Uint8Array(16);
  45840. bufferLength = 0;
  45841. }
  45842. this.buffer = buffer;
  45843. this.bufferLength = bufferLength;
  45844. this.iv = iv;
  45845. if (result.length === 0) {
  45846. return new Uint8Array(0);
  45847. }
  45848. let outputLength = 16 * result.length;
  45849. if (finalize) {
  45850. const lastBlock = result.at(-1);
  45851. let psLen = lastBlock[15];
  45852. if (psLen <= 16) {
  45853. for (let i = 15, ii = 16 - psLen; i >= ii; --i) {
  45854. if (lastBlock[i] !== psLen) {
  45855. psLen = 0;
  45856. break;
  45857. }
  45858. }
  45859. outputLength -= psLen;
  45860. result[result.length - 1] = lastBlock.subarray(0, 16 - psLen);
  45861. }
  45862. }
  45863. const output = new Uint8Array(outputLength);
  45864. for (let i = 0, j = 0, ii = result.length; i < ii; ++i, j += 16) {
  45865. output.set(result[i], j);
  45866. }
  45867. return output;
  45868. }
  45869. decryptBlock(data, finalize) {
  45870. let iv = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
  45871. const sourceLength = data.length;
  45872. const buffer = this.buffer;
  45873. let bufferLength = this.bufferPosition;
  45874. if (iv) {
  45875. this.iv = iv;
  45876. } else {
  45877. for (let i = 0; bufferLength < 16 && i < sourceLength; ++i, ++bufferLength) {
  45878. buffer[bufferLength] = data[i];
  45879. }
  45880. if (bufferLength < 16) {
  45881. this.bufferLength = bufferLength;
  45882. return new Uint8Array(0);
  45883. }
  45884. this.iv = buffer;
  45885. data = data.subarray(16);
  45886. }
  45887. this.buffer = new Uint8Array(16);
  45888. this.bufferLength = 0;
  45889. this.decryptBlock = this._decryptBlock2;
  45890. return this.decryptBlock(data, finalize);
  45891. }
  45892. encrypt(data, iv) {
  45893. const sourceLength = data.length;
  45894. let buffer = this.buffer,
  45895. bufferLength = this.bufferPosition;
  45896. const result = [];
  45897. if (!iv) {
  45898. iv = new Uint8Array(16);
  45899. }
  45900. for (let i = 0; i < sourceLength; ++i) {
  45901. buffer[bufferLength] = data[i];
  45902. ++bufferLength;
  45903. if (bufferLength < 16) {
  45904. continue;
  45905. }
  45906. for (let j = 0; j < 16; ++j) {
  45907. buffer[j] ^= iv[j];
  45908. }
  45909. const cipher = this._encrypt(buffer, this._key);
  45910. iv = cipher;
  45911. result.push(cipher);
  45912. buffer = new Uint8Array(16);
  45913. bufferLength = 0;
  45914. }
  45915. this.buffer = buffer;
  45916. this.bufferLength = bufferLength;
  45917. this.iv = iv;
  45918. if (result.length === 0) {
  45919. return new Uint8Array(0);
  45920. }
  45921. const outputLength = 16 * result.length;
  45922. const output = new Uint8Array(outputLength);
  45923. for (let i = 0, j = 0, ii = result.length; i < ii; ++i, j += 16) {
  45924. output.set(result[i], j);
  45925. }
  45926. return output;
  45927. }
  45928. }
  45929. class AES128Cipher extends AESBaseCipher {
  45930. constructor(key) {
  45931. super();
  45932. this._cyclesOfRepetition = 10;
  45933. this._keySize = 160;
  45934. 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]);
  45935. this._key = this._expandKey(key);
  45936. }
  45937. _expandKey(cipherKey) {
  45938. const b = 176;
  45939. const s = this._s;
  45940. const rcon = this._rcon;
  45941. const result = new Uint8Array(b);
  45942. result.set(cipherKey);
  45943. for (let j = 16, i = 1; j < b; ++i) {
  45944. let t1 = result[j - 3];
  45945. let t2 = result[j - 2];
  45946. let t3 = result[j - 1];
  45947. let t4 = result[j - 4];
  45948. t1 = s[t1];
  45949. t2 = s[t2];
  45950. t3 = s[t3];
  45951. t4 = s[t4];
  45952. t1 ^= rcon[i];
  45953. for (let n = 0; n < 4; ++n) {
  45954. result[j] = t1 ^= result[j - 16];
  45955. j++;
  45956. result[j] = t2 ^= result[j - 16];
  45957. j++;
  45958. result[j] = t3 ^= result[j - 16];
  45959. j++;
  45960. result[j] = t4 ^= result[j - 16];
  45961. j++;
  45962. }
  45963. }
  45964. return result;
  45965. }
  45966. }
  45967. exports.AES128Cipher = AES128Cipher;
  45968. class AES256Cipher extends AESBaseCipher {
  45969. constructor(key) {
  45970. super();
  45971. this._cyclesOfRepetition = 14;
  45972. this._keySize = 224;
  45973. this._key = this._expandKey(key);
  45974. }
  45975. _expandKey(cipherKey) {
  45976. const b = 240;
  45977. const s = this._s;
  45978. const result = new Uint8Array(b);
  45979. result.set(cipherKey);
  45980. let r = 1;
  45981. let t1, t2, t3, t4;
  45982. for (let j = 32, i = 1; j < b; ++i) {
  45983. if (j % 32 === 16) {
  45984. t1 = s[t1];
  45985. t2 = s[t2];
  45986. t3 = s[t3];
  45987. t4 = s[t4];
  45988. } else if (j % 32 === 0) {
  45989. t1 = result[j - 3];
  45990. t2 = result[j - 2];
  45991. t3 = result[j - 1];
  45992. t4 = result[j - 4];
  45993. t1 = s[t1];
  45994. t2 = s[t2];
  45995. t3 = s[t3];
  45996. t4 = s[t4];
  45997. t1 ^= r;
  45998. if ((r <<= 1) >= 256) {
  45999. r = (r ^ 0x1b) & 0xff;
  46000. }
  46001. }
  46002. for (let n = 0; n < 4; ++n) {
  46003. result[j] = t1 ^= result[j - 32];
  46004. j++;
  46005. result[j] = t2 ^= result[j - 32];
  46006. j++;
  46007. result[j] = t3 ^= result[j - 32];
  46008. j++;
  46009. result[j] = t4 ^= result[j - 32];
  46010. j++;
  46011. }
  46012. }
  46013. return result;
  46014. }
  46015. }
  46016. exports.AES256Cipher = AES256Cipher;
  46017. class PDF17 {
  46018. checkOwnerPassword(password, ownerValidationSalt, userBytes, ownerPassword) {
  46019. const hashData = new Uint8Array(password.length + 56);
  46020. hashData.set(password, 0);
  46021. hashData.set(ownerValidationSalt, password.length);
  46022. hashData.set(userBytes, password.length + ownerValidationSalt.length);
  46023. const result = calculateSHA256(hashData, 0, hashData.length);
  46024. return (0, _util.isArrayEqual)(result, ownerPassword);
  46025. }
  46026. checkUserPassword(password, userValidationSalt, userPassword) {
  46027. const hashData = new Uint8Array(password.length + 8);
  46028. hashData.set(password, 0);
  46029. hashData.set(userValidationSalt, password.length);
  46030. const result = calculateSHA256(hashData, 0, hashData.length);
  46031. return (0, _util.isArrayEqual)(result, userPassword);
  46032. }
  46033. getOwnerKey(password, ownerKeySalt, userBytes, ownerEncryption) {
  46034. const hashData = new Uint8Array(password.length + 56);
  46035. hashData.set(password, 0);
  46036. hashData.set(ownerKeySalt, password.length);
  46037. hashData.set(userBytes, password.length + ownerKeySalt.length);
  46038. const key = calculateSHA256(hashData, 0, hashData.length);
  46039. const cipher = new AES256Cipher(key);
  46040. return cipher.decryptBlock(ownerEncryption, false, new Uint8Array(16));
  46041. }
  46042. getUserKey(password, userKeySalt, userEncryption) {
  46043. const hashData = new Uint8Array(password.length + 8);
  46044. hashData.set(password, 0);
  46045. hashData.set(userKeySalt, password.length);
  46046. const key = calculateSHA256(hashData, 0, hashData.length);
  46047. const cipher = new AES256Cipher(key);
  46048. return cipher.decryptBlock(userEncryption, false, new Uint8Array(16));
  46049. }
  46050. }
  46051. exports.PDF17 = PDF17;
  46052. class PDF20 {
  46053. _hash(password, input, userBytes) {
  46054. let k = calculateSHA256(input, 0, input.length).subarray(0, 32);
  46055. let e = [0];
  46056. let i = 0;
  46057. while (i < 64 || e.at(-1) > i - 32) {
  46058. const combinedLength = password.length + k.length + userBytes.length,
  46059. combinedArray = new Uint8Array(combinedLength);
  46060. let writeOffset = 0;
  46061. combinedArray.set(password, writeOffset);
  46062. writeOffset += password.length;
  46063. combinedArray.set(k, writeOffset);
  46064. writeOffset += k.length;
  46065. combinedArray.set(userBytes, writeOffset);
  46066. const k1 = new Uint8Array(combinedLength * 64);
  46067. for (let j = 0, pos = 0; j < 64; j++, pos += combinedLength) {
  46068. k1.set(combinedArray, pos);
  46069. }
  46070. const cipher = new AES128Cipher(k.subarray(0, 16));
  46071. e = cipher.encrypt(k1, k.subarray(16, 32));
  46072. const remainder = e.slice(0, 16).reduce((a, b) => a + b, 0) % 3;
  46073. if (remainder === 0) {
  46074. k = calculateSHA256(e, 0, e.length);
  46075. } else if (remainder === 1) {
  46076. k = calculateSHA384(e, 0, e.length);
  46077. } else if (remainder === 2) {
  46078. k = calculateSHA512(e, 0, e.length);
  46079. }
  46080. i++;
  46081. }
  46082. return k.subarray(0, 32);
  46083. }
  46084. checkOwnerPassword(password, ownerValidationSalt, userBytes, ownerPassword) {
  46085. const hashData = new Uint8Array(password.length + 56);
  46086. hashData.set(password, 0);
  46087. hashData.set(ownerValidationSalt, password.length);
  46088. hashData.set(userBytes, password.length + ownerValidationSalt.length);
  46089. const result = this._hash(password, hashData, userBytes);
  46090. return (0, _util.isArrayEqual)(result, ownerPassword);
  46091. }
  46092. checkUserPassword(password, userValidationSalt, userPassword) {
  46093. const hashData = new Uint8Array(password.length + 8);
  46094. hashData.set(password, 0);
  46095. hashData.set(userValidationSalt, password.length);
  46096. const result = this._hash(password, hashData, []);
  46097. return (0, _util.isArrayEqual)(result, userPassword);
  46098. }
  46099. getOwnerKey(password, ownerKeySalt, userBytes, ownerEncryption) {
  46100. const hashData = new Uint8Array(password.length + 56);
  46101. hashData.set(password, 0);
  46102. hashData.set(ownerKeySalt, password.length);
  46103. hashData.set(userBytes, password.length + ownerKeySalt.length);
  46104. const key = this._hash(password, hashData, userBytes);
  46105. const cipher = new AES256Cipher(key);
  46106. return cipher.decryptBlock(ownerEncryption, false, new Uint8Array(16));
  46107. }
  46108. getUserKey(password, userKeySalt, userEncryption) {
  46109. const hashData = new Uint8Array(password.length + 8);
  46110. hashData.set(password, 0);
  46111. hashData.set(userKeySalt, password.length);
  46112. const key = this._hash(password, hashData, []);
  46113. const cipher = new AES256Cipher(key);
  46114. return cipher.decryptBlock(userEncryption, false, new Uint8Array(16));
  46115. }
  46116. }
  46117. exports.PDF20 = PDF20;
  46118. class CipherTransform {
  46119. constructor(stringCipherConstructor, streamCipherConstructor) {
  46120. this.StringCipherConstructor = stringCipherConstructor;
  46121. this.StreamCipherConstructor = streamCipherConstructor;
  46122. }
  46123. createStream(stream, length) {
  46124. const cipher = new this.StreamCipherConstructor();
  46125. return new _decrypt_stream.DecryptStream(stream, length, function cipherTransformDecryptStream(data, finalize) {
  46126. return cipher.decryptBlock(data, finalize);
  46127. });
  46128. }
  46129. decryptString(s) {
  46130. const cipher = new this.StringCipherConstructor();
  46131. let data = (0, _util.stringToBytes)(s);
  46132. data = cipher.decryptBlock(data, true);
  46133. return (0, _util.bytesToString)(data);
  46134. }
  46135. encryptString(s) {
  46136. const cipher = new this.StringCipherConstructor();
  46137. if (cipher instanceof AESBaseCipher) {
  46138. const strLen = s.length;
  46139. const pad = 16 - strLen % 16;
  46140. s += String.fromCharCode(pad).repeat(pad);
  46141. const iv = new Uint8Array(16);
  46142. if (typeof crypto !== "undefined") {
  46143. crypto.getRandomValues(iv);
  46144. } else {
  46145. for (let i = 0; i < 16; i++) {
  46146. iv[i] = Math.floor(256 * Math.random());
  46147. }
  46148. }
  46149. let data = (0, _util.stringToBytes)(s);
  46150. data = cipher.encrypt(data, iv);
  46151. const buf = new Uint8Array(16 + data.length);
  46152. buf.set(iv);
  46153. buf.set(data, 16);
  46154. return (0, _util.bytesToString)(buf);
  46155. }
  46156. let data = (0, _util.stringToBytes)(s);
  46157. data = cipher.encrypt(data);
  46158. return (0, _util.bytesToString)(data);
  46159. }
  46160. }
  46161. const CipherTransformFactory = function CipherTransformFactoryClosure() {
  46162. 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]);
  46163. function createEncryptionKey20(revision, password, ownerPassword, ownerValidationSalt, ownerKeySalt, uBytes, userPassword, userValidationSalt, userKeySalt, ownerEncryption, userEncryption, perms) {
  46164. if (password) {
  46165. const passwordLength = Math.min(127, password.length);
  46166. password = password.subarray(0, passwordLength);
  46167. } else {
  46168. password = [];
  46169. }
  46170. const pdfAlgorithm = revision === 6 ? new PDF20() : new PDF17();
  46171. if (pdfAlgorithm.checkUserPassword(password, userValidationSalt, userPassword)) {
  46172. return pdfAlgorithm.getUserKey(password, userKeySalt, userEncryption);
  46173. } else if (password.length && pdfAlgorithm.checkOwnerPassword(password, ownerValidationSalt, uBytes, ownerPassword)) {
  46174. return pdfAlgorithm.getOwnerKey(password, ownerKeySalt, uBytes, ownerEncryption);
  46175. }
  46176. return null;
  46177. }
  46178. function prepareKeyData(fileId, password, ownerPassword, userPassword, flags, revision, keyLength, encryptMetadata) {
  46179. const hashDataSize = 40 + ownerPassword.length + fileId.length;
  46180. const hashData = new Uint8Array(hashDataSize);
  46181. let i = 0,
  46182. j,
  46183. n;
  46184. if (password) {
  46185. n = Math.min(32, password.length);
  46186. for (; i < n; ++i) {
  46187. hashData[i] = password[i];
  46188. }
  46189. }
  46190. j = 0;
  46191. while (i < 32) {
  46192. hashData[i++] = defaultPasswordBytes[j++];
  46193. }
  46194. for (j = 0, n = ownerPassword.length; j < n; ++j) {
  46195. hashData[i++] = ownerPassword[j];
  46196. }
  46197. hashData[i++] = flags & 0xff;
  46198. hashData[i++] = flags >> 8 & 0xff;
  46199. hashData[i++] = flags >> 16 & 0xff;
  46200. hashData[i++] = flags >>> 24 & 0xff;
  46201. for (j = 0, n = fileId.length; j < n; ++j) {
  46202. hashData[i++] = fileId[j];
  46203. }
  46204. if (revision >= 4 && !encryptMetadata) {
  46205. hashData[i++] = 0xff;
  46206. hashData[i++] = 0xff;
  46207. hashData[i++] = 0xff;
  46208. hashData[i++] = 0xff;
  46209. }
  46210. let hash = calculateMD5(hashData, 0, i);
  46211. const keyLengthInBytes = keyLength >> 3;
  46212. if (revision >= 3) {
  46213. for (j = 0; j < 50; ++j) {
  46214. hash = calculateMD5(hash, 0, keyLengthInBytes);
  46215. }
  46216. }
  46217. const encryptionKey = hash.subarray(0, keyLengthInBytes);
  46218. let cipher, checkData;
  46219. if (revision >= 3) {
  46220. for (i = 0; i < 32; ++i) {
  46221. hashData[i] = defaultPasswordBytes[i];
  46222. }
  46223. for (j = 0, n = fileId.length; j < n; ++j) {
  46224. hashData[i++] = fileId[j];
  46225. }
  46226. cipher = new ARCFourCipher(encryptionKey);
  46227. checkData = cipher.encryptBlock(calculateMD5(hashData, 0, i));
  46228. n = encryptionKey.length;
  46229. const derivedKey = new Uint8Array(n);
  46230. for (j = 1; j <= 19; ++j) {
  46231. for (let k = 0; k < n; ++k) {
  46232. derivedKey[k] = encryptionKey[k] ^ j;
  46233. }
  46234. cipher = new ARCFourCipher(derivedKey);
  46235. checkData = cipher.encryptBlock(checkData);
  46236. }
  46237. for (j = 0, n = checkData.length; j < n; ++j) {
  46238. if (userPassword[j] !== checkData[j]) {
  46239. return null;
  46240. }
  46241. }
  46242. } else {
  46243. cipher = new ARCFourCipher(encryptionKey);
  46244. checkData = cipher.encryptBlock(defaultPasswordBytes);
  46245. for (j = 0, n = checkData.length; j < n; ++j) {
  46246. if (userPassword[j] !== checkData[j]) {
  46247. return null;
  46248. }
  46249. }
  46250. }
  46251. return encryptionKey;
  46252. }
  46253. function decodeUserPassword(password, ownerPassword, revision, keyLength) {
  46254. const hashData = new Uint8Array(32);
  46255. let i = 0;
  46256. const n = Math.min(32, password.length);
  46257. for (; i < n; ++i) {
  46258. hashData[i] = password[i];
  46259. }
  46260. let j = 0;
  46261. while (i < 32) {
  46262. hashData[i++] = defaultPasswordBytes[j++];
  46263. }
  46264. let hash = calculateMD5(hashData, 0, i);
  46265. const keyLengthInBytes = keyLength >> 3;
  46266. if (revision >= 3) {
  46267. for (j = 0; j < 50; ++j) {
  46268. hash = calculateMD5(hash, 0, hash.length);
  46269. }
  46270. }
  46271. let cipher, userPassword;
  46272. if (revision >= 3) {
  46273. userPassword = ownerPassword;
  46274. const derivedKey = new Uint8Array(keyLengthInBytes);
  46275. for (j = 19; j >= 0; j--) {
  46276. for (let k = 0; k < keyLengthInBytes; ++k) {
  46277. derivedKey[k] = hash[k] ^ j;
  46278. }
  46279. cipher = new ARCFourCipher(derivedKey);
  46280. userPassword = cipher.encryptBlock(userPassword);
  46281. }
  46282. } else {
  46283. cipher = new ARCFourCipher(hash.subarray(0, keyLengthInBytes));
  46284. userPassword = cipher.encryptBlock(ownerPassword);
  46285. }
  46286. return userPassword;
  46287. }
  46288. const identityName = _primitives.Name.get("Identity");
  46289. function buildObjectKey(num, gen, encryptionKey) {
  46290. let isAes = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
  46291. const key = new Uint8Array(encryptionKey.length + 9);
  46292. const n = encryptionKey.length;
  46293. let i;
  46294. for (i = 0; i < n; ++i) {
  46295. key[i] = encryptionKey[i];
  46296. }
  46297. key[i++] = num & 0xff;
  46298. key[i++] = num >> 8 & 0xff;
  46299. key[i++] = num >> 16 & 0xff;
  46300. key[i++] = gen & 0xff;
  46301. key[i++] = gen >> 8 & 0xff;
  46302. if (isAes) {
  46303. key[i++] = 0x73;
  46304. key[i++] = 0x41;
  46305. key[i++] = 0x6c;
  46306. key[i++] = 0x54;
  46307. }
  46308. const hash = calculateMD5(key, 0, i);
  46309. return hash.subarray(0, Math.min(encryptionKey.length + 5, 16));
  46310. }
  46311. function buildCipherConstructor(cf, name, num, gen, key) {
  46312. if (!(name instanceof _primitives.Name)) {
  46313. throw new _util.FormatError("Invalid crypt filter name.");
  46314. }
  46315. const cryptFilter = cf.get(name.name);
  46316. let cfm;
  46317. if (cryptFilter !== null && cryptFilter !== undefined) {
  46318. cfm = cryptFilter.get("CFM");
  46319. }
  46320. if (!cfm || cfm.name === "None") {
  46321. return function cipherTransformFactoryBuildCipherConstructorNone() {
  46322. return new NullCipher();
  46323. };
  46324. }
  46325. if (cfm.name === "V2") {
  46326. return function cipherTransformFactoryBuildCipherConstructorV2() {
  46327. return new ARCFourCipher(buildObjectKey(num, gen, key, false));
  46328. };
  46329. }
  46330. if (cfm.name === "AESV2") {
  46331. return function cipherTransformFactoryBuildCipherConstructorAESV2() {
  46332. return new AES128Cipher(buildObjectKey(num, gen, key, true));
  46333. };
  46334. }
  46335. if (cfm.name === "AESV3") {
  46336. return function cipherTransformFactoryBuildCipherConstructorAESV3() {
  46337. return new AES256Cipher(key);
  46338. };
  46339. }
  46340. throw new _util.FormatError("Unknown crypto method");
  46341. }
  46342. class CipherTransformFactory {
  46343. constructor(dict, fileId, password) {
  46344. const filter = dict.get("Filter");
  46345. if (!(0, _primitives.isName)(filter, "Standard")) {
  46346. throw new _util.FormatError("unknown encryption method");
  46347. }
  46348. this.filterName = filter.name;
  46349. this.dict = dict;
  46350. const algorithm = dict.get("V");
  46351. if (!Number.isInteger(algorithm) || algorithm !== 1 && algorithm !== 2 && algorithm !== 4 && algorithm !== 5) {
  46352. throw new _util.FormatError("unsupported encryption algorithm");
  46353. }
  46354. this.algorithm = algorithm;
  46355. let keyLength = dict.get("Length");
  46356. if (!keyLength) {
  46357. if (algorithm <= 3) {
  46358. keyLength = 40;
  46359. } else {
  46360. const cfDict = dict.get("CF");
  46361. const streamCryptoName = dict.get("StmF");
  46362. if (cfDict instanceof _primitives.Dict && streamCryptoName instanceof _primitives.Name) {
  46363. cfDict.suppressEncryption = true;
  46364. const handlerDict = cfDict.get(streamCryptoName.name);
  46365. keyLength = handlerDict?.get("Length") || 128;
  46366. if (keyLength < 40) {
  46367. keyLength <<= 3;
  46368. }
  46369. }
  46370. }
  46371. }
  46372. if (!Number.isInteger(keyLength) || keyLength < 40 || keyLength % 8 !== 0) {
  46373. throw new _util.FormatError("invalid key length");
  46374. }
  46375. const ownerBytes = (0, _util.stringToBytes)(dict.get("O")),
  46376. userBytes = (0, _util.stringToBytes)(dict.get("U"));
  46377. const ownerPassword = ownerBytes.subarray(0, 32);
  46378. const userPassword = userBytes.subarray(0, 32);
  46379. const flags = dict.get("P");
  46380. const revision = dict.get("R");
  46381. const encryptMetadata = (algorithm === 4 || algorithm === 5) && dict.get("EncryptMetadata") !== false;
  46382. this.encryptMetadata = encryptMetadata;
  46383. const fileIdBytes = (0, _util.stringToBytes)(fileId);
  46384. let passwordBytes;
  46385. if (password) {
  46386. if (revision === 6) {
  46387. try {
  46388. password = (0, _util.utf8StringToString)(password);
  46389. } catch {
  46390. (0, _util.warn)("CipherTransformFactory: Unable to convert UTF8 encoded password.");
  46391. }
  46392. }
  46393. passwordBytes = (0, _util.stringToBytes)(password);
  46394. }
  46395. let encryptionKey;
  46396. if (algorithm !== 5) {
  46397. encryptionKey = prepareKeyData(fileIdBytes, passwordBytes, ownerPassword, userPassword, flags, revision, keyLength, encryptMetadata);
  46398. } else {
  46399. const ownerValidationSalt = ownerBytes.subarray(32, 40);
  46400. const ownerKeySalt = ownerBytes.subarray(40, 48);
  46401. const uBytes = userBytes.subarray(0, 48);
  46402. const userValidationSalt = userBytes.subarray(32, 40);
  46403. const userKeySalt = userBytes.subarray(40, 48);
  46404. const ownerEncryption = (0, _util.stringToBytes)(dict.get("OE"));
  46405. const userEncryption = (0, _util.stringToBytes)(dict.get("UE"));
  46406. const perms = (0, _util.stringToBytes)(dict.get("Perms"));
  46407. encryptionKey = createEncryptionKey20(revision, passwordBytes, ownerPassword, ownerValidationSalt, ownerKeySalt, uBytes, userPassword, userValidationSalt, userKeySalt, ownerEncryption, userEncryption, perms);
  46408. }
  46409. if (!encryptionKey && !password) {
  46410. throw new _util.PasswordException("No password given", _util.PasswordResponses.NEED_PASSWORD);
  46411. } else if (!encryptionKey && password) {
  46412. const decodedPassword = decodeUserPassword(passwordBytes, ownerPassword, revision, keyLength);
  46413. encryptionKey = prepareKeyData(fileIdBytes, decodedPassword, ownerPassword, userPassword, flags, revision, keyLength, encryptMetadata);
  46414. }
  46415. if (!encryptionKey) {
  46416. throw new _util.PasswordException("Incorrect Password", _util.PasswordResponses.INCORRECT_PASSWORD);
  46417. }
  46418. this.encryptionKey = encryptionKey;
  46419. if (algorithm >= 4) {
  46420. const cf = dict.get("CF");
  46421. if (cf instanceof _primitives.Dict) {
  46422. cf.suppressEncryption = true;
  46423. }
  46424. this.cf = cf;
  46425. this.stmf = dict.get("StmF") || identityName;
  46426. this.strf = dict.get("StrF") || identityName;
  46427. this.eff = dict.get("EFF") || this.stmf;
  46428. }
  46429. }
  46430. createCipherTransform(num, gen) {
  46431. if (this.algorithm === 4 || this.algorithm === 5) {
  46432. return new CipherTransform(buildCipherConstructor(this.cf, this.strf, num, gen, this.encryptionKey), buildCipherConstructor(this.cf, this.stmf, num, gen, this.encryptionKey));
  46433. }
  46434. const key = buildObjectKey(num, gen, this.encryptionKey, false);
  46435. const cipherConstructor = function buildCipherCipherConstructor() {
  46436. return new ARCFourCipher(key);
  46437. };
  46438. return new CipherTransform(cipherConstructor, cipherConstructor);
  46439. }
  46440. }
  46441. return CipherTransformFactory;
  46442. }();
  46443. exports.CipherTransformFactory = CipherTransformFactory;
  46444. /***/ }),
  46445. /* 220 */
  46446. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  46447. Object.defineProperty(exports, "__esModule", ({
  46448. value: true
  46449. }));
  46450. exports.DecryptStream = void 0;
  46451. var _decode_stream = __w_pdfjs_require__(169);
  46452. const chunkSize = 512;
  46453. class DecryptStream extends _decode_stream.DecodeStream {
  46454. constructor(str, maybeLength, decrypt) {
  46455. super(maybeLength);
  46456. this.str = str;
  46457. this.dict = str.dict;
  46458. this.decrypt = decrypt;
  46459. this.nextChunk = null;
  46460. this.initialized = false;
  46461. }
  46462. readBlock() {
  46463. let chunk;
  46464. if (this.initialized) {
  46465. chunk = this.nextChunk;
  46466. } else {
  46467. chunk = this.str.getBytes(chunkSize);
  46468. this.initialized = true;
  46469. }
  46470. if (!chunk || chunk.length === 0) {
  46471. this.eof = true;
  46472. return;
  46473. }
  46474. this.nextChunk = this.str.getBytes(chunkSize);
  46475. const hasMoreData = this.nextChunk?.length > 0;
  46476. const decrypt = this.decrypt;
  46477. chunk = decrypt(chunk, !hasMoreData);
  46478. const bufferLength = this.bufferLength,
  46479. newLength = bufferLength + chunk.length,
  46480. buffer = this.ensureBuffer(newLength);
  46481. buffer.set(chunk, bufferLength);
  46482. this.bufferLength = newLength;
  46483. }
  46484. }
  46485. exports.DecryptStream = DecryptStream;
  46486. /***/ }),
  46487. /* 221 */
  46488. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  46489. Object.defineProperty(exports, "__esModule", ({
  46490. value: true
  46491. }));
  46492. exports.Catalog = void 0;
  46493. __w_pdfjs_require__(84);
  46494. __w_pdfjs_require__(93);
  46495. __w_pdfjs_require__(94);
  46496. __w_pdfjs_require__(97);
  46497. __w_pdfjs_require__(99);
  46498. __w_pdfjs_require__(101);
  46499. __w_pdfjs_require__(105);
  46500. __w_pdfjs_require__(108);
  46501. __w_pdfjs_require__(115);
  46502. __w_pdfjs_require__(140);
  46503. __w_pdfjs_require__(2);
  46504. var _core_utils = __w_pdfjs_require__(150);
  46505. var _util = __w_pdfjs_require__(145);
  46506. var _primitives = __w_pdfjs_require__(151);
  46507. var _name_number_tree = __w_pdfjs_require__(222);
  46508. var _base_stream = __w_pdfjs_require__(152);
  46509. var _cleanup_helper = __w_pdfjs_require__(223);
  46510. var _colorspace = __w_pdfjs_require__(163);
  46511. var _file_spec = __w_pdfjs_require__(224);
  46512. var _image_utils = __w_pdfjs_require__(210);
  46513. var _metadata_parser = __w_pdfjs_require__(225);
  46514. var _struct_tree = __w_pdfjs_require__(226);
  46515. function fetchDestination(dest) {
  46516. if (dest instanceof _primitives.Dict) {
  46517. dest = dest.get("D");
  46518. }
  46519. return Array.isArray(dest) ? dest : null;
  46520. }
  46521. class Catalog {
  46522. constructor(pdfManager, xref) {
  46523. this.pdfManager = pdfManager;
  46524. this.xref = xref;
  46525. this._catDict = xref.getCatalogObj();
  46526. if (!(this._catDict instanceof _primitives.Dict)) {
  46527. throw new _util.FormatError("Catalog object is not a dictionary.");
  46528. }
  46529. this.toplevelPagesDict;
  46530. this._actualNumPages = null;
  46531. this.fontCache = new _primitives.RefSetCache();
  46532. this.builtInCMapCache = new Map();
  46533. this.standardFontDataCache = new Map();
  46534. this.globalImageCache = new _image_utils.GlobalImageCache();
  46535. this.pageKidsCountCache = new _primitives.RefSetCache();
  46536. this.pageIndexCache = new _primitives.RefSetCache();
  46537. this.nonBlendModesSet = new _primitives.RefSet();
  46538. this.systemFontCache = new Map();
  46539. }
  46540. get version() {
  46541. const version = this._catDict.get("Version");
  46542. if (version instanceof _primitives.Name) {
  46543. if (_core_utils.PDF_VERSION_REGEXP.test(version.name)) {
  46544. return (0, _util.shadow)(this, "version", version.name);
  46545. }
  46546. (0, _util.warn)(`Invalid PDF catalog version: ${version.name}`);
  46547. }
  46548. return (0, _util.shadow)(this, "version", null);
  46549. }
  46550. get lang() {
  46551. const lang = this._catDict.get("Lang");
  46552. return (0, _util.shadow)(this, "lang", typeof lang === "string" ? (0, _util.stringToPDFString)(lang) : null);
  46553. }
  46554. get needsRendering() {
  46555. const needsRendering = this._catDict.get("NeedsRendering");
  46556. return (0, _util.shadow)(this, "needsRendering", typeof needsRendering === "boolean" ? needsRendering : false);
  46557. }
  46558. get collection() {
  46559. let collection = null;
  46560. try {
  46561. const obj = this._catDict.get("Collection");
  46562. if (obj instanceof _primitives.Dict && obj.size > 0) {
  46563. collection = obj;
  46564. }
  46565. } catch (ex) {
  46566. if (ex instanceof _core_utils.MissingDataException) {
  46567. throw ex;
  46568. }
  46569. (0, _util.info)("Cannot fetch Collection entry; assuming no collection is present.");
  46570. }
  46571. return (0, _util.shadow)(this, "collection", collection);
  46572. }
  46573. get acroForm() {
  46574. let acroForm = null;
  46575. try {
  46576. const obj = this._catDict.get("AcroForm");
  46577. if (obj instanceof _primitives.Dict && obj.size > 0) {
  46578. acroForm = obj;
  46579. }
  46580. } catch (ex) {
  46581. if (ex instanceof _core_utils.MissingDataException) {
  46582. throw ex;
  46583. }
  46584. (0, _util.info)("Cannot fetch AcroForm entry; assuming no forms are present.");
  46585. }
  46586. return (0, _util.shadow)(this, "acroForm", acroForm);
  46587. }
  46588. get acroFormRef() {
  46589. const value = this._catDict.getRaw("AcroForm");
  46590. return (0, _util.shadow)(this, "acroFormRef", value instanceof _primitives.Ref ? value : null);
  46591. }
  46592. get metadata() {
  46593. const streamRef = this._catDict.getRaw("Metadata");
  46594. if (!(streamRef instanceof _primitives.Ref)) {
  46595. return (0, _util.shadow)(this, "metadata", null);
  46596. }
  46597. let metadata = null;
  46598. try {
  46599. const stream = this.xref.fetch(streamRef, !this.xref.encrypt?.encryptMetadata);
  46600. if (stream instanceof _base_stream.BaseStream && stream.dict instanceof _primitives.Dict) {
  46601. const type = stream.dict.get("Type");
  46602. const subtype = stream.dict.get("Subtype");
  46603. if ((0, _primitives.isName)(type, "Metadata") && (0, _primitives.isName)(subtype, "XML")) {
  46604. const data = (0, _util.stringToUTF8String)(stream.getString());
  46605. if (data) {
  46606. metadata = new _metadata_parser.MetadataParser(data).serializable;
  46607. }
  46608. }
  46609. }
  46610. } catch (ex) {
  46611. if (ex instanceof _core_utils.MissingDataException) {
  46612. throw ex;
  46613. }
  46614. (0, _util.info)(`Skipping invalid Metadata: "${ex}".`);
  46615. }
  46616. return (0, _util.shadow)(this, "metadata", metadata);
  46617. }
  46618. get markInfo() {
  46619. let markInfo = null;
  46620. try {
  46621. markInfo = this._readMarkInfo();
  46622. } catch (ex) {
  46623. if (ex instanceof _core_utils.MissingDataException) {
  46624. throw ex;
  46625. }
  46626. (0, _util.warn)("Unable to read mark info.");
  46627. }
  46628. return (0, _util.shadow)(this, "markInfo", markInfo);
  46629. }
  46630. _readMarkInfo() {
  46631. const obj = this._catDict.get("MarkInfo");
  46632. if (!(obj instanceof _primitives.Dict)) {
  46633. return null;
  46634. }
  46635. const markInfo = {
  46636. Marked: false,
  46637. UserProperties: false,
  46638. Suspects: false
  46639. };
  46640. for (const key in markInfo) {
  46641. const value = obj.get(key);
  46642. if (typeof value === "boolean") {
  46643. markInfo[key] = value;
  46644. }
  46645. }
  46646. return markInfo;
  46647. }
  46648. get structTreeRoot() {
  46649. let structTree = null;
  46650. try {
  46651. structTree = this._readStructTreeRoot();
  46652. } catch (ex) {
  46653. if (ex instanceof _core_utils.MissingDataException) {
  46654. throw ex;
  46655. }
  46656. (0, _util.warn)("Unable read to structTreeRoot info.");
  46657. }
  46658. return (0, _util.shadow)(this, "structTreeRoot", structTree);
  46659. }
  46660. _readStructTreeRoot() {
  46661. const obj = this._catDict.get("StructTreeRoot");
  46662. if (!(obj instanceof _primitives.Dict)) {
  46663. return null;
  46664. }
  46665. const root = new _struct_tree.StructTreeRoot(obj);
  46666. root.init();
  46667. return root;
  46668. }
  46669. get toplevelPagesDict() {
  46670. const pagesObj = this._catDict.get("Pages");
  46671. if (!(pagesObj instanceof _primitives.Dict)) {
  46672. throw new _util.FormatError("Invalid top-level pages dictionary.");
  46673. }
  46674. return (0, _util.shadow)(this, "toplevelPagesDict", pagesObj);
  46675. }
  46676. get documentOutline() {
  46677. let obj = null;
  46678. try {
  46679. obj = this._readDocumentOutline();
  46680. } catch (ex) {
  46681. if (ex instanceof _core_utils.MissingDataException) {
  46682. throw ex;
  46683. }
  46684. (0, _util.warn)("Unable to read document outline.");
  46685. }
  46686. return (0, _util.shadow)(this, "documentOutline", obj);
  46687. }
  46688. _readDocumentOutline() {
  46689. let obj = this._catDict.get("Outlines");
  46690. if (!(obj instanceof _primitives.Dict)) {
  46691. return null;
  46692. }
  46693. obj = obj.getRaw("First");
  46694. if (!(obj instanceof _primitives.Ref)) {
  46695. return null;
  46696. }
  46697. const root = {
  46698. items: []
  46699. };
  46700. const queue = [{
  46701. obj,
  46702. parent: root
  46703. }];
  46704. const processed = new _primitives.RefSet();
  46705. processed.put(obj);
  46706. const xref = this.xref,
  46707. blackColor = new Uint8ClampedArray(3);
  46708. while (queue.length > 0) {
  46709. const i = queue.shift();
  46710. const outlineDict = xref.fetchIfRef(i.obj);
  46711. if (outlineDict === null) {
  46712. continue;
  46713. }
  46714. if (!outlineDict.has("Title")) {
  46715. throw new _util.FormatError("Invalid outline item encountered.");
  46716. }
  46717. const data = {
  46718. url: null,
  46719. dest: null,
  46720. action: null
  46721. };
  46722. Catalog.parseDestDictionary({
  46723. destDict: outlineDict,
  46724. resultObj: data,
  46725. docBaseUrl: this.pdfManager.docBaseUrl,
  46726. docAttachments: this.attachments
  46727. });
  46728. const title = outlineDict.get("Title");
  46729. const flags = outlineDict.get("F") || 0;
  46730. const color = outlineDict.getArray("C");
  46731. const count = outlineDict.get("Count");
  46732. let rgbColor = blackColor;
  46733. if (Array.isArray(color) && color.length === 3 && (color[0] !== 0 || color[1] !== 0 || color[2] !== 0)) {
  46734. rgbColor = _colorspace.ColorSpace.singletons.rgb.getRgb(color, 0);
  46735. }
  46736. const outlineItem = {
  46737. action: data.action,
  46738. attachment: data.attachment,
  46739. dest: data.dest,
  46740. url: data.url,
  46741. unsafeUrl: data.unsafeUrl,
  46742. newWindow: data.newWindow,
  46743. setOCGState: data.setOCGState,
  46744. title: (0, _util.stringToPDFString)(title),
  46745. color: rgbColor,
  46746. count: Number.isInteger(count) ? count : undefined,
  46747. bold: !!(flags & 2),
  46748. italic: !!(flags & 1),
  46749. items: []
  46750. };
  46751. i.parent.items.push(outlineItem);
  46752. obj = outlineDict.getRaw("First");
  46753. if (obj instanceof _primitives.Ref && !processed.has(obj)) {
  46754. queue.push({
  46755. obj,
  46756. parent: outlineItem
  46757. });
  46758. processed.put(obj);
  46759. }
  46760. obj = outlineDict.getRaw("Next");
  46761. if (obj instanceof _primitives.Ref && !processed.has(obj)) {
  46762. queue.push({
  46763. obj,
  46764. parent: i.parent
  46765. });
  46766. processed.put(obj);
  46767. }
  46768. }
  46769. return root.items.length > 0 ? root.items : null;
  46770. }
  46771. get permissions() {
  46772. let permissions = null;
  46773. try {
  46774. permissions = this._readPermissions();
  46775. } catch (ex) {
  46776. if (ex instanceof _core_utils.MissingDataException) {
  46777. throw ex;
  46778. }
  46779. (0, _util.warn)("Unable to read permissions.");
  46780. }
  46781. return (0, _util.shadow)(this, "permissions", permissions);
  46782. }
  46783. _readPermissions() {
  46784. const encrypt = this.xref.trailer.get("Encrypt");
  46785. if (!(encrypt instanceof _primitives.Dict)) {
  46786. return null;
  46787. }
  46788. let flags = encrypt.get("P");
  46789. if (typeof flags !== "number") {
  46790. return null;
  46791. }
  46792. flags += 2 ** 32;
  46793. const permissions = [];
  46794. for (const key in _util.PermissionFlag) {
  46795. const value = _util.PermissionFlag[key];
  46796. if (flags & value) {
  46797. permissions.push(value);
  46798. }
  46799. }
  46800. return permissions;
  46801. }
  46802. get optionalContentConfig() {
  46803. let config = null;
  46804. try {
  46805. const properties = this._catDict.get("OCProperties");
  46806. if (!properties) {
  46807. return (0, _util.shadow)(this, "optionalContentConfig", null);
  46808. }
  46809. const defaultConfig = properties.get("D");
  46810. if (!defaultConfig) {
  46811. return (0, _util.shadow)(this, "optionalContentConfig", null);
  46812. }
  46813. const groupsData = properties.get("OCGs");
  46814. if (!Array.isArray(groupsData)) {
  46815. return (0, _util.shadow)(this, "optionalContentConfig", null);
  46816. }
  46817. const groups = [];
  46818. const groupRefs = [];
  46819. for (const groupRef of groupsData) {
  46820. if (!(groupRef instanceof _primitives.Ref)) {
  46821. continue;
  46822. }
  46823. groupRefs.push(groupRef);
  46824. const group = this.xref.fetchIfRef(groupRef);
  46825. groups.push({
  46826. id: groupRef.toString(),
  46827. name: typeof group.get("Name") === "string" ? (0, _util.stringToPDFString)(group.get("Name")) : null,
  46828. intent: typeof group.get("Intent") === "string" ? (0, _util.stringToPDFString)(group.get("Intent")) : null
  46829. });
  46830. }
  46831. config = this._readOptionalContentConfig(defaultConfig, groupRefs);
  46832. config.groups = groups;
  46833. } catch (ex) {
  46834. if (ex instanceof _core_utils.MissingDataException) {
  46835. throw ex;
  46836. }
  46837. (0, _util.warn)(`Unable to read optional content config: ${ex}`);
  46838. }
  46839. return (0, _util.shadow)(this, "optionalContentConfig", config);
  46840. }
  46841. _readOptionalContentConfig(config, contentGroupRefs) {
  46842. function parseOnOff(refs) {
  46843. const onParsed = [];
  46844. if (Array.isArray(refs)) {
  46845. for (const value of refs) {
  46846. if (!(value instanceof _primitives.Ref)) {
  46847. continue;
  46848. }
  46849. if (contentGroupRefs.includes(value)) {
  46850. onParsed.push(value.toString());
  46851. }
  46852. }
  46853. }
  46854. return onParsed;
  46855. }
  46856. function parseOrder(refs) {
  46857. let nestedLevels = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
  46858. if (!Array.isArray(refs)) {
  46859. return null;
  46860. }
  46861. const order = [];
  46862. for (const value of refs) {
  46863. if (value instanceof _primitives.Ref && contentGroupRefs.includes(value)) {
  46864. parsedOrderRefs.put(value);
  46865. order.push(value.toString());
  46866. continue;
  46867. }
  46868. const nestedOrder = parseNestedOrder(value, nestedLevels);
  46869. if (nestedOrder) {
  46870. order.push(nestedOrder);
  46871. }
  46872. }
  46873. if (nestedLevels > 0) {
  46874. return order;
  46875. }
  46876. const hiddenGroups = [];
  46877. for (const groupRef of contentGroupRefs) {
  46878. if (parsedOrderRefs.has(groupRef)) {
  46879. continue;
  46880. }
  46881. hiddenGroups.push(groupRef.toString());
  46882. }
  46883. if (hiddenGroups.length) {
  46884. order.push({
  46885. name: null,
  46886. order: hiddenGroups
  46887. });
  46888. }
  46889. return order;
  46890. }
  46891. function parseNestedOrder(ref, nestedLevels) {
  46892. if (++nestedLevels > MAX_NESTED_LEVELS) {
  46893. (0, _util.warn)("parseNestedOrder - reached MAX_NESTED_LEVELS.");
  46894. return null;
  46895. }
  46896. const value = xref.fetchIfRef(ref);
  46897. if (!Array.isArray(value)) {
  46898. return null;
  46899. }
  46900. const nestedName = xref.fetchIfRef(value[0]);
  46901. if (typeof nestedName !== "string") {
  46902. return null;
  46903. }
  46904. const nestedOrder = parseOrder(value.slice(1), nestedLevels);
  46905. if (!nestedOrder || !nestedOrder.length) {
  46906. return null;
  46907. }
  46908. return {
  46909. name: (0, _util.stringToPDFString)(nestedName),
  46910. order: nestedOrder
  46911. };
  46912. }
  46913. const xref = this.xref,
  46914. parsedOrderRefs = new _primitives.RefSet(),
  46915. MAX_NESTED_LEVELS = 10;
  46916. return {
  46917. name: typeof config.get("Name") === "string" ? (0, _util.stringToPDFString)(config.get("Name")) : null,
  46918. creator: typeof config.get("Creator") === "string" ? (0, _util.stringToPDFString)(config.get("Creator")) : null,
  46919. baseState: config.get("BaseState") instanceof _primitives.Name ? config.get("BaseState").name : null,
  46920. on: parseOnOff(config.get("ON")),
  46921. off: parseOnOff(config.get("OFF")),
  46922. order: parseOrder(config.get("Order")),
  46923. groups: null
  46924. };
  46925. }
  46926. setActualNumPages() {
  46927. let num = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
  46928. this._actualNumPages = num;
  46929. }
  46930. get hasActualNumPages() {
  46931. return this._actualNumPages !== null;
  46932. }
  46933. get _pagesCount() {
  46934. const obj = this.toplevelPagesDict.get("Count");
  46935. if (!Number.isInteger(obj)) {
  46936. throw new _util.FormatError("Page count in top-level pages dictionary is not an integer.");
  46937. }
  46938. return (0, _util.shadow)(this, "_pagesCount", obj);
  46939. }
  46940. get numPages() {
  46941. return this.hasActualNumPages ? this._actualNumPages : this._pagesCount;
  46942. }
  46943. get destinations() {
  46944. const obj = this._readDests(),
  46945. dests = Object.create(null);
  46946. if (obj instanceof _name_number_tree.NameTree) {
  46947. for (const [key, value] of obj.getAll()) {
  46948. const dest = fetchDestination(value);
  46949. if (dest) {
  46950. dests[(0, _util.stringToPDFString)(key)] = dest;
  46951. }
  46952. }
  46953. } else if (obj instanceof _primitives.Dict) {
  46954. obj.forEach(function (key, value) {
  46955. const dest = fetchDestination(value);
  46956. if (dest) {
  46957. dests[key] = dest;
  46958. }
  46959. });
  46960. }
  46961. return (0, _util.shadow)(this, "destinations", dests);
  46962. }
  46963. getDestination(id) {
  46964. const obj = this._readDests();
  46965. if (obj instanceof _name_number_tree.NameTree) {
  46966. const dest = fetchDestination(obj.get(id));
  46967. if (dest) {
  46968. return dest;
  46969. }
  46970. const allDest = this.destinations[id];
  46971. if (allDest) {
  46972. (0, _util.warn)(`Found "${id}" at an incorrect position in the NameTree.`);
  46973. return allDest;
  46974. }
  46975. } else if (obj instanceof _primitives.Dict) {
  46976. const dest = fetchDestination(obj.get(id));
  46977. if (dest) {
  46978. return dest;
  46979. }
  46980. }
  46981. return null;
  46982. }
  46983. _readDests() {
  46984. const obj = this._catDict.get("Names");
  46985. if (obj?.has("Dests")) {
  46986. return new _name_number_tree.NameTree(obj.getRaw("Dests"), this.xref);
  46987. } else if (this._catDict.has("Dests")) {
  46988. return this._catDict.get("Dests");
  46989. }
  46990. return undefined;
  46991. }
  46992. get pageLabels() {
  46993. let obj = null;
  46994. try {
  46995. obj = this._readPageLabels();
  46996. } catch (ex) {
  46997. if (ex instanceof _core_utils.MissingDataException) {
  46998. throw ex;
  46999. }
  47000. (0, _util.warn)("Unable to read page labels.");
  47001. }
  47002. return (0, _util.shadow)(this, "pageLabels", obj);
  47003. }
  47004. _readPageLabels() {
  47005. const obj = this._catDict.getRaw("PageLabels");
  47006. if (!obj) {
  47007. return null;
  47008. }
  47009. const pageLabels = new Array(this.numPages);
  47010. let style = null,
  47011. prefix = "";
  47012. const numberTree = new _name_number_tree.NumberTree(obj, this.xref);
  47013. const nums = numberTree.getAll();
  47014. let currentLabel = "",
  47015. currentIndex = 1;
  47016. for (let i = 0, ii = this.numPages; i < ii; i++) {
  47017. const labelDict = nums.get(i);
  47018. if (labelDict !== undefined) {
  47019. if (!(labelDict instanceof _primitives.Dict)) {
  47020. throw new _util.FormatError("PageLabel is not a dictionary.");
  47021. }
  47022. if (labelDict.has("Type") && !(0, _primitives.isName)(labelDict.get("Type"), "PageLabel")) {
  47023. throw new _util.FormatError("Invalid type in PageLabel dictionary.");
  47024. }
  47025. if (labelDict.has("S")) {
  47026. const s = labelDict.get("S");
  47027. if (!(s instanceof _primitives.Name)) {
  47028. throw new _util.FormatError("Invalid style in PageLabel dictionary.");
  47029. }
  47030. style = s.name;
  47031. } else {
  47032. style = null;
  47033. }
  47034. if (labelDict.has("P")) {
  47035. const p = labelDict.get("P");
  47036. if (typeof p !== "string") {
  47037. throw new _util.FormatError("Invalid prefix in PageLabel dictionary.");
  47038. }
  47039. prefix = (0, _util.stringToPDFString)(p);
  47040. } else {
  47041. prefix = "";
  47042. }
  47043. if (labelDict.has("St")) {
  47044. const st = labelDict.get("St");
  47045. if (!(Number.isInteger(st) && st >= 1)) {
  47046. throw new _util.FormatError("Invalid start in PageLabel dictionary.");
  47047. }
  47048. currentIndex = st;
  47049. } else {
  47050. currentIndex = 1;
  47051. }
  47052. }
  47053. switch (style) {
  47054. case "D":
  47055. currentLabel = currentIndex;
  47056. break;
  47057. case "R":
  47058. case "r":
  47059. currentLabel = (0, _core_utils.toRomanNumerals)(currentIndex, style === "r");
  47060. break;
  47061. case "A":
  47062. case "a":
  47063. const LIMIT = 26;
  47064. const A_UPPER_CASE = 0x41,
  47065. A_LOWER_CASE = 0x61;
  47066. const baseCharCode = style === "a" ? A_LOWER_CASE : A_UPPER_CASE;
  47067. const letterIndex = currentIndex - 1;
  47068. const character = String.fromCharCode(baseCharCode + letterIndex % LIMIT);
  47069. currentLabel = character.repeat(Math.floor(letterIndex / LIMIT) + 1);
  47070. break;
  47071. default:
  47072. if (style) {
  47073. throw new _util.FormatError(`Invalid style "${style}" in PageLabel dictionary.`);
  47074. }
  47075. currentLabel = "";
  47076. }
  47077. pageLabels[i] = prefix + currentLabel;
  47078. currentIndex++;
  47079. }
  47080. return pageLabels;
  47081. }
  47082. get pageLayout() {
  47083. const obj = this._catDict.get("PageLayout");
  47084. let pageLayout = "";
  47085. if (obj instanceof _primitives.Name) {
  47086. switch (obj.name) {
  47087. case "SinglePage":
  47088. case "OneColumn":
  47089. case "TwoColumnLeft":
  47090. case "TwoColumnRight":
  47091. case "TwoPageLeft":
  47092. case "TwoPageRight":
  47093. pageLayout = obj.name;
  47094. }
  47095. }
  47096. return (0, _util.shadow)(this, "pageLayout", pageLayout);
  47097. }
  47098. get pageMode() {
  47099. const obj = this._catDict.get("PageMode");
  47100. let pageMode = "UseNone";
  47101. if (obj instanceof _primitives.Name) {
  47102. switch (obj.name) {
  47103. case "UseNone":
  47104. case "UseOutlines":
  47105. case "UseThumbs":
  47106. case "FullScreen":
  47107. case "UseOC":
  47108. case "UseAttachments":
  47109. pageMode = obj.name;
  47110. }
  47111. }
  47112. return (0, _util.shadow)(this, "pageMode", pageMode);
  47113. }
  47114. get viewerPreferences() {
  47115. const obj = this._catDict.get("ViewerPreferences");
  47116. if (!(obj instanceof _primitives.Dict)) {
  47117. return (0, _util.shadow)(this, "viewerPreferences", null);
  47118. }
  47119. let prefs = null;
  47120. for (const key of obj.getKeys()) {
  47121. const value = obj.get(key);
  47122. let prefValue;
  47123. switch (key) {
  47124. case "HideToolbar":
  47125. case "HideMenubar":
  47126. case "HideWindowUI":
  47127. case "FitWindow":
  47128. case "CenterWindow":
  47129. case "DisplayDocTitle":
  47130. case "PickTrayByPDFSize":
  47131. if (typeof value === "boolean") {
  47132. prefValue = value;
  47133. }
  47134. break;
  47135. case "NonFullScreenPageMode":
  47136. if (value instanceof _primitives.Name) {
  47137. switch (value.name) {
  47138. case "UseNone":
  47139. case "UseOutlines":
  47140. case "UseThumbs":
  47141. case "UseOC":
  47142. prefValue = value.name;
  47143. break;
  47144. default:
  47145. prefValue = "UseNone";
  47146. }
  47147. }
  47148. break;
  47149. case "Direction":
  47150. if (value instanceof _primitives.Name) {
  47151. switch (value.name) {
  47152. case "L2R":
  47153. case "R2L":
  47154. prefValue = value.name;
  47155. break;
  47156. default:
  47157. prefValue = "L2R";
  47158. }
  47159. }
  47160. break;
  47161. case "ViewArea":
  47162. case "ViewClip":
  47163. case "PrintArea":
  47164. case "PrintClip":
  47165. if (value instanceof _primitives.Name) {
  47166. switch (value.name) {
  47167. case "MediaBox":
  47168. case "CropBox":
  47169. case "BleedBox":
  47170. case "TrimBox":
  47171. case "ArtBox":
  47172. prefValue = value.name;
  47173. break;
  47174. default:
  47175. prefValue = "CropBox";
  47176. }
  47177. }
  47178. break;
  47179. case "PrintScaling":
  47180. if (value instanceof _primitives.Name) {
  47181. switch (value.name) {
  47182. case "None":
  47183. case "AppDefault":
  47184. prefValue = value.name;
  47185. break;
  47186. default:
  47187. prefValue = "AppDefault";
  47188. }
  47189. }
  47190. break;
  47191. case "Duplex":
  47192. if (value instanceof _primitives.Name) {
  47193. switch (value.name) {
  47194. case "Simplex":
  47195. case "DuplexFlipShortEdge":
  47196. case "DuplexFlipLongEdge":
  47197. prefValue = value.name;
  47198. break;
  47199. default:
  47200. prefValue = "None";
  47201. }
  47202. }
  47203. break;
  47204. case "PrintPageRange":
  47205. if (Array.isArray(value) && value.length % 2 === 0) {
  47206. const isValid = value.every((page, i, arr) => {
  47207. return Number.isInteger(page) && page > 0 && (i === 0 || page >= arr[i - 1]) && page <= this.numPages;
  47208. });
  47209. if (isValid) {
  47210. prefValue = value;
  47211. }
  47212. }
  47213. break;
  47214. case "NumCopies":
  47215. if (Number.isInteger(value) && value > 0) {
  47216. prefValue = value;
  47217. }
  47218. break;
  47219. default:
  47220. (0, _util.warn)(`Ignoring non-standard key in ViewerPreferences: ${key}.`);
  47221. continue;
  47222. }
  47223. if (prefValue === undefined) {
  47224. (0, _util.warn)(`Bad value, for key "${key}", in ViewerPreferences: ${value}.`);
  47225. continue;
  47226. }
  47227. if (!prefs) {
  47228. prefs = Object.create(null);
  47229. }
  47230. prefs[key] = prefValue;
  47231. }
  47232. return (0, _util.shadow)(this, "viewerPreferences", prefs);
  47233. }
  47234. get openAction() {
  47235. const obj = this._catDict.get("OpenAction");
  47236. const openAction = Object.create(null);
  47237. if (obj instanceof _primitives.Dict) {
  47238. const destDict = new _primitives.Dict(this.xref);
  47239. destDict.set("A", obj);
  47240. const resultObj = {
  47241. url: null,
  47242. dest: null,
  47243. action: null
  47244. };
  47245. Catalog.parseDestDictionary({
  47246. destDict,
  47247. resultObj
  47248. });
  47249. if (Array.isArray(resultObj.dest)) {
  47250. openAction.dest = resultObj.dest;
  47251. } else if (resultObj.action) {
  47252. openAction.action = resultObj.action;
  47253. }
  47254. } else if (Array.isArray(obj)) {
  47255. openAction.dest = obj;
  47256. }
  47257. return (0, _util.shadow)(this, "openAction", (0, _util.objectSize)(openAction) > 0 ? openAction : null);
  47258. }
  47259. get attachments() {
  47260. const obj = this._catDict.get("Names");
  47261. let attachments = null;
  47262. if (obj instanceof _primitives.Dict && obj.has("EmbeddedFiles")) {
  47263. const nameTree = new _name_number_tree.NameTree(obj.getRaw("EmbeddedFiles"), this.xref);
  47264. for (const [key, value] of nameTree.getAll()) {
  47265. const fs = new _file_spec.FileSpec(value, this.xref);
  47266. if (!attachments) {
  47267. attachments = Object.create(null);
  47268. }
  47269. attachments[(0, _util.stringToPDFString)(key)] = fs.serializable;
  47270. }
  47271. }
  47272. return (0, _util.shadow)(this, "attachments", attachments);
  47273. }
  47274. get xfaImages() {
  47275. const obj = this._catDict.get("Names");
  47276. let xfaImages = null;
  47277. if (obj instanceof _primitives.Dict && obj.has("XFAImages")) {
  47278. const nameTree = new _name_number_tree.NameTree(obj.getRaw("XFAImages"), this.xref);
  47279. for (const [key, value] of nameTree.getAll()) {
  47280. if (!xfaImages) {
  47281. xfaImages = new _primitives.Dict(this.xref);
  47282. }
  47283. xfaImages.set((0, _util.stringToPDFString)(key), value);
  47284. }
  47285. }
  47286. return (0, _util.shadow)(this, "xfaImages", xfaImages);
  47287. }
  47288. _collectJavaScript() {
  47289. const obj = this._catDict.get("Names");
  47290. let javaScript = null;
  47291. function appendIfJavaScriptDict(name, jsDict) {
  47292. if (!(jsDict instanceof _primitives.Dict)) {
  47293. return;
  47294. }
  47295. if (!(0, _primitives.isName)(jsDict.get("S"), "JavaScript")) {
  47296. return;
  47297. }
  47298. let js = jsDict.get("JS");
  47299. if (js instanceof _base_stream.BaseStream) {
  47300. js = js.getString();
  47301. } else if (typeof js !== "string") {
  47302. return;
  47303. }
  47304. js = (0, _util.stringToPDFString)(js).replaceAll("\x00", "");
  47305. if (js) {
  47306. (javaScript ||= new Map()).set(name, js);
  47307. }
  47308. }
  47309. if (obj instanceof _primitives.Dict && obj.has("JavaScript")) {
  47310. const nameTree = new _name_number_tree.NameTree(obj.getRaw("JavaScript"), this.xref);
  47311. for (const [key, value] of nameTree.getAll()) {
  47312. appendIfJavaScriptDict((0, _util.stringToPDFString)(key), value);
  47313. }
  47314. }
  47315. const openAction = this._catDict.get("OpenAction");
  47316. if (openAction) {
  47317. appendIfJavaScriptDict("OpenAction", openAction);
  47318. }
  47319. return javaScript;
  47320. }
  47321. get jsActions() {
  47322. const javaScript = this._collectJavaScript();
  47323. let actions = (0, _core_utils.collectActions)(this.xref, this._catDict, _util.DocumentActionEventType);
  47324. if (javaScript) {
  47325. actions ||= Object.create(null);
  47326. for (const [key, val] of javaScript) {
  47327. if (key in actions) {
  47328. actions[key].push(val);
  47329. } else {
  47330. actions[key] = [val];
  47331. }
  47332. }
  47333. }
  47334. return (0, _util.shadow)(this, "jsActions", actions);
  47335. }
  47336. async fontFallback(id, handler) {
  47337. const translatedFonts = await Promise.all(this.fontCache);
  47338. for (const translatedFont of translatedFonts) {
  47339. if (translatedFont.loadedName === id) {
  47340. translatedFont.fallback(handler);
  47341. return;
  47342. }
  47343. }
  47344. }
  47345. async cleanup() {
  47346. let manuallyTriggered = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  47347. (0, _cleanup_helper.clearGlobalCaches)();
  47348. this.globalImageCache.clear(manuallyTriggered);
  47349. this.pageKidsCountCache.clear();
  47350. this.pageIndexCache.clear();
  47351. this.nonBlendModesSet.clear();
  47352. const translatedFonts = await Promise.all(this.fontCache);
  47353. for (const {
  47354. dict
  47355. } of translatedFonts) {
  47356. delete dict.cacheKey;
  47357. }
  47358. this.fontCache.clear();
  47359. this.builtInCMapCache.clear();
  47360. this.standardFontDataCache.clear();
  47361. this.systemFontCache.clear();
  47362. }
  47363. async getPageDict(pageIndex) {
  47364. const nodesToVisit = [this.toplevelPagesDict];
  47365. const visitedNodes = new _primitives.RefSet();
  47366. const pagesRef = this._catDict.getRaw("Pages");
  47367. if (pagesRef instanceof _primitives.Ref) {
  47368. visitedNodes.put(pagesRef);
  47369. }
  47370. const xref = this.xref,
  47371. pageKidsCountCache = this.pageKidsCountCache,
  47372. pageIndexCache = this.pageIndexCache;
  47373. let currentPageIndex = 0;
  47374. while (nodesToVisit.length) {
  47375. const currentNode = nodesToVisit.pop();
  47376. if (currentNode instanceof _primitives.Ref) {
  47377. const count = pageKidsCountCache.get(currentNode);
  47378. if (count >= 0 && currentPageIndex + count <= pageIndex) {
  47379. currentPageIndex += count;
  47380. continue;
  47381. }
  47382. if (visitedNodes.has(currentNode)) {
  47383. throw new _util.FormatError("Pages tree contains circular reference.");
  47384. }
  47385. visitedNodes.put(currentNode);
  47386. const obj = await xref.fetchAsync(currentNode);
  47387. if (obj instanceof _primitives.Dict) {
  47388. let type = obj.getRaw("Type");
  47389. if (type instanceof _primitives.Ref) {
  47390. type = await xref.fetchAsync(type);
  47391. }
  47392. if ((0, _primitives.isName)(type, "Page") || !obj.has("Kids")) {
  47393. if (!pageKidsCountCache.has(currentNode)) {
  47394. pageKidsCountCache.put(currentNode, 1);
  47395. }
  47396. if (!pageIndexCache.has(currentNode)) {
  47397. pageIndexCache.put(currentNode, currentPageIndex);
  47398. }
  47399. if (currentPageIndex === pageIndex) {
  47400. return [obj, currentNode];
  47401. }
  47402. currentPageIndex++;
  47403. continue;
  47404. }
  47405. }
  47406. nodesToVisit.push(obj);
  47407. continue;
  47408. }
  47409. if (!(currentNode instanceof _primitives.Dict)) {
  47410. throw new _util.FormatError("Page dictionary kid reference points to wrong type of object.");
  47411. }
  47412. const {
  47413. objId
  47414. } = currentNode;
  47415. let count = currentNode.getRaw("Count");
  47416. if (count instanceof _primitives.Ref) {
  47417. count = await xref.fetchAsync(count);
  47418. }
  47419. if (Number.isInteger(count) && count >= 0) {
  47420. if (objId && !pageKidsCountCache.has(objId)) {
  47421. pageKidsCountCache.put(objId, count);
  47422. }
  47423. if (currentPageIndex + count <= pageIndex) {
  47424. currentPageIndex += count;
  47425. continue;
  47426. }
  47427. }
  47428. let kids = currentNode.getRaw("Kids");
  47429. if (kids instanceof _primitives.Ref) {
  47430. kids = await xref.fetchAsync(kids);
  47431. }
  47432. if (!Array.isArray(kids)) {
  47433. let type = currentNode.getRaw("Type");
  47434. if (type instanceof _primitives.Ref) {
  47435. type = await xref.fetchAsync(type);
  47436. }
  47437. if ((0, _primitives.isName)(type, "Page") || !currentNode.has("Kids")) {
  47438. if (currentPageIndex === pageIndex) {
  47439. return [currentNode, null];
  47440. }
  47441. currentPageIndex++;
  47442. continue;
  47443. }
  47444. throw new _util.FormatError("Page dictionary kids object is not an array.");
  47445. }
  47446. for (let last = kids.length - 1; last >= 0; last--) {
  47447. nodesToVisit.push(kids[last]);
  47448. }
  47449. }
  47450. throw new Error(`Page index ${pageIndex} not found.`);
  47451. }
  47452. async getAllPageDicts() {
  47453. let recoveryMode = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  47454. const {
  47455. ignoreErrors
  47456. } = this.pdfManager.evaluatorOptions;
  47457. const queue = [{
  47458. currentNode: this.toplevelPagesDict,
  47459. posInKids: 0
  47460. }];
  47461. const visitedNodes = new _primitives.RefSet();
  47462. const pagesRef = this._catDict.getRaw("Pages");
  47463. if (pagesRef instanceof _primitives.Ref) {
  47464. visitedNodes.put(pagesRef);
  47465. }
  47466. const map = new Map(),
  47467. xref = this.xref,
  47468. pageIndexCache = this.pageIndexCache;
  47469. let pageIndex = 0;
  47470. function addPageDict(pageDict, pageRef) {
  47471. if (pageRef && !pageIndexCache.has(pageRef)) {
  47472. pageIndexCache.put(pageRef, pageIndex);
  47473. }
  47474. map.set(pageIndex++, [pageDict, pageRef]);
  47475. }
  47476. function addPageError(error) {
  47477. if (error instanceof _core_utils.XRefEntryException && !recoveryMode) {
  47478. throw error;
  47479. }
  47480. if (recoveryMode && ignoreErrors && pageIndex === 0) {
  47481. (0, _util.warn)(`getAllPageDicts - Skipping invalid first page: "${error}".`);
  47482. error = _primitives.Dict.empty;
  47483. }
  47484. map.set(pageIndex++, [error, null]);
  47485. }
  47486. while (queue.length > 0) {
  47487. const queueItem = queue.at(-1);
  47488. const {
  47489. currentNode,
  47490. posInKids
  47491. } = queueItem;
  47492. let kids = currentNode.getRaw("Kids");
  47493. if (kids instanceof _primitives.Ref) {
  47494. try {
  47495. kids = await xref.fetchAsync(kids);
  47496. } catch (ex) {
  47497. addPageError(ex);
  47498. break;
  47499. }
  47500. }
  47501. if (!Array.isArray(kids)) {
  47502. addPageError(new _util.FormatError("Page dictionary kids object is not an array."));
  47503. break;
  47504. }
  47505. if (posInKids >= kids.length) {
  47506. queue.pop();
  47507. continue;
  47508. }
  47509. const kidObj = kids[posInKids];
  47510. let obj;
  47511. if (kidObj instanceof _primitives.Ref) {
  47512. if (visitedNodes.has(kidObj)) {
  47513. addPageError(new _util.FormatError("Pages tree contains circular reference."));
  47514. break;
  47515. }
  47516. visitedNodes.put(kidObj);
  47517. try {
  47518. obj = await xref.fetchAsync(kidObj);
  47519. } catch (ex) {
  47520. addPageError(ex);
  47521. break;
  47522. }
  47523. } else {
  47524. obj = kidObj;
  47525. }
  47526. if (!(obj instanceof _primitives.Dict)) {
  47527. addPageError(new _util.FormatError("Page dictionary kid reference points to wrong type of object."));
  47528. break;
  47529. }
  47530. let type = obj.getRaw("Type");
  47531. if (type instanceof _primitives.Ref) {
  47532. try {
  47533. type = await xref.fetchAsync(type);
  47534. } catch (ex) {
  47535. addPageError(ex);
  47536. break;
  47537. }
  47538. }
  47539. if ((0, _primitives.isName)(type, "Page") || !obj.has("Kids")) {
  47540. addPageDict(obj, kidObj instanceof _primitives.Ref ? kidObj : null);
  47541. } else {
  47542. queue.push({
  47543. currentNode: obj,
  47544. posInKids: 0
  47545. });
  47546. }
  47547. queueItem.posInKids++;
  47548. }
  47549. return map;
  47550. }
  47551. getPageIndex(pageRef) {
  47552. const cachedPageIndex = this.pageIndexCache.get(pageRef);
  47553. if (cachedPageIndex !== undefined) {
  47554. return Promise.resolve(cachedPageIndex);
  47555. }
  47556. const xref = this.xref;
  47557. function pagesBeforeRef(kidRef) {
  47558. let total = 0,
  47559. parentRef;
  47560. return xref.fetchAsync(kidRef).then(function (node) {
  47561. if ((0, _primitives.isRefsEqual)(kidRef, pageRef) && !(0, _primitives.isDict)(node, "Page") && !(node instanceof _primitives.Dict && !node.has("Type") && node.has("Contents"))) {
  47562. throw new _util.FormatError("The reference does not point to a /Page dictionary.");
  47563. }
  47564. if (!node) {
  47565. return null;
  47566. }
  47567. if (!(node instanceof _primitives.Dict)) {
  47568. throw new _util.FormatError("Node must be a dictionary.");
  47569. }
  47570. parentRef = node.getRaw("Parent");
  47571. return node.getAsync("Parent");
  47572. }).then(function (parent) {
  47573. if (!parent) {
  47574. return null;
  47575. }
  47576. if (!(parent instanceof _primitives.Dict)) {
  47577. throw new _util.FormatError("Parent must be a dictionary.");
  47578. }
  47579. return parent.getAsync("Kids");
  47580. }).then(function (kids) {
  47581. if (!kids) {
  47582. return null;
  47583. }
  47584. const kidPromises = [];
  47585. let found = false;
  47586. for (const kid of kids) {
  47587. if (!(kid instanceof _primitives.Ref)) {
  47588. throw new _util.FormatError("Kid must be a reference.");
  47589. }
  47590. if ((0, _primitives.isRefsEqual)(kid, kidRef)) {
  47591. found = true;
  47592. break;
  47593. }
  47594. kidPromises.push(xref.fetchAsync(kid).then(function (obj) {
  47595. if (!(obj instanceof _primitives.Dict)) {
  47596. throw new _util.FormatError("Kid node must be a dictionary.");
  47597. }
  47598. if (obj.has("Count")) {
  47599. total += obj.get("Count");
  47600. } else {
  47601. total++;
  47602. }
  47603. }));
  47604. }
  47605. if (!found) {
  47606. throw new _util.FormatError("Kid reference not found in parent's kids.");
  47607. }
  47608. return Promise.all(kidPromises).then(function () {
  47609. return [total, parentRef];
  47610. });
  47611. });
  47612. }
  47613. let total = 0;
  47614. const next = ref => pagesBeforeRef(ref).then(args => {
  47615. if (!args) {
  47616. this.pageIndexCache.put(pageRef, total);
  47617. return total;
  47618. }
  47619. const [count, parentRef] = args;
  47620. total += count;
  47621. return next(parentRef);
  47622. });
  47623. return next(pageRef);
  47624. }
  47625. get baseUrl() {
  47626. const uri = this._catDict.get("URI");
  47627. if (uri instanceof _primitives.Dict) {
  47628. const base = uri.get("Base");
  47629. if (typeof base === "string") {
  47630. const absoluteUrl = (0, _util.createValidAbsoluteUrl)(base, null, {
  47631. tryConvertEncoding: true
  47632. });
  47633. if (absoluteUrl) {
  47634. return (0, _util.shadow)(this, "baseUrl", absoluteUrl.href);
  47635. }
  47636. }
  47637. }
  47638. return (0, _util.shadow)(this, "baseUrl", null);
  47639. }
  47640. static parseDestDictionary(params) {
  47641. const destDict = params.destDict;
  47642. if (!(destDict instanceof _primitives.Dict)) {
  47643. (0, _util.warn)("parseDestDictionary: `destDict` must be a dictionary.");
  47644. return;
  47645. }
  47646. const resultObj = params.resultObj;
  47647. if (typeof resultObj !== "object") {
  47648. (0, _util.warn)("parseDestDictionary: `resultObj` must be an object.");
  47649. return;
  47650. }
  47651. const docBaseUrl = params.docBaseUrl || null;
  47652. const docAttachments = params.docAttachments || null;
  47653. let action = destDict.get("A"),
  47654. url,
  47655. dest;
  47656. if (!(action instanceof _primitives.Dict)) {
  47657. if (destDict.has("Dest")) {
  47658. action = destDict.get("Dest");
  47659. } else {
  47660. action = destDict.get("AA");
  47661. if (action instanceof _primitives.Dict) {
  47662. if (action.has("D")) {
  47663. action = action.get("D");
  47664. } else if (action.has("U")) {
  47665. action = action.get("U");
  47666. }
  47667. }
  47668. }
  47669. }
  47670. if (action instanceof _primitives.Dict) {
  47671. const actionType = action.get("S");
  47672. if (!(actionType instanceof _primitives.Name)) {
  47673. (0, _util.warn)("parseDestDictionary: Invalid type in Action dictionary.");
  47674. return;
  47675. }
  47676. const actionName = actionType.name;
  47677. switch (actionName) {
  47678. case "ResetForm":
  47679. const flags = action.get("Flags");
  47680. const include = ((typeof flags === "number" ? flags : 0) & 1) === 0;
  47681. const fields = [];
  47682. const refs = [];
  47683. for (const obj of action.get("Fields") || []) {
  47684. if (obj instanceof _primitives.Ref) {
  47685. refs.push(obj.toString());
  47686. } else if (typeof obj === "string") {
  47687. fields.push((0, _util.stringToPDFString)(obj));
  47688. }
  47689. }
  47690. resultObj.resetForm = {
  47691. fields,
  47692. refs,
  47693. include
  47694. };
  47695. break;
  47696. case "URI":
  47697. url = action.get("URI");
  47698. if (url instanceof _primitives.Name) {
  47699. url = "/" + url.name;
  47700. }
  47701. break;
  47702. case "GoTo":
  47703. dest = action.get("D");
  47704. break;
  47705. case "Launch":
  47706. case "GoToR":
  47707. const urlDict = action.get("F");
  47708. if (urlDict instanceof _primitives.Dict) {
  47709. url = urlDict.get("F") || null;
  47710. } else if (typeof urlDict === "string") {
  47711. url = urlDict;
  47712. }
  47713. let remoteDest = action.get("D");
  47714. if (remoteDest) {
  47715. if (remoteDest instanceof _primitives.Name) {
  47716. remoteDest = remoteDest.name;
  47717. }
  47718. if (typeof url === "string") {
  47719. const baseUrl = url.split("#")[0];
  47720. if (typeof remoteDest === "string") {
  47721. url = baseUrl + "#" + remoteDest;
  47722. } else if (Array.isArray(remoteDest)) {
  47723. url = baseUrl + "#" + JSON.stringify(remoteDest);
  47724. }
  47725. }
  47726. }
  47727. const newWindow = action.get("NewWindow");
  47728. if (typeof newWindow === "boolean") {
  47729. resultObj.newWindow = newWindow;
  47730. }
  47731. break;
  47732. case "GoToE":
  47733. const target = action.get("T");
  47734. let attachment;
  47735. if (docAttachments && target instanceof _primitives.Dict) {
  47736. const relationship = target.get("R");
  47737. const name = target.get("N");
  47738. if ((0, _primitives.isName)(relationship, "C") && typeof name === "string") {
  47739. attachment = docAttachments[(0, _util.stringToPDFString)(name)];
  47740. }
  47741. }
  47742. if (attachment) {
  47743. resultObj.attachment = attachment;
  47744. } else {
  47745. (0, _util.warn)(`parseDestDictionary - unimplemented "GoToE" action.`);
  47746. }
  47747. break;
  47748. case "Named":
  47749. const namedAction = action.get("N");
  47750. if (namedAction instanceof _primitives.Name) {
  47751. resultObj.action = namedAction.name;
  47752. }
  47753. break;
  47754. case "SetOCGState":
  47755. const state = action.get("State");
  47756. const preserveRB = action.get("PreserveRB");
  47757. if (!Array.isArray(state) || state.length === 0) {
  47758. break;
  47759. }
  47760. const stateArr = [];
  47761. for (const elem of state) {
  47762. if (elem instanceof _primitives.Name) {
  47763. switch (elem.name) {
  47764. case "ON":
  47765. case "OFF":
  47766. case "Toggle":
  47767. stateArr.push(elem.name);
  47768. break;
  47769. }
  47770. } else if (elem instanceof _primitives.Ref) {
  47771. stateArr.push(elem.toString());
  47772. }
  47773. }
  47774. if (stateArr.length !== state.length) {
  47775. break;
  47776. }
  47777. resultObj.setOCGState = {
  47778. state: stateArr,
  47779. preserveRB: typeof preserveRB === "boolean" ? preserveRB : true
  47780. };
  47781. break;
  47782. case "JavaScript":
  47783. const jsAction = action.get("JS");
  47784. let js;
  47785. if (jsAction instanceof _base_stream.BaseStream) {
  47786. js = jsAction.getString();
  47787. } else if (typeof jsAction === "string") {
  47788. js = jsAction;
  47789. }
  47790. const jsURL = js && (0, _core_utils.recoverJsURL)((0, _util.stringToPDFString)(js));
  47791. if (jsURL) {
  47792. url = jsURL.url;
  47793. resultObj.newWindow = jsURL.newWindow;
  47794. break;
  47795. }
  47796. default:
  47797. if (actionName === "JavaScript" || actionName === "SubmitForm") {
  47798. break;
  47799. }
  47800. (0, _util.warn)(`parseDestDictionary - unsupported action: "${actionName}".`);
  47801. break;
  47802. }
  47803. } else if (destDict.has("Dest")) {
  47804. dest = destDict.get("Dest");
  47805. }
  47806. if (typeof url === "string") {
  47807. const absoluteUrl = (0, _util.createValidAbsoluteUrl)(url, docBaseUrl, {
  47808. addDefaultProtocol: true,
  47809. tryConvertEncoding: true
  47810. });
  47811. if (absoluteUrl) {
  47812. resultObj.url = absoluteUrl.href;
  47813. }
  47814. resultObj.unsafeUrl = url;
  47815. }
  47816. if (dest) {
  47817. if (dest instanceof _primitives.Name) {
  47818. dest = dest.name;
  47819. }
  47820. if (typeof dest === "string") {
  47821. resultObj.dest = (0, _util.stringToPDFString)(dest);
  47822. } else if (Array.isArray(dest)) {
  47823. resultObj.dest = dest;
  47824. }
  47825. }
  47826. }
  47827. }
  47828. exports.Catalog = Catalog;
  47829. /***/ }),
  47830. /* 222 */
  47831. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  47832. Object.defineProperty(exports, "__esModule", ({
  47833. value: true
  47834. }));
  47835. exports.NumberTree = exports.NameTree = void 0;
  47836. __w_pdfjs_require__(140);
  47837. var _primitives = __w_pdfjs_require__(151);
  47838. var _util = __w_pdfjs_require__(145);
  47839. class NameOrNumberTree {
  47840. constructor(root, xref, type) {
  47841. if (this.constructor === NameOrNumberTree) {
  47842. (0, _util.unreachable)("Cannot initialize NameOrNumberTree.");
  47843. }
  47844. this.root = root;
  47845. this.xref = xref;
  47846. this._type = type;
  47847. }
  47848. getAll() {
  47849. const map = new Map();
  47850. if (!this.root) {
  47851. return map;
  47852. }
  47853. const xref = this.xref;
  47854. const processed = new _primitives.RefSet();
  47855. processed.put(this.root);
  47856. const queue = [this.root];
  47857. while (queue.length > 0) {
  47858. const obj = xref.fetchIfRef(queue.shift());
  47859. if (!(obj instanceof _primitives.Dict)) {
  47860. continue;
  47861. }
  47862. if (obj.has("Kids")) {
  47863. const kids = obj.get("Kids");
  47864. if (!Array.isArray(kids)) {
  47865. continue;
  47866. }
  47867. for (const kid of kids) {
  47868. if (processed.has(kid)) {
  47869. throw new _util.FormatError(`Duplicate entry in "${this._type}" tree.`);
  47870. }
  47871. queue.push(kid);
  47872. processed.put(kid);
  47873. }
  47874. continue;
  47875. }
  47876. const entries = obj.get(this._type);
  47877. if (!Array.isArray(entries)) {
  47878. continue;
  47879. }
  47880. for (let i = 0, ii = entries.length; i < ii; i += 2) {
  47881. map.set(xref.fetchIfRef(entries[i]), xref.fetchIfRef(entries[i + 1]));
  47882. }
  47883. }
  47884. return map;
  47885. }
  47886. get(key) {
  47887. if (!this.root) {
  47888. return null;
  47889. }
  47890. const xref = this.xref;
  47891. let kidsOrEntries = xref.fetchIfRef(this.root);
  47892. let loopCount = 0;
  47893. const MAX_LEVELS = 10;
  47894. while (kidsOrEntries.has("Kids")) {
  47895. if (++loopCount > MAX_LEVELS) {
  47896. (0, _util.warn)(`Search depth limit reached for "${this._type}" tree.`);
  47897. return null;
  47898. }
  47899. const kids = kidsOrEntries.get("Kids");
  47900. if (!Array.isArray(kids)) {
  47901. return null;
  47902. }
  47903. let l = 0,
  47904. r = kids.length - 1;
  47905. while (l <= r) {
  47906. const m = l + r >> 1;
  47907. const kid = xref.fetchIfRef(kids[m]);
  47908. const limits = kid.get("Limits");
  47909. if (key < xref.fetchIfRef(limits[0])) {
  47910. r = m - 1;
  47911. } else if (key > xref.fetchIfRef(limits[1])) {
  47912. l = m + 1;
  47913. } else {
  47914. kidsOrEntries = kid;
  47915. break;
  47916. }
  47917. }
  47918. if (l > r) {
  47919. return null;
  47920. }
  47921. }
  47922. const entries = kidsOrEntries.get(this._type);
  47923. if (Array.isArray(entries)) {
  47924. let l = 0,
  47925. r = entries.length - 2;
  47926. while (l <= r) {
  47927. const tmp = l + r >> 1,
  47928. m = tmp + (tmp & 1);
  47929. const currentKey = xref.fetchIfRef(entries[m]);
  47930. if (key < currentKey) {
  47931. r = m - 2;
  47932. } else if (key > currentKey) {
  47933. l = m + 2;
  47934. } else {
  47935. return xref.fetchIfRef(entries[m + 1]);
  47936. }
  47937. }
  47938. }
  47939. return null;
  47940. }
  47941. }
  47942. class NameTree extends NameOrNumberTree {
  47943. constructor(root, xref) {
  47944. super(root, xref, "Names");
  47945. }
  47946. }
  47947. exports.NameTree = NameTree;
  47948. class NumberTree extends NameOrNumberTree {
  47949. constructor(root, xref) {
  47950. super(root, xref, "Nums");
  47951. }
  47952. }
  47953. exports.NumberTree = NumberTree;
  47954. /***/ }),
  47955. /* 223 */
  47956. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  47957. Object.defineProperty(exports, "__esModule", ({
  47958. value: true
  47959. }));
  47960. exports.clearGlobalCaches = clearGlobalCaches;
  47961. var _primitives = __w_pdfjs_require__(151);
  47962. var _unicode = __w_pdfjs_require__(191);
  47963. function clearGlobalCaches() {
  47964. (0, _primitives.clearPrimitiveCaches)();
  47965. (0, _unicode.clearUnicodeCaches)();
  47966. }
  47967. /***/ }),
  47968. /* 224 */
  47969. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  47970. Object.defineProperty(exports, "__esModule", ({
  47971. value: true
  47972. }));
  47973. exports.FileSpec = void 0;
  47974. var _util = __w_pdfjs_require__(145);
  47975. var _base_stream = __w_pdfjs_require__(152);
  47976. var _primitives = __w_pdfjs_require__(151);
  47977. function pickPlatformItem(dict) {
  47978. if (dict.has("UF")) {
  47979. return dict.get("UF");
  47980. } else if (dict.has("F")) {
  47981. return dict.get("F");
  47982. } else if (dict.has("Unix")) {
  47983. return dict.get("Unix");
  47984. } else if (dict.has("Mac")) {
  47985. return dict.get("Mac");
  47986. } else if (dict.has("DOS")) {
  47987. return dict.get("DOS");
  47988. }
  47989. return null;
  47990. }
  47991. class FileSpec {
  47992. constructor(root, xref) {
  47993. if (!(root instanceof _primitives.Dict)) {
  47994. return;
  47995. }
  47996. this.xref = xref;
  47997. this.root = root;
  47998. if (root.has("FS")) {
  47999. this.fs = root.get("FS");
  48000. }
  48001. this.description = root.has("Desc") ? (0, _util.stringToPDFString)(root.get("Desc")) : "";
  48002. if (root.has("RF")) {
  48003. (0, _util.warn)("Related file specifications are not supported");
  48004. }
  48005. this.contentAvailable = true;
  48006. if (!root.has("EF")) {
  48007. this.contentAvailable = false;
  48008. (0, _util.warn)("Non-embedded file specifications are not supported");
  48009. }
  48010. }
  48011. get filename() {
  48012. if (!this._filename && this.root) {
  48013. const filename = pickPlatformItem(this.root) || "unnamed";
  48014. this._filename = (0, _util.stringToPDFString)(filename).replaceAll("\\\\", "\\").replaceAll("\\/", "/").replaceAll("\\", "/");
  48015. }
  48016. return this._filename;
  48017. }
  48018. get content() {
  48019. if (!this.contentAvailable) {
  48020. return null;
  48021. }
  48022. if (!this.contentRef && this.root) {
  48023. this.contentRef = pickPlatformItem(this.root.get("EF"));
  48024. }
  48025. let content = null;
  48026. if (this.contentRef) {
  48027. const fileObj = this.xref.fetchIfRef(this.contentRef);
  48028. if (fileObj instanceof _base_stream.BaseStream) {
  48029. content = fileObj.getBytes();
  48030. } else {
  48031. (0, _util.warn)("Embedded file specification points to non-existing/invalid content");
  48032. }
  48033. } else {
  48034. (0, _util.warn)("Embedded file specification does not have a content");
  48035. }
  48036. return content;
  48037. }
  48038. get serializable() {
  48039. return {
  48040. filename: this.filename,
  48041. content: this.content
  48042. };
  48043. }
  48044. }
  48045. exports.FileSpec = FileSpec;
  48046. /***/ }),
  48047. /* 225 */
  48048. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  48049. Object.defineProperty(exports, "__esModule", ({
  48050. value: true
  48051. }));
  48052. exports.MetadataParser = void 0;
  48053. __w_pdfjs_require__(2);
  48054. __w_pdfjs_require__(140);
  48055. var _xml_parser = __w_pdfjs_require__(218);
  48056. class MetadataParser {
  48057. constructor(data) {
  48058. data = this._repair(data);
  48059. const parser = new _xml_parser.SimpleXMLParser({
  48060. lowerCaseName: true
  48061. });
  48062. const xmlDocument = parser.parseFromString(data);
  48063. this._metadataMap = new Map();
  48064. this._data = data;
  48065. if (xmlDocument) {
  48066. this._parse(xmlDocument);
  48067. }
  48068. }
  48069. _repair(data) {
  48070. return data.replace(/^[^<]+/, "").replaceAll(/>\\376\\377([^<]+)/g, function (all, codes) {
  48071. const bytes = codes.replaceAll(/\\([0-3])([0-7])([0-7])/g, function (code, d1, d2, d3) {
  48072. return String.fromCharCode(d1 * 64 + d2 * 8 + d3 * 1);
  48073. }).replaceAll(/&(amp|apos|gt|lt|quot);/g, function (str, name) {
  48074. switch (name) {
  48075. case "amp":
  48076. return "&";
  48077. case "apos":
  48078. return "'";
  48079. case "gt":
  48080. return ">";
  48081. case "lt":
  48082. return "<";
  48083. case "quot":
  48084. return '"';
  48085. }
  48086. throw new Error(`_repair: ${name} isn't defined.`);
  48087. });
  48088. const charBuf = [">"];
  48089. for (let i = 0, ii = bytes.length; i < ii; i += 2) {
  48090. const code = bytes.charCodeAt(i) * 256 + bytes.charCodeAt(i + 1);
  48091. if (code >= 32 && code < 127 && code !== 60 && code !== 62 && code !== 38) {
  48092. charBuf.push(String.fromCharCode(code));
  48093. } else {
  48094. charBuf.push("&#x" + (0x10000 + code).toString(16).substring(1) + ";");
  48095. }
  48096. }
  48097. return charBuf.join("");
  48098. });
  48099. }
  48100. _getSequence(entry) {
  48101. const name = entry.nodeName;
  48102. if (name !== "rdf:bag" && name !== "rdf:seq" && name !== "rdf:alt") {
  48103. return null;
  48104. }
  48105. return entry.childNodes.filter(node => node.nodeName === "rdf:li");
  48106. }
  48107. _parseArray(entry) {
  48108. if (!entry.hasChildNodes()) {
  48109. return;
  48110. }
  48111. const [seqNode] = entry.childNodes;
  48112. const sequence = this._getSequence(seqNode) || [];
  48113. this._metadataMap.set(entry.nodeName, sequence.map(node => node.textContent.trim()));
  48114. }
  48115. _parse(xmlDocument) {
  48116. let rdf = xmlDocument.documentElement;
  48117. if (rdf.nodeName !== "rdf:rdf") {
  48118. rdf = rdf.firstChild;
  48119. while (rdf && rdf.nodeName !== "rdf:rdf") {
  48120. rdf = rdf.nextSibling;
  48121. }
  48122. }
  48123. if (!rdf || rdf.nodeName !== "rdf:rdf" || !rdf.hasChildNodes()) {
  48124. return;
  48125. }
  48126. for (const desc of rdf.childNodes) {
  48127. if (desc.nodeName !== "rdf:description") {
  48128. continue;
  48129. }
  48130. for (const entry of desc.childNodes) {
  48131. const name = entry.nodeName;
  48132. switch (name) {
  48133. case "#text":
  48134. continue;
  48135. case "dc:creator":
  48136. case "dc:subject":
  48137. this._parseArray(entry);
  48138. continue;
  48139. }
  48140. this._metadataMap.set(name, entry.textContent.trim());
  48141. }
  48142. }
  48143. }
  48144. get serializable() {
  48145. return {
  48146. parsedData: this._metadataMap,
  48147. rawData: this._data
  48148. };
  48149. }
  48150. }
  48151. exports.MetadataParser = MetadataParser;
  48152. /***/ }),
  48153. /* 226 */
  48154. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  48155. Object.defineProperty(exports, "__esModule", ({
  48156. value: true
  48157. }));
  48158. exports.StructTreeRoot = exports.StructTreePage = void 0;
  48159. __w_pdfjs_require__(140);
  48160. var _primitives = __w_pdfjs_require__(151);
  48161. var _util = __w_pdfjs_require__(145);
  48162. var _name_number_tree = __w_pdfjs_require__(222);
  48163. const MAX_DEPTH = 40;
  48164. const StructElementType = {
  48165. PAGE_CONTENT: "PAGE_CONTENT",
  48166. STREAM_CONTENT: "STREAM_CONTENT",
  48167. OBJECT: "OBJECT",
  48168. ELEMENT: "ELEMENT"
  48169. };
  48170. class StructTreeRoot {
  48171. constructor(rootDict) {
  48172. this.dict = rootDict;
  48173. this.roleMap = new Map();
  48174. }
  48175. init() {
  48176. this.readRoleMap();
  48177. }
  48178. readRoleMap() {
  48179. const roleMapDict = this.dict.get("RoleMap");
  48180. if (!(roleMapDict instanceof _primitives.Dict)) {
  48181. return;
  48182. }
  48183. roleMapDict.forEach((key, value) => {
  48184. if (!(value instanceof _primitives.Name)) {
  48185. return;
  48186. }
  48187. this.roleMap.set(key, value.name);
  48188. });
  48189. }
  48190. }
  48191. exports.StructTreeRoot = StructTreeRoot;
  48192. class StructElementNode {
  48193. constructor(tree, dict) {
  48194. this.tree = tree;
  48195. this.dict = dict;
  48196. this.kids = [];
  48197. this.parseKids();
  48198. }
  48199. get role() {
  48200. const nameObj = this.dict.get("S");
  48201. const name = nameObj instanceof _primitives.Name ? nameObj.name : "";
  48202. const {
  48203. root
  48204. } = this.tree;
  48205. if (root.roleMap.has(name)) {
  48206. return root.roleMap.get(name);
  48207. }
  48208. return name;
  48209. }
  48210. parseKids() {
  48211. let pageObjId = null;
  48212. const objRef = this.dict.getRaw("Pg");
  48213. if (objRef instanceof _primitives.Ref) {
  48214. pageObjId = objRef.toString();
  48215. }
  48216. const kids = this.dict.get("K");
  48217. if (Array.isArray(kids)) {
  48218. for (const kid of kids) {
  48219. const element = this.parseKid(pageObjId, kid);
  48220. if (element) {
  48221. this.kids.push(element);
  48222. }
  48223. }
  48224. } else {
  48225. const element = this.parseKid(pageObjId, kids);
  48226. if (element) {
  48227. this.kids.push(element);
  48228. }
  48229. }
  48230. }
  48231. parseKid(pageObjId, kid) {
  48232. if (Number.isInteger(kid)) {
  48233. if (this.tree.pageDict.objId !== pageObjId) {
  48234. return null;
  48235. }
  48236. return new StructElement({
  48237. type: StructElementType.PAGE_CONTENT,
  48238. mcid: kid,
  48239. pageObjId
  48240. });
  48241. }
  48242. let kidDict = null;
  48243. if (kid instanceof _primitives.Ref) {
  48244. kidDict = this.dict.xref.fetch(kid);
  48245. } else if (kid instanceof _primitives.Dict) {
  48246. kidDict = kid;
  48247. }
  48248. if (!kidDict) {
  48249. return null;
  48250. }
  48251. const pageRef = kidDict.getRaw("Pg");
  48252. if (pageRef instanceof _primitives.Ref) {
  48253. pageObjId = pageRef.toString();
  48254. }
  48255. const type = kidDict.get("Type") instanceof _primitives.Name ? kidDict.get("Type").name : null;
  48256. if (type === "MCR") {
  48257. if (this.tree.pageDict.objId !== pageObjId) {
  48258. return null;
  48259. }
  48260. return new StructElement({
  48261. type: StructElementType.STREAM_CONTENT,
  48262. refObjId: kidDict.getRaw("Stm") instanceof _primitives.Ref ? kidDict.getRaw("Stm").toString() : null,
  48263. pageObjId,
  48264. mcid: kidDict.get("MCID")
  48265. });
  48266. }
  48267. if (type === "OBJR") {
  48268. if (this.tree.pageDict.objId !== pageObjId) {
  48269. return null;
  48270. }
  48271. return new StructElement({
  48272. type: StructElementType.OBJECT,
  48273. refObjId: kidDict.getRaw("Obj") instanceof _primitives.Ref ? kidDict.getRaw("Obj").toString() : null,
  48274. pageObjId
  48275. });
  48276. }
  48277. return new StructElement({
  48278. type: StructElementType.ELEMENT,
  48279. dict: kidDict
  48280. });
  48281. }
  48282. }
  48283. class StructElement {
  48284. constructor(_ref) {
  48285. let {
  48286. type,
  48287. dict = null,
  48288. mcid = null,
  48289. pageObjId = null,
  48290. refObjId = null
  48291. } = _ref;
  48292. this.type = type;
  48293. this.dict = dict;
  48294. this.mcid = mcid;
  48295. this.pageObjId = pageObjId;
  48296. this.refObjId = refObjId;
  48297. this.parentNode = null;
  48298. }
  48299. }
  48300. class StructTreePage {
  48301. constructor(structTreeRoot, pageDict) {
  48302. this.root = structTreeRoot;
  48303. this.rootDict = structTreeRoot ? structTreeRoot.dict : null;
  48304. this.pageDict = pageDict;
  48305. this.nodes = [];
  48306. }
  48307. parse() {
  48308. if (!this.root || !this.rootDict) {
  48309. return;
  48310. }
  48311. const parentTree = this.rootDict.get("ParentTree");
  48312. if (!parentTree) {
  48313. return;
  48314. }
  48315. const id = this.pageDict.get("StructParents");
  48316. if (!Number.isInteger(id)) {
  48317. return;
  48318. }
  48319. const numberTree = new _name_number_tree.NumberTree(parentTree, this.rootDict.xref);
  48320. const parentArray = numberTree.get(id);
  48321. if (!Array.isArray(parentArray)) {
  48322. return;
  48323. }
  48324. const map = new Map();
  48325. for (const ref of parentArray) {
  48326. if (ref instanceof _primitives.Ref) {
  48327. this.addNode(this.rootDict.xref.fetch(ref), map);
  48328. }
  48329. }
  48330. }
  48331. addNode(dict, map) {
  48332. let level = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
  48333. if (level > MAX_DEPTH) {
  48334. (0, _util.warn)("StructTree MAX_DEPTH reached.");
  48335. return null;
  48336. }
  48337. if (map.has(dict)) {
  48338. return map.get(dict);
  48339. }
  48340. const element = new StructElementNode(this, dict);
  48341. map.set(dict, element);
  48342. const parent = dict.get("P");
  48343. if (!parent || (0, _primitives.isName)(parent.get("Type"), "StructTreeRoot")) {
  48344. if (!this.addTopLevelNode(dict, element)) {
  48345. map.delete(dict);
  48346. }
  48347. return element;
  48348. }
  48349. const parentNode = this.addNode(parent, map, level + 1);
  48350. if (!parentNode) {
  48351. return element;
  48352. }
  48353. let save = false;
  48354. for (const kid of parentNode.kids) {
  48355. if (kid.type === StructElementType.ELEMENT && kid.dict === dict) {
  48356. kid.parentNode = element;
  48357. save = true;
  48358. }
  48359. }
  48360. if (!save) {
  48361. map.delete(dict);
  48362. }
  48363. return element;
  48364. }
  48365. addTopLevelNode(dict, element) {
  48366. const obj = this.rootDict.get("K");
  48367. if (!obj) {
  48368. return false;
  48369. }
  48370. if (obj instanceof _primitives.Dict) {
  48371. if (obj.objId !== dict.objId) {
  48372. return false;
  48373. }
  48374. this.nodes[0] = element;
  48375. return true;
  48376. }
  48377. if (!Array.isArray(obj)) {
  48378. return true;
  48379. }
  48380. let save = false;
  48381. for (let i = 0; i < obj.length; i++) {
  48382. const kidRef = obj[i];
  48383. if (kidRef?.toString() === dict.objId) {
  48384. this.nodes[i] = element;
  48385. save = true;
  48386. }
  48387. }
  48388. return save;
  48389. }
  48390. get serializable() {
  48391. function nodeToSerializable(node, parent) {
  48392. let level = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
  48393. if (level > MAX_DEPTH) {
  48394. (0, _util.warn)("StructTree too deep to be fully serialized.");
  48395. return;
  48396. }
  48397. const obj = Object.create(null);
  48398. obj.role = node.role;
  48399. obj.children = [];
  48400. parent.children.push(obj);
  48401. const alt = node.dict.get("Alt");
  48402. if (typeof alt === "string") {
  48403. obj.alt = (0, _util.stringToPDFString)(alt);
  48404. }
  48405. const lang = node.dict.get("Lang");
  48406. if (typeof lang === "string") {
  48407. obj.lang = (0, _util.stringToPDFString)(lang);
  48408. }
  48409. for (const kid of node.kids) {
  48410. const kidElement = kid.type === StructElementType.ELEMENT ? kid.parentNode : null;
  48411. if (kidElement) {
  48412. nodeToSerializable(kidElement, obj, level + 1);
  48413. continue;
  48414. } else if (kid.type === StructElementType.PAGE_CONTENT || kid.type === StructElementType.STREAM_CONTENT) {
  48415. obj.children.push({
  48416. type: "content",
  48417. id: `p${kid.pageObjId}_mc${kid.mcid}`
  48418. });
  48419. } else if (kid.type === StructElementType.OBJECT) {
  48420. obj.children.push({
  48421. type: "object",
  48422. id: kid.refObjId
  48423. });
  48424. }
  48425. }
  48426. }
  48427. const root = Object.create(null);
  48428. root.children = [];
  48429. root.role = "Root";
  48430. for (const child of this.nodes) {
  48431. if (!child) {
  48432. continue;
  48433. }
  48434. nodeToSerializable(child, root);
  48435. }
  48436. return root;
  48437. }
  48438. }
  48439. exports.StructTreePage = StructTreePage;
  48440. /***/ }),
  48441. /* 227 */
  48442. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  48443. Object.defineProperty(exports, "__esModule", ({
  48444. value: true
  48445. }));
  48446. exports.ObjectLoader = void 0;
  48447. __w_pdfjs_require__(140);
  48448. var _primitives = __w_pdfjs_require__(151);
  48449. var _base_stream = __w_pdfjs_require__(152);
  48450. var _core_utils = __w_pdfjs_require__(150);
  48451. var _util = __w_pdfjs_require__(145);
  48452. function mayHaveChildren(value) {
  48453. return value instanceof _primitives.Ref || value instanceof _primitives.Dict || value instanceof _base_stream.BaseStream || Array.isArray(value);
  48454. }
  48455. function addChildren(node, nodesToVisit) {
  48456. if (node instanceof _primitives.Dict) {
  48457. node = node.getRawValues();
  48458. } else if (node instanceof _base_stream.BaseStream) {
  48459. node = node.dict.getRawValues();
  48460. } else if (!Array.isArray(node)) {
  48461. return;
  48462. }
  48463. for (const rawValue of node) {
  48464. if (mayHaveChildren(rawValue)) {
  48465. nodesToVisit.push(rawValue);
  48466. }
  48467. }
  48468. }
  48469. class ObjectLoader {
  48470. constructor(dict, keys, xref) {
  48471. this.dict = dict;
  48472. this.keys = keys;
  48473. this.xref = xref;
  48474. this.refSet = null;
  48475. }
  48476. async load() {
  48477. if (this.xref.stream.isDataLoaded) {
  48478. return undefined;
  48479. }
  48480. const {
  48481. keys,
  48482. dict
  48483. } = this;
  48484. this.refSet = new _primitives.RefSet();
  48485. const nodesToVisit = [];
  48486. for (const key of keys) {
  48487. const rawValue = dict.getRaw(key);
  48488. if (rawValue !== undefined) {
  48489. nodesToVisit.push(rawValue);
  48490. }
  48491. }
  48492. return this._walk(nodesToVisit);
  48493. }
  48494. async _walk(nodesToVisit) {
  48495. const nodesToRevisit = [];
  48496. const pendingRequests = [];
  48497. while (nodesToVisit.length) {
  48498. let currentNode = nodesToVisit.pop();
  48499. if (currentNode instanceof _primitives.Ref) {
  48500. if (this.refSet.has(currentNode)) {
  48501. continue;
  48502. }
  48503. try {
  48504. this.refSet.put(currentNode);
  48505. currentNode = this.xref.fetch(currentNode);
  48506. } catch (ex) {
  48507. if (!(ex instanceof _core_utils.MissingDataException)) {
  48508. (0, _util.warn)(`ObjectLoader._walk - requesting all data: "${ex}".`);
  48509. this.refSet = null;
  48510. const {
  48511. manager
  48512. } = this.xref.stream;
  48513. return manager.requestAllChunks();
  48514. }
  48515. nodesToRevisit.push(currentNode);
  48516. pendingRequests.push({
  48517. begin: ex.begin,
  48518. end: ex.end
  48519. });
  48520. }
  48521. }
  48522. if (currentNode instanceof _base_stream.BaseStream) {
  48523. const baseStreams = currentNode.getBaseStreams();
  48524. if (baseStreams) {
  48525. let foundMissingData = false;
  48526. for (const stream of baseStreams) {
  48527. if (stream.isDataLoaded) {
  48528. continue;
  48529. }
  48530. foundMissingData = true;
  48531. pendingRequests.push({
  48532. begin: stream.start,
  48533. end: stream.end
  48534. });
  48535. }
  48536. if (foundMissingData) {
  48537. nodesToRevisit.push(currentNode);
  48538. }
  48539. }
  48540. }
  48541. addChildren(currentNode, nodesToVisit);
  48542. }
  48543. if (pendingRequests.length) {
  48544. await this.xref.stream.manager.requestRanges(pendingRequests);
  48545. for (const node of nodesToRevisit) {
  48546. if (node instanceof _primitives.Ref) {
  48547. this.refSet.remove(node);
  48548. }
  48549. }
  48550. return this._walk(nodesToRevisit);
  48551. }
  48552. this.refSet = null;
  48553. return undefined;
  48554. }
  48555. }
  48556. exports.ObjectLoader = ObjectLoader;
  48557. /***/ }),
  48558. /* 228 */
  48559. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  48560. Object.defineProperty(exports, "__esModule", ({
  48561. value: true
  48562. }));
  48563. exports.XFAFactory = void 0;
  48564. __w_pdfjs_require__(140);
  48565. var _symbol_utils = __w_pdfjs_require__(229);
  48566. var _bind = __w_pdfjs_require__(230);
  48567. var _data = __w_pdfjs_require__(243);
  48568. var _fonts = __w_pdfjs_require__(239);
  48569. var _utils = __w_pdfjs_require__(238);
  48570. var _util = __w_pdfjs_require__(145);
  48571. var _parser = __w_pdfjs_require__(244);
  48572. var _xhtml = __w_pdfjs_require__(254);
  48573. class XFAFactory {
  48574. constructor(data) {
  48575. try {
  48576. this.root = new _parser.XFAParser().parse(XFAFactory._createDocument(data));
  48577. const binder = new _bind.Binder(this.root);
  48578. this.form = binder.bind();
  48579. this.dataHandler = new _data.DataHandler(this.root, binder.getData());
  48580. this.form[_symbol_utils.$globalData].template = this.form;
  48581. } catch (e) {
  48582. (0, _util.warn)(`XFA - an error occurred during parsing and binding: ${e}`);
  48583. }
  48584. }
  48585. isValid() {
  48586. return this.root && this.form;
  48587. }
  48588. _createPagesHelper() {
  48589. const iterator = this.form[_symbol_utils.$toPages]();
  48590. return new Promise((resolve, reject) => {
  48591. const nextIteration = () => {
  48592. try {
  48593. const value = iterator.next();
  48594. if (value.done) {
  48595. resolve(value.value);
  48596. } else {
  48597. setTimeout(nextIteration, 0);
  48598. }
  48599. } catch (e) {
  48600. reject(e);
  48601. }
  48602. };
  48603. setTimeout(nextIteration, 0);
  48604. });
  48605. }
  48606. async _createPages() {
  48607. try {
  48608. this.pages = await this._createPagesHelper();
  48609. this.dims = this.pages.children.map(c => {
  48610. const {
  48611. width,
  48612. height
  48613. } = c.attributes.style;
  48614. return [0, 0, parseInt(width), parseInt(height)];
  48615. });
  48616. } catch (e) {
  48617. (0, _util.warn)(`XFA - an error occurred during layout: ${e}`);
  48618. }
  48619. }
  48620. getBoundingBox(pageIndex) {
  48621. return this.dims[pageIndex];
  48622. }
  48623. async getNumPages() {
  48624. if (!this.pages) {
  48625. await this._createPages();
  48626. }
  48627. return this.dims.length;
  48628. }
  48629. setImages(images) {
  48630. this.form[_symbol_utils.$globalData].images = images;
  48631. }
  48632. setFonts(fonts) {
  48633. this.form[_symbol_utils.$globalData].fontFinder = new _fonts.FontFinder(fonts);
  48634. const missingFonts = [];
  48635. for (let typeface of this.form[_symbol_utils.$globalData].usedTypefaces) {
  48636. typeface = (0, _utils.stripQuotes)(typeface);
  48637. const font = this.form[_symbol_utils.$globalData].fontFinder.find(typeface);
  48638. if (!font) {
  48639. missingFonts.push(typeface);
  48640. }
  48641. }
  48642. if (missingFonts.length > 0) {
  48643. return missingFonts;
  48644. }
  48645. return null;
  48646. }
  48647. appendFonts(fonts, reallyMissingFonts) {
  48648. this.form[_symbol_utils.$globalData].fontFinder.add(fonts, reallyMissingFonts);
  48649. }
  48650. async getPages() {
  48651. if (!this.pages) {
  48652. await this._createPages();
  48653. }
  48654. const pages = this.pages;
  48655. this.pages = null;
  48656. return pages;
  48657. }
  48658. serializeData(storage) {
  48659. return this.dataHandler.serialize(storage);
  48660. }
  48661. static _createDocument(data) {
  48662. if (!data["/xdp:xdp"]) {
  48663. return data["xdp:xdp"];
  48664. }
  48665. return Object.values(data).join("");
  48666. }
  48667. static getRichTextAsHtml(rc) {
  48668. if (!rc || typeof rc !== "string") {
  48669. return null;
  48670. }
  48671. try {
  48672. let root = new _parser.XFAParser(_xhtml.XhtmlNamespace, true).parse(rc);
  48673. if (!["body", "xhtml"].includes(root[_symbol_utils.$nodeName])) {
  48674. const newRoot = _xhtml.XhtmlNamespace.body({});
  48675. newRoot[_symbol_utils.$appendChild](root);
  48676. root = newRoot;
  48677. }
  48678. const result = root[_symbol_utils.$toHTML]();
  48679. if (!result.success) {
  48680. return null;
  48681. }
  48682. const {
  48683. html
  48684. } = result;
  48685. const {
  48686. attributes
  48687. } = html;
  48688. if (attributes) {
  48689. if (attributes.class) {
  48690. attributes.class = attributes.class.filter(attr => !attr.startsWith("xfa"));
  48691. }
  48692. attributes.dir = "auto";
  48693. }
  48694. return {
  48695. html,
  48696. str: root[_symbol_utils.$text]()
  48697. };
  48698. } catch (e) {
  48699. (0, _util.warn)(`XFA - an error occurred during parsing of rich text: ${e}`);
  48700. }
  48701. return null;
  48702. }
  48703. }
  48704. exports.XFAFactory = XFAFactory;
  48705. /***/ }),
  48706. /* 229 */
  48707. /***/ ((__unused_webpack_module, exports) => {
  48708. Object.defineProperty(exports, "__esModule", ({
  48709. value: true
  48710. }));
  48711. 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;
  48712. const $acceptWhitespace = Symbol();
  48713. exports.$acceptWhitespace = $acceptWhitespace;
  48714. const $addHTML = Symbol();
  48715. exports.$addHTML = $addHTML;
  48716. const $appendChild = Symbol();
  48717. exports.$appendChild = $appendChild;
  48718. const $childrenToHTML = Symbol();
  48719. exports.$childrenToHTML = $childrenToHTML;
  48720. const $clean = Symbol();
  48721. exports.$clean = $clean;
  48722. const $cleanPage = Symbol();
  48723. exports.$cleanPage = $cleanPage;
  48724. const $cleanup = Symbol();
  48725. exports.$cleanup = $cleanup;
  48726. const $clone = Symbol();
  48727. exports.$clone = $clone;
  48728. const $consumed = Symbol();
  48729. exports.$consumed = $consumed;
  48730. const $content = Symbol("content");
  48731. exports.$content = $content;
  48732. const $data = Symbol("data");
  48733. exports.$data = $data;
  48734. const $dump = Symbol();
  48735. exports.$dump = $dump;
  48736. const $extra = Symbol("extra");
  48737. exports.$extra = $extra;
  48738. const $finalize = Symbol();
  48739. exports.$finalize = $finalize;
  48740. const $flushHTML = Symbol();
  48741. exports.$flushHTML = $flushHTML;
  48742. const $getAttributeIt = Symbol();
  48743. exports.$getAttributeIt = $getAttributeIt;
  48744. const $getAttributes = Symbol();
  48745. exports.$getAttributes = $getAttributes;
  48746. const $getAvailableSpace = Symbol();
  48747. exports.$getAvailableSpace = $getAvailableSpace;
  48748. const $getChildrenByClass = Symbol();
  48749. exports.$getChildrenByClass = $getChildrenByClass;
  48750. const $getChildrenByName = Symbol();
  48751. exports.$getChildrenByName = $getChildrenByName;
  48752. const $getChildrenByNameIt = Symbol();
  48753. exports.$getChildrenByNameIt = $getChildrenByNameIt;
  48754. const $getDataValue = Symbol();
  48755. exports.$getDataValue = $getDataValue;
  48756. const $getExtra = Symbol();
  48757. exports.$getExtra = $getExtra;
  48758. const $getRealChildrenByNameIt = Symbol();
  48759. exports.$getRealChildrenByNameIt = $getRealChildrenByNameIt;
  48760. const $getChildren = Symbol();
  48761. exports.$getChildren = $getChildren;
  48762. const $getContainedChildren = Symbol();
  48763. exports.$getContainedChildren = $getContainedChildren;
  48764. const $getNextPage = Symbol();
  48765. exports.$getNextPage = $getNextPage;
  48766. const $getSubformParent = Symbol();
  48767. exports.$getSubformParent = $getSubformParent;
  48768. const $getParent = Symbol();
  48769. exports.$getParent = $getParent;
  48770. const $getTemplateRoot = Symbol();
  48771. exports.$getTemplateRoot = $getTemplateRoot;
  48772. const $globalData = Symbol();
  48773. exports.$globalData = $globalData;
  48774. const $hasSettableValue = Symbol();
  48775. exports.$hasSettableValue = $hasSettableValue;
  48776. const $ids = Symbol();
  48777. exports.$ids = $ids;
  48778. const $indexOf = Symbol();
  48779. exports.$indexOf = $indexOf;
  48780. const $insertAt = Symbol();
  48781. exports.$insertAt = $insertAt;
  48782. const $isCDATAXml = Symbol();
  48783. exports.$isCDATAXml = $isCDATAXml;
  48784. const $isBindable = Symbol();
  48785. exports.$isBindable = $isBindable;
  48786. const $isDataValue = Symbol();
  48787. exports.$isDataValue = $isDataValue;
  48788. const $isDescendent = Symbol();
  48789. exports.$isDescendent = $isDescendent;
  48790. const $isNsAgnostic = Symbol();
  48791. exports.$isNsAgnostic = $isNsAgnostic;
  48792. const $isSplittable = Symbol();
  48793. exports.$isSplittable = $isSplittable;
  48794. const $isThereMoreWidth = Symbol();
  48795. exports.$isThereMoreWidth = $isThereMoreWidth;
  48796. const $isTransparent = Symbol();
  48797. exports.$isTransparent = $isTransparent;
  48798. const $isUsable = Symbol();
  48799. exports.$isUsable = $isUsable;
  48800. const $lastAttribute = Symbol();
  48801. exports.$lastAttribute = $lastAttribute;
  48802. const $namespaceId = Symbol("namespaceId");
  48803. exports.$namespaceId = $namespaceId;
  48804. const $nodeName = Symbol("nodeName");
  48805. exports.$nodeName = $nodeName;
  48806. const $nsAttributes = Symbol();
  48807. exports.$nsAttributes = $nsAttributes;
  48808. const $onChild = Symbol();
  48809. exports.$onChild = $onChild;
  48810. const $onChildCheck = Symbol();
  48811. exports.$onChildCheck = $onChildCheck;
  48812. const $onText = Symbol();
  48813. exports.$onText = $onText;
  48814. const $pushGlyphs = Symbol();
  48815. exports.$pushGlyphs = $pushGlyphs;
  48816. const $popPara = Symbol();
  48817. exports.$popPara = $popPara;
  48818. const $pushPara = Symbol();
  48819. exports.$pushPara = $pushPara;
  48820. const $removeChild = Symbol();
  48821. exports.$removeChild = $removeChild;
  48822. const $root = Symbol("root");
  48823. exports.$root = $root;
  48824. const $resolvePrototypes = Symbol();
  48825. exports.$resolvePrototypes = $resolvePrototypes;
  48826. const $searchNode = Symbol();
  48827. exports.$searchNode = $searchNode;
  48828. const $setId = Symbol();
  48829. exports.$setId = $setId;
  48830. const $setSetAttributes = Symbol();
  48831. exports.$setSetAttributes = $setSetAttributes;
  48832. const $setValue = Symbol();
  48833. exports.$setValue = $setValue;
  48834. const $tabIndex = Symbol();
  48835. exports.$tabIndex = $tabIndex;
  48836. const $text = Symbol();
  48837. exports.$text = $text;
  48838. const $toPages = Symbol();
  48839. exports.$toPages = $toPages;
  48840. const $toHTML = Symbol();
  48841. exports.$toHTML = $toHTML;
  48842. const $toString = Symbol();
  48843. exports.$toString = $toString;
  48844. const $toStyle = Symbol();
  48845. exports.$toStyle = $toStyle;
  48846. const $uid = Symbol("uid");
  48847. exports.$uid = $uid;
  48848. /***/ }),
  48849. /* 230 */
  48850. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  48851. Object.defineProperty(exports, "__esModule", ({
  48852. value: true
  48853. }));
  48854. exports.Binder = void 0;
  48855. __w_pdfjs_require__(140);
  48856. var _symbol_utils = __w_pdfjs_require__(229);
  48857. var _template = __w_pdfjs_require__(231);
  48858. var _som = __w_pdfjs_require__(242);
  48859. var _xfa_object = __w_pdfjs_require__(241);
  48860. var _namespaces = __w_pdfjs_require__(235);
  48861. var _util = __w_pdfjs_require__(145);
  48862. const NS_DATASETS = _namespaces.NamespaceIds.datasets.id;
  48863. function createText(content) {
  48864. const node = new _template.Text({});
  48865. node[_symbol_utils.$content] = content;
  48866. return node;
  48867. }
  48868. class Binder {
  48869. constructor(root) {
  48870. this.root = root;
  48871. this.datasets = root.datasets;
  48872. this.data = root.datasets?.data || new _xfa_object.XmlObject(_namespaces.NamespaceIds.datasets.id, "data");
  48873. this.emptyMerge = this.data[_symbol_utils.$getChildren]().length === 0;
  48874. this.root.form = this.form = root.template[_symbol_utils.$clone]();
  48875. }
  48876. _isConsumeData() {
  48877. return !this.emptyMerge && this._mergeMode;
  48878. }
  48879. _isMatchTemplate() {
  48880. return !this._isConsumeData();
  48881. }
  48882. bind() {
  48883. this._bindElement(this.form, this.data);
  48884. return this.form;
  48885. }
  48886. getData() {
  48887. return this.data;
  48888. }
  48889. _bindValue(formNode, data, picture) {
  48890. formNode[_symbol_utils.$data] = data;
  48891. if (formNode[_symbol_utils.$hasSettableValue]()) {
  48892. if (data[_symbol_utils.$isDataValue]()) {
  48893. const value = data[_symbol_utils.$getDataValue]();
  48894. formNode[_symbol_utils.$setValue](createText(value));
  48895. } else if (formNode instanceof _template.Field && formNode.ui?.choiceList?.open === "multiSelect") {
  48896. const value = data[_symbol_utils.$getChildren]().map(child => child[_symbol_utils.$content].trim()).join("\n");
  48897. formNode[_symbol_utils.$setValue](createText(value));
  48898. } else if (this._isConsumeData()) {
  48899. (0, _util.warn)(`XFA - Nodes haven't the same type.`);
  48900. }
  48901. } else if (!data[_symbol_utils.$isDataValue]() || this._isMatchTemplate()) {
  48902. this._bindElement(formNode, data);
  48903. } else {
  48904. (0, _util.warn)(`XFA - Nodes haven't the same type.`);
  48905. }
  48906. }
  48907. _findDataByNameToConsume(name, isValue, dataNode, global) {
  48908. if (!name) {
  48909. return null;
  48910. }
  48911. let generator, match;
  48912. for (let i = 0; i < 3; i++) {
  48913. generator = dataNode[_symbol_utils.$getRealChildrenByNameIt](name, false, true);
  48914. while (true) {
  48915. match = generator.next().value;
  48916. if (!match) {
  48917. break;
  48918. }
  48919. if (isValue === match[_symbol_utils.$isDataValue]()) {
  48920. return match;
  48921. }
  48922. }
  48923. if (dataNode[_symbol_utils.$namespaceId] === _namespaces.NamespaceIds.datasets.id && dataNode[_symbol_utils.$nodeName] === "data") {
  48924. break;
  48925. }
  48926. dataNode = dataNode[_symbol_utils.$getParent]();
  48927. }
  48928. if (!global) {
  48929. return null;
  48930. }
  48931. generator = this.data[_symbol_utils.$getRealChildrenByNameIt](name, true, false);
  48932. match = generator.next().value;
  48933. if (match) {
  48934. return match;
  48935. }
  48936. generator = this.data[_symbol_utils.$getAttributeIt](name, true);
  48937. match = generator.next().value;
  48938. if (match?.[_symbol_utils.$isDataValue]()) {
  48939. return match;
  48940. }
  48941. return null;
  48942. }
  48943. _setProperties(formNode, dataNode) {
  48944. if (!formNode.hasOwnProperty("setProperty")) {
  48945. return;
  48946. }
  48947. for (const {
  48948. ref,
  48949. target,
  48950. connection
  48951. } of formNode.setProperty.children) {
  48952. if (connection) {
  48953. continue;
  48954. }
  48955. if (!ref) {
  48956. continue;
  48957. }
  48958. const nodes = (0, _som.searchNode)(this.root, dataNode, ref, false, false);
  48959. if (!nodes) {
  48960. (0, _util.warn)(`XFA - Invalid reference: ${ref}.`);
  48961. continue;
  48962. }
  48963. const [node] = nodes;
  48964. if (!node[_symbol_utils.$isDescendent](this.data)) {
  48965. (0, _util.warn)(`XFA - Invalid node: must be a data node.`);
  48966. continue;
  48967. }
  48968. const targetNodes = (0, _som.searchNode)(this.root, formNode, target, false, false);
  48969. if (!targetNodes) {
  48970. (0, _util.warn)(`XFA - Invalid target: ${target}.`);
  48971. continue;
  48972. }
  48973. const [targetNode] = targetNodes;
  48974. if (!targetNode[_symbol_utils.$isDescendent](formNode)) {
  48975. (0, _util.warn)(`XFA - Invalid target: must be a property or subproperty.`);
  48976. continue;
  48977. }
  48978. const targetParent = targetNode[_symbol_utils.$getParent]();
  48979. if (targetNode instanceof _template.SetProperty || targetParent instanceof _template.SetProperty) {
  48980. (0, _util.warn)(`XFA - Invalid target: cannot be a setProperty or one of its properties.`);
  48981. continue;
  48982. }
  48983. if (targetNode instanceof _template.BindItems || targetParent instanceof _template.BindItems) {
  48984. (0, _util.warn)(`XFA - Invalid target: cannot be a bindItems or one of its properties.`);
  48985. continue;
  48986. }
  48987. const content = node[_symbol_utils.$text]();
  48988. const name = targetNode[_symbol_utils.$nodeName];
  48989. if (targetNode instanceof _xfa_object.XFAAttribute) {
  48990. const attrs = Object.create(null);
  48991. attrs[name] = content;
  48992. const obj = Reflect.construct(Object.getPrototypeOf(targetParent).constructor, [attrs]);
  48993. targetParent[name] = obj[name];
  48994. continue;
  48995. }
  48996. if (!targetNode.hasOwnProperty(_symbol_utils.$content)) {
  48997. (0, _util.warn)(`XFA - Invalid node to use in setProperty`);
  48998. continue;
  48999. }
  49000. targetNode[_symbol_utils.$data] = node;
  49001. targetNode[_symbol_utils.$content] = content;
  49002. targetNode[_symbol_utils.$finalize]();
  49003. }
  49004. }
  49005. _bindItems(formNode, dataNode) {
  49006. if (!formNode.hasOwnProperty("items") || !formNode.hasOwnProperty("bindItems") || formNode.bindItems.isEmpty()) {
  49007. return;
  49008. }
  49009. for (const item of formNode.items.children) {
  49010. formNode[_symbol_utils.$removeChild](item);
  49011. }
  49012. formNode.items.clear();
  49013. const labels = new _template.Items({});
  49014. const values = new _template.Items({});
  49015. formNode[_symbol_utils.$appendChild](labels);
  49016. formNode.items.push(labels);
  49017. formNode[_symbol_utils.$appendChild](values);
  49018. formNode.items.push(values);
  49019. for (const {
  49020. ref,
  49021. labelRef,
  49022. valueRef,
  49023. connection
  49024. } of formNode.bindItems.children) {
  49025. if (connection) {
  49026. continue;
  49027. }
  49028. if (!ref) {
  49029. continue;
  49030. }
  49031. const nodes = (0, _som.searchNode)(this.root, dataNode, ref, false, false);
  49032. if (!nodes) {
  49033. (0, _util.warn)(`XFA - Invalid reference: ${ref}.`);
  49034. continue;
  49035. }
  49036. for (const node of nodes) {
  49037. if (!node[_symbol_utils.$isDescendent](this.datasets)) {
  49038. (0, _util.warn)(`XFA - Invalid ref (${ref}): must be a datasets child.`);
  49039. continue;
  49040. }
  49041. const labelNodes = (0, _som.searchNode)(this.root, node, labelRef, true, false);
  49042. if (!labelNodes) {
  49043. (0, _util.warn)(`XFA - Invalid label: ${labelRef}.`);
  49044. continue;
  49045. }
  49046. const [labelNode] = labelNodes;
  49047. if (!labelNode[_symbol_utils.$isDescendent](this.datasets)) {
  49048. (0, _util.warn)(`XFA - Invalid label: must be a datasets child.`);
  49049. continue;
  49050. }
  49051. const valueNodes = (0, _som.searchNode)(this.root, node, valueRef, true, false);
  49052. if (!valueNodes) {
  49053. (0, _util.warn)(`XFA - Invalid value: ${valueRef}.`);
  49054. continue;
  49055. }
  49056. const [valueNode] = valueNodes;
  49057. if (!valueNode[_symbol_utils.$isDescendent](this.datasets)) {
  49058. (0, _util.warn)(`XFA - Invalid value: must be a datasets child.`);
  49059. continue;
  49060. }
  49061. const label = createText(labelNode[_symbol_utils.$text]());
  49062. const value = createText(valueNode[_symbol_utils.$text]());
  49063. labels[_symbol_utils.$appendChild](label);
  49064. labels.text.push(label);
  49065. values[_symbol_utils.$appendChild](value);
  49066. values.text.push(value);
  49067. }
  49068. }
  49069. }
  49070. _bindOccurrences(formNode, matches, picture) {
  49071. let baseClone;
  49072. if (matches.length > 1) {
  49073. baseClone = formNode[_symbol_utils.$clone]();
  49074. baseClone[_symbol_utils.$removeChild](baseClone.occur);
  49075. baseClone.occur = null;
  49076. }
  49077. this._bindValue(formNode, matches[0], picture);
  49078. this._setProperties(formNode, matches[0]);
  49079. this._bindItems(formNode, matches[0]);
  49080. if (matches.length === 1) {
  49081. return;
  49082. }
  49083. const parent = formNode[_symbol_utils.$getParent]();
  49084. const name = formNode[_symbol_utils.$nodeName];
  49085. const pos = parent[_symbol_utils.$indexOf](formNode);
  49086. for (let i = 1, ii = matches.length; i < ii; i++) {
  49087. const match = matches[i];
  49088. const clone = baseClone[_symbol_utils.$clone]();
  49089. parent[name].push(clone);
  49090. parent[_symbol_utils.$insertAt](pos + i, clone);
  49091. this._bindValue(clone, match, picture);
  49092. this._setProperties(clone, match);
  49093. this._bindItems(clone, match);
  49094. }
  49095. }
  49096. _createOccurrences(formNode) {
  49097. if (!this.emptyMerge) {
  49098. return;
  49099. }
  49100. const {
  49101. occur
  49102. } = formNode;
  49103. if (!occur || occur.initial <= 1) {
  49104. return;
  49105. }
  49106. const parent = formNode[_symbol_utils.$getParent]();
  49107. const name = formNode[_symbol_utils.$nodeName];
  49108. if (!(parent[name] instanceof _xfa_object.XFAObjectArray)) {
  49109. return;
  49110. }
  49111. let currentNumber;
  49112. if (formNode.name) {
  49113. currentNumber = parent[name].children.filter(e => e.name === formNode.name).length;
  49114. } else {
  49115. currentNumber = parent[name].children.length;
  49116. }
  49117. const pos = parent[_symbol_utils.$indexOf](formNode) + 1;
  49118. const ii = occur.initial - currentNumber;
  49119. if (ii) {
  49120. const nodeClone = formNode[_symbol_utils.$clone]();
  49121. nodeClone[_symbol_utils.$removeChild](nodeClone.occur);
  49122. nodeClone.occur = null;
  49123. parent[name].push(nodeClone);
  49124. parent[_symbol_utils.$insertAt](pos, nodeClone);
  49125. for (let i = 1; i < ii; i++) {
  49126. const clone = nodeClone[_symbol_utils.$clone]();
  49127. parent[name].push(clone);
  49128. parent[_symbol_utils.$insertAt](pos + i, clone);
  49129. }
  49130. }
  49131. }
  49132. _getOccurInfo(formNode) {
  49133. const {
  49134. name,
  49135. occur
  49136. } = formNode;
  49137. if (!occur || !name) {
  49138. return [1, 1];
  49139. }
  49140. const max = occur.max === -1 ? Infinity : occur.max;
  49141. return [occur.min, max];
  49142. }
  49143. _setAndBind(formNode, dataNode) {
  49144. this._setProperties(formNode, dataNode);
  49145. this._bindItems(formNode, dataNode);
  49146. this._bindElement(formNode, dataNode);
  49147. }
  49148. _bindElement(formNode, dataNode) {
  49149. const uselessNodes = [];
  49150. this._createOccurrences(formNode);
  49151. for (const child of formNode[_symbol_utils.$getChildren]()) {
  49152. if (child[_symbol_utils.$data]) {
  49153. continue;
  49154. }
  49155. if (this._mergeMode === undefined && child[_symbol_utils.$nodeName] === "subform") {
  49156. this._mergeMode = child.mergeMode === "consumeData";
  49157. const dataChildren = dataNode[_symbol_utils.$getChildren]();
  49158. if (dataChildren.length > 0) {
  49159. this._bindOccurrences(child, [dataChildren[0]], null);
  49160. } else if (this.emptyMerge) {
  49161. const nsId = dataNode[_symbol_utils.$namespaceId] === NS_DATASETS ? -1 : dataNode[_symbol_utils.$namespaceId];
  49162. const dataChild = child[_symbol_utils.$data] = new _xfa_object.XmlObject(nsId, child.name || "root");
  49163. dataNode[_symbol_utils.$appendChild](dataChild);
  49164. this._bindElement(child, dataChild);
  49165. }
  49166. continue;
  49167. }
  49168. if (!child[_symbol_utils.$isBindable]()) {
  49169. continue;
  49170. }
  49171. let global = false;
  49172. let picture = null;
  49173. let ref = null;
  49174. let match = null;
  49175. if (child.bind) {
  49176. switch (child.bind.match) {
  49177. case "none":
  49178. this._setAndBind(child, dataNode);
  49179. continue;
  49180. case "global":
  49181. global = true;
  49182. break;
  49183. case "dataRef":
  49184. if (!child.bind.ref) {
  49185. (0, _util.warn)(`XFA - ref is empty in node ${child[_symbol_utils.$nodeName]}.`);
  49186. this._setAndBind(child, dataNode);
  49187. continue;
  49188. }
  49189. ref = child.bind.ref;
  49190. break;
  49191. default:
  49192. break;
  49193. }
  49194. if (child.bind.picture) {
  49195. picture = child.bind.picture[_symbol_utils.$content];
  49196. }
  49197. }
  49198. const [min, max] = this._getOccurInfo(child);
  49199. if (ref) {
  49200. match = (0, _som.searchNode)(this.root, dataNode, ref, true, false);
  49201. if (match === null) {
  49202. match = (0, _som.createDataNode)(this.data, dataNode, ref);
  49203. if (!match) {
  49204. continue;
  49205. }
  49206. if (this._isConsumeData()) {
  49207. match[_symbol_utils.$consumed] = true;
  49208. }
  49209. this._setAndBind(child, match);
  49210. continue;
  49211. } else {
  49212. if (this._isConsumeData()) {
  49213. match = match.filter(node => !node[_symbol_utils.$consumed]);
  49214. }
  49215. if (match.length > max) {
  49216. match = match.slice(0, max);
  49217. } else if (match.length === 0) {
  49218. match = null;
  49219. }
  49220. if (match && this._isConsumeData()) {
  49221. match.forEach(node => {
  49222. node[_symbol_utils.$consumed] = true;
  49223. });
  49224. }
  49225. }
  49226. } else {
  49227. if (!child.name) {
  49228. this._setAndBind(child, dataNode);
  49229. continue;
  49230. }
  49231. if (this._isConsumeData()) {
  49232. const matches = [];
  49233. while (matches.length < max) {
  49234. const found = this._findDataByNameToConsume(child.name, child[_symbol_utils.$hasSettableValue](), dataNode, global);
  49235. if (!found) {
  49236. break;
  49237. }
  49238. found[_symbol_utils.$consumed] = true;
  49239. matches.push(found);
  49240. }
  49241. match = matches.length > 0 ? matches : null;
  49242. } else {
  49243. match = dataNode[_symbol_utils.$getRealChildrenByNameIt](child.name, false, this.emptyMerge).next().value;
  49244. if (!match) {
  49245. if (min === 0) {
  49246. uselessNodes.push(child);
  49247. continue;
  49248. }
  49249. const nsId = dataNode[_symbol_utils.$namespaceId] === NS_DATASETS ? -1 : dataNode[_symbol_utils.$namespaceId];
  49250. match = child[_symbol_utils.$data] = new _xfa_object.XmlObject(nsId, child.name);
  49251. if (this.emptyMerge) {
  49252. match[_symbol_utils.$consumed] = true;
  49253. }
  49254. dataNode[_symbol_utils.$appendChild](match);
  49255. this._setAndBind(child, match);
  49256. continue;
  49257. }
  49258. if (this.emptyMerge) {
  49259. match[_symbol_utils.$consumed] = true;
  49260. }
  49261. match = [match];
  49262. }
  49263. }
  49264. if (match) {
  49265. this._bindOccurrences(child, match, picture);
  49266. } else if (min > 0) {
  49267. this._setAndBind(child, dataNode);
  49268. } else {
  49269. uselessNodes.push(child);
  49270. }
  49271. }
  49272. uselessNodes.forEach(node => node[_symbol_utils.$getParent]()[_symbol_utils.$removeChild](node));
  49273. }
  49274. }
  49275. exports.Binder = Binder;
  49276. /***/ }),
  49277. /* 231 */
  49278. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  49279. Object.defineProperty(exports, "__esModule", ({
  49280. value: true
  49281. }));
  49282. exports.Value = exports.Text = exports.TemplateNamespace = exports.Template = exports.SetProperty = exports.Items = exports.Field = exports.BindItems = void 0;
  49283. __w_pdfjs_require__(116);
  49284. __w_pdfjs_require__(127);
  49285. __w_pdfjs_require__(129);
  49286. __w_pdfjs_require__(132);
  49287. __w_pdfjs_require__(134);
  49288. __w_pdfjs_require__(136);
  49289. __w_pdfjs_require__(138);
  49290. __w_pdfjs_require__(140);
  49291. __w_pdfjs_require__(232);
  49292. __w_pdfjs_require__(146);
  49293. __w_pdfjs_require__(148);
  49294. __w_pdfjs_require__(149);
  49295. var _symbol_utils = __w_pdfjs_require__(229);
  49296. var _namespaces = __w_pdfjs_require__(235);
  49297. var _layout = __w_pdfjs_require__(236);
  49298. var _html_utils = __w_pdfjs_require__(237);
  49299. var _xfa_object = __w_pdfjs_require__(241);
  49300. var _utils = __w_pdfjs_require__(238);
  49301. var _util = __w_pdfjs_require__(145);
  49302. var _fonts = __w_pdfjs_require__(239);
  49303. var _core_utils = __w_pdfjs_require__(150);
  49304. var _som = __w_pdfjs_require__(242);
  49305. const TEMPLATE_NS_ID = _namespaces.NamespaceIds.template.id;
  49306. const SVG_NS = "http://www.w3.org/2000/svg";
  49307. const MAX_ATTEMPTS_FOR_LRTB_LAYOUT = 2;
  49308. const MAX_EMPTY_PAGES = 3;
  49309. const DEFAULT_TAB_INDEX = 5000;
  49310. const HEADING_PATTERN = /^H(\d+)$/;
  49311. 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"]);
  49312. 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"]];
  49313. function getBorderDims(node) {
  49314. if (!node || !node.border) {
  49315. return {
  49316. w: 0,
  49317. h: 0
  49318. };
  49319. }
  49320. const borderExtra = node.border[_symbol_utils.$getExtra]();
  49321. if (!borderExtra) {
  49322. return {
  49323. w: 0,
  49324. h: 0
  49325. };
  49326. }
  49327. return {
  49328. w: borderExtra.widths[0] + borderExtra.widths[2] + borderExtra.insets[0] + borderExtra.insets[2],
  49329. h: borderExtra.widths[1] + borderExtra.widths[3] + borderExtra.insets[1] + borderExtra.insets[3]
  49330. };
  49331. }
  49332. function hasMargin(node) {
  49333. return node.margin && (node.margin.topInset || node.margin.rightInset || node.margin.bottomInset || node.margin.leftInset);
  49334. }
  49335. function _setValue(templateNode, value) {
  49336. if (!templateNode.value) {
  49337. const nodeValue = new Value({});
  49338. templateNode[_symbol_utils.$appendChild](nodeValue);
  49339. templateNode.value = nodeValue;
  49340. }
  49341. templateNode.value[_symbol_utils.$setValue](value);
  49342. }
  49343. function* getContainedChildren(node) {
  49344. for (const child of node[_symbol_utils.$getChildren]()) {
  49345. if (child instanceof SubformSet) {
  49346. yield* child[_symbol_utils.$getContainedChildren]();
  49347. continue;
  49348. }
  49349. yield child;
  49350. }
  49351. }
  49352. function isRequired(node) {
  49353. return node.validate?.nullTest === "error";
  49354. }
  49355. function setTabIndex(node) {
  49356. while (node) {
  49357. if (!node.traversal) {
  49358. node[_symbol_utils.$tabIndex] = node[_symbol_utils.$getParent]()[_symbol_utils.$tabIndex];
  49359. return;
  49360. }
  49361. if (node[_symbol_utils.$tabIndex]) {
  49362. return;
  49363. }
  49364. let next = null;
  49365. for (const child of node.traversal[_symbol_utils.$getChildren]()) {
  49366. if (child.operation === "next") {
  49367. next = child;
  49368. break;
  49369. }
  49370. }
  49371. if (!next || !next.ref) {
  49372. node[_symbol_utils.$tabIndex] = node[_symbol_utils.$getParent]()[_symbol_utils.$tabIndex];
  49373. return;
  49374. }
  49375. const root = node[_symbol_utils.$getTemplateRoot]();
  49376. node[_symbol_utils.$tabIndex] = ++root[_symbol_utils.$tabIndex];
  49377. const ref = root[_symbol_utils.$searchNode](next.ref, node);
  49378. if (!ref) {
  49379. return;
  49380. }
  49381. node = ref[0];
  49382. }
  49383. }
  49384. function applyAssist(obj, attributes) {
  49385. const assist = obj.assist;
  49386. if (assist) {
  49387. const assistTitle = assist[_symbol_utils.$toHTML]();
  49388. if (assistTitle) {
  49389. attributes.title = assistTitle;
  49390. }
  49391. const role = assist.role;
  49392. const match = role.match(HEADING_PATTERN);
  49393. if (match) {
  49394. const ariaRole = "heading";
  49395. const ariaLevel = match[1];
  49396. attributes.role = ariaRole;
  49397. attributes["aria-level"] = ariaLevel;
  49398. }
  49399. }
  49400. if (obj.layout === "table") {
  49401. attributes.role = "table";
  49402. } else if (obj.layout === "row") {
  49403. attributes.role = "row";
  49404. } else {
  49405. const parent = obj[_symbol_utils.$getParent]();
  49406. if (parent.layout === "row") {
  49407. attributes.role = parent.assist?.role === "TH" ? "columnheader" : "cell";
  49408. }
  49409. }
  49410. }
  49411. function ariaLabel(obj) {
  49412. if (!obj.assist) {
  49413. return null;
  49414. }
  49415. const assist = obj.assist;
  49416. if (assist.speak && assist.speak[_symbol_utils.$content] !== "") {
  49417. return assist.speak[_symbol_utils.$content];
  49418. }
  49419. if (assist.toolTip) {
  49420. return assist.toolTip[_symbol_utils.$content];
  49421. }
  49422. return null;
  49423. }
  49424. function valueToHtml(value) {
  49425. return _utils.HTMLResult.success({
  49426. name: "div",
  49427. attributes: {
  49428. class: ["xfaRich"],
  49429. style: Object.create(null)
  49430. },
  49431. children: [{
  49432. name: "span",
  49433. attributes: {
  49434. style: Object.create(null)
  49435. },
  49436. value
  49437. }]
  49438. });
  49439. }
  49440. function setFirstUnsplittable(node) {
  49441. const root = node[_symbol_utils.$getTemplateRoot]();
  49442. if (root[_symbol_utils.$extra].firstUnsplittable === null) {
  49443. root[_symbol_utils.$extra].firstUnsplittable = node;
  49444. root[_symbol_utils.$extra].noLayoutFailure = true;
  49445. }
  49446. }
  49447. function unsetFirstUnsplittable(node) {
  49448. const root = node[_symbol_utils.$getTemplateRoot]();
  49449. if (root[_symbol_utils.$extra].firstUnsplittable === node) {
  49450. root[_symbol_utils.$extra].noLayoutFailure = false;
  49451. }
  49452. }
  49453. function handleBreak(node) {
  49454. if (node[_symbol_utils.$extra]) {
  49455. return false;
  49456. }
  49457. node[_symbol_utils.$extra] = Object.create(null);
  49458. if (node.targetType === "auto") {
  49459. return false;
  49460. }
  49461. const root = node[_symbol_utils.$getTemplateRoot]();
  49462. let target = null;
  49463. if (node.target) {
  49464. target = root[_symbol_utils.$searchNode](node.target, node[_symbol_utils.$getParent]());
  49465. if (!target) {
  49466. return false;
  49467. }
  49468. target = target[0];
  49469. }
  49470. const {
  49471. currentPageArea,
  49472. currentContentArea
  49473. } = root[_symbol_utils.$extra];
  49474. if (node.targetType === "pageArea") {
  49475. if (!(target instanceof PageArea)) {
  49476. target = null;
  49477. }
  49478. if (node.startNew) {
  49479. node[_symbol_utils.$extra].target = target || currentPageArea;
  49480. return true;
  49481. } else if (target && target !== currentPageArea) {
  49482. node[_symbol_utils.$extra].target = target;
  49483. return true;
  49484. }
  49485. return false;
  49486. }
  49487. if (!(target instanceof ContentArea)) {
  49488. target = null;
  49489. }
  49490. const pageArea = target && target[_symbol_utils.$getParent]();
  49491. let index;
  49492. let nextPageArea = pageArea;
  49493. if (node.startNew) {
  49494. if (target) {
  49495. const contentAreas = pageArea.contentArea.children;
  49496. const indexForCurrent = contentAreas.indexOf(currentContentArea);
  49497. const indexForTarget = contentAreas.indexOf(target);
  49498. if (indexForCurrent !== -1 && indexForCurrent < indexForTarget) {
  49499. nextPageArea = null;
  49500. }
  49501. index = indexForTarget - 1;
  49502. } else {
  49503. index = currentPageArea.contentArea.children.indexOf(currentContentArea);
  49504. }
  49505. } else if (target && target !== currentContentArea) {
  49506. const contentAreas = pageArea.contentArea.children;
  49507. index = contentAreas.indexOf(target) - 1;
  49508. nextPageArea = pageArea === currentPageArea ? null : pageArea;
  49509. } else {
  49510. return false;
  49511. }
  49512. node[_symbol_utils.$extra].target = nextPageArea;
  49513. node[_symbol_utils.$extra].index = index;
  49514. return true;
  49515. }
  49516. function handleOverflow(node, extraNode, space) {
  49517. const root = node[_symbol_utils.$getTemplateRoot]();
  49518. const saved = root[_symbol_utils.$extra].noLayoutFailure;
  49519. const savedMethod = extraNode[_symbol_utils.$getSubformParent];
  49520. extraNode[_symbol_utils.$getSubformParent] = () => node;
  49521. root[_symbol_utils.$extra].noLayoutFailure = true;
  49522. const res = extraNode[_symbol_utils.$toHTML](space);
  49523. node[_symbol_utils.$addHTML](res.html, res.bbox);
  49524. root[_symbol_utils.$extra].noLayoutFailure = saved;
  49525. extraNode[_symbol_utils.$getSubformParent] = savedMethod;
  49526. }
  49527. class AppearanceFilter extends _xfa_object.StringObject {
  49528. constructor(attributes) {
  49529. super(TEMPLATE_NS_ID, "appearanceFilter");
  49530. this.id = attributes.id || "";
  49531. this.type = (0, _utils.getStringOption)(attributes.type, ["optional", "required"]);
  49532. this.use = attributes.use || "";
  49533. this.usehref = attributes.usehref || "";
  49534. }
  49535. }
  49536. class Arc extends _xfa_object.XFAObject {
  49537. constructor(attributes) {
  49538. super(TEMPLATE_NS_ID, "arc", true);
  49539. this.circular = (0, _utils.getInteger)({
  49540. data: attributes.circular,
  49541. defaultValue: 0,
  49542. validate: x => x === 1
  49543. });
  49544. this.hand = (0, _utils.getStringOption)(attributes.hand, ["even", "left", "right"]);
  49545. this.id = attributes.id || "";
  49546. this.startAngle = (0, _utils.getFloat)({
  49547. data: attributes.startAngle,
  49548. defaultValue: 0,
  49549. validate: x => true
  49550. });
  49551. this.sweepAngle = (0, _utils.getFloat)({
  49552. data: attributes.sweepAngle,
  49553. defaultValue: 360,
  49554. validate: x => true
  49555. });
  49556. this.use = attributes.use || "";
  49557. this.usehref = attributes.usehref || "";
  49558. this.edge = null;
  49559. this.fill = null;
  49560. }
  49561. [_symbol_utils.$toHTML]() {
  49562. const edge = this.edge || new Edge({});
  49563. const edgeStyle = edge[_symbol_utils.$toStyle]();
  49564. const style = Object.create(null);
  49565. if (this.fill?.presence === "visible") {
  49566. Object.assign(style, this.fill[_symbol_utils.$toStyle]());
  49567. } else {
  49568. style.fill = "transparent";
  49569. }
  49570. style.strokeWidth = (0, _html_utils.measureToString)(edge.presence === "visible" ? edge.thickness : 0);
  49571. style.stroke = edgeStyle.color;
  49572. let arc;
  49573. const attributes = {
  49574. xmlns: SVG_NS,
  49575. style: {
  49576. width: "100%",
  49577. height: "100%",
  49578. overflow: "visible"
  49579. }
  49580. };
  49581. if (this.sweepAngle === 360) {
  49582. arc = {
  49583. name: "ellipse",
  49584. attributes: {
  49585. xmlns: SVG_NS,
  49586. cx: "50%",
  49587. cy: "50%",
  49588. rx: "50%",
  49589. ry: "50%",
  49590. style
  49591. }
  49592. };
  49593. } else {
  49594. const startAngle = this.startAngle * Math.PI / 180;
  49595. const sweepAngle = this.sweepAngle * Math.PI / 180;
  49596. const largeArc = this.sweepAngle > 180 ? 1 : 0;
  49597. 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))];
  49598. arc = {
  49599. name: "path",
  49600. attributes: {
  49601. xmlns: SVG_NS,
  49602. d: `M ${x1} ${y1} A 50 50 0 ${largeArc} 0 ${x2} ${y2}`,
  49603. vectorEffect: "non-scaling-stroke",
  49604. style
  49605. }
  49606. };
  49607. Object.assign(attributes, {
  49608. viewBox: "0 0 100 100",
  49609. preserveAspectRatio: "none"
  49610. });
  49611. }
  49612. const svg = {
  49613. name: "svg",
  49614. children: [arc],
  49615. attributes
  49616. };
  49617. const parent = this[_symbol_utils.$getParent]()[_symbol_utils.$getParent]();
  49618. if (hasMargin(parent)) {
  49619. return _utils.HTMLResult.success({
  49620. name: "div",
  49621. attributes: {
  49622. style: {
  49623. display: "inline",
  49624. width: "100%",
  49625. height: "100%"
  49626. }
  49627. },
  49628. children: [svg]
  49629. });
  49630. }
  49631. svg.attributes.style.position = "absolute";
  49632. return _utils.HTMLResult.success(svg);
  49633. }
  49634. }
  49635. class Area extends _xfa_object.XFAObject {
  49636. constructor(attributes) {
  49637. super(TEMPLATE_NS_ID, "area", true);
  49638. this.colSpan = (0, _utils.getInteger)({
  49639. data: attributes.colSpan,
  49640. defaultValue: 1,
  49641. validate: n => n >= 1 || n === -1
  49642. });
  49643. this.id = attributes.id || "";
  49644. this.name = attributes.name || "";
  49645. this.relevant = (0, _utils.getRelevant)(attributes.relevant);
  49646. this.use = attributes.use || "";
  49647. this.usehref = attributes.usehref || "";
  49648. this.x = (0, _utils.getMeasurement)(attributes.x, "0pt");
  49649. this.y = (0, _utils.getMeasurement)(attributes.y, "0pt");
  49650. this.desc = null;
  49651. this.extras = null;
  49652. this.area = new _xfa_object.XFAObjectArray();
  49653. this.draw = new _xfa_object.XFAObjectArray();
  49654. this.exObject = new _xfa_object.XFAObjectArray();
  49655. this.exclGroup = new _xfa_object.XFAObjectArray();
  49656. this.field = new _xfa_object.XFAObjectArray();
  49657. this.subform = new _xfa_object.XFAObjectArray();
  49658. this.subformSet = new _xfa_object.XFAObjectArray();
  49659. }
  49660. *[_symbol_utils.$getContainedChildren]() {
  49661. yield* getContainedChildren(this);
  49662. }
  49663. [_symbol_utils.$isTransparent]() {
  49664. return true;
  49665. }
  49666. [_symbol_utils.$isBindable]() {
  49667. return true;
  49668. }
  49669. [_symbol_utils.$addHTML](html, bbox) {
  49670. const [x, y, w, h] = bbox;
  49671. this[_symbol_utils.$extra].width = Math.max(this[_symbol_utils.$extra].width, x + w);
  49672. this[_symbol_utils.$extra].height = Math.max(this[_symbol_utils.$extra].height, y + h);
  49673. this[_symbol_utils.$extra].children.push(html);
  49674. }
  49675. [_symbol_utils.$getAvailableSpace]() {
  49676. return this[_symbol_utils.$extra].availableSpace;
  49677. }
  49678. [_symbol_utils.$toHTML](availableSpace) {
  49679. const style = (0, _html_utils.toStyle)(this, "position");
  49680. const attributes = {
  49681. style,
  49682. id: this[_symbol_utils.$uid],
  49683. class: ["xfaArea"]
  49684. };
  49685. if ((0, _html_utils.isPrintOnly)(this)) {
  49686. attributes.class.push("xfaPrintOnly");
  49687. }
  49688. if (this.name) {
  49689. attributes.xfaName = this.name;
  49690. }
  49691. const children = [];
  49692. this[_symbol_utils.$extra] = {
  49693. children,
  49694. width: 0,
  49695. height: 0,
  49696. availableSpace
  49697. };
  49698. const result = this[_symbol_utils.$childrenToHTML]({
  49699. filter: new Set(["area", "draw", "field", "exclGroup", "subform", "subformSet"]),
  49700. include: true
  49701. });
  49702. if (!result.success) {
  49703. if (result.isBreak()) {
  49704. return result;
  49705. }
  49706. delete this[_symbol_utils.$extra];
  49707. return _utils.HTMLResult.FAILURE;
  49708. }
  49709. style.width = (0, _html_utils.measureToString)(this[_symbol_utils.$extra].width);
  49710. style.height = (0, _html_utils.measureToString)(this[_symbol_utils.$extra].height);
  49711. const html = {
  49712. name: "div",
  49713. attributes,
  49714. children
  49715. };
  49716. const bbox = [this.x, this.y, this[_symbol_utils.$extra].width, this[_symbol_utils.$extra].height];
  49717. delete this[_symbol_utils.$extra];
  49718. return _utils.HTMLResult.success(html, bbox);
  49719. }
  49720. }
  49721. class Assist extends _xfa_object.XFAObject {
  49722. constructor(attributes) {
  49723. super(TEMPLATE_NS_ID, "assist", true);
  49724. this.id = attributes.id || "";
  49725. this.role = attributes.role || "";
  49726. this.use = attributes.use || "";
  49727. this.usehref = attributes.usehref || "";
  49728. this.speak = null;
  49729. this.toolTip = null;
  49730. }
  49731. [_symbol_utils.$toHTML]() {
  49732. return this.toolTip?.[_symbol_utils.$content] || null;
  49733. }
  49734. }
  49735. class Barcode extends _xfa_object.XFAObject {
  49736. constructor(attributes) {
  49737. super(TEMPLATE_NS_ID, "barcode", true);
  49738. this.charEncoding = (0, _utils.getKeyword)({
  49739. data: attributes.charEncoding ? attributes.charEncoding.toLowerCase() : "",
  49740. defaultValue: "",
  49741. 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}/)
  49742. });
  49743. this.checksum = (0, _utils.getStringOption)(attributes.checksum, ["none", "1mod10", "1mod10_1mod11", "2mod10", "auto"]);
  49744. this.dataColumnCount = (0, _utils.getInteger)({
  49745. data: attributes.dataColumnCount,
  49746. defaultValue: -1,
  49747. validate: x => x >= 0
  49748. });
  49749. this.dataLength = (0, _utils.getInteger)({
  49750. data: attributes.dataLength,
  49751. defaultValue: -1,
  49752. validate: x => x >= 0
  49753. });
  49754. this.dataPrep = (0, _utils.getStringOption)(attributes.dataPrep, ["none", "flateCompress"]);
  49755. this.dataRowCount = (0, _utils.getInteger)({
  49756. data: attributes.dataRowCount,
  49757. defaultValue: -1,
  49758. validate: x => x >= 0
  49759. });
  49760. this.endChar = attributes.endChar || "";
  49761. this.errorCorrectionLevel = (0, _utils.getInteger)({
  49762. data: attributes.errorCorrectionLevel,
  49763. defaultValue: -1,
  49764. validate: x => x >= 0 && x <= 8
  49765. });
  49766. this.id = attributes.id || "";
  49767. this.moduleHeight = (0, _utils.getMeasurement)(attributes.moduleHeight, "5mm");
  49768. this.moduleWidth = (0, _utils.getMeasurement)(attributes.moduleWidth, "0.25mm");
  49769. this.printCheckDigit = (0, _utils.getInteger)({
  49770. data: attributes.printCheckDigit,
  49771. defaultValue: 0,
  49772. validate: x => x === 1
  49773. });
  49774. this.rowColumnRatio = (0, _utils.getRatio)(attributes.rowColumnRatio);
  49775. this.startChar = attributes.startChar || "";
  49776. this.textLocation = (0, _utils.getStringOption)(attributes.textLocation, ["below", "above", "aboveEmbedded", "belowEmbedded", "none"]);
  49777. this.truncate = (0, _utils.getInteger)({
  49778. data: attributes.truncate,
  49779. defaultValue: 0,
  49780. validate: x => x === 1
  49781. });
  49782. 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"]);
  49783. this.upsMode = (0, _utils.getStringOption)(attributes.upsMode, ["usCarrier", "internationalCarrier", "secureSymbol", "standardSymbol"]);
  49784. this.use = attributes.use || "";
  49785. this.usehref = attributes.usehref || "";
  49786. this.wideNarrowRatio = (0, _utils.getRatio)(attributes.wideNarrowRatio);
  49787. this.encrypt = null;
  49788. this.extras = null;
  49789. }
  49790. }
  49791. class Bind extends _xfa_object.XFAObject {
  49792. constructor(attributes) {
  49793. super(TEMPLATE_NS_ID, "bind", true);
  49794. this.match = (0, _utils.getStringOption)(attributes.match, ["once", "dataRef", "global", "none"]);
  49795. this.ref = attributes.ref || "";
  49796. this.picture = null;
  49797. }
  49798. }
  49799. class BindItems extends _xfa_object.XFAObject {
  49800. constructor(attributes) {
  49801. super(TEMPLATE_NS_ID, "bindItems");
  49802. this.connection = attributes.connection || "";
  49803. this.labelRef = attributes.labelRef || "";
  49804. this.ref = attributes.ref || "";
  49805. this.valueRef = attributes.valueRef || "";
  49806. }
  49807. }
  49808. exports.BindItems = BindItems;
  49809. class Bookend extends _xfa_object.XFAObject {
  49810. constructor(attributes) {
  49811. super(TEMPLATE_NS_ID, "bookend");
  49812. this.id = attributes.id || "";
  49813. this.leader = attributes.leader || "";
  49814. this.trailer = attributes.trailer || "";
  49815. this.use = attributes.use || "";
  49816. this.usehref = attributes.usehref || "";
  49817. }
  49818. }
  49819. class BooleanElement extends _xfa_object.Option01 {
  49820. constructor(attributes) {
  49821. super(TEMPLATE_NS_ID, "boolean");
  49822. this.id = attributes.id || "";
  49823. this.name = attributes.name || "";
  49824. this.use = attributes.use || "";
  49825. this.usehref = attributes.usehref || "";
  49826. }
  49827. [_symbol_utils.$toHTML](availableSpace) {
  49828. return valueToHtml(this[_symbol_utils.$content] === 1 ? "1" : "0");
  49829. }
  49830. }
  49831. class Border extends _xfa_object.XFAObject {
  49832. constructor(attributes) {
  49833. super(TEMPLATE_NS_ID, "border", true);
  49834. this.break = (0, _utils.getStringOption)(attributes.break, ["close", "open"]);
  49835. this.hand = (0, _utils.getStringOption)(attributes.hand, ["even", "left", "right"]);
  49836. this.id = attributes.id || "";
  49837. this.presence = (0, _utils.getStringOption)(attributes.presence, ["visible", "hidden", "inactive", "invisible"]);
  49838. this.relevant = (0, _utils.getRelevant)(attributes.relevant);
  49839. this.use = attributes.use || "";
  49840. this.usehref = attributes.usehref || "";
  49841. this.corner = new _xfa_object.XFAObjectArray(4);
  49842. this.edge = new _xfa_object.XFAObjectArray(4);
  49843. this.extras = null;
  49844. this.fill = null;
  49845. this.margin = null;
  49846. }
  49847. [_symbol_utils.$getExtra]() {
  49848. if (!this[_symbol_utils.$extra]) {
  49849. const edges = this.edge.children.slice();
  49850. if (edges.length < 4) {
  49851. const defaultEdge = edges.at(-1) || new Edge({});
  49852. for (let i = edges.length; i < 4; i++) {
  49853. edges.push(defaultEdge);
  49854. }
  49855. }
  49856. const widths = edges.map(edge => edge.thickness);
  49857. const insets = [0, 0, 0, 0];
  49858. if (this.margin) {
  49859. insets[0] = this.margin.topInset;
  49860. insets[1] = this.margin.rightInset;
  49861. insets[2] = this.margin.bottomInset;
  49862. insets[3] = this.margin.leftInset;
  49863. }
  49864. this[_symbol_utils.$extra] = {
  49865. widths,
  49866. insets,
  49867. edges
  49868. };
  49869. }
  49870. return this[_symbol_utils.$extra];
  49871. }
  49872. [_symbol_utils.$toStyle]() {
  49873. const {
  49874. edges
  49875. } = this[_symbol_utils.$getExtra]();
  49876. const edgeStyles = edges.map(node => {
  49877. const style = node[_symbol_utils.$toStyle]();
  49878. style.color ||= "#000000";
  49879. return style;
  49880. });
  49881. const style = Object.create(null);
  49882. if (this.margin) {
  49883. Object.assign(style, this.margin[_symbol_utils.$toStyle]());
  49884. }
  49885. if (this.fill?.presence === "visible") {
  49886. Object.assign(style, this.fill[_symbol_utils.$toStyle]());
  49887. }
  49888. if (this.corner.children.some(node => node.radius !== 0)) {
  49889. const cornerStyles = this.corner.children.map(node => node[_symbol_utils.$toStyle]());
  49890. if (cornerStyles.length === 2 || cornerStyles.length === 3) {
  49891. const last = cornerStyles.at(-1);
  49892. for (let i = cornerStyles.length; i < 4; i++) {
  49893. cornerStyles.push(last);
  49894. }
  49895. }
  49896. style.borderRadius = cornerStyles.map(s => s.radius).join(" ");
  49897. }
  49898. switch (this.presence) {
  49899. case "invisible":
  49900. case "hidden":
  49901. style.borderStyle = "";
  49902. break;
  49903. case "inactive":
  49904. style.borderStyle = "none";
  49905. break;
  49906. default:
  49907. style.borderStyle = edgeStyles.map(s => s.style).join(" ");
  49908. break;
  49909. }
  49910. style.borderWidth = edgeStyles.map(s => s.width).join(" ");
  49911. style.borderColor = edgeStyles.map(s => s.color).join(" ");
  49912. return style;
  49913. }
  49914. }
  49915. class Break extends _xfa_object.XFAObject {
  49916. constructor(attributes) {
  49917. super(TEMPLATE_NS_ID, "break", true);
  49918. this.after = (0, _utils.getStringOption)(attributes.after, ["auto", "contentArea", "pageArea", "pageEven", "pageOdd"]);
  49919. this.afterTarget = attributes.afterTarget || "";
  49920. this.before = (0, _utils.getStringOption)(attributes.before, ["auto", "contentArea", "pageArea", "pageEven", "pageOdd"]);
  49921. this.beforeTarget = attributes.beforeTarget || "";
  49922. this.bookendLeader = attributes.bookendLeader || "";
  49923. this.bookendTrailer = attributes.bookendTrailer || "";
  49924. this.id = attributes.id || "";
  49925. this.overflowLeader = attributes.overflowLeader || "";
  49926. this.overflowTarget = attributes.overflowTarget || "";
  49927. this.overflowTrailer = attributes.overflowTrailer || "";
  49928. this.startNew = (0, _utils.getInteger)({
  49929. data: attributes.startNew,
  49930. defaultValue: 0,
  49931. validate: x => x === 1
  49932. });
  49933. this.use = attributes.use || "";
  49934. this.usehref = attributes.usehref || "";
  49935. this.extras = null;
  49936. }
  49937. }
  49938. class BreakAfter extends _xfa_object.XFAObject {
  49939. constructor(attributes) {
  49940. super(TEMPLATE_NS_ID, "breakAfter", true);
  49941. this.id = attributes.id || "";
  49942. this.leader = attributes.leader || "";
  49943. this.startNew = (0, _utils.getInteger)({
  49944. data: attributes.startNew,
  49945. defaultValue: 0,
  49946. validate: x => x === 1
  49947. });
  49948. this.target = attributes.target || "";
  49949. this.targetType = (0, _utils.getStringOption)(attributes.targetType, ["auto", "contentArea", "pageArea"]);
  49950. this.trailer = attributes.trailer || "";
  49951. this.use = attributes.use || "";
  49952. this.usehref = attributes.usehref || "";
  49953. this.script = null;
  49954. }
  49955. }
  49956. class BreakBefore extends _xfa_object.XFAObject {
  49957. constructor(attributes) {
  49958. super(TEMPLATE_NS_ID, "breakBefore", true);
  49959. this.id = attributes.id || "";
  49960. this.leader = attributes.leader || "";
  49961. this.startNew = (0, _utils.getInteger)({
  49962. data: attributes.startNew,
  49963. defaultValue: 0,
  49964. validate: x => x === 1
  49965. });
  49966. this.target = attributes.target || "";
  49967. this.targetType = (0, _utils.getStringOption)(attributes.targetType, ["auto", "contentArea", "pageArea"]);
  49968. this.trailer = attributes.trailer || "";
  49969. this.use = attributes.use || "";
  49970. this.usehref = attributes.usehref || "";
  49971. this.script = null;
  49972. }
  49973. [_symbol_utils.$toHTML](availableSpace) {
  49974. this[_symbol_utils.$extra] = {};
  49975. return _utils.HTMLResult.FAILURE;
  49976. }
  49977. }
  49978. class Button extends _xfa_object.XFAObject {
  49979. constructor(attributes) {
  49980. super(TEMPLATE_NS_ID, "button", true);
  49981. this.highlight = (0, _utils.getStringOption)(attributes.highlight, ["inverted", "none", "outline", "push"]);
  49982. this.id = attributes.id || "";
  49983. this.use = attributes.use || "";
  49984. this.usehref = attributes.usehref || "";
  49985. this.extras = null;
  49986. }
  49987. [_symbol_utils.$toHTML](availableSpace) {
  49988. const parent = this[_symbol_utils.$getParent]();
  49989. const grandpa = parent[_symbol_utils.$getParent]();
  49990. const htmlButton = {
  49991. name: "button",
  49992. attributes: {
  49993. id: this[_symbol_utils.$uid],
  49994. class: ["xfaButton"],
  49995. style: {}
  49996. },
  49997. children: []
  49998. };
  49999. for (const event of grandpa.event.children) {
  50000. if (event.activity !== "click" || !event.script) {
  50001. continue;
  50002. }
  50003. const jsURL = (0, _core_utils.recoverJsURL)(event.script[_symbol_utils.$content]);
  50004. if (!jsURL) {
  50005. continue;
  50006. }
  50007. const href = (0, _html_utils.fixURL)(jsURL.url);
  50008. if (!href) {
  50009. continue;
  50010. }
  50011. htmlButton.children.push({
  50012. name: "a",
  50013. attributes: {
  50014. id: "link" + this[_symbol_utils.$uid],
  50015. href,
  50016. newWindow: jsURL.newWindow,
  50017. class: ["xfaLink"],
  50018. style: {}
  50019. },
  50020. children: []
  50021. });
  50022. }
  50023. return _utils.HTMLResult.success(htmlButton);
  50024. }
  50025. }
  50026. class Calculate extends _xfa_object.XFAObject {
  50027. constructor(attributes) {
  50028. super(TEMPLATE_NS_ID, "calculate", true);
  50029. this.id = attributes.id || "";
  50030. this.override = (0, _utils.getStringOption)(attributes.override, ["disabled", "error", "ignore", "warning"]);
  50031. this.use = attributes.use || "";
  50032. this.usehref = attributes.usehref || "";
  50033. this.extras = null;
  50034. this.message = null;
  50035. this.script = null;
  50036. }
  50037. }
  50038. class Caption extends _xfa_object.XFAObject {
  50039. constructor(attributes) {
  50040. super(TEMPLATE_NS_ID, "caption", true);
  50041. this.id = attributes.id || "";
  50042. this.placement = (0, _utils.getStringOption)(attributes.placement, ["left", "bottom", "inline", "right", "top"]);
  50043. this.presence = (0, _utils.getStringOption)(attributes.presence, ["visible", "hidden", "inactive", "invisible"]);
  50044. this.reserve = Math.ceil((0, _utils.getMeasurement)(attributes.reserve));
  50045. this.use = attributes.use || "";
  50046. this.usehref = attributes.usehref || "";
  50047. this.extras = null;
  50048. this.font = null;
  50049. this.margin = null;
  50050. this.para = null;
  50051. this.value = null;
  50052. }
  50053. [_symbol_utils.$setValue](value) {
  50054. _setValue(this, value);
  50055. }
  50056. [_symbol_utils.$getExtra](availableSpace) {
  50057. if (!this[_symbol_utils.$extra]) {
  50058. let {
  50059. width,
  50060. height
  50061. } = availableSpace;
  50062. switch (this.placement) {
  50063. case "left":
  50064. case "right":
  50065. case "inline":
  50066. width = this.reserve <= 0 ? width : this.reserve;
  50067. break;
  50068. case "top":
  50069. case "bottom":
  50070. height = this.reserve <= 0 ? height : this.reserve;
  50071. break;
  50072. }
  50073. this[_symbol_utils.$extra] = (0, _html_utils.layoutNode)(this, {
  50074. width,
  50075. height
  50076. });
  50077. }
  50078. return this[_symbol_utils.$extra];
  50079. }
  50080. [_symbol_utils.$toHTML](availableSpace) {
  50081. if (!this.value) {
  50082. return _utils.HTMLResult.EMPTY;
  50083. }
  50084. this[_symbol_utils.$pushPara]();
  50085. const value = this.value[_symbol_utils.$toHTML](availableSpace).html;
  50086. if (!value) {
  50087. this[_symbol_utils.$popPara]();
  50088. return _utils.HTMLResult.EMPTY;
  50089. }
  50090. const savedReserve = this.reserve;
  50091. if (this.reserve <= 0) {
  50092. const {
  50093. w,
  50094. h
  50095. } = this[_symbol_utils.$getExtra](availableSpace);
  50096. switch (this.placement) {
  50097. case "left":
  50098. case "right":
  50099. case "inline":
  50100. this.reserve = w;
  50101. break;
  50102. case "top":
  50103. case "bottom":
  50104. this.reserve = h;
  50105. break;
  50106. }
  50107. }
  50108. const children = [];
  50109. if (typeof value === "string") {
  50110. children.push({
  50111. name: "#text",
  50112. value
  50113. });
  50114. } else {
  50115. children.push(value);
  50116. }
  50117. const style = (0, _html_utils.toStyle)(this, "font", "margin", "visibility");
  50118. switch (this.placement) {
  50119. case "left":
  50120. case "right":
  50121. if (this.reserve > 0) {
  50122. style.width = (0, _html_utils.measureToString)(this.reserve);
  50123. }
  50124. break;
  50125. case "top":
  50126. case "bottom":
  50127. if (this.reserve > 0) {
  50128. style.height = (0, _html_utils.measureToString)(this.reserve);
  50129. }
  50130. break;
  50131. }
  50132. (0, _html_utils.setPara)(this, null, value);
  50133. this[_symbol_utils.$popPara]();
  50134. this.reserve = savedReserve;
  50135. return _utils.HTMLResult.success({
  50136. name: "div",
  50137. attributes: {
  50138. style,
  50139. class: ["xfaCaption"]
  50140. },
  50141. children
  50142. });
  50143. }
  50144. }
  50145. class Certificate extends _xfa_object.StringObject {
  50146. constructor(attributes) {
  50147. super(TEMPLATE_NS_ID, "certificate");
  50148. this.id = attributes.id || "";
  50149. this.name = attributes.name || "";
  50150. this.use = attributes.use || "";
  50151. this.usehref = attributes.usehref || "";
  50152. }
  50153. }
  50154. class Certificates extends _xfa_object.XFAObject {
  50155. constructor(attributes) {
  50156. super(TEMPLATE_NS_ID, "certificates", true);
  50157. this.credentialServerPolicy = (0, _utils.getStringOption)(attributes.credentialServerPolicy, ["optional", "required"]);
  50158. this.id = attributes.id || "";
  50159. this.url = attributes.url || "";
  50160. this.urlPolicy = attributes.urlPolicy || "";
  50161. this.use = attributes.use || "";
  50162. this.usehref = attributes.usehref || "";
  50163. this.encryption = null;
  50164. this.issuers = null;
  50165. this.keyUsage = null;
  50166. this.oids = null;
  50167. this.signing = null;
  50168. this.subjectDNs = null;
  50169. }
  50170. }
  50171. class CheckButton extends _xfa_object.XFAObject {
  50172. constructor(attributes) {
  50173. super(TEMPLATE_NS_ID, "checkButton", true);
  50174. this.id = attributes.id || "";
  50175. this.mark = (0, _utils.getStringOption)(attributes.mark, ["default", "check", "circle", "cross", "diamond", "square", "star"]);
  50176. this.shape = (0, _utils.getStringOption)(attributes.shape, ["square", "round"]);
  50177. this.size = (0, _utils.getMeasurement)(attributes.size, "10pt");
  50178. this.use = attributes.use || "";
  50179. this.usehref = attributes.usehref || "";
  50180. this.border = null;
  50181. this.extras = null;
  50182. this.margin = null;
  50183. }
  50184. [_symbol_utils.$toHTML](availableSpace) {
  50185. const style = (0, _html_utils.toStyle)("margin");
  50186. const size = (0, _html_utils.measureToString)(this.size);
  50187. style.width = style.height = size;
  50188. let type;
  50189. let className;
  50190. let groupId;
  50191. const field = this[_symbol_utils.$getParent]()[_symbol_utils.$getParent]();
  50192. const items = field.items.children.length && field.items.children[0][_symbol_utils.$toHTML]().html || [];
  50193. const exportedValue = {
  50194. on: (items[0] !== undefined ? items[0] : "on").toString(),
  50195. off: (items[1] !== undefined ? items[1] : "off").toString()
  50196. };
  50197. const value = field.value?.[_symbol_utils.$text]() || "off";
  50198. const checked = value === exportedValue.on || undefined;
  50199. const container = field[_symbol_utils.$getSubformParent]();
  50200. const fieldId = field[_symbol_utils.$uid];
  50201. let dataId;
  50202. if (container instanceof ExclGroup) {
  50203. groupId = container[_symbol_utils.$uid];
  50204. type = "radio";
  50205. className = "xfaRadio";
  50206. dataId = container[_symbol_utils.$data]?.[_symbol_utils.$uid] || container[_symbol_utils.$uid];
  50207. } else {
  50208. type = "checkbox";
  50209. className = "xfaCheckbox";
  50210. dataId = field[_symbol_utils.$data]?.[_symbol_utils.$uid] || field[_symbol_utils.$uid];
  50211. }
  50212. const input = {
  50213. name: "input",
  50214. attributes: {
  50215. class: [className],
  50216. style,
  50217. fieldId,
  50218. dataId,
  50219. type,
  50220. checked,
  50221. xfaOn: exportedValue.on,
  50222. xfaOff: exportedValue.off,
  50223. "aria-label": ariaLabel(field),
  50224. "aria-required": false
  50225. }
  50226. };
  50227. if (groupId) {
  50228. input.attributes.name = groupId;
  50229. }
  50230. if (isRequired(field)) {
  50231. input.attributes["aria-required"] = true;
  50232. input.attributes.required = true;
  50233. }
  50234. return _utils.HTMLResult.success({
  50235. name: "label",
  50236. attributes: {
  50237. class: ["xfaLabel"]
  50238. },
  50239. children: [input]
  50240. });
  50241. }
  50242. }
  50243. class ChoiceList extends _xfa_object.XFAObject {
  50244. constructor(attributes) {
  50245. super(TEMPLATE_NS_ID, "choiceList", true);
  50246. this.commitOn = (0, _utils.getStringOption)(attributes.commitOn, ["select", "exit"]);
  50247. this.id = attributes.id || "";
  50248. this.open = (0, _utils.getStringOption)(attributes.open, ["userControl", "always", "multiSelect", "onEntry"]);
  50249. this.textEntry = (0, _utils.getInteger)({
  50250. data: attributes.textEntry,
  50251. defaultValue: 0,
  50252. validate: x => x === 1
  50253. });
  50254. this.use = attributes.use || "";
  50255. this.usehref = attributes.usehref || "";
  50256. this.border = null;
  50257. this.extras = null;
  50258. this.margin = null;
  50259. }
  50260. [_symbol_utils.$toHTML](availableSpace) {
  50261. const style = (0, _html_utils.toStyle)(this, "border", "margin");
  50262. const ui = this[_symbol_utils.$getParent]();
  50263. const field = ui[_symbol_utils.$getParent]();
  50264. const fontSize = field.font?.size || 10;
  50265. const optionStyle = {
  50266. fontSize: `calc(${fontSize}px * var(--scale-factor))`
  50267. };
  50268. const children = [];
  50269. if (field.items.children.length > 0) {
  50270. const items = field.items;
  50271. let displayedIndex = 0;
  50272. let saveIndex = 0;
  50273. if (items.children.length === 2) {
  50274. displayedIndex = items.children[0].save;
  50275. saveIndex = 1 - displayedIndex;
  50276. }
  50277. const displayed = items.children[displayedIndex][_symbol_utils.$toHTML]().html;
  50278. const values = items.children[saveIndex][_symbol_utils.$toHTML]().html;
  50279. let selected = false;
  50280. const value = field.value?.[_symbol_utils.$text]() || "";
  50281. for (let i = 0, ii = displayed.length; i < ii; i++) {
  50282. const option = {
  50283. name: "option",
  50284. attributes: {
  50285. value: values[i] || displayed[i],
  50286. style: optionStyle
  50287. },
  50288. value: displayed[i]
  50289. };
  50290. if (values[i] === value) {
  50291. option.attributes.selected = selected = true;
  50292. }
  50293. children.push(option);
  50294. }
  50295. if (!selected) {
  50296. children.splice(0, 0, {
  50297. name: "option",
  50298. attributes: {
  50299. hidden: true,
  50300. selected: true
  50301. },
  50302. value: " "
  50303. });
  50304. }
  50305. }
  50306. const selectAttributes = {
  50307. class: ["xfaSelect"],
  50308. fieldId: field[_symbol_utils.$uid],
  50309. dataId: field[_symbol_utils.$data]?.[_symbol_utils.$uid] || field[_symbol_utils.$uid],
  50310. style,
  50311. "aria-label": ariaLabel(field),
  50312. "aria-required": false
  50313. };
  50314. if (isRequired(field)) {
  50315. selectAttributes["aria-required"] = true;
  50316. selectAttributes.required = true;
  50317. }
  50318. if (this.open === "multiSelect") {
  50319. selectAttributes.multiple = true;
  50320. }
  50321. return _utils.HTMLResult.success({
  50322. name: "label",
  50323. attributes: {
  50324. class: ["xfaLabel"]
  50325. },
  50326. children: [{
  50327. name: "select",
  50328. children,
  50329. attributes: selectAttributes
  50330. }]
  50331. });
  50332. }
  50333. }
  50334. class Color extends _xfa_object.XFAObject {
  50335. constructor(attributes) {
  50336. super(TEMPLATE_NS_ID, "color", true);
  50337. this.cSpace = (0, _utils.getStringOption)(attributes.cSpace, ["SRGB"]);
  50338. this.id = attributes.id || "";
  50339. this.use = attributes.use || "";
  50340. this.usehref = attributes.usehref || "";
  50341. this.value = attributes.value ? (0, _utils.getColor)(attributes.value) : "";
  50342. this.extras = null;
  50343. }
  50344. [_symbol_utils.$hasSettableValue]() {
  50345. return false;
  50346. }
  50347. [_symbol_utils.$toStyle]() {
  50348. return this.value ? _util.Util.makeHexColor(this.value.r, this.value.g, this.value.b) : null;
  50349. }
  50350. }
  50351. class Comb extends _xfa_object.XFAObject {
  50352. constructor(attributes) {
  50353. super(TEMPLATE_NS_ID, "comb");
  50354. this.id = attributes.id || "";
  50355. this.numberOfCells = (0, _utils.getInteger)({
  50356. data: attributes.numberOfCells,
  50357. defaultValue: 0,
  50358. validate: x => x >= 0
  50359. });
  50360. this.use = attributes.use || "";
  50361. this.usehref = attributes.usehref || "";
  50362. }
  50363. }
  50364. class Connect extends _xfa_object.XFAObject {
  50365. constructor(attributes) {
  50366. super(TEMPLATE_NS_ID, "connect", true);
  50367. this.connection = attributes.connection || "";
  50368. this.id = attributes.id || "";
  50369. this.ref = attributes.ref || "";
  50370. this.usage = (0, _utils.getStringOption)(attributes.usage, ["exportAndImport", "exportOnly", "importOnly"]);
  50371. this.use = attributes.use || "";
  50372. this.usehref = attributes.usehref || "";
  50373. this.picture = null;
  50374. }
  50375. }
  50376. class ContentArea extends _xfa_object.XFAObject {
  50377. constructor(attributes) {
  50378. super(TEMPLATE_NS_ID, "contentArea", true);
  50379. this.h = (0, _utils.getMeasurement)(attributes.h);
  50380. this.id = attributes.id || "";
  50381. this.name = attributes.name || "";
  50382. this.relevant = (0, _utils.getRelevant)(attributes.relevant);
  50383. this.use = attributes.use || "";
  50384. this.usehref = attributes.usehref || "";
  50385. this.w = (0, _utils.getMeasurement)(attributes.w);
  50386. this.x = (0, _utils.getMeasurement)(attributes.x, "0pt");
  50387. this.y = (0, _utils.getMeasurement)(attributes.y, "0pt");
  50388. this.desc = null;
  50389. this.extras = null;
  50390. }
  50391. [_symbol_utils.$toHTML](availableSpace) {
  50392. const left = (0, _html_utils.measureToString)(this.x);
  50393. const top = (0, _html_utils.measureToString)(this.y);
  50394. const style = {
  50395. left,
  50396. top,
  50397. width: (0, _html_utils.measureToString)(this.w),
  50398. height: (0, _html_utils.measureToString)(this.h)
  50399. };
  50400. const classNames = ["xfaContentarea"];
  50401. if ((0, _html_utils.isPrintOnly)(this)) {
  50402. classNames.push("xfaPrintOnly");
  50403. }
  50404. return _utils.HTMLResult.success({
  50405. name: "div",
  50406. children: [],
  50407. attributes: {
  50408. style,
  50409. class: classNames,
  50410. id: this[_symbol_utils.$uid]
  50411. }
  50412. });
  50413. }
  50414. }
  50415. class Corner extends _xfa_object.XFAObject {
  50416. constructor(attributes) {
  50417. super(TEMPLATE_NS_ID, "corner", true);
  50418. this.id = attributes.id || "";
  50419. this.inverted = (0, _utils.getInteger)({
  50420. data: attributes.inverted,
  50421. defaultValue: 0,
  50422. validate: x => x === 1
  50423. });
  50424. this.join = (0, _utils.getStringOption)(attributes.join, ["square", "round"]);
  50425. this.presence = (0, _utils.getStringOption)(attributes.presence, ["visible", "hidden", "inactive", "invisible"]);
  50426. this.radius = (0, _utils.getMeasurement)(attributes.radius);
  50427. this.stroke = (0, _utils.getStringOption)(attributes.stroke, ["solid", "dashDot", "dashDotDot", "dashed", "dotted", "embossed", "etched", "lowered", "raised"]);
  50428. this.thickness = (0, _utils.getMeasurement)(attributes.thickness, "0.5pt");
  50429. this.use = attributes.use || "";
  50430. this.usehref = attributes.usehref || "";
  50431. this.color = null;
  50432. this.extras = null;
  50433. }
  50434. [_symbol_utils.$toStyle]() {
  50435. const style = (0, _html_utils.toStyle)(this, "visibility");
  50436. style.radius = (0, _html_utils.measureToString)(this.join === "square" ? 0 : this.radius);
  50437. return style;
  50438. }
  50439. }
  50440. class DateElement extends _xfa_object.ContentObject {
  50441. constructor(attributes) {
  50442. super(TEMPLATE_NS_ID, "date");
  50443. this.id = attributes.id || "";
  50444. this.name = attributes.name || "";
  50445. this.use = attributes.use || "";
  50446. this.usehref = attributes.usehref || "";
  50447. }
  50448. [_symbol_utils.$finalize]() {
  50449. const date = this[_symbol_utils.$content].trim();
  50450. this[_symbol_utils.$content] = date ? new Date(date) : null;
  50451. }
  50452. [_symbol_utils.$toHTML](availableSpace) {
  50453. return valueToHtml(this[_symbol_utils.$content] ? this[_symbol_utils.$content].toString() : "");
  50454. }
  50455. }
  50456. class DateTime extends _xfa_object.ContentObject {
  50457. constructor(attributes) {
  50458. super(TEMPLATE_NS_ID, "dateTime");
  50459. this.id = attributes.id || "";
  50460. this.name = attributes.name || "";
  50461. this.use = attributes.use || "";
  50462. this.usehref = attributes.usehref || "";
  50463. }
  50464. [_symbol_utils.$finalize]() {
  50465. const date = this[_symbol_utils.$content].trim();
  50466. this[_symbol_utils.$content] = date ? new Date(date) : null;
  50467. }
  50468. [_symbol_utils.$toHTML](availableSpace) {
  50469. return valueToHtml(this[_symbol_utils.$content] ? this[_symbol_utils.$content].toString() : "");
  50470. }
  50471. }
  50472. class DateTimeEdit extends _xfa_object.XFAObject {
  50473. constructor(attributes) {
  50474. super(TEMPLATE_NS_ID, "dateTimeEdit", true);
  50475. this.hScrollPolicy = (0, _utils.getStringOption)(attributes.hScrollPolicy, ["auto", "off", "on"]);
  50476. this.id = attributes.id || "";
  50477. this.picker = (0, _utils.getStringOption)(attributes.picker, ["host", "none"]);
  50478. this.use = attributes.use || "";
  50479. this.usehref = attributes.usehref || "";
  50480. this.border = null;
  50481. this.comb = null;
  50482. this.extras = null;
  50483. this.margin = null;
  50484. }
  50485. [_symbol_utils.$toHTML](availableSpace) {
  50486. const style = (0, _html_utils.toStyle)(this, "border", "font", "margin");
  50487. const field = this[_symbol_utils.$getParent]()[_symbol_utils.$getParent]();
  50488. const html = {
  50489. name: "input",
  50490. attributes: {
  50491. type: "text",
  50492. fieldId: field[_symbol_utils.$uid],
  50493. dataId: field[_symbol_utils.$data]?.[_symbol_utils.$uid] || field[_symbol_utils.$uid],
  50494. class: ["xfaTextfield"],
  50495. style,
  50496. "aria-label": ariaLabel(field),
  50497. "aria-required": false
  50498. }
  50499. };
  50500. if (isRequired(field)) {
  50501. html.attributes["aria-required"] = true;
  50502. html.attributes.required = true;
  50503. }
  50504. return _utils.HTMLResult.success({
  50505. name: "label",
  50506. attributes: {
  50507. class: ["xfaLabel"]
  50508. },
  50509. children: [html]
  50510. });
  50511. }
  50512. }
  50513. class Decimal extends _xfa_object.ContentObject {
  50514. constructor(attributes) {
  50515. super(TEMPLATE_NS_ID, "decimal");
  50516. this.fracDigits = (0, _utils.getInteger)({
  50517. data: attributes.fracDigits,
  50518. defaultValue: 2,
  50519. validate: x => true
  50520. });
  50521. this.id = attributes.id || "";
  50522. this.leadDigits = (0, _utils.getInteger)({
  50523. data: attributes.leadDigits,
  50524. defaultValue: -1,
  50525. validate: x => true
  50526. });
  50527. this.name = attributes.name || "";
  50528. this.use = attributes.use || "";
  50529. this.usehref = attributes.usehref || "";
  50530. }
  50531. [_symbol_utils.$finalize]() {
  50532. const number = parseFloat(this[_symbol_utils.$content].trim());
  50533. this[_symbol_utils.$content] = isNaN(number) ? null : number;
  50534. }
  50535. [_symbol_utils.$toHTML](availableSpace) {
  50536. return valueToHtml(this[_symbol_utils.$content] !== null ? this[_symbol_utils.$content].toString() : "");
  50537. }
  50538. }
  50539. class DefaultUi extends _xfa_object.XFAObject {
  50540. constructor(attributes) {
  50541. super(TEMPLATE_NS_ID, "defaultUi", true);
  50542. this.id = attributes.id || "";
  50543. this.use = attributes.use || "";
  50544. this.usehref = attributes.usehref || "";
  50545. this.extras = null;
  50546. }
  50547. }
  50548. class Desc extends _xfa_object.XFAObject {
  50549. constructor(attributes) {
  50550. super(TEMPLATE_NS_ID, "desc", true);
  50551. this.id = attributes.id || "";
  50552. this.use = attributes.use || "";
  50553. this.usehref = attributes.usehref || "";
  50554. this.boolean = new _xfa_object.XFAObjectArray();
  50555. this.date = new _xfa_object.XFAObjectArray();
  50556. this.dateTime = new _xfa_object.XFAObjectArray();
  50557. this.decimal = new _xfa_object.XFAObjectArray();
  50558. this.exData = new _xfa_object.XFAObjectArray();
  50559. this.float = new _xfa_object.XFAObjectArray();
  50560. this.image = new _xfa_object.XFAObjectArray();
  50561. this.integer = new _xfa_object.XFAObjectArray();
  50562. this.text = new _xfa_object.XFAObjectArray();
  50563. this.time = new _xfa_object.XFAObjectArray();
  50564. }
  50565. }
  50566. class DigestMethod extends _xfa_object.OptionObject {
  50567. constructor(attributes) {
  50568. super(TEMPLATE_NS_ID, "digestMethod", ["", "SHA1", "SHA256", "SHA512", "RIPEMD160"]);
  50569. this.id = attributes.id || "";
  50570. this.use = attributes.use || "";
  50571. this.usehref = attributes.usehref || "";
  50572. }
  50573. }
  50574. class DigestMethods extends _xfa_object.XFAObject {
  50575. constructor(attributes) {
  50576. super(TEMPLATE_NS_ID, "digestMethods", true);
  50577. this.id = attributes.id || "";
  50578. this.type = (0, _utils.getStringOption)(attributes.type, ["optional", "required"]);
  50579. this.use = attributes.use || "";
  50580. this.usehref = attributes.usehref || "";
  50581. this.digestMethod = new _xfa_object.XFAObjectArray();
  50582. }
  50583. }
  50584. class Draw extends _xfa_object.XFAObject {
  50585. constructor(attributes) {
  50586. super(TEMPLATE_NS_ID, "draw", true);
  50587. this.anchorType = (0, _utils.getStringOption)(attributes.anchorType, ["topLeft", "bottomCenter", "bottomLeft", "bottomRight", "middleCenter", "middleLeft", "middleRight", "topCenter", "topRight"]);
  50588. this.colSpan = (0, _utils.getInteger)({
  50589. data: attributes.colSpan,
  50590. defaultValue: 1,
  50591. validate: n => n >= 1 || n === -1
  50592. });
  50593. this.h = attributes.h ? (0, _utils.getMeasurement)(attributes.h) : "";
  50594. this.hAlign = (0, _utils.getStringOption)(attributes.hAlign, ["left", "center", "justify", "justifyAll", "radix", "right"]);
  50595. this.id = attributes.id || "";
  50596. this.locale = attributes.locale || "";
  50597. this.maxH = (0, _utils.getMeasurement)(attributes.maxH, "0pt");
  50598. this.maxW = (0, _utils.getMeasurement)(attributes.maxW, "0pt");
  50599. this.minH = (0, _utils.getMeasurement)(attributes.minH, "0pt");
  50600. this.minW = (0, _utils.getMeasurement)(attributes.minW, "0pt");
  50601. this.name = attributes.name || "";
  50602. this.presence = (0, _utils.getStringOption)(attributes.presence, ["visible", "hidden", "inactive", "invisible"]);
  50603. this.relevant = (0, _utils.getRelevant)(attributes.relevant);
  50604. this.rotate = (0, _utils.getInteger)({
  50605. data: attributes.rotate,
  50606. defaultValue: 0,
  50607. validate: x => x % 90 === 0
  50608. });
  50609. this.use = attributes.use || "";
  50610. this.usehref = attributes.usehref || "";
  50611. this.w = attributes.w ? (0, _utils.getMeasurement)(attributes.w) : "";
  50612. this.x = (0, _utils.getMeasurement)(attributes.x, "0pt");
  50613. this.y = (0, _utils.getMeasurement)(attributes.y, "0pt");
  50614. this.assist = null;
  50615. this.border = null;
  50616. this.caption = null;
  50617. this.desc = null;
  50618. this.extras = null;
  50619. this.font = null;
  50620. this.keep = null;
  50621. this.margin = null;
  50622. this.para = null;
  50623. this.traversal = null;
  50624. this.ui = null;
  50625. this.value = null;
  50626. this.setProperty = new _xfa_object.XFAObjectArray();
  50627. }
  50628. [_symbol_utils.$setValue](value) {
  50629. _setValue(this, value);
  50630. }
  50631. [_symbol_utils.$toHTML](availableSpace) {
  50632. setTabIndex(this);
  50633. if (this.presence === "hidden" || this.presence === "inactive") {
  50634. return _utils.HTMLResult.EMPTY;
  50635. }
  50636. (0, _html_utils.fixDimensions)(this);
  50637. this[_symbol_utils.$pushPara]();
  50638. const savedW = this.w;
  50639. const savedH = this.h;
  50640. const {
  50641. w,
  50642. h,
  50643. isBroken
  50644. } = (0, _html_utils.layoutNode)(this, availableSpace);
  50645. if (w && this.w === "") {
  50646. if (isBroken && this[_symbol_utils.$getSubformParent]()[_symbol_utils.$isThereMoreWidth]()) {
  50647. this[_symbol_utils.$popPara]();
  50648. return _utils.HTMLResult.FAILURE;
  50649. }
  50650. this.w = w;
  50651. }
  50652. if (h && this.h === "") {
  50653. this.h = h;
  50654. }
  50655. setFirstUnsplittable(this);
  50656. if (!(0, _layout.checkDimensions)(this, availableSpace)) {
  50657. this.w = savedW;
  50658. this.h = savedH;
  50659. this[_symbol_utils.$popPara]();
  50660. return _utils.HTMLResult.FAILURE;
  50661. }
  50662. unsetFirstUnsplittable(this);
  50663. const style = (0, _html_utils.toStyle)(this, "font", "hAlign", "dimensions", "position", "presence", "rotate", "anchorType", "border", "margin");
  50664. (0, _html_utils.setMinMaxDimensions)(this, style);
  50665. if (style.margin) {
  50666. style.padding = style.margin;
  50667. delete style.margin;
  50668. }
  50669. const classNames = ["xfaDraw"];
  50670. if (this.font) {
  50671. classNames.push("xfaFont");
  50672. }
  50673. if ((0, _html_utils.isPrintOnly)(this)) {
  50674. classNames.push("xfaPrintOnly");
  50675. }
  50676. const attributes = {
  50677. style,
  50678. id: this[_symbol_utils.$uid],
  50679. class: classNames
  50680. };
  50681. if (this.name) {
  50682. attributes.xfaName = this.name;
  50683. }
  50684. const html = {
  50685. name: "div",
  50686. attributes,
  50687. children: []
  50688. };
  50689. applyAssist(this, attributes);
  50690. const bbox = (0, _html_utils.computeBbox)(this, html, availableSpace);
  50691. const value = this.value ? this.value[_symbol_utils.$toHTML](availableSpace).html : null;
  50692. if (value === null) {
  50693. this.w = savedW;
  50694. this.h = savedH;
  50695. this[_symbol_utils.$popPara]();
  50696. return _utils.HTMLResult.success((0, _html_utils.createWrapper)(this, html), bbox);
  50697. }
  50698. html.children.push(value);
  50699. (0, _html_utils.setPara)(this, style, value);
  50700. this.w = savedW;
  50701. this.h = savedH;
  50702. this[_symbol_utils.$popPara]();
  50703. return _utils.HTMLResult.success((0, _html_utils.createWrapper)(this, html), bbox);
  50704. }
  50705. }
  50706. class Edge extends _xfa_object.XFAObject {
  50707. constructor(attributes) {
  50708. super(TEMPLATE_NS_ID, "edge", true);
  50709. this.cap = (0, _utils.getStringOption)(attributes.cap, ["square", "butt", "round"]);
  50710. this.id = attributes.id || "";
  50711. this.presence = (0, _utils.getStringOption)(attributes.presence, ["visible", "hidden", "inactive", "invisible"]);
  50712. this.stroke = (0, _utils.getStringOption)(attributes.stroke, ["solid", "dashDot", "dashDotDot", "dashed", "dotted", "embossed", "etched", "lowered", "raised"]);
  50713. this.thickness = (0, _utils.getMeasurement)(attributes.thickness, "0.5pt");
  50714. this.use = attributes.use || "";
  50715. this.usehref = attributes.usehref || "";
  50716. this.color = null;
  50717. this.extras = null;
  50718. }
  50719. [_symbol_utils.$toStyle]() {
  50720. const style = (0, _html_utils.toStyle)(this, "visibility");
  50721. Object.assign(style, {
  50722. linecap: this.cap,
  50723. width: (0, _html_utils.measureToString)(this.thickness),
  50724. color: this.color ? this.color[_symbol_utils.$toStyle]() : "#000000",
  50725. style: ""
  50726. });
  50727. if (this.presence !== "visible") {
  50728. style.style = "none";
  50729. } else {
  50730. switch (this.stroke) {
  50731. case "solid":
  50732. style.style = "solid";
  50733. break;
  50734. case "dashDot":
  50735. style.style = "dashed";
  50736. break;
  50737. case "dashDotDot":
  50738. style.style = "dashed";
  50739. break;
  50740. case "dashed":
  50741. style.style = "dashed";
  50742. break;
  50743. case "dotted":
  50744. style.style = "dotted";
  50745. break;
  50746. case "embossed":
  50747. style.style = "ridge";
  50748. break;
  50749. case "etched":
  50750. style.style = "groove";
  50751. break;
  50752. case "lowered":
  50753. style.style = "inset";
  50754. break;
  50755. case "raised":
  50756. style.style = "outset";
  50757. break;
  50758. }
  50759. }
  50760. return style;
  50761. }
  50762. }
  50763. class Encoding extends _xfa_object.OptionObject {
  50764. constructor(attributes) {
  50765. super(TEMPLATE_NS_ID, "encoding", ["adbe.x509.rsa_sha1", "adbe.pkcs7.detached", "adbe.pkcs7.sha1"]);
  50766. this.id = attributes.id || "";
  50767. this.use = attributes.use || "";
  50768. this.usehref = attributes.usehref || "";
  50769. }
  50770. }
  50771. class Encodings extends _xfa_object.XFAObject {
  50772. constructor(attributes) {
  50773. super(TEMPLATE_NS_ID, "encodings", true);
  50774. this.id = attributes.id || "";
  50775. this.type = (0, _utils.getStringOption)(attributes.type, ["optional", "required"]);
  50776. this.use = attributes.use || "";
  50777. this.usehref = attributes.usehref || "";
  50778. this.encoding = new _xfa_object.XFAObjectArray();
  50779. }
  50780. }
  50781. class Encrypt extends _xfa_object.XFAObject {
  50782. constructor(attributes) {
  50783. super(TEMPLATE_NS_ID, "encrypt", true);
  50784. this.id = attributes.id || "";
  50785. this.use = attributes.use || "";
  50786. this.usehref = attributes.usehref || "";
  50787. this.certificate = null;
  50788. }
  50789. }
  50790. class EncryptData extends _xfa_object.XFAObject {
  50791. constructor(attributes) {
  50792. super(TEMPLATE_NS_ID, "encryptData", true);
  50793. this.id = attributes.id || "";
  50794. this.operation = (0, _utils.getStringOption)(attributes.operation, ["encrypt", "decrypt"]);
  50795. this.target = attributes.target || "";
  50796. this.use = attributes.use || "";
  50797. this.usehref = attributes.usehref || "";
  50798. this.filter = null;
  50799. this.manifest = null;
  50800. }
  50801. }
  50802. class Encryption extends _xfa_object.XFAObject {
  50803. constructor(attributes) {
  50804. super(TEMPLATE_NS_ID, "encryption", true);
  50805. this.id = attributes.id || "";
  50806. this.type = (0, _utils.getStringOption)(attributes.type, ["optional", "required"]);
  50807. this.use = attributes.use || "";
  50808. this.usehref = attributes.usehref || "";
  50809. this.certificate = new _xfa_object.XFAObjectArray();
  50810. }
  50811. }
  50812. class EncryptionMethod extends _xfa_object.OptionObject {
  50813. constructor(attributes) {
  50814. super(TEMPLATE_NS_ID, "encryptionMethod", ["", "AES256-CBC", "TRIPLEDES-CBC", "AES128-CBC", "AES192-CBC"]);
  50815. this.id = attributes.id || "";
  50816. this.use = attributes.use || "";
  50817. this.usehref = attributes.usehref || "";
  50818. }
  50819. }
  50820. class EncryptionMethods extends _xfa_object.XFAObject {
  50821. constructor(attributes) {
  50822. super(TEMPLATE_NS_ID, "encryptionMethods", true);
  50823. this.id = attributes.id || "";
  50824. this.type = (0, _utils.getStringOption)(attributes.type, ["optional", "required"]);
  50825. this.use = attributes.use || "";
  50826. this.usehref = attributes.usehref || "";
  50827. this.encryptionMethod = new _xfa_object.XFAObjectArray();
  50828. }
  50829. }
  50830. class Event extends _xfa_object.XFAObject {
  50831. constructor(attributes) {
  50832. super(TEMPLATE_NS_ID, "event", true);
  50833. 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"]);
  50834. this.id = attributes.id || "";
  50835. this.listen = (0, _utils.getStringOption)(attributes.listen, ["refOnly", "refAndDescendents"]);
  50836. this.name = attributes.name || "";
  50837. this.ref = attributes.ref || "";
  50838. this.use = attributes.use || "";
  50839. this.usehref = attributes.usehref || "";
  50840. this.extras = null;
  50841. this.encryptData = null;
  50842. this.execute = null;
  50843. this.script = null;
  50844. this.signData = null;
  50845. this.submit = null;
  50846. }
  50847. }
  50848. class ExData extends _xfa_object.ContentObject {
  50849. constructor(attributes) {
  50850. super(TEMPLATE_NS_ID, "exData");
  50851. this.contentType = attributes.contentType || "";
  50852. this.href = attributes.href || "";
  50853. this.id = attributes.id || "";
  50854. this.maxLength = (0, _utils.getInteger)({
  50855. data: attributes.maxLength,
  50856. defaultValue: -1,
  50857. validate: x => x >= -1
  50858. });
  50859. this.name = attributes.name || "";
  50860. this.rid = attributes.rid || "";
  50861. this.transferEncoding = (0, _utils.getStringOption)(attributes.transferEncoding, ["none", "base64", "package"]);
  50862. this.use = attributes.use || "";
  50863. this.usehref = attributes.usehref || "";
  50864. }
  50865. [_symbol_utils.$isCDATAXml]() {
  50866. return this.contentType === "text/html";
  50867. }
  50868. [_symbol_utils.$onChild](child) {
  50869. if (this.contentType === "text/html" && child[_symbol_utils.$namespaceId] === _namespaces.NamespaceIds.xhtml.id) {
  50870. this[_symbol_utils.$content] = child;
  50871. return true;
  50872. }
  50873. if (this.contentType === "text/xml") {
  50874. this[_symbol_utils.$content] = child;
  50875. return true;
  50876. }
  50877. return false;
  50878. }
  50879. [_symbol_utils.$toHTML](availableSpace) {
  50880. if (this.contentType !== "text/html" || !this[_symbol_utils.$content]) {
  50881. return _utils.HTMLResult.EMPTY;
  50882. }
  50883. return this[_symbol_utils.$content][_symbol_utils.$toHTML](availableSpace);
  50884. }
  50885. }
  50886. class ExObject extends _xfa_object.XFAObject {
  50887. constructor(attributes) {
  50888. super(TEMPLATE_NS_ID, "exObject", true);
  50889. this.archive = attributes.archive || "";
  50890. this.classId = attributes.classId || "";
  50891. this.codeBase = attributes.codeBase || "";
  50892. this.codeType = attributes.codeType || "";
  50893. this.id = attributes.id || "";
  50894. this.name = attributes.name || "";
  50895. this.use = attributes.use || "";
  50896. this.usehref = attributes.usehref || "";
  50897. this.extras = null;
  50898. this.boolean = new _xfa_object.XFAObjectArray();
  50899. this.date = new _xfa_object.XFAObjectArray();
  50900. this.dateTime = new _xfa_object.XFAObjectArray();
  50901. this.decimal = new _xfa_object.XFAObjectArray();
  50902. this.exData = new _xfa_object.XFAObjectArray();
  50903. this.exObject = new _xfa_object.XFAObjectArray();
  50904. this.float = new _xfa_object.XFAObjectArray();
  50905. this.image = new _xfa_object.XFAObjectArray();
  50906. this.integer = new _xfa_object.XFAObjectArray();
  50907. this.text = new _xfa_object.XFAObjectArray();
  50908. this.time = new _xfa_object.XFAObjectArray();
  50909. }
  50910. }
  50911. class ExclGroup extends _xfa_object.XFAObject {
  50912. constructor(attributes) {
  50913. super(TEMPLATE_NS_ID, "exclGroup", true);
  50914. this.access = (0, _utils.getStringOption)(attributes.access, ["open", "nonInteractive", "protected", "readOnly"]);
  50915. this.accessKey = attributes.accessKey || "";
  50916. this.anchorType = (0, _utils.getStringOption)(attributes.anchorType, ["topLeft", "bottomCenter", "bottomLeft", "bottomRight", "middleCenter", "middleLeft", "middleRight", "topCenter", "topRight"]);
  50917. this.colSpan = (0, _utils.getInteger)({
  50918. data: attributes.colSpan,
  50919. defaultValue: 1,
  50920. validate: n => n >= 1 || n === -1
  50921. });
  50922. this.h = attributes.h ? (0, _utils.getMeasurement)(attributes.h) : "";
  50923. this.hAlign = (0, _utils.getStringOption)(attributes.hAlign, ["left", "center", "justify", "justifyAll", "radix", "right"]);
  50924. this.id = attributes.id || "";
  50925. this.layout = (0, _utils.getStringOption)(attributes.layout, ["position", "lr-tb", "rl-row", "rl-tb", "row", "table", "tb"]);
  50926. this.maxH = (0, _utils.getMeasurement)(attributes.maxH, "0pt");
  50927. this.maxW = (0, _utils.getMeasurement)(attributes.maxW, "0pt");
  50928. this.minH = (0, _utils.getMeasurement)(attributes.minH, "0pt");
  50929. this.minW = (0, _utils.getMeasurement)(attributes.minW, "0pt");
  50930. this.name = attributes.name || "";
  50931. this.presence = (0, _utils.getStringOption)(attributes.presence, ["visible", "hidden", "inactive", "invisible"]);
  50932. this.relevant = (0, _utils.getRelevant)(attributes.relevant);
  50933. this.use = attributes.use || "";
  50934. this.usehref = attributes.usehref || "";
  50935. this.w = attributes.w ? (0, _utils.getMeasurement)(attributes.w) : "";
  50936. this.x = (0, _utils.getMeasurement)(attributes.x, "0pt");
  50937. this.y = (0, _utils.getMeasurement)(attributes.y, "0pt");
  50938. this.assist = null;
  50939. this.bind = null;
  50940. this.border = null;
  50941. this.calculate = null;
  50942. this.caption = null;
  50943. this.desc = null;
  50944. this.extras = null;
  50945. this.margin = null;
  50946. this.para = null;
  50947. this.traversal = null;
  50948. this.validate = null;
  50949. this.connect = new _xfa_object.XFAObjectArray();
  50950. this.event = new _xfa_object.XFAObjectArray();
  50951. this.field = new _xfa_object.XFAObjectArray();
  50952. this.setProperty = new _xfa_object.XFAObjectArray();
  50953. }
  50954. [_symbol_utils.$isBindable]() {
  50955. return true;
  50956. }
  50957. [_symbol_utils.$hasSettableValue]() {
  50958. return true;
  50959. }
  50960. [_symbol_utils.$setValue](value) {
  50961. for (const field of this.field.children) {
  50962. if (!field.value) {
  50963. const nodeValue = new Value({});
  50964. field[_symbol_utils.$appendChild](nodeValue);
  50965. field.value = nodeValue;
  50966. }
  50967. field.value[_symbol_utils.$setValue](value);
  50968. }
  50969. }
  50970. [_symbol_utils.$isThereMoreWidth]() {
  50971. return this.layout.endsWith("-tb") && this[_symbol_utils.$extra].attempt === 0 && this[_symbol_utils.$extra].numberInLine > 0 || this[_symbol_utils.$getParent]()[_symbol_utils.$isThereMoreWidth]();
  50972. }
  50973. [_symbol_utils.$isSplittable]() {
  50974. const parent = this[_symbol_utils.$getSubformParent]();
  50975. if (!parent[_symbol_utils.$isSplittable]()) {
  50976. return false;
  50977. }
  50978. if (this[_symbol_utils.$extra]._isSplittable !== undefined) {
  50979. return this[_symbol_utils.$extra]._isSplittable;
  50980. }
  50981. if (this.layout === "position" || this.layout.includes("row")) {
  50982. this[_symbol_utils.$extra]._isSplittable = false;
  50983. return false;
  50984. }
  50985. if (parent.layout?.endsWith("-tb") && parent[_symbol_utils.$extra].numberInLine !== 0) {
  50986. return false;
  50987. }
  50988. this[_symbol_utils.$extra]._isSplittable = true;
  50989. return true;
  50990. }
  50991. [_symbol_utils.$flushHTML]() {
  50992. return (0, _layout.flushHTML)(this);
  50993. }
  50994. [_symbol_utils.$addHTML](html, bbox) {
  50995. (0, _layout.addHTML)(this, html, bbox);
  50996. }
  50997. [_symbol_utils.$getAvailableSpace]() {
  50998. return (0, _layout.getAvailableSpace)(this);
  50999. }
  51000. [_symbol_utils.$toHTML](availableSpace) {
  51001. setTabIndex(this);
  51002. if (this.presence === "hidden" || this.presence === "inactive" || this.h === 0 || this.w === 0) {
  51003. return _utils.HTMLResult.EMPTY;
  51004. }
  51005. (0, _html_utils.fixDimensions)(this);
  51006. const children = [];
  51007. const attributes = {
  51008. id: this[_symbol_utils.$uid],
  51009. class: []
  51010. };
  51011. (0, _html_utils.setAccess)(this, attributes.class);
  51012. if (!this[_symbol_utils.$extra]) {
  51013. this[_symbol_utils.$extra] = Object.create(null);
  51014. }
  51015. Object.assign(this[_symbol_utils.$extra], {
  51016. children,
  51017. attributes,
  51018. attempt: 0,
  51019. line: null,
  51020. numberInLine: 0,
  51021. availableSpace: {
  51022. width: Math.min(this.w || Infinity, availableSpace.width),
  51023. height: Math.min(this.h || Infinity, availableSpace.height)
  51024. },
  51025. width: 0,
  51026. height: 0,
  51027. prevHeight: 0,
  51028. currentWidth: 0
  51029. });
  51030. const isSplittable = this[_symbol_utils.$isSplittable]();
  51031. if (!isSplittable) {
  51032. setFirstUnsplittable(this);
  51033. }
  51034. if (!(0, _layout.checkDimensions)(this, availableSpace)) {
  51035. return _utils.HTMLResult.FAILURE;
  51036. }
  51037. const filter = new Set(["field"]);
  51038. if (this.layout.includes("row")) {
  51039. const columnWidths = this[_symbol_utils.$getSubformParent]().columnWidths;
  51040. if (Array.isArray(columnWidths) && columnWidths.length > 0) {
  51041. this[_symbol_utils.$extra].columnWidths = columnWidths;
  51042. this[_symbol_utils.$extra].currentColumn = 0;
  51043. }
  51044. }
  51045. const style = (0, _html_utils.toStyle)(this, "anchorType", "dimensions", "position", "presence", "border", "margin", "hAlign");
  51046. const classNames = ["xfaExclgroup"];
  51047. const cl = (0, _html_utils.layoutClass)(this);
  51048. if (cl) {
  51049. classNames.push(cl);
  51050. }
  51051. if ((0, _html_utils.isPrintOnly)(this)) {
  51052. classNames.push("xfaPrintOnly");
  51053. }
  51054. attributes.style = style;
  51055. attributes.class = classNames;
  51056. if (this.name) {
  51057. attributes.xfaName = this.name;
  51058. }
  51059. this[_symbol_utils.$pushPara]();
  51060. const isLrTb = this.layout === "lr-tb" || this.layout === "rl-tb";
  51061. const maxRun = isLrTb ? MAX_ATTEMPTS_FOR_LRTB_LAYOUT : 1;
  51062. for (; this[_symbol_utils.$extra].attempt < maxRun; this[_symbol_utils.$extra].attempt++) {
  51063. if (isLrTb && this[_symbol_utils.$extra].attempt === MAX_ATTEMPTS_FOR_LRTB_LAYOUT - 1) {
  51064. this[_symbol_utils.$extra].numberInLine = 0;
  51065. }
  51066. const result = this[_symbol_utils.$childrenToHTML]({
  51067. filter,
  51068. include: true
  51069. });
  51070. if (result.success) {
  51071. break;
  51072. }
  51073. if (result.isBreak()) {
  51074. this[_symbol_utils.$popPara]();
  51075. return result;
  51076. }
  51077. if (isLrTb && this[_symbol_utils.$extra].attempt === 0 && this[_symbol_utils.$extra].numberInLine === 0 && !this[_symbol_utils.$getTemplateRoot]()[_symbol_utils.$extra].noLayoutFailure) {
  51078. this[_symbol_utils.$extra].attempt = maxRun;
  51079. break;
  51080. }
  51081. }
  51082. this[_symbol_utils.$popPara]();
  51083. if (!isSplittable) {
  51084. unsetFirstUnsplittable(this);
  51085. }
  51086. if (this[_symbol_utils.$extra].attempt === maxRun) {
  51087. if (!isSplittable) {
  51088. delete this[_symbol_utils.$extra];
  51089. }
  51090. return _utils.HTMLResult.FAILURE;
  51091. }
  51092. let marginH = 0;
  51093. let marginV = 0;
  51094. if (this.margin) {
  51095. marginH = this.margin.leftInset + this.margin.rightInset;
  51096. marginV = this.margin.topInset + this.margin.bottomInset;
  51097. }
  51098. const width = Math.max(this[_symbol_utils.$extra].width + marginH, this.w || 0);
  51099. const height = Math.max(this[_symbol_utils.$extra].height + marginV, this.h || 0);
  51100. const bbox = [this.x, this.y, width, height];
  51101. if (this.w === "") {
  51102. style.width = (0, _html_utils.measureToString)(width);
  51103. }
  51104. if (this.h === "") {
  51105. style.height = (0, _html_utils.measureToString)(height);
  51106. }
  51107. const html = {
  51108. name: "div",
  51109. attributes,
  51110. children
  51111. };
  51112. applyAssist(this, attributes);
  51113. delete this[_symbol_utils.$extra];
  51114. return _utils.HTMLResult.success((0, _html_utils.createWrapper)(this, html), bbox);
  51115. }
  51116. }
  51117. class Execute extends _xfa_object.XFAObject {
  51118. constructor(attributes) {
  51119. super(TEMPLATE_NS_ID, "execute");
  51120. this.connection = attributes.connection || "";
  51121. this.executeType = (0, _utils.getStringOption)(attributes.executeType, ["import", "remerge"]);
  51122. this.id = attributes.id || "";
  51123. this.runAt = (0, _utils.getStringOption)(attributes.runAt, ["client", "both", "server"]);
  51124. this.use = attributes.use || "";
  51125. this.usehref = attributes.usehref || "";
  51126. }
  51127. }
  51128. class Extras extends _xfa_object.XFAObject {
  51129. constructor(attributes) {
  51130. super(TEMPLATE_NS_ID, "extras", true);
  51131. this.id = attributes.id || "";
  51132. this.name = attributes.name || "";
  51133. this.use = attributes.use || "";
  51134. this.usehref = attributes.usehref || "";
  51135. this.boolean = new _xfa_object.XFAObjectArray();
  51136. this.date = new _xfa_object.XFAObjectArray();
  51137. this.dateTime = new _xfa_object.XFAObjectArray();
  51138. this.decimal = new _xfa_object.XFAObjectArray();
  51139. this.exData = new _xfa_object.XFAObjectArray();
  51140. this.extras = new _xfa_object.XFAObjectArray();
  51141. this.float = new _xfa_object.XFAObjectArray();
  51142. this.image = new _xfa_object.XFAObjectArray();
  51143. this.integer = new _xfa_object.XFAObjectArray();
  51144. this.text = new _xfa_object.XFAObjectArray();
  51145. this.time = new _xfa_object.XFAObjectArray();
  51146. }
  51147. }
  51148. class Field extends _xfa_object.XFAObject {
  51149. constructor(attributes) {
  51150. super(TEMPLATE_NS_ID, "field", true);
  51151. this.access = (0, _utils.getStringOption)(attributes.access, ["open", "nonInteractive", "protected", "readOnly"]);
  51152. this.accessKey = attributes.accessKey || "";
  51153. this.anchorType = (0, _utils.getStringOption)(attributes.anchorType, ["topLeft", "bottomCenter", "bottomLeft", "bottomRight", "middleCenter", "middleLeft", "middleRight", "topCenter", "topRight"]);
  51154. this.colSpan = (0, _utils.getInteger)({
  51155. data: attributes.colSpan,
  51156. defaultValue: 1,
  51157. validate: n => n >= 1 || n === -1
  51158. });
  51159. this.h = attributes.h ? (0, _utils.getMeasurement)(attributes.h) : "";
  51160. this.hAlign = (0, _utils.getStringOption)(attributes.hAlign, ["left", "center", "justify", "justifyAll", "radix", "right"]);
  51161. this.id = attributes.id || "";
  51162. this.locale = attributes.locale || "";
  51163. this.maxH = (0, _utils.getMeasurement)(attributes.maxH, "0pt");
  51164. this.maxW = (0, _utils.getMeasurement)(attributes.maxW, "0pt");
  51165. this.minH = (0, _utils.getMeasurement)(attributes.minH, "0pt");
  51166. this.minW = (0, _utils.getMeasurement)(attributes.minW, "0pt");
  51167. this.name = attributes.name || "";
  51168. this.presence = (0, _utils.getStringOption)(attributes.presence, ["visible", "hidden", "inactive", "invisible"]);
  51169. this.relevant = (0, _utils.getRelevant)(attributes.relevant);
  51170. this.rotate = (0, _utils.getInteger)({
  51171. data: attributes.rotate,
  51172. defaultValue: 0,
  51173. validate: x => x % 90 === 0
  51174. });
  51175. this.use = attributes.use || "";
  51176. this.usehref = attributes.usehref || "";
  51177. this.w = attributes.w ? (0, _utils.getMeasurement)(attributes.w) : "";
  51178. this.x = (0, _utils.getMeasurement)(attributes.x, "0pt");
  51179. this.y = (0, _utils.getMeasurement)(attributes.y, "0pt");
  51180. this.assist = null;
  51181. this.bind = null;
  51182. this.border = null;
  51183. this.calculate = null;
  51184. this.caption = null;
  51185. this.desc = null;
  51186. this.extras = null;
  51187. this.font = null;
  51188. this.format = null;
  51189. this.items = new _xfa_object.XFAObjectArray(2);
  51190. this.keep = null;
  51191. this.margin = null;
  51192. this.para = null;
  51193. this.traversal = null;
  51194. this.ui = null;
  51195. this.validate = null;
  51196. this.value = null;
  51197. this.bindItems = new _xfa_object.XFAObjectArray();
  51198. this.connect = new _xfa_object.XFAObjectArray();
  51199. this.event = new _xfa_object.XFAObjectArray();
  51200. this.setProperty = new _xfa_object.XFAObjectArray();
  51201. }
  51202. [_symbol_utils.$isBindable]() {
  51203. return true;
  51204. }
  51205. [_symbol_utils.$setValue](value) {
  51206. _setValue(this, value);
  51207. }
  51208. [_symbol_utils.$toHTML](availableSpace) {
  51209. setTabIndex(this);
  51210. if (!this.ui) {
  51211. this.ui = new Ui({});
  51212. this.ui[_symbol_utils.$globalData] = this[_symbol_utils.$globalData];
  51213. this[_symbol_utils.$appendChild](this.ui);
  51214. let node;
  51215. switch (this.items.children.length) {
  51216. case 0:
  51217. node = new TextEdit({});
  51218. this.ui.textEdit = node;
  51219. break;
  51220. case 1:
  51221. node = new CheckButton({});
  51222. this.ui.checkButton = node;
  51223. break;
  51224. case 2:
  51225. node = new ChoiceList({});
  51226. this.ui.choiceList = node;
  51227. break;
  51228. }
  51229. this.ui[_symbol_utils.$appendChild](node);
  51230. }
  51231. if (!this.ui || this.presence === "hidden" || this.presence === "inactive" || this.h === 0 || this.w === 0) {
  51232. return _utils.HTMLResult.EMPTY;
  51233. }
  51234. if (this.caption) {
  51235. delete this.caption[_symbol_utils.$extra];
  51236. }
  51237. this[_symbol_utils.$pushPara]();
  51238. const caption = this.caption ? this.caption[_symbol_utils.$toHTML](availableSpace).html : null;
  51239. const savedW = this.w;
  51240. const savedH = this.h;
  51241. let marginH = 0;
  51242. let marginV = 0;
  51243. if (this.margin) {
  51244. marginH = this.margin.leftInset + this.margin.rightInset;
  51245. marginV = this.margin.topInset + this.margin.bottomInset;
  51246. }
  51247. let borderDims = null;
  51248. if (this.w === "" || this.h === "") {
  51249. let width = null;
  51250. let height = null;
  51251. let uiW = 0;
  51252. let uiH = 0;
  51253. if (this.ui.checkButton) {
  51254. uiW = uiH = this.ui.checkButton.size;
  51255. } else {
  51256. const {
  51257. w,
  51258. h
  51259. } = (0, _html_utils.layoutNode)(this, availableSpace);
  51260. if (w !== null) {
  51261. uiW = w;
  51262. uiH = h;
  51263. } else {
  51264. uiH = (0, _fonts.getMetrics)(this.font, true).lineNoGap;
  51265. }
  51266. }
  51267. borderDims = getBorderDims(this.ui[_symbol_utils.$getExtra]());
  51268. uiW += borderDims.w;
  51269. uiH += borderDims.h;
  51270. if (this.caption) {
  51271. const {
  51272. w,
  51273. h,
  51274. isBroken
  51275. } = this.caption[_symbol_utils.$getExtra](availableSpace);
  51276. if (isBroken && this[_symbol_utils.$getSubformParent]()[_symbol_utils.$isThereMoreWidth]()) {
  51277. this[_symbol_utils.$popPara]();
  51278. return _utils.HTMLResult.FAILURE;
  51279. }
  51280. width = w;
  51281. height = h;
  51282. switch (this.caption.placement) {
  51283. case "left":
  51284. case "right":
  51285. case "inline":
  51286. width += uiW;
  51287. break;
  51288. case "top":
  51289. case "bottom":
  51290. height += uiH;
  51291. break;
  51292. }
  51293. } else {
  51294. width = uiW;
  51295. height = uiH;
  51296. }
  51297. if (width && this.w === "") {
  51298. width += marginH;
  51299. this.w = Math.min(this.maxW <= 0 ? Infinity : this.maxW, this.minW + 1 < width ? width : this.minW);
  51300. }
  51301. if (height && this.h === "") {
  51302. height += marginV;
  51303. this.h = Math.min(this.maxH <= 0 ? Infinity : this.maxH, this.minH + 1 < height ? height : this.minH);
  51304. }
  51305. }
  51306. this[_symbol_utils.$popPara]();
  51307. (0, _html_utils.fixDimensions)(this);
  51308. setFirstUnsplittable(this);
  51309. if (!(0, _layout.checkDimensions)(this, availableSpace)) {
  51310. this.w = savedW;
  51311. this.h = savedH;
  51312. this[_symbol_utils.$popPara]();
  51313. return _utils.HTMLResult.FAILURE;
  51314. }
  51315. unsetFirstUnsplittable(this);
  51316. const style = (0, _html_utils.toStyle)(this, "font", "dimensions", "position", "rotate", "anchorType", "presence", "margin", "hAlign");
  51317. (0, _html_utils.setMinMaxDimensions)(this, style);
  51318. const classNames = ["xfaField"];
  51319. if (this.font) {
  51320. classNames.push("xfaFont");
  51321. }
  51322. if ((0, _html_utils.isPrintOnly)(this)) {
  51323. classNames.push("xfaPrintOnly");
  51324. }
  51325. const attributes = {
  51326. style,
  51327. id: this[_symbol_utils.$uid],
  51328. class: classNames
  51329. };
  51330. if (style.margin) {
  51331. style.padding = style.margin;
  51332. delete style.margin;
  51333. }
  51334. (0, _html_utils.setAccess)(this, classNames);
  51335. if (this.name) {
  51336. attributes.xfaName = this.name;
  51337. }
  51338. const children = [];
  51339. const html = {
  51340. name: "div",
  51341. attributes,
  51342. children
  51343. };
  51344. applyAssist(this, attributes);
  51345. const borderStyle = this.border ? this.border[_symbol_utils.$toStyle]() : null;
  51346. const bbox = (0, _html_utils.computeBbox)(this, html, availableSpace);
  51347. const ui = this.ui[_symbol_utils.$toHTML]().html;
  51348. if (!ui) {
  51349. Object.assign(style, borderStyle);
  51350. return _utils.HTMLResult.success((0, _html_utils.createWrapper)(this, html), bbox);
  51351. }
  51352. if (this[_symbol_utils.$tabIndex]) {
  51353. if (ui.children?.[0]) {
  51354. ui.children[0].attributes.tabindex = this[_symbol_utils.$tabIndex];
  51355. } else {
  51356. ui.attributes.tabindex = this[_symbol_utils.$tabIndex];
  51357. }
  51358. }
  51359. if (!ui.attributes.style) {
  51360. ui.attributes.style = Object.create(null);
  51361. }
  51362. let aElement = null;
  51363. if (this.ui.button) {
  51364. if (ui.children.length === 1) {
  51365. [aElement] = ui.children.splice(0, 1);
  51366. }
  51367. Object.assign(ui.attributes.style, borderStyle);
  51368. } else {
  51369. Object.assign(style, borderStyle);
  51370. }
  51371. children.push(ui);
  51372. if (this.value) {
  51373. if (this.ui.imageEdit) {
  51374. ui.children.push(this.value[_symbol_utils.$toHTML]().html);
  51375. } else if (!this.ui.button) {
  51376. let value = "";
  51377. if (this.value.exData) {
  51378. value = this.value.exData[_symbol_utils.$text]();
  51379. } else if (this.value.text) {
  51380. value = this.value.text[_symbol_utils.$getExtra]();
  51381. } else {
  51382. const htmlValue = this.value[_symbol_utils.$toHTML]().html;
  51383. if (htmlValue !== null) {
  51384. value = htmlValue.children[0].value;
  51385. }
  51386. }
  51387. if (this.ui.textEdit && this.value.text?.maxChars) {
  51388. ui.children[0].attributes.maxLength = this.value.text.maxChars;
  51389. }
  51390. if (value) {
  51391. if (this.ui.numericEdit) {
  51392. value = parseFloat(value);
  51393. value = isNaN(value) ? "" : value.toString();
  51394. }
  51395. if (ui.children[0].name === "textarea") {
  51396. ui.children[0].attributes.textContent = value;
  51397. } else {
  51398. ui.children[0].attributes.value = value;
  51399. }
  51400. }
  51401. }
  51402. }
  51403. if (!this.ui.imageEdit && ui.children?.[0] && this.h) {
  51404. borderDims = borderDims || getBorderDims(this.ui[_symbol_utils.$getExtra]());
  51405. let captionHeight = 0;
  51406. if (this.caption && ["top", "bottom"].includes(this.caption.placement)) {
  51407. captionHeight = this.caption.reserve;
  51408. if (captionHeight <= 0) {
  51409. captionHeight = this.caption[_symbol_utils.$getExtra](availableSpace).h;
  51410. }
  51411. const inputHeight = this.h - captionHeight - marginV - borderDims.h;
  51412. ui.children[0].attributes.style.height = (0, _html_utils.measureToString)(inputHeight);
  51413. } else {
  51414. ui.children[0].attributes.style.height = "100%";
  51415. }
  51416. }
  51417. if (aElement) {
  51418. ui.children.push(aElement);
  51419. }
  51420. if (!caption) {
  51421. if (ui.attributes.class) {
  51422. ui.attributes.class.push("xfaLeft");
  51423. }
  51424. this.w = savedW;
  51425. this.h = savedH;
  51426. return _utils.HTMLResult.success((0, _html_utils.createWrapper)(this, html), bbox);
  51427. }
  51428. if (this.ui.button) {
  51429. if (style.padding) {
  51430. delete style.padding;
  51431. }
  51432. if (caption.name === "div") {
  51433. caption.name = "span";
  51434. }
  51435. ui.children.push(caption);
  51436. return _utils.HTMLResult.success(html, bbox);
  51437. } else if (this.ui.checkButton) {
  51438. caption.attributes.class[0] = "xfaCaptionForCheckButton";
  51439. }
  51440. if (!ui.attributes.class) {
  51441. ui.attributes.class = [];
  51442. }
  51443. ui.children.splice(0, 0, caption);
  51444. switch (this.caption.placement) {
  51445. case "left":
  51446. ui.attributes.class.push("xfaLeft");
  51447. break;
  51448. case "right":
  51449. ui.attributes.class.push("xfaRight");
  51450. break;
  51451. case "top":
  51452. ui.attributes.class.push("xfaTop");
  51453. break;
  51454. case "bottom":
  51455. ui.attributes.class.push("xfaBottom");
  51456. break;
  51457. case "inline":
  51458. ui.attributes.class.push("xfaLeft");
  51459. break;
  51460. }
  51461. this.w = savedW;
  51462. this.h = savedH;
  51463. return _utils.HTMLResult.success((0, _html_utils.createWrapper)(this, html), bbox);
  51464. }
  51465. }
  51466. exports.Field = Field;
  51467. class Fill extends _xfa_object.XFAObject {
  51468. constructor(attributes) {
  51469. super(TEMPLATE_NS_ID, "fill", true);
  51470. this.id = attributes.id || "";
  51471. this.presence = (0, _utils.getStringOption)(attributes.presence, ["visible", "hidden", "inactive", "invisible"]);
  51472. this.use = attributes.use || "";
  51473. this.usehref = attributes.usehref || "";
  51474. this.color = null;
  51475. this.extras = null;
  51476. this.linear = null;
  51477. this.pattern = null;
  51478. this.radial = null;
  51479. this.solid = null;
  51480. this.stipple = null;
  51481. }
  51482. [_symbol_utils.$toStyle]() {
  51483. const parent = this[_symbol_utils.$getParent]();
  51484. const grandpa = parent[_symbol_utils.$getParent]();
  51485. const ggrandpa = grandpa[_symbol_utils.$getParent]();
  51486. const style = Object.create(null);
  51487. let propName = "color";
  51488. let altPropName = propName;
  51489. if (parent instanceof Border) {
  51490. propName = "background-color";
  51491. altPropName = "background";
  51492. if (ggrandpa instanceof Ui) {
  51493. style.backgroundColor = "white";
  51494. }
  51495. }
  51496. if (parent instanceof Rectangle || parent instanceof Arc) {
  51497. propName = altPropName = "fill";
  51498. style.fill = "white";
  51499. }
  51500. for (const name of Object.getOwnPropertyNames(this)) {
  51501. if (name === "extras" || name === "color") {
  51502. continue;
  51503. }
  51504. const obj = this[name];
  51505. if (!(obj instanceof _xfa_object.XFAObject)) {
  51506. continue;
  51507. }
  51508. const color = obj[_symbol_utils.$toStyle](this.color);
  51509. if (color) {
  51510. style[color.startsWith("#") ? propName : altPropName] = color;
  51511. }
  51512. return style;
  51513. }
  51514. if (this.color?.value) {
  51515. const color = this.color[_symbol_utils.$toStyle]();
  51516. style[color.startsWith("#") ? propName : altPropName] = color;
  51517. }
  51518. return style;
  51519. }
  51520. }
  51521. class Filter extends _xfa_object.XFAObject {
  51522. constructor(attributes) {
  51523. super(TEMPLATE_NS_ID, "filter", true);
  51524. this.addRevocationInfo = (0, _utils.getStringOption)(attributes.addRevocationInfo, ["", "required", "optional", "none"]);
  51525. this.id = attributes.id || "";
  51526. this.name = attributes.name || "";
  51527. this.use = attributes.use || "";
  51528. this.usehref = attributes.usehref || "";
  51529. this.version = (0, _utils.getInteger)({
  51530. data: this.version,
  51531. defaultValue: 5,
  51532. validate: x => x >= 1 && x <= 5
  51533. });
  51534. this.appearanceFilter = null;
  51535. this.certificates = null;
  51536. this.digestMethods = null;
  51537. this.encodings = null;
  51538. this.encryptionMethods = null;
  51539. this.handler = null;
  51540. this.lockDocument = null;
  51541. this.mdp = null;
  51542. this.reasons = null;
  51543. this.timeStamp = null;
  51544. }
  51545. }
  51546. class Float extends _xfa_object.ContentObject {
  51547. constructor(attributes) {
  51548. super(TEMPLATE_NS_ID, "float");
  51549. this.id = attributes.id || "";
  51550. this.name = attributes.name || "";
  51551. this.use = attributes.use || "";
  51552. this.usehref = attributes.usehref || "";
  51553. }
  51554. [_symbol_utils.$finalize]() {
  51555. const number = parseFloat(this[_symbol_utils.$content].trim());
  51556. this[_symbol_utils.$content] = isNaN(number) ? null : number;
  51557. }
  51558. [_symbol_utils.$toHTML](availableSpace) {
  51559. return valueToHtml(this[_symbol_utils.$content] !== null ? this[_symbol_utils.$content].toString() : "");
  51560. }
  51561. }
  51562. class Font extends _xfa_object.XFAObject {
  51563. constructor(attributes) {
  51564. super(TEMPLATE_NS_ID, "font", true);
  51565. this.baselineShift = (0, _utils.getMeasurement)(attributes.baselineShift);
  51566. this.fontHorizontalScale = (0, _utils.getFloat)({
  51567. data: attributes.fontHorizontalScale,
  51568. defaultValue: 100,
  51569. validate: x => x >= 0
  51570. });
  51571. this.fontVerticalScale = (0, _utils.getFloat)({
  51572. data: attributes.fontVerticalScale,
  51573. defaultValue: 100,
  51574. validate: x => x >= 0
  51575. });
  51576. this.id = attributes.id || "";
  51577. this.kerningMode = (0, _utils.getStringOption)(attributes.kerningMode, ["none", "pair"]);
  51578. this.letterSpacing = (0, _utils.getMeasurement)(attributes.letterSpacing, "0");
  51579. this.lineThrough = (0, _utils.getInteger)({
  51580. data: attributes.lineThrough,
  51581. defaultValue: 0,
  51582. validate: x => x === 1 || x === 2
  51583. });
  51584. this.lineThroughPeriod = (0, _utils.getStringOption)(attributes.lineThroughPeriod, ["all", "word"]);
  51585. this.overline = (0, _utils.getInteger)({
  51586. data: attributes.overline,
  51587. defaultValue: 0,
  51588. validate: x => x === 1 || x === 2
  51589. });
  51590. this.overlinePeriod = (0, _utils.getStringOption)(attributes.overlinePeriod, ["all", "word"]);
  51591. this.posture = (0, _utils.getStringOption)(attributes.posture, ["normal", "italic"]);
  51592. this.size = (0, _utils.getMeasurement)(attributes.size, "10pt");
  51593. this.typeface = attributes.typeface || "Courier";
  51594. this.underline = (0, _utils.getInteger)({
  51595. data: attributes.underline,
  51596. defaultValue: 0,
  51597. validate: x => x === 1 || x === 2
  51598. });
  51599. this.underlinePeriod = (0, _utils.getStringOption)(attributes.underlinePeriod, ["all", "word"]);
  51600. this.use = attributes.use || "";
  51601. this.usehref = attributes.usehref || "";
  51602. this.weight = (0, _utils.getStringOption)(attributes.weight, ["normal", "bold"]);
  51603. this.extras = null;
  51604. this.fill = null;
  51605. }
  51606. [_symbol_utils.$clean](builder) {
  51607. super[_symbol_utils.$clean](builder);
  51608. this[_symbol_utils.$globalData].usedTypefaces.add(this.typeface);
  51609. }
  51610. [_symbol_utils.$toStyle]() {
  51611. const style = (0, _html_utils.toStyle)(this, "fill");
  51612. const color = style.color;
  51613. if (color) {
  51614. if (color === "#000000") {
  51615. delete style.color;
  51616. } else if (!color.startsWith("#")) {
  51617. style.background = color;
  51618. style.backgroundClip = "text";
  51619. style.color = "transparent";
  51620. }
  51621. }
  51622. if (this.baselineShift) {
  51623. style.verticalAlign = (0, _html_utils.measureToString)(this.baselineShift);
  51624. }
  51625. style.fontKerning = this.kerningMode === "none" ? "none" : "normal";
  51626. style.letterSpacing = (0, _html_utils.measureToString)(this.letterSpacing);
  51627. if (this.lineThrough !== 0) {
  51628. style.textDecoration = "line-through";
  51629. if (this.lineThrough === 2) {
  51630. style.textDecorationStyle = "double";
  51631. }
  51632. }
  51633. if (this.overline !== 0) {
  51634. style.textDecoration = "overline";
  51635. if (this.overline === 2) {
  51636. style.textDecorationStyle = "double";
  51637. }
  51638. }
  51639. style.fontStyle = this.posture;
  51640. style.fontSize = (0, _html_utils.measureToString)(0.99 * this.size);
  51641. (0, _html_utils.setFontFamily)(this, this, this[_symbol_utils.$globalData].fontFinder, style);
  51642. if (this.underline !== 0) {
  51643. style.textDecoration = "underline";
  51644. if (this.underline === 2) {
  51645. style.textDecorationStyle = "double";
  51646. }
  51647. }
  51648. style.fontWeight = this.weight;
  51649. return style;
  51650. }
  51651. }
  51652. class Format extends _xfa_object.XFAObject {
  51653. constructor(attributes) {
  51654. super(TEMPLATE_NS_ID, "format", true);
  51655. this.id = attributes.id || "";
  51656. this.use = attributes.use || "";
  51657. this.usehref = attributes.usehref || "";
  51658. this.extras = null;
  51659. this.picture = null;
  51660. }
  51661. }
  51662. class Handler extends _xfa_object.StringObject {
  51663. constructor(attributes) {
  51664. super(TEMPLATE_NS_ID, "handler");
  51665. this.id = attributes.id || "";
  51666. this.type = (0, _utils.getStringOption)(attributes.type, ["optional", "required"]);
  51667. this.use = attributes.use || "";
  51668. this.usehref = attributes.usehref || "";
  51669. }
  51670. }
  51671. class Hyphenation extends _xfa_object.XFAObject {
  51672. constructor(attributes) {
  51673. super(TEMPLATE_NS_ID, "hyphenation");
  51674. this.excludeAllCaps = (0, _utils.getInteger)({
  51675. data: attributes.excludeAllCaps,
  51676. defaultValue: 0,
  51677. validate: x => x === 1
  51678. });
  51679. this.excludeInitialCap = (0, _utils.getInteger)({
  51680. data: attributes.excludeInitialCap,
  51681. defaultValue: 0,
  51682. validate: x => x === 1
  51683. });
  51684. this.hyphenate = (0, _utils.getInteger)({
  51685. data: attributes.hyphenate,
  51686. defaultValue: 0,
  51687. validate: x => x === 1
  51688. });
  51689. this.id = attributes.id || "";
  51690. this.pushCharacterCount = (0, _utils.getInteger)({
  51691. data: attributes.pushCharacterCount,
  51692. defaultValue: 3,
  51693. validate: x => x >= 0
  51694. });
  51695. this.remainCharacterCount = (0, _utils.getInteger)({
  51696. data: attributes.remainCharacterCount,
  51697. defaultValue: 3,
  51698. validate: x => x >= 0
  51699. });
  51700. this.use = attributes.use || "";
  51701. this.usehref = attributes.usehref || "";
  51702. this.wordCharacterCount = (0, _utils.getInteger)({
  51703. data: attributes.wordCharacterCount,
  51704. defaultValue: 7,
  51705. validate: x => x >= 0
  51706. });
  51707. }
  51708. }
  51709. class Image extends _xfa_object.StringObject {
  51710. constructor(attributes) {
  51711. super(TEMPLATE_NS_ID, "image");
  51712. this.aspect = (0, _utils.getStringOption)(attributes.aspect, ["fit", "actual", "height", "none", "width"]);
  51713. this.contentType = attributes.contentType || "";
  51714. this.href = attributes.href || "";
  51715. this.id = attributes.id || "";
  51716. this.name = attributes.name || "";
  51717. this.transferEncoding = (0, _utils.getStringOption)(attributes.transferEncoding, ["base64", "none", "package"]);
  51718. this.use = attributes.use || "";
  51719. this.usehref = attributes.usehref || "";
  51720. }
  51721. [_symbol_utils.$toHTML]() {
  51722. if (this.contentType && !MIMES.has(this.contentType.toLowerCase())) {
  51723. return _utils.HTMLResult.EMPTY;
  51724. }
  51725. let buffer = this[_symbol_utils.$globalData].images && this[_symbol_utils.$globalData].images.get(this.href);
  51726. if (!buffer && (this.href || !this[_symbol_utils.$content])) {
  51727. return _utils.HTMLResult.EMPTY;
  51728. }
  51729. if (!buffer && this.transferEncoding === "base64") {
  51730. buffer = (0, _util.stringToBytes)(atob(this[_symbol_utils.$content]));
  51731. }
  51732. if (!buffer) {
  51733. return _utils.HTMLResult.EMPTY;
  51734. }
  51735. if (!this.contentType) {
  51736. for (const [header, type] of IMAGES_HEADERS) {
  51737. if (buffer.length > header.length && header.every((x, i) => x === buffer[i])) {
  51738. this.contentType = type;
  51739. break;
  51740. }
  51741. }
  51742. if (!this.contentType) {
  51743. return _utils.HTMLResult.EMPTY;
  51744. }
  51745. }
  51746. const blob = new Blob([buffer], {
  51747. type: this.contentType
  51748. });
  51749. let style;
  51750. switch (this.aspect) {
  51751. case "fit":
  51752. case "actual":
  51753. break;
  51754. case "height":
  51755. style = {
  51756. height: "100%",
  51757. objectFit: "fill"
  51758. };
  51759. break;
  51760. case "none":
  51761. style = {
  51762. width: "100%",
  51763. height: "100%",
  51764. objectFit: "fill"
  51765. };
  51766. break;
  51767. case "width":
  51768. style = {
  51769. width: "100%",
  51770. objectFit: "fill"
  51771. };
  51772. break;
  51773. }
  51774. const parent = this[_symbol_utils.$getParent]();
  51775. return _utils.HTMLResult.success({
  51776. name: "img",
  51777. attributes: {
  51778. class: ["xfaImage"],
  51779. style,
  51780. src: URL.createObjectURL(blob),
  51781. alt: parent ? ariaLabel(parent[_symbol_utils.$getParent]()) : null
  51782. }
  51783. });
  51784. }
  51785. }
  51786. class ImageEdit extends _xfa_object.XFAObject {
  51787. constructor(attributes) {
  51788. super(TEMPLATE_NS_ID, "imageEdit", true);
  51789. this.data = (0, _utils.getStringOption)(attributes.data, ["link", "embed"]);
  51790. this.id = attributes.id || "";
  51791. this.use = attributes.use || "";
  51792. this.usehref = attributes.usehref || "";
  51793. this.border = null;
  51794. this.extras = null;
  51795. this.margin = null;
  51796. }
  51797. [_symbol_utils.$toHTML](availableSpace) {
  51798. if (this.data === "embed") {
  51799. return _utils.HTMLResult.success({
  51800. name: "div",
  51801. children: [],
  51802. attributes: {}
  51803. });
  51804. }
  51805. return _utils.HTMLResult.EMPTY;
  51806. }
  51807. }
  51808. class Integer extends _xfa_object.ContentObject {
  51809. constructor(attributes) {
  51810. super(TEMPLATE_NS_ID, "integer");
  51811. this.id = attributes.id || "";
  51812. this.name = attributes.name || "";
  51813. this.use = attributes.use || "";
  51814. this.usehref = attributes.usehref || "";
  51815. }
  51816. [_symbol_utils.$finalize]() {
  51817. const number = parseInt(this[_symbol_utils.$content].trim(), 10);
  51818. this[_symbol_utils.$content] = isNaN(number) ? null : number;
  51819. }
  51820. [_symbol_utils.$toHTML](availableSpace) {
  51821. return valueToHtml(this[_symbol_utils.$content] !== null ? this[_symbol_utils.$content].toString() : "");
  51822. }
  51823. }
  51824. class Issuers extends _xfa_object.XFAObject {
  51825. constructor(attributes) {
  51826. super(TEMPLATE_NS_ID, "issuers", true);
  51827. this.id = attributes.id || "";
  51828. this.type = (0, _utils.getStringOption)(attributes.type, ["optional", "required"]);
  51829. this.use = attributes.use || "";
  51830. this.usehref = attributes.usehref || "";
  51831. this.certificate = new _xfa_object.XFAObjectArray();
  51832. }
  51833. }
  51834. class Items extends _xfa_object.XFAObject {
  51835. constructor(attributes) {
  51836. super(TEMPLATE_NS_ID, "items", true);
  51837. this.id = attributes.id || "";
  51838. this.name = attributes.name || "";
  51839. this.presence = (0, _utils.getStringOption)(attributes.presence, ["visible", "hidden", "inactive", "invisible"]);
  51840. this.ref = attributes.ref || "";
  51841. this.save = (0, _utils.getInteger)({
  51842. data: attributes.save,
  51843. defaultValue: 0,
  51844. validate: x => x === 1
  51845. });
  51846. this.use = attributes.use || "";
  51847. this.usehref = attributes.usehref || "";
  51848. this.boolean = new _xfa_object.XFAObjectArray();
  51849. this.date = new _xfa_object.XFAObjectArray();
  51850. this.dateTime = new _xfa_object.XFAObjectArray();
  51851. this.decimal = new _xfa_object.XFAObjectArray();
  51852. this.exData = new _xfa_object.XFAObjectArray();
  51853. this.float = new _xfa_object.XFAObjectArray();
  51854. this.image = new _xfa_object.XFAObjectArray();
  51855. this.integer = new _xfa_object.XFAObjectArray();
  51856. this.text = new _xfa_object.XFAObjectArray();
  51857. this.time = new _xfa_object.XFAObjectArray();
  51858. }
  51859. [_symbol_utils.$toHTML]() {
  51860. const output = [];
  51861. for (const child of this[_symbol_utils.$getChildren]()) {
  51862. output.push(child[_symbol_utils.$text]());
  51863. }
  51864. return _utils.HTMLResult.success(output);
  51865. }
  51866. }
  51867. exports.Items = Items;
  51868. class Keep extends _xfa_object.XFAObject {
  51869. constructor(attributes) {
  51870. super(TEMPLATE_NS_ID, "keep", true);
  51871. this.id = attributes.id || "";
  51872. const options = ["none", "contentArea", "pageArea"];
  51873. this.intact = (0, _utils.getStringOption)(attributes.intact, options);
  51874. this.next = (0, _utils.getStringOption)(attributes.next, options);
  51875. this.previous = (0, _utils.getStringOption)(attributes.previous, options);
  51876. this.use = attributes.use || "";
  51877. this.usehref = attributes.usehref || "";
  51878. this.extras = null;
  51879. }
  51880. }
  51881. class KeyUsage extends _xfa_object.XFAObject {
  51882. constructor(attributes) {
  51883. super(TEMPLATE_NS_ID, "keyUsage");
  51884. const options = ["", "yes", "no"];
  51885. this.crlSign = (0, _utils.getStringOption)(attributes.crlSign, options);
  51886. this.dataEncipherment = (0, _utils.getStringOption)(attributes.dataEncipherment, options);
  51887. this.decipherOnly = (0, _utils.getStringOption)(attributes.decipherOnly, options);
  51888. this.digitalSignature = (0, _utils.getStringOption)(attributes.digitalSignature, options);
  51889. this.encipherOnly = (0, _utils.getStringOption)(attributes.encipherOnly, options);
  51890. this.id = attributes.id || "";
  51891. this.keyAgreement = (0, _utils.getStringOption)(attributes.keyAgreement, options);
  51892. this.keyCertSign = (0, _utils.getStringOption)(attributes.keyCertSign, options);
  51893. this.keyEncipherment = (0, _utils.getStringOption)(attributes.keyEncipherment, options);
  51894. this.nonRepudiation = (0, _utils.getStringOption)(attributes.nonRepudiation, options);
  51895. this.type = (0, _utils.getStringOption)(attributes.type, ["optional", "required"]);
  51896. this.use = attributes.use || "";
  51897. this.usehref = attributes.usehref || "";
  51898. }
  51899. }
  51900. class Line extends _xfa_object.XFAObject {
  51901. constructor(attributes) {
  51902. super(TEMPLATE_NS_ID, "line", true);
  51903. this.hand = (0, _utils.getStringOption)(attributes.hand, ["even", "left", "right"]);
  51904. this.id = attributes.id || "";
  51905. this.slope = (0, _utils.getStringOption)(attributes.slope, ["\\", "/"]);
  51906. this.use = attributes.use || "";
  51907. this.usehref = attributes.usehref || "";
  51908. this.edge = null;
  51909. }
  51910. [_symbol_utils.$toHTML]() {
  51911. const parent = this[_symbol_utils.$getParent]()[_symbol_utils.$getParent]();
  51912. const edge = this.edge || new Edge({});
  51913. const edgeStyle = edge[_symbol_utils.$toStyle]();
  51914. const style = Object.create(null);
  51915. const thickness = edge.presence === "visible" ? edge.thickness : 0;
  51916. style.strokeWidth = (0, _html_utils.measureToString)(thickness);
  51917. style.stroke = edgeStyle.color;
  51918. let x1, y1, x2, y2;
  51919. let width = "100%";
  51920. let height = "100%";
  51921. if (parent.w <= thickness) {
  51922. [x1, y1, x2, y2] = ["50%", 0, "50%", "100%"];
  51923. width = style.strokeWidth;
  51924. } else if (parent.h <= thickness) {
  51925. [x1, y1, x2, y2] = [0, "50%", "100%", "50%"];
  51926. height = style.strokeWidth;
  51927. } else if (this.slope === "\\") {
  51928. [x1, y1, x2, y2] = [0, 0, "100%", "100%"];
  51929. } else {
  51930. [x1, y1, x2, y2] = [0, "100%", "100%", 0];
  51931. }
  51932. const line = {
  51933. name: "line",
  51934. attributes: {
  51935. xmlns: SVG_NS,
  51936. x1,
  51937. y1,
  51938. x2,
  51939. y2,
  51940. style
  51941. }
  51942. };
  51943. const svg = {
  51944. name: "svg",
  51945. children: [line],
  51946. attributes: {
  51947. xmlns: SVG_NS,
  51948. width,
  51949. height,
  51950. style: {
  51951. overflow: "visible"
  51952. }
  51953. }
  51954. };
  51955. if (hasMargin(parent)) {
  51956. return _utils.HTMLResult.success({
  51957. name: "div",
  51958. attributes: {
  51959. style: {
  51960. display: "inline",
  51961. width: "100%",
  51962. height: "100%"
  51963. }
  51964. },
  51965. children: [svg]
  51966. });
  51967. }
  51968. svg.attributes.style.position = "absolute";
  51969. return _utils.HTMLResult.success(svg);
  51970. }
  51971. }
  51972. class Linear extends _xfa_object.XFAObject {
  51973. constructor(attributes) {
  51974. super(TEMPLATE_NS_ID, "linear", true);
  51975. this.id = attributes.id || "";
  51976. this.type = (0, _utils.getStringOption)(attributes.type, ["toRight", "toBottom", "toLeft", "toTop"]);
  51977. this.use = attributes.use || "";
  51978. this.usehref = attributes.usehref || "";
  51979. this.color = null;
  51980. this.extras = null;
  51981. }
  51982. [_symbol_utils.$toStyle](startColor) {
  51983. startColor = startColor ? startColor[_symbol_utils.$toStyle]() : "#FFFFFF";
  51984. const transf = this.type.replace(/([RBLT])/, " $1").toLowerCase();
  51985. const endColor = this.color ? this.color[_symbol_utils.$toStyle]() : "#000000";
  51986. return `linear-gradient(${transf}, ${startColor}, ${endColor})`;
  51987. }
  51988. }
  51989. class LockDocument extends _xfa_object.ContentObject {
  51990. constructor(attributes) {
  51991. super(TEMPLATE_NS_ID, "lockDocument");
  51992. this.id = attributes.id || "";
  51993. this.type = (0, _utils.getStringOption)(attributes.type, ["optional", "required"]);
  51994. this.use = attributes.use || "";
  51995. this.usehref = attributes.usehref || "";
  51996. }
  51997. [_symbol_utils.$finalize]() {
  51998. this[_symbol_utils.$content] = (0, _utils.getStringOption)(this[_symbol_utils.$content], ["auto", "0", "1"]);
  51999. }
  52000. }
  52001. class Manifest extends _xfa_object.XFAObject {
  52002. constructor(attributes) {
  52003. super(TEMPLATE_NS_ID, "manifest", true);
  52004. this.action = (0, _utils.getStringOption)(attributes.action, ["include", "all", "exclude"]);
  52005. this.id = attributes.id || "";
  52006. this.name = attributes.name || "";
  52007. this.use = attributes.use || "";
  52008. this.usehref = attributes.usehref || "";
  52009. this.extras = null;
  52010. this.ref = new _xfa_object.XFAObjectArray();
  52011. }
  52012. }
  52013. class Margin extends _xfa_object.XFAObject {
  52014. constructor(attributes) {
  52015. super(TEMPLATE_NS_ID, "margin", true);
  52016. this.bottomInset = (0, _utils.getMeasurement)(attributes.bottomInset, "0");
  52017. this.id = attributes.id || "";
  52018. this.leftInset = (0, _utils.getMeasurement)(attributes.leftInset, "0");
  52019. this.rightInset = (0, _utils.getMeasurement)(attributes.rightInset, "0");
  52020. this.topInset = (0, _utils.getMeasurement)(attributes.topInset, "0");
  52021. this.use = attributes.use || "";
  52022. this.usehref = attributes.usehref || "";
  52023. this.extras = null;
  52024. }
  52025. [_symbol_utils.$toStyle]() {
  52026. return {
  52027. 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)
  52028. };
  52029. }
  52030. }
  52031. class Mdp extends _xfa_object.XFAObject {
  52032. constructor(attributes) {
  52033. super(TEMPLATE_NS_ID, "mdp");
  52034. this.id = attributes.id || "";
  52035. this.permissions = (0, _utils.getInteger)({
  52036. data: attributes.permissions,
  52037. defaultValue: 2,
  52038. validate: x => x === 1 || x === 3
  52039. });
  52040. this.signatureType = (0, _utils.getStringOption)(attributes.signatureType, ["filler", "author"]);
  52041. this.use = attributes.use || "";
  52042. this.usehref = attributes.usehref || "";
  52043. }
  52044. }
  52045. class Medium extends _xfa_object.XFAObject {
  52046. constructor(attributes) {
  52047. super(TEMPLATE_NS_ID, "medium");
  52048. this.id = attributes.id || "";
  52049. this.imagingBBox = (0, _utils.getBBox)(attributes.imagingBBox);
  52050. this.long = (0, _utils.getMeasurement)(attributes.long);
  52051. this.orientation = (0, _utils.getStringOption)(attributes.orientation, ["portrait", "landscape"]);
  52052. this.short = (0, _utils.getMeasurement)(attributes.short);
  52053. this.stock = attributes.stock || "";
  52054. this.trayIn = (0, _utils.getStringOption)(attributes.trayIn, ["auto", "delegate", "pageFront"]);
  52055. this.trayOut = (0, _utils.getStringOption)(attributes.trayOut, ["auto", "delegate"]);
  52056. this.use = attributes.use || "";
  52057. this.usehref = attributes.usehref || "";
  52058. }
  52059. }
  52060. class Message extends _xfa_object.XFAObject {
  52061. constructor(attributes) {
  52062. super(TEMPLATE_NS_ID, "message", true);
  52063. this.id = attributes.id || "";
  52064. this.use = attributes.use || "";
  52065. this.usehref = attributes.usehref || "";
  52066. this.text = new _xfa_object.XFAObjectArray();
  52067. }
  52068. }
  52069. class NumericEdit extends _xfa_object.XFAObject {
  52070. constructor(attributes) {
  52071. super(TEMPLATE_NS_ID, "numericEdit", true);
  52072. this.hScrollPolicy = (0, _utils.getStringOption)(attributes.hScrollPolicy, ["auto", "off", "on"]);
  52073. this.id = attributes.id || "";
  52074. this.use = attributes.use || "";
  52075. this.usehref = attributes.usehref || "";
  52076. this.border = null;
  52077. this.comb = null;
  52078. this.extras = null;
  52079. this.margin = null;
  52080. }
  52081. [_symbol_utils.$toHTML](availableSpace) {
  52082. const style = (0, _html_utils.toStyle)(this, "border", "font", "margin");
  52083. const field = this[_symbol_utils.$getParent]()[_symbol_utils.$getParent]();
  52084. const html = {
  52085. name: "input",
  52086. attributes: {
  52087. type: "text",
  52088. fieldId: field[_symbol_utils.$uid],
  52089. dataId: field[_symbol_utils.$data]?.[_symbol_utils.$uid] || field[_symbol_utils.$uid],
  52090. class: ["xfaTextfield"],
  52091. style,
  52092. "aria-label": ariaLabel(field),
  52093. "aria-required": false
  52094. }
  52095. };
  52096. if (isRequired(field)) {
  52097. html.attributes["aria-required"] = true;
  52098. html.attributes.required = true;
  52099. }
  52100. return _utils.HTMLResult.success({
  52101. name: "label",
  52102. attributes: {
  52103. class: ["xfaLabel"]
  52104. },
  52105. children: [html]
  52106. });
  52107. }
  52108. }
  52109. class Occur extends _xfa_object.XFAObject {
  52110. constructor(attributes) {
  52111. super(TEMPLATE_NS_ID, "occur", true);
  52112. this.id = attributes.id || "";
  52113. this.initial = attributes.initial !== "" ? (0, _utils.getInteger)({
  52114. data: attributes.initial,
  52115. defaultValue: "",
  52116. validate: x => true
  52117. }) : "";
  52118. this.max = attributes.max !== "" ? (0, _utils.getInteger)({
  52119. data: attributes.max,
  52120. defaultValue: 1,
  52121. validate: x => true
  52122. }) : "";
  52123. this.min = attributes.min !== "" ? (0, _utils.getInteger)({
  52124. data: attributes.min,
  52125. defaultValue: 1,
  52126. validate: x => true
  52127. }) : "";
  52128. this.use = attributes.use || "";
  52129. this.usehref = attributes.usehref || "";
  52130. this.extras = null;
  52131. }
  52132. [_symbol_utils.$clean]() {
  52133. const parent = this[_symbol_utils.$getParent]();
  52134. const originalMin = this.min;
  52135. if (this.min === "") {
  52136. this.min = parent instanceof PageArea || parent instanceof PageSet ? 0 : 1;
  52137. }
  52138. if (this.max === "") {
  52139. if (originalMin === "") {
  52140. this.max = parent instanceof PageArea || parent instanceof PageSet ? -1 : 1;
  52141. } else {
  52142. this.max = this.min;
  52143. }
  52144. }
  52145. if (this.max !== -1 && this.max < this.min) {
  52146. this.max = this.min;
  52147. }
  52148. if (this.initial === "") {
  52149. this.initial = parent instanceof Template ? 1 : this.min;
  52150. }
  52151. }
  52152. }
  52153. class Oid extends _xfa_object.StringObject {
  52154. constructor(attributes) {
  52155. super(TEMPLATE_NS_ID, "oid");
  52156. this.id = attributes.id || "";
  52157. this.name = attributes.name || "";
  52158. this.use = attributes.use || "";
  52159. this.usehref = attributes.usehref || "";
  52160. }
  52161. }
  52162. class Oids extends _xfa_object.XFAObject {
  52163. constructor(attributes) {
  52164. super(TEMPLATE_NS_ID, "oids", true);
  52165. this.id = attributes.id || "";
  52166. this.type = (0, _utils.getStringOption)(attributes.type, ["optional", "required"]);
  52167. this.use = attributes.use || "";
  52168. this.usehref = attributes.usehref || "";
  52169. this.oid = new _xfa_object.XFAObjectArray();
  52170. }
  52171. }
  52172. class Overflow extends _xfa_object.XFAObject {
  52173. constructor(attributes) {
  52174. super(TEMPLATE_NS_ID, "overflow");
  52175. this.id = attributes.id || "";
  52176. this.leader = attributes.leader || "";
  52177. this.target = attributes.target || "";
  52178. this.trailer = attributes.trailer || "";
  52179. this.use = attributes.use || "";
  52180. this.usehref = attributes.usehref || "";
  52181. }
  52182. [_symbol_utils.$getExtra]() {
  52183. if (!this[_symbol_utils.$extra]) {
  52184. const parent = this[_symbol_utils.$getParent]();
  52185. const root = this[_symbol_utils.$getTemplateRoot]();
  52186. const target = root[_symbol_utils.$searchNode](this.target, parent);
  52187. const leader = root[_symbol_utils.$searchNode](this.leader, parent);
  52188. const trailer = root[_symbol_utils.$searchNode](this.trailer, parent);
  52189. this[_symbol_utils.$extra] = {
  52190. target: target?.[0] || null,
  52191. leader: leader?.[0] || null,
  52192. trailer: trailer?.[0] || null,
  52193. addLeader: false,
  52194. addTrailer: false
  52195. };
  52196. }
  52197. return this[_symbol_utils.$extra];
  52198. }
  52199. }
  52200. class PageArea extends _xfa_object.XFAObject {
  52201. constructor(attributes) {
  52202. super(TEMPLATE_NS_ID, "pageArea", true);
  52203. this.blankOrNotBlank = (0, _utils.getStringOption)(attributes.blankOrNotBlank, ["any", "blank", "notBlank"]);
  52204. this.id = attributes.id || "";
  52205. this.initialNumber = (0, _utils.getInteger)({
  52206. data: attributes.initialNumber,
  52207. defaultValue: 1,
  52208. validate: x => true
  52209. });
  52210. this.name = attributes.name || "";
  52211. this.numbered = (0, _utils.getInteger)({
  52212. data: attributes.numbered,
  52213. defaultValue: 1,
  52214. validate: x => true
  52215. });
  52216. this.oddOrEven = (0, _utils.getStringOption)(attributes.oddOrEven, ["any", "even", "odd"]);
  52217. this.pagePosition = (0, _utils.getStringOption)(attributes.pagePosition, ["any", "first", "last", "only", "rest"]);
  52218. this.relevant = (0, _utils.getRelevant)(attributes.relevant);
  52219. this.use = attributes.use || "";
  52220. this.usehref = attributes.usehref || "";
  52221. this.desc = null;
  52222. this.extras = null;
  52223. this.medium = null;
  52224. this.occur = null;
  52225. this.area = new _xfa_object.XFAObjectArray();
  52226. this.contentArea = new _xfa_object.XFAObjectArray();
  52227. this.draw = new _xfa_object.XFAObjectArray();
  52228. this.exclGroup = new _xfa_object.XFAObjectArray();
  52229. this.field = new _xfa_object.XFAObjectArray();
  52230. this.subform = new _xfa_object.XFAObjectArray();
  52231. }
  52232. [_symbol_utils.$isUsable]() {
  52233. if (!this[_symbol_utils.$extra]) {
  52234. this[_symbol_utils.$extra] = {
  52235. numberOfUse: 0
  52236. };
  52237. return true;
  52238. }
  52239. return !this.occur || this.occur.max === -1 || this[_symbol_utils.$extra].numberOfUse < this.occur.max;
  52240. }
  52241. [_symbol_utils.$cleanPage]() {
  52242. delete this[_symbol_utils.$extra];
  52243. }
  52244. [_symbol_utils.$getNextPage]() {
  52245. if (!this[_symbol_utils.$extra]) {
  52246. this[_symbol_utils.$extra] = {
  52247. numberOfUse: 0
  52248. };
  52249. }
  52250. const parent = this[_symbol_utils.$getParent]();
  52251. if (parent.relation === "orderedOccurrence") {
  52252. if (this[_symbol_utils.$isUsable]()) {
  52253. this[_symbol_utils.$extra].numberOfUse += 1;
  52254. return this;
  52255. }
  52256. }
  52257. return parent[_symbol_utils.$getNextPage]();
  52258. }
  52259. [_symbol_utils.$getAvailableSpace]() {
  52260. return this[_symbol_utils.$extra].space || {
  52261. width: 0,
  52262. height: 0
  52263. };
  52264. }
  52265. [_symbol_utils.$toHTML]() {
  52266. if (!this[_symbol_utils.$extra]) {
  52267. this[_symbol_utils.$extra] = {
  52268. numberOfUse: 1
  52269. };
  52270. }
  52271. const children = [];
  52272. this[_symbol_utils.$extra].children = children;
  52273. const style = Object.create(null);
  52274. if (this.medium && this.medium.short && this.medium.long) {
  52275. style.width = (0, _html_utils.measureToString)(this.medium.short);
  52276. style.height = (0, _html_utils.measureToString)(this.medium.long);
  52277. this[_symbol_utils.$extra].space = {
  52278. width: this.medium.short,
  52279. height: this.medium.long
  52280. };
  52281. if (this.medium.orientation === "landscape") {
  52282. const x = style.width;
  52283. style.width = style.height;
  52284. style.height = x;
  52285. this[_symbol_utils.$extra].space = {
  52286. width: this.medium.long,
  52287. height: this.medium.short
  52288. };
  52289. }
  52290. } else {
  52291. (0, _util.warn)("XFA - No medium specified in pageArea: please file a bug.");
  52292. }
  52293. this[_symbol_utils.$childrenToHTML]({
  52294. filter: new Set(["area", "draw", "field", "subform"]),
  52295. include: true
  52296. });
  52297. this[_symbol_utils.$childrenToHTML]({
  52298. filter: new Set(["contentArea"]),
  52299. include: true
  52300. });
  52301. return _utils.HTMLResult.success({
  52302. name: "div",
  52303. children,
  52304. attributes: {
  52305. class: ["xfaPage"],
  52306. id: this[_symbol_utils.$uid],
  52307. style,
  52308. xfaName: this.name
  52309. }
  52310. });
  52311. }
  52312. }
  52313. class PageSet extends _xfa_object.XFAObject {
  52314. constructor(attributes) {
  52315. super(TEMPLATE_NS_ID, "pageSet", true);
  52316. this.duplexImposition = (0, _utils.getStringOption)(attributes.duplexImposition, ["longEdge", "shortEdge"]);
  52317. this.id = attributes.id || "";
  52318. this.name = attributes.name || "";
  52319. this.relation = (0, _utils.getStringOption)(attributes.relation, ["orderedOccurrence", "duplexPaginated", "simplexPaginated"]);
  52320. this.relevant = (0, _utils.getRelevant)(attributes.relevant);
  52321. this.use = attributes.use || "";
  52322. this.usehref = attributes.usehref || "";
  52323. this.extras = null;
  52324. this.occur = null;
  52325. this.pageArea = new _xfa_object.XFAObjectArray();
  52326. this.pageSet = new _xfa_object.XFAObjectArray();
  52327. }
  52328. [_symbol_utils.$cleanPage]() {
  52329. for (const page of this.pageArea.children) {
  52330. page[_symbol_utils.$cleanPage]();
  52331. }
  52332. for (const page of this.pageSet.children) {
  52333. page[_symbol_utils.$cleanPage]();
  52334. }
  52335. }
  52336. [_symbol_utils.$isUsable]() {
  52337. return !this.occur || this.occur.max === -1 || this[_symbol_utils.$extra].numberOfUse < this.occur.max;
  52338. }
  52339. [_symbol_utils.$getNextPage]() {
  52340. if (!this[_symbol_utils.$extra]) {
  52341. this[_symbol_utils.$extra] = {
  52342. numberOfUse: 1,
  52343. pageIndex: -1,
  52344. pageSetIndex: -1
  52345. };
  52346. }
  52347. if (this.relation === "orderedOccurrence") {
  52348. if (this[_symbol_utils.$extra].pageIndex + 1 < this.pageArea.children.length) {
  52349. this[_symbol_utils.$extra].pageIndex += 1;
  52350. const pageArea = this.pageArea.children[this[_symbol_utils.$extra].pageIndex];
  52351. return pageArea[_symbol_utils.$getNextPage]();
  52352. }
  52353. if (this[_symbol_utils.$extra].pageSetIndex + 1 < this.pageSet.children.length) {
  52354. this[_symbol_utils.$extra].pageSetIndex += 1;
  52355. return this.pageSet.children[this[_symbol_utils.$extra].pageSetIndex][_symbol_utils.$getNextPage]();
  52356. }
  52357. if (this[_symbol_utils.$isUsable]()) {
  52358. this[_symbol_utils.$extra].numberOfUse += 1;
  52359. this[_symbol_utils.$extra].pageIndex = -1;
  52360. this[_symbol_utils.$extra].pageSetIndex = -1;
  52361. return this[_symbol_utils.$getNextPage]();
  52362. }
  52363. const parent = this[_symbol_utils.$getParent]();
  52364. if (parent instanceof PageSet) {
  52365. return parent[_symbol_utils.$getNextPage]();
  52366. }
  52367. this[_symbol_utils.$cleanPage]();
  52368. return this[_symbol_utils.$getNextPage]();
  52369. }
  52370. const pageNumber = this[_symbol_utils.$getTemplateRoot]()[_symbol_utils.$extra].pageNumber;
  52371. const parity = pageNumber % 2 === 0 ? "even" : "odd";
  52372. const position = pageNumber === 0 ? "first" : "rest";
  52373. let page = this.pageArea.children.find(p => p.oddOrEven === parity && p.pagePosition === position);
  52374. if (page) {
  52375. return page;
  52376. }
  52377. page = this.pageArea.children.find(p => p.oddOrEven === "any" && p.pagePosition === position);
  52378. if (page) {
  52379. return page;
  52380. }
  52381. page = this.pageArea.children.find(p => p.oddOrEven === "any" && p.pagePosition === "any");
  52382. if (page) {
  52383. return page;
  52384. }
  52385. return this.pageArea.children[0];
  52386. }
  52387. }
  52388. class Para extends _xfa_object.XFAObject {
  52389. constructor(attributes) {
  52390. super(TEMPLATE_NS_ID, "para", true);
  52391. this.hAlign = (0, _utils.getStringOption)(attributes.hAlign, ["left", "center", "justify", "justifyAll", "radix", "right"]);
  52392. this.id = attributes.id || "";
  52393. this.lineHeight = attributes.lineHeight ? (0, _utils.getMeasurement)(attributes.lineHeight, "0pt") : "";
  52394. this.marginLeft = attributes.marginLeft ? (0, _utils.getMeasurement)(attributes.marginLeft, "0pt") : "";
  52395. this.marginRight = attributes.marginRight ? (0, _utils.getMeasurement)(attributes.marginRight, "0pt") : "";
  52396. this.orphans = (0, _utils.getInteger)({
  52397. data: attributes.orphans,
  52398. defaultValue: 0,
  52399. validate: x => x >= 0
  52400. });
  52401. this.preserve = attributes.preserve || "";
  52402. this.radixOffset = attributes.radixOffset ? (0, _utils.getMeasurement)(attributes.radixOffset, "0pt") : "";
  52403. this.spaceAbove = attributes.spaceAbove ? (0, _utils.getMeasurement)(attributes.spaceAbove, "0pt") : "";
  52404. this.spaceBelow = attributes.spaceBelow ? (0, _utils.getMeasurement)(attributes.spaceBelow, "0pt") : "";
  52405. this.tabDefault = attributes.tabDefault ? (0, _utils.getMeasurement)(this.tabDefault) : "";
  52406. this.tabStops = (attributes.tabStops || "").trim().split(/\s+/).map((x, i) => i % 2 === 1 ? (0, _utils.getMeasurement)(x) : x);
  52407. this.textIndent = attributes.textIndent ? (0, _utils.getMeasurement)(attributes.textIndent, "0pt") : "";
  52408. this.use = attributes.use || "";
  52409. this.usehref = attributes.usehref || "";
  52410. this.vAlign = (0, _utils.getStringOption)(attributes.vAlign, ["top", "bottom", "middle"]);
  52411. this.widows = (0, _utils.getInteger)({
  52412. data: attributes.widows,
  52413. defaultValue: 0,
  52414. validate: x => x >= 0
  52415. });
  52416. this.hyphenation = null;
  52417. }
  52418. [_symbol_utils.$toStyle]() {
  52419. const style = (0, _html_utils.toStyle)(this, "hAlign");
  52420. if (this.marginLeft !== "") {
  52421. style.paddingLeft = (0, _html_utils.measureToString)(this.marginLeft);
  52422. }
  52423. if (this.marginRight !== "") {
  52424. style.paddingight = (0, _html_utils.measureToString)(this.marginRight);
  52425. }
  52426. if (this.spaceAbove !== "") {
  52427. style.paddingTop = (0, _html_utils.measureToString)(this.spaceAbove);
  52428. }
  52429. if (this.spaceBelow !== "") {
  52430. style.paddingBottom = (0, _html_utils.measureToString)(this.spaceBelow);
  52431. }
  52432. if (this.textIndent !== "") {
  52433. style.textIndent = (0, _html_utils.measureToString)(this.textIndent);
  52434. (0, _html_utils.fixTextIndent)(style);
  52435. }
  52436. if (this.lineHeight > 0) {
  52437. style.lineHeight = (0, _html_utils.measureToString)(this.lineHeight);
  52438. }
  52439. if (this.tabDefault !== "") {
  52440. style.tabSize = (0, _html_utils.measureToString)(this.tabDefault);
  52441. }
  52442. if (this.tabStops.length > 0) {}
  52443. if (this.hyphenatation) {
  52444. Object.assign(style, this.hyphenatation[_symbol_utils.$toStyle]());
  52445. }
  52446. return style;
  52447. }
  52448. }
  52449. class PasswordEdit extends _xfa_object.XFAObject {
  52450. constructor(attributes) {
  52451. super(TEMPLATE_NS_ID, "passwordEdit", true);
  52452. this.hScrollPolicy = (0, _utils.getStringOption)(attributes.hScrollPolicy, ["auto", "off", "on"]);
  52453. this.id = attributes.id || "";
  52454. this.passwordChar = attributes.passwordChar || "*";
  52455. this.use = attributes.use || "";
  52456. this.usehref = attributes.usehref || "";
  52457. this.border = null;
  52458. this.extras = null;
  52459. this.margin = null;
  52460. }
  52461. }
  52462. class Pattern extends _xfa_object.XFAObject {
  52463. constructor(attributes) {
  52464. super(TEMPLATE_NS_ID, "pattern", true);
  52465. this.id = attributes.id || "";
  52466. this.type = (0, _utils.getStringOption)(attributes.type, ["crossHatch", "crossDiagonal", "diagonalLeft", "diagonalRight", "horizontal", "vertical"]);
  52467. this.use = attributes.use || "";
  52468. this.usehref = attributes.usehref || "";
  52469. this.color = null;
  52470. this.extras = null;
  52471. }
  52472. [_symbol_utils.$toStyle](startColor) {
  52473. startColor = startColor ? startColor[_symbol_utils.$toStyle]() : "#FFFFFF";
  52474. const endColor = this.color ? this.color[_symbol_utils.$toStyle]() : "#000000";
  52475. const width = 5;
  52476. const cmd = "repeating-linear-gradient";
  52477. const colors = `${startColor},${startColor} ${width}px,${endColor} ${width}px,${endColor} ${2 * width}px`;
  52478. switch (this.type) {
  52479. case "crossHatch":
  52480. return `${cmd}(to top,${colors}) ${cmd}(to right,${colors})`;
  52481. case "crossDiagonal":
  52482. return `${cmd}(45deg,${colors}) ${cmd}(-45deg,${colors})`;
  52483. case "diagonalLeft":
  52484. return `${cmd}(45deg,${colors})`;
  52485. case "diagonalRight":
  52486. return `${cmd}(-45deg,${colors})`;
  52487. case "horizontal":
  52488. return `${cmd}(to top,${colors})`;
  52489. case "vertical":
  52490. return `${cmd}(to right,${colors})`;
  52491. }
  52492. return "";
  52493. }
  52494. }
  52495. class Picture extends _xfa_object.StringObject {
  52496. constructor(attributes) {
  52497. super(TEMPLATE_NS_ID, "picture");
  52498. this.id = attributes.id || "";
  52499. this.use = attributes.use || "";
  52500. this.usehref = attributes.usehref || "";
  52501. }
  52502. }
  52503. class Proto extends _xfa_object.XFAObject {
  52504. constructor(attributes) {
  52505. super(TEMPLATE_NS_ID, "proto", true);
  52506. this.appearanceFilter = new _xfa_object.XFAObjectArray();
  52507. this.arc = new _xfa_object.XFAObjectArray();
  52508. this.area = new _xfa_object.XFAObjectArray();
  52509. this.assist = new _xfa_object.XFAObjectArray();
  52510. this.barcode = new _xfa_object.XFAObjectArray();
  52511. this.bindItems = new _xfa_object.XFAObjectArray();
  52512. this.bookend = new _xfa_object.XFAObjectArray();
  52513. this.boolean = new _xfa_object.XFAObjectArray();
  52514. this.border = new _xfa_object.XFAObjectArray();
  52515. this.break = new _xfa_object.XFAObjectArray();
  52516. this.breakAfter = new _xfa_object.XFAObjectArray();
  52517. this.breakBefore = new _xfa_object.XFAObjectArray();
  52518. this.button = new _xfa_object.XFAObjectArray();
  52519. this.calculate = new _xfa_object.XFAObjectArray();
  52520. this.caption = new _xfa_object.XFAObjectArray();
  52521. this.certificate = new _xfa_object.XFAObjectArray();
  52522. this.certificates = new _xfa_object.XFAObjectArray();
  52523. this.checkButton = new _xfa_object.XFAObjectArray();
  52524. this.choiceList = new _xfa_object.XFAObjectArray();
  52525. this.color = new _xfa_object.XFAObjectArray();
  52526. this.comb = new _xfa_object.XFAObjectArray();
  52527. this.connect = new _xfa_object.XFAObjectArray();
  52528. this.contentArea = new _xfa_object.XFAObjectArray();
  52529. this.corner = new _xfa_object.XFAObjectArray();
  52530. this.date = new _xfa_object.XFAObjectArray();
  52531. this.dateTime = new _xfa_object.XFAObjectArray();
  52532. this.dateTimeEdit = new _xfa_object.XFAObjectArray();
  52533. this.decimal = new _xfa_object.XFAObjectArray();
  52534. this.defaultUi = new _xfa_object.XFAObjectArray();
  52535. this.desc = new _xfa_object.XFAObjectArray();
  52536. this.digestMethod = new _xfa_object.XFAObjectArray();
  52537. this.digestMethods = new _xfa_object.XFAObjectArray();
  52538. this.draw = new _xfa_object.XFAObjectArray();
  52539. this.edge = new _xfa_object.XFAObjectArray();
  52540. this.encoding = new _xfa_object.XFAObjectArray();
  52541. this.encodings = new _xfa_object.XFAObjectArray();
  52542. this.encrypt = new _xfa_object.XFAObjectArray();
  52543. this.encryptData = new _xfa_object.XFAObjectArray();
  52544. this.encryption = new _xfa_object.XFAObjectArray();
  52545. this.encryptionMethod = new _xfa_object.XFAObjectArray();
  52546. this.encryptionMethods = new _xfa_object.XFAObjectArray();
  52547. this.event = new _xfa_object.XFAObjectArray();
  52548. this.exData = new _xfa_object.XFAObjectArray();
  52549. this.exObject = new _xfa_object.XFAObjectArray();
  52550. this.exclGroup = new _xfa_object.XFAObjectArray();
  52551. this.execute = new _xfa_object.XFAObjectArray();
  52552. this.extras = new _xfa_object.XFAObjectArray();
  52553. this.field = new _xfa_object.XFAObjectArray();
  52554. this.fill = new _xfa_object.XFAObjectArray();
  52555. this.filter = new _xfa_object.XFAObjectArray();
  52556. this.float = new _xfa_object.XFAObjectArray();
  52557. this.font = new _xfa_object.XFAObjectArray();
  52558. this.format = new _xfa_object.XFAObjectArray();
  52559. this.handler = new _xfa_object.XFAObjectArray();
  52560. this.hyphenation = new _xfa_object.XFAObjectArray();
  52561. this.image = new _xfa_object.XFAObjectArray();
  52562. this.imageEdit = new _xfa_object.XFAObjectArray();
  52563. this.integer = new _xfa_object.XFAObjectArray();
  52564. this.issuers = new _xfa_object.XFAObjectArray();
  52565. this.items = new _xfa_object.XFAObjectArray();
  52566. this.keep = new _xfa_object.XFAObjectArray();
  52567. this.keyUsage = new _xfa_object.XFAObjectArray();
  52568. this.line = new _xfa_object.XFAObjectArray();
  52569. this.linear = new _xfa_object.XFAObjectArray();
  52570. this.lockDocument = new _xfa_object.XFAObjectArray();
  52571. this.manifest = new _xfa_object.XFAObjectArray();
  52572. this.margin = new _xfa_object.XFAObjectArray();
  52573. this.mdp = new _xfa_object.XFAObjectArray();
  52574. this.medium = new _xfa_object.XFAObjectArray();
  52575. this.message = new _xfa_object.XFAObjectArray();
  52576. this.numericEdit = new _xfa_object.XFAObjectArray();
  52577. this.occur = new _xfa_object.XFAObjectArray();
  52578. this.oid = new _xfa_object.XFAObjectArray();
  52579. this.oids = new _xfa_object.XFAObjectArray();
  52580. this.overflow = new _xfa_object.XFAObjectArray();
  52581. this.pageArea = new _xfa_object.XFAObjectArray();
  52582. this.pageSet = new _xfa_object.XFAObjectArray();
  52583. this.para = new _xfa_object.XFAObjectArray();
  52584. this.passwordEdit = new _xfa_object.XFAObjectArray();
  52585. this.pattern = new _xfa_object.XFAObjectArray();
  52586. this.picture = new _xfa_object.XFAObjectArray();
  52587. this.radial = new _xfa_object.XFAObjectArray();
  52588. this.reason = new _xfa_object.XFAObjectArray();
  52589. this.reasons = new _xfa_object.XFAObjectArray();
  52590. this.rectangle = new _xfa_object.XFAObjectArray();
  52591. this.ref = new _xfa_object.XFAObjectArray();
  52592. this.script = new _xfa_object.XFAObjectArray();
  52593. this.setProperty = new _xfa_object.XFAObjectArray();
  52594. this.signData = new _xfa_object.XFAObjectArray();
  52595. this.signature = new _xfa_object.XFAObjectArray();
  52596. this.signing = new _xfa_object.XFAObjectArray();
  52597. this.solid = new _xfa_object.XFAObjectArray();
  52598. this.speak = new _xfa_object.XFAObjectArray();
  52599. this.stipple = new _xfa_object.XFAObjectArray();
  52600. this.subform = new _xfa_object.XFAObjectArray();
  52601. this.subformSet = new _xfa_object.XFAObjectArray();
  52602. this.subjectDN = new _xfa_object.XFAObjectArray();
  52603. this.subjectDNs = new _xfa_object.XFAObjectArray();
  52604. this.submit = new _xfa_object.XFAObjectArray();
  52605. this.text = new _xfa_object.XFAObjectArray();
  52606. this.textEdit = new _xfa_object.XFAObjectArray();
  52607. this.time = new _xfa_object.XFAObjectArray();
  52608. this.timeStamp = new _xfa_object.XFAObjectArray();
  52609. this.toolTip = new _xfa_object.XFAObjectArray();
  52610. this.traversal = new _xfa_object.XFAObjectArray();
  52611. this.traverse = new _xfa_object.XFAObjectArray();
  52612. this.ui = new _xfa_object.XFAObjectArray();
  52613. this.validate = new _xfa_object.XFAObjectArray();
  52614. this.value = new _xfa_object.XFAObjectArray();
  52615. this.variables = new _xfa_object.XFAObjectArray();
  52616. }
  52617. }
  52618. class Radial extends _xfa_object.XFAObject {
  52619. constructor(attributes) {
  52620. super(TEMPLATE_NS_ID, "radial", true);
  52621. this.id = attributes.id || "";
  52622. this.type = (0, _utils.getStringOption)(attributes.type, ["toEdge", "toCenter"]);
  52623. this.use = attributes.use || "";
  52624. this.usehref = attributes.usehref || "";
  52625. this.color = null;
  52626. this.extras = null;
  52627. }
  52628. [_symbol_utils.$toStyle](startColor) {
  52629. startColor = startColor ? startColor[_symbol_utils.$toStyle]() : "#FFFFFF";
  52630. const endColor = this.color ? this.color[_symbol_utils.$toStyle]() : "#000000";
  52631. const colors = this.type === "toEdge" ? `${startColor},${endColor}` : `${endColor},${startColor}`;
  52632. return `radial-gradient(circle at center, ${colors})`;
  52633. }
  52634. }
  52635. class Reason extends _xfa_object.StringObject {
  52636. constructor(attributes) {
  52637. super(TEMPLATE_NS_ID, "reason");
  52638. this.id = attributes.id || "";
  52639. this.name = attributes.name || "";
  52640. this.use = attributes.use || "";
  52641. this.usehref = attributes.usehref || "";
  52642. }
  52643. }
  52644. class Reasons extends _xfa_object.XFAObject {
  52645. constructor(attributes) {
  52646. super(TEMPLATE_NS_ID, "reasons", true);
  52647. this.id = attributes.id || "";
  52648. this.type = (0, _utils.getStringOption)(attributes.type, ["optional", "required"]);
  52649. this.use = attributes.use || "";
  52650. this.usehref = attributes.usehref || "";
  52651. this.reason = new _xfa_object.XFAObjectArray();
  52652. }
  52653. }
  52654. class Rectangle extends _xfa_object.XFAObject {
  52655. constructor(attributes) {
  52656. super(TEMPLATE_NS_ID, "rectangle", true);
  52657. this.hand = (0, _utils.getStringOption)(attributes.hand, ["even", "left", "right"]);
  52658. this.id = attributes.id || "";
  52659. this.use = attributes.use || "";
  52660. this.usehref = attributes.usehref || "";
  52661. this.corner = new _xfa_object.XFAObjectArray(4);
  52662. this.edge = new _xfa_object.XFAObjectArray(4);
  52663. this.fill = null;
  52664. }
  52665. [_symbol_utils.$toHTML]() {
  52666. const edge = this.edge.children.length ? this.edge.children[0] : new Edge({});
  52667. const edgeStyle = edge[_symbol_utils.$toStyle]();
  52668. const style = Object.create(null);
  52669. if (this.fill?.presence === "visible") {
  52670. Object.assign(style, this.fill[_symbol_utils.$toStyle]());
  52671. } else {
  52672. style.fill = "transparent";
  52673. }
  52674. style.strokeWidth = (0, _html_utils.measureToString)(edge.presence === "visible" ? edge.thickness : 0);
  52675. style.stroke = edgeStyle.color;
  52676. const corner = this.corner.children.length ? this.corner.children[0] : new Corner({});
  52677. const cornerStyle = corner[_symbol_utils.$toStyle]();
  52678. const rect = {
  52679. name: "rect",
  52680. attributes: {
  52681. xmlns: SVG_NS,
  52682. width: "100%",
  52683. height: "100%",
  52684. x: 0,
  52685. y: 0,
  52686. rx: cornerStyle.radius,
  52687. ry: cornerStyle.radius,
  52688. style
  52689. }
  52690. };
  52691. const svg = {
  52692. name: "svg",
  52693. children: [rect],
  52694. attributes: {
  52695. xmlns: SVG_NS,
  52696. style: {
  52697. overflow: "visible"
  52698. },
  52699. width: "100%",
  52700. height: "100%"
  52701. }
  52702. };
  52703. const parent = this[_symbol_utils.$getParent]()[_symbol_utils.$getParent]();
  52704. if (hasMargin(parent)) {
  52705. return _utils.HTMLResult.success({
  52706. name: "div",
  52707. attributes: {
  52708. style: {
  52709. display: "inline",
  52710. width: "100%",
  52711. height: "100%"
  52712. }
  52713. },
  52714. children: [svg]
  52715. });
  52716. }
  52717. svg.attributes.style.position = "absolute";
  52718. return _utils.HTMLResult.success(svg);
  52719. }
  52720. }
  52721. class RefElement extends _xfa_object.StringObject {
  52722. constructor(attributes) {
  52723. super(TEMPLATE_NS_ID, "ref");
  52724. this.id = attributes.id || "";
  52725. this.use = attributes.use || "";
  52726. this.usehref = attributes.usehref || "";
  52727. }
  52728. }
  52729. class Script extends _xfa_object.StringObject {
  52730. constructor(attributes) {
  52731. super(TEMPLATE_NS_ID, "script");
  52732. this.binding = attributes.binding || "";
  52733. this.contentType = attributes.contentType || "";
  52734. this.id = attributes.id || "";
  52735. this.name = attributes.name || "";
  52736. this.runAt = (0, _utils.getStringOption)(attributes.runAt, ["client", "both", "server"]);
  52737. this.use = attributes.use || "";
  52738. this.usehref = attributes.usehref || "";
  52739. }
  52740. }
  52741. class SetProperty extends _xfa_object.XFAObject {
  52742. constructor(attributes) {
  52743. super(TEMPLATE_NS_ID, "setProperty");
  52744. this.connection = attributes.connection || "";
  52745. this.ref = attributes.ref || "";
  52746. this.target = attributes.target || "";
  52747. }
  52748. }
  52749. exports.SetProperty = SetProperty;
  52750. class SignData extends _xfa_object.XFAObject {
  52751. constructor(attributes) {
  52752. super(TEMPLATE_NS_ID, "signData", true);
  52753. this.id = attributes.id || "";
  52754. this.operation = (0, _utils.getStringOption)(attributes.operation, ["sign", "clear", "verify"]);
  52755. this.ref = attributes.ref || "";
  52756. this.target = attributes.target || "";
  52757. this.use = attributes.use || "";
  52758. this.usehref = attributes.usehref || "";
  52759. this.filter = null;
  52760. this.manifest = null;
  52761. }
  52762. }
  52763. class Signature extends _xfa_object.XFAObject {
  52764. constructor(attributes) {
  52765. super(TEMPLATE_NS_ID, "signature", true);
  52766. this.id = attributes.id || "";
  52767. this.type = (0, _utils.getStringOption)(attributes.type, ["PDF1.3", "PDF1.6"]);
  52768. this.use = attributes.use || "";
  52769. this.usehref = attributes.usehref || "";
  52770. this.border = null;
  52771. this.extras = null;
  52772. this.filter = null;
  52773. this.manifest = null;
  52774. this.margin = null;
  52775. }
  52776. }
  52777. class Signing extends _xfa_object.XFAObject {
  52778. constructor(attributes) {
  52779. super(TEMPLATE_NS_ID, "signing", true);
  52780. this.id = attributes.id || "";
  52781. this.type = (0, _utils.getStringOption)(attributes.type, ["optional", "required"]);
  52782. this.use = attributes.use || "";
  52783. this.usehref = attributes.usehref || "";
  52784. this.certificate = new _xfa_object.XFAObjectArray();
  52785. }
  52786. }
  52787. class Solid extends _xfa_object.XFAObject {
  52788. constructor(attributes) {
  52789. super(TEMPLATE_NS_ID, "solid", true);
  52790. this.id = attributes.id || "";
  52791. this.use = attributes.use || "";
  52792. this.usehref = attributes.usehref || "";
  52793. this.extras = null;
  52794. }
  52795. [_symbol_utils.$toStyle](startColor) {
  52796. return startColor ? startColor[_symbol_utils.$toStyle]() : "#FFFFFF";
  52797. }
  52798. }
  52799. class Speak extends _xfa_object.StringObject {
  52800. constructor(attributes) {
  52801. super(TEMPLATE_NS_ID, "speak");
  52802. this.disable = (0, _utils.getInteger)({
  52803. data: attributes.disable,
  52804. defaultValue: 0,
  52805. validate: x => x === 1
  52806. });
  52807. this.id = attributes.id || "";
  52808. this.priority = (0, _utils.getStringOption)(attributes.priority, ["custom", "caption", "name", "toolTip"]);
  52809. this.rid = attributes.rid || "";
  52810. this.use = attributes.use || "";
  52811. this.usehref = attributes.usehref || "";
  52812. }
  52813. }
  52814. class Stipple extends _xfa_object.XFAObject {
  52815. constructor(attributes) {
  52816. super(TEMPLATE_NS_ID, "stipple", true);
  52817. this.id = attributes.id || "";
  52818. this.rate = (0, _utils.getInteger)({
  52819. data: attributes.rate,
  52820. defaultValue: 50,
  52821. validate: x => x >= 0 && x <= 100
  52822. });
  52823. this.use = attributes.use || "";
  52824. this.usehref = attributes.usehref || "";
  52825. this.color = null;
  52826. this.extras = null;
  52827. }
  52828. [_symbol_utils.$toStyle](bgColor) {
  52829. const alpha = this.rate / 100;
  52830. 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));
  52831. }
  52832. }
  52833. class Subform extends _xfa_object.XFAObject {
  52834. constructor(attributes) {
  52835. super(TEMPLATE_NS_ID, "subform", true);
  52836. this.access = (0, _utils.getStringOption)(attributes.access, ["open", "nonInteractive", "protected", "readOnly"]);
  52837. this.allowMacro = (0, _utils.getInteger)({
  52838. data: attributes.allowMacro,
  52839. defaultValue: 0,
  52840. validate: x => x === 1
  52841. });
  52842. this.anchorType = (0, _utils.getStringOption)(attributes.anchorType, ["topLeft", "bottomCenter", "bottomLeft", "bottomRight", "middleCenter", "middleLeft", "middleRight", "topCenter", "topRight"]);
  52843. this.colSpan = (0, _utils.getInteger)({
  52844. data: attributes.colSpan,
  52845. defaultValue: 1,
  52846. validate: n => n >= 1 || n === -1
  52847. });
  52848. this.columnWidths = (attributes.columnWidths || "").trim().split(/\s+/).map(x => x === "-1" ? -1 : (0, _utils.getMeasurement)(x));
  52849. this.h = attributes.h ? (0, _utils.getMeasurement)(attributes.h) : "";
  52850. this.hAlign = (0, _utils.getStringOption)(attributes.hAlign, ["left", "center", "justify", "justifyAll", "radix", "right"]);
  52851. this.id = attributes.id || "";
  52852. this.layout = (0, _utils.getStringOption)(attributes.layout, ["position", "lr-tb", "rl-row", "rl-tb", "row", "table", "tb"]);
  52853. this.locale = attributes.locale || "";
  52854. this.maxH = (0, _utils.getMeasurement)(attributes.maxH, "0pt");
  52855. this.maxW = (0, _utils.getMeasurement)(attributes.maxW, "0pt");
  52856. this.mergeMode = (0, _utils.getStringOption)(attributes.mergeMode, ["consumeData", "matchTemplate"]);
  52857. this.minH = (0, _utils.getMeasurement)(attributes.minH, "0pt");
  52858. this.minW = (0, _utils.getMeasurement)(attributes.minW, "0pt");
  52859. this.name = attributes.name || "";
  52860. this.presence = (0, _utils.getStringOption)(attributes.presence, ["visible", "hidden", "inactive", "invisible"]);
  52861. this.relevant = (0, _utils.getRelevant)(attributes.relevant);
  52862. this.restoreState = (0, _utils.getStringOption)(attributes.restoreState, ["manual", "auto"]);
  52863. this.scope = (0, _utils.getStringOption)(attributes.scope, ["name", "none"]);
  52864. this.use = attributes.use || "";
  52865. this.usehref = attributes.usehref || "";
  52866. this.w = attributes.w ? (0, _utils.getMeasurement)(attributes.w) : "";
  52867. this.x = (0, _utils.getMeasurement)(attributes.x, "0pt");
  52868. this.y = (0, _utils.getMeasurement)(attributes.y, "0pt");
  52869. this.assist = null;
  52870. this.bind = null;
  52871. this.bookend = null;
  52872. this.border = null;
  52873. this.break = null;
  52874. this.calculate = null;
  52875. this.desc = null;
  52876. this.extras = null;
  52877. this.keep = null;
  52878. this.margin = null;
  52879. this.occur = null;
  52880. this.overflow = null;
  52881. this.pageSet = null;
  52882. this.para = null;
  52883. this.traversal = null;
  52884. this.validate = null;
  52885. this.variables = null;
  52886. this.area = new _xfa_object.XFAObjectArray();
  52887. this.breakAfter = new _xfa_object.XFAObjectArray();
  52888. this.breakBefore = new _xfa_object.XFAObjectArray();
  52889. this.connect = new _xfa_object.XFAObjectArray();
  52890. this.draw = new _xfa_object.XFAObjectArray();
  52891. this.event = new _xfa_object.XFAObjectArray();
  52892. this.exObject = new _xfa_object.XFAObjectArray();
  52893. this.exclGroup = new _xfa_object.XFAObjectArray();
  52894. this.field = new _xfa_object.XFAObjectArray();
  52895. this.proto = new _xfa_object.XFAObjectArray();
  52896. this.setProperty = new _xfa_object.XFAObjectArray();
  52897. this.subform = new _xfa_object.XFAObjectArray();
  52898. this.subformSet = new _xfa_object.XFAObjectArray();
  52899. }
  52900. [_symbol_utils.$getSubformParent]() {
  52901. const parent = this[_symbol_utils.$getParent]();
  52902. if (parent instanceof SubformSet) {
  52903. return parent[_symbol_utils.$getSubformParent]();
  52904. }
  52905. return parent;
  52906. }
  52907. [_symbol_utils.$isBindable]() {
  52908. return true;
  52909. }
  52910. [_symbol_utils.$isThereMoreWidth]() {
  52911. return this.layout.endsWith("-tb") && this[_symbol_utils.$extra].attempt === 0 && this[_symbol_utils.$extra].numberInLine > 0 || this[_symbol_utils.$getParent]()[_symbol_utils.$isThereMoreWidth]();
  52912. }
  52913. *[_symbol_utils.$getContainedChildren]() {
  52914. yield* getContainedChildren(this);
  52915. }
  52916. [_symbol_utils.$flushHTML]() {
  52917. return (0, _layout.flushHTML)(this);
  52918. }
  52919. [_symbol_utils.$addHTML](html, bbox) {
  52920. (0, _layout.addHTML)(this, html, bbox);
  52921. }
  52922. [_symbol_utils.$getAvailableSpace]() {
  52923. return (0, _layout.getAvailableSpace)(this);
  52924. }
  52925. [_symbol_utils.$isSplittable]() {
  52926. const parent = this[_symbol_utils.$getSubformParent]();
  52927. if (!parent[_symbol_utils.$isSplittable]()) {
  52928. return false;
  52929. }
  52930. if (this[_symbol_utils.$extra]._isSplittable !== undefined) {
  52931. return this[_symbol_utils.$extra]._isSplittable;
  52932. }
  52933. if (this.layout === "position" || this.layout.includes("row")) {
  52934. this[_symbol_utils.$extra]._isSplittable = false;
  52935. return false;
  52936. }
  52937. if (this.keep && this.keep.intact !== "none") {
  52938. this[_symbol_utils.$extra]._isSplittable = false;
  52939. return false;
  52940. }
  52941. if (parent.layout?.endsWith("-tb") && parent[_symbol_utils.$extra].numberInLine !== 0) {
  52942. return false;
  52943. }
  52944. this[_symbol_utils.$extra]._isSplittable = true;
  52945. return true;
  52946. }
  52947. [_symbol_utils.$toHTML](availableSpace) {
  52948. setTabIndex(this);
  52949. if (this.break) {
  52950. if (this.break.after !== "auto" || this.break.afterTarget !== "") {
  52951. const node = new BreakAfter({
  52952. targetType: this.break.after,
  52953. target: this.break.afterTarget,
  52954. startNew: this.break.startNew.toString()
  52955. });
  52956. node[_symbol_utils.$globalData] = this[_symbol_utils.$globalData];
  52957. this[_symbol_utils.$appendChild](node);
  52958. this.breakAfter.push(node);
  52959. }
  52960. if (this.break.before !== "auto" || this.break.beforeTarget !== "") {
  52961. const node = new BreakBefore({
  52962. targetType: this.break.before,
  52963. target: this.break.beforeTarget,
  52964. startNew: this.break.startNew.toString()
  52965. });
  52966. node[_symbol_utils.$globalData] = this[_symbol_utils.$globalData];
  52967. this[_symbol_utils.$appendChild](node);
  52968. this.breakBefore.push(node);
  52969. }
  52970. if (this.break.overflowTarget !== "") {
  52971. const node = new Overflow({
  52972. target: this.break.overflowTarget,
  52973. leader: this.break.overflowLeader,
  52974. trailer: this.break.overflowTrailer
  52975. });
  52976. node[_symbol_utils.$globalData] = this[_symbol_utils.$globalData];
  52977. this[_symbol_utils.$appendChild](node);
  52978. this.overflow.push(node);
  52979. }
  52980. this[_symbol_utils.$removeChild](this.break);
  52981. this.break = null;
  52982. }
  52983. if (this.presence === "hidden" || this.presence === "inactive") {
  52984. return _utils.HTMLResult.EMPTY;
  52985. }
  52986. if (this.breakBefore.children.length > 1 || this.breakAfter.children.length > 1) {
  52987. (0, _util.warn)("XFA - Several breakBefore or breakAfter in subforms: please file a bug.");
  52988. }
  52989. if (this.breakBefore.children.length >= 1) {
  52990. const breakBefore = this.breakBefore.children[0];
  52991. if (handleBreak(breakBefore)) {
  52992. return _utils.HTMLResult.breakNode(breakBefore);
  52993. }
  52994. }
  52995. if (this[_symbol_utils.$extra]?.afterBreakAfter) {
  52996. return _utils.HTMLResult.EMPTY;
  52997. }
  52998. (0, _html_utils.fixDimensions)(this);
  52999. const children = [];
  53000. const attributes = {
  53001. id: this[_symbol_utils.$uid],
  53002. class: []
  53003. };
  53004. (0, _html_utils.setAccess)(this, attributes.class);
  53005. if (!this[_symbol_utils.$extra]) {
  53006. this[_symbol_utils.$extra] = Object.create(null);
  53007. }
  53008. Object.assign(this[_symbol_utils.$extra], {
  53009. children,
  53010. line: null,
  53011. attributes,
  53012. attempt: 0,
  53013. numberInLine: 0,
  53014. availableSpace: {
  53015. width: Math.min(this.w || Infinity, availableSpace.width),
  53016. height: Math.min(this.h || Infinity, availableSpace.height)
  53017. },
  53018. width: 0,
  53019. height: 0,
  53020. prevHeight: 0,
  53021. currentWidth: 0
  53022. });
  53023. const root = this[_symbol_utils.$getTemplateRoot]();
  53024. const savedNoLayoutFailure = root[_symbol_utils.$extra].noLayoutFailure;
  53025. const isSplittable = this[_symbol_utils.$isSplittable]();
  53026. if (!isSplittable) {
  53027. setFirstUnsplittable(this);
  53028. }
  53029. if (!(0, _layout.checkDimensions)(this, availableSpace)) {
  53030. return _utils.HTMLResult.FAILURE;
  53031. }
  53032. const filter = new Set(["area", "draw", "exclGroup", "field", "subform", "subformSet"]);
  53033. if (this.layout.includes("row")) {
  53034. const columnWidths = this[_symbol_utils.$getSubformParent]().columnWidths;
  53035. if (Array.isArray(columnWidths) && columnWidths.length > 0) {
  53036. this[_symbol_utils.$extra].columnWidths = columnWidths;
  53037. this[_symbol_utils.$extra].currentColumn = 0;
  53038. }
  53039. }
  53040. const style = (0, _html_utils.toStyle)(this, "anchorType", "dimensions", "position", "presence", "border", "margin", "hAlign");
  53041. const classNames = ["xfaSubform"];
  53042. const cl = (0, _html_utils.layoutClass)(this);
  53043. if (cl) {
  53044. classNames.push(cl);
  53045. }
  53046. attributes.style = style;
  53047. attributes.class = classNames;
  53048. if (this.name) {
  53049. attributes.xfaName = this.name;
  53050. }
  53051. if (this.overflow) {
  53052. const overflowExtra = this.overflow[_symbol_utils.$getExtra]();
  53053. if (overflowExtra.addLeader) {
  53054. overflowExtra.addLeader = false;
  53055. handleOverflow(this, overflowExtra.leader, availableSpace);
  53056. }
  53057. }
  53058. this[_symbol_utils.$pushPara]();
  53059. const isLrTb = this.layout === "lr-tb" || this.layout === "rl-tb";
  53060. const maxRun = isLrTb ? MAX_ATTEMPTS_FOR_LRTB_LAYOUT : 1;
  53061. for (; this[_symbol_utils.$extra].attempt < maxRun; this[_symbol_utils.$extra].attempt++) {
  53062. if (isLrTb && this[_symbol_utils.$extra].attempt === MAX_ATTEMPTS_FOR_LRTB_LAYOUT - 1) {
  53063. this[_symbol_utils.$extra].numberInLine = 0;
  53064. }
  53065. const result = this[_symbol_utils.$childrenToHTML]({
  53066. filter,
  53067. include: true
  53068. });
  53069. if (result.success) {
  53070. break;
  53071. }
  53072. if (result.isBreak()) {
  53073. this[_symbol_utils.$popPara]();
  53074. return result;
  53075. }
  53076. if (isLrTb && this[_symbol_utils.$extra].attempt === 0 && this[_symbol_utils.$extra].numberInLine === 0 && !root[_symbol_utils.$extra].noLayoutFailure) {
  53077. this[_symbol_utils.$extra].attempt = maxRun;
  53078. break;
  53079. }
  53080. }
  53081. this[_symbol_utils.$popPara]();
  53082. if (!isSplittable) {
  53083. unsetFirstUnsplittable(this);
  53084. }
  53085. root[_symbol_utils.$extra].noLayoutFailure = savedNoLayoutFailure;
  53086. if (this[_symbol_utils.$extra].attempt === maxRun) {
  53087. if (this.overflow) {
  53088. this[_symbol_utils.$getTemplateRoot]()[_symbol_utils.$extra].overflowNode = this.overflow;
  53089. }
  53090. if (!isSplittable) {
  53091. delete this[_symbol_utils.$extra];
  53092. }
  53093. return _utils.HTMLResult.FAILURE;
  53094. }
  53095. if (this.overflow) {
  53096. const overflowExtra = this.overflow[_symbol_utils.$getExtra]();
  53097. if (overflowExtra.addTrailer) {
  53098. overflowExtra.addTrailer = false;
  53099. handleOverflow(this, overflowExtra.trailer, availableSpace);
  53100. }
  53101. }
  53102. let marginH = 0;
  53103. let marginV = 0;
  53104. if (this.margin) {
  53105. marginH = this.margin.leftInset + this.margin.rightInset;
  53106. marginV = this.margin.topInset + this.margin.bottomInset;
  53107. }
  53108. const width = Math.max(this[_symbol_utils.$extra].width + marginH, this.w || 0);
  53109. const height = Math.max(this[_symbol_utils.$extra].height + marginV, this.h || 0);
  53110. const bbox = [this.x, this.y, width, height];
  53111. if (this.w === "") {
  53112. style.width = (0, _html_utils.measureToString)(width);
  53113. }
  53114. if (this.h === "") {
  53115. style.height = (0, _html_utils.measureToString)(height);
  53116. }
  53117. if ((style.width === "0px" || style.height === "0px") && children.length === 0) {
  53118. return _utils.HTMLResult.EMPTY;
  53119. }
  53120. const html = {
  53121. name: "div",
  53122. attributes,
  53123. children
  53124. };
  53125. applyAssist(this, attributes);
  53126. const result = _utils.HTMLResult.success((0, _html_utils.createWrapper)(this, html), bbox);
  53127. if (this.breakAfter.children.length >= 1) {
  53128. const breakAfter = this.breakAfter.children[0];
  53129. if (handleBreak(breakAfter)) {
  53130. this[_symbol_utils.$extra].afterBreakAfter = result;
  53131. return _utils.HTMLResult.breakNode(breakAfter);
  53132. }
  53133. }
  53134. delete this[_symbol_utils.$extra];
  53135. return result;
  53136. }
  53137. }
  53138. class SubformSet extends _xfa_object.XFAObject {
  53139. constructor(attributes) {
  53140. super(TEMPLATE_NS_ID, "subformSet", true);
  53141. this.id = attributes.id || "";
  53142. this.name = attributes.name || "";
  53143. this.relation = (0, _utils.getStringOption)(attributes.relation, ["ordered", "choice", "unordered"]);
  53144. this.relevant = (0, _utils.getRelevant)(attributes.relevant);
  53145. this.use = attributes.use || "";
  53146. this.usehref = attributes.usehref || "";
  53147. this.bookend = null;
  53148. this.break = null;
  53149. this.desc = null;
  53150. this.extras = null;
  53151. this.occur = null;
  53152. this.overflow = null;
  53153. this.breakAfter = new _xfa_object.XFAObjectArray();
  53154. this.breakBefore = new _xfa_object.XFAObjectArray();
  53155. this.subform = new _xfa_object.XFAObjectArray();
  53156. this.subformSet = new _xfa_object.XFAObjectArray();
  53157. }
  53158. *[_symbol_utils.$getContainedChildren]() {
  53159. yield* getContainedChildren(this);
  53160. }
  53161. [_symbol_utils.$getSubformParent]() {
  53162. let parent = this[_symbol_utils.$getParent]();
  53163. while (!(parent instanceof Subform)) {
  53164. parent = parent[_symbol_utils.$getParent]();
  53165. }
  53166. return parent;
  53167. }
  53168. [_symbol_utils.$isBindable]() {
  53169. return true;
  53170. }
  53171. }
  53172. class SubjectDN extends _xfa_object.ContentObject {
  53173. constructor(attributes) {
  53174. super(TEMPLATE_NS_ID, "subjectDN");
  53175. this.delimiter = attributes.delimiter || ",";
  53176. this.id = attributes.id || "";
  53177. this.name = attributes.name || "";
  53178. this.use = attributes.use || "";
  53179. this.usehref = attributes.usehref || "";
  53180. }
  53181. [_symbol_utils.$finalize]() {
  53182. this[_symbol_utils.$content] = new Map(this[_symbol_utils.$content].split(this.delimiter).map(kv => {
  53183. kv = kv.split("=", 2);
  53184. kv[0] = kv[0].trim();
  53185. return kv;
  53186. }));
  53187. }
  53188. }
  53189. class SubjectDNs extends _xfa_object.XFAObject {
  53190. constructor(attributes) {
  53191. super(TEMPLATE_NS_ID, "subjectDNs", true);
  53192. this.id = attributes.id || "";
  53193. this.type = (0, _utils.getStringOption)(attributes.type, ["optional", "required"]);
  53194. this.use = attributes.use || "";
  53195. this.usehref = attributes.usehref || "";
  53196. this.subjectDN = new _xfa_object.XFAObjectArray();
  53197. }
  53198. }
  53199. class Submit extends _xfa_object.XFAObject {
  53200. constructor(attributes) {
  53201. super(TEMPLATE_NS_ID, "submit", true);
  53202. this.embedPDF = (0, _utils.getInteger)({
  53203. data: attributes.embedPDF,
  53204. defaultValue: 0,
  53205. validate: x => x === 1
  53206. });
  53207. this.format = (0, _utils.getStringOption)(attributes.format, ["xdp", "formdata", "pdf", "urlencoded", "xfd", "xml"]);
  53208. this.id = attributes.id || "";
  53209. this.target = attributes.target || "";
  53210. this.textEncoding = (0, _utils.getKeyword)({
  53211. data: attributes.textEncoding ? attributes.textEncoding.toLowerCase() : "",
  53212. defaultValue: "",
  53213. 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}/)
  53214. });
  53215. this.use = attributes.use || "";
  53216. this.usehref = attributes.usehref || "";
  53217. this.xdpContent = attributes.xdpContent || "";
  53218. this.encrypt = null;
  53219. this.encryptData = new _xfa_object.XFAObjectArray();
  53220. this.signData = new _xfa_object.XFAObjectArray();
  53221. }
  53222. }
  53223. class Template extends _xfa_object.XFAObject {
  53224. constructor(attributes) {
  53225. super(TEMPLATE_NS_ID, "template", true);
  53226. this.baseProfile = (0, _utils.getStringOption)(attributes.baseProfile, ["full", "interactiveForms"]);
  53227. this.extras = null;
  53228. this.subform = new _xfa_object.XFAObjectArray();
  53229. }
  53230. [_symbol_utils.$finalize]() {
  53231. if (this.subform.children.length === 0) {
  53232. (0, _util.warn)("XFA - No subforms in template node.");
  53233. }
  53234. if (this.subform.children.length >= 2) {
  53235. (0, _util.warn)("XFA - Several subforms in template node: please file a bug.");
  53236. }
  53237. this[_symbol_utils.$tabIndex] = DEFAULT_TAB_INDEX;
  53238. }
  53239. [_symbol_utils.$isSplittable]() {
  53240. return true;
  53241. }
  53242. [_symbol_utils.$searchNode](expr, container) {
  53243. if (expr.startsWith("#")) {
  53244. return [this[_symbol_utils.$ids].get(expr.slice(1))];
  53245. }
  53246. return (0, _som.searchNode)(this, container, expr, true, true);
  53247. }
  53248. *[_symbol_utils.$toPages]() {
  53249. if (!this.subform.children.length) {
  53250. return _utils.HTMLResult.success({
  53251. name: "div",
  53252. children: []
  53253. });
  53254. }
  53255. this[_symbol_utils.$extra] = {
  53256. overflowNode: null,
  53257. firstUnsplittable: null,
  53258. currentContentArea: null,
  53259. currentPageArea: null,
  53260. noLayoutFailure: false,
  53261. pageNumber: 1,
  53262. pagePosition: "first",
  53263. oddOrEven: "odd",
  53264. blankOrNotBlank: "nonBlank",
  53265. paraStack: []
  53266. };
  53267. const root = this.subform.children[0];
  53268. root.pageSet[_symbol_utils.$cleanPage]();
  53269. const pageAreas = root.pageSet.pageArea.children;
  53270. const mainHtml = {
  53271. name: "div",
  53272. children: []
  53273. };
  53274. let pageArea = null;
  53275. let breakBefore = null;
  53276. let breakBeforeTarget = null;
  53277. if (root.breakBefore.children.length >= 1) {
  53278. breakBefore = root.breakBefore.children[0];
  53279. breakBeforeTarget = breakBefore.target;
  53280. } else if (root.subform.children.length >= 1 && root.subform.children[0].breakBefore.children.length >= 1) {
  53281. breakBefore = root.subform.children[0].breakBefore.children[0];
  53282. breakBeforeTarget = breakBefore.target;
  53283. } else if (root.break?.beforeTarget) {
  53284. breakBefore = root.break;
  53285. breakBeforeTarget = breakBefore.beforeTarget;
  53286. } else if (root.subform.children.length >= 1 && root.subform.children[0].break?.beforeTarget) {
  53287. breakBefore = root.subform.children[0].break;
  53288. breakBeforeTarget = breakBefore.beforeTarget;
  53289. }
  53290. if (breakBefore) {
  53291. const target = this[_symbol_utils.$searchNode](breakBeforeTarget, breakBefore[_symbol_utils.$getParent]());
  53292. if (target instanceof PageArea) {
  53293. pageArea = target;
  53294. breakBefore[_symbol_utils.$extra] = {};
  53295. }
  53296. }
  53297. if (!pageArea) {
  53298. pageArea = pageAreas[0];
  53299. }
  53300. pageArea[_symbol_utils.$extra] = {
  53301. numberOfUse: 1
  53302. };
  53303. const pageAreaParent = pageArea[_symbol_utils.$getParent]();
  53304. pageAreaParent[_symbol_utils.$extra] = {
  53305. numberOfUse: 1,
  53306. pageIndex: pageAreaParent.pageArea.children.indexOf(pageArea),
  53307. pageSetIndex: 0
  53308. };
  53309. let targetPageArea;
  53310. let leader = null;
  53311. let trailer = null;
  53312. let hasSomething = true;
  53313. let hasSomethingCounter = 0;
  53314. let startIndex = 0;
  53315. while (true) {
  53316. if (!hasSomething) {
  53317. mainHtml.children.pop();
  53318. if (++hasSomethingCounter === MAX_EMPTY_PAGES) {
  53319. (0, _util.warn)("XFA - Something goes wrong: please file a bug.");
  53320. return mainHtml;
  53321. }
  53322. } else {
  53323. hasSomethingCounter = 0;
  53324. }
  53325. targetPageArea = null;
  53326. this[_symbol_utils.$extra].currentPageArea = pageArea;
  53327. const page = pageArea[_symbol_utils.$toHTML]().html;
  53328. mainHtml.children.push(page);
  53329. if (leader) {
  53330. this[_symbol_utils.$extra].noLayoutFailure = true;
  53331. page.children.push(leader[_symbol_utils.$toHTML](pageArea[_symbol_utils.$extra].space).html);
  53332. leader = null;
  53333. }
  53334. if (trailer) {
  53335. this[_symbol_utils.$extra].noLayoutFailure = true;
  53336. page.children.push(trailer[_symbol_utils.$toHTML](pageArea[_symbol_utils.$extra].space).html);
  53337. trailer = null;
  53338. }
  53339. const contentAreas = pageArea.contentArea.children;
  53340. const htmlContentAreas = page.children.filter(node => node.attributes.class.includes("xfaContentarea"));
  53341. hasSomething = false;
  53342. this[_symbol_utils.$extra].firstUnsplittable = null;
  53343. this[_symbol_utils.$extra].noLayoutFailure = false;
  53344. const flush = index => {
  53345. const html = root[_symbol_utils.$flushHTML]();
  53346. if (html) {
  53347. hasSomething ||= html.children?.length > 0;
  53348. htmlContentAreas[index].children.push(html);
  53349. }
  53350. };
  53351. for (let i = startIndex, ii = contentAreas.length; i < ii; i++) {
  53352. const contentArea = this[_symbol_utils.$extra].currentContentArea = contentAreas[i];
  53353. const space = {
  53354. width: contentArea.w,
  53355. height: contentArea.h
  53356. };
  53357. startIndex = 0;
  53358. if (leader) {
  53359. htmlContentAreas[i].children.push(leader[_symbol_utils.$toHTML](space).html);
  53360. leader = null;
  53361. }
  53362. if (trailer) {
  53363. htmlContentAreas[i].children.push(trailer[_symbol_utils.$toHTML](space).html);
  53364. trailer = null;
  53365. }
  53366. const html = root[_symbol_utils.$toHTML](space);
  53367. if (html.success) {
  53368. if (html.html) {
  53369. hasSomething ||= html.html.children?.length > 0;
  53370. htmlContentAreas[i].children.push(html.html);
  53371. } else if (!hasSomething && mainHtml.children.length > 1) {
  53372. mainHtml.children.pop();
  53373. }
  53374. return mainHtml;
  53375. }
  53376. if (html.isBreak()) {
  53377. const node = html.breakNode;
  53378. flush(i);
  53379. if (node.targetType === "auto") {
  53380. continue;
  53381. }
  53382. if (node.leader) {
  53383. leader = this[_symbol_utils.$searchNode](node.leader, node[_symbol_utils.$getParent]());
  53384. leader = leader ? leader[0] : null;
  53385. }
  53386. if (node.trailer) {
  53387. trailer = this[_symbol_utils.$searchNode](node.trailer, node[_symbol_utils.$getParent]());
  53388. trailer = trailer ? trailer[0] : null;
  53389. }
  53390. if (node.targetType === "pageArea") {
  53391. targetPageArea = node[_symbol_utils.$extra].target;
  53392. i = Infinity;
  53393. } else if (!node[_symbol_utils.$extra].target) {
  53394. i = node[_symbol_utils.$extra].index;
  53395. } else {
  53396. targetPageArea = node[_symbol_utils.$extra].target;
  53397. startIndex = node[_symbol_utils.$extra].index + 1;
  53398. i = Infinity;
  53399. }
  53400. continue;
  53401. }
  53402. if (this[_symbol_utils.$extra].overflowNode) {
  53403. const node = this[_symbol_utils.$extra].overflowNode;
  53404. this[_symbol_utils.$extra].overflowNode = null;
  53405. const overflowExtra = node[_symbol_utils.$getExtra]();
  53406. const target = overflowExtra.target;
  53407. overflowExtra.addLeader = overflowExtra.leader !== null;
  53408. overflowExtra.addTrailer = overflowExtra.trailer !== null;
  53409. flush(i);
  53410. const currentIndex = i;
  53411. i = Infinity;
  53412. if (target instanceof PageArea) {
  53413. targetPageArea = target;
  53414. } else if (target instanceof ContentArea) {
  53415. const index = contentAreas.indexOf(target);
  53416. if (index !== -1) {
  53417. if (index > currentIndex) {
  53418. i = index - 1;
  53419. } else {
  53420. startIndex = index;
  53421. }
  53422. } else {
  53423. targetPageArea = target[_symbol_utils.$getParent]();
  53424. startIndex = targetPageArea.contentArea.children.indexOf(target);
  53425. }
  53426. }
  53427. continue;
  53428. }
  53429. flush(i);
  53430. }
  53431. this[_symbol_utils.$extra].pageNumber += 1;
  53432. if (targetPageArea) {
  53433. if (targetPageArea[_symbol_utils.$isUsable]()) {
  53434. targetPageArea[_symbol_utils.$extra].numberOfUse += 1;
  53435. } else {
  53436. targetPageArea = null;
  53437. }
  53438. }
  53439. pageArea = targetPageArea || pageArea[_symbol_utils.$getNextPage]();
  53440. yield null;
  53441. }
  53442. }
  53443. }
  53444. exports.Template = Template;
  53445. class Text extends _xfa_object.ContentObject {
  53446. constructor(attributes) {
  53447. super(TEMPLATE_NS_ID, "text");
  53448. this.id = attributes.id || "";
  53449. this.maxChars = (0, _utils.getInteger)({
  53450. data: attributes.maxChars,
  53451. defaultValue: 0,
  53452. validate: x => x >= 0
  53453. });
  53454. this.name = attributes.name || "";
  53455. this.rid = attributes.rid || "";
  53456. this.use = attributes.use || "";
  53457. this.usehref = attributes.usehref || "";
  53458. }
  53459. [_symbol_utils.$acceptWhitespace]() {
  53460. return true;
  53461. }
  53462. [_symbol_utils.$onChild](child) {
  53463. if (child[_symbol_utils.$namespaceId] === _namespaces.NamespaceIds.xhtml.id) {
  53464. this[_symbol_utils.$content] = child;
  53465. return true;
  53466. }
  53467. (0, _util.warn)(`XFA - Invalid content in Text: ${child[_symbol_utils.$nodeName]}.`);
  53468. return false;
  53469. }
  53470. [_symbol_utils.$onText](str) {
  53471. if (this[_symbol_utils.$content] instanceof _xfa_object.XFAObject) {
  53472. return;
  53473. }
  53474. super[_symbol_utils.$onText](str);
  53475. }
  53476. [_symbol_utils.$finalize]() {
  53477. if (typeof this[_symbol_utils.$content] === "string") {
  53478. this[_symbol_utils.$content] = this[_symbol_utils.$content].replaceAll("\r\n", "\n");
  53479. }
  53480. }
  53481. [_symbol_utils.$getExtra]() {
  53482. if (typeof this[_symbol_utils.$content] === "string") {
  53483. return this[_symbol_utils.$content].split(/[\u2029\u2028\n]/).reduce((acc, line) => {
  53484. if (line) {
  53485. acc.push(line);
  53486. }
  53487. return acc;
  53488. }, []).join("\n");
  53489. }
  53490. return this[_symbol_utils.$content][_symbol_utils.$text]();
  53491. }
  53492. [_symbol_utils.$toHTML](availableSpace) {
  53493. if (typeof this[_symbol_utils.$content] === "string") {
  53494. const html = valueToHtml(this[_symbol_utils.$content]).html;
  53495. if (this[_symbol_utils.$content].includes("\u2029")) {
  53496. html.name = "div";
  53497. html.children = [];
  53498. this[_symbol_utils.$content].split("\u2029").map(para => para.split(/[\u2028\n]/).reduce((acc, line) => {
  53499. acc.push({
  53500. name: "span",
  53501. value: line
  53502. }, {
  53503. name: "br"
  53504. });
  53505. return acc;
  53506. }, [])).forEach(lines => {
  53507. html.children.push({
  53508. name: "p",
  53509. children: lines
  53510. });
  53511. });
  53512. } else if (/[\u2028\n]/.test(this[_symbol_utils.$content])) {
  53513. html.name = "div";
  53514. html.children = [];
  53515. this[_symbol_utils.$content].split(/[\u2028\n]/).forEach(line => {
  53516. html.children.push({
  53517. name: "span",
  53518. value: line
  53519. }, {
  53520. name: "br"
  53521. });
  53522. });
  53523. }
  53524. return _utils.HTMLResult.success(html);
  53525. }
  53526. return this[_symbol_utils.$content][_symbol_utils.$toHTML](availableSpace);
  53527. }
  53528. }
  53529. exports.Text = Text;
  53530. class TextEdit extends _xfa_object.XFAObject {
  53531. constructor(attributes) {
  53532. super(TEMPLATE_NS_ID, "textEdit", true);
  53533. this.allowRichText = (0, _utils.getInteger)({
  53534. data: attributes.allowRichText,
  53535. defaultValue: 0,
  53536. validate: x => x === 1
  53537. });
  53538. this.hScrollPolicy = (0, _utils.getStringOption)(attributes.hScrollPolicy, ["auto", "off", "on"]);
  53539. this.id = attributes.id || "";
  53540. this.multiLine = (0, _utils.getInteger)({
  53541. data: attributes.multiLine,
  53542. defaultValue: "",
  53543. validate: x => x === 0 || x === 1
  53544. });
  53545. this.use = attributes.use || "";
  53546. this.usehref = attributes.usehref || "";
  53547. this.vScrollPolicy = (0, _utils.getStringOption)(attributes.vScrollPolicy, ["auto", "off", "on"]);
  53548. this.border = null;
  53549. this.comb = null;
  53550. this.extras = null;
  53551. this.margin = null;
  53552. }
  53553. [_symbol_utils.$toHTML](availableSpace) {
  53554. const style = (0, _html_utils.toStyle)(this, "border", "font", "margin");
  53555. let html;
  53556. const field = this[_symbol_utils.$getParent]()[_symbol_utils.$getParent]();
  53557. if (this.multiLine === "") {
  53558. this.multiLine = field instanceof Draw ? 1 : 0;
  53559. }
  53560. if (this.multiLine === 1) {
  53561. html = {
  53562. name: "textarea",
  53563. attributes: {
  53564. dataId: field[_symbol_utils.$data]?.[_symbol_utils.$uid] || field[_symbol_utils.$uid],
  53565. fieldId: field[_symbol_utils.$uid],
  53566. class: ["xfaTextfield"],
  53567. style,
  53568. "aria-label": ariaLabel(field),
  53569. "aria-required": false
  53570. }
  53571. };
  53572. } else {
  53573. html = {
  53574. name: "input",
  53575. attributes: {
  53576. type: "text",
  53577. dataId: field[_symbol_utils.$data]?.[_symbol_utils.$uid] || field[_symbol_utils.$uid],
  53578. fieldId: field[_symbol_utils.$uid],
  53579. class: ["xfaTextfield"],
  53580. style,
  53581. "aria-label": ariaLabel(field),
  53582. "aria-required": false
  53583. }
  53584. };
  53585. }
  53586. if (isRequired(field)) {
  53587. html.attributes["aria-required"] = true;
  53588. html.attributes.required = true;
  53589. }
  53590. return _utils.HTMLResult.success({
  53591. name: "label",
  53592. attributes: {
  53593. class: ["xfaLabel"]
  53594. },
  53595. children: [html]
  53596. });
  53597. }
  53598. }
  53599. class Time extends _xfa_object.StringObject {
  53600. constructor(attributes) {
  53601. super(TEMPLATE_NS_ID, "time");
  53602. this.id = attributes.id || "";
  53603. this.name = attributes.name || "";
  53604. this.use = attributes.use || "";
  53605. this.usehref = attributes.usehref || "";
  53606. }
  53607. [_symbol_utils.$finalize]() {
  53608. const date = this[_symbol_utils.$content].trim();
  53609. this[_symbol_utils.$content] = date ? new Date(date) : null;
  53610. }
  53611. [_symbol_utils.$toHTML](availableSpace) {
  53612. return valueToHtml(this[_symbol_utils.$content] ? this[_symbol_utils.$content].toString() : "");
  53613. }
  53614. }
  53615. class TimeStamp extends _xfa_object.XFAObject {
  53616. constructor(attributes) {
  53617. super(TEMPLATE_NS_ID, "timeStamp");
  53618. this.id = attributes.id || "";
  53619. this.server = attributes.server || "";
  53620. this.type = (0, _utils.getStringOption)(attributes.type, ["optional", "required"]);
  53621. this.use = attributes.use || "";
  53622. this.usehref = attributes.usehref || "";
  53623. }
  53624. }
  53625. class ToolTip extends _xfa_object.StringObject {
  53626. constructor(attributes) {
  53627. super(TEMPLATE_NS_ID, "toolTip");
  53628. this.id = attributes.id || "";
  53629. this.rid = attributes.rid || "";
  53630. this.use = attributes.use || "";
  53631. this.usehref = attributes.usehref || "";
  53632. }
  53633. }
  53634. class Traversal extends _xfa_object.XFAObject {
  53635. constructor(attributes) {
  53636. super(TEMPLATE_NS_ID, "traversal", true);
  53637. this.id = attributes.id || "";
  53638. this.use = attributes.use || "";
  53639. this.usehref = attributes.usehref || "";
  53640. this.extras = null;
  53641. this.traverse = new _xfa_object.XFAObjectArray();
  53642. }
  53643. }
  53644. class Traverse extends _xfa_object.XFAObject {
  53645. constructor(attributes) {
  53646. super(TEMPLATE_NS_ID, "traverse", true);
  53647. this.id = attributes.id || "";
  53648. this.operation = (0, _utils.getStringOption)(attributes.operation, ["next", "back", "down", "first", "left", "right", "up"]);
  53649. this.ref = attributes.ref || "";
  53650. this.use = attributes.use || "";
  53651. this.usehref = attributes.usehref || "";
  53652. this.extras = null;
  53653. this.script = null;
  53654. }
  53655. get name() {
  53656. return this.operation;
  53657. }
  53658. [_symbol_utils.$isTransparent]() {
  53659. return false;
  53660. }
  53661. }
  53662. class Ui extends _xfa_object.XFAObject {
  53663. constructor(attributes) {
  53664. super(TEMPLATE_NS_ID, "ui", true);
  53665. this.id = attributes.id || "";
  53666. this.use = attributes.use || "";
  53667. this.usehref = attributes.usehref || "";
  53668. this.extras = null;
  53669. this.picture = null;
  53670. this.barcode = null;
  53671. this.button = null;
  53672. this.checkButton = null;
  53673. this.choiceList = null;
  53674. this.dateTimeEdit = null;
  53675. this.defaultUi = null;
  53676. this.imageEdit = null;
  53677. this.numericEdit = null;
  53678. this.passwordEdit = null;
  53679. this.signature = null;
  53680. this.textEdit = null;
  53681. }
  53682. [_symbol_utils.$getExtra]() {
  53683. if (this[_symbol_utils.$extra] === undefined) {
  53684. for (const name of Object.getOwnPropertyNames(this)) {
  53685. if (name === "extras" || name === "picture") {
  53686. continue;
  53687. }
  53688. const obj = this[name];
  53689. if (!(obj instanceof _xfa_object.XFAObject)) {
  53690. continue;
  53691. }
  53692. this[_symbol_utils.$extra] = obj;
  53693. return obj;
  53694. }
  53695. this[_symbol_utils.$extra] = null;
  53696. }
  53697. return this[_symbol_utils.$extra];
  53698. }
  53699. [_symbol_utils.$toHTML](availableSpace) {
  53700. const obj = this[_symbol_utils.$getExtra]();
  53701. if (obj) {
  53702. return obj[_symbol_utils.$toHTML](availableSpace);
  53703. }
  53704. return _utils.HTMLResult.EMPTY;
  53705. }
  53706. }
  53707. class Validate extends _xfa_object.XFAObject {
  53708. constructor(attributes) {
  53709. super(TEMPLATE_NS_ID, "validate", true);
  53710. this.formatTest = (0, _utils.getStringOption)(attributes.formatTest, ["warning", "disabled", "error"]);
  53711. this.id = attributes.id || "";
  53712. this.nullTest = (0, _utils.getStringOption)(attributes.nullTest, ["disabled", "error", "warning"]);
  53713. this.scriptTest = (0, _utils.getStringOption)(attributes.scriptTest, ["error", "disabled", "warning"]);
  53714. this.use = attributes.use || "";
  53715. this.usehref = attributes.usehref || "";
  53716. this.extras = null;
  53717. this.message = null;
  53718. this.picture = null;
  53719. this.script = null;
  53720. }
  53721. }
  53722. class Value extends _xfa_object.XFAObject {
  53723. constructor(attributes) {
  53724. super(TEMPLATE_NS_ID, "value", true);
  53725. this.id = attributes.id || "";
  53726. this.override = (0, _utils.getInteger)({
  53727. data: attributes.override,
  53728. defaultValue: 0,
  53729. validate: x => x === 1
  53730. });
  53731. this.relevant = (0, _utils.getRelevant)(attributes.relevant);
  53732. this.use = attributes.use || "";
  53733. this.usehref = attributes.usehref || "";
  53734. this.arc = null;
  53735. this.boolean = null;
  53736. this.date = null;
  53737. this.dateTime = null;
  53738. this.decimal = null;
  53739. this.exData = null;
  53740. this.float = null;
  53741. this.image = null;
  53742. this.integer = null;
  53743. this.line = null;
  53744. this.rectangle = null;
  53745. this.text = null;
  53746. this.time = null;
  53747. }
  53748. [_symbol_utils.$setValue](value) {
  53749. const parent = this[_symbol_utils.$getParent]();
  53750. if (parent instanceof Field) {
  53751. if (parent.ui?.imageEdit) {
  53752. if (!this.image) {
  53753. this.image = new Image({});
  53754. this[_symbol_utils.$appendChild](this.image);
  53755. }
  53756. this.image[_symbol_utils.$content] = value[_symbol_utils.$content];
  53757. return;
  53758. }
  53759. }
  53760. const valueName = value[_symbol_utils.$nodeName];
  53761. if (this[valueName] !== null) {
  53762. this[valueName][_symbol_utils.$content] = value[_symbol_utils.$content];
  53763. return;
  53764. }
  53765. for (const name of Object.getOwnPropertyNames(this)) {
  53766. const obj = this[name];
  53767. if (obj instanceof _xfa_object.XFAObject) {
  53768. this[name] = null;
  53769. this[_symbol_utils.$removeChild](obj);
  53770. }
  53771. }
  53772. this[value[_symbol_utils.$nodeName]] = value;
  53773. this[_symbol_utils.$appendChild](value);
  53774. }
  53775. [_symbol_utils.$text]() {
  53776. if (this.exData) {
  53777. if (typeof this.exData[_symbol_utils.$content] === "string") {
  53778. return this.exData[_symbol_utils.$content].trim();
  53779. }
  53780. return this.exData[_symbol_utils.$content][_symbol_utils.$text]().trim();
  53781. }
  53782. for (const name of Object.getOwnPropertyNames(this)) {
  53783. if (name === "image") {
  53784. continue;
  53785. }
  53786. const obj = this[name];
  53787. if (obj instanceof _xfa_object.XFAObject) {
  53788. return (obj[_symbol_utils.$content] || "").toString().trim();
  53789. }
  53790. }
  53791. return null;
  53792. }
  53793. [_symbol_utils.$toHTML](availableSpace) {
  53794. for (const name of Object.getOwnPropertyNames(this)) {
  53795. const obj = this[name];
  53796. if (!(obj instanceof _xfa_object.XFAObject)) {
  53797. continue;
  53798. }
  53799. return obj[_symbol_utils.$toHTML](availableSpace);
  53800. }
  53801. return _utils.HTMLResult.EMPTY;
  53802. }
  53803. }
  53804. exports.Value = Value;
  53805. class Variables extends _xfa_object.XFAObject {
  53806. constructor(attributes) {
  53807. super(TEMPLATE_NS_ID, "variables", true);
  53808. this.id = attributes.id || "";
  53809. this.use = attributes.use || "";
  53810. this.usehref = attributes.usehref || "";
  53811. this.boolean = new _xfa_object.XFAObjectArray();
  53812. this.date = new _xfa_object.XFAObjectArray();
  53813. this.dateTime = new _xfa_object.XFAObjectArray();
  53814. this.decimal = new _xfa_object.XFAObjectArray();
  53815. this.exData = new _xfa_object.XFAObjectArray();
  53816. this.float = new _xfa_object.XFAObjectArray();
  53817. this.image = new _xfa_object.XFAObjectArray();
  53818. this.integer = new _xfa_object.XFAObjectArray();
  53819. this.manifest = new _xfa_object.XFAObjectArray();
  53820. this.script = new _xfa_object.XFAObjectArray();
  53821. this.text = new _xfa_object.XFAObjectArray();
  53822. this.time = new _xfa_object.XFAObjectArray();
  53823. }
  53824. [_symbol_utils.$isTransparent]() {
  53825. return true;
  53826. }
  53827. }
  53828. class TemplateNamespace {
  53829. static [_namespaces.$buildXFAObject](name, attributes) {
  53830. if (TemplateNamespace.hasOwnProperty(name)) {
  53831. const node = TemplateNamespace[name](attributes);
  53832. node[_symbol_utils.$setSetAttributes](attributes);
  53833. return node;
  53834. }
  53835. return undefined;
  53836. }
  53837. static appearanceFilter(attrs) {
  53838. return new AppearanceFilter(attrs);
  53839. }
  53840. static arc(attrs) {
  53841. return new Arc(attrs);
  53842. }
  53843. static area(attrs) {
  53844. return new Area(attrs);
  53845. }
  53846. static assist(attrs) {
  53847. return new Assist(attrs);
  53848. }
  53849. static barcode(attrs) {
  53850. return new Barcode(attrs);
  53851. }
  53852. static bind(attrs) {
  53853. return new Bind(attrs);
  53854. }
  53855. static bindItems(attrs) {
  53856. return new BindItems(attrs);
  53857. }
  53858. static bookend(attrs) {
  53859. return new Bookend(attrs);
  53860. }
  53861. static boolean(attrs) {
  53862. return new BooleanElement(attrs);
  53863. }
  53864. static border(attrs) {
  53865. return new Border(attrs);
  53866. }
  53867. static break(attrs) {
  53868. return new Break(attrs);
  53869. }
  53870. static breakAfter(attrs) {
  53871. return new BreakAfter(attrs);
  53872. }
  53873. static breakBefore(attrs) {
  53874. return new BreakBefore(attrs);
  53875. }
  53876. static button(attrs) {
  53877. return new Button(attrs);
  53878. }
  53879. static calculate(attrs) {
  53880. return new Calculate(attrs);
  53881. }
  53882. static caption(attrs) {
  53883. return new Caption(attrs);
  53884. }
  53885. static certificate(attrs) {
  53886. return new Certificate(attrs);
  53887. }
  53888. static certificates(attrs) {
  53889. return new Certificates(attrs);
  53890. }
  53891. static checkButton(attrs) {
  53892. return new CheckButton(attrs);
  53893. }
  53894. static choiceList(attrs) {
  53895. return new ChoiceList(attrs);
  53896. }
  53897. static color(attrs) {
  53898. return new Color(attrs);
  53899. }
  53900. static comb(attrs) {
  53901. return new Comb(attrs);
  53902. }
  53903. static connect(attrs) {
  53904. return new Connect(attrs);
  53905. }
  53906. static contentArea(attrs) {
  53907. return new ContentArea(attrs);
  53908. }
  53909. static corner(attrs) {
  53910. return new Corner(attrs);
  53911. }
  53912. static date(attrs) {
  53913. return new DateElement(attrs);
  53914. }
  53915. static dateTime(attrs) {
  53916. return new DateTime(attrs);
  53917. }
  53918. static dateTimeEdit(attrs) {
  53919. return new DateTimeEdit(attrs);
  53920. }
  53921. static decimal(attrs) {
  53922. return new Decimal(attrs);
  53923. }
  53924. static defaultUi(attrs) {
  53925. return new DefaultUi(attrs);
  53926. }
  53927. static desc(attrs) {
  53928. return new Desc(attrs);
  53929. }
  53930. static digestMethod(attrs) {
  53931. return new DigestMethod(attrs);
  53932. }
  53933. static digestMethods(attrs) {
  53934. return new DigestMethods(attrs);
  53935. }
  53936. static draw(attrs) {
  53937. return new Draw(attrs);
  53938. }
  53939. static edge(attrs) {
  53940. return new Edge(attrs);
  53941. }
  53942. static encoding(attrs) {
  53943. return new Encoding(attrs);
  53944. }
  53945. static encodings(attrs) {
  53946. return new Encodings(attrs);
  53947. }
  53948. static encrypt(attrs) {
  53949. return new Encrypt(attrs);
  53950. }
  53951. static encryptData(attrs) {
  53952. return new EncryptData(attrs);
  53953. }
  53954. static encryption(attrs) {
  53955. return new Encryption(attrs);
  53956. }
  53957. static encryptionMethod(attrs) {
  53958. return new EncryptionMethod(attrs);
  53959. }
  53960. static encryptionMethods(attrs) {
  53961. return new EncryptionMethods(attrs);
  53962. }
  53963. static event(attrs) {
  53964. return new Event(attrs);
  53965. }
  53966. static exData(attrs) {
  53967. return new ExData(attrs);
  53968. }
  53969. static exObject(attrs) {
  53970. return new ExObject(attrs);
  53971. }
  53972. static exclGroup(attrs) {
  53973. return new ExclGroup(attrs);
  53974. }
  53975. static execute(attrs) {
  53976. return new Execute(attrs);
  53977. }
  53978. static extras(attrs) {
  53979. return new Extras(attrs);
  53980. }
  53981. static field(attrs) {
  53982. return new Field(attrs);
  53983. }
  53984. static fill(attrs) {
  53985. return new Fill(attrs);
  53986. }
  53987. static filter(attrs) {
  53988. return new Filter(attrs);
  53989. }
  53990. static float(attrs) {
  53991. return new Float(attrs);
  53992. }
  53993. static font(attrs) {
  53994. return new Font(attrs);
  53995. }
  53996. static format(attrs) {
  53997. return new Format(attrs);
  53998. }
  53999. static handler(attrs) {
  54000. return new Handler(attrs);
  54001. }
  54002. static hyphenation(attrs) {
  54003. return new Hyphenation(attrs);
  54004. }
  54005. static image(attrs) {
  54006. return new Image(attrs);
  54007. }
  54008. static imageEdit(attrs) {
  54009. return new ImageEdit(attrs);
  54010. }
  54011. static integer(attrs) {
  54012. return new Integer(attrs);
  54013. }
  54014. static issuers(attrs) {
  54015. return new Issuers(attrs);
  54016. }
  54017. static items(attrs) {
  54018. return new Items(attrs);
  54019. }
  54020. static keep(attrs) {
  54021. return new Keep(attrs);
  54022. }
  54023. static keyUsage(attrs) {
  54024. return new KeyUsage(attrs);
  54025. }
  54026. static line(attrs) {
  54027. return new Line(attrs);
  54028. }
  54029. static linear(attrs) {
  54030. return new Linear(attrs);
  54031. }
  54032. static lockDocument(attrs) {
  54033. return new LockDocument(attrs);
  54034. }
  54035. static manifest(attrs) {
  54036. return new Manifest(attrs);
  54037. }
  54038. static margin(attrs) {
  54039. return new Margin(attrs);
  54040. }
  54041. static mdp(attrs) {
  54042. return new Mdp(attrs);
  54043. }
  54044. static medium(attrs) {
  54045. return new Medium(attrs);
  54046. }
  54047. static message(attrs) {
  54048. return new Message(attrs);
  54049. }
  54050. static numericEdit(attrs) {
  54051. return new NumericEdit(attrs);
  54052. }
  54053. static occur(attrs) {
  54054. return new Occur(attrs);
  54055. }
  54056. static oid(attrs) {
  54057. return new Oid(attrs);
  54058. }
  54059. static oids(attrs) {
  54060. return new Oids(attrs);
  54061. }
  54062. static overflow(attrs) {
  54063. return new Overflow(attrs);
  54064. }
  54065. static pageArea(attrs) {
  54066. return new PageArea(attrs);
  54067. }
  54068. static pageSet(attrs) {
  54069. return new PageSet(attrs);
  54070. }
  54071. static para(attrs) {
  54072. return new Para(attrs);
  54073. }
  54074. static passwordEdit(attrs) {
  54075. return new PasswordEdit(attrs);
  54076. }
  54077. static pattern(attrs) {
  54078. return new Pattern(attrs);
  54079. }
  54080. static picture(attrs) {
  54081. return new Picture(attrs);
  54082. }
  54083. static proto(attrs) {
  54084. return new Proto(attrs);
  54085. }
  54086. static radial(attrs) {
  54087. return new Radial(attrs);
  54088. }
  54089. static reason(attrs) {
  54090. return new Reason(attrs);
  54091. }
  54092. static reasons(attrs) {
  54093. return new Reasons(attrs);
  54094. }
  54095. static rectangle(attrs) {
  54096. return new Rectangle(attrs);
  54097. }
  54098. static ref(attrs) {
  54099. return new RefElement(attrs);
  54100. }
  54101. static script(attrs) {
  54102. return new Script(attrs);
  54103. }
  54104. static setProperty(attrs) {
  54105. return new SetProperty(attrs);
  54106. }
  54107. static signData(attrs) {
  54108. return new SignData(attrs);
  54109. }
  54110. static signature(attrs) {
  54111. return new Signature(attrs);
  54112. }
  54113. static signing(attrs) {
  54114. return new Signing(attrs);
  54115. }
  54116. static solid(attrs) {
  54117. return new Solid(attrs);
  54118. }
  54119. static speak(attrs) {
  54120. return new Speak(attrs);
  54121. }
  54122. static stipple(attrs) {
  54123. return new Stipple(attrs);
  54124. }
  54125. static subform(attrs) {
  54126. return new Subform(attrs);
  54127. }
  54128. static subformSet(attrs) {
  54129. return new SubformSet(attrs);
  54130. }
  54131. static subjectDN(attrs) {
  54132. return new SubjectDN(attrs);
  54133. }
  54134. static subjectDNs(attrs) {
  54135. return new SubjectDNs(attrs);
  54136. }
  54137. static submit(attrs) {
  54138. return new Submit(attrs);
  54139. }
  54140. static template(attrs) {
  54141. return new Template(attrs);
  54142. }
  54143. static text(attrs) {
  54144. return new Text(attrs);
  54145. }
  54146. static textEdit(attrs) {
  54147. return new TextEdit(attrs);
  54148. }
  54149. static time(attrs) {
  54150. return new Time(attrs);
  54151. }
  54152. static timeStamp(attrs) {
  54153. return new TimeStamp(attrs);
  54154. }
  54155. static toolTip(attrs) {
  54156. return new ToolTip(attrs);
  54157. }
  54158. static traversal(attrs) {
  54159. return new Traversal(attrs);
  54160. }
  54161. static traverse(attrs) {
  54162. return new Traverse(attrs);
  54163. }
  54164. static ui(attrs) {
  54165. return new Ui(attrs);
  54166. }
  54167. static validate(attrs) {
  54168. return new Validate(attrs);
  54169. }
  54170. static value(attrs) {
  54171. return new Value(attrs);
  54172. }
  54173. static variables(attrs) {
  54174. return new Variables(attrs);
  54175. }
  54176. }
  54177. exports.TemplateNamespace = TemplateNamespace;
  54178. /***/ }),
  54179. /* 232 */
  54180. /***/ ((__unused_webpack_module, __unused_webpack_exports, __w_pdfjs_require__) => {
  54181. var $ = __w_pdfjs_require__(3);
  54182. var global = __w_pdfjs_require__(4);
  54183. var getBuiltIn = __w_pdfjs_require__(24);
  54184. var createPropertyDescriptor = __w_pdfjs_require__(11);
  54185. var defineProperty = (__w_pdfjs_require__(45).f);
  54186. var hasOwn = __w_pdfjs_require__(39);
  54187. var anInstance = __w_pdfjs_require__(233);
  54188. var inheritIfRequired = __w_pdfjs_require__(75);
  54189. var normalizeStringArgument = __w_pdfjs_require__(76);
  54190. var DOMExceptionConstants = __w_pdfjs_require__(234);
  54191. var clearErrorStack = __w_pdfjs_require__(82);
  54192. var DESCRIPTORS = __w_pdfjs_require__(6);
  54193. var IS_PURE = __w_pdfjs_require__(36);
  54194. var DOM_EXCEPTION = 'DOMException';
  54195. var Error = getBuiltIn('Error');
  54196. var NativeDOMException = getBuiltIn(DOM_EXCEPTION);
  54197. var $DOMException = function DOMException() {
  54198. anInstance(this, DOMExceptionPrototype);
  54199. var argumentsLength = arguments.length;
  54200. var message = normalizeStringArgument(argumentsLength < 1 ? undefined : arguments[0]);
  54201. var name = normalizeStringArgument(argumentsLength < 2 ? undefined : arguments[1], 'Error');
  54202. var that = new NativeDOMException(message, name);
  54203. var error = Error(message);
  54204. error.name = DOM_EXCEPTION;
  54205. defineProperty(that, 'stack', createPropertyDescriptor(1, clearErrorStack(error.stack, 1)));
  54206. inheritIfRequired(that, this, $DOMException);
  54207. return that;
  54208. };
  54209. var DOMExceptionPrototype = $DOMException.prototype = NativeDOMException.prototype;
  54210. var ERROR_HAS_STACK = 'stack' in Error(DOM_EXCEPTION);
  54211. var DOM_EXCEPTION_HAS_STACK = 'stack' in new NativeDOMException(1, 2);
  54212. var descriptor = NativeDOMException && DESCRIPTORS && Object.getOwnPropertyDescriptor(global, DOM_EXCEPTION);
  54213. var BUGGY_DESCRIPTOR = !!descriptor && !(descriptor.writable && descriptor.configurable);
  54214. var FORCED_CONSTRUCTOR = ERROR_HAS_STACK && !BUGGY_DESCRIPTOR && !DOM_EXCEPTION_HAS_STACK;
  54215. $({
  54216. global: true,
  54217. constructor: true,
  54218. forced: IS_PURE || FORCED_CONSTRUCTOR
  54219. }, { DOMException: FORCED_CONSTRUCTOR ? $DOMException : NativeDOMException });
  54220. var PolyfilledDOMException = getBuiltIn(DOM_EXCEPTION);
  54221. var PolyfilledDOMExceptionPrototype = PolyfilledDOMException.prototype;
  54222. if (PolyfilledDOMExceptionPrototype.constructor !== PolyfilledDOMException) {
  54223. if (!IS_PURE) {
  54224. defineProperty(PolyfilledDOMExceptionPrototype, 'constructor', createPropertyDescriptor(1, PolyfilledDOMException));
  54225. }
  54226. for (var key in DOMExceptionConstants)
  54227. if (hasOwn(DOMExceptionConstants, key)) {
  54228. var constant = DOMExceptionConstants[key];
  54229. var constantName = constant.s;
  54230. if (!hasOwn(PolyfilledDOMException, constantName)) {
  54231. defineProperty(PolyfilledDOMException, constantName, createPropertyDescriptor(6, constant.c));
  54232. }
  54233. }
  54234. }
  54235. /***/ }),
  54236. /* 233 */
  54237. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  54238. var isPrototypeOf = __w_pdfjs_require__(25);
  54239. var $TypeError = TypeError;
  54240. module.exports = function (it, Prototype) {
  54241. if (isPrototypeOf(Prototype, it))
  54242. return it;
  54243. throw $TypeError('Incorrect invocation');
  54244. };
  54245. /***/ }),
  54246. /* 234 */
  54247. /***/ ((module) => {
  54248. module.exports = {
  54249. IndexSizeError: {
  54250. s: 'INDEX_SIZE_ERR',
  54251. c: 1,
  54252. m: 1
  54253. },
  54254. DOMStringSizeError: {
  54255. s: 'DOMSTRING_SIZE_ERR',
  54256. c: 2,
  54257. m: 0
  54258. },
  54259. HierarchyRequestError: {
  54260. s: 'HIERARCHY_REQUEST_ERR',
  54261. c: 3,
  54262. m: 1
  54263. },
  54264. WrongDocumentError: {
  54265. s: 'WRONG_DOCUMENT_ERR',
  54266. c: 4,
  54267. m: 1
  54268. },
  54269. InvalidCharacterError: {
  54270. s: 'INVALID_CHARACTER_ERR',
  54271. c: 5,
  54272. m: 1
  54273. },
  54274. NoDataAllowedError: {
  54275. s: 'NO_DATA_ALLOWED_ERR',
  54276. c: 6,
  54277. m: 0
  54278. },
  54279. NoModificationAllowedError: {
  54280. s: 'NO_MODIFICATION_ALLOWED_ERR',
  54281. c: 7,
  54282. m: 1
  54283. },
  54284. NotFoundError: {
  54285. s: 'NOT_FOUND_ERR',
  54286. c: 8,
  54287. m: 1
  54288. },
  54289. NotSupportedError: {
  54290. s: 'NOT_SUPPORTED_ERR',
  54291. c: 9,
  54292. m: 1
  54293. },
  54294. InUseAttributeError: {
  54295. s: 'INUSE_ATTRIBUTE_ERR',
  54296. c: 10,
  54297. m: 1
  54298. },
  54299. InvalidStateError: {
  54300. s: 'INVALID_STATE_ERR',
  54301. c: 11,
  54302. m: 1
  54303. },
  54304. SyntaxError: {
  54305. s: 'SYNTAX_ERR',
  54306. c: 12,
  54307. m: 1
  54308. },
  54309. InvalidModificationError: {
  54310. s: 'INVALID_MODIFICATION_ERR',
  54311. c: 13,
  54312. m: 1
  54313. },
  54314. NamespaceError: {
  54315. s: 'NAMESPACE_ERR',
  54316. c: 14,
  54317. m: 1
  54318. },
  54319. InvalidAccessError: {
  54320. s: 'INVALID_ACCESS_ERR',
  54321. c: 15,
  54322. m: 1
  54323. },
  54324. ValidationError: {
  54325. s: 'VALIDATION_ERR',
  54326. c: 16,
  54327. m: 0
  54328. },
  54329. TypeMismatchError: {
  54330. s: 'TYPE_MISMATCH_ERR',
  54331. c: 17,
  54332. m: 1
  54333. },
  54334. SecurityError: {
  54335. s: 'SECURITY_ERR',
  54336. c: 18,
  54337. m: 1
  54338. },
  54339. NetworkError: {
  54340. s: 'NETWORK_ERR',
  54341. c: 19,
  54342. m: 1
  54343. },
  54344. AbortError: {
  54345. s: 'ABORT_ERR',
  54346. c: 20,
  54347. m: 1
  54348. },
  54349. URLMismatchError: {
  54350. s: 'URL_MISMATCH_ERR',
  54351. c: 21,
  54352. m: 1
  54353. },
  54354. QuotaExceededError: {
  54355. s: 'QUOTA_EXCEEDED_ERR',
  54356. c: 22,
  54357. m: 1
  54358. },
  54359. TimeoutError: {
  54360. s: 'TIMEOUT_ERR',
  54361. c: 23,
  54362. m: 1
  54363. },
  54364. InvalidNodeTypeError: {
  54365. s: 'INVALID_NODE_TYPE_ERR',
  54366. c: 24,
  54367. m: 1
  54368. },
  54369. DataCloneError: {
  54370. s: 'DATA_CLONE_ERR',
  54371. c: 25,
  54372. m: 1
  54373. }
  54374. };
  54375. /***/ }),
  54376. /* 235 */
  54377. /***/ ((__unused_webpack_module, exports) => {
  54378. Object.defineProperty(exports, "__esModule", ({
  54379. value: true
  54380. }));
  54381. exports.NamespaceIds = exports.$buildXFAObject = void 0;
  54382. const $buildXFAObject = Symbol();
  54383. exports.$buildXFAObject = $buildXFAObject;
  54384. const NamespaceIds = {
  54385. config: {
  54386. id: 0,
  54387. check: ns => ns.startsWith("http://www.xfa.org/schema/xci/")
  54388. },
  54389. connectionSet: {
  54390. id: 1,
  54391. check: ns => ns.startsWith("http://www.xfa.org/schema/xfa-connection-set/")
  54392. },
  54393. datasets: {
  54394. id: 2,
  54395. check: ns => ns.startsWith("http://www.xfa.org/schema/xfa-data/")
  54396. },
  54397. form: {
  54398. id: 3,
  54399. check: ns => ns.startsWith("http://www.xfa.org/schema/xfa-form/")
  54400. },
  54401. localeSet: {
  54402. id: 4,
  54403. check: ns => ns.startsWith("http://www.xfa.org/schema/xfa-locale-set/")
  54404. },
  54405. pdf: {
  54406. id: 5,
  54407. check: ns => ns === "http://ns.adobe.com/xdp/pdf/"
  54408. },
  54409. signature: {
  54410. id: 6,
  54411. check: ns => ns === "http://www.w3.org/2000/09/xmldsig#"
  54412. },
  54413. sourceSet: {
  54414. id: 7,
  54415. check: ns => ns.startsWith("http://www.xfa.org/schema/xfa-source-set/")
  54416. },
  54417. stylesheet: {
  54418. id: 8,
  54419. check: ns => ns === "http://www.w3.org/1999/XSL/Transform"
  54420. },
  54421. template: {
  54422. id: 9,
  54423. check: ns => ns.startsWith("http://www.xfa.org/schema/xfa-template/")
  54424. },
  54425. xdc: {
  54426. id: 10,
  54427. check: ns => ns.startsWith("http://www.xfa.org/schema/xdc/")
  54428. },
  54429. xdp: {
  54430. id: 11,
  54431. check: ns => ns === "http://ns.adobe.com/xdp/"
  54432. },
  54433. xfdf: {
  54434. id: 12,
  54435. check: ns => ns === "http://ns.adobe.com/xfdf/"
  54436. },
  54437. xhtml: {
  54438. id: 13,
  54439. check: ns => ns === "http://www.w3.org/1999/xhtml"
  54440. },
  54441. xmpmeta: {
  54442. id: 14,
  54443. check: ns => ns === "http://ns.adobe.com/xmpmeta/"
  54444. }
  54445. };
  54446. exports.NamespaceIds = NamespaceIds;
  54447. /***/ }),
  54448. /* 236 */
  54449. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  54450. Object.defineProperty(exports, "__esModule", ({
  54451. value: true
  54452. }));
  54453. exports.addHTML = addHTML;
  54454. exports.checkDimensions = checkDimensions;
  54455. exports.flushHTML = flushHTML;
  54456. exports.getAvailableSpace = getAvailableSpace;
  54457. __w_pdfjs_require__(140);
  54458. var _symbol_utils = __w_pdfjs_require__(229);
  54459. var _html_utils = __w_pdfjs_require__(237);
  54460. function createLine(node, children) {
  54461. return {
  54462. name: "div",
  54463. attributes: {
  54464. class: [node.layout === "lr-tb" ? "xfaLr" : "xfaRl"]
  54465. },
  54466. children
  54467. };
  54468. }
  54469. function flushHTML(node) {
  54470. if (!node[_symbol_utils.$extra]) {
  54471. return null;
  54472. }
  54473. const attributes = node[_symbol_utils.$extra].attributes;
  54474. const html = {
  54475. name: "div",
  54476. attributes,
  54477. children: node[_symbol_utils.$extra].children
  54478. };
  54479. if (node[_symbol_utils.$extra].failingNode) {
  54480. const htmlFromFailing = node[_symbol_utils.$extra].failingNode[_symbol_utils.$flushHTML]();
  54481. if (htmlFromFailing) {
  54482. if (node.layout.endsWith("-tb")) {
  54483. html.children.push(createLine(node, [htmlFromFailing]));
  54484. } else {
  54485. html.children.push(htmlFromFailing);
  54486. }
  54487. }
  54488. }
  54489. if (html.children.length === 0) {
  54490. return null;
  54491. }
  54492. return html;
  54493. }
  54494. function addHTML(node, html, bbox) {
  54495. const extra = node[_symbol_utils.$extra];
  54496. const availableSpace = extra.availableSpace;
  54497. const [x, y, w, h] = bbox;
  54498. switch (node.layout) {
  54499. case "position":
  54500. {
  54501. extra.width = Math.max(extra.width, x + w);
  54502. extra.height = Math.max(extra.height, y + h);
  54503. extra.children.push(html);
  54504. break;
  54505. }
  54506. case "lr-tb":
  54507. case "rl-tb":
  54508. if (!extra.line || extra.attempt === 1) {
  54509. extra.line = createLine(node, []);
  54510. extra.children.push(extra.line);
  54511. extra.numberInLine = 0;
  54512. }
  54513. extra.numberInLine += 1;
  54514. extra.line.children.push(html);
  54515. if (extra.attempt === 0) {
  54516. extra.currentWidth += w;
  54517. extra.height = Math.max(extra.height, extra.prevHeight + h);
  54518. } else {
  54519. extra.currentWidth = w;
  54520. extra.prevHeight = extra.height;
  54521. extra.height += h;
  54522. extra.attempt = 0;
  54523. }
  54524. extra.width = Math.max(extra.width, extra.currentWidth);
  54525. break;
  54526. case "rl-row":
  54527. case "row":
  54528. {
  54529. extra.children.push(html);
  54530. extra.width += w;
  54531. extra.height = Math.max(extra.height, h);
  54532. const height = (0, _html_utils.measureToString)(extra.height);
  54533. for (const child of extra.children) {
  54534. child.attributes.style.height = height;
  54535. }
  54536. break;
  54537. }
  54538. case "table":
  54539. {
  54540. extra.width = Math.min(availableSpace.width, Math.max(extra.width, w));
  54541. extra.height += h;
  54542. extra.children.push(html);
  54543. break;
  54544. }
  54545. case "tb":
  54546. {
  54547. extra.width = Math.min(availableSpace.width, Math.max(extra.width, w));
  54548. extra.height += h;
  54549. extra.children.push(html);
  54550. break;
  54551. }
  54552. }
  54553. }
  54554. function getAvailableSpace(node) {
  54555. const availableSpace = node[_symbol_utils.$extra].availableSpace;
  54556. const marginV = node.margin ? node.margin.topInset + node.margin.bottomInset : 0;
  54557. const marginH = node.margin ? node.margin.leftInset + node.margin.rightInset : 0;
  54558. switch (node.layout) {
  54559. case "lr-tb":
  54560. case "rl-tb":
  54561. if (node[_symbol_utils.$extra].attempt === 0) {
  54562. return {
  54563. width: availableSpace.width - marginH - node[_symbol_utils.$extra].currentWidth,
  54564. height: availableSpace.height - marginV - node[_symbol_utils.$extra].prevHeight
  54565. };
  54566. }
  54567. return {
  54568. width: availableSpace.width - marginH,
  54569. height: availableSpace.height - marginV - node[_symbol_utils.$extra].height
  54570. };
  54571. case "rl-row":
  54572. case "row":
  54573. const width = node[_symbol_utils.$extra].columnWidths.slice(node[_symbol_utils.$extra].currentColumn).reduce((a, x) => a + x);
  54574. return {
  54575. width,
  54576. height: availableSpace.height - marginH
  54577. };
  54578. case "table":
  54579. case "tb":
  54580. return {
  54581. width: availableSpace.width - marginH,
  54582. height: availableSpace.height - marginV - node[_symbol_utils.$extra].height
  54583. };
  54584. case "position":
  54585. default:
  54586. return availableSpace;
  54587. }
  54588. }
  54589. function getTransformedBBox(node) {
  54590. let w = node.w === "" ? NaN : node.w;
  54591. let h = node.h === "" ? NaN : node.h;
  54592. let [centerX, centerY] = [0, 0];
  54593. switch (node.anchorType || "") {
  54594. case "bottomCenter":
  54595. [centerX, centerY] = [w / 2, h];
  54596. break;
  54597. case "bottomLeft":
  54598. [centerX, centerY] = [0, h];
  54599. break;
  54600. case "bottomRight":
  54601. [centerX, centerY] = [w, h];
  54602. break;
  54603. case "middleCenter":
  54604. [centerX, centerY] = [w / 2, h / 2];
  54605. break;
  54606. case "middleLeft":
  54607. [centerX, centerY] = [0, h / 2];
  54608. break;
  54609. case "middleRight":
  54610. [centerX, centerY] = [w, h / 2];
  54611. break;
  54612. case "topCenter":
  54613. [centerX, centerY] = [w / 2, 0];
  54614. break;
  54615. case "topRight":
  54616. [centerX, centerY] = [w, 0];
  54617. break;
  54618. }
  54619. let x, y;
  54620. switch (node.rotate || 0) {
  54621. case 0:
  54622. [x, y] = [-centerX, -centerY];
  54623. break;
  54624. case 90:
  54625. [x, y] = [-centerY, centerX];
  54626. [w, h] = [h, -w];
  54627. break;
  54628. case 180:
  54629. [x, y] = [centerX, centerY];
  54630. [w, h] = [-w, -h];
  54631. break;
  54632. case 270:
  54633. [x, y] = [centerY, -centerX];
  54634. [w, h] = [-h, w];
  54635. break;
  54636. }
  54637. return [node.x + x + Math.min(0, w), node.y + y + Math.min(0, h), Math.abs(w), Math.abs(h)];
  54638. }
  54639. function checkDimensions(node, space) {
  54640. if (node[_symbol_utils.$getTemplateRoot]()[_symbol_utils.$extra].firstUnsplittable === null) {
  54641. return true;
  54642. }
  54643. if (node.w === 0 || node.h === 0) {
  54644. return true;
  54645. }
  54646. const ERROR = 2;
  54647. const parent = node[_symbol_utils.$getSubformParent]();
  54648. const attempt = parent[_symbol_utils.$extra]?.attempt || 0;
  54649. const [, y, w, h] = getTransformedBBox(node);
  54650. switch (parent.layout) {
  54651. case "lr-tb":
  54652. case "rl-tb":
  54653. if (attempt === 0) {
  54654. if (!node[_symbol_utils.$getTemplateRoot]()[_symbol_utils.$extra].noLayoutFailure) {
  54655. if (node.h !== "" && Math.round(h - space.height) > ERROR) {
  54656. return false;
  54657. }
  54658. if (node.w !== "") {
  54659. if (Math.round(w - space.width) <= ERROR) {
  54660. return true;
  54661. }
  54662. if (parent[_symbol_utils.$extra].numberInLine === 0) {
  54663. return space.height > ERROR;
  54664. }
  54665. return false;
  54666. }
  54667. return space.width > ERROR;
  54668. }
  54669. if (node.w !== "") {
  54670. return Math.round(w - space.width) <= ERROR;
  54671. }
  54672. return space.width > ERROR;
  54673. }
  54674. if (node[_symbol_utils.$getTemplateRoot]()[_symbol_utils.$extra].noLayoutFailure) {
  54675. return true;
  54676. }
  54677. if (node.h !== "" && Math.round(h - space.height) > ERROR) {
  54678. return false;
  54679. }
  54680. if (node.w === "" || Math.round(w - space.width) <= ERROR) {
  54681. return space.height > ERROR;
  54682. }
  54683. if (parent[_symbol_utils.$isThereMoreWidth]()) {
  54684. return false;
  54685. }
  54686. return space.height > ERROR;
  54687. case "table":
  54688. case "tb":
  54689. if (node[_symbol_utils.$getTemplateRoot]()[_symbol_utils.$extra].noLayoutFailure) {
  54690. return true;
  54691. }
  54692. if (node.h !== "" && !node[_symbol_utils.$isSplittable]()) {
  54693. return Math.round(h - space.height) <= ERROR;
  54694. }
  54695. if (node.w === "" || Math.round(w - space.width) <= ERROR) {
  54696. return space.height > ERROR;
  54697. }
  54698. if (parent[_symbol_utils.$isThereMoreWidth]()) {
  54699. return false;
  54700. }
  54701. return space.height > ERROR;
  54702. case "position":
  54703. if (node[_symbol_utils.$getTemplateRoot]()[_symbol_utils.$extra].noLayoutFailure) {
  54704. return true;
  54705. }
  54706. if (node.h === "" || Math.round(h + y - space.height) <= ERROR) {
  54707. return true;
  54708. }
  54709. const area = node[_symbol_utils.$getTemplateRoot]()[_symbol_utils.$extra].currentContentArea;
  54710. return h + y > area.h;
  54711. case "rl-row":
  54712. case "row":
  54713. if (node[_symbol_utils.$getTemplateRoot]()[_symbol_utils.$extra].noLayoutFailure) {
  54714. return true;
  54715. }
  54716. if (node.h !== "") {
  54717. return Math.round(h - space.height) <= ERROR;
  54718. }
  54719. return true;
  54720. default:
  54721. return true;
  54722. }
  54723. }
  54724. /***/ }),
  54725. /* 237 */
  54726. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  54727. Object.defineProperty(exports, "__esModule", ({
  54728. value: true
  54729. }));
  54730. exports.computeBbox = computeBbox;
  54731. exports.createWrapper = createWrapper;
  54732. exports.fixDimensions = fixDimensions;
  54733. exports.fixTextIndent = fixTextIndent;
  54734. exports.fixURL = fixURL;
  54735. exports.isPrintOnly = isPrintOnly;
  54736. exports.layoutClass = layoutClass;
  54737. exports.layoutNode = layoutNode;
  54738. exports.measureToString = measureToString;
  54739. exports.setAccess = setAccess;
  54740. exports.setFontFamily = setFontFamily;
  54741. exports.setMinMaxDimensions = setMinMaxDimensions;
  54742. exports.setPara = setPara;
  54743. exports.toStyle = toStyle;
  54744. __w_pdfjs_require__(140);
  54745. var _symbol_utils = __w_pdfjs_require__(229);
  54746. var _util = __w_pdfjs_require__(145);
  54747. var _utils = __w_pdfjs_require__(238);
  54748. var _fonts = __w_pdfjs_require__(239);
  54749. var _text = __w_pdfjs_require__(240);
  54750. var _xfa_object = __w_pdfjs_require__(241);
  54751. function measureToString(m) {
  54752. if (typeof m === "string") {
  54753. return "0px";
  54754. }
  54755. return Number.isInteger(m) ? `${m}px` : `${m.toFixed(2)}px`;
  54756. }
  54757. const converters = {
  54758. anchorType(node, style) {
  54759. const parent = node[_symbol_utils.$getSubformParent]();
  54760. if (!parent || parent.layout && parent.layout !== "position") {
  54761. return;
  54762. }
  54763. if (!("transform" in style)) {
  54764. style.transform = "";
  54765. }
  54766. switch (node.anchorType) {
  54767. case "bottomCenter":
  54768. style.transform += "translate(-50%, -100%)";
  54769. break;
  54770. case "bottomLeft":
  54771. style.transform += "translate(0,-100%)";
  54772. break;
  54773. case "bottomRight":
  54774. style.transform += "translate(-100%,-100%)";
  54775. break;
  54776. case "middleCenter":
  54777. style.transform += "translate(-50%,-50%)";
  54778. break;
  54779. case "middleLeft":
  54780. style.transform += "translate(0,-50%)";
  54781. break;
  54782. case "middleRight":
  54783. style.transform += "translate(-100%,-50%)";
  54784. break;
  54785. case "topCenter":
  54786. style.transform += "translate(-50%,0)";
  54787. break;
  54788. case "topRight":
  54789. style.transform += "translate(-100%,0)";
  54790. break;
  54791. }
  54792. },
  54793. dimensions(node, style) {
  54794. const parent = node[_symbol_utils.$getSubformParent]();
  54795. let width = node.w;
  54796. const height = node.h;
  54797. if (parent.layout?.includes("row")) {
  54798. const extra = parent[_symbol_utils.$extra];
  54799. const colSpan = node.colSpan;
  54800. let w;
  54801. if (colSpan === -1) {
  54802. w = extra.columnWidths.slice(extra.currentColumn).reduce((a, x) => a + x, 0);
  54803. extra.currentColumn = 0;
  54804. } else {
  54805. w = extra.columnWidths.slice(extra.currentColumn, extra.currentColumn + colSpan).reduce((a, x) => a + x, 0);
  54806. extra.currentColumn = (extra.currentColumn + node.colSpan) % extra.columnWidths.length;
  54807. }
  54808. if (!isNaN(w)) {
  54809. width = node.w = w;
  54810. }
  54811. }
  54812. style.width = width !== "" ? measureToString(width) : "auto";
  54813. style.height = height !== "" ? measureToString(height) : "auto";
  54814. },
  54815. position(node, style) {
  54816. const parent = node[_symbol_utils.$getSubformParent]();
  54817. if (parent?.layout && parent.layout !== "position") {
  54818. return;
  54819. }
  54820. style.position = "absolute";
  54821. style.left = measureToString(node.x);
  54822. style.top = measureToString(node.y);
  54823. },
  54824. rotate(node, style) {
  54825. if (node.rotate) {
  54826. if (!("transform" in style)) {
  54827. style.transform = "";
  54828. }
  54829. style.transform += `rotate(-${node.rotate}deg)`;
  54830. style.transformOrigin = "top left";
  54831. }
  54832. },
  54833. presence(node, style) {
  54834. switch (node.presence) {
  54835. case "invisible":
  54836. style.visibility = "hidden";
  54837. break;
  54838. case "hidden":
  54839. case "inactive":
  54840. style.display = "none";
  54841. break;
  54842. }
  54843. },
  54844. hAlign(node, style) {
  54845. if (node[_symbol_utils.$nodeName] === "para") {
  54846. switch (node.hAlign) {
  54847. case "justifyAll":
  54848. style.textAlign = "justify-all";
  54849. break;
  54850. case "radix":
  54851. style.textAlign = "left";
  54852. break;
  54853. default:
  54854. style.textAlign = node.hAlign;
  54855. }
  54856. } else {
  54857. switch (node.hAlign) {
  54858. case "left":
  54859. style.alignSelf = "start";
  54860. break;
  54861. case "center":
  54862. style.alignSelf = "center";
  54863. break;
  54864. case "right":
  54865. style.alignSelf = "end";
  54866. break;
  54867. }
  54868. }
  54869. },
  54870. margin(node, style) {
  54871. if (node.margin) {
  54872. style.margin = node.margin[_symbol_utils.$toStyle]().margin;
  54873. }
  54874. }
  54875. };
  54876. function setMinMaxDimensions(node, style) {
  54877. const parent = node[_symbol_utils.$getSubformParent]();
  54878. if (parent.layout === "position") {
  54879. if (node.minW > 0) {
  54880. style.minWidth = measureToString(node.minW);
  54881. }
  54882. if (node.maxW > 0) {
  54883. style.maxWidth = measureToString(node.maxW);
  54884. }
  54885. if (node.minH > 0) {
  54886. style.minHeight = measureToString(node.minH);
  54887. }
  54888. if (node.maxH > 0) {
  54889. style.maxHeight = measureToString(node.maxH);
  54890. }
  54891. }
  54892. }
  54893. function layoutText(text, xfaFont, margin, lineHeight, fontFinder, width) {
  54894. const measure = new _text.TextMeasure(xfaFont, margin, lineHeight, fontFinder);
  54895. if (typeof text === "string") {
  54896. measure.addString(text);
  54897. } else {
  54898. text[_symbol_utils.$pushGlyphs](measure);
  54899. }
  54900. return measure.compute(width);
  54901. }
  54902. function layoutNode(node, availableSpace) {
  54903. let height = null;
  54904. let width = null;
  54905. let isBroken = false;
  54906. if ((!node.w || !node.h) && node.value) {
  54907. let marginH = 0;
  54908. let marginV = 0;
  54909. if (node.margin) {
  54910. marginH = node.margin.leftInset + node.margin.rightInset;
  54911. marginV = node.margin.topInset + node.margin.bottomInset;
  54912. }
  54913. let lineHeight = null;
  54914. let margin = null;
  54915. if (node.para) {
  54916. margin = Object.create(null);
  54917. lineHeight = node.para.lineHeight === "" ? null : node.para.lineHeight;
  54918. margin.top = node.para.spaceAbove === "" ? 0 : node.para.spaceAbove;
  54919. margin.bottom = node.para.spaceBelow === "" ? 0 : node.para.spaceBelow;
  54920. margin.left = node.para.marginLeft === "" ? 0 : node.para.marginLeft;
  54921. margin.right = node.para.marginRight === "" ? 0 : node.para.marginRight;
  54922. }
  54923. let font = node.font;
  54924. if (!font) {
  54925. const root = node[_symbol_utils.$getTemplateRoot]();
  54926. let parent = node[_symbol_utils.$getParent]();
  54927. while (parent && parent !== root) {
  54928. if (parent.font) {
  54929. font = parent.font;
  54930. break;
  54931. }
  54932. parent = parent[_symbol_utils.$getParent]();
  54933. }
  54934. }
  54935. const maxWidth = (node.w || availableSpace.width) - marginH;
  54936. const fontFinder = node[_symbol_utils.$globalData].fontFinder;
  54937. if (node.value.exData && node.value.exData[_symbol_utils.$content] && node.value.exData.contentType === "text/html") {
  54938. const res = layoutText(node.value.exData[_symbol_utils.$content], font, margin, lineHeight, fontFinder, maxWidth);
  54939. width = res.width;
  54940. height = res.height;
  54941. isBroken = res.isBroken;
  54942. } else {
  54943. const text = node.value[_symbol_utils.$text]();
  54944. if (text) {
  54945. const res = layoutText(text, font, margin, lineHeight, fontFinder, maxWidth);
  54946. width = res.width;
  54947. height = res.height;
  54948. isBroken = res.isBroken;
  54949. }
  54950. }
  54951. if (width !== null && !node.w) {
  54952. width += marginH;
  54953. }
  54954. if (height !== null && !node.h) {
  54955. height += marginV;
  54956. }
  54957. }
  54958. return {
  54959. w: width,
  54960. h: height,
  54961. isBroken
  54962. };
  54963. }
  54964. function computeBbox(node, html, availableSpace) {
  54965. let bbox;
  54966. if (node.w !== "" && node.h !== "") {
  54967. bbox = [node.x, node.y, node.w, node.h];
  54968. } else {
  54969. if (!availableSpace) {
  54970. return null;
  54971. }
  54972. let width = node.w;
  54973. if (width === "") {
  54974. if (node.maxW === 0) {
  54975. const parent = node[_symbol_utils.$getSubformParent]();
  54976. width = parent.layout === "position" && parent.w !== "" ? 0 : node.minW;
  54977. } else {
  54978. width = Math.min(node.maxW, availableSpace.width);
  54979. }
  54980. html.attributes.style.width = measureToString(width);
  54981. }
  54982. let height = node.h;
  54983. if (height === "") {
  54984. if (node.maxH === 0) {
  54985. const parent = node[_symbol_utils.$getSubformParent]();
  54986. height = parent.layout === "position" && parent.h !== "" ? 0 : node.minH;
  54987. } else {
  54988. height = Math.min(node.maxH, availableSpace.height);
  54989. }
  54990. html.attributes.style.height = measureToString(height);
  54991. }
  54992. bbox = [node.x, node.y, width, height];
  54993. }
  54994. return bbox;
  54995. }
  54996. function fixDimensions(node) {
  54997. const parent = node[_symbol_utils.$getSubformParent]();
  54998. if (parent.layout?.includes("row")) {
  54999. const extra = parent[_symbol_utils.$extra];
  55000. const colSpan = node.colSpan;
  55001. let width;
  55002. if (colSpan === -1) {
  55003. width = extra.columnWidths.slice(extra.currentColumn).reduce((a, w) => a + w, 0);
  55004. } else {
  55005. width = extra.columnWidths.slice(extra.currentColumn, extra.currentColumn + colSpan).reduce((a, w) => a + w, 0);
  55006. }
  55007. if (!isNaN(width)) {
  55008. node.w = width;
  55009. }
  55010. }
  55011. if (parent.layout && parent.layout !== "position") {
  55012. node.x = node.y = 0;
  55013. }
  55014. if (node.layout === "table") {
  55015. if (node.w === "" && Array.isArray(node.columnWidths)) {
  55016. node.w = node.columnWidths.reduce((a, x) => a + x, 0);
  55017. }
  55018. }
  55019. }
  55020. function layoutClass(node) {
  55021. switch (node.layout) {
  55022. case "position":
  55023. return "xfaPosition";
  55024. case "lr-tb":
  55025. return "xfaLrTb";
  55026. case "rl-row":
  55027. return "xfaRlRow";
  55028. case "rl-tb":
  55029. return "xfaRlTb";
  55030. case "row":
  55031. return "xfaRow";
  55032. case "table":
  55033. return "xfaTable";
  55034. case "tb":
  55035. return "xfaTb";
  55036. default:
  55037. return "xfaPosition";
  55038. }
  55039. }
  55040. function toStyle(node) {
  55041. const style = Object.create(null);
  55042. for (var _len = arguments.length, names = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
  55043. names[_key - 1] = arguments[_key];
  55044. }
  55045. for (const name of names) {
  55046. const value = node[name];
  55047. if (value === null) {
  55048. continue;
  55049. }
  55050. if (converters.hasOwnProperty(name)) {
  55051. converters[name](node, style);
  55052. continue;
  55053. }
  55054. if (value instanceof _xfa_object.XFAObject) {
  55055. const newStyle = value[_symbol_utils.$toStyle]();
  55056. if (newStyle) {
  55057. Object.assign(style, newStyle);
  55058. } else {
  55059. (0, _util.warn)(`(DEBUG) - XFA - style for ${name} not implemented yet`);
  55060. }
  55061. }
  55062. }
  55063. return style;
  55064. }
  55065. function createWrapper(node, html) {
  55066. const {
  55067. attributes
  55068. } = html;
  55069. const {
  55070. style
  55071. } = attributes;
  55072. const wrapper = {
  55073. name: "div",
  55074. attributes: {
  55075. class: ["xfaWrapper"],
  55076. style: Object.create(null)
  55077. },
  55078. children: []
  55079. };
  55080. attributes.class.push("xfaWrapped");
  55081. if (node.border) {
  55082. const {
  55083. widths,
  55084. insets
  55085. } = node.border[_symbol_utils.$extra];
  55086. let width, height;
  55087. let top = insets[0];
  55088. let left = insets[3];
  55089. const insetsH = insets[0] + insets[2];
  55090. const insetsW = insets[1] + insets[3];
  55091. switch (node.border.hand) {
  55092. case "even":
  55093. top -= widths[0] / 2;
  55094. left -= widths[3] / 2;
  55095. width = `calc(100% + ${(widths[1] + widths[3]) / 2 - insetsW}px)`;
  55096. height = `calc(100% + ${(widths[0] + widths[2]) / 2 - insetsH}px)`;
  55097. break;
  55098. case "left":
  55099. top -= widths[0];
  55100. left -= widths[3];
  55101. width = `calc(100% + ${widths[1] + widths[3] - insetsW}px)`;
  55102. height = `calc(100% + ${widths[0] + widths[2] - insetsH}px)`;
  55103. break;
  55104. case "right":
  55105. width = insetsW ? `calc(100% - ${insetsW}px)` : "100%";
  55106. height = insetsH ? `calc(100% - ${insetsH}px)` : "100%";
  55107. break;
  55108. }
  55109. const classNames = ["xfaBorder"];
  55110. if (isPrintOnly(node.border)) {
  55111. classNames.push("xfaPrintOnly");
  55112. }
  55113. const border = {
  55114. name: "div",
  55115. attributes: {
  55116. class: classNames,
  55117. style: {
  55118. top: `${top}px`,
  55119. left: `${left}px`,
  55120. width,
  55121. height
  55122. }
  55123. },
  55124. children: []
  55125. };
  55126. for (const key of ["border", "borderWidth", "borderColor", "borderRadius", "borderStyle"]) {
  55127. if (style[key] !== undefined) {
  55128. border.attributes.style[key] = style[key];
  55129. delete style[key];
  55130. }
  55131. }
  55132. wrapper.children.push(border, html);
  55133. } else {
  55134. wrapper.children.push(html);
  55135. }
  55136. for (const key of ["background", "backgroundClip", "top", "left", "width", "height", "minWidth", "minHeight", "maxWidth", "maxHeight", "transform", "transformOrigin", "visibility"]) {
  55137. if (style[key] !== undefined) {
  55138. wrapper.attributes.style[key] = style[key];
  55139. delete style[key];
  55140. }
  55141. }
  55142. wrapper.attributes.style.position = style.position === "absolute" ? "absolute" : "relative";
  55143. delete style.position;
  55144. if (style.alignSelf) {
  55145. wrapper.attributes.style.alignSelf = style.alignSelf;
  55146. delete style.alignSelf;
  55147. }
  55148. return wrapper;
  55149. }
  55150. function fixTextIndent(styles) {
  55151. const indent = (0, _utils.getMeasurement)(styles.textIndent, "0px");
  55152. if (indent >= 0) {
  55153. return;
  55154. }
  55155. const align = styles.textAlign === "right" ? "right" : "left";
  55156. const name = "padding" + (align === "left" ? "Left" : "Right");
  55157. const padding = (0, _utils.getMeasurement)(styles[name], "0px");
  55158. styles[name] = `${padding - indent}px`;
  55159. }
  55160. function setAccess(node, classNames) {
  55161. switch (node.access) {
  55162. case "nonInteractive":
  55163. classNames.push("xfaNonInteractive");
  55164. break;
  55165. case "readOnly":
  55166. classNames.push("xfaReadOnly");
  55167. break;
  55168. case "protected":
  55169. classNames.push("xfaDisabled");
  55170. break;
  55171. }
  55172. }
  55173. function isPrintOnly(node) {
  55174. return node.relevant.length > 0 && !node.relevant[0].excluded && node.relevant[0].viewname === "print";
  55175. }
  55176. function getCurrentPara(node) {
  55177. const stack = node[_symbol_utils.$getTemplateRoot]()[_symbol_utils.$extra].paraStack;
  55178. return stack.length ? stack.at(-1) : null;
  55179. }
  55180. function setPara(node, nodeStyle, value) {
  55181. if (value.attributes.class?.includes("xfaRich")) {
  55182. if (nodeStyle) {
  55183. if (node.h === "") {
  55184. nodeStyle.height = "auto";
  55185. }
  55186. if (node.w === "") {
  55187. nodeStyle.width = "auto";
  55188. }
  55189. }
  55190. const para = getCurrentPara(node);
  55191. if (para) {
  55192. const valueStyle = value.attributes.style;
  55193. valueStyle.display = "flex";
  55194. valueStyle.flexDirection = "column";
  55195. switch (para.vAlign) {
  55196. case "top":
  55197. valueStyle.justifyContent = "start";
  55198. break;
  55199. case "bottom":
  55200. valueStyle.justifyContent = "end";
  55201. break;
  55202. case "middle":
  55203. valueStyle.justifyContent = "center";
  55204. break;
  55205. }
  55206. const paraStyle = para[_symbol_utils.$toStyle]();
  55207. for (const [key, val] of Object.entries(paraStyle)) {
  55208. if (!(key in valueStyle)) {
  55209. valueStyle[key] = val;
  55210. }
  55211. }
  55212. }
  55213. }
  55214. }
  55215. function setFontFamily(xfaFont, node, fontFinder, style) {
  55216. if (!fontFinder) {
  55217. delete style.fontFamily;
  55218. return;
  55219. }
  55220. const name = (0, _utils.stripQuotes)(xfaFont.typeface);
  55221. style.fontFamily = `"${name}"`;
  55222. const typeface = fontFinder.find(name);
  55223. if (typeface) {
  55224. const {
  55225. fontFamily
  55226. } = typeface.regular.cssFontInfo;
  55227. if (fontFamily !== name) {
  55228. style.fontFamily = `"${fontFamily}"`;
  55229. }
  55230. const para = getCurrentPara(node);
  55231. if (para && para.lineHeight !== "") {
  55232. return;
  55233. }
  55234. if (style.lineHeight) {
  55235. return;
  55236. }
  55237. const pdfFont = (0, _fonts.selectFont)(xfaFont, typeface);
  55238. if (pdfFont) {
  55239. style.lineHeight = Math.max(1.2, pdfFont.lineHeight);
  55240. }
  55241. }
  55242. }
  55243. function fixURL(str) {
  55244. const absoluteUrl = (0, _util.createValidAbsoluteUrl)(str, null, {
  55245. addDefaultProtocol: true,
  55246. tryConvertEncoding: true
  55247. });
  55248. return absoluteUrl ? absoluteUrl.href : null;
  55249. }
  55250. /***/ }),
  55251. /* 238 */
  55252. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  55253. Object.defineProperty(exports, "__esModule", ({
  55254. value: true
  55255. }));
  55256. exports.HTMLResult = void 0;
  55257. exports.getBBox = getBBox;
  55258. exports.getColor = getColor;
  55259. exports.getFloat = getFloat;
  55260. exports.getInteger = getInteger;
  55261. exports.getKeyword = getKeyword;
  55262. exports.getMeasurement = getMeasurement;
  55263. exports.getRatio = getRatio;
  55264. exports.getRelevant = getRelevant;
  55265. exports.getStringOption = getStringOption;
  55266. exports.stripQuotes = stripQuotes;
  55267. __w_pdfjs_require__(140);
  55268. var _util = __w_pdfjs_require__(145);
  55269. const dimConverters = {
  55270. pt: x => x,
  55271. cm: x => x / 2.54 * 72,
  55272. mm: x => x / (10 * 2.54) * 72,
  55273. in: x => x * 72,
  55274. px: x => x
  55275. };
  55276. const measurementPattern = /([+-]?\d+\.?\d*)(.*)/;
  55277. function stripQuotes(str) {
  55278. if (str.startsWith("'") || str.startsWith('"')) {
  55279. return str.slice(1, -1);
  55280. }
  55281. return str;
  55282. }
  55283. function getInteger(_ref) {
  55284. let {
  55285. data,
  55286. defaultValue,
  55287. validate
  55288. } = _ref;
  55289. if (!data) {
  55290. return defaultValue;
  55291. }
  55292. data = data.trim();
  55293. const n = parseInt(data, 10);
  55294. if (!isNaN(n) && validate(n)) {
  55295. return n;
  55296. }
  55297. return defaultValue;
  55298. }
  55299. function getFloat(_ref2) {
  55300. let {
  55301. data,
  55302. defaultValue,
  55303. validate
  55304. } = _ref2;
  55305. if (!data) {
  55306. return defaultValue;
  55307. }
  55308. data = data.trim();
  55309. const n = parseFloat(data);
  55310. if (!isNaN(n) && validate(n)) {
  55311. return n;
  55312. }
  55313. return defaultValue;
  55314. }
  55315. function getKeyword(_ref3) {
  55316. let {
  55317. data,
  55318. defaultValue,
  55319. validate
  55320. } = _ref3;
  55321. if (!data) {
  55322. return defaultValue;
  55323. }
  55324. data = data.trim();
  55325. if (validate(data)) {
  55326. return data;
  55327. }
  55328. return defaultValue;
  55329. }
  55330. function getStringOption(data, options) {
  55331. return getKeyword({
  55332. data,
  55333. defaultValue: options[0],
  55334. validate: k => options.includes(k)
  55335. });
  55336. }
  55337. function getMeasurement(str) {
  55338. let def = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "0";
  55339. def ||= "0";
  55340. if (!str) {
  55341. return getMeasurement(def);
  55342. }
  55343. const match = str.trim().match(measurementPattern);
  55344. if (!match) {
  55345. return getMeasurement(def);
  55346. }
  55347. const [, valueStr, unit] = match;
  55348. const value = parseFloat(valueStr);
  55349. if (isNaN(value)) {
  55350. return getMeasurement(def);
  55351. }
  55352. if (value === 0) {
  55353. return 0;
  55354. }
  55355. const conv = dimConverters[unit];
  55356. if (conv) {
  55357. return conv(value);
  55358. }
  55359. return value;
  55360. }
  55361. function getRatio(data) {
  55362. if (!data) {
  55363. return {
  55364. num: 1,
  55365. den: 1
  55366. };
  55367. }
  55368. const ratio = data.trim().split(/\s*:\s*/).map(x => parseFloat(x)).filter(x => !isNaN(x));
  55369. if (ratio.length === 1) {
  55370. ratio.push(1);
  55371. }
  55372. if (ratio.length === 0) {
  55373. return {
  55374. num: 1,
  55375. den: 1
  55376. };
  55377. }
  55378. const [num, den] = ratio;
  55379. return {
  55380. num,
  55381. den
  55382. };
  55383. }
  55384. function getRelevant(data) {
  55385. if (!data) {
  55386. return [];
  55387. }
  55388. return data.trim().split(/\s+/).map(e => {
  55389. return {
  55390. excluded: e[0] === "-",
  55391. viewname: e.substring(1)
  55392. };
  55393. });
  55394. }
  55395. function getColor(data) {
  55396. let def = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [0, 0, 0];
  55397. let [r, g, b] = def;
  55398. if (!data) {
  55399. return {
  55400. r,
  55401. g,
  55402. b
  55403. };
  55404. }
  55405. 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);
  55406. if (color.length < 3) {
  55407. return {
  55408. r,
  55409. g,
  55410. b
  55411. };
  55412. }
  55413. [r, g, b] = color;
  55414. return {
  55415. r,
  55416. g,
  55417. b
  55418. };
  55419. }
  55420. function getBBox(data) {
  55421. const def = -1;
  55422. if (!data) {
  55423. return {
  55424. x: def,
  55425. y: def,
  55426. width: def,
  55427. height: def
  55428. };
  55429. }
  55430. const bbox = data.trim().split(/\s*,\s*/).map(m => getMeasurement(m, "-1"));
  55431. if (bbox.length < 4 || bbox[2] < 0 || bbox[3] < 0) {
  55432. return {
  55433. x: def,
  55434. y: def,
  55435. width: def,
  55436. height: def
  55437. };
  55438. }
  55439. const [x, y, width, height] = bbox;
  55440. return {
  55441. x,
  55442. y,
  55443. width,
  55444. height
  55445. };
  55446. }
  55447. class HTMLResult {
  55448. static get FAILURE() {
  55449. return (0, _util.shadow)(this, "FAILURE", new HTMLResult(false, null, null, null));
  55450. }
  55451. static get EMPTY() {
  55452. return (0, _util.shadow)(this, "EMPTY", new HTMLResult(true, null, null, null));
  55453. }
  55454. constructor(success, html, bbox, breakNode) {
  55455. this.success = success;
  55456. this.html = html;
  55457. this.bbox = bbox;
  55458. this.breakNode = breakNode;
  55459. }
  55460. isBreak() {
  55461. return !!this.breakNode;
  55462. }
  55463. static breakNode(node) {
  55464. return new HTMLResult(false, null, null, node);
  55465. }
  55466. static success(html) {
  55467. let bbox = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  55468. return new HTMLResult(true, html, bbox, null);
  55469. }
  55470. }
  55471. exports.HTMLResult = HTMLResult;
  55472. /***/ }),
  55473. /* 239 */
  55474. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  55475. Object.defineProperty(exports, "__esModule", ({
  55476. value: true
  55477. }));
  55478. exports.FontFinder = void 0;
  55479. exports.getMetrics = getMetrics;
  55480. exports.selectFont = selectFont;
  55481. __w_pdfjs_require__(116);
  55482. __w_pdfjs_require__(127);
  55483. __w_pdfjs_require__(129);
  55484. __w_pdfjs_require__(132);
  55485. __w_pdfjs_require__(134);
  55486. __w_pdfjs_require__(136);
  55487. __w_pdfjs_require__(138);
  55488. __w_pdfjs_require__(140);
  55489. var _symbol_utils = __w_pdfjs_require__(229);
  55490. var _utils = __w_pdfjs_require__(238);
  55491. var _util = __w_pdfjs_require__(145);
  55492. class FontFinder {
  55493. constructor(pdfFonts) {
  55494. this.fonts = new Map();
  55495. this.cache = new Map();
  55496. this.warned = new Set();
  55497. this.defaultFont = null;
  55498. this.add(pdfFonts);
  55499. }
  55500. add(pdfFonts) {
  55501. let reallyMissingFonts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  55502. for (const pdfFont of pdfFonts) {
  55503. this.addPdfFont(pdfFont);
  55504. }
  55505. for (const pdfFont of this.fonts.values()) {
  55506. if (!pdfFont.regular) {
  55507. pdfFont.regular = pdfFont.italic || pdfFont.bold || pdfFont.bolditalic;
  55508. }
  55509. }
  55510. if (!reallyMissingFonts || reallyMissingFonts.size === 0) {
  55511. return;
  55512. }
  55513. const myriad = this.fonts.get("PdfJS-Fallback-PdfJS-XFA");
  55514. for (const missing of reallyMissingFonts) {
  55515. this.fonts.set(missing, myriad);
  55516. }
  55517. }
  55518. addPdfFont(pdfFont) {
  55519. const cssFontInfo = pdfFont.cssFontInfo;
  55520. const name = cssFontInfo.fontFamily;
  55521. let font = this.fonts.get(name);
  55522. if (!font) {
  55523. font = Object.create(null);
  55524. this.fonts.set(name, font);
  55525. if (!this.defaultFont) {
  55526. this.defaultFont = font;
  55527. }
  55528. }
  55529. let property = "";
  55530. const fontWeight = parseFloat(cssFontInfo.fontWeight);
  55531. if (parseFloat(cssFontInfo.italicAngle) !== 0) {
  55532. property = fontWeight >= 700 ? "bolditalic" : "italic";
  55533. } else if (fontWeight >= 700) {
  55534. property = "bold";
  55535. }
  55536. if (!property) {
  55537. if (pdfFont.name.includes("Bold") || pdfFont.psName?.includes("Bold")) {
  55538. property = "bold";
  55539. }
  55540. if (pdfFont.name.includes("Italic") || pdfFont.name.endsWith("It") || pdfFont.psName?.includes("Italic") || pdfFont.psName?.endsWith("It")) {
  55541. property += "italic";
  55542. }
  55543. }
  55544. if (!property) {
  55545. property = "regular";
  55546. }
  55547. font[property] = pdfFont;
  55548. }
  55549. getDefault() {
  55550. return this.defaultFont;
  55551. }
  55552. find(fontName) {
  55553. let mustWarn = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
  55554. let font = this.fonts.get(fontName) || this.cache.get(fontName);
  55555. if (font) {
  55556. return font;
  55557. }
  55558. const pattern = /,|-|_| |bolditalic|bold|italic|regular|it/gi;
  55559. let name = fontName.replaceAll(pattern, "");
  55560. font = this.fonts.get(name);
  55561. if (font) {
  55562. this.cache.set(fontName, font);
  55563. return font;
  55564. }
  55565. name = name.toLowerCase();
  55566. const maybe = [];
  55567. for (const [family, pdfFont] of this.fonts.entries()) {
  55568. if (family.replaceAll(pattern, "").toLowerCase().startsWith(name)) {
  55569. maybe.push(pdfFont);
  55570. }
  55571. }
  55572. if (maybe.length === 0) {
  55573. for (const [, pdfFont] of this.fonts.entries()) {
  55574. if (pdfFont.regular.name?.replaceAll(pattern, "").toLowerCase().startsWith(name)) {
  55575. maybe.push(pdfFont);
  55576. }
  55577. }
  55578. }
  55579. if (maybe.length === 0) {
  55580. name = name.replaceAll(/psmt|mt/gi, "");
  55581. for (const [family, pdfFont] of this.fonts.entries()) {
  55582. if (family.replaceAll(pattern, "").toLowerCase().startsWith(name)) {
  55583. maybe.push(pdfFont);
  55584. }
  55585. }
  55586. }
  55587. if (maybe.length === 0) {
  55588. for (const pdfFont of this.fonts.values()) {
  55589. if (pdfFont.regular.name?.replaceAll(pattern, "").toLowerCase().startsWith(name)) {
  55590. maybe.push(pdfFont);
  55591. }
  55592. }
  55593. }
  55594. if (maybe.length >= 1) {
  55595. if (maybe.length !== 1 && mustWarn) {
  55596. (0, _util.warn)(`XFA - Too many choices to guess the correct font: ${fontName}`);
  55597. }
  55598. this.cache.set(fontName, maybe[0]);
  55599. return maybe[0];
  55600. }
  55601. if (mustWarn && !this.warned.has(fontName)) {
  55602. this.warned.add(fontName);
  55603. (0, _util.warn)(`XFA - Cannot find the font: ${fontName}`);
  55604. }
  55605. return null;
  55606. }
  55607. }
  55608. exports.FontFinder = FontFinder;
  55609. function selectFont(xfaFont, typeface) {
  55610. if (xfaFont.posture === "italic") {
  55611. if (xfaFont.weight === "bold") {
  55612. return typeface.bolditalic;
  55613. }
  55614. return typeface.italic;
  55615. } else if (xfaFont.weight === "bold") {
  55616. return typeface.bold;
  55617. }
  55618. return typeface.regular;
  55619. }
  55620. function getMetrics(xfaFont) {
  55621. let real = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  55622. let pdfFont = null;
  55623. if (xfaFont) {
  55624. const name = (0, _utils.stripQuotes)(xfaFont.typeface);
  55625. const typeface = xfaFont[_symbol_utils.$globalData].fontFinder.find(name);
  55626. pdfFont = selectFont(xfaFont, typeface);
  55627. }
  55628. if (!pdfFont) {
  55629. return {
  55630. lineHeight: 12,
  55631. lineGap: 2,
  55632. lineNoGap: 10
  55633. };
  55634. }
  55635. const size = xfaFont.size || 10;
  55636. const lineHeight = pdfFont.lineHeight ? Math.max(real ? 0 : 1.2, pdfFont.lineHeight) : 1.2;
  55637. const lineGap = pdfFont.lineGap === undefined ? 0.2 : pdfFont.lineGap;
  55638. return {
  55639. lineHeight: lineHeight * size,
  55640. lineGap: lineGap * size,
  55641. lineNoGap: Math.max(1, lineHeight - lineGap) * size
  55642. };
  55643. }
  55644. /***/ }),
  55645. /* 240 */
  55646. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  55647. Object.defineProperty(exports, "__esModule", ({
  55648. value: true
  55649. }));
  55650. exports.TextMeasure = void 0;
  55651. __w_pdfjs_require__(140);
  55652. var _fonts = __w_pdfjs_require__(239);
  55653. const WIDTH_FACTOR = 1.02;
  55654. class FontInfo {
  55655. constructor(xfaFont, margin, lineHeight, fontFinder) {
  55656. this.lineHeight = lineHeight;
  55657. this.paraMargin = margin || {
  55658. top: 0,
  55659. bottom: 0,
  55660. left: 0,
  55661. right: 0
  55662. };
  55663. if (!xfaFont) {
  55664. [this.pdfFont, this.xfaFont] = this.defaultFont(fontFinder);
  55665. return;
  55666. }
  55667. this.xfaFont = {
  55668. typeface: xfaFont.typeface,
  55669. posture: xfaFont.posture,
  55670. weight: xfaFont.weight,
  55671. size: xfaFont.size,
  55672. letterSpacing: xfaFont.letterSpacing
  55673. };
  55674. const typeface = fontFinder.find(xfaFont.typeface);
  55675. if (!typeface) {
  55676. [this.pdfFont, this.xfaFont] = this.defaultFont(fontFinder);
  55677. return;
  55678. }
  55679. this.pdfFont = (0, _fonts.selectFont)(xfaFont, typeface);
  55680. if (!this.pdfFont) {
  55681. [this.pdfFont, this.xfaFont] = this.defaultFont(fontFinder);
  55682. }
  55683. }
  55684. defaultFont(fontFinder) {
  55685. const font = fontFinder.find("Helvetica", false) || fontFinder.find("Myriad Pro", false) || fontFinder.find("Arial", false) || fontFinder.getDefault();
  55686. if (font?.regular) {
  55687. const pdfFont = font.regular;
  55688. const info = pdfFont.cssFontInfo;
  55689. const xfaFont = {
  55690. typeface: info.fontFamily,
  55691. posture: "normal",
  55692. weight: "normal",
  55693. size: 10,
  55694. letterSpacing: 0
  55695. };
  55696. return [pdfFont, xfaFont];
  55697. }
  55698. const xfaFont = {
  55699. typeface: "Courier",
  55700. posture: "normal",
  55701. weight: "normal",
  55702. size: 10,
  55703. letterSpacing: 0
  55704. };
  55705. return [null, xfaFont];
  55706. }
  55707. }
  55708. class FontSelector {
  55709. constructor(defaultXfaFont, defaultParaMargin, defaultLineHeight, fontFinder) {
  55710. this.fontFinder = fontFinder;
  55711. this.stack = [new FontInfo(defaultXfaFont, defaultParaMargin, defaultLineHeight, fontFinder)];
  55712. }
  55713. pushData(xfaFont, margin, lineHeight) {
  55714. const lastFont = this.stack.at(-1);
  55715. for (const name of ["typeface", "posture", "weight", "size", "letterSpacing"]) {
  55716. if (!xfaFont[name]) {
  55717. xfaFont[name] = lastFont.xfaFont[name];
  55718. }
  55719. }
  55720. for (const name of ["top", "bottom", "left", "right"]) {
  55721. if (isNaN(margin[name])) {
  55722. margin[name] = lastFont.paraMargin[name];
  55723. }
  55724. }
  55725. const fontInfo = new FontInfo(xfaFont, margin, lineHeight || lastFont.lineHeight, this.fontFinder);
  55726. if (!fontInfo.pdfFont) {
  55727. fontInfo.pdfFont = lastFont.pdfFont;
  55728. }
  55729. this.stack.push(fontInfo);
  55730. }
  55731. popFont() {
  55732. this.stack.pop();
  55733. }
  55734. topFont() {
  55735. return this.stack.at(-1);
  55736. }
  55737. }
  55738. class TextMeasure {
  55739. constructor(defaultXfaFont, defaultParaMargin, defaultLineHeight, fonts) {
  55740. this.glyphs = [];
  55741. this.fontSelector = new FontSelector(defaultXfaFont, defaultParaMargin, defaultLineHeight, fonts);
  55742. this.extraHeight = 0;
  55743. }
  55744. pushData(xfaFont, margin, lineHeight) {
  55745. this.fontSelector.pushData(xfaFont, margin, lineHeight);
  55746. }
  55747. popFont(xfaFont) {
  55748. return this.fontSelector.popFont();
  55749. }
  55750. addPara() {
  55751. const lastFont = this.fontSelector.topFont();
  55752. this.extraHeight += lastFont.paraMargin.top + lastFont.paraMargin.bottom;
  55753. }
  55754. addString(str) {
  55755. if (!str) {
  55756. return;
  55757. }
  55758. const lastFont = this.fontSelector.topFont();
  55759. const fontSize = lastFont.xfaFont.size;
  55760. if (lastFont.pdfFont) {
  55761. const letterSpacing = lastFont.xfaFont.letterSpacing;
  55762. const pdfFont = lastFont.pdfFont;
  55763. const fontLineHeight = pdfFont.lineHeight || 1.2;
  55764. const lineHeight = lastFont.lineHeight || Math.max(1.2, fontLineHeight) * fontSize;
  55765. const lineGap = pdfFont.lineGap === undefined ? 0.2 : pdfFont.lineGap;
  55766. const noGap = fontLineHeight - lineGap;
  55767. const firstLineHeight = Math.max(1, noGap) * fontSize;
  55768. const scale = fontSize / 1000;
  55769. const fallbackWidth = pdfFont.defaultWidth || pdfFont.charsToGlyphs(" ")[0].width;
  55770. for (const line of str.split(/[\u2029\n]/)) {
  55771. const encodedLine = pdfFont.encodeString(line).join("");
  55772. const glyphs = pdfFont.charsToGlyphs(encodedLine);
  55773. for (const glyph of glyphs) {
  55774. const width = glyph.width || fallbackWidth;
  55775. this.glyphs.push([width * scale + letterSpacing, lineHeight, firstLineHeight, glyph.unicode, false]);
  55776. }
  55777. this.glyphs.push([0, 0, 0, "\n", true]);
  55778. }
  55779. this.glyphs.pop();
  55780. return;
  55781. }
  55782. for (const line of str.split(/[\u2029\n]/)) {
  55783. for (const char of line.split("")) {
  55784. this.glyphs.push([fontSize, 1.2 * fontSize, fontSize, char, false]);
  55785. }
  55786. this.glyphs.push([0, 0, 0, "\n", true]);
  55787. }
  55788. this.glyphs.pop();
  55789. }
  55790. compute(maxWidth) {
  55791. let lastSpacePos = -1,
  55792. lastSpaceWidth = 0,
  55793. width = 0,
  55794. height = 0,
  55795. currentLineWidth = 0,
  55796. currentLineHeight = 0;
  55797. let isBroken = false;
  55798. let isFirstLine = true;
  55799. for (let i = 0, ii = this.glyphs.length; i < ii; i++) {
  55800. const [glyphWidth, lineHeight, firstLineHeight, char, isEOL] = this.glyphs[i];
  55801. const isSpace = char === " ";
  55802. const glyphHeight = isFirstLine ? firstLineHeight : lineHeight;
  55803. if (isEOL) {
  55804. width = Math.max(width, currentLineWidth);
  55805. currentLineWidth = 0;
  55806. height += currentLineHeight;
  55807. currentLineHeight = glyphHeight;
  55808. lastSpacePos = -1;
  55809. lastSpaceWidth = 0;
  55810. isFirstLine = false;
  55811. continue;
  55812. }
  55813. if (isSpace) {
  55814. if (currentLineWidth + glyphWidth > maxWidth) {
  55815. width = Math.max(width, currentLineWidth);
  55816. currentLineWidth = 0;
  55817. height += currentLineHeight;
  55818. currentLineHeight = glyphHeight;
  55819. lastSpacePos = -1;
  55820. lastSpaceWidth = 0;
  55821. isBroken = true;
  55822. isFirstLine = false;
  55823. } else {
  55824. currentLineHeight = Math.max(glyphHeight, currentLineHeight);
  55825. lastSpaceWidth = currentLineWidth;
  55826. currentLineWidth += glyphWidth;
  55827. lastSpacePos = i;
  55828. }
  55829. continue;
  55830. }
  55831. if (currentLineWidth + glyphWidth > maxWidth) {
  55832. height += currentLineHeight;
  55833. currentLineHeight = glyphHeight;
  55834. if (lastSpacePos !== -1) {
  55835. i = lastSpacePos;
  55836. width = Math.max(width, lastSpaceWidth);
  55837. currentLineWidth = 0;
  55838. lastSpacePos = -1;
  55839. lastSpaceWidth = 0;
  55840. } else {
  55841. width = Math.max(width, currentLineWidth);
  55842. currentLineWidth = glyphWidth;
  55843. }
  55844. isBroken = true;
  55845. isFirstLine = false;
  55846. continue;
  55847. }
  55848. currentLineWidth += glyphWidth;
  55849. currentLineHeight = Math.max(glyphHeight, currentLineHeight);
  55850. }
  55851. width = Math.max(width, currentLineWidth);
  55852. height += currentLineHeight + this.extraHeight;
  55853. return {
  55854. width: WIDTH_FACTOR * width,
  55855. height,
  55856. isBroken
  55857. };
  55858. }
  55859. }
  55860. exports.TextMeasure = TextMeasure;
  55861. /***/ }),
  55862. /* 241 */
  55863. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  55864. Object.defineProperty(exports, "__esModule", ({
  55865. value: true
  55866. }));
  55867. exports.XmlObject = exports.XFAObjectArray = exports.XFAObject = exports.XFAAttribute = exports.StringObject = exports.OptionObject = exports.Option10 = exports.Option01 = exports.IntegerObject = exports.ContentObject = void 0;
  55868. __w_pdfjs_require__(140);
  55869. __w_pdfjs_require__(116);
  55870. __w_pdfjs_require__(127);
  55871. __w_pdfjs_require__(129);
  55872. __w_pdfjs_require__(132);
  55873. __w_pdfjs_require__(134);
  55874. __w_pdfjs_require__(136);
  55875. __w_pdfjs_require__(138);
  55876. var _symbol_utils = __w_pdfjs_require__(229);
  55877. var _utils = __w_pdfjs_require__(238);
  55878. var _util = __w_pdfjs_require__(145);
  55879. var _core_utils = __w_pdfjs_require__(150);
  55880. var _namespaces = __w_pdfjs_require__(235);
  55881. var _som = __w_pdfjs_require__(242);
  55882. const _applyPrototype = Symbol();
  55883. const _attributes = Symbol();
  55884. const _attributeNames = Symbol();
  55885. const _children = Symbol("_children");
  55886. const _cloneAttribute = Symbol();
  55887. const _dataValue = Symbol();
  55888. const _defaultValue = Symbol();
  55889. const _filteredChildrenGenerator = Symbol();
  55890. const _getPrototype = Symbol();
  55891. const _getUnsetAttributes = Symbol();
  55892. const _hasChildren = Symbol();
  55893. const _max = Symbol();
  55894. const _options = Symbol();
  55895. const _parent = Symbol("parent");
  55896. const _resolvePrototypesHelper = Symbol();
  55897. const _setAttributes = Symbol();
  55898. const _validator = Symbol();
  55899. let uid = 0;
  55900. const NS_DATASETS = _namespaces.NamespaceIds.datasets.id;
  55901. class XFAObject {
  55902. constructor(nsId, name) {
  55903. let hasChildren = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  55904. this[_symbol_utils.$namespaceId] = nsId;
  55905. this[_symbol_utils.$nodeName] = name;
  55906. this[_hasChildren] = hasChildren;
  55907. this[_parent] = null;
  55908. this[_children] = [];
  55909. this[_symbol_utils.$uid] = `${name}${uid++}`;
  55910. this[_symbol_utils.$globalData] = null;
  55911. }
  55912. get isXFAObject() {
  55913. return true;
  55914. }
  55915. get isXFAObjectArray() {
  55916. return false;
  55917. }
  55918. createNodes(path) {
  55919. let root = this,
  55920. node = null;
  55921. for (const {
  55922. name,
  55923. index
  55924. } of path) {
  55925. for (let i = 0, ii = isFinite(index) ? index : 0; i <= ii; i++) {
  55926. const nsId = root[_symbol_utils.$namespaceId] === NS_DATASETS ? -1 : root[_symbol_utils.$namespaceId];
  55927. node = new XmlObject(nsId, name);
  55928. root[_symbol_utils.$appendChild](node);
  55929. }
  55930. root = node;
  55931. }
  55932. return node;
  55933. }
  55934. [_symbol_utils.$onChild](child) {
  55935. if (!this[_hasChildren] || !this[_symbol_utils.$onChildCheck](child)) {
  55936. return false;
  55937. }
  55938. const name = child[_symbol_utils.$nodeName];
  55939. const node = this[name];
  55940. if (node instanceof XFAObjectArray) {
  55941. if (node.push(child)) {
  55942. this[_symbol_utils.$appendChild](child);
  55943. return true;
  55944. }
  55945. } else {
  55946. if (node !== null) {
  55947. this[_symbol_utils.$removeChild](node);
  55948. }
  55949. this[name] = child;
  55950. this[_symbol_utils.$appendChild](child);
  55951. return true;
  55952. }
  55953. let id = "";
  55954. if (this.id) {
  55955. id = ` (id: ${this.id})`;
  55956. } else if (this.name) {
  55957. id = ` (name: ${this.name} ${this.h.value})`;
  55958. }
  55959. (0, _util.warn)(`XFA - node "${this[_symbol_utils.$nodeName]}"${id} has already enough "${name}"!`);
  55960. return false;
  55961. }
  55962. [_symbol_utils.$onChildCheck](child) {
  55963. return this.hasOwnProperty(child[_symbol_utils.$nodeName]) && child[_symbol_utils.$namespaceId] === this[_symbol_utils.$namespaceId];
  55964. }
  55965. [_symbol_utils.$isNsAgnostic]() {
  55966. return false;
  55967. }
  55968. [_symbol_utils.$acceptWhitespace]() {
  55969. return false;
  55970. }
  55971. [_symbol_utils.$isCDATAXml]() {
  55972. return false;
  55973. }
  55974. [_symbol_utils.$isBindable]() {
  55975. return false;
  55976. }
  55977. [_symbol_utils.$popPara]() {
  55978. if (this.para) {
  55979. this[_symbol_utils.$getTemplateRoot]()[_symbol_utils.$extra].paraStack.pop();
  55980. }
  55981. }
  55982. [_symbol_utils.$pushPara]() {
  55983. this[_symbol_utils.$getTemplateRoot]()[_symbol_utils.$extra].paraStack.push(this.para);
  55984. }
  55985. [_symbol_utils.$setId](ids) {
  55986. if (this.id && this[_symbol_utils.$namespaceId] === _namespaces.NamespaceIds.template.id) {
  55987. ids.set(this.id, this);
  55988. }
  55989. }
  55990. [_symbol_utils.$getTemplateRoot]() {
  55991. return this[_symbol_utils.$globalData].template;
  55992. }
  55993. [_symbol_utils.$isSplittable]() {
  55994. return false;
  55995. }
  55996. [_symbol_utils.$isThereMoreWidth]() {
  55997. return false;
  55998. }
  55999. [_symbol_utils.$appendChild](child) {
  56000. child[_parent] = this;
  56001. this[_children].push(child);
  56002. if (!child[_symbol_utils.$globalData] && this[_symbol_utils.$globalData]) {
  56003. child[_symbol_utils.$globalData] = this[_symbol_utils.$globalData];
  56004. }
  56005. }
  56006. [_symbol_utils.$removeChild](child) {
  56007. const i = this[_children].indexOf(child);
  56008. this[_children].splice(i, 1);
  56009. }
  56010. [_symbol_utils.$hasSettableValue]() {
  56011. return this.hasOwnProperty("value");
  56012. }
  56013. [_symbol_utils.$setValue](_) {}
  56014. [_symbol_utils.$onText](_) {}
  56015. [_symbol_utils.$finalize]() {}
  56016. [_symbol_utils.$clean](builder) {
  56017. delete this[_hasChildren];
  56018. if (this[_symbol_utils.$cleanup]) {
  56019. builder.clean(this[_symbol_utils.$cleanup]);
  56020. delete this[_symbol_utils.$cleanup];
  56021. }
  56022. }
  56023. [_symbol_utils.$indexOf](child) {
  56024. return this[_children].indexOf(child);
  56025. }
  56026. [_symbol_utils.$insertAt](i, child) {
  56027. child[_parent] = this;
  56028. this[_children].splice(i, 0, child);
  56029. if (!child[_symbol_utils.$globalData] && this[_symbol_utils.$globalData]) {
  56030. child[_symbol_utils.$globalData] = this[_symbol_utils.$globalData];
  56031. }
  56032. }
  56033. [_symbol_utils.$isTransparent]() {
  56034. return !this.name;
  56035. }
  56036. [_symbol_utils.$lastAttribute]() {
  56037. return "";
  56038. }
  56039. [_symbol_utils.$text]() {
  56040. if (this[_children].length === 0) {
  56041. return this[_symbol_utils.$content];
  56042. }
  56043. return this[_children].map(c => c[_symbol_utils.$text]()).join("");
  56044. }
  56045. get [_attributeNames]() {
  56046. const proto = Object.getPrototypeOf(this);
  56047. if (!proto._attributes) {
  56048. const attributes = proto._attributes = new Set();
  56049. for (const name of Object.getOwnPropertyNames(this)) {
  56050. if (this[name] === null || this[name] instanceof XFAObject || this[name] instanceof XFAObjectArray) {
  56051. break;
  56052. }
  56053. attributes.add(name);
  56054. }
  56055. }
  56056. return (0, _util.shadow)(this, _attributeNames, proto._attributes);
  56057. }
  56058. [_symbol_utils.$isDescendent](parent) {
  56059. let node = this;
  56060. while (node) {
  56061. if (node === parent) {
  56062. return true;
  56063. }
  56064. node = node[_symbol_utils.$getParent]();
  56065. }
  56066. return false;
  56067. }
  56068. [_symbol_utils.$getParent]() {
  56069. return this[_parent];
  56070. }
  56071. [_symbol_utils.$getSubformParent]() {
  56072. return this[_symbol_utils.$getParent]();
  56073. }
  56074. [_symbol_utils.$getChildren]() {
  56075. let name = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
  56076. if (!name) {
  56077. return this[_children];
  56078. }
  56079. return this[name];
  56080. }
  56081. [_symbol_utils.$dump]() {
  56082. const dumped = Object.create(null);
  56083. if (this[_symbol_utils.$content]) {
  56084. dumped.$content = this[_symbol_utils.$content];
  56085. }
  56086. for (const name of Object.getOwnPropertyNames(this)) {
  56087. const value = this[name];
  56088. if (value === null) {
  56089. continue;
  56090. }
  56091. if (value instanceof XFAObject) {
  56092. dumped[name] = value[_symbol_utils.$dump]();
  56093. } else if (value instanceof XFAObjectArray) {
  56094. if (!value.isEmpty()) {
  56095. dumped[name] = value.dump();
  56096. }
  56097. } else {
  56098. dumped[name] = value;
  56099. }
  56100. }
  56101. return dumped;
  56102. }
  56103. [_symbol_utils.$toStyle]() {
  56104. return null;
  56105. }
  56106. [_symbol_utils.$toHTML]() {
  56107. return _utils.HTMLResult.EMPTY;
  56108. }
  56109. *[_symbol_utils.$getContainedChildren]() {
  56110. for (const node of this[_symbol_utils.$getChildren]()) {
  56111. yield node;
  56112. }
  56113. }
  56114. *[_filteredChildrenGenerator](filter, include) {
  56115. for (const node of this[_symbol_utils.$getContainedChildren]()) {
  56116. if (!filter || include === filter.has(node[_symbol_utils.$nodeName])) {
  56117. const availableSpace = this[_symbol_utils.$getAvailableSpace]();
  56118. const res = node[_symbol_utils.$toHTML](availableSpace);
  56119. if (!res.success) {
  56120. this[_symbol_utils.$extra].failingNode = node;
  56121. }
  56122. yield res;
  56123. }
  56124. }
  56125. }
  56126. [_symbol_utils.$flushHTML]() {
  56127. return null;
  56128. }
  56129. [_symbol_utils.$addHTML](html, bbox) {
  56130. this[_symbol_utils.$extra].children.push(html);
  56131. }
  56132. [_symbol_utils.$getAvailableSpace]() {}
  56133. [_symbol_utils.$childrenToHTML](_ref) {
  56134. let {
  56135. filter = null,
  56136. include = true
  56137. } = _ref;
  56138. if (!this[_symbol_utils.$extra].generator) {
  56139. this[_symbol_utils.$extra].generator = this[_filteredChildrenGenerator](filter, include);
  56140. } else {
  56141. const availableSpace = this[_symbol_utils.$getAvailableSpace]();
  56142. const res = this[_symbol_utils.$extra].failingNode[_symbol_utils.$toHTML](availableSpace);
  56143. if (!res.success) {
  56144. return res;
  56145. }
  56146. if (res.html) {
  56147. this[_symbol_utils.$addHTML](res.html, res.bbox);
  56148. }
  56149. delete this[_symbol_utils.$extra].failingNode;
  56150. }
  56151. while (true) {
  56152. const gen = this[_symbol_utils.$extra].generator.next();
  56153. if (gen.done) {
  56154. break;
  56155. }
  56156. const res = gen.value;
  56157. if (!res.success) {
  56158. return res;
  56159. }
  56160. if (res.html) {
  56161. this[_symbol_utils.$addHTML](res.html, res.bbox);
  56162. }
  56163. }
  56164. this[_symbol_utils.$extra].generator = null;
  56165. return _utils.HTMLResult.EMPTY;
  56166. }
  56167. [_symbol_utils.$setSetAttributes](attributes) {
  56168. this[_setAttributes] = new Set(Object.keys(attributes));
  56169. }
  56170. [_getUnsetAttributes](protoAttributes) {
  56171. const allAttr = this[_attributeNames];
  56172. const setAttr = this[_setAttributes];
  56173. return [...protoAttributes].filter(x => allAttr.has(x) && !setAttr.has(x));
  56174. }
  56175. [_symbol_utils.$resolvePrototypes](ids) {
  56176. let ancestors = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : new Set();
  56177. for (const child of this[_children]) {
  56178. child[_resolvePrototypesHelper](ids, ancestors);
  56179. }
  56180. }
  56181. [_resolvePrototypesHelper](ids, ancestors) {
  56182. const proto = this[_getPrototype](ids, ancestors);
  56183. if (proto) {
  56184. this[_applyPrototype](proto, ids, ancestors);
  56185. } else {
  56186. this[_symbol_utils.$resolvePrototypes](ids, ancestors);
  56187. }
  56188. }
  56189. [_getPrototype](ids, ancestors) {
  56190. const {
  56191. use,
  56192. usehref
  56193. } = this;
  56194. if (!use && !usehref) {
  56195. return null;
  56196. }
  56197. let proto = null;
  56198. let somExpression = null;
  56199. let id = null;
  56200. let ref = use;
  56201. if (usehref) {
  56202. ref = usehref;
  56203. if (usehref.startsWith("#som(") && usehref.endsWith(")")) {
  56204. somExpression = usehref.slice("#som(".length, -1);
  56205. } else if (usehref.startsWith(".#som(") && usehref.endsWith(")")) {
  56206. somExpression = usehref.slice(".#som(".length, -1);
  56207. } else if (usehref.startsWith("#")) {
  56208. id = usehref.slice(1);
  56209. } else if (usehref.startsWith(".#")) {
  56210. id = usehref.slice(2);
  56211. }
  56212. } else if (use.startsWith("#")) {
  56213. id = use.slice(1);
  56214. } else {
  56215. somExpression = use;
  56216. }
  56217. this.use = this.usehref = "";
  56218. if (id) {
  56219. proto = ids.get(id);
  56220. } else {
  56221. proto = (0, _som.searchNode)(ids.get(_symbol_utils.$root), this, somExpression, true, false);
  56222. if (proto) {
  56223. proto = proto[0];
  56224. }
  56225. }
  56226. if (!proto) {
  56227. (0, _util.warn)(`XFA - Invalid prototype reference: ${ref}.`);
  56228. return null;
  56229. }
  56230. if (proto[_symbol_utils.$nodeName] !== this[_symbol_utils.$nodeName]) {
  56231. (0, _util.warn)(`XFA - Incompatible prototype: ${proto[_symbol_utils.$nodeName]} !== ${this[_symbol_utils.$nodeName]}.`);
  56232. return null;
  56233. }
  56234. if (ancestors.has(proto)) {
  56235. (0, _util.warn)(`XFA - Cycle detected in prototypes use.`);
  56236. return null;
  56237. }
  56238. ancestors.add(proto);
  56239. const protoProto = proto[_getPrototype](ids, ancestors);
  56240. if (protoProto) {
  56241. proto[_applyPrototype](protoProto, ids, ancestors);
  56242. }
  56243. proto[_symbol_utils.$resolvePrototypes](ids, ancestors);
  56244. ancestors.delete(proto);
  56245. return proto;
  56246. }
  56247. [_applyPrototype](proto, ids, ancestors) {
  56248. if (ancestors.has(proto)) {
  56249. (0, _util.warn)(`XFA - Cycle detected in prototypes use.`);
  56250. return;
  56251. }
  56252. if (!this[_symbol_utils.$content] && proto[_symbol_utils.$content]) {
  56253. this[_symbol_utils.$content] = proto[_symbol_utils.$content];
  56254. }
  56255. const newAncestors = new Set(ancestors);
  56256. newAncestors.add(proto);
  56257. for (const unsetAttrName of this[_getUnsetAttributes](proto[_setAttributes])) {
  56258. this[unsetAttrName] = proto[unsetAttrName];
  56259. if (this[_setAttributes]) {
  56260. this[_setAttributes].add(unsetAttrName);
  56261. }
  56262. }
  56263. for (const name of Object.getOwnPropertyNames(this)) {
  56264. if (this[_attributeNames].has(name)) {
  56265. continue;
  56266. }
  56267. const value = this[name];
  56268. const protoValue = proto[name];
  56269. if (value instanceof XFAObjectArray) {
  56270. for (const child of value[_children]) {
  56271. child[_resolvePrototypesHelper](ids, ancestors);
  56272. }
  56273. for (let i = value[_children].length, ii = protoValue[_children].length; i < ii; i++) {
  56274. const child = proto[_children][i][_symbol_utils.$clone]();
  56275. if (value.push(child)) {
  56276. child[_parent] = this;
  56277. this[_children].push(child);
  56278. child[_resolvePrototypesHelper](ids, ancestors);
  56279. } else {
  56280. break;
  56281. }
  56282. }
  56283. continue;
  56284. }
  56285. if (value !== null) {
  56286. value[_symbol_utils.$resolvePrototypes](ids, ancestors);
  56287. if (protoValue) {
  56288. value[_applyPrototype](protoValue, ids, ancestors);
  56289. }
  56290. continue;
  56291. }
  56292. if (protoValue !== null) {
  56293. const child = protoValue[_symbol_utils.$clone]();
  56294. child[_parent] = this;
  56295. this[name] = child;
  56296. this[_children].push(child);
  56297. child[_resolvePrototypesHelper](ids, ancestors);
  56298. }
  56299. }
  56300. }
  56301. static [_cloneAttribute](obj) {
  56302. if (Array.isArray(obj)) {
  56303. return obj.map(x => XFAObject[_cloneAttribute](x));
  56304. }
  56305. if (typeof obj === "object" && obj !== null) {
  56306. return Object.assign({}, obj);
  56307. }
  56308. return obj;
  56309. }
  56310. [_symbol_utils.$clone]() {
  56311. const clone = Object.create(Object.getPrototypeOf(this));
  56312. for (const $symbol of Object.getOwnPropertySymbols(this)) {
  56313. try {
  56314. clone[$symbol] = this[$symbol];
  56315. } catch {
  56316. (0, _util.shadow)(clone, $symbol, this[$symbol]);
  56317. }
  56318. }
  56319. clone[_symbol_utils.$uid] = `${clone[_symbol_utils.$nodeName]}${uid++}`;
  56320. clone[_children] = [];
  56321. for (const name of Object.getOwnPropertyNames(this)) {
  56322. if (this[_attributeNames].has(name)) {
  56323. clone[name] = XFAObject[_cloneAttribute](this[name]);
  56324. continue;
  56325. }
  56326. const value = this[name];
  56327. clone[name] = value instanceof XFAObjectArray ? new XFAObjectArray(value[_max]) : null;
  56328. }
  56329. for (const child of this[_children]) {
  56330. const name = child[_symbol_utils.$nodeName];
  56331. const clonedChild = child[_symbol_utils.$clone]();
  56332. clone[_children].push(clonedChild);
  56333. clonedChild[_parent] = clone;
  56334. if (clone[name] === null) {
  56335. clone[name] = clonedChild;
  56336. } else {
  56337. clone[name][_children].push(clonedChild);
  56338. }
  56339. }
  56340. return clone;
  56341. }
  56342. [_symbol_utils.$getChildren]() {
  56343. let name = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
  56344. if (!name) {
  56345. return this[_children];
  56346. }
  56347. return this[_children].filter(c => c[_symbol_utils.$nodeName] === name);
  56348. }
  56349. [_symbol_utils.$getChildrenByClass](name) {
  56350. return this[name];
  56351. }
  56352. [_symbol_utils.$getChildrenByName](name, allTransparent) {
  56353. let first = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
  56354. return Array.from(this[_symbol_utils.$getChildrenByNameIt](name, allTransparent, first));
  56355. }
  56356. [_symbol_utils.$getChildrenByNameIt](name, allTransparent) {
  56357. var _this = this;
  56358. let first = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
  56359. return function* () {
  56360. if (name === "parent") {
  56361. yield _this[_parent];
  56362. return;
  56363. }
  56364. for (const child of _this[_children]) {
  56365. if (child[_symbol_utils.$nodeName] === name) {
  56366. yield child;
  56367. }
  56368. if (child.name === name) {
  56369. yield child;
  56370. }
  56371. if (allTransparent || child[_symbol_utils.$isTransparent]()) {
  56372. yield* child[_symbol_utils.$getChildrenByNameIt](name, allTransparent, false);
  56373. }
  56374. }
  56375. if (first && _this[_attributeNames].has(name)) {
  56376. yield new XFAAttribute(_this, name, _this[name]);
  56377. }
  56378. }();
  56379. }
  56380. }
  56381. exports.XFAObject = XFAObject;
  56382. class XFAObjectArray {
  56383. constructor() {
  56384. let max = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : Infinity;
  56385. this[_max] = max;
  56386. this[_children] = [];
  56387. }
  56388. get isXFAObject() {
  56389. return false;
  56390. }
  56391. get isXFAObjectArray() {
  56392. return true;
  56393. }
  56394. push(child) {
  56395. const len = this[_children].length;
  56396. if (len <= this[_max]) {
  56397. this[_children].push(child);
  56398. return true;
  56399. }
  56400. (0, _util.warn)(`XFA - node "${child[_symbol_utils.$nodeName]}" accepts no more than ${this[_max]} children`);
  56401. return false;
  56402. }
  56403. isEmpty() {
  56404. return this[_children].length === 0;
  56405. }
  56406. dump() {
  56407. return this[_children].length === 1 ? this[_children][0][_symbol_utils.$dump]() : this[_children].map(x => x[_symbol_utils.$dump]());
  56408. }
  56409. [_symbol_utils.$clone]() {
  56410. const clone = new XFAObjectArray(this[_max]);
  56411. clone[_children] = this[_children].map(c => c[_symbol_utils.$clone]());
  56412. return clone;
  56413. }
  56414. get children() {
  56415. return this[_children];
  56416. }
  56417. clear() {
  56418. this[_children].length = 0;
  56419. }
  56420. }
  56421. exports.XFAObjectArray = XFAObjectArray;
  56422. class XFAAttribute {
  56423. constructor(node, name, value) {
  56424. this[_parent] = node;
  56425. this[_symbol_utils.$nodeName] = name;
  56426. this[_symbol_utils.$content] = value;
  56427. this[_symbol_utils.$consumed] = false;
  56428. this[_symbol_utils.$uid] = `attribute${uid++}`;
  56429. }
  56430. [_symbol_utils.$getParent]() {
  56431. return this[_parent];
  56432. }
  56433. [_symbol_utils.$isDataValue]() {
  56434. return true;
  56435. }
  56436. [_symbol_utils.$getDataValue]() {
  56437. return this[_symbol_utils.$content].trim();
  56438. }
  56439. [_symbol_utils.$setValue](value) {
  56440. value = value.value || "";
  56441. this[_symbol_utils.$content] = value.toString();
  56442. }
  56443. [_symbol_utils.$text]() {
  56444. return this[_symbol_utils.$content];
  56445. }
  56446. [_symbol_utils.$isDescendent](parent) {
  56447. return this[_parent] === parent || this[_parent][_symbol_utils.$isDescendent](parent);
  56448. }
  56449. }
  56450. exports.XFAAttribute = XFAAttribute;
  56451. class XmlObject extends XFAObject {
  56452. constructor(nsId, name) {
  56453. let attributes = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
  56454. super(nsId, name);
  56455. this[_symbol_utils.$content] = "";
  56456. this[_dataValue] = null;
  56457. if (name !== "#text") {
  56458. const map = new Map();
  56459. this[_attributes] = map;
  56460. for (const [attrName, value] of Object.entries(attributes)) {
  56461. map.set(attrName, new XFAAttribute(this, attrName, value));
  56462. }
  56463. if (attributes.hasOwnProperty(_symbol_utils.$nsAttributes)) {
  56464. const dataNode = attributes[_symbol_utils.$nsAttributes].xfa.dataNode;
  56465. if (dataNode !== undefined) {
  56466. if (dataNode === "dataGroup") {
  56467. this[_dataValue] = false;
  56468. } else if (dataNode === "dataValue") {
  56469. this[_dataValue] = true;
  56470. }
  56471. }
  56472. }
  56473. }
  56474. this[_symbol_utils.$consumed] = false;
  56475. }
  56476. [_symbol_utils.$toString](buf) {
  56477. const tagName = this[_symbol_utils.$nodeName];
  56478. if (tagName === "#text") {
  56479. buf.push((0, _core_utils.encodeToXmlString)(this[_symbol_utils.$content]));
  56480. return;
  56481. }
  56482. const utf8TagName = (0, _util.utf8StringToString)(tagName);
  56483. const prefix = this[_symbol_utils.$namespaceId] === NS_DATASETS ? "xfa:" : "";
  56484. buf.push(`<${prefix}${utf8TagName}`);
  56485. for (const [name, value] of this[_attributes].entries()) {
  56486. const utf8Name = (0, _util.utf8StringToString)(name);
  56487. buf.push(` ${utf8Name}="${(0, _core_utils.encodeToXmlString)(value[_symbol_utils.$content])}"`);
  56488. }
  56489. if (this[_dataValue] !== null) {
  56490. if (this[_dataValue]) {
  56491. buf.push(` xfa:dataNode="dataValue"`);
  56492. } else {
  56493. buf.push(` xfa:dataNode="dataGroup"`);
  56494. }
  56495. }
  56496. if (!this[_symbol_utils.$content] && this[_children].length === 0) {
  56497. buf.push("/>");
  56498. return;
  56499. }
  56500. buf.push(">");
  56501. if (this[_symbol_utils.$content]) {
  56502. if (typeof this[_symbol_utils.$content] === "string") {
  56503. buf.push((0, _core_utils.encodeToXmlString)(this[_symbol_utils.$content]));
  56504. } else {
  56505. this[_symbol_utils.$content][_symbol_utils.$toString](buf);
  56506. }
  56507. } else {
  56508. for (const child of this[_children]) {
  56509. child[_symbol_utils.$toString](buf);
  56510. }
  56511. }
  56512. buf.push(`</${prefix}${utf8TagName}>`);
  56513. }
  56514. [_symbol_utils.$onChild](child) {
  56515. if (this[_symbol_utils.$content]) {
  56516. const node = new XmlObject(this[_symbol_utils.$namespaceId], "#text");
  56517. this[_symbol_utils.$appendChild](node);
  56518. node[_symbol_utils.$content] = this[_symbol_utils.$content];
  56519. this[_symbol_utils.$content] = "";
  56520. }
  56521. this[_symbol_utils.$appendChild](child);
  56522. return true;
  56523. }
  56524. [_symbol_utils.$onText](str) {
  56525. this[_symbol_utils.$content] += str;
  56526. }
  56527. [_symbol_utils.$finalize]() {
  56528. if (this[_symbol_utils.$content] && this[_children].length > 0) {
  56529. const node = new XmlObject(this[_symbol_utils.$namespaceId], "#text");
  56530. this[_symbol_utils.$appendChild](node);
  56531. node[_symbol_utils.$content] = this[_symbol_utils.$content];
  56532. delete this[_symbol_utils.$content];
  56533. }
  56534. }
  56535. [_symbol_utils.$toHTML]() {
  56536. if (this[_symbol_utils.$nodeName] === "#text") {
  56537. return _utils.HTMLResult.success({
  56538. name: "#text",
  56539. value: this[_symbol_utils.$content]
  56540. });
  56541. }
  56542. return _utils.HTMLResult.EMPTY;
  56543. }
  56544. [_symbol_utils.$getChildren]() {
  56545. let name = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
  56546. if (!name) {
  56547. return this[_children];
  56548. }
  56549. return this[_children].filter(c => c[_symbol_utils.$nodeName] === name);
  56550. }
  56551. [_symbol_utils.$getAttributes]() {
  56552. return this[_attributes];
  56553. }
  56554. [_symbol_utils.$getChildrenByClass](name) {
  56555. const value = this[_attributes].get(name);
  56556. if (value !== undefined) {
  56557. return value;
  56558. }
  56559. return this[_symbol_utils.$getChildren](name);
  56560. }
  56561. *[_symbol_utils.$getChildrenByNameIt](name, allTransparent) {
  56562. const value = this[_attributes].get(name);
  56563. if (value) {
  56564. yield value;
  56565. }
  56566. for (const child of this[_children]) {
  56567. if (child[_symbol_utils.$nodeName] === name) {
  56568. yield child;
  56569. }
  56570. if (allTransparent) {
  56571. yield* child[_symbol_utils.$getChildrenByNameIt](name, allTransparent);
  56572. }
  56573. }
  56574. }
  56575. *[_symbol_utils.$getAttributeIt](name, skipConsumed) {
  56576. const value = this[_attributes].get(name);
  56577. if (value && (!skipConsumed || !value[_symbol_utils.$consumed])) {
  56578. yield value;
  56579. }
  56580. for (const child of this[_children]) {
  56581. yield* child[_symbol_utils.$getAttributeIt](name, skipConsumed);
  56582. }
  56583. }
  56584. *[_symbol_utils.$getRealChildrenByNameIt](name, allTransparent, skipConsumed) {
  56585. for (const child of this[_children]) {
  56586. if (child[_symbol_utils.$nodeName] === name && (!skipConsumed || !child[_symbol_utils.$consumed])) {
  56587. yield child;
  56588. }
  56589. if (allTransparent) {
  56590. yield* child[_symbol_utils.$getRealChildrenByNameIt](name, allTransparent, skipConsumed);
  56591. }
  56592. }
  56593. }
  56594. [_symbol_utils.$isDataValue]() {
  56595. if (this[_dataValue] === null) {
  56596. return this[_children].length === 0 || this[_children][0][_symbol_utils.$namespaceId] === _namespaces.NamespaceIds.xhtml.id;
  56597. }
  56598. return this[_dataValue];
  56599. }
  56600. [_symbol_utils.$getDataValue]() {
  56601. if (this[_dataValue] === null) {
  56602. if (this[_children].length === 0) {
  56603. return this[_symbol_utils.$content].trim();
  56604. }
  56605. if (this[_children][0][_symbol_utils.$namespaceId] === _namespaces.NamespaceIds.xhtml.id) {
  56606. return this[_children][0][_symbol_utils.$text]().trim();
  56607. }
  56608. return null;
  56609. }
  56610. return this[_symbol_utils.$content].trim();
  56611. }
  56612. [_symbol_utils.$setValue](value) {
  56613. value = value.value || "";
  56614. this[_symbol_utils.$content] = value.toString();
  56615. }
  56616. [_symbol_utils.$dump]() {
  56617. let hasNS = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  56618. const dumped = Object.create(null);
  56619. if (hasNS) {
  56620. dumped.$ns = this[_symbol_utils.$namespaceId];
  56621. }
  56622. if (this[_symbol_utils.$content]) {
  56623. dumped.$content = this[_symbol_utils.$content];
  56624. }
  56625. dumped.$name = this[_symbol_utils.$nodeName];
  56626. dumped.children = [];
  56627. for (const child of this[_children]) {
  56628. dumped.children.push(child[_symbol_utils.$dump](hasNS));
  56629. }
  56630. dumped.attributes = Object.create(null);
  56631. for (const [name, value] of this[_attributes]) {
  56632. dumped.attributes[name] = value[_symbol_utils.$content];
  56633. }
  56634. return dumped;
  56635. }
  56636. }
  56637. exports.XmlObject = XmlObject;
  56638. class ContentObject extends XFAObject {
  56639. constructor(nsId, name) {
  56640. super(nsId, name);
  56641. this[_symbol_utils.$content] = "";
  56642. }
  56643. [_symbol_utils.$onText](text) {
  56644. this[_symbol_utils.$content] += text;
  56645. }
  56646. [_symbol_utils.$finalize]() {}
  56647. }
  56648. exports.ContentObject = ContentObject;
  56649. class OptionObject extends ContentObject {
  56650. constructor(nsId, name, options) {
  56651. super(nsId, name);
  56652. this[_options] = options;
  56653. }
  56654. [_symbol_utils.$finalize]() {
  56655. this[_symbol_utils.$content] = (0, _utils.getKeyword)({
  56656. data: this[_symbol_utils.$content],
  56657. defaultValue: this[_options][0],
  56658. validate: k => this[_options].includes(k)
  56659. });
  56660. }
  56661. [_symbol_utils.$clean](builder) {
  56662. super[_symbol_utils.$clean](builder);
  56663. delete this[_options];
  56664. }
  56665. }
  56666. exports.OptionObject = OptionObject;
  56667. class StringObject extends ContentObject {
  56668. [_symbol_utils.$finalize]() {
  56669. this[_symbol_utils.$content] = this[_symbol_utils.$content].trim();
  56670. }
  56671. }
  56672. exports.StringObject = StringObject;
  56673. class IntegerObject extends ContentObject {
  56674. constructor(nsId, name, defaultValue, validator) {
  56675. super(nsId, name);
  56676. this[_defaultValue] = defaultValue;
  56677. this[_validator] = validator;
  56678. }
  56679. [_symbol_utils.$finalize]() {
  56680. this[_symbol_utils.$content] = (0, _utils.getInteger)({
  56681. data: this[_symbol_utils.$content],
  56682. defaultValue: this[_defaultValue],
  56683. validate: this[_validator]
  56684. });
  56685. }
  56686. [_symbol_utils.$clean](builder) {
  56687. super[_symbol_utils.$clean](builder);
  56688. delete this[_defaultValue];
  56689. delete this[_validator];
  56690. }
  56691. }
  56692. exports.IntegerObject = IntegerObject;
  56693. class Option01 extends IntegerObject {
  56694. constructor(nsId, name) {
  56695. super(nsId, name, 0, n => n === 1);
  56696. }
  56697. }
  56698. exports.Option01 = Option01;
  56699. class Option10 extends IntegerObject {
  56700. constructor(nsId, name) {
  56701. super(nsId, name, 1, n => n === 0);
  56702. }
  56703. }
  56704. exports.Option10 = Option10;
  56705. /***/ }),
  56706. /* 242 */
  56707. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  56708. Object.defineProperty(exports, "__esModule", ({
  56709. value: true
  56710. }));
  56711. exports.createDataNode = createDataNode;
  56712. exports.searchNode = searchNode;
  56713. __w_pdfjs_require__(140);
  56714. var _symbol_utils = __w_pdfjs_require__(229);
  56715. var _util = __w_pdfjs_require__(145);
  56716. const namePattern = /^[^.[]+/;
  56717. const indexPattern = /^[^\]]+/;
  56718. const operators = {
  56719. dot: 0,
  56720. dotDot: 1,
  56721. dotHash: 2,
  56722. dotBracket: 3,
  56723. dotParen: 4
  56724. };
  56725. 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]]);
  56726. const somCache = new WeakMap();
  56727. function parseIndex(index) {
  56728. index = index.trim();
  56729. if (index === "*") {
  56730. return Infinity;
  56731. }
  56732. return parseInt(index, 10) || 0;
  56733. }
  56734. function parseExpression(expr, dotDotAllowed) {
  56735. let noExpr = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
  56736. let match = expr.match(namePattern);
  56737. if (!match) {
  56738. return null;
  56739. }
  56740. let [name] = match;
  56741. const parsed = [{
  56742. name,
  56743. cacheName: "." + name,
  56744. index: 0,
  56745. js: null,
  56746. formCalc: null,
  56747. operator: operators.dot
  56748. }];
  56749. let pos = name.length;
  56750. while (pos < expr.length) {
  56751. const spos = pos;
  56752. const char = expr.charAt(pos++);
  56753. if (char === "[") {
  56754. match = expr.slice(pos).match(indexPattern);
  56755. if (!match) {
  56756. (0, _util.warn)("XFA - Invalid index in SOM expression");
  56757. return null;
  56758. }
  56759. parsed.at(-1).index = parseIndex(match[0]);
  56760. pos += match[0].length + 1;
  56761. continue;
  56762. }
  56763. let operator;
  56764. switch (expr.charAt(pos)) {
  56765. case ".":
  56766. if (!dotDotAllowed) {
  56767. return null;
  56768. }
  56769. pos++;
  56770. operator = operators.dotDot;
  56771. break;
  56772. case "#":
  56773. pos++;
  56774. operator = operators.dotHash;
  56775. break;
  56776. case "[":
  56777. if (noExpr) {
  56778. (0, _util.warn)("XFA - SOM expression contains a FormCalc subexpression which is not supported for now.");
  56779. return null;
  56780. }
  56781. operator = operators.dotBracket;
  56782. break;
  56783. case "(":
  56784. if (noExpr) {
  56785. (0, _util.warn)("XFA - SOM expression contains a JavaScript subexpression which is not supported for now.");
  56786. return null;
  56787. }
  56788. operator = operators.dotParen;
  56789. break;
  56790. default:
  56791. operator = operators.dot;
  56792. break;
  56793. }
  56794. match = expr.slice(pos).match(namePattern);
  56795. if (!match) {
  56796. break;
  56797. }
  56798. [name] = match;
  56799. pos += name.length;
  56800. parsed.push({
  56801. name,
  56802. cacheName: expr.slice(spos, pos),
  56803. operator,
  56804. index: 0,
  56805. js: null,
  56806. formCalc: null
  56807. });
  56808. }
  56809. return parsed;
  56810. }
  56811. function searchNode(root, container, expr) {
  56812. let dotDotAllowed = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : true;
  56813. let useCache = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : true;
  56814. const parsed = parseExpression(expr, dotDotAllowed);
  56815. if (!parsed) {
  56816. return null;
  56817. }
  56818. const fn = shortcuts.get(parsed[0].name);
  56819. let i = 0;
  56820. let isQualified;
  56821. if (fn) {
  56822. isQualified = true;
  56823. root = [fn(root, container)];
  56824. i = 1;
  56825. } else {
  56826. isQualified = container === null;
  56827. root = [container || root];
  56828. }
  56829. for (let ii = parsed.length; i < ii; i++) {
  56830. const {
  56831. name,
  56832. cacheName,
  56833. operator,
  56834. index
  56835. } = parsed[i];
  56836. const nodes = [];
  56837. for (const node of root) {
  56838. if (!node.isXFAObject) {
  56839. continue;
  56840. }
  56841. let children, cached;
  56842. if (useCache) {
  56843. cached = somCache.get(node);
  56844. if (!cached) {
  56845. cached = new Map();
  56846. somCache.set(node, cached);
  56847. }
  56848. children = cached.get(cacheName);
  56849. }
  56850. if (!children) {
  56851. switch (operator) {
  56852. case operators.dot:
  56853. children = node[_symbol_utils.$getChildrenByName](name, false);
  56854. break;
  56855. case operators.dotDot:
  56856. children = node[_symbol_utils.$getChildrenByName](name, true);
  56857. break;
  56858. case operators.dotHash:
  56859. children = node[_symbol_utils.$getChildrenByClass](name);
  56860. children = children.isXFAObjectArray ? children.children : [children];
  56861. break;
  56862. default:
  56863. break;
  56864. }
  56865. if (useCache) {
  56866. cached.set(cacheName, children);
  56867. }
  56868. }
  56869. if (children.length > 0) {
  56870. nodes.push(children);
  56871. }
  56872. }
  56873. if (nodes.length === 0 && !isQualified && i === 0) {
  56874. const parent = container[_symbol_utils.$getParent]();
  56875. container = parent;
  56876. if (!container) {
  56877. return null;
  56878. }
  56879. i = -1;
  56880. root = [container];
  56881. continue;
  56882. }
  56883. root = isFinite(index) ? nodes.filter(node => index < node.length).map(node => node[index]) : nodes.flat();
  56884. }
  56885. if (root.length === 0) {
  56886. return null;
  56887. }
  56888. return root;
  56889. }
  56890. function createDataNode(root, container, expr) {
  56891. const parsed = parseExpression(expr);
  56892. if (!parsed) {
  56893. return null;
  56894. }
  56895. if (parsed.some(x => x.operator === operators.dotDot)) {
  56896. return null;
  56897. }
  56898. const fn = shortcuts.get(parsed[0].name);
  56899. let i = 0;
  56900. if (fn) {
  56901. root = fn(root, container);
  56902. i = 1;
  56903. } else {
  56904. root = container || root;
  56905. }
  56906. for (let ii = parsed.length; i < ii; i++) {
  56907. const {
  56908. name,
  56909. operator,
  56910. index
  56911. } = parsed[i];
  56912. if (!isFinite(index)) {
  56913. parsed[i].index = 0;
  56914. return root.createNodes(parsed.slice(i));
  56915. }
  56916. let children;
  56917. switch (operator) {
  56918. case operators.dot:
  56919. children = root[_symbol_utils.$getChildrenByName](name, false);
  56920. break;
  56921. case operators.dotDot:
  56922. children = root[_symbol_utils.$getChildrenByName](name, true);
  56923. break;
  56924. case operators.dotHash:
  56925. children = root[_symbol_utils.$getChildrenByClass](name);
  56926. children = children.isXFAObjectArray ? children.children : [children];
  56927. break;
  56928. default:
  56929. break;
  56930. }
  56931. if (children.length === 0) {
  56932. return root.createNodes(parsed.slice(i));
  56933. }
  56934. if (index < children.length) {
  56935. const child = children[index];
  56936. if (!child.isXFAObject) {
  56937. (0, _util.warn)(`XFA - Cannot create a node.`);
  56938. return null;
  56939. }
  56940. root = child;
  56941. } else {
  56942. parsed[i].index = index - children.length;
  56943. return root.createNodes(parsed.slice(i));
  56944. }
  56945. }
  56946. return null;
  56947. }
  56948. /***/ }),
  56949. /* 243 */
  56950. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  56951. Object.defineProperty(exports, "__esModule", ({
  56952. value: true
  56953. }));
  56954. exports.DataHandler = void 0;
  56955. __w_pdfjs_require__(140);
  56956. var _symbol_utils = __w_pdfjs_require__(229);
  56957. class DataHandler {
  56958. constructor(root, data) {
  56959. this.data = data;
  56960. this.dataset = root.datasets || null;
  56961. }
  56962. serialize(storage) {
  56963. const stack = [[-1, this.data[_symbol_utils.$getChildren]()]];
  56964. while (stack.length > 0) {
  56965. const last = stack.at(-1);
  56966. const [i, children] = last;
  56967. if (i + 1 === children.length) {
  56968. stack.pop();
  56969. continue;
  56970. }
  56971. const child = children[++last[0]];
  56972. const storageEntry = storage.get(child[_symbol_utils.$uid]);
  56973. if (storageEntry) {
  56974. child[_symbol_utils.$setValue](storageEntry);
  56975. } else {
  56976. const attributes = child[_symbol_utils.$getAttributes]();
  56977. for (const value of attributes.values()) {
  56978. const entry = storage.get(value[_symbol_utils.$uid]);
  56979. if (entry) {
  56980. value[_symbol_utils.$setValue](entry);
  56981. break;
  56982. }
  56983. }
  56984. }
  56985. const nodes = child[_symbol_utils.$getChildren]();
  56986. if (nodes.length > 0) {
  56987. stack.push([-1, nodes]);
  56988. }
  56989. }
  56990. const buf = [`<xfa:datasets xmlns:xfa="http://www.xfa.org/schema/xfa-data/1.0/">`];
  56991. if (this.dataset) {
  56992. for (const child of this.dataset[_symbol_utils.$getChildren]()) {
  56993. if (child[_symbol_utils.$nodeName] !== "data") {
  56994. child[_symbol_utils.$toString](buf);
  56995. }
  56996. }
  56997. }
  56998. this.data[_symbol_utils.$toString](buf);
  56999. buf.push("</xfa:datasets>");
  57000. return buf.join("");
  57001. }
  57002. }
  57003. exports.DataHandler = DataHandler;
  57004. /***/ }),
  57005. /* 244 */
  57006. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  57007. Object.defineProperty(exports, "__esModule", ({
  57008. value: true
  57009. }));
  57010. exports.XFAParser = void 0;
  57011. __w_pdfjs_require__(116);
  57012. __w_pdfjs_require__(127);
  57013. __w_pdfjs_require__(129);
  57014. __w_pdfjs_require__(132);
  57015. __w_pdfjs_require__(134);
  57016. __w_pdfjs_require__(136);
  57017. __w_pdfjs_require__(138);
  57018. __w_pdfjs_require__(140);
  57019. var _symbol_utils = __w_pdfjs_require__(229);
  57020. var _xml_parser = __w_pdfjs_require__(218);
  57021. var _builder = __w_pdfjs_require__(245);
  57022. var _util = __w_pdfjs_require__(145);
  57023. class XFAParser extends _xml_parser.XMLParserBase {
  57024. constructor() {
  57025. let rootNameSpace = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
  57026. let richText = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  57027. super();
  57028. this._builder = new _builder.Builder(rootNameSpace);
  57029. this._stack = [];
  57030. this._globalData = {
  57031. usedTypefaces: new Set()
  57032. };
  57033. this._ids = new Map();
  57034. this._current = this._builder.buildRoot(this._ids);
  57035. this._errorCode = _xml_parser.XMLParserErrorCode.NoError;
  57036. this._whiteRegex = /^\s+$/;
  57037. this._nbsps = /\xa0+/g;
  57038. this._richText = richText;
  57039. }
  57040. parse(data) {
  57041. this.parseXml(data);
  57042. if (this._errorCode !== _xml_parser.XMLParserErrorCode.NoError) {
  57043. return undefined;
  57044. }
  57045. this._current[_symbol_utils.$finalize]();
  57046. return this._current.element;
  57047. }
  57048. onText(text) {
  57049. text = text.replace(this._nbsps, match => match.slice(1) + " ");
  57050. if (this._richText || this._current[_symbol_utils.$acceptWhitespace]()) {
  57051. this._current[_symbol_utils.$onText](text, this._richText);
  57052. return;
  57053. }
  57054. if (this._whiteRegex.test(text)) {
  57055. return;
  57056. }
  57057. this._current[_symbol_utils.$onText](text.trim());
  57058. }
  57059. onCdata(text) {
  57060. this._current[_symbol_utils.$onText](text);
  57061. }
  57062. _mkAttributes(attributes, tagName) {
  57063. let namespace = null;
  57064. let prefixes = null;
  57065. const attributeObj = Object.create({});
  57066. for (const {
  57067. name,
  57068. value
  57069. } of attributes) {
  57070. if (name === "xmlns") {
  57071. if (!namespace) {
  57072. namespace = value;
  57073. } else {
  57074. (0, _util.warn)(`XFA - multiple namespace definition in <${tagName}>`);
  57075. }
  57076. } else if (name.startsWith("xmlns:")) {
  57077. const prefix = name.substring("xmlns:".length);
  57078. if (!prefixes) {
  57079. prefixes = [];
  57080. }
  57081. prefixes.push({
  57082. prefix,
  57083. value
  57084. });
  57085. } else {
  57086. const i = name.indexOf(":");
  57087. if (i === -1) {
  57088. attributeObj[name] = value;
  57089. } else {
  57090. let nsAttrs = attributeObj[_symbol_utils.$nsAttributes];
  57091. if (!nsAttrs) {
  57092. nsAttrs = attributeObj[_symbol_utils.$nsAttributes] = Object.create(null);
  57093. }
  57094. const [ns, attrName] = [name.slice(0, i), name.slice(i + 1)];
  57095. const attrs = nsAttrs[ns] ||= Object.create(null);
  57096. attrs[attrName] = value;
  57097. }
  57098. }
  57099. }
  57100. return [namespace, prefixes, attributeObj];
  57101. }
  57102. _getNameAndPrefix(name, nsAgnostic) {
  57103. const i = name.indexOf(":");
  57104. if (i === -1) {
  57105. return [name, null];
  57106. }
  57107. return [name.substring(i + 1), nsAgnostic ? "" : name.substring(0, i)];
  57108. }
  57109. onBeginElement(tagName, attributes, isEmpty) {
  57110. const [namespace, prefixes, attributesObj] = this._mkAttributes(attributes, tagName);
  57111. const [name, nsPrefix] = this._getNameAndPrefix(tagName, this._builder.isNsAgnostic());
  57112. const node = this._builder.build({
  57113. nsPrefix,
  57114. name,
  57115. attributes: attributesObj,
  57116. namespace,
  57117. prefixes
  57118. });
  57119. node[_symbol_utils.$globalData] = this._globalData;
  57120. if (isEmpty) {
  57121. node[_symbol_utils.$finalize]();
  57122. if (this._current[_symbol_utils.$onChild](node)) {
  57123. node[_symbol_utils.$setId](this._ids);
  57124. }
  57125. node[_symbol_utils.$clean](this._builder);
  57126. return;
  57127. }
  57128. this._stack.push(this._current);
  57129. this._current = node;
  57130. }
  57131. onEndElement(name) {
  57132. const node = this._current;
  57133. if (node[_symbol_utils.$isCDATAXml]() && typeof node[_symbol_utils.$content] === "string") {
  57134. const parser = new XFAParser();
  57135. parser._globalData = this._globalData;
  57136. const root = parser.parse(node[_symbol_utils.$content]);
  57137. node[_symbol_utils.$content] = null;
  57138. node[_symbol_utils.$onChild](root);
  57139. }
  57140. node[_symbol_utils.$finalize]();
  57141. this._current = this._stack.pop();
  57142. if (this._current[_symbol_utils.$onChild](node)) {
  57143. node[_symbol_utils.$setId](this._ids);
  57144. }
  57145. node[_symbol_utils.$clean](this._builder);
  57146. }
  57147. onError(code) {
  57148. this._errorCode = code;
  57149. }
  57150. }
  57151. exports.XFAParser = XFAParser;
  57152. /***/ }),
  57153. /* 245 */
  57154. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  57155. Object.defineProperty(exports, "__esModule", ({
  57156. value: true
  57157. }));
  57158. exports.Builder = void 0;
  57159. __w_pdfjs_require__(140);
  57160. var _namespaces = __w_pdfjs_require__(235);
  57161. var _symbol_utils = __w_pdfjs_require__(229);
  57162. var _setup = __w_pdfjs_require__(246);
  57163. var _template = __w_pdfjs_require__(231);
  57164. var _unknown = __w_pdfjs_require__(255);
  57165. var _util = __w_pdfjs_require__(145);
  57166. var _xfa_object = __w_pdfjs_require__(241);
  57167. class Root extends _xfa_object.XFAObject {
  57168. constructor(ids) {
  57169. super(-1, "root", Object.create(null));
  57170. this.element = null;
  57171. this[_symbol_utils.$ids] = ids;
  57172. }
  57173. [_symbol_utils.$onChild](child) {
  57174. this.element = child;
  57175. return true;
  57176. }
  57177. [_symbol_utils.$finalize]() {
  57178. super[_symbol_utils.$finalize]();
  57179. if (this.element.template instanceof _template.Template) {
  57180. this[_symbol_utils.$ids].set(_symbol_utils.$root, this.element);
  57181. this.element.template[_symbol_utils.$resolvePrototypes](this[_symbol_utils.$ids]);
  57182. this.element.template[_symbol_utils.$ids] = this[_symbol_utils.$ids];
  57183. }
  57184. }
  57185. }
  57186. class Empty extends _xfa_object.XFAObject {
  57187. constructor() {
  57188. super(-1, "", Object.create(null));
  57189. }
  57190. [_symbol_utils.$onChild](_) {
  57191. return false;
  57192. }
  57193. }
  57194. class Builder {
  57195. constructor() {
  57196. let rootNameSpace = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
  57197. this._namespaceStack = [];
  57198. this._nsAgnosticLevel = 0;
  57199. this._namespacePrefixes = new Map();
  57200. this._namespaces = new Map();
  57201. this._nextNsId = Math.max(...Object.values(_namespaces.NamespaceIds).map(_ref => {
  57202. let {
  57203. id
  57204. } = _ref;
  57205. return id;
  57206. }));
  57207. this._currentNamespace = rootNameSpace || new _unknown.UnknownNamespace(++this._nextNsId);
  57208. }
  57209. buildRoot(ids) {
  57210. return new Root(ids);
  57211. }
  57212. build(_ref2) {
  57213. let {
  57214. nsPrefix,
  57215. name,
  57216. attributes,
  57217. namespace,
  57218. prefixes
  57219. } = _ref2;
  57220. const hasNamespaceDef = namespace !== null;
  57221. if (hasNamespaceDef) {
  57222. this._namespaceStack.push(this._currentNamespace);
  57223. this._currentNamespace = this._searchNamespace(namespace);
  57224. }
  57225. if (prefixes) {
  57226. this._addNamespacePrefix(prefixes);
  57227. }
  57228. if (attributes.hasOwnProperty(_symbol_utils.$nsAttributes)) {
  57229. const dataTemplate = _setup.NamespaceSetUp.datasets;
  57230. const nsAttrs = attributes[_symbol_utils.$nsAttributes];
  57231. let xfaAttrs = null;
  57232. for (const [ns, attrs] of Object.entries(nsAttrs)) {
  57233. const nsToUse = this._getNamespaceToUse(ns);
  57234. if (nsToUse === dataTemplate) {
  57235. xfaAttrs = {
  57236. xfa: attrs
  57237. };
  57238. break;
  57239. }
  57240. }
  57241. if (xfaAttrs) {
  57242. attributes[_symbol_utils.$nsAttributes] = xfaAttrs;
  57243. } else {
  57244. delete attributes[_symbol_utils.$nsAttributes];
  57245. }
  57246. }
  57247. const namespaceToUse = this._getNamespaceToUse(nsPrefix);
  57248. const node = namespaceToUse?.[_namespaces.$buildXFAObject](name, attributes) || new Empty();
  57249. if (node[_symbol_utils.$isNsAgnostic]()) {
  57250. this._nsAgnosticLevel++;
  57251. }
  57252. if (hasNamespaceDef || prefixes || node[_symbol_utils.$isNsAgnostic]()) {
  57253. node[_symbol_utils.$cleanup] = {
  57254. hasNamespace: hasNamespaceDef,
  57255. prefixes,
  57256. nsAgnostic: node[_symbol_utils.$isNsAgnostic]()
  57257. };
  57258. }
  57259. return node;
  57260. }
  57261. isNsAgnostic() {
  57262. return this._nsAgnosticLevel > 0;
  57263. }
  57264. _searchNamespace(nsName) {
  57265. let ns = this._namespaces.get(nsName);
  57266. if (ns) {
  57267. return ns;
  57268. }
  57269. for (const [name, {
  57270. check
  57271. }] of Object.entries(_namespaces.NamespaceIds)) {
  57272. if (check(nsName)) {
  57273. ns = _setup.NamespaceSetUp[name];
  57274. if (ns) {
  57275. this._namespaces.set(nsName, ns);
  57276. return ns;
  57277. }
  57278. break;
  57279. }
  57280. }
  57281. ns = new _unknown.UnknownNamespace(++this._nextNsId);
  57282. this._namespaces.set(nsName, ns);
  57283. return ns;
  57284. }
  57285. _addNamespacePrefix(prefixes) {
  57286. for (const {
  57287. prefix,
  57288. value
  57289. } of prefixes) {
  57290. const namespace = this._searchNamespace(value);
  57291. let prefixStack = this._namespacePrefixes.get(prefix);
  57292. if (!prefixStack) {
  57293. prefixStack = [];
  57294. this._namespacePrefixes.set(prefix, prefixStack);
  57295. }
  57296. prefixStack.push(namespace);
  57297. }
  57298. }
  57299. _getNamespaceToUse(prefix) {
  57300. if (!prefix) {
  57301. return this._currentNamespace;
  57302. }
  57303. const prefixStack = this._namespacePrefixes.get(prefix);
  57304. if (prefixStack?.length > 0) {
  57305. return prefixStack.at(-1);
  57306. }
  57307. (0, _util.warn)(`Unknown namespace prefix: ${prefix}.`);
  57308. return null;
  57309. }
  57310. clean(data) {
  57311. const {
  57312. hasNamespace,
  57313. prefixes,
  57314. nsAgnostic
  57315. } = data;
  57316. if (hasNamespace) {
  57317. this._currentNamespace = this._namespaceStack.pop();
  57318. }
  57319. if (prefixes) {
  57320. prefixes.forEach(_ref3 => {
  57321. let {
  57322. prefix
  57323. } = _ref3;
  57324. this._namespacePrefixes.get(prefix).pop();
  57325. });
  57326. }
  57327. if (nsAgnostic) {
  57328. this._nsAgnosticLevel--;
  57329. }
  57330. }
  57331. }
  57332. exports.Builder = Builder;
  57333. /***/ }),
  57334. /* 246 */
  57335. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  57336. Object.defineProperty(exports, "__esModule", ({
  57337. value: true
  57338. }));
  57339. exports.NamespaceSetUp = void 0;
  57340. var _config = __w_pdfjs_require__(247);
  57341. var _connection_set = __w_pdfjs_require__(248);
  57342. var _datasets = __w_pdfjs_require__(249);
  57343. var _locale_set = __w_pdfjs_require__(250);
  57344. var _signature = __w_pdfjs_require__(251);
  57345. var _stylesheet = __w_pdfjs_require__(252);
  57346. var _template = __w_pdfjs_require__(231);
  57347. var _xdp = __w_pdfjs_require__(253);
  57348. var _xhtml = __w_pdfjs_require__(254);
  57349. const NamespaceSetUp = {
  57350. config: _config.ConfigNamespace,
  57351. connection: _connection_set.ConnectionSetNamespace,
  57352. datasets: _datasets.DatasetsNamespace,
  57353. localeSet: _locale_set.LocaleSetNamespace,
  57354. signature: _signature.SignatureNamespace,
  57355. stylesheet: _stylesheet.StylesheetNamespace,
  57356. template: _template.TemplateNamespace,
  57357. xdp: _xdp.XdpNamespace,
  57358. xhtml: _xhtml.XhtmlNamespace
  57359. };
  57360. exports.NamespaceSetUp = NamespaceSetUp;
  57361. /***/ }),
  57362. /* 247 */
  57363. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  57364. Object.defineProperty(exports, "__esModule", ({
  57365. value: true
  57366. }));
  57367. exports.ConfigNamespace = void 0;
  57368. __w_pdfjs_require__(140);
  57369. var _namespaces = __w_pdfjs_require__(235);
  57370. var _symbol_utils = __w_pdfjs_require__(229);
  57371. var _xfa_object = __w_pdfjs_require__(241);
  57372. var _utils = __w_pdfjs_require__(238);
  57373. var _util = __w_pdfjs_require__(145);
  57374. const CONFIG_NS_ID = _namespaces.NamespaceIds.config.id;
  57375. class Acrobat extends _xfa_object.XFAObject {
  57376. constructor(attributes) {
  57377. super(CONFIG_NS_ID, "acrobat", true);
  57378. this.acrobat7 = null;
  57379. this.autoSave = null;
  57380. this.common = null;
  57381. this.validate = null;
  57382. this.validateApprovalSignatures = null;
  57383. this.submitUrl = new _xfa_object.XFAObjectArray();
  57384. }
  57385. }
  57386. class Acrobat7 extends _xfa_object.XFAObject {
  57387. constructor(attributes) {
  57388. super(CONFIG_NS_ID, "acrobat7", true);
  57389. this.dynamicRender = null;
  57390. }
  57391. }
  57392. class ADBE_JSConsole extends _xfa_object.OptionObject {
  57393. constructor(attributes) {
  57394. super(CONFIG_NS_ID, "ADBE_JSConsole", ["delegate", "Enable", "Disable"]);
  57395. }
  57396. }
  57397. class ADBE_JSDebugger extends _xfa_object.OptionObject {
  57398. constructor(attributes) {
  57399. super(CONFIG_NS_ID, "ADBE_JSDebugger", ["delegate", "Enable", "Disable"]);
  57400. }
  57401. }
  57402. class AddSilentPrint extends _xfa_object.Option01 {
  57403. constructor(attributes) {
  57404. super(CONFIG_NS_ID, "addSilentPrint");
  57405. }
  57406. }
  57407. class AddViewerPreferences extends _xfa_object.Option01 {
  57408. constructor(attributes) {
  57409. super(CONFIG_NS_ID, "addViewerPreferences");
  57410. }
  57411. }
  57412. class AdjustData extends _xfa_object.Option10 {
  57413. constructor(attributes) {
  57414. super(CONFIG_NS_ID, "adjustData");
  57415. }
  57416. }
  57417. class AdobeExtensionLevel extends _xfa_object.IntegerObject {
  57418. constructor(attributes) {
  57419. super(CONFIG_NS_ID, "adobeExtensionLevel", 0, n => n >= 1 && n <= 8);
  57420. }
  57421. }
  57422. class Agent extends _xfa_object.XFAObject {
  57423. constructor(attributes) {
  57424. super(CONFIG_NS_ID, "agent", true);
  57425. this.name = attributes.name ? attributes.name.trim() : "";
  57426. this.common = new _xfa_object.XFAObjectArray();
  57427. }
  57428. }
  57429. class AlwaysEmbed extends _xfa_object.ContentObject {
  57430. constructor(attributes) {
  57431. super(CONFIG_NS_ID, "alwaysEmbed");
  57432. }
  57433. }
  57434. class Amd extends _xfa_object.StringObject {
  57435. constructor(attributes) {
  57436. super(CONFIG_NS_ID, "amd");
  57437. }
  57438. }
  57439. class Area extends _xfa_object.XFAObject {
  57440. constructor(attributes) {
  57441. super(CONFIG_NS_ID, "area");
  57442. this.level = (0, _utils.getInteger)({
  57443. data: attributes.level,
  57444. defaultValue: 0,
  57445. validate: n => n >= 1 && n <= 3
  57446. });
  57447. this.name = (0, _utils.getStringOption)(attributes.name, ["", "barcode", "coreinit", "deviceDriver", "font", "general", "layout", "merge", "script", "signature", "sourceSet", "templateCache"]);
  57448. }
  57449. }
  57450. class Attributes extends _xfa_object.OptionObject {
  57451. constructor(attributes) {
  57452. super(CONFIG_NS_ID, "attributes", ["preserve", "delegate", "ignore"]);
  57453. }
  57454. }
  57455. class AutoSave extends _xfa_object.OptionObject {
  57456. constructor(attributes) {
  57457. super(CONFIG_NS_ID, "autoSave", ["disabled", "enabled"]);
  57458. }
  57459. }
  57460. class Base extends _xfa_object.StringObject {
  57461. constructor(attributes) {
  57462. super(CONFIG_NS_ID, "base");
  57463. }
  57464. }
  57465. class BatchOutput extends _xfa_object.XFAObject {
  57466. constructor(attributes) {
  57467. super(CONFIG_NS_ID, "batchOutput");
  57468. this.format = (0, _utils.getStringOption)(attributes.format, ["none", "concat", "zip", "zipCompress"]);
  57469. }
  57470. }
  57471. class BehaviorOverride extends _xfa_object.ContentObject {
  57472. constructor(attributes) {
  57473. super(CONFIG_NS_ID, "behaviorOverride");
  57474. }
  57475. [_symbol_utils.$finalize]() {
  57476. this[_symbol_utils.$content] = new Map(this[_symbol_utils.$content].trim().split(/\s+/).filter(x => x.includes(":")).map(x => x.split(":", 2)));
  57477. }
  57478. }
  57479. class Cache extends _xfa_object.XFAObject {
  57480. constructor(attributes) {
  57481. super(CONFIG_NS_ID, "cache", true);
  57482. this.templateCache = null;
  57483. }
  57484. }
  57485. class Change extends _xfa_object.Option01 {
  57486. constructor(attributes) {
  57487. super(CONFIG_NS_ID, "change");
  57488. }
  57489. }
  57490. class Common extends _xfa_object.XFAObject {
  57491. constructor(attributes) {
  57492. super(CONFIG_NS_ID, "common", true);
  57493. this.data = null;
  57494. this.locale = null;
  57495. this.localeSet = null;
  57496. this.messaging = null;
  57497. this.suppressBanner = null;
  57498. this.template = null;
  57499. this.validationMessaging = null;
  57500. this.versionControl = null;
  57501. this.log = new _xfa_object.XFAObjectArray();
  57502. }
  57503. }
  57504. class Compress extends _xfa_object.XFAObject {
  57505. constructor(attributes) {
  57506. super(CONFIG_NS_ID, "compress");
  57507. this.scope = (0, _utils.getStringOption)(attributes.scope, ["imageOnly", "document"]);
  57508. }
  57509. }
  57510. class CompressLogicalStructure extends _xfa_object.Option01 {
  57511. constructor(attributes) {
  57512. super(CONFIG_NS_ID, "compressLogicalStructure");
  57513. }
  57514. }
  57515. class CompressObjectStream extends _xfa_object.Option10 {
  57516. constructor(attributes) {
  57517. super(CONFIG_NS_ID, "compressObjectStream");
  57518. }
  57519. }
  57520. class Compression extends _xfa_object.XFAObject {
  57521. constructor(attributes) {
  57522. super(CONFIG_NS_ID, "compression", true);
  57523. this.compressLogicalStructure = null;
  57524. this.compressObjectStream = null;
  57525. this.level = null;
  57526. this.type = null;
  57527. }
  57528. }
  57529. class Config extends _xfa_object.XFAObject {
  57530. constructor(attributes) {
  57531. super(CONFIG_NS_ID, "config", true);
  57532. this.acrobat = null;
  57533. this.present = null;
  57534. this.trace = null;
  57535. this.agent = new _xfa_object.XFAObjectArray();
  57536. }
  57537. }
  57538. class Conformance extends _xfa_object.OptionObject {
  57539. constructor(attributes) {
  57540. super(CONFIG_NS_ID, "conformance", ["A", "B"]);
  57541. }
  57542. }
  57543. class ContentCopy extends _xfa_object.Option01 {
  57544. constructor(attributes) {
  57545. super(CONFIG_NS_ID, "contentCopy");
  57546. }
  57547. }
  57548. class Copies extends _xfa_object.IntegerObject {
  57549. constructor(attributes) {
  57550. super(CONFIG_NS_ID, "copies", 1, n => n >= 1);
  57551. }
  57552. }
  57553. class Creator extends _xfa_object.StringObject {
  57554. constructor(attributes) {
  57555. super(CONFIG_NS_ID, "creator");
  57556. }
  57557. }
  57558. class CurrentPage extends _xfa_object.IntegerObject {
  57559. constructor(attributes) {
  57560. super(CONFIG_NS_ID, "currentPage", 0, n => n >= 0);
  57561. }
  57562. }
  57563. class Data extends _xfa_object.XFAObject {
  57564. constructor(attributes) {
  57565. super(CONFIG_NS_ID, "data", true);
  57566. this.adjustData = null;
  57567. this.attributes = null;
  57568. this.incrementalLoad = null;
  57569. this.outputXSL = null;
  57570. this.range = null;
  57571. this.record = null;
  57572. this.startNode = null;
  57573. this.uri = null;
  57574. this.window = null;
  57575. this.xsl = null;
  57576. this.excludeNS = new _xfa_object.XFAObjectArray();
  57577. this.transform = new _xfa_object.XFAObjectArray();
  57578. }
  57579. }
  57580. class Debug extends _xfa_object.XFAObject {
  57581. constructor(attributes) {
  57582. super(CONFIG_NS_ID, "debug", true);
  57583. this.uri = null;
  57584. }
  57585. }
  57586. class DefaultTypeface extends _xfa_object.ContentObject {
  57587. constructor(attributes) {
  57588. super(CONFIG_NS_ID, "defaultTypeface");
  57589. this.writingScript = (0, _utils.getStringOption)(attributes.writingScript, ["*", "Arabic", "Cyrillic", "EastEuropeanRoman", "Greek", "Hebrew", "Japanese", "Korean", "Roman", "SimplifiedChinese", "Thai", "TraditionalChinese", "Vietnamese"]);
  57590. }
  57591. }
  57592. class Destination extends _xfa_object.OptionObject {
  57593. constructor(attributes) {
  57594. super(CONFIG_NS_ID, "destination", ["pdf", "pcl", "ps", "webClient", "zpl"]);
  57595. }
  57596. }
  57597. class DocumentAssembly extends _xfa_object.Option01 {
  57598. constructor(attributes) {
  57599. super(CONFIG_NS_ID, "documentAssembly");
  57600. }
  57601. }
  57602. class Driver extends _xfa_object.XFAObject {
  57603. constructor(attributes) {
  57604. super(CONFIG_NS_ID, "driver", true);
  57605. this.name = attributes.name ? attributes.name.trim() : "";
  57606. this.fontInfo = null;
  57607. this.xdc = null;
  57608. }
  57609. }
  57610. class DuplexOption extends _xfa_object.OptionObject {
  57611. constructor(attributes) {
  57612. super(CONFIG_NS_ID, "duplexOption", ["simplex", "duplexFlipLongEdge", "duplexFlipShortEdge"]);
  57613. }
  57614. }
  57615. class DynamicRender extends _xfa_object.OptionObject {
  57616. constructor(attributes) {
  57617. super(CONFIG_NS_ID, "dynamicRender", ["forbidden", "required"]);
  57618. }
  57619. }
  57620. class Embed extends _xfa_object.Option01 {
  57621. constructor(attributes) {
  57622. super(CONFIG_NS_ID, "embed");
  57623. }
  57624. }
  57625. class Encrypt extends _xfa_object.Option01 {
  57626. constructor(attributes) {
  57627. super(CONFIG_NS_ID, "encrypt");
  57628. }
  57629. }
  57630. class Encryption extends _xfa_object.XFAObject {
  57631. constructor(attributes) {
  57632. super(CONFIG_NS_ID, "encryption", true);
  57633. this.encrypt = null;
  57634. this.encryptionLevel = null;
  57635. this.permissions = null;
  57636. }
  57637. }
  57638. class EncryptionLevel extends _xfa_object.OptionObject {
  57639. constructor(attributes) {
  57640. super(CONFIG_NS_ID, "encryptionLevel", ["40bit", "128bit"]);
  57641. }
  57642. }
  57643. class Enforce extends _xfa_object.StringObject {
  57644. constructor(attributes) {
  57645. super(CONFIG_NS_ID, "enforce");
  57646. }
  57647. }
  57648. class Equate extends _xfa_object.XFAObject {
  57649. constructor(attributes) {
  57650. super(CONFIG_NS_ID, "equate");
  57651. this.force = (0, _utils.getInteger)({
  57652. data: attributes.force,
  57653. defaultValue: 1,
  57654. validate: n => n === 0
  57655. });
  57656. this.from = attributes.from || "";
  57657. this.to = attributes.to || "";
  57658. }
  57659. }
  57660. class EquateRange extends _xfa_object.XFAObject {
  57661. constructor(attributes) {
  57662. super(CONFIG_NS_ID, "equateRange");
  57663. this.from = attributes.from || "";
  57664. this.to = attributes.to || "";
  57665. this._unicodeRange = attributes.unicodeRange || "";
  57666. }
  57667. get unicodeRange() {
  57668. const ranges = [];
  57669. const unicodeRegex = /U\+([0-9a-fA-F]+)/;
  57670. const unicodeRange = this._unicodeRange;
  57671. for (let range of unicodeRange.split(",").map(x => x.trim()).filter(x => !!x)) {
  57672. range = range.split("-", 2).map(x => {
  57673. const found = x.match(unicodeRegex);
  57674. if (!found) {
  57675. return 0;
  57676. }
  57677. return parseInt(found[1], 16);
  57678. });
  57679. if (range.length === 1) {
  57680. range.push(range[0]);
  57681. }
  57682. ranges.push(range);
  57683. }
  57684. return (0, _util.shadow)(this, "unicodeRange", ranges);
  57685. }
  57686. }
  57687. class Exclude extends _xfa_object.ContentObject {
  57688. constructor(attributes) {
  57689. super(CONFIG_NS_ID, "exclude");
  57690. }
  57691. [_symbol_utils.$finalize]() {
  57692. this[_symbol_utils.$content] = this[_symbol_utils.$content].trim().split(/\s+/).filter(x => x && ["calculate", "close", "enter", "exit", "initialize", "ready", "validate"].includes(x));
  57693. }
  57694. }
  57695. class ExcludeNS extends _xfa_object.StringObject {
  57696. constructor(attributes) {
  57697. super(CONFIG_NS_ID, "excludeNS");
  57698. }
  57699. }
  57700. class FlipLabel extends _xfa_object.OptionObject {
  57701. constructor(attributes) {
  57702. super(CONFIG_NS_ID, "flipLabel", ["usePrinterSetting", "on", "off"]);
  57703. }
  57704. }
  57705. class FontInfo extends _xfa_object.XFAObject {
  57706. constructor(attributes) {
  57707. super(CONFIG_NS_ID, "fontInfo", true);
  57708. this.embed = null;
  57709. this.map = null;
  57710. this.subsetBelow = null;
  57711. this.alwaysEmbed = new _xfa_object.XFAObjectArray();
  57712. this.defaultTypeface = new _xfa_object.XFAObjectArray();
  57713. this.neverEmbed = new _xfa_object.XFAObjectArray();
  57714. }
  57715. }
  57716. class FormFieldFilling extends _xfa_object.Option01 {
  57717. constructor(attributes) {
  57718. super(CONFIG_NS_ID, "formFieldFilling");
  57719. }
  57720. }
  57721. class GroupParent extends _xfa_object.StringObject {
  57722. constructor(attributes) {
  57723. super(CONFIG_NS_ID, "groupParent");
  57724. }
  57725. }
  57726. class IfEmpty extends _xfa_object.OptionObject {
  57727. constructor(attributes) {
  57728. super(CONFIG_NS_ID, "ifEmpty", ["dataValue", "dataGroup", "ignore", "remove"]);
  57729. }
  57730. }
  57731. class IncludeXDPContent extends _xfa_object.StringObject {
  57732. constructor(attributes) {
  57733. super(CONFIG_NS_ID, "includeXDPContent");
  57734. }
  57735. }
  57736. class IncrementalLoad extends _xfa_object.OptionObject {
  57737. constructor(attributes) {
  57738. super(CONFIG_NS_ID, "incrementalLoad", ["none", "forwardOnly"]);
  57739. }
  57740. }
  57741. class IncrementalMerge extends _xfa_object.Option01 {
  57742. constructor(attributes) {
  57743. super(CONFIG_NS_ID, "incrementalMerge");
  57744. }
  57745. }
  57746. class Interactive extends _xfa_object.Option01 {
  57747. constructor(attributes) {
  57748. super(CONFIG_NS_ID, "interactive");
  57749. }
  57750. }
  57751. class Jog extends _xfa_object.OptionObject {
  57752. constructor(attributes) {
  57753. super(CONFIG_NS_ID, "jog", ["usePrinterSetting", "none", "pageSet"]);
  57754. }
  57755. }
  57756. class LabelPrinter extends _xfa_object.XFAObject {
  57757. constructor(attributes) {
  57758. super(CONFIG_NS_ID, "labelPrinter", true);
  57759. this.name = (0, _utils.getStringOption)(attributes.name, ["zpl", "dpl", "ipl", "tcpl"]);
  57760. this.batchOutput = null;
  57761. this.flipLabel = null;
  57762. this.fontInfo = null;
  57763. this.xdc = null;
  57764. }
  57765. }
  57766. class Layout extends _xfa_object.OptionObject {
  57767. constructor(attributes) {
  57768. super(CONFIG_NS_ID, "layout", ["paginate", "panel"]);
  57769. }
  57770. }
  57771. class Level extends _xfa_object.IntegerObject {
  57772. constructor(attributes) {
  57773. super(CONFIG_NS_ID, "level", 0, n => n > 0);
  57774. }
  57775. }
  57776. class Linearized extends _xfa_object.Option01 {
  57777. constructor(attributes) {
  57778. super(CONFIG_NS_ID, "linearized");
  57779. }
  57780. }
  57781. class Locale extends _xfa_object.StringObject {
  57782. constructor(attributes) {
  57783. super(CONFIG_NS_ID, "locale");
  57784. }
  57785. }
  57786. class LocaleSet extends _xfa_object.StringObject {
  57787. constructor(attributes) {
  57788. super(CONFIG_NS_ID, "localeSet");
  57789. }
  57790. }
  57791. class Log extends _xfa_object.XFAObject {
  57792. constructor(attributes) {
  57793. super(CONFIG_NS_ID, "log", true);
  57794. this.mode = null;
  57795. this.threshold = null;
  57796. this.to = null;
  57797. this.uri = null;
  57798. }
  57799. }
  57800. class MapElement extends _xfa_object.XFAObject {
  57801. constructor(attributes) {
  57802. super(CONFIG_NS_ID, "map", true);
  57803. this.equate = new _xfa_object.XFAObjectArray();
  57804. this.equateRange = new _xfa_object.XFAObjectArray();
  57805. }
  57806. }
  57807. class MediumInfo extends _xfa_object.XFAObject {
  57808. constructor(attributes) {
  57809. super(CONFIG_NS_ID, "mediumInfo", true);
  57810. this.map = null;
  57811. }
  57812. }
  57813. class Message extends _xfa_object.XFAObject {
  57814. constructor(attributes) {
  57815. super(CONFIG_NS_ID, "message", true);
  57816. this.msgId = null;
  57817. this.severity = null;
  57818. }
  57819. }
  57820. class Messaging extends _xfa_object.XFAObject {
  57821. constructor(attributes) {
  57822. super(CONFIG_NS_ID, "messaging", true);
  57823. this.message = new _xfa_object.XFAObjectArray();
  57824. }
  57825. }
  57826. class Mode extends _xfa_object.OptionObject {
  57827. constructor(attributes) {
  57828. super(CONFIG_NS_ID, "mode", ["append", "overwrite"]);
  57829. }
  57830. }
  57831. class ModifyAnnots extends _xfa_object.Option01 {
  57832. constructor(attributes) {
  57833. super(CONFIG_NS_ID, "modifyAnnots");
  57834. }
  57835. }
  57836. class MsgId extends _xfa_object.IntegerObject {
  57837. constructor(attributes) {
  57838. super(CONFIG_NS_ID, "msgId", 1, n => n >= 1);
  57839. }
  57840. }
  57841. class NameAttr extends _xfa_object.StringObject {
  57842. constructor(attributes) {
  57843. super(CONFIG_NS_ID, "nameAttr");
  57844. }
  57845. }
  57846. class NeverEmbed extends _xfa_object.ContentObject {
  57847. constructor(attributes) {
  57848. super(CONFIG_NS_ID, "neverEmbed");
  57849. }
  57850. }
  57851. class NumberOfCopies extends _xfa_object.IntegerObject {
  57852. constructor(attributes) {
  57853. super(CONFIG_NS_ID, "numberOfCopies", null, n => n >= 2 && n <= 5);
  57854. }
  57855. }
  57856. class OpenAction extends _xfa_object.XFAObject {
  57857. constructor(attributes) {
  57858. super(CONFIG_NS_ID, "openAction", true);
  57859. this.destination = null;
  57860. }
  57861. }
  57862. class Output extends _xfa_object.XFAObject {
  57863. constructor(attributes) {
  57864. super(CONFIG_NS_ID, "output", true);
  57865. this.to = null;
  57866. this.type = null;
  57867. this.uri = null;
  57868. }
  57869. }
  57870. class OutputBin extends _xfa_object.StringObject {
  57871. constructor(attributes) {
  57872. super(CONFIG_NS_ID, "outputBin");
  57873. }
  57874. }
  57875. class OutputXSL extends _xfa_object.XFAObject {
  57876. constructor(attributes) {
  57877. super(CONFIG_NS_ID, "outputXSL", true);
  57878. this.uri = null;
  57879. }
  57880. }
  57881. class Overprint extends _xfa_object.OptionObject {
  57882. constructor(attributes) {
  57883. super(CONFIG_NS_ID, "overprint", ["none", "both", "draw", "field"]);
  57884. }
  57885. }
  57886. class Packets extends _xfa_object.StringObject {
  57887. constructor(attributes) {
  57888. super(CONFIG_NS_ID, "packets");
  57889. }
  57890. [_symbol_utils.$finalize]() {
  57891. if (this[_symbol_utils.$content] === "*") {
  57892. return;
  57893. }
  57894. this[_symbol_utils.$content] = this[_symbol_utils.$content].trim().split(/\s+/).filter(x => ["config", "datasets", "template", "xfdf", "xslt"].includes(x));
  57895. }
  57896. }
  57897. class PageOffset extends _xfa_object.XFAObject {
  57898. constructor(attributes) {
  57899. super(CONFIG_NS_ID, "pageOffset");
  57900. this.x = (0, _utils.getInteger)({
  57901. data: attributes.x,
  57902. defaultValue: "useXDCSetting",
  57903. validate: n => true
  57904. });
  57905. this.y = (0, _utils.getInteger)({
  57906. data: attributes.y,
  57907. defaultValue: "useXDCSetting",
  57908. validate: n => true
  57909. });
  57910. }
  57911. }
  57912. class PageRange extends _xfa_object.StringObject {
  57913. constructor(attributes) {
  57914. super(CONFIG_NS_ID, "pageRange");
  57915. }
  57916. [_symbol_utils.$finalize]() {
  57917. const numbers = this[_symbol_utils.$content].trim().split(/\s+/).map(x => parseInt(x, 10));
  57918. const ranges = [];
  57919. for (let i = 0, ii = numbers.length; i < ii; i += 2) {
  57920. ranges.push(numbers.slice(i, i + 2));
  57921. }
  57922. this[_symbol_utils.$content] = ranges;
  57923. }
  57924. }
  57925. class Pagination extends _xfa_object.OptionObject {
  57926. constructor(attributes) {
  57927. super(CONFIG_NS_ID, "pagination", ["simplex", "duplexShortEdge", "duplexLongEdge"]);
  57928. }
  57929. }
  57930. class PaginationOverride extends _xfa_object.OptionObject {
  57931. constructor(attributes) {
  57932. super(CONFIG_NS_ID, "paginationOverride", ["none", "forceDuplex", "forceDuplexLongEdge", "forceDuplexShortEdge", "forceSimplex"]);
  57933. }
  57934. }
  57935. class Part extends _xfa_object.IntegerObject {
  57936. constructor(attributes) {
  57937. super(CONFIG_NS_ID, "part", 1, n => false);
  57938. }
  57939. }
  57940. class Pcl extends _xfa_object.XFAObject {
  57941. constructor(attributes) {
  57942. super(CONFIG_NS_ID, "pcl", true);
  57943. this.name = attributes.name || "";
  57944. this.batchOutput = null;
  57945. this.fontInfo = null;
  57946. this.jog = null;
  57947. this.mediumInfo = null;
  57948. this.outputBin = null;
  57949. this.pageOffset = null;
  57950. this.staple = null;
  57951. this.xdc = null;
  57952. }
  57953. }
  57954. class Pdf extends _xfa_object.XFAObject {
  57955. constructor(attributes) {
  57956. super(CONFIG_NS_ID, "pdf", true);
  57957. this.name = attributes.name || "";
  57958. this.adobeExtensionLevel = null;
  57959. this.batchOutput = null;
  57960. this.compression = null;
  57961. this.creator = null;
  57962. this.encryption = null;
  57963. this.fontInfo = null;
  57964. this.interactive = null;
  57965. this.linearized = null;
  57966. this.openAction = null;
  57967. this.pdfa = null;
  57968. this.producer = null;
  57969. this.renderPolicy = null;
  57970. this.scriptModel = null;
  57971. this.silentPrint = null;
  57972. this.submitFormat = null;
  57973. this.tagged = null;
  57974. this.version = null;
  57975. this.viewerPreferences = null;
  57976. this.xdc = null;
  57977. }
  57978. }
  57979. class Pdfa extends _xfa_object.XFAObject {
  57980. constructor(attributes) {
  57981. super(CONFIG_NS_ID, "pdfa", true);
  57982. this.amd = null;
  57983. this.conformance = null;
  57984. this.includeXDPContent = null;
  57985. this.part = null;
  57986. }
  57987. }
  57988. class Permissions extends _xfa_object.XFAObject {
  57989. constructor(attributes) {
  57990. super(CONFIG_NS_ID, "permissions", true);
  57991. this.accessibleContent = null;
  57992. this.change = null;
  57993. this.contentCopy = null;
  57994. this.documentAssembly = null;
  57995. this.formFieldFilling = null;
  57996. this.modifyAnnots = null;
  57997. this.plaintextMetadata = null;
  57998. this.print = null;
  57999. this.printHighQuality = null;
  58000. }
  58001. }
  58002. class PickTrayByPDFSize extends _xfa_object.Option01 {
  58003. constructor(attributes) {
  58004. super(CONFIG_NS_ID, "pickTrayByPDFSize");
  58005. }
  58006. }
  58007. class Picture extends _xfa_object.StringObject {
  58008. constructor(attributes) {
  58009. super(CONFIG_NS_ID, "picture");
  58010. }
  58011. }
  58012. class PlaintextMetadata extends _xfa_object.Option01 {
  58013. constructor(attributes) {
  58014. super(CONFIG_NS_ID, "plaintextMetadata");
  58015. }
  58016. }
  58017. class Presence extends _xfa_object.OptionObject {
  58018. constructor(attributes) {
  58019. super(CONFIG_NS_ID, "presence", ["preserve", "dissolve", "dissolveStructure", "ignore", "remove"]);
  58020. }
  58021. }
  58022. class Present extends _xfa_object.XFAObject {
  58023. constructor(attributes) {
  58024. super(CONFIG_NS_ID, "present", true);
  58025. this.behaviorOverride = null;
  58026. this.cache = null;
  58027. this.common = null;
  58028. this.copies = null;
  58029. this.destination = null;
  58030. this.incrementalMerge = null;
  58031. this.layout = null;
  58032. this.output = null;
  58033. this.overprint = null;
  58034. this.pagination = null;
  58035. this.paginationOverride = null;
  58036. this.script = null;
  58037. this.validate = null;
  58038. this.xdp = null;
  58039. this.driver = new _xfa_object.XFAObjectArray();
  58040. this.labelPrinter = new _xfa_object.XFAObjectArray();
  58041. this.pcl = new _xfa_object.XFAObjectArray();
  58042. this.pdf = new _xfa_object.XFAObjectArray();
  58043. this.ps = new _xfa_object.XFAObjectArray();
  58044. this.submitUrl = new _xfa_object.XFAObjectArray();
  58045. this.webClient = new _xfa_object.XFAObjectArray();
  58046. this.zpl = new _xfa_object.XFAObjectArray();
  58047. }
  58048. }
  58049. class Print extends _xfa_object.Option01 {
  58050. constructor(attributes) {
  58051. super(CONFIG_NS_ID, "print");
  58052. }
  58053. }
  58054. class PrintHighQuality extends _xfa_object.Option01 {
  58055. constructor(attributes) {
  58056. super(CONFIG_NS_ID, "printHighQuality");
  58057. }
  58058. }
  58059. class PrintScaling extends _xfa_object.OptionObject {
  58060. constructor(attributes) {
  58061. super(CONFIG_NS_ID, "printScaling", ["appdefault", "noScaling"]);
  58062. }
  58063. }
  58064. class PrinterName extends _xfa_object.StringObject {
  58065. constructor(attributes) {
  58066. super(CONFIG_NS_ID, "printerName");
  58067. }
  58068. }
  58069. class Producer extends _xfa_object.StringObject {
  58070. constructor(attributes) {
  58071. super(CONFIG_NS_ID, "producer");
  58072. }
  58073. }
  58074. class Ps extends _xfa_object.XFAObject {
  58075. constructor(attributes) {
  58076. super(CONFIG_NS_ID, "ps", true);
  58077. this.name = attributes.name || "";
  58078. this.batchOutput = null;
  58079. this.fontInfo = null;
  58080. this.jog = null;
  58081. this.mediumInfo = null;
  58082. this.outputBin = null;
  58083. this.staple = null;
  58084. this.xdc = null;
  58085. }
  58086. }
  58087. class Range extends _xfa_object.ContentObject {
  58088. constructor(attributes) {
  58089. super(CONFIG_NS_ID, "range");
  58090. }
  58091. [_symbol_utils.$finalize]() {
  58092. 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 => {
  58093. if (range.length === 1) {
  58094. range.push(range[0]);
  58095. }
  58096. return range;
  58097. });
  58098. }
  58099. }
  58100. class Record extends _xfa_object.ContentObject {
  58101. constructor(attributes) {
  58102. super(CONFIG_NS_ID, "record");
  58103. }
  58104. [_symbol_utils.$finalize]() {
  58105. this[_symbol_utils.$content] = this[_symbol_utils.$content].trim();
  58106. const n = parseInt(this[_symbol_utils.$content], 10);
  58107. if (!isNaN(n) && n >= 0) {
  58108. this[_symbol_utils.$content] = n;
  58109. }
  58110. }
  58111. }
  58112. class Relevant extends _xfa_object.ContentObject {
  58113. constructor(attributes) {
  58114. super(CONFIG_NS_ID, "relevant");
  58115. }
  58116. [_symbol_utils.$finalize]() {
  58117. this[_symbol_utils.$content] = this[_symbol_utils.$content].trim().split(/\s+/);
  58118. }
  58119. }
  58120. class Rename extends _xfa_object.ContentObject {
  58121. constructor(attributes) {
  58122. super(CONFIG_NS_ID, "rename");
  58123. }
  58124. [_symbol_utils.$finalize]() {
  58125. this[_symbol_utils.$content] = this[_symbol_utils.$content].trim();
  58126. if (this[_symbol_utils.$content].toLowerCase().startsWith("xml") || new RegExp("[\\p{L}_][\\p{L}\\d._\\p{M}-]*", "u").test(this[_symbol_utils.$content])) {
  58127. (0, _util.warn)("XFA - Rename: invalid XFA name");
  58128. }
  58129. }
  58130. }
  58131. class RenderPolicy extends _xfa_object.OptionObject {
  58132. constructor(attributes) {
  58133. super(CONFIG_NS_ID, "renderPolicy", ["server", "client"]);
  58134. }
  58135. }
  58136. class RunScripts extends _xfa_object.OptionObject {
  58137. constructor(attributes) {
  58138. super(CONFIG_NS_ID, "runScripts", ["both", "client", "none", "server"]);
  58139. }
  58140. }
  58141. class Script extends _xfa_object.XFAObject {
  58142. constructor(attributes) {
  58143. super(CONFIG_NS_ID, "script", true);
  58144. this.currentPage = null;
  58145. this.exclude = null;
  58146. this.runScripts = null;
  58147. }
  58148. }
  58149. class ScriptModel extends _xfa_object.OptionObject {
  58150. constructor(attributes) {
  58151. super(CONFIG_NS_ID, "scriptModel", ["XFA", "none"]);
  58152. }
  58153. }
  58154. class Severity extends _xfa_object.OptionObject {
  58155. constructor(attributes) {
  58156. super(CONFIG_NS_ID, "severity", ["ignore", "error", "information", "trace", "warning"]);
  58157. }
  58158. }
  58159. class SilentPrint extends _xfa_object.XFAObject {
  58160. constructor(attributes) {
  58161. super(CONFIG_NS_ID, "silentPrint", true);
  58162. this.addSilentPrint = null;
  58163. this.printerName = null;
  58164. }
  58165. }
  58166. class Staple extends _xfa_object.XFAObject {
  58167. constructor(attributes) {
  58168. super(CONFIG_NS_ID, "staple");
  58169. this.mode = (0, _utils.getStringOption)(attributes.mode, ["usePrinterSetting", "on", "off"]);
  58170. }
  58171. }
  58172. class StartNode extends _xfa_object.StringObject {
  58173. constructor(attributes) {
  58174. super(CONFIG_NS_ID, "startNode");
  58175. }
  58176. }
  58177. class StartPage extends _xfa_object.IntegerObject {
  58178. constructor(attributes) {
  58179. super(CONFIG_NS_ID, "startPage", 0, n => true);
  58180. }
  58181. }
  58182. class SubmitFormat extends _xfa_object.OptionObject {
  58183. constructor(attributes) {
  58184. super(CONFIG_NS_ID, "submitFormat", ["html", "delegate", "fdf", "xml", "pdf"]);
  58185. }
  58186. }
  58187. class SubmitUrl extends _xfa_object.StringObject {
  58188. constructor(attributes) {
  58189. super(CONFIG_NS_ID, "submitUrl");
  58190. }
  58191. }
  58192. class SubsetBelow extends _xfa_object.IntegerObject {
  58193. constructor(attributes) {
  58194. super(CONFIG_NS_ID, "subsetBelow", 100, n => n >= 0 && n <= 100);
  58195. }
  58196. }
  58197. class SuppressBanner extends _xfa_object.Option01 {
  58198. constructor(attributes) {
  58199. super(CONFIG_NS_ID, "suppressBanner");
  58200. }
  58201. }
  58202. class Tagged extends _xfa_object.Option01 {
  58203. constructor(attributes) {
  58204. super(CONFIG_NS_ID, "tagged");
  58205. }
  58206. }
  58207. class Template extends _xfa_object.XFAObject {
  58208. constructor(attributes) {
  58209. super(CONFIG_NS_ID, "template", true);
  58210. this.base = null;
  58211. this.relevant = null;
  58212. this.startPage = null;
  58213. this.uri = null;
  58214. this.xsl = null;
  58215. }
  58216. }
  58217. class Threshold extends _xfa_object.OptionObject {
  58218. constructor(attributes) {
  58219. super(CONFIG_NS_ID, "threshold", ["trace", "error", "information", "warning"]);
  58220. }
  58221. }
  58222. class To extends _xfa_object.OptionObject {
  58223. constructor(attributes) {
  58224. super(CONFIG_NS_ID, "to", ["null", "memory", "stderr", "stdout", "system", "uri"]);
  58225. }
  58226. }
  58227. class TemplateCache extends _xfa_object.XFAObject {
  58228. constructor(attributes) {
  58229. super(CONFIG_NS_ID, "templateCache");
  58230. this.maxEntries = (0, _utils.getInteger)({
  58231. data: attributes.maxEntries,
  58232. defaultValue: 5,
  58233. validate: n => n >= 0
  58234. });
  58235. }
  58236. }
  58237. class Trace extends _xfa_object.XFAObject {
  58238. constructor(attributes) {
  58239. super(CONFIG_NS_ID, "trace", true);
  58240. this.area = new _xfa_object.XFAObjectArray();
  58241. }
  58242. }
  58243. class Transform extends _xfa_object.XFAObject {
  58244. constructor(attributes) {
  58245. super(CONFIG_NS_ID, "transform", true);
  58246. this.groupParent = null;
  58247. this.ifEmpty = null;
  58248. this.nameAttr = null;
  58249. this.picture = null;
  58250. this.presence = null;
  58251. this.rename = null;
  58252. this.whitespace = null;
  58253. }
  58254. }
  58255. class Type extends _xfa_object.OptionObject {
  58256. constructor(attributes) {
  58257. super(CONFIG_NS_ID, "type", ["none", "ascii85", "asciiHex", "ccittfax", "flate", "lzw", "runLength", "native", "xdp", "mergedXDP"]);
  58258. }
  58259. }
  58260. class Uri extends _xfa_object.StringObject {
  58261. constructor(attributes) {
  58262. super(CONFIG_NS_ID, "uri");
  58263. }
  58264. }
  58265. class Validate extends _xfa_object.OptionObject {
  58266. constructor(attributes) {
  58267. super(CONFIG_NS_ID, "validate", ["preSubmit", "prePrint", "preExecute", "preSave"]);
  58268. }
  58269. }
  58270. class ValidateApprovalSignatures extends _xfa_object.ContentObject {
  58271. constructor(attributes) {
  58272. super(CONFIG_NS_ID, "validateApprovalSignatures");
  58273. }
  58274. [_symbol_utils.$finalize]() {
  58275. this[_symbol_utils.$content] = this[_symbol_utils.$content].trim().split(/\s+/).filter(x => ["docReady", "postSign"].includes(x));
  58276. }
  58277. }
  58278. class ValidationMessaging extends _xfa_object.OptionObject {
  58279. constructor(attributes) {
  58280. super(CONFIG_NS_ID, "validationMessaging", ["allMessagesIndividually", "allMessagesTogether", "firstMessageOnly", "noMessages"]);
  58281. }
  58282. }
  58283. class Version extends _xfa_object.OptionObject {
  58284. constructor(attributes) {
  58285. super(CONFIG_NS_ID, "version", ["1.7", "1.6", "1.5", "1.4", "1.3", "1.2"]);
  58286. }
  58287. }
  58288. class VersionControl extends _xfa_object.XFAObject {
  58289. constructor(attributes) {
  58290. super(CONFIG_NS_ID, "VersionControl");
  58291. this.outputBelow = (0, _utils.getStringOption)(attributes.outputBelow, ["warn", "error", "update"]);
  58292. this.sourceAbove = (0, _utils.getStringOption)(attributes.sourceAbove, ["warn", "error"]);
  58293. this.sourceBelow = (0, _utils.getStringOption)(attributes.sourceBelow, ["update", "maintain"]);
  58294. }
  58295. }
  58296. class ViewerPreferences extends _xfa_object.XFAObject {
  58297. constructor(attributes) {
  58298. super(CONFIG_NS_ID, "viewerPreferences", true);
  58299. this.ADBE_JSConsole = null;
  58300. this.ADBE_JSDebugger = null;
  58301. this.addViewerPreferences = null;
  58302. this.duplexOption = null;
  58303. this.enforce = null;
  58304. this.numberOfCopies = null;
  58305. this.pageRange = null;
  58306. this.pickTrayByPDFSize = null;
  58307. this.printScaling = null;
  58308. }
  58309. }
  58310. class WebClient extends _xfa_object.XFAObject {
  58311. constructor(attributes) {
  58312. super(CONFIG_NS_ID, "webClient", true);
  58313. this.name = attributes.name ? attributes.name.trim() : "";
  58314. this.fontInfo = null;
  58315. this.xdc = null;
  58316. }
  58317. }
  58318. class Whitespace extends _xfa_object.OptionObject {
  58319. constructor(attributes) {
  58320. super(CONFIG_NS_ID, "whitespace", ["preserve", "ltrim", "normalize", "rtrim", "trim"]);
  58321. }
  58322. }
  58323. class Window extends _xfa_object.ContentObject {
  58324. constructor(attributes) {
  58325. super(CONFIG_NS_ID, "window");
  58326. }
  58327. [_symbol_utils.$finalize]() {
  58328. const pair = this[_symbol_utils.$content].trim().split(/\s*,\s*/, 2).map(x => parseInt(x, 10));
  58329. if (pair.some(x => isNaN(x))) {
  58330. this[_symbol_utils.$content] = [0, 0];
  58331. return;
  58332. }
  58333. if (pair.length === 1) {
  58334. pair.push(pair[0]);
  58335. }
  58336. this[_symbol_utils.$content] = pair;
  58337. }
  58338. }
  58339. class Xdc extends _xfa_object.XFAObject {
  58340. constructor(attributes) {
  58341. super(CONFIG_NS_ID, "xdc", true);
  58342. this.uri = new _xfa_object.XFAObjectArray();
  58343. this.xsl = new _xfa_object.XFAObjectArray();
  58344. }
  58345. }
  58346. class Xdp extends _xfa_object.XFAObject {
  58347. constructor(attributes) {
  58348. super(CONFIG_NS_ID, "xdp", true);
  58349. this.packets = null;
  58350. }
  58351. }
  58352. class Xsl extends _xfa_object.XFAObject {
  58353. constructor(attributes) {
  58354. super(CONFIG_NS_ID, "xsl", true);
  58355. this.debug = null;
  58356. this.uri = null;
  58357. }
  58358. }
  58359. class Zpl extends _xfa_object.XFAObject {
  58360. constructor(attributes) {
  58361. super(CONFIG_NS_ID, "zpl", true);
  58362. this.name = attributes.name ? attributes.name.trim() : "";
  58363. this.batchOutput = null;
  58364. this.flipLabel = null;
  58365. this.fontInfo = null;
  58366. this.xdc = null;
  58367. }
  58368. }
  58369. class ConfigNamespace {
  58370. static [_namespaces.$buildXFAObject](name, attributes) {
  58371. if (ConfigNamespace.hasOwnProperty(name)) {
  58372. return ConfigNamespace[name](attributes);
  58373. }
  58374. return undefined;
  58375. }
  58376. static acrobat(attrs) {
  58377. return new Acrobat(attrs);
  58378. }
  58379. static acrobat7(attrs) {
  58380. return new Acrobat7(attrs);
  58381. }
  58382. static ADBE_JSConsole(attrs) {
  58383. return new ADBE_JSConsole(attrs);
  58384. }
  58385. static ADBE_JSDebugger(attrs) {
  58386. return new ADBE_JSDebugger(attrs);
  58387. }
  58388. static addSilentPrint(attrs) {
  58389. return new AddSilentPrint(attrs);
  58390. }
  58391. static addViewerPreferences(attrs) {
  58392. return new AddViewerPreferences(attrs);
  58393. }
  58394. static adjustData(attrs) {
  58395. return new AdjustData(attrs);
  58396. }
  58397. static adobeExtensionLevel(attrs) {
  58398. return new AdobeExtensionLevel(attrs);
  58399. }
  58400. static agent(attrs) {
  58401. return new Agent(attrs);
  58402. }
  58403. static alwaysEmbed(attrs) {
  58404. return new AlwaysEmbed(attrs);
  58405. }
  58406. static amd(attrs) {
  58407. return new Amd(attrs);
  58408. }
  58409. static area(attrs) {
  58410. return new Area(attrs);
  58411. }
  58412. static attributes(attrs) {
  58413. return new Attributes(attrs);
  58414. }
  58415. static autoSave(attrs) {
  58416. return new AutoSave(attrs);
  58417. }
  58418. static base(attrs) {
  58419. return new Base(attrs);
  58420. }
  58421. static batchOutput(attrs) {
  58422. return new BatchOutput(attrs);
  58423. }
  58424. static behaviorOverride(attrs) {
  58425. return new BehaviorOverride(attrs);
  58426. }
  58427. static cache(attrs) {
  58428. return new Cache(attrs);
  58429. }
  58430. static change(attrs) {
  58431. return new Change(attrs);
  58432. }
  58433. static common(attrs) {
  58434. return new Common(attrs);
  58435. }
  58436. static compress(attrs) {
  58437. return new Compress(attrs);
  58438. }
  58439. static compressLogicalStructure(attrs) {
  58440. return new CompressLogicalStructure(attrs);
  58441. }
  58442. static compressObjectStream(attrs) {
  58443. return new CompressObjectStream(attrs);
  58444. }
  58445. static compression(attrs) {
  58446. return new Compression(attrs);
  58447. }
  58448. static config(attrs) {
  58449. return new Config(attrs);
  58450. }
  58451. static conformance(attrs) {
  58452. return new Conformance(attrs);
  58453. }
  58454. static contentCopy(attrs) {
  58455. return new ContentCopy(attrs);
  58456. }
  58457. static copies(attrs) {
  58458. return new Copies(attrs);
  58459. }
  58460. static creator(attrs) {
  58461. return new Creator(attrs);
  58462. }
  58463. static currentPage(attrs) {
  58464. return new CurrentPage(attrs);
  58465. }
  58466. static data(attrs) {
  58467. return new Data(attrs);
  58468. }
  58469. static debug(attrs) {
  58470. return new Debug(attrs);
  58471. }
  58472. static defaultTypeface(attrs) {
  58473. return new DefaultTypeface(attrs);
  58474. }
  58475. static destination(attrs) {
  58476. return new Destination(attrs);
  58477. }
  58478. static documentAssembly(attrs) {
  58479. return new DocumentAssembly(attrs);
  58480. }
  58481. static driver(attrs) {
  58482. return new Driver(attrs);
  58483. }
  58484. static duplexOption(attrs) {
  58485. return new DuplexOption(attrs);
  58486. }
  58487. static dynamicRender(attrs) {
  58488. return new DynamicRender(attrs);
  58489. }
  58490. static embed(attrs) {
  58491. return new Embed(attrs);
  58492. }
  58493. static encrypt(attrs) {
  58494. return new Encrypt(attrs);
  58495. }
  58496. static encryption(attrs) {
  58497. return new Encryption(attrs);
  58498. }
  58499. static encryptionLevel(attrs) {
  58500. return new EncryptionLevel(attrs);
  58501. }
  58502. static enforce(attrs) {
  58503. return new Enforce(attrs);
  58504. }
  58505. static equate(attrs) {
  58506. return new Equate(attrs);
  58507. }
  58508. static equateRange(attrs) {
  58509. return new EquateRange(attrs);
  58510. }
  58511. static exclude(attrs) {
  58512. return new Exclude(attrs);
  58513. }
  58514. static excludeNS(attrs) {
  58515. return new ExcludeNS(attrs);
  58516. }
  58517. static flipLabel(attrs) {
  58518. return new FlipLabel(attrs);
  58519. }
  58520. static fontInfo(attrs) {
  58521. return new FontInfo(attrs);
  58522. }
  58523. static formFieldFilling(attrs) {
  58524. return new FormFieldFilling(attrs);
  58525. }
  58526. static groupParent(attrs) {
  58527. return new GroupParent(attrs);
  58528. }
  58529. static ifEmpty(attrs) {
  58530. return new IfEmpty(attrs);
  58531. }
  58532. static includeXDPContent(attrs) {
  58533. return new IncludeXDPContent(attrs);
  58534. }
  58535. static incrementalLoad(attrs) {
  58536. return new IncrementalLoad(attrs);
  58537. }
  58538. static incrementalMerge(attrs) {
  58539. return new IncrementalMerge(attrs);
  58540. }
  58541. static interactive(attrs) {
  58542. return new Interactive(attrs);
  58543. }
  58544. static jog(attrs) {
  58545. return new Jog(attrs);
  58546. }
  58547. static labelPrinter(attrs) {
  58548. return new LabelPrinter(attrs);
  58549. }
  58550. static layout(attrs) {
  58551. return new Layout(attrs);
  58552. }
  58553. static level(attrs) {
  58554. return new Level(attrs);
  58555. }
  58556. static linearized(attrs) {
  58557. return new Linearized(attrs);
  58558. }
  58559. static locale(attrs) {
  58560. return new Locale(attrs);
  58561. }
  58562. static localeSet(attrs) {
  58563. return new LocaleSet(attrs);
  58564. }
  58565. static log(attrs) {
  58566. return new Log(attrs);
  58567. }
  58568. static map(attrs) {
  58569. return new MapElement(attrs);
  58570. }
  58571. static mediumInfo(attrs) {
  58572. return new MediumInfo(attrs);
  58573. }
  58574. static message(attrs) {
  58575. return new Message(attrs);
  58576. }
  58577. static messaging(attrs) {
  58578. return new Messaging(attrs);
  58579. }
  58580. static mode(attrs) {
  58581. return new Mode(attrs);
  58582. }
  58583. static modifyAnnots(attrs) {
  58584. return new ModifyAnnots(attrs);
  58585. }
  58586. static msgId(attrs) {
  58587. return new MsgId(attrs);
  58588. }
  58589. static nameAttr(attrs) {
  58590. return new NameAttr(attrs);
  58591. }
  58592. static neverEmbed(attrs) {
  58593. return new NeverEmbed(attrs);
  58594. }
  58595. static numberOfCopies(attrs) {
  58596. return new NumberOfCopies(attrs);
  58597. }
  58598. static openAction(attrs) {
  58599. return new OpenAction(attrs);
  58600. }
  58601. static output(attrs) {
  58602. return new Output(attrs);
  58603. }
  58604. static outputBin(attrs) {
  58605. return new OutputBin(attrs);
  58606. }
  58607. static outputXSL(attrs) {
  58608. return new OutputXSL(attrs);
  58609. }
  58610. static overprint(attrs) {
  58611. return new Overprint(attrs);
  58612. }
  58613. static packets(attrs) {
  58614. return new Packets(attrs);
  58615. }
  58616. static pageOffset(attrs) {
  58617. return new PageOffset(attrs);
  58618. }
  58619. static pageRange(attrs) {
  58620. return new PageRange(attrs);
  58621. }
  58622. static pagination(attrs) {
  58623. return new Pagination(attrs);
  58624. }
  58625. static paginationOverride(attrs) {
  58626. return new PaginationOverride(attrs);
  58627. }
  58628. static part(attrs) {
  58629. return new Part(attrs);
  58630. }
  58631. static pcl(attrs) {
  58632. return new Pcl(attrs);
  58633. }
  58634. static pdf(attrs) {
  58635. return new Pdf(attrs);
  58636. }
  58637. static pdfa(attrs) {
  58638. return new Pdfa(attrs);
  58639. }
  58640. static permissions(attrs) {
  58641. return new Permissions(attrs);
  58642. }
  58643. static pickTrayByPDFSize(attrs) {
  58644. return new PickTrayByPDFSize(attrs);
  58645. }
  58646. static picture(attrs) {
  58647. return new Picture(attrs);
  58648. }
  58649. static plaintextMetadata(attrs) {
  58650. return new PlaintextMetadata(attrs);
  58651. }
  58652. static presence(attrs) {
  58653. return new Presence(attrs);
  58654. }
  58655. static present(attrs) {
  58656. return new Present(attrs);
  58657. }
  58658. static print(attrs) {
  58659. return new Print(attrs);
  58660. }
  58661. static printHighQuality(attrs) {
  58662. return new PrintHighQuality(attrs);
  58663. }
  58664. static printScaling(attrs) {
  58665. return new PrintScaling(attrs);
  58666. }
  58667. static printerName(attrs) {
  58668. return new PrinterName(attrs);
  58669. }
  58670. static producer(attrs) {
  58671. return new Producer(attrs);
  58672. }
  58673. static ps(attrs) {
  58674. return new Ps(attrs);
  58675. }
  58676. static range(attrs) {
  58677. return new Range(attrs);
  58678. }
  58679. static record(attrs) {
  58680. return new Record(attrs);
  58681. }
  58682. static relevant(attrs) {
  58683. return new Relevant(attrs);
  58684. }
  58685. static rename(attrs) {
  58686. return new Rename(attrs);
  58687. }
  58688. static renderPolicy(attrs) {
  58689. return new RenderPolicy(attrs);
  58690. }
  58691. static runScripts(attrs) {
  58692. return new RunScripts(attrs);
  58693. }
  58694. static script(attrs) {
  58695. return new Script(attrs);
  58696. }
  58697. static scriptModel(attrs) {
  58698. return new ScriptModel(attrs);
  58699. }
  58700. static severity(attrs) {
  58701. return new Severity(attrs);
  58702. }
  58703. static silentPrint(attrs) {
  58704. return new SilentPrint(attrs);
  58705. }
  58706. static staple(attrs) {
  58707. return new Staple(attrs);
  58708. }
  58709. static startNode(attrs) {
  58710. return new StartNode(attrs);
  58711. }
  58712. static startPage(attrs) {
  58713. return new StartPage(attrs);
  58714. }
  58715. static submitFormat(attrs) {
  58716. return new SubmitFormat(attrs);
  58717. }
  58718. static submitUrl(attrs) {
  58719. return new SubmitUrl(attrs);
  58720. }
  58721. static subsetBelow(attrs) {
  58722. return new SubsetBelow(attrs);
  58723. }
  58724. static suppressBanner(attrs) {
  58725. return new SuppressBanner(attrs);
  58726. }
  58727. static tagged(attrs) {
  58728. return new Tagged(attrs);
  58729. }
  58730. static template(attrs) {
  58731. return new Template(attrs);
  58732. }
  58733. static templateCache(attrs) {
  58734. return new TemplateCache(attrs);
  58735. }
  58736. static threshold(attrs) {
  58737. return new Threshold(attrs);
  58738. }
  58739. static to(attrs) {
  58740. return new To(attrs);
  58741. }
  58742. static trace(attrs) {
  58743. return new Trace(attrs);
  58744. }
  58745. static transform(attrs) {
  58746. return new Transform(attrs);
  58747. }
  58748. static type(attrs) {
  58749. return new Type(attrs);
  58750. }
  58751. static uri(attrs) {
  58752. return new Uri(attrs);
  58753. }
  58754. static validate(attrs) {
  58755. return new Validate(attrs);
  58756. }
  58757. static validateApprovalSignatures(attrs) {
  58758. return new ValidateApprovalSignatures(attrs);
  58759. }
  58760. static validationMessaging(attrs) {
  58761. return new ValidationMessaging(attrs);
  58762. }
  58763. static version(attrs) {
  58764. return new Version(attrs);
  58765. }
  58766. static versionControl(attrs) {
  58767. return new VersionControl(attrs);
  58768. }
  58769. static viewerPreferences(attrs) {
  58770. return new ViewerPreferences(attrs);
  58771. }
  58772. static webClient(attrs) {
  58773. return new WebClient(attrs);
  58774. }
  58775. static whitespace(attrs) {
  58776. return new Whitespace(attrs);
  58777. }
  58778. static window(attrs) {
  58779. return new Window(attrs);
  58780. }
  58781. static xdc(attrs) {
  58782. return new Xdc(attrs);
  58783. }
  58784. static xdp(attrs) {
  58785. return new Xdp(attrs);
  58786. }
  58787. static xsl(attrs) {
  58788. return new Xsl(attrs);
  58789. }
  58790. static zpl(attrs) {
  58791. return new Zpl(attrs);
  58792. }
  58793. }
  58794. exports.ConfigNamespace = ConfigNamespace;
  58795. /***/ }),
  58796. /* 248 */
  58797. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  58798. Object.defineProperty(exports, "__esModule", ({
  58799. value: true
  58800. }));
  58801. exports.ConnectionSetNamespace = void 0;
  58802. var _namespaces = __w_pdfjs_require__(235);
  58803. var _xfa_object = __w_pdfjs_require__(241);
  58804. const CONNECTION_SET_NS_ID = _namespaces.NamespaceIds.connectionSet.id;
  58805. class ConnectionSet extends _xfa_object.XFAObject {
  58806. constructor(attributes) {
  58807. super(CONNECTION_SET_NS_ID, "connectionSet", true);
  58808. this.wsdlConnection = new _xfa_object.XFAObjectArray();
  58809. this.xmlConnection = new _xfa_object.XFAObjectArray();
  58810. this.xsdConnection = new _xfa_object.XFAObjectArray();
  58811. }
  58812. }
  58813. class EffectiveInputPolicy extends _xfa_object.XFAObject {
  58814. constructor(attributes) {
  58815. super(CONNECTION_SET_NS_ID, "effectiveInputPolicy");
  58816. this.id = attributes.id || "";
  58817. this.name = attributes.name || "";
  58818. this.use = attributes.use || "";
  58819. this.usehref = attributes.usehref || "";
  58820. }
  58821. }
  58822. class EffectiveOutputPolicy extends _xfa_object.XFAObject {
  58823. constructor(attributes) {
  58824. super(CONNECTION_SET_NS_ID, "effectiveOutputPolicy");
  58825. this.id = attributes.id || "";
  58826. this.name = attributes.name || "";
  58827. this.use = attributes.use || "";
  58828. this.usehref = attributes.usehref || "";
  58829. }
  58830. }
  58831. class Operation extends _xfa_object.StringObject {
  58832. constructor(attributes) {
  58833. super(CONNECTION_SET_NS_ID, "operation");
  58834. this.id = attributes.id || "";
  58835. this.input = attributes.input || "";
  58836. this.name = attributes.name || "";
  58837. this.output = attributes.output || "";
  58838. this.use = attributes.use || "";
  58839. this.usehref = attributes.usehref || "";
  58840. }
  58841. }
  58842. class RootElement extends _xfa_object.StringObject {
  58843. constructor(attributes) {
  58844. super(CONNECTION_SET_NS_ID, "rootElement");
  58845. this.id = attributes.id || "";
  58846. this.name = attributes.name || "";
  58847. this.use = attributes.use || "";
  58848. this.usehref = attributes.usehref || "";
  58849. }
  58850. }
  58851. class SoapAction extends _xfa_object.StringObject {
  58852. constructor(attributes) {
  58853. super(CONNECTION_SET_NS_ID, "soapAction");
  58854. this.id = attributes.id || "";
  58855. this.name = attributes.name || "";
  58856. this.use = attributes.use || "";
  58857. this.usehref = attributes.usehref || "";
  58858. }
  58859. }
  58860. class SoapAddress extends _xfa_object.StringObject {
  58861. constructor(attributes) {
  58862. super(CONNECTION_SET_NS_ID, "soapAddress");
  58863. this.id = attributes.id || "";
  58864. this.name = attributes.name || "";
  58865. this.use = attributes.use || "";
  58866. this.usehref = attributes.usehref || "";
  58867. }
  58868. }
  58869. class Uri extends _xfa_object.StringObject {
  58870. constructor(attributes) {
  58871. super(CONNECTION_SET_NS_ID, "uri");
  58872. this.id = attributes.id || "";
  58873. this.name = attributes.name || "";
  58874. this.use = attributes.use || "";
  58875. this.usehref = attributes.usehref || "";
  58876. }
  58877. }
  58878. class WsdlAddress extends _xfa_object.StringObject {
  58879. constructor(attributes) {
  58880. super(CONNECTION_SET_NS_ID, "wsdlAddress");
  58881. this.id = attributes.id || "";
  58882. this.name = attributes.name || "";
  58883. this.use = attributes.use || "";
  58884. this.usehref = attributes.usehref || "";
  58885. }
  58886. }
  58887. class WsdlConnection extends _xfa_object.XFAObject {
  58888. constructor(attributes) {
  58889. super(CONNECTION_SET_NS_ID, "wsdlConnection", true);
  58890. this.dataDescription = attributes.dataDescription || "";
  58891. this.name = attributes.name || "";
  58892. this.effectiveInputPolicy = null;
  58893. this.effectiveOutputPolicy = null;
  58894. this.operation = null;
  58895. this.soapAction = null;
  58896. this.soapAddress = null;
  58897. this.wsdlAddress = null;
  58898. }
  58899. }
  58900. class XmlConnection extends _xfa_object.XFAObject {
  58901. constructor(attributes) {
  58902. super(CONNECTION_SET_NS_ID, "xmlConnection", true);
  58903. this.dataDescription = attributes.dataDescription || "";
  58904. this.name = attributes.name || "";
  58905. this.uri = null;
  58906. }
  58907. }
  58908. class XsdConnection extends _xfa_object.XFAObject {
  58909. constructor(attributes) {
  58910. super(CONNECTION_SET_NS_ID, "xsdConnection", true);
  58911. this.dataDescription = attributes.dataDescription || "";
  58912. this.name = attributes.name || "";
  58913. this.rootElement = null;
  58914. this.uri = null;
  58915. }
  58916. }
  58917. class ConnectionSetNamespace {
  58918. static [_namespaces.$buildXFAObject](name, attributes) {
  58919. if (ConnectionSetNamespace.hasOwnProperty(name)) {
  58920. return ConnectionSetNamespace[name](attributes);
  58921. }
  58922. return undefined;
  58923. }
  58924. static connectionSet(attrs) {
  58925. return new ConnectionSet(attrs);
  58926. }
  58927. static effectiveInputPolicy(attrs) {
  58928. return new EffectiveInputPolicy(attrs);
  58929. }
  58930. static effectiveOutputPolicy(attrs) {
  58931. return new EffectiveOutputPolicy(attrs);
  58932. }
  58933. static operation(attrs) {
  58934. return new Operation(attrs);
  58935. }
  58936. static rootElement(attrs) {
  58937. return new RootElement(attrs);
  58938. }
  58939. static soapAction(attrs) {
  58940. return new SoapAction(attrs);
  58941. }
  58942. static soapAddress(attrs) {
  58943. return new SoapAddress(attrs);
  58944. }
  58945. static uri(attrs) {
  58946. return new Uri(attrs);
  58947. }
  58948. static wsdlAddress(attrs) {
  58949. return new WsdlAddress(attrs);
  58950. }
  58951. static wsdlConnection(attrs) {
  58952. return new WsdlConnection(attrs);
  58953. }
  58954. static xmlConnection(attrs) {
  58955. return new XmlConnection(attrs);
  58956. }
  58957. static xsdConnection(attrs) {
  58958. return new XsdConnection(attrs);
  58959. }
  58960. }
  58961. exports.ConnectionSetNamespace = ConnectionSetNamespace;
  58962. /***/ }),
  58963. /* 249 */
  58964. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  58965. Object.defineProperty(exports, "__esModule", ({
  58966. value: true
  58967. }));
  58968. exports.DatasetsNamespace = void 0;
  58969. var _symbol_utils = __w_pdfjs_require__(229);
  58970. var _namespaces = __w_pdfjs_require__(235);
  58971. var _xfa_object = __w_pdfjs_require__(241);
  58972. const DATASETS_NS_ID = _namespaces.NamespaceIds.datasets.id;
  58973. class Data extends _xfa_object.XmlObject {
  58974. constructor(attributes) {
  58975. super(DATASETS_NS_ID, "data", attributes);
  58976. }
  58977. [_symbol_utils.$isNsAgnostic]() {
  58978. return true;
  58979. }
  58980. }
  58981. class Datasets extends _xfa_object.XFAObject {
  58982. constructor(attributes) {
  58983. super(DATASETS_NS_ID, "datasets", true);
  58984. this.data = null;
  58985. this.Signature = null;
  58986. }
  58987. [_symbol_utils.$onChild](child) {
  58988. const name = child[_symbol_utils.$nodeName];
  58989. if (name === "data" && child[_symbol_utils.$namespaceId] === DATASETS_NS_ID || name === "Signature" && child[_symbol_utils.$namespaceId] === _namespaces.NamespaceIds.signature.id) {
  58990. this[name] = child;
  58991. }
  58992. this[_symbol_utils.$appendChild](child);
  58993. }
  58994. }
  58995. class DatasetsNamespace {
  58996. static [_namespaces.$buildXFAObject](name, attributes) {
  58997. if (DatasetsNamespace.hasOwnProperty(name)) {
  58998. return DatasetsNamespace[name](attributes);
  58999. }
  59000. return undefined;
  59001. }
  59002. static datasets(attributes) {
  59003. return new Datasets(attributes);
  59004. }
  59005. static data(attributes) {
  59006. return new Data(attributes);
  59007. }
  59008. }
  59009. exports.DatasetsNamespace = DatasetsNamespace;
  59010. /***/ }),
  59011. /* 250 */
  59012. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  59013. Object.defineProperty(exports, "__esModule", ({
  59014. value: true
  59015. }));
  59016. exports.LocaleSetNamespace = void 0;
  59017. var _namespaces = __w_pdfjs_require__(235);
  59018. var _xfa_object = __w_pdfjs_require__(241);
  59019. var _utils = __w_pdfjs_require__(238);
  59020. const LOCALE_SET_NS_ID = _namespaces.NamespaceIds.localeSet.id;
  59021. class CalendarSymbols extends _xfa_object.XFAObject {
  59022. constructor(attributes) {
  59023. super(LOCALE_SET_NS_ID, "calendarSymbols", true);
  59024. this.name = "gregorian";
  59025. this.dayNames = new _xfa_object.XFAObjectArray(2);
  59026. this.eraNames = null;
  59027. this.meridiemNames = null;
  59028. this.monthNames = new _xfa_object.XFAObjectArray(2);
  59029. }
  59030. }
  59031. class CurrencySymbol extends _xfa_object.StringObject {
  59032. constructor(attributes) {
  59033. super(LOCALE_SET_NS_ID, "currencySymbol");
  59034. this.name = (0, _utils.getStringOption)(attributes.name, ["symbol", "isoname", "decimal"]);
  59035. }
  59036. }
  59037. class CurrencySymbols extends _xfa_object.XFAObject {
  59038. constructor(attributes) {
  59039. super(LOCALE_SET_NS_ID, "currencySymbols", true);
  59040. this.currencySymbol = new _xfa_object.XFAObjectArray(3);
  59041. }
  59042. }
  59043. class DatePattern extends _xfa_object.StringObject {
  59044. constructor(attributes) {
  59045. super(LOCALE_SET_NS_ID, "datePattern");
  59046. this.name = (0, _utils.getStringOption)(attributes.name, ["full", "long", "med", "short"]);
  59047. }
  59048. }
  59049. class DatePatterns extends _xfa_object.XFAObject {
  59050. constructor(attributes) {
  59051. super(LOCALE_SET_NS_ID, "datePatterns", true);
  59052. this.datePattern = new _xfa_object.XFAObjectArray(4);
  59053. }
  59054. }
  59055. class DateTimeSymbols extends _xfa_object.ContentObject {
  59056. constructor(attributes) {
  59057. super(LOCALE_SET_NS_ID, "dateTimeSymbols");
  59058. }
  59059. }
  59060. class Day extends _xfa_object.StringObject {
  59061. constructor(attributes) {
  59062. super(LOCALE_SET_NS_ID, "day");
  59063. }
  59064. }
  59065. class DayNames extends _xfa_object.XFAObject {
  59066. constructor(attributes) {
  59067. super(LOCALE_SET_NS_ID, "dayNames", true);
  59068. this.abbr = (0, _utils.getInteger)({
  59069. data: attributes.abbr,
  59070. defaultValue: 0,
  59071. validate: x => x === 1
  59072. });
  59073. this.day = new _xfa_object.XFAObjectArray(7);
  59074. }
  59075. }
  59076. class Era extends _xfa_object.StringObject {
  59077. constructor(attributes) {
  59078. super(LOCALE_SET_NS_ID, "era");
  59079. }
  59080. }
  59081. class EraNames extends _xfa_object.XFAObject {
  59082. constructor(attributes) {
  59083. super(LOCALE_SET_NS_ID, "eraNames", true);
  59084. this.era = new _xfa_object.XFAObjectArray(2);
  59085. }
  59086. }
  59087. class Locale extends _xfa_object.XFAObject {
  59088. constructor(attributes) {
  59089. super(LOCALE_SET_NS_ID, "locale", true);
  59090. this.desc = attributes.desc || "";
  59091. this.name = "isoname";
  59092. this.calendarSymbols = null;
  59093. this.currencySymbols = null;
  59094. this.datePatterns = null;
  59095. this.dateTimeSymbols = null;
  59096. this.numberPatterns = null;
  59097. this.numberSymbols = null;
  59098. this.timePatterns = null;
  59099. this.typeFaces = null;
  59100. }
  59101. }
  59102. class LocaleSet extends _xfa_object.XFAObject {
  59103. constructor(attributes) {
  59104. super(LOCALE_SET_NS_ID, "localeSet", true);
  59105. this.locale = new _xfa_object.XFAObjectArray();
  59106. }
  59107. }
  59108. class Meridiem extends _xfa_object.StringObject {
  59109. constructor(attributes) {
  59110. super(LOCALE_SET_NS_ID, "meridiem");
  59111. }
  59112. }
  59113. class MeridiemNames extends _xfa_object.XFAObject {
  59114. constructor(attributes) {
  59115. super(LOCALE_SET_NS_ID, "meridiemNames", true);
  59116. this.meridiem = new _xfa_object.XFAObjectArray(2);
  59117. }
  59118. }
  59119. class Month extends _xfa_object.StringObject {
  59120. constructor(attributes) {
  59121. super(LOCALE_SET_NS_ID, "month");
  59122. }
  59123. }
  59124. class MonthNames extends _xfa_object.XFAObject {
  59125. constructor(attributes) {
  59126. super(LOCALE_SET_NS_ID, "monthNames", true);
  59127. this.abbr = (0, _utils.getInteger)({
  59128. data: attributes.abbr,
  59129. defaultValue: 0,
  59130. validate: x => x === 1
  59131. });
  59132. this.month = new _xfa_object.XFAObjectArray(12);
  59133. }
  59134. }
  59135. class NumberPattern extends _xfa_object.StringObject {
  59136. constructor(attributes) {
  59137. super(LOCALE_SET_NS_ID, "numberPattern");
  59138. this.name = (0, _utils.getStringOption)(attributes.name, ["full", "long", "med", "short"]);
  59139. }
  59140. }
  59141. class NumberPatterns extends _xfa_object.XFAObject {
  59142. constructor(attributes) {
  59143. super(LOCALE_SET_NS_ID, "numberPatterns", true);
  59144. this.numberPattern = new _xfa_object.XFAObjectArray(4);
  59145. }
  59146. }
  59147. class NumberSymbol extends _xfa_object.StringObject {
  59148. constructor(attributes) {
  59149. super(LOCALE_SET_NS_ID, "numberSymbol");
  59150. this.name = (0, _utils.getStringOption)(attributes.name, ["decimal", "grouping", "percent", "minus", "zero"]);
  59151. }
  59152. }
  59153. class NumberSymbols extends _xfa_object.XFAObject {
  59154. constructor(attributes) {
  59155. super(LOCALE_SET_NS_ID, "numberSymbols", true);
  59156. this.numberSymbol = new _xfa_object.XFAObjectArray(5);
  59157. }
  59158. }
  59159. class TimePattern extends _xfa_object.StringObject {
  59160. constructor(attributes) {
  59161. super(LOCALE_SET_NS_ID, "timePattern");
  59162. this.name = (0, _utils.getStringOption)(attributes.name, ["full", "long", "med", "short"]);
  59163. }
  59164. }
  59165. class TimePatterns extends _xfa_object.XFAObject {
  59166. constructor(attributes) {
  59167. super(LOCALE_SET_NS_ID, "timePatterns", true);
  59168. this.timePattern = new _xfa_object.XFAObjectArray(4);
  59169. }
  59170. }
  59171. class TypeFace extends _xfa_object.XFAObject {
  59172. constructor(attributes) {
  59173. super(LOCALE_SET_NS_ID, "typeFace", true);
  59174. this.name = attributes.name | "";
  59175. }
  59176. }
  59177. class TypeFaces extends _xfa_object.XFAObject {
  59178. constructor(attributes) {
  59179. super(LOCALE_SET_NS_ID, "typeFaces", true);
  59180. this.typeFace = new _xfa_object.XFAObjectArray();
  59181. }
  59182. }
  59183. class LocaleSetNamespace {
  59184. static [_namespaces.$buildXFAObject](name, attributes) {
  59185. if (LocaleSetNamespace.hasOwnProperty(name)) {
  59186. return LocaleSetNamespace[name](attributes);
  59187. }
  59188. return undefined;
  59189. }
  59190. static calendarSymbols(attrs) {
  59191. return new CalendarSymbols(attrs);
  59192. }
  59193. static currencySymbol(attrs) {
  59194. return new CurrencySymbol(attrs);
  59195. }
  59196. static currencySymbols(attrs) {
  59197. return new CurrencySymbols(attrs);
  59198. }
  59199. static datePattern(attrs) {
  59200. return new DatePattern(attrs);
  59201. }
  59202. static datePatterns(attrs) {
  59203. return new DatePatterns(attrs);
  59204. }
  59205. static dateTimeSymbols(attrs) {
  59206. return new DateTimeSymbols(attrs);
  59207. }
  59208. static day(attrs) {
  59209. return new Day(attrs);
  59210. }
  59211. static dayNames(attrs) {
  59212. return new DayNames(attrs);
  59213. }
  59214. static era(attrs) {
  59215. return new Era(attrs);
  59216. }
  59217. static eraNames(attrs) {
  59218. return new EraNames(attrs);
  59219. }
  59220. static locale(attrs) {
  59221. return new Locale(attrs);
  59222. }
  59223. static localeSet(attrs) {
  59224. return new LocaleSet(attrs);
  59225. }
  59226. static meridiem(attrs) {
  59227. return new Meridiem(attrs);
  59228. }
  59229. static meridiemNames(attrs) {
  59230. return new MeridiemNames(attrs);
  59231. }
  59232. static month(attrs) {
  59233. return new Month(attrs);
  59234. }
  59235. static monthNames(attrs) {
  59236. return new MonthNames(attrs);
  59237. }
  59238. static numberPattern(attrs) {
  59239. return new NumberPattern(attrs);
  59240. }
  59241. static numberPatterns(attrs) {
  59242. return new NumberPatterns(attrs);
  59243. }
  59244. static numberSymbol(attrs) {
  59245. return new NumberSymbol(attrs);
  59246. }
  59247. static numberSymbols(attrs) {
  59248. return new NumberSymbols(attrs);
  59249. }
  59250. static timePattern(attrs) {
  59251. return new TimePattern(attrs);
  59252. }
  59253. static timePatterns(attrs) {
  59254. return new TimePatterns(attrs);
  59255. }
  59256. static typeFace(attrs) {
  59257. return new TypeFace(attrs);
  59258. }
  59259. static typeFaces(attrs) {
  59260. return new TypeFaces(attrs);
  59261. }
  59262. }
  59263. exports.LocaleSetNamespace = LocaleSetNamespace;
  59264. /***/ }),
  59265. /* 251 */
  59266. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  59267. Object.defineProperty(exports, "__esModule", ({
  59268. value: true
  59269. }));
  59270. exports.SignatureNamespace = void 0;
  59271. var _namespaces = __w_pdfjs_require__(235);
  59272. var _xfa_object = __w_pdfjs_require__(241);
  59273. const SIGNATURE_NS_ID = _namespaces.NamespaceIds.signature.id;
  59274. class Signature extends _xfa_object.XFAObject {
  59275. constructor(attributes) {
  59276. super(SIGNATURE_NS_ID, "signature", true);
  59277. }
  59278. }
  59279. class SignatureNamespace {
  59280. static [_namespaces.$buildXFAObject](name, attributes) {
  59281. if (SignatureNamespace.hasOwnProperty(name)) {
  59282. return SignatureNamespace[name](attributes);
  59283. }
  59284. return undefined;
  59285. }
  59286. static signature(attributes) {
  59287. return new Signature(attributes);
  59288. }
  59289. }
  59290. exports.SignatureNamespace = SignatureNamespace;
  59291. /***/ }),
  59292. /* 252 */
  59293. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  59294. Object.defineProperty(exports, "__esModule", ({
  59295. value: true
  59296. }));
  59297. exports.StylesheetNamespace = void 0;
  59298. var _namespaces = __w_pdfjs_require__(235);
  59299. var _xfa_object = __w_pdfjs_require__(241);
  59300. const STYLESHEET_NS_ID = _namespaces.NamespaceIds.stylesheet.id;
  59301. class Stylesheet extends _xfa_object.XFAObject {
  59302. constructor(attributes) {
  59303. super(STYLESHEET_NS_ID, "stylesheet", true);
  59304. }
  59305. }
  59306. class StylesheetNamespace {
  59307. static [_namespaces.$buildXFAObject](name, attributes) {
  59308. if (StylesheetNamespace.hasOwnProperty(name)) {
  59309. return StylesheetNamespace[name](attributes);
  59310. }
  59311. return undefined;
  59312. }
  59313. static stylesheet(attributes) {
  59314. return new Stylesheet(attributes);
  59315. }
  59316. }
  59317. exports.StylesheetNamespace = StylesheetNamespace;
  59318. /***/ }),
  59319. /* 253 */
  59320. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  59321. Object.defineProperty(exports, "__esModule", ({
  59322. value: true
  59323. }));
  59324. exports.XdpNamespace = void 0;
  59325. var _namespaces = __w_pdfjs_require__(235);
  59326. var _symbol_utils = __w_pdfjs_require__(229);
  59327. var _xfa_object = __w_pdfjs_require__(241);
  59328. const XDP_NS_ID = _namespaces.NamespaceIds.xdp.id;
  59329. class Xdp extends _xfa_object.XFAObject {
  59330. constructor(attributes) {
  59331. super(XDP_NS_ID, "xdp", true);
  59332. this.uuid = attributes.uuid || "";
  59333. this.timeStamp = attributes.timeStamp || "";
  59334. this.config = null;
  59335. this.connectionSet = null;
  59336. this.datasets = null;
  59337. this.localeSet = null;
  59338. this.stylesheet = new _xfa_object.XFAObjectArray();
  59339. this.template = null;
  59340. }
  59341. [_symbol_utils.$onChildCheck](child) {
  59342. const ns = _namespaces.NamespaceIds[child[_symbol_utils.$nodeName]];
  59343. return ns && child[_symbol_utils.$namespaceId] === ns.id;
  59344. }
  59345. }
  59346. class XdpNamespace {
  59347. static [_namespaces.$buildXFAObject](name, attributes) {
  59348. if (XdpNamespace.hasOwnProperty(name)) {
  59349. return XdpNamespace[name](attributes);
  59350. }
  59351. return undefined;
  59352. }
  59353. static xdp(attributes) {
  59354. return new Xdp(attributes);
  59355. }
  59356. }
  59357. exports.XdpNamespace = XdpNamespace;
  59358. /***/ }),
  59359. /* 254 */
  59360. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  59361. Object.defineProperty(exports, "__esModule", ({
  59362. value: true
  59363. }));
  59364. exports.XhtmlNamespace = void 0;
  59365. __w_pdfjs_require__(116);
  59366. __w_pdfjs_require__(127);
  59367. __w_pdfjs_require__(129);
  59368. __w_pdfjs_require__(132);
  59369. __w_pdfjs_require__(134);
  59370. __w_pdfjs_require__(136);
  59371. __w_pdfjs_require__(138);
  59372. var _symbol_utils = __w_pdfjs_require__(229);
  59373. var _namespaces = __w_pdfjs_require__(235);
  59374. var _html_utils = __w_pdfjs_require__(237);
  59375. var _utils = __w_pdfjs_require__(238);
  59376. var _xfa_object = __w_pdfjs_require__(241);
  59377. const XHTML_NS_ID = _namespaces.NamespaceIds.xhtml.id;
  59378. const $richText = Symbol();
  59379. 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"]);
  59380. 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) => {
  59381. value = original.fontSize = (0, _utils.getMeasurement)(value);
  59382. return (0, _html_utils.measureToString)(0.99 * value);
  59383. }], ["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))]]);
  59384. const spacesRegExp = /\s+/g;
  59385. const crlfRegExp = /[\r\n]+/g;
  59386. const crlfForRichTextRegExp = /\r\n?/g;
  59387. function mapStyle(styleStr, node, richText) {
  59388. const style = Object.create(null);
  59389. if (!styleStr) {
  59390. return style;
  59391. }
  59392. const original = Object.create(null);
  59393. for (const [key, value] of styleStr.split(";").map(s => s.split(":", 2))) {
  59394. const mapping = StyleMapping.get(key);
  59395. if (mapping === "") {
  59396. continue;
  59397. }
  59398. let newValue = value;
  59399. if (mapping) {
  59400. newValue = typeof mapping === "string" ? mapping : mapping(value, original);
  59401. }
  59402. if (key.endsWith("scale")) {
  59403. style.transform = style.transform ? `${style[key]} ${newValue}` : newValue;
  59404. } else {
  59405. style[key.replaceAll(/-([a-zA-Z])/g, (_, x) => x.toUpperCase())] = newValue;
  59406. }
  59407. }
  59408. if (style.fontFamily) {
  59409. (0, _html_utils.setFontFamily)({
  59410. typeface: style.fontFamily,
  59411. weight: style.fontWeight || "normal",
  59412. posture: style.fontStyle || "normal",
  59413. size: original.fontSize || 0
  59414. }, node, node[_symbol_utils.$globalData].fontFinder, style);
  59415. }
  59416. if (richText && style.verticalAlign && style.verticalAlign !== "0px" && style.fontSize) {
  59417. const SUB_SUPER_SCRIPT_FACTOR = 0.583;
  59418. const VERTICAL_FACTOR = 0.333;
  59419. const fontSize = (0, _utils.getMeasurement)(style.fontSize);
  59420. style.fontSize = (0, _html_utils.measureToString)(fontSize * SUB_SUPER_SCRIPT_FACTOR);
  59421. style.verticalAlign = (0, _html_utils.measureToString)(Math.sign((0, _utils.getMeasurement)(style.verticalAlign)) * fontSize * VERTICAL_FACTOR);
  59422. }
  59423. if (richText && style.fontSize) {
  59424. style.fontSize = `calc(${style.fontSize} * var(--scale-factor))`;
  59425. }
  59426. (0, _html_utils.fixTextIndent)(style);
  59427. return style;
  59428. }
  59429. function checkStyle(node) {
  59430. if (!node.style) {
  59431. return "";
  59432. }
  59433. return node.style.trim().split(/\s*;\s*/).filter(s => !!s).map(s => s.split(/\s*:\s*/, 2)).filter(_ref => {
  59434. let [key, value] = _ref;
  59435. if (key === "font-family") {
  59436. node[_symbol_utils.$globalData].usedTypefaces.add(value);
  59437. }
  59438. return VALID_STYLES.has(key);
  59439. }).map(kv => kv.join(":")).join(";");
  59440. }
  59441. const NoWhites = new Set(["body", "html"]);
  59442. class XhtmlObject extends _xfa_object.XmlObject {
  59443. constructor(attributes, name) {
  59444. super(XHTML_NS_ID, name);
  59445. this[$richText] = false;
  59446. this.style = attributes.style || "";
  59447. }
  59448. [_symbol_utils.$clean](builder) {
  59449. super[_symbol_utils.$clean](builder);
  59450. this.style = checkStyle(this);
  59451. }
  59452. [_symbol_utils.$acceptWhitespace]() {
  59453. return !NoWhites.has(this[_symbol_utils.$nodeName]);
  59454. }
  59455. [_symbol_utils.$onText](str) {
  59456. let richText = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  59457. if (!richText) {
  59458. str = str.replaceAll(crlfRegExp, "");
  59459. if (!this.style.includes("xfa-spacerun:yes")) {
  59460. str = str.replaceAll(spacesRegExp, " ");
  59461. }
  59462. } else {
  59463. this[$richText] = true;
  59464. }
  59465. if (str) {
  59466. this[_symbol_utils.$content] += str;
  59467. }
  59468. }
  59469. [_symbol_utils.$pushGlyphs](measure) {
  59470. let mustPop = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
  59471. const xfaFont = Object.create(null);
  59472. const margin = {
  59473. top: NaN,
  59474. bottom: NaN,
  59475. left: NaN,
  59476. right: NaN
  59477. };
  59478. let lineHeight = null;
  59479. for (const [key, value] of this.style.split(";").map(s => s.split(":", 2))) {
  59480. switch (key) {
  59481. case "font-family":
  59482. xfaFont.typeface = (0, _utils.stripQuotes)(value);
  59483. break;
  59484. case "font-size":
  59485. xfaFont.size = (0, _utils.getMeasurement)(value);
  59486. break;
  59487. case "font-weight":
  59488. xfaFont.weight = value;
  59489. break;
  59490. case "font-style":
  59491. xfaFont.posture = value;
  59492. break;
  59493. case "letter-spacing":
  59494. xfaFont.letterSpacing = (0, _utils.getMeasurement)(value);
  59495. break;
  59496. case "margin":
  59497. const values = value.split(/ \t/).map(x => (0, _utils.getMeasurement)(x));
  59498. switch (values.length) {
  59499. case 1:
  59500. margin.top = margin.bottom = margin.left = margin.right = values[0];
  59501. break;
  59502. case 2:
  59503. margin.top = margin.bottom = values[0];
  59504. margin.left = margin.right = values[1];
  59505. break;
  59506. case 3:
  59507. margin.top = values[0];
  59508. margin.bottom = values[2];
  59509. margin.left = margin.right = values[1];
  59510. break;
  59511. case 4:
  59512. margin.top = values[0];
  59513. margin.left = values[1];
  59514. margin.bottom = values[2];
  59515. margin.right = values[3];
  59516. break;
  59517. }
  59518. break;
  59519. case "margin-top":
  59520. margin.top = (0, _utils.getMeasurement)(value);
  59521. break;
  59522. case "margin-bottom":
  59523. margin.bottom = (0, _utils.getMeasurement)(value);
  59524. break;
  59525. case "margin-left":
  59526. margin.left = (0, _utils.getMeasurement)(value);
  59527. break;
  59528. case "margin-right":
  59529. margin.right = (0, _utils.getMeasurement)(value);
  59530. break;
  59531. case "line-height":
  59532. lineHeight = (0, _utils.getMeasurement)(value);
  59533. break;
  59534. }
  59535. }
  59536. measure.pushData(xfaFont, margin, lineHeight);
  59537. if (this[_symbol_utils.$content]) {
  59538. measure.addString(this[_symbol_utils.$content]);
  59539. } else {
  59540. for (const child of this[_symbol_utils.$getChildren]()) {
  59541. if (child[_symbol_utils.$nodeName] === "#text") {
  59542. measure.addString(child[_symbol_utils.$content]);
  59543. continue;
  59544. }
  59545. child[_symbol_utils.$pushGlyphs](measure);
  59546. }
  59547. }
  59548. if (mustPop) {
  59549. measure.popFont();
  59550. }
  59551. }
  59552. [_symbol_utils.$toHTML](availableSpace) {
  59553. const children = [];
  59554. this[_symbol_utils.$extra] = {
  59555. children
  59556. };
  59557. this[_symbol_utils.$childrenToHTML]({});
  59558. if (children.length === 0 && !this[_symbol_utils.$content]) {
  59559. return _utils.HTMLResult.EMPTY;
  59560. }
  59561. let value;
  59562. if (this[$richText]) {
  59563. value = this[_symbol_utils.$content] ? this[_symbol_utils.$content].replaceAll(crlfForRichTextRegExp, "\n") : undefined;
  59564. } else {
  59565. value = this[_symbol_utils.$content] || undefined;
  59566. }
  59567. return _utils.HTMLResult.success({
  59568. name: this[_symbol_utils.$nodeName],
  59569. attributes: {
  59570. href: this.href,
  59571. style: mapStyle(this.style, this, this[$richText])
  59572. },
  59573. children,
  59574. value
  59575. });
  59576. }
  59577. }
  59578. class A extends XhtmlObject {
  59579. constructor(attributes) {
  59580. super(attributes, "a");
  59581. this.href = (0, _html_utils.fixURL)(attributes.href) || "";
  59582. }
  59583. }
  59584. class B extends XhtmlObject {
  59585. constructor(attributes) {
  59586. super(attributes, "b");
  59587. }
  59588. [_symbol_utils.$pushGlyphs](measure) {
  59589. measure.pushFont({
  59590. weight: "bold"
  59591. });
  59592. super[_symbol_utils.$pushGlyphs](measure);
  59593. measure.popFont();
  59594. }
  59595. }
  59596. class Body extends XhtmlObject {
  59597. constructor(attributes) {
  59598. super(attributes, "body");
  59599. }
  59600. [_symbol_utils.$toHTML](availableSpace) {
  59601. const res = super[_symbol_utils.$toHTML](availableSpace);
  59602. const {
  59603. html
  59604. } = res;
  59605. if (!html) {
  59606. return _utils.HTMLResult.EMPTY;
  59607. }
  59608. html.name = "div";
  59609. html.attributes.class = ["xfaRich"];
  59610. return res;
  59611. }
  59612. }
  59613. class Br extends XhtmlObject {
  59614. constructor(attributes) {
  59615. super(attributes, "br");
  59616. }
  59617. [_symbol_utils.$text]() {
  59618. return "\n";
  59619. }
  59620. [_symbol_utils.$pushGlyphs](measure) {
  59621. measure.addString("\n");
  59622. }
  59623. [_symbol_utils.$toHTML](availableSpace) {
  59624. return _utils.HTMLResult.success({
  59625. name: "br"
  59626. });
  59627. }
  59628. }
  59629. class Html extends XhtmlObject {
  59630. constructor(attributes) {
  59631. super(attributes, "html");
  59632. }
  59633. [_symbol_utils.$toHTML](availableSpace) {
  59634. const children = [];
  59635. this[_symbol_utils.$extra] = {
  59636. children
  59637. };
  59638. this[_symbol_utils.$childrenToHTML]({});
  59639. if (children.length === 0) {
  59640. return _utils.HTMLResult.success({
  59641. name: "div",
  59642. attributes: {
  59643. class: ["xfaRich"],
  59644. style: {}
  59645. },
  59646. value: this[_symbol_utils.$content] || ""
  59647. });
  59648. }
  59649. if (children.length === 1) {
  59650. const child = children[0];
  59651. if (child.attributes?.class.includes("xfaRich")) {
  59652. return _utils.HTMLResult.success(child);
  59653. }
  59654. }
  59655. return _utils.HTMLResult.success({
  59656. name: "div",
  59657. attributes: {
  59658. class: ["xfaRich"],
  59659. style: {}
  59660. },
  59661. children
  59662. });
  59663. }
  59664. }
  59665. class I extends XhtmlObject {
  59666. constructor(attributes) {
  59667. super(attributes, "i");
  59668. }
  59669. [_symbol_utils.$pushGlyphs](measure) {
  59670. measure.pushFont({
  59671. posture: "italic"
  59672. });
  59673. super[_symbol_utils.$pushGlyphs](measure);
  59674. measure.popFont();
  59675. }
  59676. }
  59677. class Li extends XhtmlObject {
  59678. constructor(attributes) {
  59679. super(attributes, "li");
  59680. }
  59681. }
  59682. class Ol extends XhtmlObject {
  59683. constructor(attributes) {
  59684. super(attributes, "ol");
  59685. }
  59686. }
  59687. class P extends XhtmlObject {
  59688. constructor(attributes) {
  59689. super(attributes, "p");
  59690. }
  59691. [_symbol_utils.$pushGlyphs](measure) {
  59692. super[_symbol_utils.$pushGlyphs](measure, false);
  59693. measure.addString("\n");
  59694. measure.addPara();
  59695. measure.popFont();
  59696. }
  59697. [_symbol_utils.$text]() {
  59698. const siblings = this[_symbol_utils.$getParent]()[_symbol_utils.$getChildren]();
  59699. if (siblings.at(-1) === this) {
  59700. return super[_symbol_utils.$text]();
  59701. }
  59702. return super[_symbol_utils.$text]() + "\n";
  59703. }
  59704. }
  59705. class Span extends XhtmlObject {
  59706. constructor(attributes) {
  59707. super(attributes, "span");
  59708. }
  59709. }
  59710. class Sub extends XhtmlObject {
  59711. constructor(attributes) {
  59712. super(attributes, "sub");
  59713. }
  59714. }
  59715. class Sup extends XhtmlObject {
  59716. constructor(attributes) {
  59717. super(attributes, "sup");
  59718. }
  59719. }
  59720. class Ul extends XhtmlObject {
  59721. constructor(attributes) {
  59722. super(attributes, "ul");
  59723. }
  59724. }
  59725. class XhtmlNamespace {
  59726. static [_namespaces.$buildXFAObject](name, attributes) {
  59727. if (XhtmlNamespace.hasOwnProperty(name)) {
  59728. return XhtmlNamespace[name](attributes);
  59729. }
  59730. return undefined;
  59731. }
  59732. static a(attributes) {
  59733. return new A(attributes);
  59734. }
  59735. static b(attributes) {
  59736. return new B(attributes);
  59737. }
  59738. static body(attributes) {
  59739. return new Body(attributes);
  59740. }
  59741. static br(attributes) {
  59742. return new Br(attributes);
  59743. }
  59744. static html(attributes) {
  59745. return new Html(attributes);
  59746. }
  59747. static i(attributes) {
  59748. return new I(attributes);
  59749. }
  59750. static li(attributes) {
  59751. return new Li(attributes);
  59752. }
  59753. static ol(attributes) {
  59754. return new Ol(attributes);
  59755. }
  59756. static p(attributes) {
  59757. return new P(attributes);
  59758. }
  59759. static span(attributes) {
  59760. return new Span(attributes);
  59761. }
  59762. static sub(attributes) {
  59763. return new Sub(attributes);
  59764. }
  59765. static sup(attributes) {
  59766. return new Sup(attributes);
  59767. }
  59768. static ul(attributes) {
  59769. return new Ul(attributes);
  59770. }
  59771. }
  59772. exports.XhtmlNamespace = XhtmlNamespace;
  59773. /***/ }),
  59774. /* 255 */
  59775. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  59776. Object.defineProperty(exports, "__esModule", ({
  59777. value: true
  59778. }));
  59779. exports.UnknownNamespace = void 0;
  59780. var _namespaces = __w_pdfjs_require__(235);
  59781. var _xfa_object = __w_pdfjs_require__(241);
  59782. class UnknownNamespace {
  59783. constructor(nsId) {
  59784. this.namespaceId = nsId;
  59785. }
  59786. [_namespaces.$buildXFAObject](name, attributes) {
  59787. return new _xfa_object.XmlObject(this.namespaceId, name, attributes);
  59788. }
  59789. }
  59790. exports.UnknownNamespace = UnknownNamespace;
  59791. /***/ }),
  59792. /* 256 */
  59793. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  59794. Object.defineProperty(exports, "__esModule", ({
  59795. value: true
  59796. }));
  59797. exports.DatasetReader = void 0;
  59798. __w_pdfjs_require__(2);
  59799. var _util = __w_pdfjs_require__(145);
  59800. var _core_utils = __w_pdfjs_require__(150);
  59801. var _xml_parser = __w_pdfjs_require__(218);
  59802. function decodeString(str) {
  59803. try {
  59804. return (0, _util.stringToUTF8String)(str);
  59805. } catch (ex) {
  59806. (0, _util.warn)(`UTF-8 decoding failed: "${ex}".`);
  59807. return str;
  59808. }
  59809. }
  59810. class DatasetXMLParser extends _xml_parser.SimpleXMLParser {
  59811. constructor(options) {
  59812. super(options);
  59813. this.node = null;
  59814. }
  59815. onEndElement(name) {
  59816. const node = super.onEndElement(name);
  59817. if (node && name === "xfa:datasets") {
  59818. this.node = node;
  59819. throw new Error("Aborting DatasetXMLParser.");
  59820. }
  59821. }
  59822. }
  59823. class DatasetReader {
  59824. constructor(data) {
  59825. if (data.datasets) {
  59826. this.node = new _xml_parser.SimpleXMLParser({
  59827. hasAttributes: true
  59828. }).parseFromString(data.datasets).documentElement;
  59829. } else {
  59830. const parser = new DatasetXMLParser({
  59831. hasAttributes: true
  59832. });
  59833. try {
  59834. parser.parseFromString(data["xdp:xdp"]);
  59835. } catch {}
  59836. this.node = parser.node;
  59837. }
  59838. }
  59839. getValue(path) {
  59840. if (!this.node || !path) {
  59841. return "";
  59842. }
  59843. const node = this.node.searchNode((0, _core_utils.parseXFAPath)(path), 0);
  59844. if (!node) {
  59845. return "";
  59846. }
  59847. const first = node.firstChild;
  59848. if (first?.nodeName === "value") {
  59849. return node.children.map(child => decodeString(child.textContent));
  59850. }
  59851. return decodeString(node.textContent);
  59852. }
  59853. }
  59854. exports.DatasetReader = DatasetReader;
  59855. /***/ }),
  59856. /* 257 */
  59857. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  59858. Object.defineProperty(exports, "__esModule", ({
  59859. value: true
  59860. }));
  59861. exports.XRef = void 0;
  59862. __w_pdfjs_require__(116);
  59863. __w_pdfjs_require__(127);
  59864. __w_pdfjs_require__(129);
  59865. __w_pdfjs_require__(132);
  59866. __w_pdfjs_require__(134);
  59867. __w_pdfjs_require__(136);
  59868. __w_pdfjs_require__(138);
  59869. __w_pdfjs_require__(84);
  59870. __w_pdfjs_require__(93);
  59871. __w_pdfjs_require__(94);
  59872. __w_pdfjs_require__(97);
  59873. __w_pdfjs_require__(99);
  59874. __w_pdfjs_require__(101);
  59875. __w_pdfjs_require__(105);
  59876. __w_pdfjs_require__(108);
  59877. __w_pdfjs_require__(115);
  59878. __w_pdfjs_require__(140);
  59879. __w_pdfjs_require__(2);
  59880. var _util = __w_pdfjs_require__(145);
  59881. var _primitives = __w_pdfjs_require__(151);
  59882. var _parser = __w_pdfjs_require__(167);
  59883. var _core_utils = __w_pdfjs_require__(150);
  59884. var _base_stream = __w_pdfjs_require__(152);
  59885. var _crypto = __w_pdfjs_require__(219);
  59886. class XRef {
  59887. #firstXRefStmPos = null;
  59888. constructor(stream, pdfManager) {
  59889. this.stream = stream;
  59890. this.pdfManager = pdfManager;
  59891. this.entries = [];
  59892. this._xrefStms = new Set();
  59893. this._cacheMap = new Map();
  59894. this._pendingRefs = new _primitives.RefSet();
  59895. this._newPersistentRefNum = null;
  59896. this._newTemporaryRefNum = null;
  59897. }
  59898. getNewPersistentRef(obj) {
  59899. if (this._newPersistentRefNum === null) {
  59900. this._newPersistentRefNum = this.entries.length || 1;
  59901. }
  59902. const num = this._newPersistentRefNum++;
  59903. this._cacheMap.set(num, obj);
  59904. return _primitives.Ref.get(num, 0);
  59905. }
  59906. getNewTemporaryRef() {
  59907. if (this._newTemporaryRefNum === null) {
  59908. this._newTemporaryRefNum = this.entries.length || 1;
  59909. }
  59910. return _primitives.Ref.get(this._newTemporaryRefNum++, 0);
  59911. }
  59912. resetNewTemporaryRef() {
  59913. this._newTemporaryRefNum = null;
  59914. }
  59915. setStartXRef(startXRef) {
  59916. this.startXRefQueue = [startXRef];
  59917. }
  59918. parse() {
  59919. let recoveryMode = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  59920. let trailerDict;
  59921. if (!recoveryMode) {
  59922. trailerDict = this.readXRef();
  59923. } else {
  59924. (0, _util.warn)("Indexing all PDF objects");
  59925. trailerDict = this.indexObjects();
  59926. }
  59927. trailerDict.assignXref(this);
  59928. this.trailer = trailerDict;
  59929. let encrypt;
  59930. try {
  59931. encrypt = trailerDict.get("Encrypt");
  59932. } catch (ex) {
  59933. if (ex instanceof _core_utils.MissingDataException) {
  59934. throw ex;
  59935. }
  59936. (0, _util.warn)(`XRef.parse - Invalid "Encrypt" reference: "${ex}".`);
  59937. }
  59938. if (encrypt instanceof _primitives.Dict) {
  59939. const ids = trailerDict.get("ID");
  59940. const fileId = ids?.length ? ids[0] : "";
  59941. encrypt.suppressEncryption = true;
  59942. this.encrypt = new _crypto.CipherTransformFactory(encrypt, fileId, this.pdfManager.password);
  59943. }
  59944. let root;
  59945. try {
  59946. root = trailerDict.get("Root");
  59947. } catch (ex) {
  59948. if (ex instanceof _core_utils.MissingDataException) {
  59949. throw ex;
  59950. }
  59951. (0, _util.warn)(`XRef.parse - Invalid "Root" reference: "${ex}".`);
  59952. }
  59953. if (root instanceof _primitives.Dict) {
  59954. try {
  59955. const pages = root.get("Pages");
  59956. if (pages instanceof _primitives.Dict) {
  59957. this.root = root;
  59958. return;
  59959. }
  59960. } catch (ex) {
  59961. if (ex instanceof _core_utils.MissingDataException) {
  59962. throw ex;
  59963. }
  59964. (0, _util.warn)(`XRef.parse - Invalid "Pages" reference: "${ex}".`);
  59965. }
  59966. }
  59967. if (!recoveryMode) {
  59968. throw new _core_utils.XRefParseException();
  59969. }
  59970. throw new _util.InvalidPDFException("Invalid Root reference.");
  59971. }
  59972. processXRefTable(parser) {
  59973. if (!("tableState" in this)) {
  59974. this.tableState = {
  59975. entryNum: 0,
  59976. streamPos: parser.lexer.stream.pos,
  59977. parserBuf1: parser.buf1,
  59978. parserBuf2: parser.buf2
  59979. };
  59980. }
  59981. const obj = this.readXRefTable(parser);
  59982. if (!(0, _primitives.isCmd)(obj, "trailer")) {
  59983. throw new _util.FormatError("Invalid XRef table: could not find trailer dictionary");
  59984. }
  59985. let dict = parser.getObj();
  59986. if (!(dict instanceof _primitives.Dict) && dict.dict) {
  59987. dict = dict.dict;
  59988. }
  59989. if (!(dict instanceof _primitives.Dict)) {
  59990. throw new _util.FormatError("Invalid XRef table: could not parse trailer dictionary");
  59991. }
  59992. delete this.tableState;
  59993. return dict;
  59994. }
  59995. readXRefTable(parser) {
  59996. const stream = parser.lexer.stream;
  59997. const tableState = this.tableState;
  59998. stream.pos = tableState.streamPos;
  59999. parser.buf1 = tableState.parserBuf1;
  60000. parser.buf2 = tableState.parserBuf2;
  60001. let obj;
  60002. while (true) {
  60003. if (!("firstEntryNum" in tableState) || !("entryCount" in tableState)) {
  60004. if ((0, _primitives.isCmd)(obj = parser.getObj(), "trailer")) {
  60005. break;
  60006. }
  60007. tableState.firstEntryNum = obj;
  60008. tableState.entryCount = parser.getObj();
  60009. }
  60010. let first = tableState.firstEntryNum;
  60011. const count = tableState.entryCount;
  60012. if (!Number.isInteger(first) || !Number.isInteger(count)) {
  60013. throw new _util.FormatError("Invalid XRef table: wrong types in subsection header");
  60014. }
  60015. for (let i = tableState.entryNum; i < count; i++) {
  60016. tableState.streamPos = stream.pos;
  60017. tableState.entryNum = i;
  60018. tableState.parserBuf1 = parser.buf1;
  60019. tableState.parserBuf2 = parser.buf2;
  60020. const entry = {};
  60021. entry.offset = parser.getObj();
  60022. entry.gen = parser.getObj();
  60023. const type = parser.getObj();
  60024. if (type instanceof _primitives.Cmd) {
  60025. switch (type.cmd) {
  60026. case "f":
  60027. entry.free = true;
  60028. break;
  60029. case "n":
  60030. entry.uncompressed = true;
  60031. break;
  60032. }
  60033. }
  60034. if (!Number.isInteger(entry.offset) || !Number.isInteger(entry.gen) || !(entry.free || entry.uncompressed)) {
  60035. throw new _util.FormatError(`Invalid entry in XRef subsection: ${first}, ${count}`);
  60036. }
  60037. if (i === 0 && entry.free && first === 1) {
  60038. first = 0;
  60039. }
  60040. if (!this.entries[i + first]) {
  60041. this.entries[i + first] = entry;
  60042. }
  60043. }
  60044. tableState.entryNum = 0;
  60045. tableState.streamPos = stream.pos;
  60046. tableState.parserBuf1 = parser.buf1;
  60047. tableState.parserBuf2 = parser.buf2;
  60048. delete tableState.firstEntryNum;
  60049. delete tableState.entryCount;
  60050. }
  60051. if (this.entries[0] && !this.entries[0].free) {
  60052. throw new _util.FormatError("Invalid XRef table: unexpected first object");
  60053. }
  60054. return obj;
  60055. }
  60056. processXRefStream(stream) {
  60057. if (!("streamState" in this)) {
  60058. const streamParameters = stream.dict;
  60059. const byteWidths = streamParameters.get("W");
  60060. let range = streamParameters.get("Index");
  60061. if (!range) {
  60062. range = [0, streamParameters.get("Size")];
  60063. }
  60064. this.streamState = {
  60065. entryRanges: range,
  60066. byteWidths,
  60067. entryNum: 0,
  60068. streamPos: stream.pos
  60069. };
  60070. }
  60071. this.readXRefStream(stream);
  60072. delete this.streamState;
  60073. return stream.dict;
  60074. }
  60075. readXRefStream(stream) {
  60076. const streamState = this.streamState;
  60077. stream.pos = streamState.streamPos;
  60078. const [typeFieldWidth, offsetFieldWidth, generationFieldWidth] = streamState.byteWidths;
  60079. const entryRanges = streamState.entryRanges;
  60080. while (entryRanges.length > 0) {
  60081. const [first, n] = entryRanges;
  60082. if (!Number.isInteger(first) || !Number.isInteger(n)) {
  60083. throw new _util.FormatError(`Invalid XRef range fields: ${first}, ${n}`);
  60084. }
  60085. if (!Number.isInteger(typeFieldWidth) || !Number.isInteger(offsetFieldWidth) || !Number.isInteger(generationFieldWidth)) {
  60086. throw new _util.FormatError(`Invalid XRef entry fields length: ${first}, ${n}`);
  60087. }
  60088. for (let i = streamState.entryNum; i < n; ++i) {
  60089. streamState.entryNum = i;
  60090. streamState.streamPos = stream.pos;
  60091. let type = 0,
  60092. offset = 0,
  60093. generation = 0;
  60094. for (let j = 0; j < typeFieldWidth; ++j) {
  60095. const typeByte = stream.getByte();
  60096. if (typeByte === -1) {
  60097. throw new _util.FormatError("Invalid XRef byteWidths 'type'.");
  60098. }
  60099. type = type << 8 | typeByte;
  60100. }
  60101. if (typeFieldWidth === 0) {
  60102. type = 1;
  60103. }
  60104. for (let j = 0; j < offsetFieldWidth; ++j) {
  60105. const offsetByte = stream.getByte();
  60106. if (offsetByte === -1) {
  60107. throw new _util.FormatError("Invalid XRef byteWidths 'offset'.");
  60108. }
  60109. offset = offset << 8 | offsetByte;
  60110. }
  60111. for (let j = 0; j < generationFieldWidth; ++j) {
  60112. const generationByte = stream.getByte();
  60113. if (generationByte === -1) {
  60114. throw new _util.FormatError("Invalid XRef byteWidths 'generation'.");
  60115. }
  60116. generation = generation << 8 | generationByte;
  60117. }
  60118. const entry = {};
  60119. entry.offset = offset;
  60120. entry.gen = generation;
  60121. switch (type) {
  60122. case 0:
  60123. entry.free = true;
  60124. break;
  60125. case 1:
  60126. entry.uncompressed = true;
  60127. break;
  60128. case 2:
  60129. break;
  60130. default:
  60131. throw new _util.FormatError(`Invalid XRef entry type: ${type}`);
  60132. }
  60133. if (!this.entries[first + i]) {
  60134. this.entries[first + i] = entry;
  60135. }
  60136. }
  60137. streamState.entryNum = 0;
  60138. streamState.streamPos = stream.pos;
  60139. entryRanges.splice(0, 2);
  60140. }
  60141. }
  60142. indexObjects() {
  60143. const TAB = 0x9,
  60144. LF = 0xa,
  60145. CR = 0xd,
  60146. SPACE = 0x20;
  60147. const PERCENT = 0x25,
  60148. LT = 0x3c;
  60149. function readToken(data, offset) {
  60150. let token = "",
  60151. ch = data[offset];
  60152. while (ch !== LF && ch !== CR && ch !== LT) {
  60153. if (++offset >= data.length) {
  60154. break;
  60155. }
  60156. token += String.fromCharCode(ch);
  60157. ch = data[offset];
  60158. }
  60159. return token;
  60160. }
  60161. function skipUntil(data, offset, what) {
  60162. const length = what.length,
  60163. dataLength = data.length;
  60164. let skipped = 0;
  60165. while (offset < dataLength) {
  60166. let i = 0;
  60167. while (i < length && data[offset + i] === what[i]) {
  60168. ++i;
  60169. }
  60170. if (i >= length) {
  60171. break;
  60172. }
  60173. offset++;
  60174. skipped++;
  60175. }
  60176. return skipped;
  60177. }
  60178. const gEndobjRegExp = /\b(endobj|\d+\s+\d+\s+obj|xref|trailer\s*<<)\b/g;
  60179. const gStartxrefRegExp = /\b(startxref|\d+\s+\d+\s+obj)\b/g;
  60180. const objRegExp = /^(\d+)\s+(\d+)\s+obj\b/;
  60181. const trailerBytes = new Uint8Array([116, 114, 97, 105, 108, 101, 114]);
  60182. const startxrefBytes = new Uint8Array([115, 116, 97, 114, 116, 120, 114, 101, 102]);
  60183. const xrefBytes = new Uint8Array([47, 88, 82, 101, 102]);
  60184. this.entries.length = 0;
  60185. this._cacheMap.clear();
  60186. const stream = this.stream;
  60187. stream.pos = 0;
  60188. const buffer = stream.getBytes(),
  60189. bufferStr = (0, _util.bytesToString)(buffer),
  60190. length = buffer.length;
  60191. let position = stream.start;
  60192. const trailers = [],
  60193. xrefStms = [];
  60194. while (position < length) {
  60195. let ch = buffer[position];
  60196. if (ch === TAB || ch === LF || ch === CR || ch === SPACE) {
  60197. ++position;
  60198. continue;
  60199. }
  60200. if (ch === PERCENT) {
  60201. do {
  60202. ++position;
  60203. if (position >= length) {
  60204. break;
  60205. }
  60206. ch = buffer[position];
  60207. } while (ch !== LF && ch !== CR);
  60208. continue;
  60209. }
  60210. const token = readToken(buffer, position);
  60211. let m;
  60212. if (token.startsWith("xref") && (token.length === 4 || /\s/.test(token[4]))) {
  60213. position += skipUntil(buffer, position, trailerBytes);
  60214. trailers.push(position);
  60215. position += skipUntil(buffer, position, startxrefBytes);
  60216. } else if (m = objRegExp.exec(token)) {
  60217. const num = m[1] | 0,
  60218. gen = m[2] | 0;
  60219. const startPos = position + token.length;
  60220. let contentLength,
  60221. updateEntries = false;
  60222. if (!this.entries[num]) {
  60223. updateEntries = true;
  60224. } else if (this.entries[num].gen === gen) {
  60225. try {
  60226. const parser = new _parser.Parser({
  60227. lexer: new _parser.Lexer(stream.makeSubStream(startPos))
  60228. });
  60229. parser.getObj();
  60230. updateEntries = true;
  60231. } catch (ex) {
  60232. if (ex instanceof _core_utils.ParserEOFException) {
  60233. (0, _util.warn)(`indexObjects -- checking object (${token}): "${ex}".`);
  60234. } else {
  60235. updateEntries = true;
  60236. }
  60237. }
  60238. }
  60239. if (updateEntries) {
  60240. this.entries[num] = {
  60241. offset: position - stream.start,
  60242. gen,
  60243. uncompressed: true
  60244. };
  60245. }
  60246. gEndobjRegExp.lastIndex = startPos;
  60247. const match = gEndobjRegExp.exec(bufferStr);
  60248. if (match) {
  60249. const endPos = gEndobjRegExp.lastIndex + 1;
  60250. contentLength = endPos - position;
  60251. if (match[1] !== "endobj") {
  60252. (0, _util.warn)(`indexObjects: Found "${match[1]}" inside of another "obj", ` + 'caused by missing "endobj" -- trying to recover.');
  60253. contentLength -= match[1].length + 1;
  60254. }
  60255. } else {
  60256. contentLength = length - position;
  60257. }
  60258. const content = buffer.subarray(position, position + contentLength);
  60259. const xrefTagOffset = skipUntil(content, 0, xrefBytes);
  60260. if (xrefTagOffset < contentLength && content[xrefTagOffset + 5] < 64) {
  60261. xrefStms.push(position - stream.start);
  60262. this._xrefStms.add(position - stream.start);
  60263. }
  60264. position += contentLength;
  60265. } else if (token.startsWith("trailer") && (token.length === 7 || /\s/.test(token[7]))) {
  60266. trailers.push(position);
  60267. const startPos = position + token.length;
  60268. let contentLength;
  60269. gStartxrefRegExp.lastIndex = startPos;
  60270. const match = gStartxrefRegExp.exec(bufferStr);
  60271. if (match) {
  60272. const endPos = gStartxrefRegExp.lastIndex + 1;
  60273. contentLength = endPos - position;
  60274. if (match[1] !== "startxref") {
  60275. (0, _util.warn)(`indexObjects: Found "${match[1]}" after "trailer", ` + 'caused by missing "startxref" -- trying to recover.');
  60276. contentLength -= match[1].length + 1;
  60277. }
  60278. } else {
  60279. contentLength = length - position;
  60280. }
  60281. position += contentLength;
  60282. } else {
  60283. position += token.length + 1;
  60284. }
  60285. }
  60286. for (const xrefStm of xrefStms) {
  60287. this.startXRefQueue.push(xrefStm);
  60288. this.readXRef(true);
  60289. }
  60290. const trailerDicts = [];
  60291. let isEncrypted = false;
  60292. for (const trailer of trailers) {
  60293. stream.pos = trailer;
  60294. const parser = new _parser.Parser({
  60295. lexer: new _parser.Lexer(stream),
  60296. xref: this,
  60297. allowStreams: true,
  60298. recoveryMode: true
  60299. });
  60300. const obj = parser.getObj();
  60301. if (!(0, _primitives.isCmd)(obj, "trailer")) {
  60302. continue;
  60303. }
  60304. const dict = parser.getObj();
  60305. if (!(dict instanceof _primitives.Dict)) {
  60306. continue;
  60307. }
  60308. trailerDicts.push(dict);
  60309. if (dict.has("Encrypt")) {
  60310. isEncrypted = true;
  60311. }
  60312. }
  60313. let trailerDict, trailerError;
  60314. for (const dict of [...trailerDicts, "genFallback", ...trailerDicts]) {
  60315. if (dict === "genFallback") {
  60316. if (!trailerError) {
  60317. break;
  60318. }
  60319. this._generationFallback = true;
  60320. continue;
  60321. }
  60322. let validPagesDict = false;
  60323. try {
  60324. const rootDict = dict.get("Root");
  60325. if (!(rootDict instanceof _primitives.Dict)) {
  60326. continue;
  60327. }
  60328. const pagesDict = rootDict.get("Pages");
  60329. if (!(pagesDict instanceof _primitives.Dict)) {
  60330. continue;
  60331. }
  60332. const pagesCount = pagesDict.get("Count");
  60333. if (Number.isInteger(pagesCount)) {
  60334. validPagesDict = true;
  60335. }
  60336. } catch (ex) {
  60337. trailerError = ex;
  60338. continue;
  60339. }
  60340. if (validPagesDict && (!isEncrypted || dict.has("Encrypt")) && dict.has("ID")) {
  60341. return dict;
  60342. }
  60343. trailerDict = dict;
  60344. }
  60345. if (trailerDict) {
  60346. return trailerDict;
  60347. }
  60348. if (this.topDict) {
  60349. return this.topDict;
  60350. }
  60351. throw new _util.InvalidPDFException("Invalid PDF structure.");
  60352. }
  60353. readXRef() {
  60354. let recoveryMode = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  60355. const stream = this.stream;
  60356. const startXRefParsedCache = new Set();
  60357. while (this.startXRefQueue.length) {
  60358. try {
  60359. const startXRef = this.startXRefQueue[0];
  60360. if (startXRefParsedCache.has(startXRef)) {
  60361. (0, _util.warn)("readXRef - skipping XRef table since it was already parsed.");
  60362. this.startXRefQueue.shift();
  60363. continue;
  60364. }
  60365. startXRefParsedCache.add(startXRef);
  60366. stream.pos = startXRef + stream.start;
  60367. const parser = new _parser.Parser({
  60368. lexer: new _parser.Lexer(stream),
  60369. xref: this,
  60370. allowStreams: true
  60371. });
  60372. let obj = parser.getObj();
  60373. let dict;
  60374. if ((0, _primitives.isCmd)(obj, "xref")) {
  60375. dict = this.processXRefTable(parser);
  60376. if (!this.topDict) {
  60377. this.topDict = dict;
  60378. }
  60379. obj = dict.get("XRefStm");
  60380. if (Number.isInteger(obj) && !this._xrefStms.has(obj)) {
  60381. this._xrefStms.add(obj);
  60382. this.startXRefQueue.push(obj);
  60383. this.#firstXRefStmPos ??= obj;
  60384. }
  60385. } else if (Number.isInteger(obj)) {
  60386. if (!Number.isInteger(parser.getObj()) || !(0, _primitives.isCmd)(parser.getObj(), "obj") || !((obj = parser.getObj()) instanceof _base_stream.BaseStream)) {
  60387. throw new _util.FormatError("Invalid XRef stream");
  60388. }
  60389. dict = this.processXRefStream(obj);
  60390. if (!this.topDict) {
  60391. this.topDict = dict;
  60392. }
  60393. if (!dict) {
  60394. throw new _util.FormatError("Failed to read XRef stream");
  60395. }
  60396. } else {
  60397. throw new _util.FormatError("Invalid XRef stream header");
  60398. }
  60399. obj = dict.get("Prev");
  60400. if (Number.isInteger(obj)) {
  60401. this.startXRefQueue.push(obj);
  60402. } else if (obj instanceof _primitives.Ref) {
  60403. this.startXRefQueue.push(obj.num);
  60404. }
  60405. } catch (e) {
  60406. if (e instanceof _core_utils.MissingDataException) {
  60407. throw e;
  60408. }
  60409. (0, _util.info)("(while reading XRef): " + e);
  60410. }
  60411. this.startXRefQueue.shift();
  60412. }
  60413. if (this.topDict) {
  60414. return this.topDict;
  60415. }
  60416. if (recoveryMode) {
  60417. return undefined;
  60418. }
  60419. throw new _core_utils.XRefParseException();
  60420. }
  60421. get lastXRefStreamPos() {
  60422. return this.#firstXRefStmPos ?? (this._xrefStms.size > 0 ? Math.max(...this._xrefStms) : null);
  60423. }
  60424. getEntry(i) {
  60425. const xrefEntry = this.entries[i];
  60426. if (xrefEntry && !xrefEntry.free && xrefEntry.offset) {
  60427. return xrefEntry;
  60428. }
  60429. return null;
  60430. }
  60431. fetchIfRef(obj) {
  60432. let suppressEncryption = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  60433. if (obj instanceof _primitives.Ref) {
  60434. return this.fetch(obj, suppressEncryption);
  60435. }
  60436. return obj;
  60437. }
  60438. fetch(ref) {
  60439. let suppressEncryption = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  60440. if (!(ref instanceof _primitives.Ref)) {
  60441. throw new Error("ref object is not a reference");
  60442. }
  60443. const num = ref.num;
  60444. const cacheEntry = this._cacheMap.get(num);
  60445. if (cacheEntry !== undefined) {
  60446. if (cacheEntry instanceof _primitives.Dict && !cacheEntry.objId) {
  60447. cacheEntry.objId = ref.toString();
  60448. }
  60449. return cacheEntry;
  60450. }
  60451. let xrefEntry = this.getEntry(num);
  60452. if (xrefEntry === null) {
  60453. this._cacheMap.set(num, xrefEntry);
  60454. return xrefEntry;
  60455. }
  60456. if (this._pendingRefs.has(ref)) {
  60457. this._pendingRefs.remove(ref);
  60458. (0, _util.warn)(`Ignoring circular reference: ${ref}.`);
  60459. return _primitives.CIRCULAR_REF;
  60460. }
  60461. this._pendingRefs.put(ref);
  60462. try {
  60463. xrefEntry = xrefEntry.uncompressed ? this.fetchUncompressed(ref, xrefEntry, suppressEncryption) : this.fetchCompressed(ref, xrefEntry, suppressEncryption);
  60464. this._pendingRefs.remove(ref);
  60465. } catch (ex) {
  60466. this._pendingRefs.remove(ref);
  60467. throw ex;
  60468. }
  60469. if (xrefEntry instanceof _primitives.Dict) {
  60470. xrefEntry.objId = ref.toString();
  60471. } else if (xrefEntry instanceof _base_stream.BaseStream) {
  60472. xrefEntry.dict.objId = ref.toString();
  60473. }
  60474. return xrefEntry;
  60475. }
  60476. fetchUncompressed(ref, xrefEntry) {
  60477. let suppressEncryption = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  60478. const gen = ref.gen;
  60479. let num = ref.num;
  60480. if (xrefEntry.gen !== gen) {
  60481. const msg = `Inconsistent generation in XRef: ${ref}`;
  60482. if (this._generationFallback && xrefEntry.gen < gen) {
  60483. (0, _util.warn)(msg);
  60484. return this.fetchUncompressed(_primitives.Ref.get(num, xrefEntry.gen), xrefEntry, suppressEncryption);
  60485. }
  60486. throw new _core_utils.XRefEntryException(msg);
  60487. }
  60488. const stream = this.stream.makeSubStream(xrefEntry.offset + this.stream.start);
  60489. const parser = new _parser.Parser({
  60490. lexer: new _parser.Lexer(stream),
  60491. xref: this,
  60492. allowStreams: true
  60493. });
  60494. const obj1 = parser.getObj();
  60495. const obj2 = parser.getObj();
  60496. const obj3 = parser.getObj();
  60497. if (obj1 !== num || obj2 !== gen || !(obj3 instanceof _primitives.Cmd)) {
  60498. throw new _core_utils.XRefEntryException(`Bad (uncompressed) XRef entry: ${ref}`);
  60499. }
  60500. if (obj3.cmd !== "obj") {
  60501. if (obj3.cmd.startsWith("obj")) {
  60502. num = parseInt(obj3.cmd.substring(3), 10);
  60503. if (!Number.isNaN(num)) {
  60504. return num;
  60505. }
  60506. }
  60507. throw new _core_utils.XRefEntryException(`Bad (uncompressed) XRef entry: ${ref}`);
  60508. }
  60509. xrefEntry = this.encrypt && !suppressEncryption ? parser.getObj(this.encrypt.createCipherTransform(num, gen)) : parser.getObj();
  60510. if (!(xrefEntry instanceof _base_stream.BaseStream)) {
  60511. this._cacheMap.set(num, xrefEntry);
  60512. }
  60513. return xrefEntry;
  60514. }
  60515. fetchCompressed(ref, xrefEntry) {
  60516. let suppressEncryption = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  60517. const tableOffset = xrefEntry.offset;
  60518. const stream = this.fetch(_primitives.Ref.get(tableOffset, 0));
  60519. if (!(stream instanceof _base_stream.BaseStream)) {
  60520. throw new _util.FormatError("bad ObjStm stream");
  60521. }
  60522. const first = stream.dict.get("First");
  60523. const n = stream.dict.get("N");
  60524. if (!Number.isInteger(first) || !Number.isInteger(n)) {
  60525. throw new _util.FormatError("invalid first and n parameters for ObjStm stream");
  60526. }
  60527. let parser = new _parser.Parser({
  60528. lexer: new _parser.Lexer(stream),
  60529. xref: this,
  60530. allowStreams: true
  60531. });
  60532. const nums = new Array(n);
  60533. const offsets = new Array(n);
  60534. for (let i = 0; i < n; ++i) {
  60535. const num = parser.getObj();
  60536. if (!Number.isInteger(num)) {
  60537. throw new _util.FormatError(`invalid object number in the ObjStm stream: ${num}`);
  60538. }
  60539. const offset = parser.getObj();
  60540. if (!Number.isInteger(offset)) {
  60541. throw new _util.FormatError(`invalid object offset in the ObjStm stream: ${offset}`);
  60542. }
  60543. nums[i] = num;
  60544. offsets[i] = offset;
  60545. }
  60546. const start = (stream.start || 0) + first;
  60547. const entries = new Array(n);
  60548. for (let i = 0; i < n; ++i) {
  60549. const length = i < n - 1 ? offsets[i + 1] - offsets[i] : undefined;
  60550. if (length < 0) {
  60551. throw new _util.FormatError("Invalid offset in the ObjStm stream.");
  60552. }
  60553. parser = new _parser.Parser({
  60554. lexer: new _parser.Lexer(stream.makeSubStream(start + offsets[i], length, stream.dict)),
  60555. xref: this,
  60556. allowStreams: true
  60557. });
  60558. const obj = parser.getObj();
  60559. entries[i] = obj;
  60560. if (obj instanceof _base_stream.BaseStream) {
  60561. continue;
  60562. }
  60563. const num = nums[i],
  60564. entry = this.entries[num];
  60565. if (entry && entry.offset === tableOffset && entry.gen === i) {
  60566. this._cacheMap.set(num, obj);
  60567. }
  60568. }
  60569. xrefEntry = entries[xrefEntry.gen];
  60570. if (xrefEntry === undefined) {
  60571. throw new _core_utils.XRefEntryException(`Bad (compressed) XRef entry: ${ref}`);
  60572. }
  60573. return xrefEntry;
  60574. }
  60575. async fetchIfRefAsync(obj, suppressEncryption) {
  60576. if (obj instanceof _primitives.Ref) {
  60577. return this.fetchAsync(obj, suppressEncryption);
  60578. }
  60579. return obj;
  60580. }
  60581. async fetchAsync(ref, suppressEncryption) {
  60582. try {
  60583. return this.fetch(ref, suppressEncryption);
  60584. } catch (ex) {
  60585. if (!(ex instanceof _core_utils.MissingDataException)) {
  60586. throw ex;
  60587. }
  60588. await this.pdfManager.requestRange(ex.begin, ex.end);
  60589. return this.fetchAsync(ref, suppressEncryption);
  60590. }
  60591. }
  60592. getCatalogObj() {
  60593. return this.root;
  60594. }
  60595. }
  60596. exports.XRef = XRef;
  60597. /***/ }),
  60598. /* 258 */
  60599. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  60600. Object.defineProperty(exports, "__esModule", ({
  60601. value: true
  60602. }));
  60603. exports.MessageHandler = void 0;
  60604. __w_pdfjs_require__(2);
  60605. var _util = __w_pdfjs_require__(145);
  60606. const CallbackKind = {
  60607. UNKNOWN: 0,
  60608. DATA: 1,
  60609. ERROR: 2
  60610. };
  60611. const StreamKind = {
  60612. UNKNOWN: 0,
  60613. CANCEL: 1,
  60614. CANCEL_COMPLETE: 2,
  60615. CLOSE: 3,
  60616. ENQUEUE: 4,
  60617. ERROR: 5,
  60618. PULL: 6,
  60619. PULL_COMPLETE: 7,
  60620. START_COMPLETE: 8
  60621. };
  60622. function wrapReason(reason) {
  60623. if (!(reason instanceof Error || typeof reason === "object" && reason !== null)) {
  60624. (0, _util.unreachable)('wrapReason: Expected "reason" to be a (possibly cloned) Error.');
  60625. }
  60626. switch (reason.name) {
  60627. case "AbortException":
  60628. return new _util.AbortException(reason.message);
  60629. case "MissingPDFException":
  60630. return new _util.MissingPDFException(reason.message);
  60631. case "PasswordException":
  60632. return new _util.PasswordException(reason.message, reason.code);
  60633. case "UnexpectedResponseException":
  60634. return new _util.UnexpectedResponseException(reason.message, reason.status);
  60635. case "UnknownErrorException":
  60636. return new _util.UnknownErrorException(reason.message, reason.details);
  60637. default:
  60638. return new _util.UnknownErrorException(reason.message, reason.toString());
  60639. }
  60640. }
  60641. class MessageHandler {
  60642. constructor(sourceName, targetName, comObj) {
  60643. this.sourceName = sourceName;
  60644. this.targetName = targetName;
  60645. this.comObj = comObj;
  60646. this.callbackId = 1;
  60647. this.streamId = 1;
  60648. this.streamSinks = Object.create(null);
  60649. this.streamControllers = Object.create(null);
  60650. this.callbackCapabilities = Object.create(null);
  60651. this.actionHandler = Object.create(null);
  60652. this._onComObjOnMessage = event => {
  60653. const data = event.data;
  60654. if (data.targetName !== this.sourceName) {
  60655. return;
  60656. }
  60657. if (data.stream) {
  60658. this.#processStreamMessage(data);
  60659. return;
  60660. }
  60661. if (data.callback) {
  60662. const callbackId = data.callbackId;
  60663. const capability = this.callbackCapabilities[callbackId];
  60664. if (!capability) {
  60665. throw new Error(`Cannot resolve callback ${callbackId}`);
  60666. }
  60667. delete this.callbackCapabilities[callbackId];
  60668. if (data.callback === CallbackKind.DATA) {
  60669. capability.resolve(data.data);
  60670. } else if (data.callback === CallbackKind.ERROR) {
  60671. capability.reject(wrapReason(data.reason));
  60672. } else {
  60673. throw new Error("Unexpected callback case");
  60674. }
  60675. return;
  60676. }
  60677. const action = this.actionHandler[data.action];
  60678. if (!action) {
  60679. throw new Error(`Unknown action from worker: ${data.action}`);
  60680. }
  60681. if (data.callbackId) {
  60682. const cbSourceName = this.sourceName;
  60683. const cbTargetName = data.sourceName;
  60684. new Promise(function (resolve) {
  60685. resolve(action(data.data));
  60686. }).then(function (result) {
  60687. comObj.postMessage({
  60688. sourceName: cbSourceName,
  60689. targetName: cbTargetName,
  60690. callback: CallbackKind.DATA,
  60691. callbackId: data.callbackId,
  60692. data: result
  60693. });
  60694. }, function (reason) {
  60695. comObj.postMessage({
  60696. sourceName: cbSourceName,
  60697. targetName: cbTargetName,
  60698. callback: CallbackKind.ERROR,
  60699. callbackId: data.callbackId,
  60700. reason: wrapReason(reason)
  60701. });
  60702. });
  60703. return;
  60704. }
  60705. if (data.streamId) {
  60706. this.#createStreamSink(data);
  60707. return;
  60708. }
  60709. action(data.data);
  60710. };
  60711. comObj.addEventListener("message", this._onComObjOnMessage);
  60712. }
  60713. on(actionName, handler) {
  60714. const ah = this.actionHandler;
  60715. if (ah[actionName]) {
  60716. throw new Error(`There is already an actionName called "${actionName}"`);
  60717. }
  60718. ah[actionName] = handler;
  60719. }
  60720. send(actionName, data, transfers) {
  60721. this.comObj.postMessage({
  60722. sourceName: this.sourceName,
  60723. targetName: this.targetName,
  60724. action: actionName,
  60725. data
  60726. }, transfers);
  60727. }
  60728. sendWithPromise(actionName, data, transfers) {
  60729. const callbackId = this.callbackId++;
  60730. const capability = new _util.PromiseCapability();
  60731. this.callbackCapabilities[callbackId] = capability;
  60732. try {
  60733. this.comObj.postMessage({
  60734. sourceName: this.sourceName,
  60735. targetName: this.targetName,
  60736. action: actionName,
  60737. callbackId,
  60738. data
  60739. }, transfers);
  60740. } catch (ex) {
  60741. capability.reject(ex);
  60742. }
  60743. return capability.promise;
  60744. }
  60745. sendWithStream(actionName, data, queueingStrategy, transfers) {
  60746. const streamId = this.streamId++,
  60747. sourceName = this.sourceName,
  60748. targetName = this.targetName,
  60749. comObj = this.comObj;
  60750. return new ReadableStream({
  60751. start: controller => {
  60752. const startCapability = new _util.PromiseCapability();
  60753. this.streamControllers[streamId] = {
  60754. controller,
  60755. startCall: startCapability,
  60756. pullCall: null,
  60757. cancelCall: null,
  60758. isClosed: false
  60759. };
  60760. comObj.postMessage({
  60761. sourceName,
  60762. targetName,
  60763. action: actionName,
  60764. streamId,
  60765. data,
  60766. desiredSize: controller.desiredSize
  60767. }, transfers);
  60768. return startCapability.promise;
  60769. },
  60770. pull: controller => {
  60771. const pullCapability = new _util.PromiseCapability();
  60772. this.streamControllers[streamId].pullCall = pullCapability;
  60773. comObj.postMessage({
  60774. sourceName,
  60775. targetName,
  60776. stream: StreamKind.PULL,
  60777. streamId,
  60778. desiredSize: controller.desiredSize
  60779. });
  60780. return pullCapability.promise;
  60781. },
  60782. cancel: reason => {
  60783. (0, _util.assert)(reason instanceof Error, "cancel must have a valid reason");
  60784. const cancelCapability = new _util.PromiseCapability();
  60785. this.streamControllers[streamId].cancelCall = cancelCapability;
  60786. this.streamControllers[streamId].isClosed = true;
  60787. comObj.postMessage({
  60788. sourceName,
  60789. targetName,
  60790. stream: StreamKind.CANCEL,
  60791. streamId,
  60792. reason: wrapReason(reason)
  60793. });
  60794. return cancelCapability.promise;
  60795. }
  60796. }, queueingStrategy);
  60797. }
  60798. #createStreamSink(data) {
  60799. const streamId = data.streamId,
  60800. sourceName = this.sourceName,
  60801. targetName = data.sourceName,
  60802. comObj = this.comObj;
  60803. const self = this,
  60804. action = this.actionHandler[data.action];
  60805. const streamSink = {
  60806. enqueue(chunk) {
  60807. let size = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
  60808. let transfers = arguments.length > 2 ? arguments[2] : undefined;
  60809. if (this.isCancelled) {
  60810. return;
  60811. }
  60812. const lastDesiredSize = this.desiredSize;
  60813. this.desiredSize -= size;
  60814. if (lastDesiredSize > 0 && this.desiredSize <= 0) {
  60815. this.sinkCapability = new _util.PromiseCapability();
  60816. this.ready = this.sinkCapability.promise;
  60817. }
  60818. comObj.postMessage({
  60819. sourceName,
  60820. targetName,
  60821. stream: StreamKind.ENQUEUE,
  60822. streamId,
  60823. chunk
  60824. }, transfers);
  60825. },
  60826. close() {
  60827. if (this.isCancelled) {
  60828. return;
  60829. }
  60830. this.isCancelled = true;
  60831. comObj.postMessage({
  60832. sourceName,
  60833. targetName,
  60834. stream: StreamKind.CLOSE,
  60835. streamId
  60836. });
  60837. delete self.streamSinks[streamId];
  60838. },
  60839. error(reason) {
  60840. (0, _util.assert)(reason instanceof Error, "error must have a valid reason");
  60841. if (this.isCancelled) {
  60842. return;
  60843. }
  60844. this.isCancelled = true;
  60845. comObj.postMessage({
  60846. sourceName,
  60847. targetName,
  60848. stream: StreamKind.ERROR,
  60849. streamId,
  60850. reason: wrapReason(reason)
  60851. });
  60852. },
  60853. sinkCapability: new _util.PromiseCapability(),
  60854. onPull: null,
  60855. onCancel: null,
  60856. isCancelled: false,
  60857. desiredSize: data.desiredSize,
  60858. ready: null
  60859. };
  60860. streamSink.sinkCapability.resolve();
  60861. streamSink.ready = streamSink.sinkCapability.promise;
  60862. this.streamSinks[streamId] = streamSink;
  60863. new Promise(function (resolve) {
  60864. resolve(action(data.data, streamSink));
  60865. }).then(function () {
  60866. comObj.postMessage({
  60867. sourceName,
  60868. targetName,
  60869. stream: StreamKind.START_COMPLETE,
  60870. streamId,
  60871. success: true
  60872. });
  60873. }, function (reason) {
  60874. comObj.postMessage({
  60875. sourceName,
  60876. targetName,
  60877. stream: StreamKind.START_COMPLETE,
  60878. streamId,
  60879. reason: wrapReason(reason)
  60880. });
  60881. });
  60882. }
  60883. #processStreamMessage(data) {
  60884. const streamId = data.streamId,
  60885. sourceName = this.sourceName,
  60886. targetName = data.sourceName,
  60887. comObj = this.comObj;
  60888. const streamController = this.streamControllers[streamId],
  60889. streamSink = this.streamSinks[streamId];
  60890. switch (data.stream) {
  60891. case StreamKind.START_COMPLETE:
  60892. if (data.success) {
  60893. streamController.startCall.resolve();
  60894. } else {
  60895. streamController.startCall.reject(wrapReason(data.reason));
  60896. }
  60897. break;
  60898. case StreamKind.PULL_COMPLETE:
  60899. if (data.success) {
  60900. streamController.pullCall.resolve();
  60901. } else {
  60902. streamController.pullCall.reject(wrapReason(data.reason));
  60903. }
  60904. break;
  60905. case StreamKind.PULL:
  60906. if (!streamSink) {
  60907. comObj.postMessage({
  60908. sourceName,
  60909. targetName,
  60910. stream: StreamKind.PULL_COMPLETE,
  60911. streamId,
  60912. success: true
  60913. });
  60914. break;
  60915. }
  60916. if (streamSink.desiredSize <= 0 && data.desiredSize > 0) {
  60917. streamSink.sinkCapability.resolve();
  60918. }
  60919. streamSink.desiredSize = data.desiredSize;
  60920. new Promise(function (resolve) {
  60921. resolve(streamSink.onPull?.());
  60922. }).then(function () {
  60923. comObj.postMessage({
  60924. sourceName,
  60925. targetName,
  60926. stream: StreamKind.PULL_COMPLETE,
  60927. streamId,
  60928. success: true
  60929. });
  60930. }, function (reason) {
  60931. comObj.postMessage({
  60932. sourceName,
  60933. targetName,
  60934. stream: StreamKind.PULL_COMPLETE,
  60935. streamId,
  60936. reason: wrapReason(reason)
  60937. });
  60938. });
  60939. break;
  60940. case StreamKind.ENQUEUE:
  60941. (0, _util.assert)(streamController, "enqueue should have stream controller");
  60942. if (streamController.isClosed) {
  60943. break;
  60944. }
  60945. streamController.controller.enqueue(data.chunk);
  60946. break;
  60947. case StreamKind.CLOSE:
  60948. (0, _util.assert)(streamController, "close should have stream controller");
  60949. if (streamController.isClosed) {
  60950. break;
  60951. }
  60952. streamController.isClosed = true;
  60953. streamController.controller.close();
  60954. this.#deleteStreamController(streamController, streamId);
  60955. break;
  60956. case StreamKind.ERROR:
  60957. (0, _util.assert)(streamController, "error should have stream controller");
  60958. streamController.controller.error(wrapReason(data.reason));
  60959. this.#deleteStreamController(streamController, streamId);
  60960. break;
  60961. case StreamKind.CANCEL_COMPLETE:
  60962. if (data.success) {
  60963. streamController.cancelCall.resolve();
  60964. } else {
  60965. streamController.cancelCall.reject(wrapReason(data.reason));
  60966. }
  60967. this.#deleteStreamController(streamController, streamId);
  60968. break;
  60969. case StreamKind.CANCEL:
  60970. if (!streamSink) {
  60971. break;
  60972. }
  60973. new Promise(function (resolve) {
  60974. resolve(streamSink.onCancel?.(wrapReason(data.reason)));
  60975. }).then(function () {
  60976. comObj.postMessage({
  60977. sourceName,
  60978. targetName,
  60979. stream: StreamKind.CANCEL_COMPLETE,
  60980. streamId,
  60981. success: true
  60982. });
  60983. }, function (reason) {
  60984. comObj.postMessage({
  60985. sourceName,
  60986. targetName,
  60987. stream: StreamKind.CANCEL_COMPLETE,
  60988. streamId,
  60989. reason: wrapReason(reason)
  60990. });
  60991. });
  60992. streamSink.sinkCapability.reject(wrapReason(data.reason));
  60993. streamSink.isCancelled = true;
  60994. delete this.streamSinks[streamId];
  60995. break;
  60996. default:
  60997. throw new Error("Unexpected stream case");
  60998. }
  60999. }
  61000. async #deleteStreamController(streamController, streamId) {
  61001. await Promise.allSettled([streamController.startCall?.promise, streamController.pullCall?.promise, streamController.cancelCall?.promise]);
  61002. delete this.streamControllers[streamId];
  61003. }
  61004. destroy() {
  61005. this.comObj.removeEventListener("message", this._onComObjOnMessage);
  61006. }
  61007. }
  61008. exports.MessageHandler = MessageHandler;
  61009. /***/ }),
  61010. /* 259 */
  61011. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  61012. Object.defineProperty(exports, "__esModule", ({
  61013. value: true
  61014. }));
  61015. exports.PDFWorkerStream = void 0;
  61016. __w_pdfjs_require__(140);
  61017. var _util = __w_pdfjs_require__(145);
  61018. class PDFWorkerStream {
  61019. constructor(msgHandler) {
  61020. this._msgHandler = msgHandler;
  61021. this._contentLength = null;
  61022. this._fullRequestReader = null;
  61023. this._rangeRequestReaders = [];
  61024. }
  61025. getFullReader() {
  61026. (0, _util.assert)(!this._fullRequestReader, "PDFWorkerStream.getFullReader can only be called once.");
  61027. this._fullRequestReader = new PDFWorkerStreamReader(this._msgHandler);
  61028. return this._fullRequestReader;
  61029. }
  61030. getRangeReader(begin, end) {
  61031. const reader = new PDFWorkerStreamRangeReader(begin, end, this._msgHandler);
  61032. this._rangeRequestReaders.push(reader);
  61033. return reader;
  61034. }
  61035. cancelAllRequests(reason) {
  61036. this._fullRequestReader?.cancel(reason);
  61037. for (const reader of this._rangeRequestReaders.slice(0)) {
  61038. reader.cancel(reason);
  61039. }
  61040. }
  61041. }
  61042. exports.PDFWorkerStream = PDFWorkerStream;
  61043. class PDFWorkerStreamReader {
  61044. constructor(msgHandler) {
  61045. this._msgHandler = msgHandler;
  61046. this.onProgress = null;
  61047. this._contentLength = null;
  61048. this._isRangeSupported = false;
  61049. this._isStreamingSupported = false;
  61050. const readableStream = this._msgHandler.sendWithStream("GetReader");
  61051. this._reader = readableStream.getReader();
  61052. this._headersReady = this._msgHandler.sendWithPromise("ReaderHeadersReady").then(data => {
  61053. this._isStreamingSupported = data.isStreamingSupported;
  61054. this._isRangeSupported = data.isRangeSupported;
  61055. this._contentLength = data.contentLength;
  61056. });
  61057. }
  61058. get headersReady() {
  61059. return this._headersReady;
  61060. }
  61061. get contentLength() {
  61062. return this._contentLength;
  61063. }
  61064. get isStreamingSupported() {
  61065. return this._isStreamingSupported;
  61066. }
  61067. get isRangeSupported() {
  61068. return this._isRangeSupported;
  61069. }
  61070. async read() {
  61071. const {
  61072. value,
  61073. done
  61074. } = await this._reader.read();
  61075. if (done) {
  61076. return {
  61077. value: undefined,
  61078. done: true
  61079. };
  61080. }
  61081. return {
  61082. value: value.buffer,
  61083. done: false
  61084. };
  61085. }
  61086. cancel(reason) {
  61087. this._reader.cancel(reason);
  61088. }
  61089. }
  61090. class PDFWorkerStreamRangeReader {
  61091. constructor(begin, end, msgHandler) {
  61092. this._msgHandler = msgHandler;
  61093. this.onProgress = null;
  61094. const readableStream = this._msgHandler.sendWithStream("GetRangeReader", {
  61095. begin,
  61096. end
  61097. });
  61098. this._reader = readableStream.getReader();
  61099. }
  61100. get isStreamingSupported() {
  61101. return false;
  61102. }
  61103. async read() {
  61104. const {
  61105. value,
  61106. done
  61107. } = await this._reader.read();
  61108. if (done) {
  61109. return {
  61110. value: undefined,
  61111. done: true
  61112. };
  61113. }
  61114. return {
  61115. value: value.buffer,
  61116. done: false
  61117. };
  61118. }
  61119. cancel(reason) {
  61120. this._reader.cancel(reason);
  61121. }
  61122. }
  61123. /***/ })
  61124. /******/ ]);
  61125. /************************************************************************/
  61126. /******/ // The module cache
  61127. /******/ var __webpack_module_cache__ = {};
  61128. /******/
  61129. /******/ // The require function
  61130. /******/ function __w_pdfjs_require__(moduleId) {
  61131. /******/ // Check if module is in cache
  61132. /******/ var cachedModule = __webpack_module_cache__[moduleId];
  61133. /******/ if (cachedModule !== undefined) {
  61134. /******/ return cachedModule.exports;
  61135. /******/ }
  61136. /******/ // Create a new module (and put it into the cache)
  61137. /******/ var module = __webpack_module_cache__[moduleId] = {
  61138. /******/ // no module.id needed
  61139. /******/ // no module.loaded needed
  61140. /******/ exports: {}
  61141. /******/ };
  61142. /******/
  61143. /******/ // Execute the module function
  61144. /******/ __webpack_modules__[moduleId].call(module.exports, module, module.exports, __w_pdfjs_require__);
  61145. /******/
  61146. /******/ // Return the exports of the module
  61147. /******/ return module.exports;
  61148. /******/ }
  61149. /******/
  61150. /************************************************************************/
  61151. var __webpack_exports__ = {};
  61152. // This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk.
  61153. (() => {
  61154. var exports = __webpack_exports__;
  61155. Object.defineProperty(exports, "__esModule", ({
  61156. value: true
  61157. }));
  61158. Object.defineProperty(exports, "WorkerMessageHandler", ({
  61159. enumerable: true,
  61160. get: function () {
  61161. return _worker.WorkerMessageHandler;
  61162. }
  61163. }));
  61164. var _worker = __w_pdfjs_require__(1);
  61165. const pdfjsVersion = '3.10.111';
  61166. const pdfjsBuild = 'e142baecb';
  61167. })();
  61168. /******/ return __webpack_exports__;
  61169. /******/ })()
  61170. ;
  61171. });
  61172. //# sourceMappingURL=pdf.worker.js.map