pdf_viewer.js 319 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226
  1. /**
  2. * @licstart The following is the entire license notice for the
  3. * Javascript code in this page
  4. *
  5. * Copyright 2021 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 = factory();
  25. else if(typeof define === 'function' && define.amd)
  26. define("pdfjs-dist/web/pdf_viewer", [], factory);
  27. else if(typeof exports === 'object')
  28. exports["pdfjs-dist/web/pdf_viewer"] = factory();
  29. else
  30. root["pdfjs-dist/web/pdf_viewer"] = root.pdfjsViewer = factory();
  31. })(this, function() {
  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.DefaultAnnotationLayerFactory = exports.AnnotationLayerBuilder = void 0;
  42. var _pdfjsLib = __w_pdfjs_require__(2);
  43. var _l10n_utils = __w_pdfjs_require__(3);
  44. var _pdf_link_service = __w_pdfjs_require__(6);
  45. function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
  46. function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
  47. function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
  48. function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
  49. function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
  50. function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
  51. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  52. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  53. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  54. var AnnotationLayerBuilder = /*#__PURE__*/function () {
  55. function AnnotationLayerBuilder(_ref) {
  56. var pageDiv = _ref.pageDiv,
  57. pdfPage = _ref.pdfPage,
  58. linkService = _ref.linkService,
  59. downloadManager = _ref.downloadManager,
  60. _ref$annotationStorag = _ref.annotationStorage,
  61. annotationStorage = _ref$annotationStorag === void 0 ? null : _ref$annotationStorag,
  62. _ref$imageResourcesPa = _ref.imageResourcesPath,
  63. imageResourcesPath = _ref$imageResourcesPa === void 0 ? "" : _ref$imageResourcesPa,
  64. _ref$renderInteractiv = _ref.renderInteractiveForms,
  65. renderInteractiveForms = _ref$renderInteractiv === void 0 ? true : _ref$renderInteractiv,
  66. _ref$l10n = _ref.l10n,
  67. l10n = _ref$l10n === void 0 ? _l10n_utils.NullL10n : _ref$l10n,
  68. _ref$enableScripting = _ref.enableScripting,
  69. enableScripting = _ref$enableScripting === void 0 ? false : _ref$enableScripting,
  70. _ref$hasJSActionsProm = _ref.hasJSActionsPromise,
  71. hasJSActionsPromise = _ref$hasJSActionsProm === void 0 ? null : _ref$hasJSActionsProm,
  72. _ref$mouseState = _ref.mouseState,
  73. mouseState = _ref$mouseState === void 0 ? null : _ref$mouseState;
  74. _classCallCheck(this, AnnotationLayerBuilder);
  75. this.pageDiv = pageDiv;
  76. this.pdfPage = pdfPage;
  77. this.linkService = linkService;
  78. this.downloadManager = downloadManager;
  79. this.imageResourcesPath = imageResourcesPath;
  80. this.renderInteractiveForms = renderInteractiveForms;
  81. this.l10n = l10n;
  82. this.annotationStorage = annotationStorage;
  83. this.enableScripting = enableScripting;
  84. this._hasJSActionsPromise = hasJSActionsPromise;
  85. this._mouseState = mouseState;
  86. this.div = null;
  87. this._cancelled = false;
  88. }
  89. _createClass(AnnotationLayerBuilder, [{
  90. key: "render",
  91. value: function render(viewport) {
  92. var _this = this;
  93. var intent = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "display";
  94. return Promise.all([this.pdfPage.getAnnotations({
  95. intent: intent
  96. }), this._hasJSActionsPromise]).then(function (_ref2) {
  97. var _ref3 = _slicedToArray(_ref2, 2),
  98. annotations = _ref3[0],
  99. _ref3$ = _ref3[1],
  100. hasJSActions = _ref3$ === void 0 ? false : _ref3$;
  101. if (_this._cancelled) {
  102. return;
  103. }
  104. if (annotations.length === 0) {
  105. return;
  106. }
  107. var parameters = {
  108. viewport: viewport.clone({
  109. dontFlip: true
  110. }),
  111. div: _this.div,
  112. annotations: annotations,
  113. page: _this.pdfPage,
  114. imageResourcesPath: _this.imageResourcesPath,
  115. renderInteractiveForms: _this.renderInteractiveForms,
  116. linkService: _this.linkService,
  117. downloadManager: _this.downloadManager,
  118. annotationStorage: _this.annotationStorage,
  119. enableScripting: _this.enableScripting,
  120. hasJSActions: hasJSActions,
  121. mouseState: _this._mouseState
  122. };
  123. if (_this.div) {
  124. _pdfjsLib.AnnotationLayer.update(parameters);
  125. } else {
  126. _this.div = document.createElement("div");
  127. _this.div.className = "annotationLayer";
  128. _this.pageDiv.appendChild(_this.div);
  129. parameters.div = _this.div;
  130. _pdfjsLib.AnnotationLayer.render(parameters);
  131. _this.l10n.translate(_this.div);
  132. }
  133. });
  134. }
  135. }, {
  136. key: "cancel",
  137. value: function cancel() {
  138. this._cancelled = true;
  139. }
  140. }, {
  141. key: "hide",
  142. value: function hide() {
  143. if (!this.div) {
  144. return;
  145. }
  146. this.div.hidden = true;
  147. }
  148. }]);
  149. return AnnotationLayerBuilder;
  150. }();
  151. exports.AnnotationLayerBuilder = AnnotationLayerBuilder;
  152. var DefaultAnnotationLayerFactory = /*#__PURE__*/function () {
  153. function DefaultAnnotationLayerFactory() {
  154. _classCallCheck(this, DefaultAnnotationLayerFactory);
  155. }
  156. _createClass(DefaultAnnotationLayerFactory, [{
  157. key: "createAnnotationLayerBuilder",
  158. value: function createAnnotationLayerBuilder(pageDiv, pdfPage) {
  159. var annotationStorage = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
  160. var imageResourcesPath = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : "";
  161. var renderInteractiveForms = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : true;
  162. var l10n = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : _l10n_utils.NullL10n;
  163. var enableScripting = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : false;
  164. var hasJSActionsPromise = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : null;
  165. var mouseState = arguments.length > 8 && arguments[8] !== undefined ? arguments[8] : null;
  166. return new AnnotationLayerBuilder({
  167. pageDiv: pageDiv,
  168. pdfPage: pdfPage,
  169. imageResourcesPath: imageResourcesPath,
  170. renderInteractiveForms: renderInteractiveForms,
  171. linkService: new _pdf_link_service.SimpleLinkService(),
  172. l10n: l10n,
  173. annotationStorage: annotationStorage,
  174. enableScripting: enableScripting,
  175. hasJSActionsPromise: hasJSActionsPromise,
  176. mouseState: mouseState
  177. });
  178. }
  179. }]);
  180. return DefaultAnnotationLayerFactory;
  181. }();
  182. exports.DefaultAnnotationLayerFactory = DefaultAnnotationLayerFactory;
  183. /***/ }),
  184. /* 2 */
  185. /***/ ((module) => {
  186. var pdfjsLib;
  187. if (typeof window !== "undefined" && window["pdfjs-dist/build/pdf"]) {
  188. pdfjsLib = window["pdfjs-dist/build/pdf"];
  189. } else {
  190. pdfjsLib = require("../build/pdf.js");
  191. }
  192. module.exports = pdfjsLib;
  193. /***/ }),
  194. /* 3 */
  195. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  196. Object.defineProperty(exports, "__esModule", ({
  197. value: true
  198. }));
  199. exports.fixupLangCode = fixupLangCode;
  200. exports.getL10nFallback = getL10nFallback;
  201. exports.NullL10n = void 0;
  202. var _regenerator = _interopRequireDefault(__w_pdfjs_require__(4));
  203. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  204. function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
  205. function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
  206. var DEFAULT_L10N_STRINGS = {
  207. of_pages: "of {{pagesCount}}",
  208. page_of_pages: "({{pageNumber}} of {{pagesCount}})",
  209. document_properties_kb: "{{size_kb}} KB ({{size_b}} bytes)",
  210. document_properties_mb: "{{size_mb}} MB ({{size_b}} bytes)",
  211. document_properties_date_string: "{{date}}, {{time}}",
  212. document_properties_page_size_unit_inches: "in",
  213. document_properties_page_size_unit_millimeters: "mm",
  214. document_properties_page_size_orientation_portrait: "portrait",
  215. document_properties_page_size_orientation_landscape: "landscape",
  216. document_properties_page_size_name_a3: "A3",
  217. document_properties_page_size_name_a4: "A4",
  218. document_properties_page_size_name_letter: "Letter",
  219. document_properties_page_size_name_legal: "Legal",
  220. document_properties_page_size_dimension_string: "{{width}} × {{height}} {{unit}} ({{orientation}})",
  221. document_properties_page_size_dimension_name_string: "{{width}} × {{height}} {{unit}} ({{name}}, {{orientation}})",
  222. document_properties_linearized_yes: "Yes",
  223. document_properties_linearized_no: "No",
  224. print_progress_percent: "{{progress}}%",
  225. "toggle_sidebar.title": "Toggle Sidebar",
  226. "toggle_sidebar_notification2.title": "Toggle Sidebar (document contains outline/attachments/layers)",
  227. additional_layers: "Additional Layers",
  228. page_landmark: "Page {{page}}",
  229. thumb_page_title: "Page {{page}}",
  230. thumb_page_canvas: "Thumbnail of Page {{page}}",
  231. find_reached_top: "Reached top of document, continued from bottom",
  232. find_reached_bottom: "Reached end of document, continued from top",
  233. "find_match_count[one]": "{{current}} of {{total}} match",
  234. "find_match_count[other]": "{{current}} of {{total}} matches",
  235. "find_match_count_limit[one]": "More than {{limit}} match",
  236. "find_match_count_limit[other]": "More than {{limit}} matches",
  237. find_not_found: "Phrase not found",
  238. error_version_info: "PDF.js v{{version}} (build: {{build}})",
  239. error_message: "Message: {{message}}",
  240. error_stack: "Stack: {{stack}}",
  241. error_file: "File: {{file}}",
  242. error_line: "Line: {{line}}",
  243. rendering_error: "An error occurred while rendering the page.",
  244. page_scale_width: "Page Width",
  245. page_scale_fit: "Page Fit",
  246. page_scale_auto: "Automatic Zoom",
  247. page_scale_actual: "Actual Size",
  248. page_scale_percent: "{{scale}}%",
  249. loading: "Loading…",
  250. loading_error: "An error occurred while loading the PDF.",
  251. invalid_file_error: "Invalid or corrupted PDF file.",
  252. missing_file_error: "Missing PDF file.",
  253. unexpected_response_error: "Unexpected server response.",
  254. printing_not_supported: "Warning: Printing is not fully supported by this browser.",
  255. printing_not_ready: "Warning: The PDF is not fully loaded for printing.",
  256. web_fonts_disabled: "Web fonts are disabled: unable to use embedded PDF fonts."
  257. };
  258. function getL10nFallback(key, args) {
  259. switch (key) {
  260. case "find_match_count":
  261. key = "find_match_count[".concat(args.total === 1 ? "one" : "other", "]");
  262. break;
  263. case "find_match_count_limit":
  264. key = "find_match_count_limit[".concat(args.limit === 1 ? "one" : "other", "]");
  265. break;
  266. }
  267. return DEFAULT_L10N_STRINGS[key] || "";
  268. }
  269. var PARTIAL_LANG_CODES = {
  270. en: "en-US",
  271. es: "es-ES",
  272. fy: "fy-NL",
  273. ga: "ga-IE",
  274. gu: "gu-IN",
  275. hi: "hi-IN",
  276. hy: "hy-AM",
  277. nb: "nb-NO",
  278. ne: "ne-NP",
  279. nn: "nn-NO",
  280. pa: "pa-IN",
  281. pt: "pt-PT",
  282. sv: "sv-SE",
  283. zh: "zh-CN"
  284. };
  285. function fixupLangCode(langCode) {
  286. return PARTIAL_LANG_CODES[langCode === null || langCode === void 0 ? void 0 : langCode.toLowerCase()] || langCode;
  287. }
  288. function formatL10nValue(text, args) {
  289. if (!args) {
  290. return text;
  291. }
  292. return text.replace(/\{\{\s*(\w+)\s*\}\}/g, function (all, name) {
  293. return name in args ? args[name] : "{{" + name + "}}";
  294. });
  295. }
  296. var NullL10n = {
  297. getLanguage: function getLanguage() {
  298. return _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
  299. return _regenerator["default"].wrap(function _callee$(_context) {
  300. while (1) {
  301. switch (_context.prev = _context.next) {
  302. case 0:
  303. return _context.abrupt("return", "en-us");
  304. case 1:
  305. case "end":
  306. return _context.stop();
  307. }
  308. }
  309. }, _callee);
  310. }))();
  311. },
  312. getDirection: function getDirection() {
  313. return _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee2() {
  314. return _regenerator["default"].wrap(function _callee2$(_context2) {
  315. while (1) {
  316. switch (_context2.prev = _context2.next) {
  317. case 0:
  318. return _context2.abrupt("return", "ltr");
  319. case 1:
  320. case "end":
  321. return _context2.stop();
  322. }
  323. }
  324. }, _callee2);
  325. }))();
  326. },
  327. get: function get(key) {
  328. var _arguments = arguments;
  329. return _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee3() {
  330. var args, fallback;
  331. return _regenerator["default"].wrap(function _callee3$(_context3) {
  332. while (1) {
  333. switch (_context3.prev = _context3.next) {
  334. case 0:
  335. args = _arguments.length > 1 && _arguments[1] !== undefined ? _arguments[1] : null;
  336. fallback = _arguments.length > 2 && _arguments[2] !== undefined ? _arguments[2] : getL10nFallback(key, args);
  337. return _context3.abrupt("return", formatL10nValue(fallback, args));
  338. case 3:
  339. case "end":
  340. return _context3.stop();
  341. }
  342. }
  343. }, _callee3);
  344. }))();
  345. },
  346. translate: function translate(element) {
  347. return _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee4() {
  348. return _regenerator["default"].wrap(function _callee4$(_context4) {
  349. while (1) {
  350. switch (_context4.prev = _context4.next) {
  351. case 0:
  352. case "end":
  353. return _context4.stop();
  354. }
  355. }
  356. }, _callee4);
  357. }))();
  358. }
  359. };
  360. exports.NullL10n = NullL10n;
  361. /***/ }),
  362. /* 4 */
  363. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  364. module.exports = __w_pdfjs_require__(5);
  365. /***/ }),
  366. /* 5 */
  367. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  368. /* module decorator */ module = __w_pdfjs_require__.nmd(module);
  369. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  370. var runtime = function (exports) {
  371. "use strict";
  372. var Op = Object.prototype;
  373. var hasOwn = Op.hasOwnProperty;
  374. var undefined;
  375. var $Symbol = typeof Symbol === "function" ? Symbol : {};
  376. var iteratorSymbol = $Symbol.iterator || "@@iterator";
  377. var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator";
  378. var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
  379. function define(obj, key, value) {
  380. Object.defineProperty(obj, key, {
  381. value: value,
  382. enumerable: true,
  383. configurable: true,
  384. writable: true
  385. });
  386. return obj[key];
  387. }
  388. try {
  389. define({}, "");
  390. } catch (err) {
  391. define = function define(obj, key, value) {
  392. return obj[key] = value;
  393. };
  394. }
  395. function wrap(innerFn, outerFn, self, tryLocsList) {
  396. var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator;
  397. var generator = Object.create(protoGenerator.prototype);
  398. var context = new Context(tryLocsList || []);
  399. generator._invoke = makeInvokeMethod(innerFn, self, context);
  400. return generator;
  401. }
  402. exports.wrap = wrap;
  403. function tryCatch(fn, obj, arg) {
  404. try {
  405. return {
  406. type: "normal",
  407. arg: fn.call(obj, arg)
  408. };
  409. } catch (err) {
  410. return {
  411. type: "throw",
  412. arg: err
  413. };
  414. }
  415. }
  416. var GenStateSuspendedStart = "suspendedStart";
  417. var GenStateSuspendedYield = "suspendedYield";
  418. var GenStateExecuting = "executing";
  419. var GenStateCompleted = "completed";
  420. var ContinueSentinel = {};
  421. function Generator() {}
  422. function GeneratorFunction() {}
  423. function GeneratorFunctionPrototype() {}
  424. var IteratorPrototype = {};
  425. define(IteratorPrototype, iteratorSymbol, function () {
  426. return this;
  427. });
  428. var getProto = Object.getPrototypeOf;
  429. var NativeIteratorPrototype = getProto && getProto(getProto(values([])));
  430. if (NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) {
  431. IteratorPrototype = NativeIteratorPrototype;
  432. }
  433. var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype);
  434. GeneratorFunction.prototype = GeneratorFunctionPrototype;
  435. define(Gp, "constructor", GeneratorFunctionPrototype);
  436. define(GeneratorFunctionPrototype, "constructor", GeneratorFunction);
  437. GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction");
  438. function defineIteratorMethods(prototype) {
  439. ["next", "throw", "return"].forEach(function (method) {
  440. define(prototype, method, function (arg) {
  441. return this._invoke(method, arg);
  442. });
  443. });
  444. }
  445. exports.isGeneratorFunction = function (genFun) {
  446. var ctor = typeof genFun === "function" && genFun.constructor;
  447. return ctor ? ctor === GeneratorFunction || (ctor.displayName || ctor.name) === "GeneratorFunction" : false;
  448. };
  449. exports.mark = function (genFun) {
  450. if (Object.setPrototypeOf) {
  451. Object.setPrototypeOf(genFun, GeneratorFunctionPrototype);
  452. } else {
  453. genFun.__proto__ = GeneratorFunctionPrototype;
  454. define(genFun, toStringTagSymbol, "GeneratorFunction");
  455. }
  456. genFun.prototype = Object.create(Gp);
  457. return genFun;
  458. };
  459. exports.awrap = function (arg) {
  460. return {
  461. __await: arg
  462. };
  463. };
  464. function AsyncIterator(generator, PromiseImpl) {
  465. function invoke(method, arg, resolve, reject) {
  466. var record = tryCatch(generator[method], generator, arg);
  467. if (record.type === "throw") {
  468. reject(record.arg);
  469. } else {
  470. var result = record.arg;
  471. var value = result.value;
  472. if (value && _typeof(value) === "object" && hasOwn.call(value, "__await")) {
  473. return PromiseImpl.resolve(value.__await).then(function (value) {
  474. invoke("next", value, resolve, reject);
  475. }, function (err) {
  476. invoke("throw", err, resolve, reject);
  477. });
  478. }
  479. return PromiseImpl.resolve(value).then(function (unwrapped) {
  480. result.value = unwrapped;
  481. resolve(result);
  482. }, function (error) {
  483. return invoke("throw", error, resolve, reject);
  484. });
  485. }
  486. }
  487. var previousPromise;
  488. function enqueue(method, arg) {
  489. function callInvokeWithMethodAndArg() {
  490. return new PromiseImpl(function (resolve, reject) {
  491. invoke(method, arg, resolve, reject);
  492. });
  493. }
  494. return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
  495. }
  496. this._invoke = enqueue;
  497. }
  498. defineIteratorMethods(AsyncIterator.prototype);
  499. define(AsyncIterator.prototype, asyncIteratorSymbol, function () {
  500. return this;
  501. });
  502. exports.AsyncIterator = AsyncIterator;
  503. exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) {
  504. if (PromiseImpl === void 0) PromiseImpl = Promise;
  505. var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl);
  506. return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) {
  507. return result.done ? result.value : iter.next();
  508. });
  509. };
  510. function makeInvokeMethod(innerFn, self, context) {
  511. var state = GenStateSuspendedStart;
  512. return function invoke(method, arg) {
  513. if (state === GenStateExecuting) {
  514. throw new Error("Generator is already running");
  515. }
  516. if (state === GenStateCompleted) {
  517. if (method === "throw") {
  518. throw arg;
  519. }
  520. return doneResult();
  521. }
  522. context.method = method;
  523. context.arg = arg;
  524. while (true) {
  525. var delegate = context.delegate;
  526. if (delegate) {
  527. var delegateResult = maybeInvokeDelegate(delegate, context);
  528. if (delegateResult) {
  529. if (delegateResult === ContinueSentinel) continue;
  530. return delegateResult;
  531. }
  532. }
  533. if (context.method === "next") {
  534. context.sent = context._sent = context.arg;
  535. } else if (context.method === "throw") {
  536. if (state === GenStateSuspendedStart) {
  537. state = GenStateCompleted;
  538. throw context.arg;
  539. }
  540. context.dispatchException(context.arg);
  541. } else if (context.method === "return") {
  542. context.abrupt("return", context.arg);
  543. }
  544. state = GenStateExecuting;
  545. var record = tryCatch(innerFn, self, context);
  546. if (record.type === "normal") {
  547. state = context.done ? GenStateCompleted : GenStateSuspendedYield;
  548. if (record.arg === ContinueSentinel) {
  549. continue;
  550. }
  551. return {
  552. value: record.arg,
  553. done: context.done
  554. };
  555. } else if (record.type === "throw") {
  556. state = GenStateCompleted;
  557. context.method = "throw";
  558. context.arg = record.arg;
  559. }
  560. }
  561. };
  562. }
  563. function maybeInvokeDelegate(delegate, context) {
  564. var method = delegate.iterator[context.method];
  565. if (method === undefined) {
  566. context.delegate = null;
  567. if (context.method === "throw") {
  568. if (delegate.iterator["return"]) {
  569. context.method = "return";
  570. context.arg = undefined;
  571. maybeInvokeDelegate(delegate, context);
  572. if (context.method === "throw") {
  573. return ContinueSentinel;
  574. }
  575. }
  576. context.method = "throw";
  577. context.arg = new TypeError("The iterator does not provide a 'throw' method");
  578. }
  579. return ContinueSentinel;
  580. }
  581. var record = tryCatch(method, delegate.iterator, context.arg);
  582. if (record.type === "throw") {
  583. context.method = "throw";
  584. context.arg = record.arg;
  585. context.delegate = null;
  586. return ContinueSentinel;
  587. }
  588. var info = record.arg;
  589. if (!info) {
  590. context.method = "throw";
  591. context.arg = new TypeError("iterator result is not an object");
  592. context.delegate = null;
  593. return ContinueSentinel;
  594. }
  595. if (info.done) {
  596. context[delegate.resultName] = info.value;
  597. context.next = delegate.nextLoc;
  598. if (context.method !== "return") {
  599. context.method = "next";
  600. context.arg = undefined;
  601. }
  602. } else {
  603. return info;
  604. }
  605. context.delegate = null;
  606. return ContinueSentinel;
  607. }
  608. defineIteratorMethods(Gp);
  609. define(Gp, toStringTagSymbol, "Generator");
  610. define(Gp, iteratorSymbol, function () {
  611. return this;
  612. });
  613. define(Gp, "toString", function () {
  614. return "[object Generator]";
  615. });
  616. function pushTryEntry(locs) {
  617. var entry = {
  618. tryLoc: locs[0]
  619. };
  620. if (1 in locs) {
  621. entry.catchLoc = locs[1];
  622. }
  623. if (2 in locs) {
  624. entry.finallyLoc = locs[2];
  625. entry.afterLoc = locs[3];
  626. }
  627. this.tryEntries.push(entry);
  628. }
  629. function resetTryEntry(entry) {
  630. var record = entry.completion || {};
  631. record.type = "normal";
  632. delete record.arg;
  633. entry.completion = record;
  634. }
  635. function Context(tryLocsList) {
  636. this.tryEntries = [{
  637. tryLoc: "root"
  638. }];
  639. tryLocsList.forEach(pushTryEntry, this);
  640. this.reset(true);
  641. }
  642. exports.keys = function (object) {
  643. var keys = [];
  644. for (var key in object) {
  645. keys.push(key);
  646. }
  647. keys.reverse();
  648. return function next() {
  649. while (keys.length) {
  650. var key = keys.pop();
  651. if (key in object) {
  652. next.value = key;
  653. next.done = false;
  654. return next;
  655. }
  656. }
  657. next.done = true;
  658. return next;
  659. };
  660. };
  661. function values(iterable) {
  662. if (iterable) {
  663. var iteratorMethod = iterable[iteratorSymbol];
  664. if (iteratorMethod) {
  665. return iteratorMethod.call(iterable);
  666. }
  667. if (typeof iterable.next === "function") {
  668. return iterable;
  669. }
  670. if (!isNaN(iterable.length)) {
  671. var i = -1,
  672. next = function next() {
  673. while (++i < iterable.length) {
  674. if (hasOwn.call(iterable, i)) {
  675. next.value = iterable[i];
  676. next.done = false;
  677. return next;
  678. }
  679. }
  680. next.value = undefined;
  681. next.done = true;
  682. return next;
  683. };
  684. return next.next = next;
  685. }
  686. }
  687. return {
  688. next: doneResult
  689. };
  690. }
  691. exports.values = values;
  692. function doneResult() {
  693. return {
  694. value: undefined,
  695. done: true
  696. };
  697. }
  698. Context.prototype = {
  699. constructor: Context,
  700. reset: function reset(skipTempReset) {
  701. this.prev = 0;
  702. this.next = 0;
  703. this.sent = this._sent = undefined;
  704. this.done = false;
  705. this.delegate = null;
  706. this.method = "next";
  707. this.arg = undefined;
  708. this.tryEntries.forEach(resetTryEntry);
  709. if (!skipTempReset) {
  710. for (var name in this) {
  711. if (name.charAt(0) === "t" && hasOwn.call(this, name) && !isNaN(+name.slice(1))) {
  712. this[name] = undefined;
  713. }
  714. }
  715. }
  716. },
  717. stop: function stop() {
  718. this.done = true;
  719. var rootEntry = this.tryEntries[0];
  720. var rootRecord = rootEntry.completion;
  721. if (rootRecord.type === "throw") {
  722. throw rootRecord.arg;
  723. }
  724. return this.rval;
  725. },
  726. dispatchException: function dispatchException(exception) {
  727. if (this.done) {
  728. throw exception;
  729. }
  730. var context = this;
  731. function handle(loc, caught) {
  732. record.type = "throw";
  733. record.arg = exception;
  734. context.next = loc;
  735. if (caught) {
  736. context.method = "next";
  737. context.arg = undefined;
  738. }
  739. return !!caught;
  740. }
  741. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  742. var entry = this.tryEntries[i];
  743. var record = entry.completion;
  744. if (entry.tryLoc === "root") {
  745. return handle("end");
  746. }
  747. if (entry.tryLoc <= this.prev) {
  748. var hasCatch = hasOwn.call(entry, "catchLoc");
  749. var hasFinally = hasOwn.call(entry, "finallyLoc");
  750. if (hasCatch && hasFinally) {
  751. if (this.prev < entry.catchLoc) {
  752. return handle(entry.catchLoc, true);
  753. } else if (this.prev < entry.finallyLoc) {
  754. return handle(entry.finallyLoc);
  755. }
  756. } else if (hasCatch) {
  757. if (this.prev < entry.catchLoc) {
  758. return handle(entry.catchLoc, true);
  759. }
  760. } else if (hasFinally) {
  761. if (this.prev < entry.finallyLoc) {
  762. return handle(entry.finallyLoc);
  763. }
  764. } else {
  765. throw new Error("try statement without catch or finally");
  766. }
  767. }
  768. }
  769. },
  770. abrupt: function abrupt(type, arg) {
  771. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  772. var entry = this.tryEntries[i];
  773. if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
  774. var finallyEntry = entry;
  775. break;
  776. }
  777. }
  778. if (finallyEntry && (type === "break" || type === "continue") && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc) {
  779. finallyEntry = null;
  780. }
  781. var record = finallyEntry ? finallyEntry.completion : {};
  782. record.type = type;
  783. record.arg = arg;
  784. if (finallyEntry) {
  785. this.method = "next";
  786. this.next = finallyEntry.finallyLoc;
  787. return ContinueSentinel;
  788. }
  789. return this.complete(record);
  790. },
  791. complete: function complete(record, afterLoc) {
  792. if (record.type === "throw") {
  793. throw record.arg;
  794. }
  795. if (record.type === "break" || record.type === "continue") {
  796. this.next = record.arg;
  797. } else if (record.type === "return") {
  798. this.rval = this.arg = record.arg;
  799. this.method = "return";
  800. this.next = "end";
  801. } else if (record.type === "normal" && afterLoc) {
  802. this.next = afterLoc;
  803. }
  804. return ContinueSentinel;
  805. },
  806. finish: function finish(finallyLoc) {
  807. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  808. var entry = this.tryEntries[i];
  809. if (entry.finallyLoc === finallyLoc) {
  810. this.complete(entry.completion, entry.afterLoc);
  811. resetTryEntry(entry);
  812. return ContinueSentinel;
  813. }
  814. }
  815. },
  816. "catch": function _catch(tryLoc) {
  817. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  818. var entry = this.tryEntries[i];
  819. if (entry.tryLoc === tryLoc) {
  820. var record = entry.completion;
  821. if (record.type === "throw") {
  822. var thrown = record.arg;
  823. resetTryEntry(entry);
  824. }
  825. return thrown;
  826. }
  827. }
  828. throw new Error("illegal catch attempt");
  829. },
  830. delegateYield: function delegateYield(iterable, resultName, nextLoc) {
  831. this.delegate = {
  832. iterator: values(iterable),
  833. resultName: resultName,
  834. nextLoc: nextLoc
  835. };
  836. if (this.method === "next") {
  837. this.arg = undefined;
  838. }
  839. return ContinueSentinel;
  840. }
  841. };
  842. return exports;
  843. }(( false ? 0 : _typeof(module)) === "object" ? module.exports : {});
  844. try {
  845. regeneratorRuntime = runtime;
  846. } catch (accidentalStrictMode) {
  847. if ((typeof globalThis === "undefined" ? "undefined" : _typeof(globalThis)) === "object") {
  848. globalThis.regeneratorRuntime = runtime;
  849. } else {
  850. Function("r", "regeneratorRuntime = r")(runtime);
  851. }
  852. }
  853. /***/ }),
  854. /* 6 */
  855. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  856. Object.defineProperty(exports, "__esModule", ({
  857. value: true
  858. }));
  859. exports.SimpleLinkService = exports.PDFLinkService = void 0;
  860. var _regenerator = _interopRequireDefault(__w_pdfjs_require__(4));
  861. var _ui_utils = __w_pdfjs_require__(7);
  862. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  863. function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
  864. function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
  865. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  866. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  867. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  868. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  869. var PDFLinkService = /*#__PURE__*/function () {
  870. function PDFLinkService() {
  871. var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
  872. eventBus = _ref.eventBus,
  873. _ref$externalLinkTarg = _ref.externalLinkTarget,
  874. externalLinkTarget = _ref$externalLinkTarg === void 0 ? null : _ref$externalLinkTarg,
  875. _ref$externalLinkRel = _ref.externalLinkRel,
  876. externalLinkRel = _ref$externalLinkRel === void 0 ? null : _ref$externalLinkRel,
  877. _ref$ignoreDestinatio = _ref.ignoreDestinationZoom,
  878. ignoreDestinationZoom = _ref$ignoreDestinatio === void 0 ? false : _ref$ignoreDestinatio;
  879. _classCallCheck(this, PDFLinkService);
  880. this.eventBus = eventBus;
  881. this.externalLinkTarget = externalLinkTarget;
  882. this.externalLinkRel = externalLinkRel;
  883. this.externalLinkEnabled = true;
  884. this._ignoreDestinationZoom = ignoreDestinationZoom;
  885. this.baseUrl = null;
  886. this.pdfDocument = null;
  887. this.pdfViewer = null;
  888. this.pdfHistory = null;
  889. this._pagesRefCache = null;
  890. }
  891. _createClass(PDFLinkService, [{
  892. key: "setDocument",
  893. value: function setDocument(pdfDocument) {
  894. var baseUrl = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  895. this.baseUrl = baseUrl;
  896. this.pdfDocument = pdfDocument;
  897. this._pagesRefCache = Object.create(null);
  898. }
  899. }, {
  900. key: "setViewer",
  901. value: function setViewer(pdfViewer) {
  902. this.pdfViewer = pdfViewer;
  903. }
  904. }, {
  905. key: "setHistory",
  906. value: function setHistory(pdfHistory) {
  907. this.pdfHistory = pdfHistory;
  908. }
  909. }, {
  910. key: "pagesCount",
  911. get: function get() {
  912. return this.pdfDocument ? this.pdfDocument.numPages : 0;
  913. }
  914. }, {
  915. key: "page",
  916. get: function get() {
  917. return this.pdfViewer.currentPageNumber;
  918. },
  919. set: function set(value) {
  920. this.pdfViewer.currentPageNumber = value;
  921. }
  922. }, {
  923. key: "rotation",
  924. get: function get() {
  925. return this.pdfViewer.pagesRotation;
  926. },
  927. set: function set(value) {
  928. this.pdfViewer.pagesRotation = value;
  929. }
  930. }, {
  931. key: "_goToDestinationHelper",
  932. value: function _goToDestinationHelper(rawDest) {
  933. var _this = this;
  934. var namedDest = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  935. var explicitDest = arguments.length > 2 ? arguments[2] : undefined;
  936. var destRef = explicitDest[0];
  937. var pageNumber;
  938. if (_typeof(destRef) === "object" && destRef !== null) {
  939. pageNumber = this._cachedPageNumber(destRef);
  940. if (pageNumber === null) {
  941. this.pdfDocument.getPageIndex(destRef).then(function (pageIndex) {
  942. _this.cachePageRef(pageIndex + 1, destRef);
  943. _this._goToDestinationHelper(rawDest, namedDest, explicitDest);
  944. })["catch"](function () {
  945. console.error("PDFLinkService._goToDestinationHelper: \"".concat(destRef, "\" is not ") + "a valid page reference, for dest=\"".concat(rawDest, "\"."));
  946. });
  947. return;
  948. }
  949. } else if (Number.isInteger(destRef)) {
  950. pageNumber = destRef + 1;
  951. } else {
  952. console.error("PDFLinkService._goToDestinationHelper: \"".concat(destRef, "\" is not ") + "a valid destination reference, for dest=\"".concat(rawDest, "\"."));
  953. return;
  954. }
  955. if (!pageNumber || pageNumber < 1 || pageNumber > this.pagesCount) {
  956. console.error("PDFLinkService._goToDestinationHelper: \"".concat(pageNumber, "\" is not ") + "a valid page number, for dest=\"".concat(rawDest, "\"."));
  957. return;
  958. }
  959. if (this.pdfHistory) {
  960. this.pdfHistory.pushCurrentPosition();
  961. this.pdfHistory.push({
  962. namedDest: namedDest,
  963. explicitDest: explicitDest,
  964. pageNumber: pageNumber
  965. });
  966. }
  967. this.pdfViewer.scrollPageIntoView({
  968. pageNumber: pageNumber,
  969. destArray: explicitDest,
  970. ignoreDestinationZoom: this._ignoreDestinationZoom
  971. });
  972. }
  973. }, {
  974. key: "goToDestination",
  975. value: function () {
  976. var _goToDestination = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee(dest) {
  977. var namedDest, explicitDest;
  978. return _regenerator["default"].wrap(function _callee$(_context) {
  979. while (1) {
  980. switch (_context.prev = _context.next) {
  981. case 0:
  982. if (this.pdfDocument) {
  983. _context.next = 2;
  984. break;
  985. }
  986. return _context.abrupt("return");
  987. case 2:
  988. if (!(typeof dest === "string")) {
  989. _context.next = 9;
  990. break;
  991. }
  992. namedDest = dest;
  993. _context.next = 6;
  994. return this.pdfDocument.getDestination(dest);
  995. case 6:
  996. explicitDest = _context.sent;
  997. _context.next = 13;
  998. break;
  999. case 9:
  1000. namedDest = null;
  1001. _context.next = 12;
  1002. return dest;
  1003. case 12:
  1004. explicitDest = _context.sent;
  1005. case 13:
  1006. if (Array.isArray(explicitDest)) {
  1007. _context.next = 16;
  1008. break;
  1009. }
  1010. console.error("PDFLinkService.goToDestination: \"".concat(explicitDest, "\" is not ") + "a valid destination array, for dest=\"".concat(dest, "\"."));
  1011. return _context.abrupt("return");
  1012. case 16:
  1013. this._goToDestinationHelper(dest, namedDest, explicitDest);
  1014. case 17:
  1015. case "end":
  1016. return _context.stop();
  1017. }
  1018. }
  1019. }, _callee, this);
  1020. }));
  1021. function goToDestination(_x) {
  1022. return _goToDestination.apply(this, arguments);
  1023. }
  1024. return goToDestination;
  1025. }()
  1026. }, {
  1027. key: "goToPage",
  1028. value: function goToPage(val) {
  1029. if (!this.pdfDocument) {
  1030. return;
  1031. }
  1032. var pageNumber = typeof val === "string" && this.pdfViewer.pageLabelToPageNumber(val) || val | 0;
  1033. if (!(Number.isInteger(pageNumber) && pageNumber > 0 && pageNumber <= this.pagesCount)) {
  1034. console.error("PDFLinkService.goToPage: \"".concat(val, "\" is not a valid page."));
  1035. return;
  1036. }
  1037. if (this.pdfHistory) {
  1038. this.pdfHistory.pushCurrentPosition();
  1039. this.pdfHistory.pushPage(pageNumber);
  1040. }
  1041. this.pdfViewer.scrollPageIntoView({
  1042. pageNumber: pageNumber
  1043. });
  1044. }
  1045. }, {
  1046. key: "getDestinationHash",
  1047. value: function getDestinationHash(dest) {
  1048. if (typeof dest === "string") {
  1049. if (dest.length > 0) {
  1050. return this.getAnchorUrl("#" + escape(dest));
  1051. }
  1052. } else if (Array.isArray(dest)) {
  1053. var str = JSON.stringify(dest);
  1054. if (str.length > 0) {
  1055. return this.getAnchorUrl("#" + escape(str));
  1056. }
  1057. }
  1058. return this.getAnchorUrl("");
  1059. }
  1060. }, {
  1061. key: "getAnchorUrl",
  1062. value: function getAnchorUrl(anchor) {
  1063. return (this.baseUrl || "") + anchor;
  1064. }
  1065. }, {
  1066. key: "setHash",
  1067. value: function setHash(hash) {
  1068. if (!this.pdfDocument) {
  1069. return;
  1070. }
  1071. var pageNumber, dest;
  1072. if (hash.includes("=")) {
  1073. var params = (0, _ui_utils.parseQueryString)(hash);
  1074. if ("search" in params) {
  1075. this.eventBus.dispatch("findfromurlhash", {
  1076. source: this,
  1077. query: params.search.replace(/"/g, ""),
  1078. phraseSearch: params.phrase === "true"
  1079. });
  1080. }
  1081. if ("page" in params) {
  1082. pageNumber = params.page | 0 || 1;
  1083. }
  1084. if ("zoom" in params) {
  1085. var zoomArgs = params.zoom.split(",");
  1086. var zoomArg = zoomArgs[0];
  1087. var zoomArgNumber = parseFloat(zoomArg);
  1088. if (!zoomArg.includes("Fit")) {
  1089. dest = [null, {
  1090. name: "XYZ"
  1091. }, zoomArgs.length > 1 ? zoomArgs[1] | 0 : null, zoomArgs.length > 2 ? zoomArgs[2] | 0 : null, zoomArgNumber ? zoomArgNumber / 100 : zoomArg];
  1092. } else {
  1093. if (zoomArg === "Fit" || zoomArg === "FitB") {
  1094. dest = [null, {
  1095. name: zoomArg
  1096. }];
  1097. } else if (zoomArg === "FitH" || zoomArg === "FitBH" || zoomArg === "FitV" || zoomArg === "FitBV") {
  1098. dest = [null, {
  1099. name: zoomArg
  1100. }, zoomArgs.length > 1 ? zoomArgs[1] | 0 : null];
  1101. } else if (zoomArg === "FitR") {
  1102. if (zoomArgs.length !== 5) {
  1103. console.error('PDFLinkService.setHash: Not enough parameters for "FitR".');
  1104. } else {
  1105. dest = [null, {
  1106. name: zoomArg
  1107. }, zoomArgs[1] | 0, zoomArgs[2] | 0, zoomArgs[3] | 0, zoomArgs[4] | 0];
  1108. }
  1109. } else {
  1110. console.error("PDFLinkService.setHash: \"".concat(zoomArg, "\" is not ") + "a valid zoom value.");
  1111. }
  1112. }
  1113. }
  1114. if (dest) {
  1115. this.pdfViewer.scrollPageIntoView({
  1116. pageNumber: pageNumber || this.page,
  1117. destArray: dest,
  1118. allowNegativeOffset: true
  1119. });
  1120. } else if (pageNumber) {
  1121. this.page = pageNumber;
  1122. }
  1123. if ("pagemode" in params) {
  1124. this.eventBus.dispatch("pagemode", {
  1125. source: this,
  1126. mode: params.pagemode
  1127. });
  1128. }
  1129. if ("nameddest" in params) {
  1130. this.goToDestination(params.nameddest);
  1131. }
  1132. } else {
  1133. dest = unescape(hash);
  1134. try {
  1135. dest = JSON.parse(dest);
  1136. if (!Array.isArray(dest)) {
  1137. dest = dest.toString();
  1138. }
  1139. } catch (ex) {}
  1140. if (typeof dest === "string" || isValidExplicitDestination(dest)) {
  1141. this.goToDestination(dest);
  1142. return;
  1143. }
  1144. console.error("PDFLinkService.setHash: \"".concat(unescape(hash), "\" is not ") + "a valid destination.");
  1145. }
  1146. }
  1147. }, {
  1148. key: "executeNamedAction",
  1149. value: function executeNamedAction(action) {
  1150. switch (action) {
  1151. case "GoBack":
  1152. if (this.pdfHistory) {
  1153. this.pdfHistory.back();
  1154. }
  1155. break;
  1156. case "GoForward":
  1157. if (this.pdfHistory) {
  1158. this.pdfHistory.forward();
  1159. }
  1160. break;
  1161. case "NextPage":
  1162. this.pdfViewer.nextPage();
  1163. break;
  1164. case "PrevPage":
  1165. this.pdfViewer.previousPage();
  1166. break;
  1167. case "LastPage":
  1168. this.page = this.pagesCount;
  1169. break;
  1170. case "FirstPage":
  1171. this.page = 1;
  1172. break;
  1173. default:
  1174. break;
  1175. }
  1176. this.eventBus.dispatch("namedaction", {
  1177. source: this,
  1178. action: action
  1179. });
  1180. }
  1181. }, {
  1182. key: "cachePageRef",
  1183. value: function cachePageRef(pageNum, pageRef) {
  1184. if (!pageRef) {
  1185. return;
  1186. }
  1187. var refStr = pageRef.gen === 0 ? "".concat(pageRef.num, "R") : "".concat(pageRef.num, "R").concat(pageRef.gen);
  1188. this._pagesRefCache[refStr] = pageNum;
  1189. }
  1190. }, {
  1191. key: "_cachedPageNumber",
  1192. value: function _cachedPageNumber(pageRef) {
  1193. var _this$_pagesRefCache;
  1194. var refStr = pageRef.gen === 0 ? "".concat(pageRef.num, "R") : "".concat(pageRef.num, "R").concat(pageRef.gen);
  1195. return ((_this$_pagesRefCache = this._pagesRefCache) === null || _this$_pagesRefCache === void 0 ? void 0 : _this$_pagesRefCache[refStr]) || null;
  1196. }
  1197. }, {
  1198. key: "isPageVisible",
  1199. value: function isPageVisible(pageNumber) {
  1200. return this.pdfViewer.isPageVisible(pageNumber);
  1201. }
  1202. }, {
  1203. key: "isPageCached",
  1204. value: function isPageCached(pageNumber) {
  1205. return this.pdfViewer.isPageCached(pageNumber);
  1206. }
  1207. }]);
  1208. return PDFLinkService;
  1209. }();
  1210. exports.PDFLinkService = PDFLinkService;
  1211. function isValidExplicitDestination(dest) {
  1212. if (!Array.isArray(dest)) {
  1213. return false;
  1214. }
  1215. var destLength = dest.length;
  1216. if (destLength < 2) {
  1217. return false;
  1218. }
  1219. var page = dest[0];
  1220. if (!(_typeof(page) === "object" && Number.isInteger(page.num) && Number.isInteger(page.gen)) && !(Number.isInteger(page) && page >= 0)) {
  1221. return false;
  1222. }
  1223. var zoom = dest[1];
  1224. if (!(_typeof(zoom) === "object" && typeof zoom.name === "string")) {
  1225. return false;
  1226. }
  1227. var allowNull = true;
  1228. switch (zoom.name) {
  1229. case "XYZ":
  1230. if (destLength !== 5) {
  1231. return false;
  1232. }
  1233. break;
  1234. case "Fit":
  1235. case "FitB":
  1236. return destLength === 2;
  1237. case "FitH":
  1238. case "FitBH":
  1239. case "FitV":
  1240. case "FitBV":
  1241. if (destLength !== 3) {
  1242. return false;
  1243. }
  1244. break;
  1245. case "FitR":
  1246. if (destLength !== 6) {
  1247. return false;
  1248. }
  1249. allowNull = false;
  1250. break;
  1251. default:
  1252. return false;
  1253. }
  1254. for (var i = 2; i < destLength; i++) {
  1255. var param = dest[i];
  1256. if (!(typeof param === "number" || allowNull && param === null)) {
  1257. return false;
  1258. }
  1259. }
  1260. return true;
  1261. }
  1262. var SimpleLinkService = /*#__PURE__*/function () {
  1263. function SimpleLinkService() {
  1264. _classCallCheck(this, SimpleLinkService);
  1265. this.externalLinkTarget = null;
  1266. this.externalLinkRel = null;
  1267. this.externalLinkEnabled = true;
  1268. this._ignoreDestinationZoom = false;
  1269. }
  1270. _createClass(SimpleLinkService, [{
  1271. key: "pagesCount",
  1272. get: function get() {
  1273. return 0;
  1274. }
  1275. }, {
  1276. key: "page",
  1277. get: function get() {
  1278. return 0;
  1279. },
  1280. set: function set(value) {}
  1281. }, {
  1282. key: "rotation",
  1283. get: function get() {
  1284. return 0;
  1285. },
  1286. set: function set(value) {}
  1287. }, {
  1288. key: "goToDestination",
  1289. value: function () {
  1290. var _goToDestination2 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee2(dest) {
  1291. return _regenerator["default"].wrap(function _callee2$(_context2) {
  1292. while (1) {
  1293. switch (_context2.prev = _context2.next) {
  1294. case 0:
  1295. case "end":
  1296. return _context2.stop();
  1297. }
  1298. }
  1299. }, _callee2);
  1300. }));
  1301. function goToDestination(_x2) {
  1302. return _goToDestination2.apply(this, arguments);
  1303. }
  1304. return goToDestination;
  1305. }()
  1306. }, {
  1307. key: "goToPage",
  1308. value: function goToPage(val) {}
  1309. }, {
  1310. key: "getDestinationHash",
  1311. value: function getDestinationHash(dest) {
  1312. return "#";
  1313. }
  1314. }, {
  1315. key: "getAnchorUrl",
  1316. value: function getAnchorUrl(hash) {
  1317. return "#";
  1318. }
  1319. }, {
  1320. key: "setHash",
  1321. value: function setHash(hash) {}
  1322. }, {
  1323. key: "executeNamedAction",
  1324. value: function executeNamedAction(action) {}
  1325. }, {
  1326. key: "cachePageRef",
  1327. value: function cachePageRef(pageNum, pageRef) {}
  1328. }, {
  1329. key: "isPageVisible",
  1330. value: function isPageVisible(pageNumber) {
  1331. return true;
  1332. }
  1333. }, {
  1334. key: "isPageCached",
  1335. value: function isPageCached(pageNumber) {
  1336. return true;
  1337. }
  1338. }]);
  1339. return SimpleLinkService;
  1340. }();
  1341. exports.SimpleLinkService = SimpleLinkService;
  1342. /***/ }),
  1343. /* 7 */
  1344. /***/ ((__unused_webpack_module, exports) => {
  1345. Object.defineProperty(exports, "__esModule", ({
  1346. value: true
  1347. }));
  1348. exports.apiPageLayoutToSpreadMode = apiPageLayoutToSpreadMode;
  1349. exports.apiPageModeToSidebarView = apiPageModeToSidebarView;
  1350. exports.approximateFraction = approximateFraction;
  1351. exports.backtrackBeforeAllVisibleElements = backtrackBeforeAllVisibleElements;
  1352. exports.binarySearchFirstItem = binarySearchFirstItem;
  1353. exports.getActiveOrFocusedElement = getActiveOrFocusedElement;
  1354. exports.getOutputScale = getOutputScale;
  1355. exports.getPageSizeInches = getPageSizeInches;
  1356. exports.getVisibleElements = getVisibleElements;
  1357. exports.isPortraitOrientation = isPortraitOrientation;
  1358. exports.isValidRotation = isValidRotation;
  1359. exports.isValidScrollMode = isValidScrollMode;
  1360. exports.isValidSpreadMode = isValidSpreadMode;
  1361. exports.moveToEndOfArray = moveToEndOfArray;
  1362. exports.noContextMenuHandler = noContextMenuHandler;
  1363. exports.normalizeWheelEventDelta = normalizeWheelEventDelta;
  1364. exports.normalizeWheelEventDirection = normalizeWheelEventDirection;
  1365. exports.parseQueryString = parseQueryString;
  1366. exports.roundToDivide = roundToDivide;
  1367. exports.scrollIntoView = scrollIntoView;
  1368. exports.waitOnEventOrTimeout = waitOnEventOrTimeout;
  1369. exports.watchScroll = watchScroll;
  1370. exports.WaitOnType = exports.VERTICAL_PADDING = exports.UNKNOWN_SCALE = exports.TextLayerMode = exports.SpreadMode = exports.SidebarView = exports.ScrollMode = exports.SCROLLBAR_PADDING = exports.RendererType = exports.ProgressBar = exports.PresentationModeState = exports.MIN_SCALE = exports.MAX_SCALE = exports.MAX_AUTO_SCALE = exports.EventBus = exports.DEFAULT_SCALE_VALUE = exports.DEFAULT_SCALE = exports.CSS_UNITS = exports.AutoPrintRegExp = exports.animationStarted = void 0;
  1371. function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e2) { throw _e2; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e3) { didErr = true; err = _e3; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
  1372. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  1373. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  1374. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  1375. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  1376. function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
  1377. function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
  1378. function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
  1379. function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
  1380. function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
  1381. function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
  1382. var CSS_UNITS = 96.0 / 72.0;
  1383. exports.CSS_UNITS = CSS_UNITS;
  1384. var DEFAULT_SCALE_VALUE = "auto";
  1385. exports.DEFAULT_SCALE_VALUE = DEFAULT_SCALE_VALUE;
  1386. var DEFAULT_SCALE = 1.0;
  1387. exports.DEFAULT_SCALE = DEFAULT_SCALE;
  1388. var MIN_SCALE = 0.1;
  1389. exports.MIN_SCALE = MIN_SCALE;
  1390. var MAX_SCALE = 10.0;
  1391. exports.MAX_SCALE = MAX_SCALE;
  1392. var UNKNOWN_SCALE = 0;
  1393. exports.UNKNOWN_SCALE = UNKNOWN_SCALE;
  1394. var MAX_AUTO_SCALE = 1.25;
  1395. exports.MAX_AUTO_SCALE = MAX_AUTO_SCALE;
  1396. var SCROLLBAR_PADDING = 40;
  1397. exports.SCROLLBAR_PADDING = SCROLLBAR_PADDING;
  1398. var VERTICAL_PADDING = 5;
  1399. exports.VERTICAL_PADDING = VERTICAL_PADDING;
  1400. var LOADINGBAR_END_OFFSET_VAR = "--loadingBar-end-offset";
  1401. var PresentationModeState = {
  1402. UNKNOWN: 0,
  1403. NORMAL: 1,
  1404. CHANGING: 2,
  1405. FULLSCREEN: 3
  1406. };
  1407. exports.PresentationModeState = PresentationModeState;
  1408. var SidebarView = {
  1409. UNKNOWN: -1,
  1410. NONE: 0,
  1411. THUMBS: 1,
  1412. OUTLINE: 2,
  1413. ATTACHMENTS: 3,
  1414. LAYERS: 4
  1415. };
  1416. exports.SidebarView = SidebarView;
  1417. var RendererType = {
  1418. CANVAS: "canvas",
  1419. SVG: "svg"
  1420. };
  1421. exports.RendererType = RendererType;
  1422. var TextLayerMode = {
  1423. DISABLE: 0,
  1424. ENABLE: 1,
  1425. ENABLE_ENHANCE: 2
  1426. };
  1427. exports.TextLayerMode = TextLayerMode;
  1428. var ScrollMode = {
  1429. UNKNOWN: -1,
  1430. VERTICAL: 0,
  1431. HORIZONTAL: 1,
  1432. WRAPPED: 2
  1433. };
  1434. exports.ScrollMode = ScrollMode;
  1435. var SpreadMode = {
  1436. UNKNOWN: -1,
  1437. NONE: 0,
  1438. ODD: 1,
  1439. EVEN: 2
  1440. };
  1441. exports.SpreadMode = SpreadMode;
  1442. var AutoPrintRegExp = /\bprint\s*\(/;
  1443. exports.AutoPrintRegExp = AutoPrintRegExp;
  1444. function getOutputScale(ctx) {
  1445. var devicePixelRatio = window.devicePixelRatio || 1;
  1446. var backingStoreRatio = ctx.webkitBackingStorePixelRatio || ctx.mozBackingStorePixelRatio || ctx.backingStorePixelRatio || 1;
  1447. var pixelRatio = devicePixelRatio / backingStoreRatio;
  1448. return {
  1449. sx: pixelRatio,
  1450. sy: pixelRatio,
  1451. scaled: pixelRatio !== 1
  1452. };
  1453. }
  1454. function scrollIntoView(element, spot) {
  1455. var scrollMatches = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  1456. var parent = element.offsetParent;
  1457. if (!parent) {
  1458. console.error("offsetParent is not set -- cannot scroll");
  1459. return;
  1460. }
  1461. var offsetY = element.offsetTop + element.clientTop;
  1462. var offsetX = element.offsetLeft + element.clientLeft;
  1463. while (parent.clientHeight === parent.scrollHeight && parent.clientWidth === parent.scrollWidth || scrollMatches && (parent.classList.contains("markedContent") || getComputedStyle(parent).overflow === "hidden")) {
  1464. offsetY += parent.offsetTop;
  1465. offsetX += parent.offsetLeft;
  1466. parent = parent.offsetParent;
  1467. if (!parent) {
  1468. return;
  1469. }
  1470. }
  1471. if (spot) {
  1472. if (spot.top !== undefined) {
  1473. offsetY += spot.top;
  1474. }
  1475. if (spot.left !== undefined) {
  1476. offsetX += spot.left;
  1477. parent.scrollLeft = offsetX;
  1478. }
  1479. }
  1480. parent.scrollTop = offsetY;
  1481. }
  1482. function watchScroll(viewAreaElement, callback) {
  1483. var debounceScroll = function debounceScroll(evt) {
  1484. if (rAF) {
  1485. return;
  1486. }
  1487. rAF = window.requestAnimationFrame(function viewAreaElementScrolled() {
  1488. rAF = null;
  1489. var currentX = viewAreaElement.scrollLeft;
  1490. var lastX = state.lastX;
  1491. if (currentX !== lastX) {
  1492. state.right = currentX > lastX;
  1493. }
  1494. state.lastX = currentX;
  1495. var currentY = viewAreaElement.scrollTop;
  1496. var lastY = state.lastY;
  1497. if (currentY !== lastY) {
  1498. state.down = currentY > lastY;
  1499. }
  1500. state.lastY = currentY;
  1501. callback(state);
  1502. });
  1503. };
  1504. var state = {
  1505. right: true,
  1506. down: true,
  1507. lastX: viewAreaElement.scrollLeft,
  1508. lastY: viewAreaElement.scrollTop,
  1509. _eventHandler: debounceScroll
  1510. };
  1511. var rAF = null;
  1512. viewAreaElement.addEventListener("scroll", debounceScroll, true);
  1513. return state;
  1514. }
  1515. function parseQueryString(query) {
  1516. var parts = query.split("&");
  1517. var params = Object.create(null);
  1518. for (var i = 0, ii = parts.length; i < ii; ++i) {
  1519. var param = parts[i].split("=");
  1520. var key = param[0].toLowerCase();
  1521. var value = param.length > 1 ? param[1] : null;
  1522. params[decodeURIComponent(key)] = decodeURIComponent(value);
  1523. }
  1524. return params;
  1525. }
  1526. function binarySearchFirstItem(items, condition) {
  1527. var minIndex = 0;
  1528. var maxIndex = items.length - 1;
  1529. if (maxIndex < 0 || !condition(items[maxIndex])) {
  1530. return items.length;
  1531. }
  1532. if (condition(items[minIndex])) {
  1533. return minIndex;
  1534. }
  1535. while (minIndex < maxIndex) {
  1536. var currentIndex = minIndex + maxIndex >> 1;
  1537. var currentItem = items[currentIndex];
  1538. if (condition(currentItem)) {
  1539. maxIndex = currentIndex;
  1540. } else {
  1541. minIndex = currentIndex + 1;
  1542. }
  1543. }
  1544. return minIndex;
  1545. }
  1546. function approximateFraction(x) {
  1547. if (Math.floor(x) === x) {
  1548. return [x, 1];
  1549. }
  1550. var xinv = 1 / x;
  1551. var limit = 8;
  1552. if (xinv > limit) {
  1553. return [1, limit];
  1554. } else if (Math.floor(xinv) === xinv) {
  1555. return [1, xinv];
  1556. }
  1557. var x_ = x > 1 ? xinv : x;
  1558. var a = 0,
  1559. b = 1,
  1560. c = 1,
  1561. d = 1;
  1562. while (true) {
  1563. var p = a + c,
  1564. q = b + d;
  1565. if (q > limit) {
  1566. break;
  1567. }
  1568. if (x_ <= p / q) {
  1569. c = p;
  1570. d = q;
  1571. } else {
  1572. a = p;
  1573. b = q;
  1574. }
  1575. }
  1576. var result;
  1577. if (x_ - a / b < c / d - x_) {
  1578. result = x_ === x ? [a, b] : [b, a];
  1579. } else {
  1580. result = x_ === x ? [c, d] : [d, c];
  1581. }
  1582. return result;
  1583. }
  1584. function roundToDivide(x, div) {
  1585. var r = x % div;
  1586. return r === 0 ? x : Math.round(x - r + div);
  1587. }
  1588. function getPageSizeInches(_ref) {
  1589. var view = _ref.view,
  1590. userUnit = _ref.userUnit,
  1591. rotate = _ref.rotate;
  1592. var _view = _slicedToArray(view, 4),
  1593. x1 = _view[0],
  1594. y1 = _view[1],
  1595. x2 = _view[2],
  1596. y2 = _view[3];
  1597. var changeOrientation = rotate % 180 !== 0;
  1598. var width = (x2 - x1) / 72 * userUnit;
  1599. var height = (y2 - y1) / 72 * userUnit;
  1600. return {
  1601. width: changeOrientation ? height : width,
  1602. height: changeOrientation ? width : height
  1603. };
  1604. }
  1605. function backtrackBeforeAllVisibleElements(index, views, top) {
  1606. if (index < 2) {
  1607. return index;
  1608. }
  1609. var elt = views[index].div;
  1610. var pageTop = elt.offsetTop + elt.clientTop;
  1611. if (pageTop >= top) {
  1612. elt = views[index - 1].div;
  1613. pageTop = elt.offsetTop + elt.clientTop;
  1614. }
  1615. for (var i = index - 2; i >= 0; --i) {
  1616. elt = views[i].div;
  1617. if (elt.offsetTop + elt.clientTop + elt.clientHeight <= pageTop) {
  1618. break;
  1619. }
  1620. index = i;
  1621. }
  1622. return index;
  1623. }
  1624. function getVisibleElements(_ref2) {
  1625. var scrollEl = _ref2.scrollEl,
  1626. views = _ref2.views,
  1627. _ref2$sortByVisibilit = _ref2.sortByVisibility,
  1628. sortByVisibility = _ref2$sortByVisibilit === void 0 ? false : _ref2$sortByVisibilit,
  1629. _ref2$horizontal = _ref2.horizontal,
  1630. horizontal = _ref2$horizontal === void 0 ? false : _ref2$horizontal,
  1631. _ref2$rtl = _ref2.rtl,
  1632. rtl = _ref2$rtl === void 0 ? false : _ref2$rtl;
  1633. var top = scrollEl.scrollTop,
  1634. bottom = top + scrollEl.clientHeight;
  1635. var left = scrollEl.scrollLeft,
  1636. right = left + scrollEl.clientWidth;
  1637. function isElementBottomAfterViewTop(view) {
  1638. var element = view.div;
  1639. var elementBottom = element.offsetTop + element.clientTop + element.clientHeight;
  1640. return elementBottom > top;
  1641. }
  1642. function isElementNextAfterViewHorizontally(view) {
  1643. var element = view.div;
  1644. var elementLeft = element.offsetLeft + element.clientLeft;
  1645. var elementRight = elementLeft + element.clientWidth;
  1646. return rtl ? elementLeft < right : elementRight > left;
  1647. }
  1648. var visible = [],
  1649. numViews = views.length;
  1650. var firstVisibleElementInd = binarySearchFirstItem(views, horizontal ? isElementNextAfterViewHorizontally : isElementBottomAfterViewTop);
  1651. if (firstVisibleElementInd > 0 && firstVisibleElementInd < numViews && !horizontal) {
  1652. firstVisibleElementInd = backtrackBeforeAllVisibleElements(firstVisibleElementInd, views, top);
  1653. }
  1654. var lastEdge = horizontal ? right : -1;
  1655. for (var i = firstVisibleElementInd; i < numViews; i++) {
  1656. var view = views[i],
  1657. element = view.div;
  1658. var currentWidth = element.offsetLeft + element.clientLeft;
  1659. var currentHeight = element.offsetTop + element.clientTop;
  1660. var viewWidth = element.clientWidth,
  1661. viewHeight = element.clientHeight;
  1662. var viewRight = currentWidth + viewWidth;
  1663. var viewBottom = currentHeight + viewHeight;
  1664. if (lastEdge === -1) {
  1665. if (viewBottom >= bottom) {
  1666. lastEdge = viewBottom;
  1667. }
  1668. } else if ((horizontal ? currentWidth : currentHeight) > lastEdge) {
  1669. break;
  1670. }
  1671. if (viewBottom <= top || currentHeight >= bottom || viewRight <= left || currentWidth >= right) {
  1672. continue;
  1673. }
  1674. var hiddenHeight = Math.max(0, top - currentHeight) + Math.max(0, viewBottom - bottom);
  1675. var hiddenWidth = Math.max(0, left - currentWidth) + Math.max(0, viewRight - right);
  1676. var fractionHeight = (viewHeight - hiddenHeight) / viewHeight,
  1677. fractionWidth = (viewWidth - hiddenWidth) / viewWidth;
  1678. var percent = fractionHeight * fractionWidth * 100 | 0;
  1679. visible.push({
  1680. id: view.id,
  1681. x: currentWidth,
  1682. y: currentHeight,
  1683. view: view,
  1684. percent: percent,
  1685. widthPercent: fractionWidth * 100 | 0
  1686. });
  1687. }
  1688. var first = visible[0],
  1689. last = visible[visible.length - 1];
  1690. if (sortByVisibility) {
  1691. visible.sort(function (a, b) {
  1692. var pc = a.percent - b.percent;
  1693. if (Math.abs(pc) > 0.001) {
  1694. return -pc;
  1695. }
  1696. return a.id - b.id;
  1697. });
  1698. }
  1699. return {
  1700. first: first,
  1701. last: last,
  1702. views: visible
  1703. };
  1704. }
  1705. function noContextMenuHandler(evt) {
  1706. evt.preventDefault();
  1707. }
  1708. function normalizeWheelEventDirection(evt) {
  1709. var delta = Math.hypot(evt.deltaX, evt.deltaY);
  1710. var angle = Math.atan2(evt.deltaY, evt.deltaX);
  1711. if (-0.25 * Math.PI < angle && angle < 0.75 * Math.PI) {
  1712. delta = -delta;
  1713. }
  1714. return delta;
  1715. }
  1716. function normalizeWheelEventDelta(evt) {
  1717. var delta = normalizeWheelEventDirection(evt);
  1718. var MOUSE_DOM_DELTA_PIXEL_MODE = 0;
  1719. var MOUSE_DOM_DELTA_LINE_MODE = 1;
  1720. var MOUSE_PIXELS_PER_LINE = 30;
  1721. var MOUSE_LINES_PER_PAGE = 30;
  1722. if (evt.deltaMode === MOUSE_DOM_DELTA_PIXEL_MODE) {
  1723. delta /= MOUSE_PIXELS_PER_LINE * MOUSE_LINES_PER_PAGE;
  1724. } else if (evt.deltaMode === MOUSE_DOM_DELTA_LINE_MODE) {
  1725. delta /= MOUSE_LINES_PER_PAGE;
  1726. }
  1727. return delta;
  1728. }
  1729. function isValidRotation(angle) {
  1730. return Number.isInteger(angle) && angle % 90 === 0;
  1731. }
  1732. function isValidScrollMode(mode) {
  1733. return Number.isInteger(mode) && Object.values(ScrollMode).includes(mode) && mode !== ScrollMode.UNKNOWN;
  1734. }
  1735. function isValidSpreadMode(mode) {
  1736. return Number.isInteger(mode) && Object.values(SpreadMode).includes(mode) && mode !== SpreadMode.UNKNOWN;
  1737. }
  1738. function isPortraitOrientation(size) {
  1739. return size.width <= size.height;
  1740. }
  1741. var WaitOnType = {
  1742. EVENT: "event",
  1743. TIMEOUT: "timeout"
  1744. };
  1745. exports.WaitOnType = WaitOnType;
  1746. function waitOnEventOrTimeout(_ref3) {
  1747. var target = _ref3.target,
  1748. name = _ref3.name,
  1749. _ref3$delay = _ref3.delay,
  1750. delay = _ref3$delay === void 0 ? 0 : _ref3$delay;
  1751. return new Promise(function (resolve, reject) {
  1752. if (_typeof(target) !== "object" || !(name && typeof name === "string") || !(Number.isInteger(delay) && delay >= 0)) {
  1753. throw new Error("waitOnEventOrTimeout - invalid parameters.");
  1754. }
  1755. function handler(type) {
  1756. if (target instanceof EventBus) {
  1757. target._off(name, eventHandler);
  1758. } else {
  1759. target.removeEventListener(name, eventHandler);
  1760. }
  1761. if (timeout) {
  1762. clearTimeout(timeout);
  1763. }
  1764. resolve(type);
  1765. }
  1766. var eventHandler = handler.bind(null, WaitOnType.EVENT);
  1767. if (target instanceof EventBus) {
  1768. target._on(name, eventHandler);
  1769. } else {
  1770. target.addEventListener(name, eventHandler);
  1771. }
  1772. var timeoutHandler = handler.bind(null, WaitOnType.TIMEOUT);
  1773. var timeout = setTimeout(timeoutHandler, delay);
  1774. });
  1775. }
  1776. var animationStarted = new Promise(function (resolve) {
  1777. window.requestAnimationFrame(resolve);
  1778. });
  1779. exports.animationStarted = animationStarted;
  1780. function dispatchDOMEvent(eventName) {
  1781. var args = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  1782. throw new Error("Not implemented: dispatchDOMEvent");
  1783. }
  1784. var EventBus = /*#__PURE__*/function () {
  1785. function EventBus(options) {
  1786. _classCallCheck(this, EventBus);
  1787. this._listeners = Object.create(null);
  1788. }
  1789. _createClass(EventBus, [{
  1790. key: "on",
  1791. value: function on(eventName, listener) {
  1792. var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
  1793. this._on(eventName, listener, {
  1794. external: true,
  1795. once: options === null || options === void 0 ? void 0 : options.once
  1796. });
  1797. }
  1798. }, {
  1799. key: "off",
  1800. value: function off(eventName, listener) {
  1801. var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
  1802. this._off(eventName, listener, {
  1803. external: true,
  1804. once: options === null || options === void 0 ? void 0 : options.once
  1805. });
  1806. }
  1807. }, {
  1808. key: "dispatch",
  1809. value: function dispatch(eventName) {
  1810. var eventListeners = this._listeners[eventName];
  1811. if (!eventListeners || eventListeners.length === 0) {
  1812. return;
  1813. }
  1814. var args = Array.prototype.slice.call(arguments, 1);
  1815. var externalListeners;
  1816. var _iterator = _createForOfIteratorHelper(eventListeners.slice(0)),
  1817. _step;
  1818. try {
  1819. for (_iterator.s(); !(_step = _iterator.n()).done;) {
  1820. var _step$value = _step.value,
  1821. _listener = _step$value.listener,
  1822. external = _step$value.external,
  1823. once = _step$value.once;
  1824. if (once) {
  1825. this._off(eventName, _listener);
  1826. }
  1827. if (external) {
  1828. (externalListeners || (externalListeners = [])).push(_listener);
  1829. continue;
  1830. }
  1831. _listener.apply(null, args);
  1832. }
  1833. } catch (err) {
  1834. _iterator.e(err);
  1835. } finally {
  1836. _iterator.f();
  1837. }
  1838. if (externalListeners) {
  1839. var _iterator2 = _createForOfIteratorHelper(externalListeners),
  1840. _step2;
  1841. try {
  1842. for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
  1843. var listener = _step2.value;
  1844. listener.apply(null, args);
  1845. }
  1846. } catch (err) {
  1847. _iterator2.e(err);
  1848. } finally {
  1849. _iterator2.f();
  1850. }
  1851. externalListeners = null;
  1852. }
  1853. }
  1854. }, {
  1855. key: "_on",
  1856. value: function _on(eventName, listener) {
  1857. var _this$_listeners;
  1858. var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
  1859. var eventListeners = (_this$_listeners = this._listeners)[eventName] || (_this$_listeners[eventName] = []);
  1860. eventListeners.push({
  1861. listener: listener,
  1862. external: (options === null || options === void 0 ? void 0 : options.external) === true,
  1863. once: (options === null || options === void 0 ? void 0 : options.once) === true
  1864. });
  1865. }
  1866. }, {
  1867. key: "_off",
  1868. value: function _off(eventName, listener) {
  1869. var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
  1870. var eventListeners = this._listeners[eventName];
  1871. if (!eventListeners) {
  1872. return;
  1873. }
  1874. for (var i = 0, ii = eventListeners.length; i < ii; i++) {
  1875. if (eventListeners[i].listener === listener) {
  1876. eventListeners.splice(i, 1);
  1877. return;
  1878. }
  1879. }
  1880. }
  1881. }]);
  1882. return EventBus;
  1883. }();
  1884. exports.EventBus = EventBus;
  1885. function clamp(v, min, max) {
  1886. return Math.min(Math.max(v, min), max);
  1887. }
  1888. var ProgressBar = /*#__PURE__*/function () {
  1889. function ProgressBar(id) {
  1890. var _ref4 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
  1891. height = _ref4.height,
  1892. width = _ref4.width,
  1893. units = _ref4.units;
  1894. _classCallCheck(this, ProgressBar);
  1895. this.visible = true;
  1896. this.div = document.querySelector(id + " .progress");
  1897. this.bar = this.div.parentNode;
  1898. this.height = height || 100;
  1899. this.width = width || 100;
  1900. this.units = units || "%";
  1901. this.div.style.height = this.height + this.units;
  1902. this.percent = 0;
  1903. }
  1904. _createClass(ProgressBar, [{
  1905. key: "_updateBar",
  1906. value: function _updateBar() {
  1907. if (this._indeterminate) {
  1908. this.div.classList.add("indeterminate");
  1909. this.div.style.width = this.width + this.units;
  1910. return;
  1911. }
  1912. this.div.classList.remove("indeterminate");
  1913. var progressSize = this.width * this._percent / 100;
  1914. this.div.style.width = progressSize + this.units;
  1915. }
  1916. }, {
  1917. key: "percent",
  1918. get: function get() {
  1919. return this._percent;
  1920. },
  1921. set: function set(val) {
  1922. this._indeterminate = isNaN(val);
  1923. this._percent = clamp(val, 0, 100);
  1924. this._updateBar();
  1925. }
  1926. }, {
  1927. key: "setWidth",
  1928. value: function setWidth(viewer) {
  1929. if (!viewer) {
  1930. return;
  1931. }
  1932. var container = viewer.parentNode;
  1933. var scrollbarWidth = container.offsetWidth - viewer.offsetWidth;
  1934. if (scrollbarWidth > 0) {
  1935. var doc = document.documentElement;
  1936. doc.style.setProperty(LOADINGBAR_END_OFFSET_VAR, "".concat(scrollbarWidth, "px"));
  1937. }
  1938. }
  1939. }, {
  1940. key: "hide",
  1941. value: function hide() {
  1942. if (!this.visible) {
  1943. return;
  1944. }
  1945. this.visible = false;
  1946. this.bar.classList.add("hidden");
  1947. }
  1948. }, {
  1949. key: "show",
  1950. value: function show() {
  1951. if (this.visible) {
  1952. return;
  1953. }
  1954. this.visible = true;
  1955. this.bar.classList.remove("hidden");
  1956. }
  1957. }]);
  1958. return ProgressBar;
  1959. }();
  1960. exports.ProgressBar = ProgressBar;
  1961. function moveToEndOfArray(arr, condition) {
  1962. var moved = [],
  1963. len = arr.length;
  1964. var write = 0;
  1965. for (var read = 0; read < len; ++read) {
  1966. if (condition(arr[read])) {
  1967. moved.push(arr[read]);
  1968. } else {
  1969. arr[write] = arr[read];
  1970. ++write;
  1971. }
  1972. }
  1973. for (var _read = 0; write < len; ++_read, ++write) {
  1974. arr[write] = moved[_read];
  1975. }
  1976. }
  1977. function getActiveOrFocusedElement() {
  1978. var curRoot = document;
  1979. var curActiveOrFocused = curRoot.activeElement || curRoot.querySelector(":focus");
  1980. while ((_curActiveOrFocused = curActiveOrFocused) !== null && _curActiveOrFocused !== void 0 && _curActiveOrFocused.shadowRoot) {
  1981. var _curActiveOrFocused;
  1982. curRoot = curActiveOrFocused.shadowRoot;
  1983. curActiveOrFocused = curRoot.activeElement || curRoot.querySelector(":focus");
  1984. }
  1985. return curActiveOrFocused;
  1986. }
  1987. function apiPageLayoutToSpreadMode(layout) {
  1988. switch (layout) {
  1989. case "SinglePage":
  1990. case "OneColumn":
  1991. return SpreadMode.NONE;
  1992. case "TwoColumnLeft":
  1993. case "TwoPageLeft":
  1994. return SpreadMode.ODD;
  1995. case "TwoColumnRight":
  1996. case "TwoPageRight":
  1997. return SpreadMode.EVEN;
  1998. }
  1999. return SpreadMode.NONE;
  2000. }
  2001. function apiPageModeToSidebarView(mode) {
  2002. switch (mode) {
  2003. case "UseNone":
  2004. return SidebarView.NONE;
  2005. case "UseThumbs":
  2006. return SidebarView.THUMBS;
  2007. case "UseOutlines":
  2008. return SidebarView.OUTLINE;
  2009. case "UseAttachments":
  2010. return SidebarView.ATTACHMENTS;
  2011. case "UseOC":
  2012. return SidebarView.LAYERS;
  2013. }
  2014. return SidebarView.NONE;
  2015. }
  2016. /***/ }),
  2017. /* 8 */
  2018. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  2019. Object.defineProperty(exports, "__esModule", ({
  2020. value: true
  2021. }));
  2022. exports.TextLayerBuilder = exports.DefaultTextLayerFactory = void 0;
  2023. var _pdfjsLib = __w_pdfjs_require__(2);
  2024. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  2025. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  2026. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  2027. var EXPAND_DIVS_TIMEOUT = 300;
  2028. var TextLayerBuilder = /*#__PURE__*/function () {
  2029. function TextLayerBuilder(_ref) {
  2030. var textLayerDiv = _ref.textLayerDiv,
  2031. eventBus = _ref.eventBus,
  2032. pageIndex = _ref.pageIndex,
  2033. viewport = _ref.viewport,
  2034. _ref$findController = _ref.findController,
  2035. findController = _ref$findController === void 0 ? null : _ref$findController,
  2036. _ref$enhanceTextSelec = _ref.enhanceTextSelection,
  2037. enhanceTextSelection = _ref$enhanceTextSelec === void 0 ? false : _ref$enhanceTextSelec;
  2038. _classCallCheck(this, TextLayerBuilder);
  2039. this.textLayerDiv = textLayerDiv;
  2040. this.eventBus = eventBus;
  2041. this.textContent = null;
  2042. this.textContentItemsStr = [];
  2043. this.textContentStream = null;
  2044. this.renderingDone = false;
  2045. this.pageIdx = pageIndex;
  2046. this.pageNumber = this.pageIdx + 1;
  2047. this.matches = [];
  2048. this.viewport = viewport;
  2049. this.textDivs = [];
  2050. this.findController = findController;
  2051. this.textLayerRenderTask = null;
  2052. this.enhanceTextSelection = enhanceTextSelection;
  2053. this._onUpdateTextLayerMatches = null;
  2054. this._bindMouse();
  2055. }
  2056. _createClass(TextLayerBuilder, [{
  2057. key: "_finishRendering",
  2058. value: function _finishRendering() {
  2059. this.renderingDone = true;
  2060. if (!this.enhanceTextSelection) {
  2061. var endOfContent = document.createElement("div");
  2062. endOfContent.className = "endOfContent";
  2063. this.textLayerDiv.appendChild(endOfContent);
  2064. }
  2065. this.eventBus.dispatch("textlayerrendered", {
  2066. source: this,
  2067. pageNumber: this.pageNumber,
  2068. numTextDivs: this.textDivs.length
  2069. });
  2070. }
  2071. }, {
  2072. key: "render",
  2073. value: function render() {
  2074. var _this = this;
  2075. var timeout = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
  2076. if (!(this.textContent || this.textContentStream) || this.renderingDone) {
  2077. return;
  2078. }
  2079. this.cancel();
  2080. this.textDivs = [];
  2081. var textLayerFrag = document.createDocumentFragment();
  2082. this.textLayerRenderTask = (0, _pdfjsLib.renderTextLayer)({
  2083. textContent: this.textContent,
  2084. textContentStream: this.textContentStream,
  2085. container: textLayerFrag,
  2086. viewport: this.viewport,
  2087. textDivs: this.textDivs,
  2088. textContentItemsStr: this.textContentItemsStr,
  2089. timeout: timeout,
  2090. enhanceTextSelection: this.enhanceTextSelection
  2091. });
  2092. this.textLayerRenderTask.promise.then(function () {
  2093. _this.textLayerDiv.appendChild(textLayerFrag);
  2094. _this._finishRendering();
  2095. _this._updateMatches();
  2096. }, function (reason) {});
  2097. if (!this._onUpdateTextLayerMatches) {
  2098. this._onUpdateTextLayerMatches = function (evt) {
  2099. if (evt.pageIndex === _this.pageIdx || evt.pageIndex === -1) {
  2100. _this._updateMatches();
  2101. }
  2102. };
  2103. this.eventBus._on("updatetextlayermatches", this._onUpdateTextLayerMatches);
  2104. }
  2105. }
  2106. }, {
  2107. key: "cancel",
  2108. value: function cancel() {
  2109. if (this.textLayerRenderTask) {
  2110. this.textLayerRenderTask.cancel();
  2111. this.textLayerRenderTask = null;
  2112. }
  2113. if (this._onUpdateTextLayerMatches) {
  2114. this.eventBus._off("updatetextlayermatches", this._onUpdateTextLayerMatches);
  2115. this._onUpdateTextLayerMatches = null;
  2116. }
  2117. }
  2118. }, {
  2119. key: "setTextContentStream",
  2120. value: function setTextContentStream(readableStream) {
  2121. this.cancel();
  2122. this.textContentStream = readableStream;
  2123. }
  2124. }, {
  2125. key: "setTextContent",
  2126. value: function setTextContent(textContent) {
  2127. this.cancel();
  2128. this.textContent = textContent;
  2129. }
  2130. }, {
  2131. key: "_convertMatches",
  2132. value: function _convertMatches(matches, matchesLength) {
  2133. if (!matches) {
  2134. return [];
  2135. }
  2136. var textContentItemsStr = this.textContentItemsStr;
  2137. var i = 0,
  2138. iIndex = 0;
  2139. var end = textContentItemsStr.length - 1;
  2140. var result = [];
  2141. for (var m = 0, mm = matches.length; m < mm; m++) {
  2142. var matchIdx = matches[m];
  2143. while (i !== end && matchIdx >= iIndex + textContentItemsStr[i].length) {
  2144. iIndex += textContentItemsStr[i].length;
  2145. i++;
  2146. }
  2147. if (i === textContentItemsStr.length) {
  2148. console.error("Could not find a matching mapping");
  2149. }
  2150. var match = {
  2151. begin: {
  2152. divIdx: i,
  2153. offset: matchIdx - iIndex
  2154. }
  2155. };
  2156. matchIdx += matchesLength[m];
  2157. while (i !== end && matchIdx > iIndex + textContentItemsStr[i].length) {
  2158. iIndex += textContentItemsStr[i].length;
  2159. i++;
  2160. }
  2161. match.end = {
  2162. divIdx: i,
  2163. offset: matchIdx - iIndex
  2164. };
  2165. result.push(match);
  2166. }
  2167. return result;
  2168. }
  2169. }, {
  2170. key: "_renderMatches",
  2171. value: function _renderMatches(matches) {
  2172. if (matches.length === 0) {
  2173. return;
  2174. }
  2175. var findController = this.findController,
  2176. pageIdx = this.pageIdx,
  2177. textContentItemsStr = this.textContentItemsStr,
  2178. textDivs = this.textDivs;
  2179. var isSelectedPage = pageIdx === findController.selected.pageIdx;
  2180. var selectedMatchIdx = findController.selected.matchIdx;
  2181. var highlightAll = findController.state.highlightAll;
  2182. var prevEnd = null;
  2183. var infinity = {
  2184. divIdx: -1,
  2185. offset: undefined
  2186. };
  2187. function beginText(begin, className) {
  2188. var divIdx = begin.divIdx;
  2189. textDivs[divIdx].textContent = "";
  2190. return appendTextToDiv(divIdx, 0, begin.offset, className);
  2191. }
  2192. function appendTextToDiv(divIdx, fromOffset, toOffset, className) {
  2193. var div = textDivs[divIdx];
  2194. var content = textContentItemsStr[divIdx].substring(fromOffset, toOffset);
  2195. var node = document.createTextNode(content);
  2196. if (className) {
  2197. var span = document.createElement("span");
  2198. span.className = "".concat(className, " appended");
  2199. span.appendChild(node);
  2200. div.appendChild(span);
  2201. return className.includes("selected") ? span.offsetLeft : 0;
  2202. }
  2203. div.appendChild(node);
  2204. return 0;
  2205. }
  2206. var i0 = selectedMatchIdx,
  2207. i1 = i0 + 1;
  2208. if (highlightAll) {
  2209. i0 = 0;
  2210. i1 = matches.length;
  2211. } else if (!isSelectedPage) {
  2212. return;
  2213. }
  2214. for (var i = i0; i < i1; i++) {
  2215. var match = matches[i];
  2216. var begin = match.begin;
  2217. var end = match.end;
  2218. var isSelected = isSelectedPage && i === selectedMatchIdx;
  2219. var highlightSuffix = isSelected ? " selected" : "";
  2220. var selectedLeft = 0;
  2221. if (!prevEnd || begin.divIdx !== prevEnd.divIdx) {
  2222. if (prevEnd !== null) {
  2223. appendTextToDiv(prevEnd.divIdx, prevEnd.offset, infinity.offset);
  2224. }
  2225. beginText(begin);
  2226. } else {
  2227. appendTextToDiv(prevEnd.divIdx, prevEnd.offset, begin.offset);
  2228. }
  2229. if (begin.divIdx === end.divIdx) {
  2230. selectedLeft = appendTextToDiv(begin.divIdx, begin.offset, end.offset, "highlight" + highlightSuffix);
  2231. } else {
  2232. selectedLeft = appendTextToDiv(begin.divIdx, begin.offset, infinity.offset, "highlight begin" + highlightSuffix);
  2233. for (var n0 = begin.divIdx + 1, n1 = end.divIdx; n0 < n1; n0++) {
  2234. textDivs[n0].className = "highlight middle" + highlightSuffix;
  2235. }
  2236. beginText(end, "highlight end" + highlightSuffix);
  2237. }
  2238. prevEnd = end;
  2239. if (isSelected) {
  2240. findController.scrollMatchIntoView({
  2241. element: textDivs[begin.divIdx],
  2242. selectedLeft: selectedLeft,
  2243. pageIndex: pageIdx,
  2244. matchIndex: selectedMatchIdx
  2245. });
  2246. }
  2247. }
  2248. if (prevEnd) {
  2249. appendTextToDiv(prevEnd.divIdx, prevEnd.offset, infinity.offset);
  2250. }
  2251. }
  2252. }, {
  2253. key: "_updateMatches",
  2254. value: function _updateMatches() {
  2255. if (!this.renderingDone) {
  2256. return;
  2257. }
  2258. var findController = this.findController,
  2259. matches = this.matches,
  2260. pageIdx = this.pageIdx,
  2261. textContentItemsStr = this.textContentItemsStr,
  2262. textDivs = this.textDivs;
  2263. var clearedUntilDivIdx = -1;
  2264. for (var i = 0, ii = matches.length; i < ii; i++) {
  2265. var match = matches[i];
  2266. var begin = Math.max(clearedUntilDivIdx, match.begin.divIdx);
  2267. for (var n = begin, end = match.end.divIdx; n <= end; n++) {
  2268. var div = textDivs[n];
  2269. div.textContent = textContentItemsStr[n];
  2270. div.className = "";
  2271. }
  2272. clearedUntilDivIdx = match.end.divIdx + 1;
  2273. }
  2274. if (!(findController !== null && findController !== void 0 && findController.highlightMatches)) {
  2275. return;
  2276. }
  2277. var pageMatches = findController.pageMatches[pageIdx] || null;
  2278. var pageMatchesLength = findController.pageMatchesLength[pageIdx] || null;
  2279. this.matches = this._convertMatches(pageMatches, pageMatchesLength);
  2280. this._renderMatches(this.matches);
  2281. }
  2282. }, {
  2283. key: "_bindMouse",
  2284. value: function _bindMouse() {
  2285. var _this2 = this;
  2286. var div = this.textLayerDiv;
  2287. var expandDivsTimer = null;
  2288. div.addEventListener("mousedown", function (evt) {
  2289. if (_this2.enhanceTextSelection && _this2.textLayerRenderTask) {
  2290. _this2.textLayerRenderTask.expandTextDivs(true);
  2291. if (expandDivsTimer) {
  2292. clearTimeout(expandDivsTimer);
  2293. expandDivsTimer = null;
  2294. }
  2295. return;
  2296. }
  2297. var end = div.querySelector(".endOfContent");
  2298. if (!end) {
  2299. return;
  2300. }
  2301. var adjustTop = evt.target !== div;
  2302. adjustTop = adjustTop && window.getComputedStyle(end).getPropertyValue("-moz-user-select") !== "none";
  2303. if (adjustTop) {
  2304. var divBounds = div.getBoundingClientRect();
  2305. var r = Math.max(0, (evt.pageY - divBounds.top) / divBounds.height);
  2306. end.style.top = (r * 100).toFixed(2) + "%";
  2307. }
  2308. end.classList.add("active");
  2309. });
  2310. div.addEventListener("mouseup", function () {
  2311. if (_this2.enhanceTextSelection && _this2.textLayerRenderTask) {
  2312. expandDivsTimer = setTimeout(function () {
  2313. if (_this2.textLayerRenderTask) {
  2314. _this2.textLayerRenderTask.expandTextDivs(false);
  2315. }
  2316. expandDivsTimer = null;
  2317. }, EXPAND_DIVS_TIMEOUT);
  2318. return;
  2319. }
  2320. var end = div.querySelector(".endOfContent");
  2321. if (!end) {
  2322. return;
  2323. }
  2324. end.style.top = "";
  2325. end.classList.remove("active");
  2326. });
  2327. }
  2328. }]);
  2329. return TextLayerBuilder;
  2330. }();
  2331. exports.TextLayerBuilder = TextLayerBuilder;
  2332. var DefaultTextLayerFactory = /*#__PURE__*/function () {
  2333. function DefaultTextLayerFactory() {
  2334. _classCallCheck(this, DefaultTextLayerFactory);
  2335. }
  2336. _createClass(DefaultTextLayerFactory, [{
  2337. key: "createTextLayerBuilder",
  2338. value: function createTextLayerBuilder(textLayerDiv, pageIndex, viewport) {
  2339. var enhanceTextSelection = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
  2340. var eventBus = arguments.length > 4 ? arguments[4] : undefined;
  2341. return new TextLayerBuilder({
  2342. textLayerDiv: textLayerDiv,
  2343. pageIndex: pageIndex,
  2344. viewport: viewport,
  2345. enhanceTextSelection: enhanceTextSelection,
  2346. eventBus: eventBus
  2347. });
  2348. }
  2349. }]);
  2350. return DefaultTextLayerFactory;
  2351. }();
  2352. exports.DefaultTextLayerFactory = DefaultTextLayerFactory;
  2353. /***/ }),
  2354. /* 9 */
  2355. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  2356. Object.defineProperty(exports, "__esModule", ({
  2357. value: true
  2358. }));
  2359. exports.DownloadManager = void 0;
  2360. var _pdfjsLib = __w_pdfjs_require__(2);
  2361. var _viewer_compatibility = __w_pdfjs_require__(10);
  2362. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  2363. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  2364. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  2365. ;
  2366. function _download(blobUrl, filename) {
  2367. var a = document.createElement("a");
  2368. if (!a.click) {
  2369. throw new Error('DownloadManager: "a.click()" is not supported.');
  2370. }
  2371. a.href = blobUrl;
  2372. a.target = "_parent";
  2373. if ("download" in a) {
  2374. a.download = filename;
  2375. }
  2376. (document.body || document.documentElement).appendChild(a);
  2377. a.click();
  2378. a.remove();
  2379. }
  2380. var DownloadManager = /*#__PURE__*/function () {
  2381. function DownloadManager() {
  2382. _classCallCheck(this, DownloadManager);
  2383. this._openBlobUrls = new WeakMap();
  2384. }
  2385. _createClass(DownloadManager, [{
  2386. key: "downloadUrl",
  2387. value: function downloadUrl(url, filename) {
  2388. if (!(0, _pdfjsLib.createValidAbsoluteUrl)(url, "http://example.com")) {
  2389. return;
  2390. }
  2391. _download(url + "#pdfjs.action=download", filename);
  2392. }
  2393. }, {
  2394. key: "downloadData",
  2395. value: function downloadData(data, filename, contentType) {
  2396. var blobUrl = (0, _pdfjsLib.createObjectURL)(data, contentType, _viewer_compatibility.viewerCompatibilityParams.disableCreateObjectURL);
  2397. _download(blobUrl, filename);
  2398. }
  2399. }, {
  2400. key: "openOrDownloadData",
  2401. value: function openOrDownloadData(element, data, filename) {
  2402. var isPdfData = (0, _pdfjsLib.isPdfFile)(filename);
  2403. var contentType = isPdfData ? "application/pdf" : "";
  2404. if (isPdfData && !_viewer_compatibility.viewerCompatibilityParams.disableCreateObjectURL) {
  2405. var blobUrl = this._openBlobUrls.get(element);
  2406. if (!blobUrl) {
  2407. blobUrl = URL.createObjectURL(new Blob([data], {
  2408. type: contentType
  2409. }));
  2410. this._openBlobUrls.set(element, blobUrl);
  2411. }
  2412. var viewerUrl;
  2413. viewerUrl = "?file=" + encodeURIComponent(blobUrl + "#" + filename);
  2414. try {
  2415. window.open(viewerUrl);
  2416. return true;
  2417. } catch (ex) {
  2418. console.error("openOrDownloadData: ".concat(ex));
  2419. URL.revokeObjectURL(blobUrl);
  2420. this._openBlobUrls["delete"](element);
  2421. }
  2422. }
  2423. this.downloadData(data, filename, contentType);
  2424. return false;
  2425. }
  2426. }, {
  2427. key: "download",
  2428. value: function download(blob, url, filename) {
  2429. var sourceEventType = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : "download";
  2430. if (_viewer_compatibility.viewerCompatibilityParams.disableCreateObjectURL) {
  2431. this.downloadUrl(url, filename);
  2432. return;
  2433. }
  2434. var blobUrl = URL.createObjectURL(blob);
  2435. _download(blobUrl, filename);
  2436. }
  2437. }]);
  2438. return DownloadManager;
  2439. }();
  2440. exports.DownloadManager = DownloadManager;
  2441. /***/ }),
  2442. /* 10 */
  2443. /***/ ((__unused_webpack_module, exports) => {
  2444. Object.defineProperty(exports, "__esModule", ({
  2445. value: true
  2446. }));
  2447. exports.viewerCompatibilityParams = void 0;
  2448. var compatibilityParams = Object.create(null);
  2449. {
  2450. var userAgent = typeof navigator !== "undefined" && navigator.userAgent || "";
  2451. var platform = typeof navigator !== "undefined" && navigator.platform || "";
  2452. var maxTouchPoints = typeof navigator !== "undefined" && navigator.maxTouchPoints || 1;
  2453. var isAndroid = /Android/.test(userAgent);
  2454. var isIOS = /\b(iPad|iPhone|iPod)(?=;)/.test(userAgent) || platform === "MacIntel" && maxTouchPoints > 1;
  2455. var isIOSChrome = /CriOS/.test(userAgent);
  2456. (function checkOnBlobSupport() {
  2457. if (isIOSChrome) {
  2458. compatibilityParams.disableCreateObjectURL = true;
  2459. }
  2460. })();
  2461. (function checkCanvasSizeLimitation() {
  2462. if (isIOS || isAndroid) {
  2463. compatibilityParams.maxCanvasPixels = 5242880;
  2464. }
  2465. })();
  2466. }
  2467. var viewerCompatibilityParams = Object.freeze(compatibilityParams);
  2468. exports.viewerCompatibilityParams = viewerCompatibilityParams;
  2469. /***/ }),
  2470. /* 11 */
  2471. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  2472. Object.defineProperty(exports, "__esModule", ({
  2473. value: true
  2474. }));
  2475. exports.GenericL10n = void 0;
  2476. var _regenerator = _interopRequireDefault(__w_pdfjs_require__(4));
  2477. __w_pdfjs_require__(12);
  2478. var _l10n_utils = __w_pdfjs_require__(3);
  2479. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  2480. function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
  2481. function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
  2482. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  2483. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  2484. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  2485. var webL10n = document.webL10n;
  2486. var GenericL10n = /*#__PURE__*/function () {
  2487. function GenericL10n(lang) {
  2488. _classCallCheck(this, GenericL10n);
  2489. this._lang = lang;
  2490. this._ready = new Promise(function (resolve, reject) {
  2491. webL10n.setLanguage((0, _l10n_utils.fixupLangCode)(lang), function () {
  2492. resolve(webL10n);
  2493. });
  2494. });
  2495. }
  2496. _createClass(GenericL10n, [{
  2497. key: "getLanguage",
  2498. value: function () {
  2499. var _getLanguage = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
  2500. var l10n;
  2501. return _regenerator["default"].wrap(function _callee$(_context) {
  2502. while (1) {
  2503. switch (_context.prev = _context.next) {
  2504. case 0:
  2505. _context.next = 2;
  2506. return this._ready;
  2507. case 2:
  2508. l10n = _context.sent;
  2509. return _context.abrupt("return", l10n.getLanguage());
  2510. case 4:
  2511. case "end":
  2512. return _context.stop();
  2513. }
  2514. }
  2515. }, _callee, this);
  2516. }));
  2517. function getLanguage() {
  2518. return _getLanguage.apply(this, arguments);
  2519. }
  2520. return getLanguage;
  2521. }()
  2522. }, {
  2523. key: "getDirection",
  2524. value: function () {
  2525. var _getDirection = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee2() {
  2526. var l10n;
  2527. return _regenerator["default"].wrap(function _callee2$(_context2) {
  2528. while (1) {
  2529. switch (_context2.prev = _context2.next) {
  2530. case 0:
  2531. _context2.next = 2;
  2532. return this._ready;
  2533. case 2:
  2534. l10n = _context2.sent;
  2535. return _context2.abrupt("return", l10n.getDirection());
  2536. case 4:
  2537. case "end":
  2538. return _context2.stop();
  2539. }
  2540. }
  2541. }, _callee2, this);
  2542. }));
  2543. function getDirection() {
  2544. return _getDirection.apply(this, arguments);
  2545. }
  2546. return getDirection;
  2547. }()
  2548. }, {
  2549. key: "get",
  2550. value: function () {
  2551. var _get = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee3(key) {
  2552. var args,
  2553. fallback,
  2554. l10n,
  2555. _args3 = arguments;
  2556. return _regenerator["default"].wrap(function _callee3$(_context3) {
  2557. while (1) {
  2558. switch (_context3.prev = _context3.next) {
  2559. case 0:
  2560. args = _args3.length > 1 && _args3[1] !== undefined ? _args3[1] : null;
  2561. fallback = _args3.length > 2 && _args3[2] !== undefined ? _args3[2] : (0, _l10n_utils.getL10nFallback)(key, args);
  2562. _context3.next = 4;
  2563. return this._ready;
  2564. case 4:
  2565. l10n = _context3.sent;
  2566. return _context3.abrupt("return", l10n.get(key, args, fallback));
  2567. case 6:
  2568. case "end":
  2569. return _context3.stop();
  2570. }
  2571. }
  2572. }, _callee3, this);
  2573. }));
  2574. function get(_x) {
  2575. return _get.apply(this, arguments);
  2576. }
  2577. return get;
  2578. }()
  2579. }, {
  2580. key: "translate",
  2581. value: function () {
  2582. var _translate = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee4(element) {
  2583. var l10n;
  2584. return _regenerator["default"].wrap(function _callee4$(_context4) {
  2585. while (1) {
  2586. switch (_context4.prev = _context4.next) {
  2587. case 0:
  2588. _context4.next = 2;
  2589. return this._ready;
  2590. case 2:
  2591. l10n = _context4.sent;
  2592. return _context4.abrupt("return", l10n.translate(element));
  2593. case 4:
  2594. case "end":
  2595. return _context4.stop();
  2596. }
  2597. }
  2598. }, _callee4, this);
  2599. }));
  2600. function translate(_x2) {
  2601. return _translate.apply(this, arguments);
  2602. }
  2603. return translate;
  2604. }()
  2605. }]);
  2606. return GenericL10n;
  2607. }();
  2608. exports.GenericL10n = GenericL10n;
  2609. /***/ }),
  2610. /* 12 */
  2611. /***/ (() => {
  2612. document.webL10n = function (window, document, undefined) {
  2613. var gL10nData = {};
  2614. var gTextData = '';
  2615. var gTextProp = 'textContent';
  2616. var gLanguage = '';
  2617. var gMacros = {};
  2618. var gReadyState = 'loading';
  2619. var gAsyncResourceLoading = true;
  2620. function getL10nResourceLinks() {
  2621. return document.querySelectorAll('link[type="application/l10n"]');
  2622. }
  2623. function getL10nDictionary() {
  2624. var script = document.querySelector('script[type="application/l10n"]');
  2625. return script ? JSON.parse(script.innerHTML) : null;
  2626. }
  2627. function getTranslatableChildren(element) {
  2628. return element ? element.querySelectorAll('*[data-l10n-id]') : [];
  2629. }
  2630. function getL10nAttributes(element) {
  2631. if (!element) return {};
  2632. var l10nId = element.getAttribute('data-l10n-id');
  2633. var l10nArgs = element.getAttribute('data-l10n-args');
  2634. var args = {};
  2635. if (l10nArgs) {
  2636. try {
  2637. args = JSON.parse(l10nArgs);
  2638. } catch (e) {
  2639. console.warn('could not parse arguments for #' + l10nId);
  2640. }
  2641. }
  2642. return {
  2643. id: l10nId,
  2644. args: args
  2645. };
  2646. }
  2647. function xhrLoadText(url, onSuccess, onFailure) {
  2648. onSuccess = onSuccess || function _onSuccess(data) {};
  2649. onFailure = onFailure || function _onFailure() {};
  2650. var xhr = new XMLHttpRequest();
  2651. xhr.open('GET', url, gAsyncResourceLoading);
  2652. if (xhr.overrideMimeType) {
  2653. xhr.overrideMimeType('text/plain; charset=utf-8');
  2654. }
  2655. xhr.onreadystatechange = function () {
  2656. if (xhr.readyState == 4) {
  2657. if (xhr.status == 200 || xhr.status === 0) {
  2658. onSuccess(xhr.responseText);
  2659. } else {
  2660. onFailure();
  2661. }
  2662. }
  2663. };
  2664. xhr.onerror = onFailure;
  2665. xhr.ontimeout = onFailure;
  2666. try {
  2667. xhr.send(null);
  2668. } catch (e) {
  2669. onFailure();
  2670. }
  2671. }
  2672. function parseResource(href, lang, successCallback, failureCallback) {
  2673. var baseURL = href.replace(/[^\/]*$/, '') || './';
  2674. function evalString(text) {
  2675. if (text.lastIndexOf('\\') < 0) return text;
  2676. return text.replace(/\\\\/g, '\\').replace(/\\n/g, '\n').replace(/\\r/g, '\r').replace(/\\t/g, '\t').replace(/\\b/g, '\b').replace(/\\f/g, '\f').replace(/\\{/g, '{').replace(/\\}/g, '}').replace(/\\"/g, '"').replace(/\\'/g, "'");
  2677. }
  2678. function parseProperties(text, parsedPropertiesCallback) {
  2679. var dictionary = {};
  2680. var reBlank = /^\s*|\s*$/;
  2681. var reComment = /^\s*#|^\s*$/;
  2682. var reSection = /^\s*\[(.*)\]\s*$/;
  2683. var reImport = /^\s*@import\s+url\((.*)\)\s*$/i;
  2684. var reSplit = /^([^=\s]*)\s*=\s*(.+)$/;
  2685. function parseRawLines(rawText, extendedSyntax, parsedRawLinesCallback) {
  2686. var entries = rawText.replace(reBlank, '').split(/[\r\n]+/);
  2687. var currentLang = '*';
  2688. var genericLang = lang.split('-', 1)[0];
  2689. var skipLang = false;
  2690. var match = '';
  2691. function nextEntry() {
  2692. while (true) {
  2693. if (!entries.length) {
  2694. parsedRawLinesCallback();
  2695. return;
  2696. }
  2697. var line = entries.shift();
  2698. if (reComment.test(line)) continue;
  2699. if (extendedSyntax) {
  2700. match = reSection.exec(line);
  2701. if (match) {
  2702. currentLang = match[1].toLowerCase();
  2703. skipLang = currentLang !== '*' && currentLang !== lang && currentLang !== genericLang;
  2704. continue;
  2705. } else if (skipLang) {
  2706. continue;
  2707. }
  2708. match = reImport.exec(line);
  2709. if (match) {
  2710. loadImport(baseURL + match[1], nextEntry);
  2711. return;
  2712. }
  2713. }
  2714. var tmp = line.match(reSplit);
  2715. if (tmp && tmp.length == 3) {
  2716. dictionary[tmp[1]] = evalString(tmp[2]);
  2717. }
  2718. }
  2719. }
  2720. nextEntry();
  2721. }
  2722. function loadImport(url, callback) {
  2723. xhrLoadText(url, function (content) {
  2724. parseRawLines(content, false, callback);
  2725. }, function () {
  2726. console.warn(url + ' not found.');
  2727. callback();
  2728. });
  2729. }
  2730. parseRawLines(text, true, function () {
  2731. parsedPropertiesCallback(dictionary);
  2732. });
  2733. }
  2734. xhrLoadText(href, function (response) {
  2735. gTextData += response;
  2736. parseProperties(response, function (data) {
  2737. for (var key in data) {
  2738. var id,
  2739. prop,
  2740. index = key.lastIndexOf('.');
  2741. if (index > 0) {
  2742. id = key.substring(0, index);
  2743. prop = key.substring(index + 1);
  2744. } else {
  2745. id = key;
  2746. prop = gTextProp;
  2747. }
  2748. if (!gL10nData[id]) {
  2749. gL10nData[id] = {};
  2750. }
  2751. gL10nData[id][prop] = data[key];
  2752. }
  2753. if (successCallback) {
  2754. successCallback();
  2755. }
  2756. });
  2757. }, failureCallback);
  2758. }
  2759. function loadLocale(lang, callback) {
  2760. if (lang) {
  2761. lang = lang.toLowerCase();
  2762. }
  2763. callback = callback || function _callback() {};
  2764. clear();
  2765. gLanguage = lang;
  2766. var langLinks = getL10nResourceLinks();
  2767. var langCount = langLinks.length;
  2768. if (langCount === 0) {
  2769. var dict = getL10nDictionary();
  2770. if (dict && dict.locales && dict.default_locale) {
  2771. console.log('using the embedded JSON directory, early way out');
  2772. gL10nData = dict.locales[lang];
  2773. if (!gL10nData) {
  2774. var defaultLocale = dict.default_locale.toLowerCase();
  2775. for (var anyCaseLang in dict.locales) {
  2776. anyCaseLang = anyCaseLang.toLowerCase();
  2777. if (anyCaseLang === lang) {
  2778. gL10nData = dict.locales[lang];
  2779. break;
  2780. } else if (anyCaseLang === defaultLocale) {
  2781. gL10nData = dict.locales[defaultLocale];
  2782. }
  2783. }
  2784. }
  2785. callback();
  2786. } else {
  2787. console.log('no resource to load, early way out');
  2788. }
  2789. gReadyState = 'complete';
  2790. return;
  2791. }
  2792. var onResourceLoaded = null;
  2793. var gResourceCount = 0;
  2794. onResourceLoaded = function onResourceLoaded() {
  2795. gResourceCount++;
  2796. if (gResourceCount >= langCount) {
  2797. callback();
  2798. gReadyState = 'complete';
  2799. }
  2800. };
  2801. function L10nResourceLink(link) {
  2802. var href = link.href;
  2803. this.load = function (lang, callback) {
  2804. parseResource(href, lang, callback, function () {
  2805. console.warn(href + ' not found.');
  2806. console.warn('"' + lang + '" resource not found');
  2807. gLanguage = '';
  2808. callback();
  2809. });
  2810. };
  2811. }
  2812. for (var i = 0; i < langCount; i++) {
  2813. var resource = new L10nResourceLink(langLinks[i]);
  2814. resource.load(lang, onResourceLoaded);
  2815. }
  2816. }
  2817. function clear() {
  2818. gL10nData = {};
  2819. gTextData = '';
  2820. gLanguage = '';
  2821. }
  2822. function getPluralRules(lang) {
  2823. var locales2rules = {
  2824. 'af': 3,
  2825. 'ak': 4,
  2826. 'am': 4,
  2827. 'ar': 1,
  2828. 'asa': 3,
  2829. 'az': 0,
  2830. 'be': 11,
  2831. 'bem': 3,
  2832. 'bez': 3,
  2833. 'bg': 3,
  2834. 'bh': 4,
  2835. 'bm': 0,
  2836. 'bn': 3,
  2837. 'bo': 0,
  2838. 'br': 20,
  2839. 'brx': 3,
  2840. 'bs': 11,
  2841. 'ca': 3,
  2842. 'cgg': 3,
  2843. 'chr': 3,
  2844. 'cs': 12,
  2845. 'cy': 17,
  2846. 'da': 3,
  2847. 'de': 3,
  2848. 'dv': 3,
  2849. 'dz': 0,
  2850. 'ee': 3,
  2851. 'el': 3,
  2852. 'en': 3,
  2853. 'eo': 3,
  2854. 'es': 3,
  2855. 'et': 3,
  2856. 'eu': 3,
  2857. 'fa': 0,
  2858. 'ff': 5,
  2859. 'fi': 3,
  2860. 'fil': 4,
  2861. 'fo': 3,
  2862. 'fr': 5,
  2863. 'fur': 3,
  2864. 'fy': 3,
  2865. 'ga': 8,
  2866. 'gd': 24,
  2867. 'gl': 3,
  2868. 'gsw': 3,
  2869. 'gu': 3,
  2870. 'guw': 4,
  2871. 'gv': 23,
  2872. 'ha': 3,
  2873. 'haw': 3,
  2874. 'he': 2,
  2875. 'hi': 4,
  2876. 'hr': 11,
  2877. 'hu': 0,
  2878. 'id': 0,
  2879. 'ig': 0,
  2880. 'ii': 0,
  2881. 'is': 3,
  2882. 'it': 3,
  2883. 'iu': 7,
  2884. 'ja': 0,
  2885. 'jmc': 3,
  2886. 'jv': 0,
  2887. 'ka': 0,
  2888. 'kab': 5,
  2889. 'kaj': 3,
  2890. 'kcg': 3,
  2891. 'kde': 0,
  2892. 'kea': 0,
  2893. 'kk': 3,
  2894. 'kl': 3,
  2895. 'km': 0,
  2896. 'kn': 0,
  2897. 'ko': 0,
  2898. 'ksb': 3,
  2899. 'ksh': 21,
  2900. 'ku': 3,
  2901. 'kw': 7,
  2902. 'lag': 18,
  2903. 'lb': 3,
  2904. 'lg': 3,
  2905. 'ln': 4,
  2906. 'lo': 0,
  2907. 'lt': 10,
  2908. 'lv': 6,
  2909. 'mas': 3,
  2910. 'mg': 4,
  2911. 'mk': 16,
  2912. 'ml': 3,
  2913. 'mn': 3,
  2914. 'mo': 9,
  2915. 'mr': 3,
  2916. 'ms': 0,
  2917. 'mt': 15,
  2918. 'my': 0,
  2919. 'nah': 3,
  2920. 'naq': 7,
  2921. 'nb': 3,
  2922. 'nd': 3,
  2923. 'ne': 3,
  2924. 'nl': 3,
  2925. 'nn': 3,
  2926. 'no': 3,
  2927. 'nr': 3,
  2928. 'nso': 4,
  2929. 'ny': 3,
  2930. 'nyn': 3,
  2931. 'om': 3,
  2932. 'or': 3,
  2933. 'pa': 3,
  2934. 'pap': 3,
  2935. 'pl': 13,
  2936. 'ps': 3,
  2937. 'pt': 3,
  2938. 'rm': 3,
  2939. 'ro': 9,
  2940. 'rof': 3,
  2941. 'ru': 11,
  2942. 'rwk': 3,
  2943. 'sah': 0,
  2944. 'saq': 3,
  2945. 'se': 7,
  2946. 'seh': 3,
  2947. 'ses': 0,
  2948. 'sg': 0,
  2949. 'sh': 11,
  2950. 'shi': 19,
  2951. 'sk': 12,
  2952. 'sl': 14,
  2953. 'sma': 7,
  2954. 'smi': 7,
  2955. 'smj': 7,
  2956. 'smn': 7,
  2957. 'sms': 7,
  2958. 'sn': 3,
  2959. 'so': 3,
  2960. 'sq': 3,
  2961. 'sr': 11,
  2962. 'ss': 3,
  2963. 'ssy': 3,
  2964. 'st': 3,
  2965. 'sv': 3,
  2966. 'sw': 3,
  2967. 'syr': 3,
  2968. 'ta': 3,
  2969. 'te': 3,
  2970. 'teo': 3,
  2971. 'th': 0,
  2972. 'ti': 4,
  2973. 'tig': 3,
  2974. 'tk': 3,
  2975. 'tl': 4,
  2976. 'tn': 3,
  2977. 'to': 0,
  2978. 'tr': 0,
  2979. 'ts': 3,
  2980. 'tzm': 22,
  2981. 'uk': 11,
  2982. 'ur': 3,
  2983. 've': 3,
  2984. 'vi': 0,
  2985. 'vun': 3,
  2986. 'wa': 4,
  2987. 'wae': 3,
  2988. 'wo': 0,
  2989. 'xh': 3,
  2990. 'xog': 3,
  2991. 'yo': 0,
  2992. 'zh': 0,
  2993. 'zu': 3
  2994. };
  2995. function isIn(n, list) {
  2996. return list.indexOf(n) !== -1;
  2997. }
  2998. function isBetween(n, start, end) {
  2999. return start <= n && n <= end;
  3000. }
  3001. var pluralRules = {
  3002. '0': function _(n) {
  3003. return 'other';
  3004. },
  3005. '1': function _(n) {
  3006. if (isBetween(n % 100, 3, 10)) return 'few';
  3007. if (n === 0) return 'zero';
  3008. if (isBetween(n % 100, 11, 99)) return 'many';
  3009. if (n == 2) return 'two';
  3010. if (n == 1) return 'one';
  3011. return 'other';
  3012. },
  3013. '2': function _(n) {
  3014. if (n !== 0 && n % 10 === 0) return 'many';
  3015. if (n == 2) return 'two';
  3016. if (n == 1) return 'one';
  3017. return 'other';
  3018. },
  3019. '3': function _(n) {
  3020. if (n == 1) return 'one';
  3021. return 'other';
  3022. },
  3023. '4': function _(n) {
  3024. if (isBetween(n, 0, 1)) return 'one';
  3025. return 'other';
  3026. },
  3027. '5': function _(n) {
  3028. if (isBetween(n, 0, 2) && n != 2) return 'one';
  3029. return 'other';
  3030. },
  3031. '6': function _(n) {
  3032. if (n === 0) return 'zero';
  3033. if (n % 10 == 1 && n % 100 != 11) return 'one';
  3034. return 'other';
  3035. },
  3036. '7': function _(n) {
  3037. if (n == 2) return 'two';
  3038. if (n == 1) return 'one';
  3039. return 'other';
  3040. },
  3041. '8': function _(n) {
  3042. if (isBetween(n, 3, 6)) return 'few';
  3043. if (isBetween(n, 7, 10)) return 'many';
  3044. if (n == 2) return 'two';
  3045. if (n == 1) return 'one';
  3046. return 'other';
  3047. },
  3048. '9': function _(n) {
  3049. if (n === 0 || n != 1 && isBetween(n % 100, 1, 19)) return 'few';
  3050. if (n == 1) return 'one';
  3051. return 'other';
  3052. },
  3053. '10': function _(n) {
  3054. if (isBetween(n % 10, 2, 9) && !isBetween(n % 100, 11, 19)) return 'few';
  3055. if (n % 10 == 1 && !isBetween(n % 100, 11, 19)) return 'one';
  3056. return 'other';
  3057. },
  3058. '11': function _(n) {
  3059. if (isBetween(n % 10, 2, 4) && !isBetween(n % 100, 12, 14)) return 'few';
  3060. if (n % 10 === 0 || isBetween(n % 10, 5, 9) || isBetween(n % 100, 11, 14)) return 'many';
  3061. if (n % 10 == 1 && n % 100 != 11) return 'one';
  3062. return 'other';
  3063. },
  3064. '12': function _(n) {
  3065. if (isBetween(n, 2, 4)) return 'few';
  3066. if (n == 1) return 'one';
  3067. return 'other';
  3068. },
  3069. '13': function _(n) {
  3070. if (isBetween(n % 10, 2, 4) && !isBetween(n % 100, 12, 14)) return 'few';
  3071. if (n != 1 && isBetween(n % 10, 0, 1) || isBetween(n % 10, 5, 9) || isBetween(n % 100, 12, 14)) return 'many';
  3072. if (n == 1) return 'one';
  3073. return 'other';
  3074. },
  3075. '14': function _(n) {
  3076. if (isBetween(n % 100, 3, 4)) return 'few';
  3077. if (n % 100 == 2) return 'two';
  3078. if (n % 100 == 1) return 'one';
  3079. return 'other';
  3080. },
  3081. '15': function _(n) {
  3082. if (n === 0 || isBetween(n % 100, 2, 10)) return 'few';
  3083. if (isBetween(n % 100, 11, 19)) return 'many';
  3084. if (n == 1) return 'one';
  3085. return 'other';
  3086. },
  3087. '16': function _(n) {
  3088. if (n % 10 == 1 && n != 11) return 'one';
  3089. return 'other';
  3090. },
  3091. '17': function _(n) {
  3092. if (n == 3) return 'few';
  3093. if (n === 0) return 'zero';
  3094. if (n == 6) return 'many';
  3095. if (n == 2) return 'two';
  3096. if (n == 1) return 'one';
  3097. return 'other';
  3098. },
  3099. '18': function _(n) {
  3100. if (n === 0) return 'zero';
  3101. if (isBetween(n, 0, 2) && n !== 0 && n != 2) return 'one';
  3102. return 'other';
  3103. },
  3104. '19': function _(n) {
  3105. if (isBetween(n, 2, 10)) return 'few';
  3106. if (isBetween(n, 0, 1)) return 'one';
  3107. return 'other';
  3108. },
  3109. '20': function _(n) {
  3110. if ((isBetween(n % 10, 3, 4) || n % 10 == 9) && !(isBetween(n % 100, 10, 19) || isBetween(n % 100, 70, 79) || isBetween(n % 100, 90, 99))) return 'few';
  3111. if (n % 1000000 === 0 && n !== 0) return 'many';
  3112. if (n % 10 == 2 && !isIn(n % 100, [12, 72, 92])) return 'two';
  3113. if (n % 10 == 1 && !isIn(n % 100, [11, 71, 91])) return 'one';
  3114. return 'other';
  3115. },
  3116. '21': function _(n) {
  3117. if (n === 0) return 'zero';
  3118. if (n == 1) return 'one';
  3119. return 'other';
  3120. },
  3121. '22': function _(n) {
  3122. if (isBetween(n, 0, 1) || isBetween(n, 11, 99)) return 'one';
  3123. return 'other';
  3124. },
  3125. '23': function _(n) {
  3126. if (isBetween(n % 10, 1, 2) || n % 20 === 0) return 'one';
  3127. return 'other';
  3128. },
  3129. '24': function _(n) {
  3130. if (isBetween(n, 3, 10) || isBetween(n, 13, 19)) return 'few';
  3131. if (isIn(n, [2, 12])) return 'two';
  3132. if (isIn(n, [1, 11])) return 'one';
  3133. return 'other';
  3134. }
  3135. };
  3136. var index = locales2rules[lang.replace(/-.*$/, '')];
  3137. if (!(index in pluralRules)) {
  3138. console.warn('plural form unknown for [' + lang + ']');
  3139. return function () {
  3140. return 'other';
  3141. };
  3142. }
  3143. return pluralRules[index];
  3144. }
  3145. gMacros.plural = function (str, param, key, prop) {
  3146. var n = parseFloat(param);
  3147. if (isNaN(n)) return str;
  3148. if (prop != gTextProp) return str;
  3149. if (!gMacros._pluralRules) {
  3150. gMacros._pluralRules = getPluralRules(gLanguage);
  3151. }
  3152. var index = '[' + gMacros._pluralRules(n) + ']';
  3153. if (n === 0 && key + '[zero]' in gL10nData) {
  3154. str = gL10nData[key + '[zero]'][prop];
  3155. } else if (n == 1 && key + '[one]' in gL10nData) {
  3156. str = gL10nData[key + '[one]'][prop];
  3157. } else if (n == 2 && key + '[two]' in gL10nData) {
  3158. str = gL10nData[key + '[two]'][prop];
  3159. } else if (key + index in gL10nData) {
  3160. str = gL10nData[key + index][prop];
  3161. } else if (key + '[other]' in gL10nData) {
  3162. str = gL10nData[key + '[other]'][prop];
  3163. }
  3164. return str;
  3165. };
  3166. function getL10nData(key, args, fallback) {
  3167. var data = gL10nData[key];
  3168. if (!data) {
  3169. console.warn('#' + key + ' is undefined.');
  3170. if (!fallback) {
  3171. return null;
  3172. }
  3173. data = fallback;
  3174. }
  3175. var rv = {};
  3176. for (var prop in data) {
  3177. var str = data[prop];
  3178. str = substIndexes(str, args, key, prop);
  3179. str = substArguments(str, args, key);
  3180. rv[prop] = str;
  3181. }
  3182. return rv;
  3183. }
  3184. function substIndexes(str, args, key, prop) {
  3185. var reIndex = /\{\[\s*([a-zA-Z]+)\(([a-zA-Z]+)\)\s*\]\}/;
  3186. var reMatch = reIndex.exec(str);
  3187. if (!reMatch || !reMatch.length) return str;
  3188. var macroName = reMatch[1];
  3189. var paramName = reMatch[2];
  3190. var param;
  3191. if (args && paramName in args) {
  3192. param = args[paramName];
  3193. } else if (paramName in gL10nData) {
  3194. param = gL10nData[paramName];
  3195. }
  3196. if (macroName in gMacros) {
  3197. var macro = gMacros[macroName];
  3198. str = macro(str, param, key, prop);
  3199. }
  3200. return str;
  3201. }
  3202. function substArguments(str, args, key) {
  3203. var reArgs = /\{\{\s*(.+?)\s*\}\}/g;
  3204. return str.replace(reArgs, function (matched_text, arg) {
  3205. if (args && arg in args) {
  3206. return args[arg];
  3207. }
  3208. if (arg in gL10nData) {
  3209. return gL10nData[arg];
  3210. }
  3211. console.log('argument {{' + arg + '}} for #' + key + ' is undefined.');
  3212. return matched_text;
  3213. });
  3214. }
  3215. function translateElement(element) {
  3216. var l10n = getL10nAttributes(element);
  3217. if (!l10n.id) return;
  3218. var data = getL10nData(l10n.id, l10n.args);
  3219. if (!data) {
  3220. console.warn('#' + l10n.id + ' is undefined.');
  3221. return;
  3222. }
  3223. if (data[gTextProp]) {
  3224. if (getChildElementCount(element) === 0) {
  3225. element[gTextProp] = data[gTextProp];
  3226. } else {
  3227. var children = element.childNodes;
  3228. var found = false;
  3229. for (var i = 0, l = children.length; i < l; i++) {
  3230. if (children[i].nodeType === 3 && /\S/.test(children[i].nodeValue)) {
  3231. if (found) {
  3232. children[i].nodeValue = '';
  3233. } else {
  3234. children[i].nodeValue = data[gTextProp];
  3235. found = true;
  3236. }
  3237. }
  3238. }
  3239. if (!found) {
  3240. var textNode = document.createTextNode(data[gTextProp]);
  3241. element.insertBefore(textNode, element.firstChild);
  3242. }
  3243. }
  3244. delete data[gTextProp];
  3245. }
  3246. for (var k in data) {
  3247. element[k] = data[k];
  3248. }
  3249. }
  3250. function getChildElementCount(element) {
  3251. if (element.children) {
  3252. return element.children.length;
  3253. }
  3254. if (typeof element.childElementCount !== 'undefined') {
  3255. return element.childElementCount;
  3256. }
  3257. var count = 0;
  3258. for (var i = 0; i < element.childNodes.length; i++) {
  3259. count += element.nodeType === 1 ? 1 : 0;
  3260. }
  3261. return count;
  3262. }
  3263. function translateFragment(element) {
  3264. element = element || document.documentElement;
  3265. var children = getTranslatableChildren(element);
  3266. var elementCount = children.length;
  3267. for (var i = 0; i < elementCount; i++) {
  3268. translateElement(children[i]);
  3269. }
  3270. translateElement(element);
  3271. }
  3272. return {
  3273. get: function get(key, args, fallbackString) {
  3274. var index = key.lastIndexOf('.');
  3275. var prop = gTextProp;
  3276. if (index > 0) {
  3277. prop = key.substring(index + 1);
  3278. key = key.substring(0, index);
  3279. }
  3280. var fallback;
  3281. if (fallbackString) {
  3282. fallback = {};
  3283. fallback[prop] = fallbackString;
  3284. }
  3285. var data = getL10nData(key, args, fallback);
  3286. if (data && prop in data) {
  3287. return data[prop];
  3288. }
  3289. return '{{' + key + '}}';
  3290. },
  3291. getData: function getData() {
  3292. return gL10nData;
  3293. },
  3294. getText: function getText() {
  3295. return gTextData;
  3296. },
  3297. getLanguage: function getLanguage() {
  3298. return gLanguage;
  3299. },
  3300. setLanguage: function setLanguage(lang, callback) {
  3301. loadLocale(lang, function () {
  3302. if (callback) callback();
  3303. });
  3304. },
  3305. getDirection: function getDirection() {
  3306. var rtlList = ['ar', 'he', 'fa', 'ps', 'ur'];
  3307. var shortCode = gLanguage.split('-', 1)[0];
  3308. return rtlList.indexOf(shortCode) >= 0 ? 'rtl' : 'ltr';
  3309. },
  3310. translate: translateFragment,
  3311. getReadyState: function getReadyState() {
  3312. return gReadyState;
  3313. },
  3314. ready: function ready(callback) {
  3315. if (!callback) {
  3316. return;
  3317. } else if (gReadyState == 'complete' || gReadyState == 'interactive') {
  3318. window.setTimeout(function () {
  3319. callback();
  3320. });
  3321. } else if (document.addEventListener) {
  3322. document.addEventListener('localized', function once() {
  3323. document.removeEventListener('localized', once);
  3324. callback();
  3325. });
  3326. }
  3327. }
  3328. };
  3329. }(window, document);
  3330. /***/ }),
  3331. /* 13 */
  3332. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  3333. Object.defineProperty(exports, "__esModule", ({
  3334. value: true
  3335. }));
  3336. exports.PDFFindController = exports.FindState = void 0;
  3337. var _pdfjsLib = __w_pdfjs_require__(2);
  3338. var _pdf_find_utils = __w_pdfjs_require__(14);
  3339. var _ui_utils = __w_pdfjs_require__(7);
  3340. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  3341. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  3342. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  3343. function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
  3344. function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
  3345. function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
  3346. function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
  3347. function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e2) { throw _e2; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e3) { didErr = true; err = _e3; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
  3348. function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
  3349. function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
  3350. var FindState = {
  3351. FOUND: 0,
  3352. NOT_FOUND: 1,
  3353. WRAPPED: 2,
  3354. PENDING: 3
  3355. };
  3356. exports.FindState = FindState;
  3357. var FIND_TIMEOUT = 250;
  3358. var MATCH_SCROLL_OFFSET_TOP = -50;
  3359. var MATCH_SCROLL_OFFSET_LEFT = -400;
  3360. var CHARACTERS_TO_NORMALIZE = {
  3361. "\u2010": "-",
  3362. "\u2018": "'",
  3363. "\u2019": "'",
  3364. "\u201A": "'",
  3365. "\u201B": "'",
  3366. "\u201C": '"',
  3367. "\u201D": '"',
  3368. "\u201E": '"',
  3369. "\u201F": '"',
  3370. "\xBC": "1/4",
  3371. "\xBD": "1/2",
  3372. "\xBE": "3/4"
  3373. };
  3374. var normalizationRegex = null;
  3375. function normalize(text) {
  3376. if (!normalizationRegex) {
  3377. var replace = Object.keys(CHARACTERS_TO_NORMALIZE).join("");
  3378. normalizationRegex = new RegExp("[".concat(replace, "]"), "g");
  3379. }
  3380. var diffs = null;
  3381. var normalizedText = text.replace(normalizationRegex, function (ch, index) {
  3382. var normalizedCh = CHARACTERS_TO_NORMALIZE[ch],
  3383. diff = normalizedCh.length - ch.length;
  3384. if (diff !== 0) {
  3385. (diffs || (diffs = [])).push([index, diff]);
  3386. }
  3387. return normalizedCh;
  3388. });
  3389. return [normalizedText, diffs];
  3390. }
  3391. function getOriginalIndex(matchIndex) {
  3392. var diffs = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  3393. if (!diffs) {
  3394. return matchIndex;
  3395. }
  3396. var totalDiff = 0;
  3397. var _iterator = _createForOfIteratorHelper(diffs),
  3398. _step;
  3399. try {
  3400. for (_iterator.s(); !(_step = _iterator.n()).done;) {
  3401. var _step$value = _slicedToArray(_step.value, 2),
  3402. index = _step$value[0],
  3403. diff = _step$value[1];
  3404. var currentIndex = index + totalDiff;
  3405. if (currentIndex >= matchIndex) {
  3406. break;
  3407. }
  3408. if (currentIndex + diff > matchIndex) {
  3409. totalDiff += matchIndex - currentIndex;
  3410. break;
  3411. }
  3412. totalDiff += diff;
  3413. }
  3414. } catch (err) {
  3415. _iterator.e(err);
  3416. } finally {
  3417. _iterator.f();
  3418. }
  3419. return matchIndex - totalDiff;
  3420. }
  3421. var PDFFindController = /*#__PURE__*/function () {
  3422. function PDFFindController(_ref) {
  3423. var linkService = _ref.linkService,
  3424. eventBus = _ref.eventBus;
  3425. _classCallCheck(this, PDFFindController);
  3426. this._linkService = linkService;
  3427. this._eventBus = eventBus;
  3428. this._reset();
  3429. eventBus._on("findbarclose", this._onFindBarClose.bind(this));
  3430. }
  3431. _createClass(PDFFindController, [{
  3432. key: "highlightMatches",
  3433. get: function get() {
  3434. return this._highlightMatches;
  3435. }
  3436. }, {
  3437. key: "pageMatches",
  3438. get: function get() {
  3439. return this._pageMatches;
  3440. }
  3441. }, {
  3442. key: "pageMatchesLength",
  3443. get: function get() {
  3444. return this._pageMatchesLength;
  3445. }
  3446. }, {
  3447. key: "selected",
  3448. get: function get() {
  3449. return this._selected;
  3450. }
  3451. }, {
  3452. key: "state",
  3453. get: function get() {
  3454. return this._state;
  3455. }
  3456. }, {
  3457. key: "setDocument",
  3458. value: function setDocument(pdfDocument) {
  3459. if (this._pdfDocument) {
  3460. this._reset();
  3461. }
  3462. if (!pdfDocument) {
  3463. return;
  3464. }
  3465. this._pdfDocument = pdfDocument;
  3466. this._firstPageCapability.resolve();
  3467. }
  3468. }, {
  3469. key: "executeCommand",
  3470. value: function executeCommand(cmd, state) {
  3471. var _this = this;
  3472. if (!state) {
  3473. return;
  3474. }
  3475. var pdfDocument = this._pdfDocument;
  3476. if (this._state === null || this._shouldDirtyMatch(cmd, state)) {
  3477. this._dirtyMatch = true;
  3478. }
  3479. this._state = state;
  3480. if (cmd !== "findhighlightallchange") {
  3481. this._updateUIState(FindState.PENDING);
  3482. }
  3483. this._firstPageCapability.promise.then(function () {
  3484. if (!_this._pdfDocument || pdfDocument && _this._pdfDocument !== pdfDocument) {
  3485. return;
  3486. }
  3487. _this._extractText();
  3488. var findbarClosed = !_this._highlightMatches;
  3489. var pendingTimeout = !!_this._findTimeout;
  3490. if (_this._findTimeout) {
  3491. clearTimeout(_this._findTimeout);
  3492. _this._findTimeout = null;
  3493. }
  3494. if (cmd === "find") {
  3495. _this._findTimeout = setTimeout(function () {
  3496. _this._nextMatch();
  3497. _this._findTimeout = null;
  3498. }, FIND_TIMEOUT);
  3499. } else if (_this._dirtyMatch) {
  3500. _this._nextMatch();
  3501. } else if (cmd === "findagain") {
  3502. _this._nextMatch();
  3503. if (findbarClosed && _this._state.highlightAll) {
  3504. _this._updateAllPages();
  3505. }
  3506. } else if (cmd === "findhighlightallchange") {
  3507. if (pendingTimeout) {
  3508. _this._nextMatch();
  3509. } else {
  3510. _this._highlightMatches = true;
  3511. }
  3512. _this._updateAllPages();
  3513. } else {
  3514. _this._nextMatch();
  3515. }
  3516. });
  3517. }
  3518. }, {
  3519. key: "scrollMatchIntoView",
  3520. value: function scrollMatchIntoView(_ref2) {
  3521. var _ref2$element = _ref2.element,
  3522. element = _ref2$element === void 0 ? null : _ref2$element,
  3523. _ref2$selectedLeft = _ref2.selectedLeft,
  3524. selectedLeft = _ref2$selectedLeft === void 0 ? 0 : _ref2$selectedLeft,
  3525. _ref2$pageIndex = _ref2.pageIndex,
  3526. pageIndex = _ref2$pageIndex === void 0 ? -1 : _ref2$pageIndex,
  3527. _ref2$matchIndex = _ref2.matchIndex,
  3528. matchIndex = _ref2$matchIndex === void 0 ? -1 : _ref2$matchIndex;
  3529. if (!this._scrollMatches || !element) {
  3530. return;
  3531. } else if (matchIndex === -1 || matchIndex !== this._selected.matchIdx) {
  3532. return;
  3533. } else if (pageIndex === -1 || pageIndex !== this._selected.pageIdx) {
  3534. return;
  3535. }
  3536. this._scrollMatches = false;
  3537. var spot = {
  3538. top: MATCH_SCROLL_OFFSET_TOP,
  3539. left: selectedLeft + MATCH_SCROLL_OFFSET_LEFT
  3540. };
  3541. (0, _ui_utils.scrollIntoView)(element, spot, true);
  3542. }
  3543. }, {
  3544. key: "_reset",
  3545. value: function _reset() {
  3546. this._highlightMatches = false;
  3547. this._scrollMatches = false;
  3548. this._pdfDocument = null;
  3549. this._pageMatches = [];
  3550. this._pageMatchesLength = [];
  3551. this._state = null;
  3552. this._selected = {
  3553. pageIdx: -1,
  3554. matchIdx: -1
  3555. };
  3556. this._offset = {
  3557. pageIdx: null,
  3558. matchIdx: null,
  3559. wrapped: false
  3560. };
  3561. this._extractTextPromises = [];
  3562. this._pageContents = [];
  3563. this._pageDiffs = [];
  3564. this._matchesCountTotal = 0;
  3565. this._pagesToSearch = null;
  3566. this._pendingFindMatches = new Set();
  3567. this._resumePageIdx = null;
  3568. this._dirtyMatch = false;
  3569. clearTimeout(this._findTimeout);
  3570. this._findTimeout = null;
  3571. this._firstPageCapability = (0, _pdfjsLib.createPromiseCapability)();
  3572. }
  3573. }, {
  3574. key: "_query",
  3575. get: function get() {
  3576. if (this._state.query !== this._rawQuery) {
  3577. this._rawQuery = this._state.query;
  3578. var _normalize = normalize(this._state.query);
  3579. var _normalize2 = _slicedToArray(_normalize, 1);
  3580. this._normalizedQuery = _normalize2[0];
  3581. }
  3582. return this._normalizedQuery;
  3583. }
  3584. }, {
  3585. key: "_shouldDirtyMatch",
  3586. value: function _shouldDirtyMatch(cmd, state) {
  3587. if (state.query !== this._state.query) {
  3588. return true;
  3589. }
  3590. switch (cmd) {
  3591. case "findagain":
  3592. var pageNumber = this._selected.pageIdx + 1;
  3593. var linkService = this._linkService;
  3594. if (pageNumber >= 1 && pageNumber <= linkService.pagesCount && pageNumber !== linkService.page && !linkService.isPageVisible(pageNumber)) {
  3595. return true;
  3596. }
  3597. return false;
  3598. case "findhighlightallchange":
  3599. return false;
  3600. }
  3601. return true;
  3602. }
  3603. }, {
  3604. key: "_prepareMatches",
  3605. value: function _prepareMatches(matchesWithLength, matches, matchesLength) {
  3606. function isSubTerm(currentIndex) {
  3607. var currentElem = matchesWithLength[currentIndex];
  3608. var nextElem = matchesWithLength[currentIndex + 1];
  3609. if (currentIndex < matchesWithLength.length - 1 && currentElem.match === nextElem.match) {
  3610. currentElem.skipped = true;
  3611. return true;
  3612. }
  3613. for (var i = currentIndex - 1; i >= 0; i--) {
  3614. var prevElem = matchesWithLength[i];
  3615. if (prevElem.skipped) {
  3616. continue;
  3617. }
  3618. if (prevElem.match + prevElem.matchLength < currentElem.match) {
  3619. break;
  3620. }
  3621. if (prevElem.match + prevElem.matchLength >= currentElem.match + currentElem.matchLength) {
  3622. currentElem.skipped = true;
  3623. return true;
  3624. }
  3625. }
  3626. return false;
  3627. }
  3628. matchesWithLength.sort(function (a, b) {
  3629. return a.match === b.match ? a.matchLength - b.matchLength : a.match - b.match;
  3630. });
  3631. for (var i = 0, len = matchesWithLength.length; i < len; i++) {
  3632. if (isSubTerm(i)) {
  3633. continue;
  3634. }
  3635. matches.push(matchesWithLength[i].match);
  3636. matchesLength.push(matchesWithLength[i].matchLength);
  3637. }
  3638. }
  3639. }, {
  3640. key: "_isEntireWord",
  3641. value: function _isEntireWord(content, startIdx, length) {
  3642. if (startIdx > 0) {
  3643. var first = content.charCodeAt(startIdx);
  3644. var limit = content.charCodeAt(startIdx - 1);
  3645. if ((0, _pdf_find_utils.getCharacterType)(first) === (0, _pdf_find_utils.getCharacterType)(limit)) {
  3646. return false;
  3647. }
  3648. }
  3649. var endIdx = startIdx + length - 1;
  3650. if (endIdx < content.length - 1) {
  3651. var last = content.charCodeAt(endIdx);
  3652. var _limit = content.charCodeAt(endIdx + 1);
  3653. if ((0, _pdf_find_utils.getCharacterType)(last) === (0, _pdf_find_utils.getCharacterType)(_limit)) {
  3654. return false;
  3655. }
  3656. }
  3657. return true;
  3658. }
  3659. }, {
  3660. key: "_calculatePhraseMatch",
  3661. value: function _calculatePhraseMatch(query, pageIndex, pageContent, pageDiffs, entireWord) {
  3662. var matches = [],
  3663. matchesLength = [];
  3664. var queryLen = query.length;
  3665. var matchIdx = -queryLen;
  3666. while (true) {
  3667. matchIdx = pageContent.indexOf(query, matchIdx + queryLen);
  3668. if (matchIdx === -1) {
  3669. break;
  3670. }
  3671. if (entireWord && !this._isEntireWord(pageContent, matchIdx, queryLen)) {
  3672. continue;
  3673. }
  3674. var originalMatchIdx = getOriginalIndex(matchIdx, pageDiffs),
  3675. matchEnd = matchIdx + queryLen - 1,
  3676. originalQueryLen = getOriginalIndex(matchEnd, pageDiffs) - originalMatchIdx + 1;
  3677. matches.push(originalMatchIdx);
  3678. matchesLength.push(originalQueryLen);
  3679. }
  3680. this._pageMatches[pageIndex] = matches;
  3681. this._pageMatchesLength[pageIndex] = matchesLength;
  3682. }
  3683. }, {
  3684. key: "_calculateWordMatch",
  3685. value: function _calculateWordMatch(query, pageIndex, pageContent, pageDiffs, entireWord) {
  3686. var matchesWithLength = [];
  3687. var queryArray = query.match(/\S+/g);
  3688. for (var i = 0, len = queryArray.length; i < len; i++) {
  3689. var subquery = queryArray[i];
  3690. var subqueryLen = subquery.length;
  3691. var matchIdx = -subqueryLen;
  3692. while (true) {
  3693. matchIdx = pageContent.indexOf(subquery, matchIdx + subqueryLen);
  3694. if (matchIdx === -1) {
  3695. break;
  3696. }
  3697. if (entireWord && !this._isEntireWord(pageContent, matchIdx, subqueryLen)) {
  3698. continue;
  3699. }
  3700. var originalMatchIdx = getOriginalIndex(matchIdx, pageDiffs),
  3701. matchEnd = matchIdx + subqueryLen - 1,
  3702. originalQueryLen = getOriginalIndex(matchEnd, pageDiffs) - originalMatchIdx + 1;
  3703. matchesWithLength.push({
  3704. match: originalMatchIdx,
  3705. matchLength: originalQueryLen,
  3706. skipped: false
  3707. });
  3708. }
  3709. }
  3710. this._pageMatchesLength[pageIndex] = [];
  3711. this._pageMatches[pageIndex] = [];
  3712. this._prepareMatches(matchesWithLength, this._pageMatches[pageIndex], this._pageMatchesLength[pageIndex]);
  3713. }
  3714. }, {
  3715. key: "_calculateMatch",
  3716. value: function _calculateMatch(pageIndex) {
  3717. var pageContent = this._pageContents[pageIndex];
  3718. var pageDiffs = this._pageDiffs[pageIndex];
  3719. var query = this._query;
  3720. var _this$_state = this._state,
  3721. caseSensitive = _this$_state.caseSensitive,
  3722. entireWord = _this$_state.entireWord,
  3723. phraseSearch = _this$_state.phraseSearch;
  3724. if (query.length === 0) {
  3725. return;
  3726. }
  3727. if (!caseSensitive) {
  3728. pageContent = pageContent.toLowerCase();
  3729. query = query.toLowerCase();
  3730. }
  3731. if (phraseSearch) {
  3732. this._calculatePhraseMatch(query, pageIndex, pageContent, pageDiffs, entireWord);
  3733. } else {
  3734. this._calculateWordMatch(query, pageIndex, pageContent, pageDiffs, entireWord);
  3735. }
  3736. if (this._state.highlightAll) {
  3737. this._updatePage(pageIndex);
  3738. }
  3739. if (this._resumePageIdx === pageIndex) {
  3740. this._resumePageIdx = null;
  3741. this._nextPageMatch();
  3742. }
  3743. var pageMatchesCount = this._pageMatches[pageIndex].length;
  3744. if (pageMatchesCount > 0) {
  3745. this._matchesCountTotal += pageMatchesCount;
  3746. this._updateUIResultsCount();
  3747. }
  3748. }
  3749. }, {
  3750. key: "_extractText",
  3751. value: function _extractText() {
  3752. var _this2 = this;
  3753. if (this._extractTextPromises.length > 0) {
  3754. return;
  3755. }
  3756. var promise = Promise.resolve();
  3757. var _loop = function _loop(i, ii) {
  3758. var extractTextCapability = (0, _pdfjsLib.createPromiseCapability)();
  3759. _this2._extractTextPromises[i] = extractTextCapability.promise;
  3760. promise = promise.then(function () {
  3761. return _this2._pdfDocument.getPage(i + 1).then(function (pdfPage) {
  3762. return pdfPage.getTextContent({
  3763. normalizeWhitespace: true
  3764. });
  3765. }).then(function (textContent) {
  3766. var textItems = textContent.items;
  3767. var strBuf = [];
  3768. for (var j = 0, jj = textItems.length; j < jj; j++) {
  3769. strBuf.push(textItems[j].str);
  3770. }
  3771. var _normalize3 = normalize(strBuf.join(""));
  3772. var _normalize4 = _slicedToArray(_normalize3, 2);
  3773. _this2._pageContents[i] = _normalize4[0];
  3774. _this2._pageDiffs[i] = _normalize4[1];
  3775. extractTextCapability.resolve(i);
  3776. }, function (reason) {
  3777. console.error("Unable to get text content for page ".concat(i + 1), reason);
  3778. _this2._pageContents[i] = "";
  3779. _this2._pageDiffs[i] = null;
  3780. extractTextCapability.resolve(i);
  3781. });
  3782. });
  3783. };
  3784. for (var i = 0, ii = this._linkService.pagesCount; i < ii; i++) {
  3785. _loop(i, ii);
  3786. }
  3787. }
  3788. }, {
  3789. key: "_updatePage",
  3790. value: function _updatePage(index) {
  3791. if (this._scrollMatches && this._selected.pageIdx === index) {
  3792. this._linkService.page = index + 1;
  3793. }
  3794. this._eventBus.dispatch("updatetextlayermatches", {
  3795. source: this,
  3796. pageIndex: index
  3797. });
  3798. }
  3799. }, {
  3800. key: "_updateAllPages",
  3801. value: function _updateAllPages() {
  3802. this._eventBus.dispatch("updatetextlayermatches", {
  3803. source: this,
  3804. pageIndex: -1
  3805. });
  3806. }
  3807. }, {
  3808. key: "_nextMatch",
  3809. value: function _nextMatch() {
  3810. var _this3 = this;
  3811. var previous = this._state.findPrevious;
  3812. var currentPageIndex = this._linkService.page - 1;
  3813. var numPages = this._linkService.pagesCount;
  3814. this._highlightMatches = true;
  3815. if (this._dirtyMatch) {
  3816. this._dirtyMatch = false;
  3817. this._selected.pageIdx = this._selected.matchIdx = -1;
  3818. this._offset.pageIdx = currentPageIndex;
  3819. this._offset.matchIdx = null;
  3820. this._offset.wrapped = false;
  3821. this._resumePageIdx = null;
  3822. this._pageMatches.length = 0;
  3823. this._pageMatchesLength.length = 0;
  3824. this._matchesCountTotal = 0;
  3825. this._updateAllPages();
  3826. for (var i = 0; i < numPages; i++) {
  3827. if (this._pendingFindMatches.has(i)) {
  3828. continue;
  3829. }
  3830. this._pendingFindMatches.add(i);
  3831. this._extractTextPromises[i].then(function (pageIdx) {
  3832. _this3._pendingFindMatches["delete"](pageIdx);
  3833. _this3._calculateMatch(pageIdx);
  3834. });
  3835. }
  3836. }
  3837. if (this._query === "") {
  3838. this._updateUIState(FindState.FOUND);
  3839. return;
  3840. }
  3841. if (this._resumePageIdx) {
  3842. return;
  3843. }
  3844. var offset = this._offset;
  3845. this._pagesToSearch = numPages;
  3846. if (offset.matchIdx !== null) {
  3847. var numPageMatches = this._pageMatches[offset.pageIdx].length;
  3848. if (!previous && offset.matchIdx + 1 < numPageMatches || previous && offset.matchIdx > 0) {
  3849. offset.matchIdx = previous ? offset.matchIdx - 1 : offset.matchIdx + 1;
  3850. this._updateMatch(true);
  3851. return;
  3852. }
  3853. this._advanceOffsetPage(previous);
  3854. }
  3855. this._nextPageMatch();
  3856. }
  3857. }, {
  3858. key: "_matchesReady",
  3859. value: function _matchesReady(matches) {
  3860. var offset = this._offset;
  3861. var numMatches = matches.length;
  3862. var previous = this._state.findPrevious;
  3863. if (numMatches) {
  3864. offset.matchIdx = previous ? numMatches - 1 : 0;
  3865. this._updateMatch(true);
  3866. return true;
  3867. }
  3868. this._advanceOffsetPage(previous);
  3869. if (offset.wrapped) {
  3870. offset.matchIdx = null;
  3871. if (this._pagesToSearch < 0) {
  3872. this._updateMatch(false);
  3873. return true;
  3874. }
  3875. }
  3876. return false;
  3877. }
  3878. }, {
  3879. key: "_nextPageMatch",
  3880. value: function _nextPageMatch() {
  3881. if (this._resumePageIdx !== null) {
  3882. console.error("There can only be one pending page.");
  3883. }
  3884. var matches = null;
  3885. do {
  3886. var pageIdx = this._offset.pageIdx;
  3887. matches = this._pageMatches[pageIdx];
  3888. if (!matches) {
  3889. this._resumePageIdx = pageIdx;
  3890. break;
  3891. }
  3892. } while (!this._matchesReady(matches));
  3893. }
  3894. }, {
  3895. key: "_advanceOffsetPage",
  3896. value: function _advanceOffsetPage(previous) {
  3897. var offset = this._offset;
  3898. var numPages = this._linkService.pagesCount;
  3899. offset.pageIdx = previous ? offset.pageIdx - 1 : offset.pageIdx + 1;
  3900. offset.matchIdx = null;
  3901. this._pagesToSearch--;
  3902. if (offset.pageIdx >= numPages || offset.pageIdx < 0) {
  3903. offset.pageIdx = previous ? numPages - 1 : 0;
  3904. offset.wrapped = true;
  3905. }
  3906. }
  3907. }, {
  3908. key: "_updateMatch",
  3909. value: function _updateMatch() {
  3910. var found = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  3911. var state = FindState.NOT_FOUND;
  3912. var wrapped = this._offset.wrapped;
  3913. this._offset.wrapped = false;
  3914. if (found) {
  3915. var previousPage = this._selected.pageIdx;
  3916. this._selected.pageIdx = this._offset.pageIdx;
  3917. this._selected.matchIdx = this._offset.matchIdx;
  3918. state = wrapped ? FindState.WRAPPED : FindState.FOUND;
  3919. if (previousPage !== -1 && previousPage !== this._selected.pageIdx) {
  3920. this._updatePage(previousPage);
  3921. }
  3922. }
  3923. this._updateUIState(state, this._state.findPrevious);
  3924. if (this._selected.pageIdx !== -1) {
  3925. this._scrollMatches = true;
  3926. this._updatePage(this._selected.pageIdx);
  3927. }
  3928. }
  3929. }, {
  3930. key: "_onFindBarClose",
  3931. value: function _onFindBarClose(evt) {
  3932. var _this4 = this;
  3933. var pdfDocument = this._pdfDocument;
  3934. this._firstPageCapability.promise.then(function () {
  3935. if (!_this4._pdfDocument || pdfDocument && _this4._pdfDocument !== pdfDocument) {
  3936. return;
  3937. }
  3938. if (_this4._findTimeout) {
  3939. clearTimeout(_this4._findTimeout);
  3940. _this4._findTimeout = null;
  3941. }
  3942. if (_this4._resumePageIdx) {
  3943. _this4._resumePageIdx = null;
  3944. _this4._dirtyMatch = true;
  3945. }
  3946. _this4._updateUIState(FindState.FOUND);
  3947. _this4._highlightMatches = false;
  3948. _this4._updateAllPages();
  3949. });
  3950. }
  3951. }, {
  3952. key: "_requestMatchesCount",
  3953. value: function _requestMatchesCount() {
  3954. var _this$_selected = this._selected,
  3955. pageIdx = _this$_selected.pageIdx,
  3956. matchIdx = _this$_selected.matchIdx;
  3957. var current = 0,
  3958. total = this._matchesCountTotal;
  3959. if (matchIdx !== -1) {
  3960. for (var i = 0; i < pageIdx; i++) {
  3961. var _this$_pageMatches$i;
  3962. current += ((_this$_pageMatches$i = this._pageMatches[i]) === null || _this$_pageMatches$i === void 0 ? void 0 : _this$_pageMatches$i.length) || 0;
  3963. }
  3964. current += matchIdx + 1;
  3965. }
  3966. if (current < 1 || current > total) {
  3967. current = total = 0;
  3968. }
  3969. return {
  3970. current: current,
  3971. total: total
  3972. };
  3973. }
  3974. }, {
  3975. key: "_updateUIResultsCount",
  3976. value: function _updateUIResultsCount() {
  3977. this._eventBus.dispatch("updatefindmatchescount", {
  3978. source: this,
  3979. matchesCount: this._requestMatchesCount()
  3980. });
  3981. }
  3982. }, {
  3983. key: "_updateUIState",
  3984. value: function _updateUIState(state, previous) {
  3985. var _this$_state$query, _this$_state2;
  3986. this._eventBus.dispatch("updatefindcontrolstate", {
  3987. source: this,
  3988. state: state,
  3989. previous: previous,
  3990. matchesCount: this._requestMatchesCount(),
  3991. rawQuery: (_this$_state$query = (_this$_state2 = this._state) === null || _this$_state2 === void 0 ? void 0 : _this$_state2.query) !== null && _this$_state$query !== void 0 ? _this$_state$query : null
  3992. });
  3993. }
  3994. }]);
  3995. return PDFFindController;
  3996. }();
  3997. exports.PDFFindController = PDFFindController;
  3998. /***/ }),
  3999. /* 14 */
  4000. /***/ ((__unused_webpack_module, exports) => {
  4001. Object.defineProperty(exports, "__esModule", ({
  4002. value: true
  4003. }));
  4004. exports.getCharacterType = getCharacterType;
  4005. exports.CharacterType = void 0;
  4006. var CharacterType = {
  4007. SPACE: 0,
  4008. ALPHA_LETTER: 1,
  4009. PUNCT: 2,
  4010. HAN_LETTER: 3,
  4011. KATAKANA_LETTER: 4,
  4012. HIRAGANA_LETTER: 5,
  4013. HALFWIDTH_KATAKANA_LETTER: 6,
  4014. THAI_LETTER: 7
  4015. };
  4016. exports.CharacterType = CharacterType;
  4017. function isAlphabeticalScript(charCode) {
  4018. return charCode < 0x2e80;
  4019. }
  4020. function isAscii(charCode) {
  4021. return (charCode & 0xff80) === 0;
  4022. }
  4023. function isAsciiAlpha(charCode) {
  4024. return charCode >= 0x61 && charCode <= 0x7a || charCode >= 0x41 && charCode <= 0x5a;
  4025. }
  4026. function isAsciiDigit(charCode) {
  4027. return charCode >= 0x30 && charCode <= 0x39;
  4028. }
  4029. function isAsciiSpace(charCode) {
  4030. return charCode === 0x20 || charCode === 0x09 || charCode === 0x0d || charCode === 0x0a;
  4031. }
  4032. function isHan(charCode) {
  4033. return charCode >= 0x3400 && charCode <= 0x9fff || charCode >= 0xf900 && charCode <= 0xfaff;
  4034. }
  4035. function isKatakana(charCode) {
  4036. return charCode >= 0x30a0 && charCode <= 0x30ff;
  4037. }
  4038. function isHiragana(charCode) {
  4039. return charCode >= 0x3040 && charCode <= 0x309f;
  4040. }
  4041. function isHalfwidthKatakana(charCode) {
  4042. return charCode >= 0xff60 && charCode <= 0xff9f;
  4043. }
  4044. function isThai(charCode) {
  4045. return (charCode & 0xff80) === 0x0e00;
  4046. }
  4047. function getCharacterType(charCode) {
  4048. if (isAlphabeticalScript(charCode)) {
  4049. if (isAscii(charCode)) {
  4050. if (isAsciiSpace(charCode)) {
  4051. return CharacterType.SPACE;
  4052. } else if (isAsciiAlpha(charCode) || isAsciiDigit(charCode) || charCode === 0x5f) {
  4053. return CharacterType.ALPHA_LETTER;
  4054. }
  4055. return CharacterType.PUNCT;
  4056. } else if (isThai(charCode)) {
  4057. return CharacterType.THAI_LETTER;
  4058. } else if (charCode === 0xa0) {
  4059. return CharacterType.SPACE;
  4060. }
  4061. return CharacterType.ALPHA_LETTER;
  4062. }
  4063. if (isHan(charCode)) {
  4064. return CharacterType.HAN_LETTER;
  4065. } else if (isKatakana(charCode)) {
  4066. return CharacterType.KATAKANA_LETTER;
  4067. } else if (isHiragana(charCode)) {
  4068. return CharacterType.HIRAGANA_LETTER;
  4069. } else if (isHalfwidthKatakana(charCode)) {
  4070. return CharacterType.HALFWIDTH_KATAKANA_LETTER;
  4071. }
  4072. return CharacterType.ALPHA_LETTER;
  4073. }
  4074. /***/ }),
  4075. /* 15 */
  4076. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  4077. Object.defineProperty(exports, "__esModule", ({
  4078. value: true
  4079. }));
  4080. exports.isDestArraysEqual = isDestArraysEqual;
  4081. exports.isDestHashesEqual = isDestHashesEqual;
  4082. exports.PDFHistory = void 0;
  4083. var _ui_utils = __w_pdfjs_require__(7);
  4084. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  4085. function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
  4086. function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
  4087. function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
  4088. function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
  4089. function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
  4090. function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
  4091. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  4092. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  4093. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  4094. var HASH_CHANGE_TIMEOUT = 1000;
  4095. var POSITION_UPDATED_THRESHOLD = 50;
  4096. var UPDATE_VIEWAREA_TIMEOUT = 1000;
  4097. function getCurrentHash() {
  4098. return document.location.hash;
  4099. }
  4100. var PDFHistory = /*#__PURE__*/function () {
  4101. function PDFHistory(_ref) {
  4102. var _this = this;
  4103. var linkService = _ref.linkService,
  4104. eventBus = _ref.eventBus;
  4105. _classCallCheck(this, PDFHistory);
  4106. this.linkService = linkService;
  4107. this.eventBus = eventBus;
  4108. this._initialized = false;
  4109. this._fingerprint = "";
  4110. this.reset();
  4111. this._boundEvents = null;
  4112. this._isViewerInPresentationMode = false;
  4113. this.eventBus._on("presentationmodechanged", function (evt) {
  4114. _this._isViewerInPresentationMode = evt.state !== _ui_utils.PresentationModeState.NORMAL;
  4115. });
  4116. this.eventBus._on("pagesinit", function () {
  4117. _this._isPagesLoaded = false;
  4118. _this.eventBus._on("pagesloaded", function (evt) {
  4119. _this._isPagesLoaded = !!evt.pagesCount;
  4120. }, {
  4121. once: true
  4122. });
  4123. });
  4124. }
  4125. _createClass(PDFHistory, [{
  4126. key: "initialize",
  4127. value: function initialize(_ref2) {
  4128. var fingerprint = _ref2.fingerprint,
  4129. _ref2$resetHistory = _ref2.resetHistory,
  4130. resetHistory = _ref2$resetHistory === void 0 ? false : _ref2$resetHistory,
  4131. _ref2$updateUrl = _ref2.updateUrl,
  4132. updateUrl = _ref2$updateUrl === void 0 ? false : _ref2$updateUrl;
  4133. if (!fingerprint || typeof fingerprint !== "string") {
  4134. console.error('PDFHistory.initialize: The "fingerprint" must be a non-empty string.');
  4135. return;
  4136. }
  4137. if (this._initialized) {
  4138. this.reset();
  4139. }
  4140. var reInitialized = this._fingerprint !== "" && this._fingerprint !== fingerprint;
  4141. this._fingerprint = fingerprint;
  4142. this._updateUrl = updateUrl === true;
  4143. this._initialized = true;
  4144. this._bindEvents();
  4145. var state = window.history.state;
  4146. this._popStateInProgress = false;
  4147. this._blockHashChange = 0;
  4148. this._currentHash = getCurrentHash();
  4149. this._numPositionUpdates = 0;
  4150. this._uid = this._maxUid = 0;
  4151. this._destination = null;
  4152. this._position = null;
  4153. if (!this._isValidState(state, true) || resetHistory) {
  4154. var _this$_parseCurrentHa = this._parseCurrentHash(true),
  4155. hash = _this$_parseCurrentHa.hash,
  4156. page = _this$_parseCurrentHa.page,
  4157. rotation = _this$_parseCurrentHa.rotation;
  4158. if (!hash || reInitialized || resetHistory) {
  4159. this._pushOrReplaceState(null, true);
  4160. return;
  4161. }
  4162. this._pushOrReplaceState({
  4163. hash: hash,
  4164. page: page,
  4165. rotation: rotation
  4166. }, true);
  4167. return;
  4168. }
  4169. var destination = state.destination;
  4170. this._updateInternalState(destination, state.uid, true);
  4171. if (destination.rotation !== undefined) {
  4172. this._initialRotation = destination.rotation;
  4173. }
  4174. if (destination.dest) {
  4175. this._initialBookmark = JSON.stringify(destination.dest);
  4176. this._destination.page = null;
  4177. } else if (destination.hash) {
  4178. this._initialBookmark = destination.hash;
  4179. } else if (destination.page) {
  4180. this._initialBookmark = "page=".concat(destination.page);
  4181. }
  4182. }
  4183. }, {
  4184. key: "reset",
  4185. value: function reset() {
  4186. if (this._initialized) {
  4187. this._pageHide();
  4188. this._initialized = false;
  4189. this._unbindEvents();
  4190. }
  4191. if (this._updateViewareaTimeout) {
  4192. clearTimeout(this._updateViewareaTimeout);
  4193. this._updateViewareaTimeout = null;
  4194. }
  4195. this._initialBookmark = null;
  4196. this._initialRotation = null;
  4197. }
  4198. }, {
  4199. key: "push",
  4200. value: function push(_ref3) {
  4201. var _this2 = this;
  4202. var _ref3$namedDest = _ref3.namedDest,
  4203. namedDest = _ref3$namedDest === void 0 ? null : _ref3$namedDest,
  4204. explicitDest = _ref3.explicitDest,
  4205. pageNumber = _ref3.pageNumber;
  4206. if (!this._initialized) {
  4207. return;
  4208. }
  4209. if (namedDest && typeof namedDest !== "string") {
  4210. console.error("PDFHistory.push: " + "\"".concat(namedDest, "\" is not a valid namedDest parameter."));
  4211. return;
  4212. } else if (!Array.isArray(explicitDest)) {
  4213. console.error("PDFHistory.push: " + "\"".concat(explicitDest, "\" is not a valid explicitDest parameter."));
  4214. return;
  4215. } else if (!this._isValidPage(pageNumber)) {
  4216. if (pageNumber !== null || this._destination) {
  4217. console.error("PDFHistory.push: " + "\"".concat(pageNumber, "\" is not a valid pageNumber parameter."));
  4218. return;
  4219. }
  4220. }
  4221. var hash = namedDest || JSON.stringify(explicitDest);
  4222. if (!hash) {
  4223. return;
  4224. }
  4225. var forceReplace = false;
  4226. if (this._destination && (isDestHashesEqual(this._destination.hash, hash) || isDestArraysEqual(this._destination.dest, explicitDest))) {
  4227. if (this._destination.page) {
  4228. return;
  4229. }
  4230. forceReplace = true;
  4231. }
  4232. if (this._popStateInProgress && !forceReplace) {
  4233. return;
  4234. }
  4235. this._pushOrReplaceState({
  4236. dest: explicitDest,
  4237. hash: hash,
  4238. page: pageNumber,
  4239. rotation: this.linkService.rotation
  4240. }, forceReplace);
  4241. if (!this._popStateInProgress) {
  4242. this._popStateInProgress = true;
  4243. Promise.resolve().then(function () {
  4244. _this2._popStateInProgress = false;
  4245. });
  4246. }
  4247. }
  4248. }, {
  4249. key: "pushPage",
  4250. value: function pushPage(pageNumber) {
  4251. var _this$_destination,
  4252. _this3 = this;
  4253. if (!this._initialized) {
  4254. return;
  4255. }
  4256. if (!this._isValidPage(pageNumber)) {
  4257. console.error("PDFHistory.pushPage: \"".concat(pageNumber, "\" is not a valid page number."));
  4258. return;
  4259. }
  4260. if (((_this$_destination = this._destination) === null || _this$_destination === void 0 ? void 0 : _this$_destination.page) === pageNumber) {
  4261. return;
  4262. }
  4263. if (this._popStateInProgress) {
  4264. return;
  4265. }
  4266. this._pushOrReplaceState({
  4267. dest: null,
  4268. hash: "page=".concat(pageNumber),
  4269. page: pageNumber,
  4270. rotation: this.linkService.rotation
  4271. });
  4272. if (!this._popStateInProgress) {
  4273. this._popStateInProgress = true;
  4274. Promise.resolve().then(function () {
  4275. _this3._popStateInProgress = false;
  4276. });
  4277. }
  4278. }
  4279. }, {
  4280. key: "pushCurrentPosition",
  4281. value: function pushCurrentPosition() {
  4282. if (!this._initialized || this._popStateInProgress) {
  4283. return;
  4284. }
  4285. this._tryPushCurrentPosition();
  4286. }
  4287. }, {
  4288. key: "back",
  4289. value: function back() {
  4290. if (!this._initialized || this._popStateInProgress) {
  4291. return;
  4292. }
  4293. var state = window.history.state;
  4294. if (this._isValidState(state) && state.uid > 0) {
  4295. window.history.back();
  4296. }
  4297. }
  4298. }, {
  4299. key: "forward",
  4300. value: function forward() {
  4301. if (!this._initialized || this._popStateInProgress) {
  4302. return;
  4303. }
  4304. var state = window.history.state;
  4305. if (this._isValidState(state) && state.uid < this._maxUid) {
  4306. window.history.forward();
  4307. }
  4308. }
  4309. }, {
  4310. key: "popStateInProgress",
  4311. get: function get() {
  4312. return this._initialized && (this._popStateInProgress || this._blockHashChange > 0);
  4313. }
  4314. }, {
  4315. key: "initialBookmark",
  4316. get: function get() {
  4317. return this._initialized ? this._initialBookmark : null;
  4318. }
  4319. }, {
  4320. key: "initialRotation",
  4321. get: function get() {
  4322. return this._initialized ? this._initialRotation : null;
  4323. }
  4324. }, {
  4325. key: "_pushOrReplaceState",
  4326. value: function _pushOrReplaceState(destination) {
  4327. var forceReplace = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  4328. var shouldReplace = forceReplace || !this._destination;
  4329. var newState = {
  4330. fingerprint: this._fingerprint,
  4331. uid: shouldReplace ? this._uid : this._uid + 1,
  4332. destination: destination
  4333. };
  4334. this._updateInternalState(destination, newState.uid);
  4335. var newUrl;
  4336. if (this._updateUrl && destination !== null && destination !== void 0 && destination.hash) {
  4337. var baseUrl = document.location.href.split("#")[0];
  4338. if (!baseUrl.startsWith("file://")) {
  4339. newUrl = "".concat(baseUrl, "#").concat(destination.hash);
  4340. }
  4341. }
  4342. if (shouldReplace) {
  4343. window.history.replaceState(newState, "", newUrl);
  4344. } else {
  4345. window.history.pushState(newState, "", newUrl);
  4346. }
  4347. }
  4348. }, {
  4349. key: "_tryPushCurrentPosition",
  4350. value: function _tryPushCurrentPosition() {
  4351. var temporary = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  4352. if (!this._position) {
  4353. return;
  4354. }
  4355. var position = this._position;
  4356. if (temporary) {
  4357. position = Object.assign(Object.create(null), this._position);
  4358. position.temporary = true;
  4359. }
  4360. if (!this._destination) {
  4361. this._pushOrReplaceState(position);
  4362. return;
  4363. }
  4364. if (this._destination.temporary) {
  4365. this._pushOrReplaceState(position, true);
  4366. return;
  4367. }
  4368. if (this._destination.hash === position.hash) {
  4369. return;
  4370. }
  4371. if (!this._destination.page && (POSITION_UPDATED_THRESHOLD <= 0 || this._numPositionUpdates <= POSITION_UPDATED_THRESHOLD)) {
  4372. return;
  4373. }
  4374. var forceReplace = false;
  4375. if (this._destination.page >= position.first && this._destination.page <= position.page) {
  4376. if (this._destination.dest !== undefined || !this._destination.first) {
  4377. return;
  4378. }
  4379. forceReplace = true;
  4380. }
  4381. this._pushOrReplaceState(position, forceReplace);
  4382. }
  4383. }, {
  4384. key: "_isValidPage",
  4385. value: function _isValidPage(val) {
  4386. return Number.isInteger(val) && val > 0 && val <= this.linkService.pagesCount;
  4387. }
  4388. }, {
  4389. key: "_isValidState",
  4390. value: function _isValidState(state) {
  4391. var checkReload = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  4392. if (!state) {
  4393. return false;
  4394. }
  4395. if (state.fingerprint !== this._fingerprint) {
  4396. if (checkReload) {
  4397. if (typeof state.fingerprint !== "string" || state.fingerprint.length !== this._fingerprint.length) {
  4398. return false;
  4399. }
  4400. var _performance$getEntri = performance.getEntriesByType("navigation"),
  4401. _performance$getEntri2 = _slicedToArray(_performance$getEntri, 1),
  4402. perfEntry = _performance$getEntri2[0];
  4403. if ((perfEntry === null || perfEntry === void 0 ? void 0 : perfEntry.type) !== "reload") {
  4404. return false;
  4405. }
  4406. } else {
  4407. return false;
  4408. }
  4409. }
  4410. if (!Number.isInteger(state.uid) || state.uid < 0) {
  4411. return false;
  4412. }
  4413. if (state.destination === null || _typeof(state.destination) !== "object") {
  4414. return false;
  4415. }
  4416. return true;
  4417. }
  4418. }, {
  4419. key: "_updateInternalState",
  4420. value: function _updateInternalState(destination, uid) {
  4421. var removeTemporary = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  4422. if (this._updateViewareaTimeout) {
  4423. clearTimeout(this._updateViewareaTimeout);
  4424. this._updateViewareaTimeout = null;
  4425. }
  4426. if (removeTemporary && destination !== null && destination !== void 0 && destination.temporary) {
  4427. delete destination.temporary;
  4428. }
  4429. this._destination = destination;
  4430. this._uid = uid;
  4431. this._maxUid = Math.max(this._maxUid, uid);
  4432. this._numPositionUpdates = 0;
  4433. }
  4434. }, {
  4435. key: "_parseCurrentHash",
  4436. value: function _parseCurrentHash() {
  4437. var checkNameddest = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  4438. var hash = unescape(getCurrentHash()).substring(1);
  4439. var params = (0, _ui_utils.parseQueryString)(hash);
  4440. var nameddest = params.nameddest || "";
  4441. var page = params.page | 0;
  4442. if (!this._isValidPage(page) || checkNameddest && nameddest.length > 0) {
  4443. page = null;
  4444. }
  4445. return {
  4446. hash: hash,
  4447. page: page,
  4448. rotation: this.linkService.rotation
  4449. };
  4450. }
  4451. }, {
  4452. key: "_updateViewarea",
  4453. value: function _updateViewarea(_ref4) {
  4454. var _this4 = this;
  4455. var location = _ref4.location;
  4456. if (this._updateViewareaTimeout) {
  4457. clearTimeout(this._updateViewareaTimeout);
  4458. this._updateViewareaTimeout = null;
  4459. }
  4460. this._position = {
  4461. hash: this._isViewerInPresentationMode ? "page=".concat(location.pageNumber) : location.pdfOpenParams.substring(1),
  4462. page: this.linkService.page,
  4463. first: location.pageNumber,
  4464. rotation: location.rotation
  4465. };
  4466. if (this._popStateInProgress) {
  4467. return;
  4468. }
  4469. if (POSITION_UPDATED_THRESHOLD > 0 && this._isPagesLoaded && this._destination && !this._destination.page) {
  4470. this._numPositionUpdates++;
  4471. }
  4472. if (UPDATE_VIEWAREA_TIMEOUT > 0) {
  4473. this._updateViewareaTimeout = setTimeout(function () {
  4474. if (!_this4._popStateInProgress) {
  4475. _this4._tryPushCurrentPosition(true);
  4476. }
  4477. _this4._updateViewareaTimeout = null;
  4478. }, UPDATE_VIEWAREA_TIMEOUT);
  4479. }
  4480. }
  4481. }, {
  4482. key: "_popState",
  4483. value: function _popState(_ref5) {
  4484. var _this5 = this;
  4485. var state = _ref5.state;
  4486. var newHash = getCurrentHash(),
  4487. hashChanged = this._currentHash !== newHash;
  4488. this._currentHash = newHash;
  4489. if (!state) {
  4490. this._uid++;
  4491. var _this$_parseCurrentHa2 = this._parseCurrentHash(),
  4492. hash = _this$_parseCurrentHa2.hash,
  4493. page = _this$_parseCurrentHa2.page,
  4494. rotation = _this$_parseCurrentHa2.rotation;
  4495. this._pushOrReplaceState({
  4496. hash: hash,
  4497. page: page,
  4498. rotation: rotation
  4499. }, true);
  4500. return;
  4501. }
  4502. if (!this._isValidState(state)) {
  4503. return;
  4504. }
  4505. this._popStateInProgress = true;
  4506. if (hashChanged) {
  4507. this._blockHashChange++;
  4508. (0, _ui_utils.waitOnEventOrTimeout)({
  4509. target: window,
  4510. name: "hashchange",
  4511. delay: HASH_CHANGE_TIMEOUT
  4512. }).then(function () {
  4513. _this5._blockHashChange--;
  4514. });
  4515. }
  4516. var destination = state.destination;
  4517. this._updateInternalState(destination, state.uid, true);
  4518. if ((0, _ui_utils.isValidRotation)(destination.rotation)) {
  4519. this.linkService.rotation = destination.rotation;
  4520. }
  4521. if (destination.dest) {
  4522. this.linkService.goToDestination(destination.dest);
  4523. } else if (destination.hash) {
  4524. this.linkService.setHash(destination.hash);
  4525. } else if (destination.page) {
  4526. this.linkService.page = destination.page;
  4527. }
  4528. Promise.resolve().then(function () {
  4529. _this5._popStateInProgress = false;
  4530. });
  4531. }
  4532. }, {
  4533. key: "_pageHide",
  4534. value: function _pageHide() {
  4535. if (!this._destination || this._destination.temporary) {
  4536. this._tryPushCurrentPosition();
  4537. }
  4538. }
  4539. }, {
  4540. key: "_bindEvents",
  4541. value: function _bindEvents() {
  4542. if (this._boundEvents) {
  4543. return;
  4544. }
  4545. this._boundEvents = {
  4546. updateViewarea: this._updateViewarea.bind(this),
  4547. popState: this._popState.bind(this),
  4548. pageHide: this._pageHide.bind(this)
  4549. };
  4550. this.eventBus._on("updateviewarea", this._boundEvents.updateViewarea);
  4551. window.addEventListener("popstate", this._boundEvents.popState);
  4552. window.addEventListener("pagehide", this._boundEvents.pageHide);
  4553. }
  4554. }, {
  4555. key: "_unbindEvents",
  4556. value: function _unbindEvents() {
  4557. if (!this._boundEvents) {
  4558. return;
  4559. }
  4560. this.eventBus._off("updateviewarea", this._boundEvents.updateViewarea);
  4561. window.removeEventListener("popstate", this._boundEvents.popState);
  4562. window.removeEventListener("pagehide", this._boundEvents.pageHide);
  4563. this._boundEvents = null;
  4564. }
  4565. }]);
  4566. return PDFHistory;
  4567. }();
  4568. exports.PDFHistory = PDFHistory;
  4569. function isDestHashesEqual(destHash, pushHash) {
  4570. if (typeof destHash !== "string" || typeof pushHash !== "string") {
  4571. return false;
  4572. }
  4573. if (destHash === pushHash) {
  4574. return true;
  4575. }
  4576. var _parseQueryString = (0, _ui_utils.parseQueryString)(destHash),
  4577. nameddest = _parseQueryString.nameddest;
  4578. if (nameddest === pushHash) {
  4579. return true;
  4580. }
  4581. return false;
  4582. }
  4583. function isDestArraysEqual(firstDest, secondDest) {
  4584. function isEntryEqual(first, second) {
  4585. if (_typeof(first) !== _typeof(second)) {
  4586. return false;
  4587. }
  4588. if (Array.isArray(first) || Array.isArray(second)) {
  4589. return false;
  4590. }
  4591. if (first !== null && _typeof(first) === "object" && second !== null) {
  4592. if (Object.keys(first).length !== Object.keys(second).length) {
  4593. return false;
  4594. }
  4595. for (var key in first) {
  4596. if (!isEntryEqual(first[key], second[key])) {
  4597. return false;
  4598. }
  4599. }
  4600. return true;
  4601. }
  4602. return first === second || Number.isNaN(first) && Number.isNaN(second);
  4603. }
  4604. if (!(Array.isArray(firstDest) && Array.isArray(secondDest))) {
  4605. return false;
  4606. }
  4607. if (firstDest.length !== secondDest.length) {
  4608. return false;
  4609. }
  4610. for (var i = 0, ii = firstDest.length; i < ii; i++) {
  4611. if (!isEntryEqual(firstDest[i], secondDest[i])) {
  4612. return false;
  4613. }
  4614. }
  4615. return true;
  4616. }
  4617. /***/ }),
  4618. /* 16 */
  4619. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  4620. Object.defineProperty(exports, "__esModule", ({
  4621. value: true
  4622. }));
  4623. exports.PDFPageView = void 0;
  4624. var _regenerator = _interopRequireDefault(__w_pdfjs_require__(4));
  4625. var _ui_utils = __w_pdfjs_require__(7);
  4626. var _pdfjsLib = __w_pdfjs_require__(2);
  4627. var _l10n_utils = __w_pdfjs_require__(3);
  4628. var _pdf_rendering_queue = __w_pdfjs_require__(17);
  4629. var _viewer_compatibility = __w_pdfjs_require__(10);
  4630. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  4631. function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
  4632. function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
  4633. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  4634. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  4635. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  4636. var MAX_CANVAS_PIXELS = _viewer_compatibility.viewerCompatibilityParams.maxCanvasPixels || 16777216;
  4637. var PDFPageView = /*#__PURE__*/function () {
  4638. function PDFPageView(options) {
  4639. _classCallCheck(this, PDFPageView);
  4640. var container = options.container;
  4641. var defaultViewport = options.defaultViewport;
  4642. this.id = options.id;
  4643. this.renderingId = "page" + this.id;
  4644. this.pdfPage = null;
  4645. this.pageLabel = null;
  4646. this.rotation = 0;
  4647. this.scale = options.scale || _ui_utils.DEFAULT_SCALE;
  4648. this.viewport = defaultViewport;
  4649. this.pdfPageRotate = defaultViewport.rotation;
  4650. this._optionalContentConfigPromise = options.optionalContentConfigPromise || null;
  4651. this.hasRestrictedScaling = false;
  4652. this.textLayerMode = Number.isInteger(options.textLayerMode) ? options.textLayerMode : _ui_utils.TextLayerMode.ENABLE;
  4653. this.imageResourcesPath = options.imageResourcesPath || "";
  4654. this.renderInteractiveForms = options.renderInteractiveForms !== false;
  4655. this.useOnlyCssZoom = options.useOnlyCssZoom || false;
  4656. this.maxCanvasPixels = options.maxCanvasPixels || MAX_CANVAS_PIXELS;
  4657. this.eventBus = options.eventBus;
  4658. this.renderingQueue = options.renderingQueue;
  4659. this.textLayerFactory = options.textLayerFactory;
  4660. this.annotationLayerFactory = options.annotationLayerFactory;
  4661. this.xfaLayerFactory = options.xfaLayerFactory;
  4662. this.structTreeLayerFactory = options.structTreeLayerFactory;
  4663. this.renderer = options.renderer || _ui_utils.RendererType.CANVAS;
  4664. this.l10n = options.l10n || _l10n_utils.NullL10n;
  4665. this.paintTask = null;
  4666. this.paintedViewportMap = new WeakMap();
  4667. this.renderingState = _pdf_rendering_queue.RenderingStates.INITIAL;
  4668. this.resume = null;
  4669. this._renderError = null;
  4670. this.annotationLayer = null;
  4671. this.textLayer = null;
  4672. this.zoomLayer = null;
  4673. this.xfaLayer = null;
  4674. this.structTreeLayer = null;
  4675. var div = document.createElement("div");
  4676. div.className = "page";
  4677. div.style.width = Math.floor(this.viewport.width) + "px";
  4678. div.style.height = Math.floor(this.viewport.height) + "px";
  4679. div.setAttribute("data-page-number", this.id);
  4680. div.setAttribute("role", "region");
  4681. this.l10n.get("page_landmark", {
  4682. page: this.id
  4683. }).then(function (msg) {
  4684. div.setAttribute("aria-label", msg);
  4685. });
  4686. this.div = div;
  4687. container.appendChild(div);
  4688. }
  4689. _createClass(PDFPageView, [{
  4690. key: "setPdfPage",
  4691. value: function setPdfPage(pdfPage) {
  4692. this.pdfPage = pdfPage;
  4693. this.pdfPageRotate = pdfPage.rotate;
  4694. var totalRotation = (this.rotation + this.pdfPageRotate) % 360;
  4695. this.viewport = pdfPage.getViewport({
  4696. scale: this.scale * _ui_utils.CSS_UNITS,
  4697. rotation: totalRotation
  4698. });
  4699. this.reset();
  4700. }
  4701. }, {
  4702. key: "destroy",
  4703. value: function destroy() {
  4704. this.reset();
  4705. if (this.pdfPage) {
  4706. this.pdfPage.cleanup();
  4707. }
  4708. }
  4709. }, {
  4710. key: "_renderAnnotationLayer",
  4711. value: function () {
  4712. var _renderAnnotationLayer2 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
  4713. var error;
  4714. return _regenerator["default"].wrap(function _callee$(_context) {
  4715. while (1) {
  4716. switch (_context.prev = _context.next) {
  4717. case 0:
  4718. error = null;
  4719. _context.prev = 1;
  4720. _context.next = 4;
  4721. return this.annotationLayer.render(this.viewport, "display");
  4722. case 4:
  4723. _context.next = 9;
  4724. break;
  4725. case 6:
  4726. _context.prev = 6;
  4727. _context.t0 = _context["catch"](1);
  4728. error = _context.t0;
  4729. case 9:
  4730. _context.prev = 9;
  4731. this.eventBus.dispatch("annotationlayerrendered", {
  4732. source: this,
  4733. pageNumber: this.id,
  4734. error: error
  4735. });
  4736. return _context.finish(9);
  4737. case 12:
  4738. case "end":
  4739. return _context.stop();
  4740. }
  4741. }
  4742. }, _callee, this, [[1, 6, 9, 12]]);
  4743. }));
  4744. function _renderAnnotationLayer() {
  4745. return _renderAnnotationLayer2.apply(this, arguments);
  4746. }
  4747. return _renderAnnotationLayer;
  4748. }()
  4749. }, {
  4750. key: "_renderXfaLayer",
  4751. value: function () {
  4752. var _renderXfaLayer2 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee2() {
  4753. var error;
  4754. return _regenerator["default"].wrap(function _callee2$(_context2) {
  4755. while (1) {
  4756. switch (_context2.prev = _context2.next) {
  4757. case 0:
  4758. error = null;
  4759. _context2.prev = 1;
  4760. _context2.next = 4;
  4761. return this.xfaLayer.render(this.viewport, "display");
  4762. case 4:
  4763. _context2.next = 9;
  4764. break;
  4765. case 6:
  4766. _context2.prev = 6;
  4767. _context2.t0 = _context2["catch"](1);
  4768. error = _context2.t0;
  4769. case 9:
  4770. _context2.prev = 9;
  4771. this.eventBus.dispatch("xfalayerrendered", {
  4772. source: this,
  4773. pageNumber: this.id,
  4774. error: error
  4775. });
  4776. return _context2.finish(9);
  4777. case 12:
  4778. case "end":
  4779. return _context2.stop();
  4780. }
  4781. }
  4782. }, _callee2, this, [[1, 6, 9, 12]]);
  4783. }));
  4784. function _renderXfaLayer() {
  4785. return _renderXfaLayer2.apply(this, arguments);
  4786. }
  4787. return _renderXfaLayer;
  4788. }()
  4789. }, {
  4790. key: "_resetZoomLayer",
  4791. value: function _resetZoomLayer() {
  4792. var removeFromDOM = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  4793. if (!this.zoomLayer) {
  4794. return;
  4795. }
  4796. var zoomLayerCanvas = this.zoomLayer.firstChild;
  4797. this.paintedViewportMap["delete"](zoomLayerCanvas);
  4798. zoomLayerCanvas.width = 0;
  4799. zoomLayerCanvas.height = 0;
  4800. if (removeFromDOM) {
  4801. this.zoomLayer.remove();
  4802. }
  4803. this.zoomLayer = null;
  4804. }
  4805. }, {
  4806. key: "reset",
  4807. value: function reset() {
  4808. var _this$annotationLayer,
  4809. _this$xfaLayer,
  4810. _this = this;
  4811. var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
  4812. _ref$keepZoomLayer = _ref.keepZoomLayer,
  4813. keepZoomLayer = _ref$keepZoomLayer === void 0 ? false : _ref$keepZoomLayer,
  4814. _ref$keepAnnotationLa = _ref.keepAnnotationLayer,
  4815. keepAnnotationLayer = _ref$keepAnnotationLa === void 0 ? false : _ref$keepAnnotationLa,
  4816. _ref$keepXfaLayer = _ref.keepXfaLayer,
  4817. keepXfaLayer = _ref$keepXfaLayer === void 0 ? false : _ref$keepXfaLayer;
  4818. this.cancelRendering({
  4819. keepAnnotationLayer: keepAnnotationLayer,
  4820. keepXfaLayer: keepXfaLayer
  4821. });
  4822. this.renderingState = _pdf_rendering_queue.RenderingStates.INITIAL;
  4823. var div = this.div;
  4824. div.style.width = Math.floor(this.viewport.width) + "px";
  4825. div.style.height = Math.floor(this.viewport.height) + "px";
  4826. var childNodes = div.childNodes,
  4827. zoomLayerNode = keepZoomLayer && this.zoomLayer || null,
  4828. annotationLayerNode = keepAnnotationLayer && ((_this$annotationLayer = this.annotationLayer) === null || _this$annotationLayer === void 0 ? void 0 : _this$annotationLayer.div) || null,
  4829. xfaLayerNode = keepXfaLayer && ((_this$xfaLayer = this.xfaLayer) === null || _this$xfaLayer === void 0 ? void 0 : _this$xfaLayer.div) || null;
  4830. for (var i = childNodes.length - 1; i >= 0; i--) {
  4831. var node = childNodes[i];
  4832. switch (node) {
  4833. case zoomLayerNode:
  4834. case annotationLayerNode:
  4835. case xfaLayerNode:
  4836. continue;
  4837. }
  4838. div.removeChild(node);
  4839. }
  4840. div.removeAttribute("data-loaded");
  4841. if (annotationLayerNode) {
  4842. this.annotationLayer.hide();
  4843. }
  4844. if (xfaLayerNode) {
  4845. this.xfaLayer.hide();
  4846. }
  4847. if (!zoomLayerNode) {
  4848. if (this.canvas) {
  4849. this.paintedViewportMap["delete"](this.canvas);
  4850. this.canvas.width = 0;
  4851. this.canvas.height = 0;
  4852. delete this.canvas;
  4853. }
  4854. this._resetZoomLayer();
  4855. }
  4856. if (this.svg) {
  4857. this.paintedViewportMap["delete"](this.svg);
  4858. delete this.svg;
  4859. }
  4860. this.loadingIconDiv = document.createElement("div");
  4861. this.loadingIconDiv.className = "loadingIcon";
  4862. this.loadingIconDiv.setAttribute("role", "img");
  4863. this.l10n.get("loading").then(function (msg) {
  4864. var _this$loadingIconDiv;
  4865. (_this$loadingIconDiv = _this.loadingIconDiv) === null || _this$loadingIconDiv === void 0 ? void 0 : _this$loadingIconDiv.setAttribute("aria-label", msg);
  4866. });
  4867. div.appendChild(this.loadingIconDiv);
  4868. }
  4869. }, {
  4870. key: "update",
  4871. value: function update(scale, rotation) {
  4872. var optionalContentConfigPromise = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
  4873. this.scale = scale || this.scale;
  4874. if (typeof rotation !== "undefined") {
  4875. this.rotation = rotation;
  4876. }
  4877. if (optionalContentConfigPromise instanceof Promise) {
  4878. this._optionalContentConfigPromise = optionalContentConfigPromise;
  4879. }
  4880. var totalRotation = (this.rotation + this.pdfPageRotate) % 360;
  4881. this.viewport = this.viewport.clone({
  4882. scale: this.scale * _ui_utils.CSS_UNITS,
  4883. rotation: totalRotation
  4884. });
  4885. if (this.svg) {
  4886. this.cssTransform({
  4887. target: this.svg,
  4888. redrawAnnotationLayer: true,
  4889. redrawXfaLayer: true
  4890. });
  4891. this.eventBus.dispatch("pagerendered", {
  4892. source: this,
  4893. pageNumber: this.id,
  4894. cssTransform: true,
  4895. timestamp: performance.now(),
  4896. error: this._renderError
  4897. });
  4898. return;
  4899. }
  4900. var isScalingRestricted = false;
  4901. if (this.canvas && this.maxCanvasPixels > 0) {
  4902. var outputScale = this.outputScale;
  4903. if ((Math.floor(this.viewport.width) * outputScale.sx | 0) * (Math.floor(this.viewport.height) * outputScale.sy | 0) > this.maxCanvasPixels) {
  4904. isScalingRestricted = true;
  4905. }
  4906. }
  4907. if (this.canvas) {
  4908. if (this.useOnlyCssZoom || this.hasRestrictedScaling && isScalingRestricted) {
  4909. this.cssTransform({
  4910. target: this.canvas,
  4911. redrawAnnotationLayer: true,
  4912. redrawXfaLayer: true
  4913. });
  4914. this.eventBus.dispatch("pagerendered", {
  4915. source: this,
  4916. pageNumber: this.id,
  4917. cssTransform: true,
  4918. timestamp: performance.now(),
  4919. error: this._renderError
  4920. });
  4921. return;
  4922. }
  4923. if (!this.zoomLayer && !this.canvas.hidden) {
  4924. this.zoomLayer = this.canvas.parentNode;
  4925. this.zoomLayer.style.position = "absolute";
  4926. }
  4927. }
  4928. if (this.zoomLayer) {
  4929. this.cssTransform({
  4930. target: this.zoomLayer.firstChild
  4931. });
  4932. }
  4933. this.reset({
  4934. keepZoomLayer: true,
  4935. keepAnnotationLayer: true,
  4936. keepXfaLayer: true
  4937. });
  4938. }
  4939. }, {
  4940. key: "cancelRendering",
  4941. value: function cancelRendering() {
  4942. var _ref2 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
  4943. _ref2$keepAnnotationL = _ref2.keepAnnotationLayer,
  4944. keepAnnotationLayer = _ref2$keepAnnotationL === void 0 ? false : _ref2$keepAnnotationL,
  4945. _ref2$keepXfaLayer = _ref2.keepXfaLayer,
  4946. keepXfaLayer = _ref2$keepXfaLayer === void 0 ? false : _ref2$keepXfaLayer;
  4947. if (this.paintTask) {
  4948. this.paintTask.cancel();
  4949. this.paintTask = null;
  4950. }
  4951. this.resume = null;
  4952. if (this.textLayer) {
  4953. this.textLayer.cancel();
  4954. this.textLayer = null;
  4955. }
  4956. if (this.annotationLayer && (!keepAnnotationLayer || !this.annotationLayer.div)) {
  4957. this.annotationLayer.cancel();
  4958. this.annotationLayer = null;
  4959. }
  4960. if (this.xfaLayer && (!keepXfaLayer || !this.xfaLayer.div)) {
  4961. this.xfaLayer.cancel();
  4962. this.xfaLayer = null;
  4963. }
  4964. if (this._onTextLayerRendered) {
  4965. this.eventBus._off("textlayerrendered", this._onTextLayerRendered);
  4966. this._onTextLayerRendered = null;
  4967. }
  4968. }
  4969. }, {
  4970. key: "cssTransform",
  4971. value: function cssTransform(_ref3) {
  4972. var target = _ref3.target,
  4973. _ref3$redrawAnnotatio = _ref3.redrawAnnotationLayer,
  4974. redrawAnnotationLayer = _ref3$redrawAnnotatio === void 0 ? false : _ref3$redrawAnnotatio,
  4975. _ref3$redrawXfaLayer = _ref3.redrawXfaLayer,
  4976. redrawXfaLayer = _ref3$redrawXfaLayer === void 0 ? false : _ref3$redrawXfaLayer;
  4977. var width = this.viewport.width;
  4978. var height = this.viewport.height;
  4979. var div = this.div;
  4980. target.style.width = target.parentNode.style.width = div.style.width = Math.floor(width) + "px";
  4981. target.style.height = target.parentNode.style.height = div.style.height = Math.floor(height) + "px";
  4982. var relativeRotation = this.viewport.rotation - this.paintedViewportMap.get(target).rotation;
  4983. var absRotation = Math.abs(relativeRotation);
  4984. var scaleX = 1,
  4985. scaleY = 1;
  4986. if (absRotation === 90 || absRotation === 270) {
  4987. scaleX = height / width;
  4988. scaleY = width / height;
  4989. }
  4990. target.style.transform = "rotate(".concat(relativeRotation, "deg) scale(").concat(scaleX, ", ").concat(scaleY, ")");
  4991. if (this.textLayer) {
  4992. var textLayerViewport = this.textLayer.viewport;
  4993. var textRelativeRotation = this.viewport.rotation - textLayerViewport.rotation;
  4994. var textAbsRotation = Math.abs(textRelativeRotation);
  4995. var scale = width / textLayerViewport.width;
  4996. if (textAbsRotation === 90 || textAbsRotation === 270) {
  4997. scale = width / textLayerViewport.height;
  4998. }
  4999. var textLayerDiv = this.textLayer.textLayerDiv;
  5000. var transX, transY;
  5001. switch (textAbsRotation) {
  5002. case 0:
  5003. transX = transY = 0;
  5004. break;
  5005. case 90:
  5006. transX = 0;
  5007. transY = "-" + textLayerDiv.style.height;
  5008. break;
  5009. case 180:
  5010. transX = "-" + textLayerDiv.style.width;
  5011. transY = "-" + textLayerDiv.style.height;
  5012. break;
  5013. case 270:
  5014. transX = "-" + textLayerDiv.style.width;
  5015. transY = 0;
  5016. break;
  5017. default:
  5018. console.error("Bad rotation value.");
  5019. break;
  5020. }
  5021. textLayerDiv.style.transform = "rotate(".concat(textAbsRotation, "deg) ") + "scale(".concat(scale, ") ") + "translate(".concat(transX, ", ").concat(transY, ")");
  5022. textLayerDiv.style.transformOrigin = "0% 0%";
  5023. }
  5024. if (redrawAnnotationLayer && this.annotationLayer) {
  5025. this._renderAnnotationLayer();
  5026. }
  5027. if (redrawXfaLayer && this.xfaLayer) {
  5028. this._renderXfaLayer();
  5029. }
  5030. }
  5031. }, {
  5032. key: "width",
  5033. get: function get() {
  5034. return this.viewport.width;
  5035. }
  5036. }, {
  5037. key: "height",
  5038. get: function get() {
  5039. return this.viewport.height;
  5040. }
  5041. }, {
  5042. key: "getPagePoint",
  5043. value: function getPagePoint(x, y) {
  5044. return this.viewport.convertToPdfPoint(x, y);
  5045. }
  5046. }, {
  5047. key: "draw",
  5048. value: function draw() {
  5049. var _this$annotationLayer2,
  5050. _this$xfaLayer2,
  5051. _this2 = this;
  5052. if (this.renderingState !== _pdf_rendering_queue.RenderingStates.INITIAL) {
  5053. console.error("Must be in new state before drawing");
  5054. this.reset();
  5055. }
  5056. var div = this.div,
  5057. pdfPage = this.pdfPage;
  5058. if (!pdfPage) {
  5059. this.renderingState = _pdf_rendering_queue.RenderingStates.FINISHED;
  5060. if (this.loadingIconDiv) {
  5061. div.removeChild(this.loadingIconDiv);
  5062. delete this.loadingIconDiv;
  5063. }
  5064. return Promise.reject(new Error("pdfPage is not loaded"));
  5065. }
  5066. this.renderingState = _pdf_rendering_queue.RenderingStates.RUNNING;
  5067. var canvasWrapper = document.createElement("div");
  5068. canvasWrapper.style.width = div.style.width;
  5069. canvasWrapper.style.height = div.style.height;
  5070. canvasWrapper.classList.add("canvasWrapper");
  5071. if ((_this$annotationLayer2 = this.annotationLayer) !== null && _this$annotationLayer2 !== void 0 && _this$annotationLayer2.div) {
  5072. div.insertBefore(canvasWrapper, this.annotationLayer.div);
  5073. } else {
  5074. div.appendChild(canvasWrapper);
  5075. }
  5076. var textLayer = null;
  5077. if (this.textLayerMode !== _ui_utils.TextLayerMode.DISABLE && this.textLayerFactory) {
  5078. var _this$annotationLayer3;
  5079. var textLayerDiv = document.createElement("div");
  5080. textLayerDiv.className = "textLayer";
  5081. textLayerDiv.style.width = canvasWrapper.style.width;
  5082. textLayerDiv.style.height = canvasWrapper.style.height;
  5083. if ((_this$annotationLayer3 = this.annotationLayer) !== null && _this$annotationLayer3 !== void 0 && _this$annotationLayer3.div) {
  5084. div.insertBefore(textLayerDiv, this.annotationLayer.div);
  5085. } else {
  5086. div.appendChild(textLayerDiv);
  5087. }
  5088. textLayer = this.textLayerFactory.createTextLayerBuilder(textLayerDiv, this.id - 1, this.viewport, this.textLayerMode === _ui_utils.TextLayerMode.ENABLE_ENHANCE, this.eventBus);
  5089. }
  5090. this.textLayer = textLayer;
  5091. if ((_this$xfaLayer2 = this.xfaLayer) !== null && _this$xfaLayer2 !== void 0 && _this$xfaLayer2.div) {
  5092. div.appendChild(this.xfaLayer.div);
  5093. }
  5094. var renderContinueCallback = null;
  5095. if (this.renderingQueue) {
  5096. renderContinueCallback = function renderContinueCallback(cont) {
  5097. if (!_this2.renderingQueue.isHighestPriority(_this2)) {
  5098. _this2.renderingState = _pdf_rendering_queue.RenderingStates.PAUSED;
  5099. _this2.resume = function () {
  5100. _this2.renderingState = _pdf_rendering_queue.RenderingStates.RUNNING;
  5101. cont();
  5102. };
  5103. return;
  5104. }
  5105. cont();
  5106. };
  5107. }
  5108. var finishPaintTask = /*#__PURE__*/function () {
  5109. var _ref4 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee3() {
  5110. var error,
  5111. _args3 = arguments;
  5112. return _regenerator["default"].wrap(function _callee3$(_context3) {
  5113. while (1) {
  5114. switch (_context3.prev = _context3.next) {
  5115. case 0:
  5116. error = _args3.length > 0 && _args3[0] !== undefined ? _args3[0] : null;
  5117. if (paintTask === _this2.paintTask) {
  5118. _this2.paintTask = null;
  5119. }
  5120. if (!(error instanceof _pdfjsLib.RenderingCancelledException)) {
  5121. _context3.next = 5;
  5122. break;
  5123. }
  5124. _this2._renderError = null;
  5125. return _context3.abrupt("return");
  5126. case 5:
  5127. _this2._renderError = error;
  5128. _this2.renderingState = _pdf_rendering_queue.RenderingStates.FINISHED;
  5129. if (_this2.loadingIconDiv) {
  5130. div.removeChild(_this2.loadingIconDiv);
  5131. delete _this2.loadingIconDiv;
  5132. }
  5133. _this2._resetZoomLayer(true);
  5134. _this2.eventBus.dispatch("pagerendered", {
  5135. source: _this2,
  5136. pageNumber: _this2.id,
  5137. cssTransform: false,
  5138. timestamp: performance.now(),
  5139. error: _this2._renderError
  5140. });
  5141. if (!error) {
  5142. _context3.next = 12;
  5143. break;
  5144. }
  5145. throw error;
  5146. case 12:
  5147. case "end":
  5148. return _context3.stop();
  5149. }
  5150. }
  5151. }, _callee3);
  5152. }));
  5153. return function finishPaintTask() {
  5154. return _ref4.apply(this, arguments);
  5155. };
  5156. }();
  5157. var paintTask = this.renderer === _ui_utils.RendererType.SVG ? this.paintOnSvg(canvasWrapper) : this.paintOnCanvas(canvasWrapper);
  5158. paintTask.onRenderContinue = renderContinueCallback;
  5159. this.paintTask = paintTask;
  5160. var resultPromise = paintTask.promise.then(function () {
  5161. return finishPaintTask(null).then(function () {
  5162. if (textLayer) {
  5163. var readableStream = pdfPage.streamTextContent({
  5164. normalizeWhitespace: true,
  5165. includeMarkedContent: true
  5166. });
  5167. textLayer.setTextContentStream(readableStream);
  5168. textLayer.render();
  5169. }
  5170. });
  5171. }, function (reason) {
  5172. return finishPaintTask(reason);
  5173. });
  5174. if (this.annotationLayerFactory) {
  5175. if (!this.annotationLayer) {
  5176. this.annotationLayer = this.annotationLayerFactory.createAnnotationLayerBuilder(div, pdfPage, null, this.imageResourcesPath, this.renderInteractiveForms, this.l10n, null, null, null);
  5177. }
  5178. this._renderAnnotationLayer();
  5179. }
  5180. if (this.xfaLayerFactory) {
  5181. if (!this.xfaLayer) {
  5182. this.xfaLayer = this.xfaLayerFactory.createXfaLayerBuilder(div, pdfPage, null);
  5183. }
  5184. this._renderXfaLayer();
  5185. }
  5186. if (this.structTreeLayerFactory && this.textLayer && this.canvas) {
  5187. this._onTextLayerRendered = function (event) {
  5188. if (event.pageNumber !== _this2.id) {
  5189. return;
  5190. }
  5191. _this2.eventBus._off("textlayerrendered", _this2._onTextLayerRendered);
  5192. _this2._onTextLayerRendered = null;
  5193. if (!_this2.canvas) {
  5194. return;
  5195. }
  5196. _this2.pdfPage.getStructTree().then(function (tree) {
  5197. if (!tree) {
  5198. return;
  5199. }
  5200. if (!_this2.canvas) {
  5201. return;
  5202. }
  5203. var treeDom = _this2.structTreeLayer.render(tree);
  5204. treeDom.classList.add("structTree");
  5205. _this2.canvas.appendChild(treeDom);
  5206. });
  5207. };
  5208. this.eventBus._on("textlayerrendered", this._onTextLayerRendered);
  5209. this.structTreeLayer = this.structTreeLayerFactory.createStructTreeLayerBuilder(pdfPage);
  5210. }
  5211. div.setAttribute("data-loaded", true);
  5212. this.eventBus.dispatch("pagerender", {
  5213. source: this,
  5214. pageNumber: this.id
  5215. });
  5216. return resultPromise;
  5217. }
  5218. }, {
  5219. key: "paintOnCanvas",
  5220. value: function paintOnCanvas(canvasWrapper) {
  5221. var renderCapability = (0, _pdfjsLib.createPromiseCapability)();
  5222. var result = {
  5223. promise: renderCapability.promise,
  5224. onRenderContinue: function onRenderContinue(cont) {
  5225. cont();
  5226. },
  5227. cancel: function cancel() {
  5228. renderTask.cancel();
  5229. }
  5230. };
  5231. var viewport = this.viewport;
  5232. var canvas = document.createElement("canvas");
  5233. canvas.hidden = true;
  5234. var isCanvasHidden = true;
  5235. var showCanvas = function showCanvas() {
  5236. if (isCanvasHidden) {
  5237. canvas.hidden = false;
  5238. isCanvasHidden = false;
  5239. }
  5240. };
  5241. canvasWrapper.appendChild(canvas);
  5242. this.canvas = canvas;
  5243. canvas.mozOpaque = true;
  5244. var ctx = canvas.getContext("2d", {
  5245. alpha: false
  5246. });
  5247. var outputScale = (0, _ui_utils.getOutputScale)(ctx);
  5248. this.outputScale = outputScale;
  5249. if (this.useOnlyCssZoom) {
  5250. var actualSizeViewport = viewport.clone({
  5251. scale: _ui_utils.CSS_UNITS
  5252. });
  5253. outputScale.sx *= actualSizeViewport.width / viewport.width;
  5254. outputScale.sy *= actualSizeViewport.height / viewport.height;
  5255. outputScale.scaled = true;
  5256. }
  5257. if (this.maxCanvasPixels > 0) {
  5258. var pixelsInViewport = viewport.width * viewport.height;
  5259. var maxScale = Math.sqrt(this.maxCanvasPixels / pixelsInViewport);
  5260. if (outputScale.sx > maxScale || outputScale.sy > maxScale) {
  5261. outputScale.sx = maxScale;
  5262. outputScale.sy = maxScale;
  5263. outputScale.scaled = true;
  5264. this.hasRestrictedScaling = true;
  5265. } else {
  5266. this.hasRestrictedScaling = false;
  5267. }
  5268. }
  5269. var sfx = (0, _ui_utils.approximateFraction)(outputScale.sx);
  5270. var sfy = (0, _ui_utils.approximateFraction)(outputScale.sy);
  5271. canvas.width = (0, _ui_utils.roundToDivide)(viewport.width * outputScale.sx, sfx[0]);
  5272. canvas.height = (0, _ui_utils.roundToDivide)(viewport.height * outputScale.sy, sfy[0]);
  5273. canvas.style.width = (0, _ui_utils.roundToDivide)(viewport.width, sfx[1]) + "px";
  5274. canvas.style.height = (0, _ui_utils.roundToDivide)(viewport.height, sfy[1]) + "px";
  5275. this.paintedViewportMap.set(canvas, viewport);
  5276. var transform = !outputScale.scaled ? null : [outputScale.sx, 0, 0, outputScale.sy, 0, 0];
  5277. var renderContext = {
  5278. canvasContext: ctx,
  5279. transform: transform,
  5280. viewport: this.viewport,
  5281. renderInteractiveForms: this.renderInteractiveForms,
  5282. optionalContentConfigPromise: this._optionalContentConfigPromise
  5283. };
  5284. var renderTask = this.pdfPage.render(renderContext);
  5285. renderTask.onContinue = function (cont) {
  5286. showCanvas();
  5287. if (result.onRenderContinue) {
  5288. result.onRenderContinue(cont);
  5289. } else {
  5290. cont();
  5291. }
  5292. };
  5293. renderTask.promise.then(function () {
  5294. showCanvas();
  5295. renderCapability.resolve(undefined);
  5296. }, function (error) {
  5297. showCanvas();
  5298. renderCapability.reject(error);
  5299. });
  5300. return result;
  5301. }
  5302. }, {
  5303. key: "paintOnSvg",
  5304. value: function paintOnSvg(wrapper) {
  5305. var _this3 = this;
  5306. var cancelled = false;
  5307. var ensureNotCancelled = function ensureNotCancelled() {
  5308. if (cancelled) {
  5309. throw new _pdfjsLib.RenderingCancelledException("Rendering cancelled, page ".concat(_this3.id), "svg");
  5310. }
  5311. };
  5312. var pdfPage = this.pdfPage;
  5313. var actualSizeViewport = this.viewport.clone({
  5314. scale: _ui_utils.CSS_UNITS
  5315. });
  5316. var promise = pdfPage.getOperatorList().then(function (opList) {
  5317. ensureNotCancelled();
  5318. var svgGfx = new _pdfjsLib.SVGGraphics(pdfPage.commonObjs, pdfPage.objs, _viewer_compatibility.viewerCompatibilityParams.disableCreateObjectURL);
  5319. return svgGfx.getSVG(opList, actualSizeViewport).then(function (svg) {
  5320. ensureNotCancelled();
  5321. _this3.svg = svg;
  5322. _this3.paintedViewportMap.set(svg, actualSizeViewport);
  5323. svg.style.width = wrapper.style.width;
  5324. svg.style.height = wrapper.style.height;
  5325. _this3.renderingState = _pdf_rendering_queue.RenderingStates.FINISHED;
  5326. wrapper.appendChild(svg);
  5327. });
  5328. });
  5329. return {
  5330. promise: promise,
  5331. onRenderContinue: function onRenderContinue(cont) {
  5332. cont();
  5333. },
  5334. cancel: function cancel() {
  5335. cancelled = true;
  5336. }
  5337. };
  5338. }
  5339. }, {
  5340. key: "setPageLabel",
  5341. value: function setPageLabel(label) {
  5342. this.pageLabel = typeof label === "string" ? label : null;
  5343. if (this.pageLabel !== null) {
  5344. this.div.setAttribute("data-page-label", this.pageLabel);
  5345. } else {
  5346. this.div.removeAttribute("data-page-label");
  5347. }
  5348. }
  5349. }]);
  5350. return PDFPageView;
  5351. }();
  5352. exports.PDFPageView = PDFPageView;
  5353. /***/ }),
  5354. /* 17 */
  5355. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  5356. Object.defineProperty(exports, "__esModule", ({
  5357. value: true
  5358. }));
  5359. exports.RenderingStates = exports.PDFRenderingQueue = void 0;
  5360. var _pdfjsLib = __w_pdfjs_require__(2);
  5361. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  5362. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  5363. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  5364. var CLEANUP_TIMEOUT = 30000;
  5365. var RenderingStates = {
  5366. INITIAL: 0,
  5367. RUNNING: 1,
  5368. PAUSED: 2,
  5369. FINISHED: 3
  5370. };
  5371. exports.RenderingStates = RenderingStates;
  5372. var PDFRenderingQueue = /*#__PURE__*/function () {
  5373. function PDFRenderingQueue() {
  5374. _classCallCheck(this, PDFRenderingQueue);
  5375. this.pdfViewer = null;
  5376. this.pdfThumbnailViewer = null;
  5377. this.onIdle = null;
  5378. this.highestPriorityPage = null;
  5379. this.idleTimeout = null;
  5380. this.printing = false;
  5381. this.isThumbnailViewEnabled = false;
  5382. }
  5383. _createClass(PDFRenderingQueue, [{
  5384. key: "setViewer",
  5385. value: function setViewer(pdfViewer) {
  5386. this.pdfViewer = pdfViewer;
  5387. }
  5388. }, {
  5389. key: "setThumbnailViewer",
  5390. value: function setThumbnailViewer(pdfThumbnailViewer) {
  5391. this.pdfThumbnailViewer = pdfThumbnailViewer;
  5392. }
  5393. }, {
  5394. key: "isHighestPriority",
  5395. value: function isHighestPriority(view) {
  5396. return this.highestPriorityPage === view.renderingId;
  5397. }
  5398. }, {
  5399. key: "renderHighestPriority",
  5400. value: function renderHighestPriority(currentlyVisiblePages) {
  5401. if (this.idleTimeout) {
  5402. clearTimeout(this.idleTimeout);
  5403. this.idleTimeout = null;
  5404. }
  5405. if (this.pdfViewer.forceRendering(currentlyVisiblePages)) {
  5406. return;
  5407. }
  5408. if (this.pdfThumbnailViewer && this.isThumbnailViewEnabled) {
  5409. if (this.pdfThumbnailViewer.forceRendering()) {
  5410. return;
  5411. }
  5412. }
  5413. if (this.printing) {
  5414. return;
  5415. }
  5416. if (this.onIdle) {
  5417. this.idleTimeout = setTimeout(this.onIdle.bind(this), CLEANUP_TIMEOUT);
  5418. }
  5419. }
  5420. }, {
  5421. key: "getHighestPriority",
  5422. value: function getHighestPriority(visible, views, scrolledDown) {
  5423. var visibleViews = visible.views;
  5424. var numVisible = visibleViews.length;
  5425. if (numVisible === 0) {
  5426. return null;
  5427. }
  5428. for (var i = 0; i < numVisible; ++i) {
  5429. var view = visibleViews[i].view;
  5430. if (!this.isViewFinished(view)) {
  5431. return view;
  5432. }
  5433. }
  5434. if (scrolledDown) {
  5435. var nextPageIndex = visible.last.id;
  5436. if (views[nextPageIndex] && !this.isViewFinished(views[nextPageIndex])) {
  5437. return views[nextPageIndex];
  5438. }
  5439. } else {
  5440. var previousPageIndex = visible.first.id - 2;
  5441. if (views[previousPageIndex] && !this.isViewFinished(views[previousPageIndex])) {
  5442. return views[previousPageIndex];
  5443. }
  5444. }
  5445. return null;
  5446. }
  5447. }, {
  5448. key: "isViewFinished",
  5449. value: function isViewFinished(view) {
  5450. return view.renderingState === RenderingStates.FINISHED;
  5451. }
  5452. }, {
  5453. key: "renderView",
  5454. value: function renderView(view) {
  5455. var _this = this;
  5456. switch (view.renderingState) {
  5457. case RenderingStates.FINISHED:
  5458. return false;
  5459. case RenderingStates.PAUSED:
  5460. this.highestPriorityPage = view.renderingId;
  5461. view.resume();
  5462. break;
  5463. case RenderingStates.RUNNING:
  5464. this.highestPriorityPage = view.renderingId;
  5465. break;
  5466. case RenderingStates.INITIAL:
  5467. this.highestPriorityPage = view.renderingId;
  5468. view.draw()["finally"](function () {
  5469. _this.renderHighestPriority();
  5470. })["catch"](function (reason) {
  5471. if (reason instanceof _pdfjsLib.RenderingCancelledException) {
  5472. return;
  5473. }
  5474. console.error("renderView: \"".concat(reason, "\""));
  5475. });
  5476. break;
  5477. }
  5478. return true;
  5479. }
  5480. }]);
  5481. return PDFRenderingQueue;
  5482. }();
  5483. exports.PDFRenderingQueue = PDFRenderingQueue;
  5484. /***/ }),
  5485. /* 18 */
  5486. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  5487. Object.defineProperty(exports, "__esModule", ({
  5488. value: true
  5489. }));
  5490. exports.PDFScriptingManager = void 0;
  5491. var _regenerator = _interopRequireDefault(__w_pdfjs_require__(4));
  5492. var _pdfjsLib = __w_pdfjs_require__(2);
  5493. var _ui_utils = __w_pdfjs_require__(7);
  5494. var _pdf_rendering_queue = __w_pdfjs_require__(17);
  5495. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  5496. function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
  5497. function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
  5498. function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
  5499. function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
  5500. function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
  5501. function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
  5502. function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
  5503. function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e2) { throw _e2; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e3) { didErr = true; err = _e3; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
  5504. function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
  5505. function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
  5506. function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
  5507. function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
  5508. function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
  5509. function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
  5510. function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
  5511. function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
  5512. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  5513. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  5514. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  5515. var PDFScriptingManager = /*#__PURE__*/function () {
  5516. function PDFScriptingManager(_ref) {
  5517. var _this = this;
  5518. var eventBus = _ref.eventBus,
  5519. _ref$sandboxBundleSrc = _ref.sandboxBundleSrc,
  5520. sandboxBundleSrc = _ref$sandboxBundleSrc === void 0 ? null : _ref$sandboxBundleSrc,
  5521. _ref$scriptingFactory = _ref.scriptingFactory,
  5522. scriptingFactory = _ref$scriptingFactory === void 0 ? null : _ref$scriptingFactory,
  5523. _ref$docPropertiesLoo = _ref.docPropertiesLookup,
  5524. docPropertiesLookup = _ref$docPropertiesLoo === void 0 ? null : _ref$docPropertiesLoo;
  5525. _classCallCheck(this, PDFScriptingManager);
  5526. this._pdfDocument = null;
  5527. this._pdfViewer = null;
  5528. this._closeCapability = null;
  5529. this._destroyCapability = null;
  5530. this._scripting = null;
  5531. this._mouseState = Object.create(null);
  5532. this._ready = false;
  5533. this._eventBus = eventBus;
  5534. this._sandboxBundleSrc = sandboxBundleSrc;
  5535. this._scriptingFactory = scriptingFactory;
  5536. this._docPropertiesLookup = docPropertiesLookup;
  5537. if (!this._scriptingFactory) {
  5538. window.addEventListener("updatefromsandbox", function (event) {
  5539. _this._eventBus.dispatch("updatefromsandbox", {
  5540. source: window,
  5541. detail: event.detail
  5542. });
  5543. });
  5544. }
  5545. }
  5546. _createClass(PDFScriptingManager, [{
  5547. key: "setViewer",
  5548. value: function setViewer(pdfViewer) {
  5549. this._pdfViewer = pdfViewer;
  5550. }
  5551. }, {
  5552. key: "setDocument",
  5553. value: function () {
  5554. var _setDocument = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee2(pdfDocument) {
  5555. var _this2 = this,
  5556. _this$_scripting;
  5557. var _yield$Promise$all, _yield$Promise$all2, objects, calculationOrder, docActions, _iterator, _step, _step$value, name, listener, _iterator2, _step2, _step2$value, _name, _listener, docProperties;
  5558. return _regenerator["default"].wrap(function _callee2$(_context2) {
  5559. while (1) {
  5560. switch (_context2.prev = _context2.next) {
  5561. case 0:
  5562. if (!this._pdfDocument) {
  5563. _context2.next = 3;
  5564. break;
  5565. }
  5566. _context2.next = 3;
  5567. return this._destroyScripting();
  5568. case 3:
  5569. this._pdfDocument = pdfDocument;
  5570. if (pdfDocument) {
  5571. _context2.next = 6;
  5572. break;
  5573. }
  5574. return _context2.abrupt("return");
  5575. case 6:
  5576. _context2.next = 8;
  5577. return Promise.all([pdfDocument.getFieldObjects(), pdfDocument.getCalculationOrderIds(), pdfDocument.getJSActions()]);
  5578. case 8:
  5579. _yield$Promise$all = _context2.sent;
  5580. _yield$Promise$all2 = _slicedToArray(_yield$Promise$all, 3);
  5581. objects = _yield$Promise$all2[0];
  5582. calculationOrder = _yield$Promise$all2[1];
  5583. docActions = _yield$Promise$all2[2];
  5584. if (!(!objects && !docActions)) {
  5585. _context2.next = 17;
  5586. break;
  5587. }
  5588. _context2.next = 16;
  5589. return this._destroyScripting();
  5590. case 16:
  5591. return _context2.abrupt("return");
  5592. case 17:
  5593. if (!(pdfDocument !== this._pdfDocument)) {
  5594. _context2.next = 19;
  5595. break;
  5596. }
  5597. return _context2.abrupt("return");
  5598. case 19:
  5599. _context2.prev = 19;
  5600. this._scripting = this._createScripting();
  5601. _context2.next = 29;
  5602. break;
  5603. case 23:
  5604. _context2.prev = 23;
  5605. _context2.t0 = _context2["catch"](19);
  5606. console.error("PDFScriptingManager.setDocument: \"".concat(_context2.t0 === null || _context2.t0 === void 0 ? void 0 : _context2.t0.message, "\"."));
  5607. _context2.next = 28;
  5608. return this._destroyScripting();
  5609. case 28:
  5610. return _context2.abrupt("return");
  5611. case 29:
  5612. this._internalEvents.set("updatefromsandbox", function (event) {
  5613. if ((event === null || event === void 0 ? void 0 : event.source) !== window) {
  5614. return;
  5615. }
  5616. _this2._updateFromSandbox(event.detail);
  5617. });
  5618. this._internalEvents.set("dispatcheventinsandbox", function (event) {
  5619. var _this2$_scripting;
  5620. (_this2$_scripting = _this2._scripting) === null || _this2$_scripting === void 0 ? void 0 : _this2$_scripting.dispatchEventInSandbox(event.detail);
  5621. });
  5622. this._internalEvents.set("pagechanging", function (_ref2) {
  5623. var pageNumber = _ref2.pageNumber,
  5624. previous = _ref2.previous;
  5625. if (pageNumber === previous) {
  5626. return;
  5627. }
  5628. _this2._dispatchPageClose(previous);
  5629. _this2._dispatchPageOpen(pageNumber);
  5630. });
  5631. this._internalEvents.set("pagerendered", function (_ref3) {
  5632. var pageNumber = _ref3.pageNumber;
  5633. if (!_this2._pageOpenPending.has(pageNumber)) {
  5634. return;
  5635. }
  5636. if (pageNumber !== _this2._pdfViewer.currentPageNumber) {
  5637. return;
  5638. }
  5639. _this2._dispatchPageOpen(pageNumber);
  5640. });
  5641. this._internalEvents.set("pagesdestroy", /*#__PURE__*/function () {
  5642. var _ref4 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee(event) {
  5643. var _this2$_scripting2, _this2$_closeCapabili;
  5644. return _regenerator["default"].wrap(function _callee$(_context) {
  5645. while (1) {
  5646. switch (_context.prev = _context.next) {
  5647. case 0:
  5648. _context.next = 2;
  5649. return _this2._dispatchPageClose(_this2._pdfViewer.currentPageNumber);
  5650. case 2:
  5651. _context.next = 4;
  5652. return (_this2$_scripting2 = _this2._scripting) === null || _this2$_scripting2 === void 0 ? void 0 : _this2$_scripting2.dispatchEventInSandbox({
  5653. id: "doc",
  5654. name: "WillClose"
  5655. });
  5656. case 4:
  5657. (_this2$_closeCapabili = _this2._closeCapability) === null || _this2$_closeCapabili === void 0 ? void 0 : _this2$_closeCapabili.resolve();
  5658. case 5:
  5659. case "end":
  5660. return _context.stop();
  5661. }
  5662. }
  5663. }, _callee);
  5664. }));
  5665. return function (_x2) {
  5666. return _ref4.apply(this, arguments);
  5667. };
  5668. }());
  5669. this._domEvents.set("mousedown", function (event) {
  5670. _this2._mouseState.isDown = true;
  5671. });
  5672. this._domEvents.set("mouseup", function (event) {
  5673. _this2._mouseState.isDown = false;
  5674. });
  5675. _iterator = _createForOfIteratorHelper(this._internalEvents);
  5676. try {
  5677. for (_iterator.s(); !(_step = _iterator.n()).done;) {
  5678. _step$value = _slicedToArray(_step.value, 2), name = _step$value[0], listener = _step$value[1];
  5679. this._eventBus._on(name, listener);
  5680. }
  5681. } catch (err) {
  5682. _iterator.e(err);
  5683. } finally {
  5684. _iterator.f();
  5685. }
  5686. _iterator2 = _createForOfIteratorHelper(this._domEvents);
  5687. try {
  5688. for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
  5689. _step2$value = _slicedToArray(_step2.value, 2), _name = _step2$value[0], _listener = _step2$value[1];
  5690. window.addEventListener(_name, _listener);
  5691. }
  5692. } catch (err) {
  5693. _iterator2.e(err);
  5694. } finally {
  5695. _iterator2.f();
  5696. }
  5697. _context2.prev = 40;
  5698. _context2.next = 43;
  5699. return this._getDocProperties();
  5700. case 43:
  5701. docProperties = _context2.sent;
  5702. if (!(pdfDocument !== this._pdfDocument)) {
  5703. _context2.next = 46;
  5704. break;
  5705. }
  5706. return _context2.abrupt("return");
  5707. case 46:
  5708. _context2.next = 48;
  5709. return this._scripting.createSandbox({
  5710. objects: objects,
  5711. calculationOrder: calculationOrder,
  5712. appInfo: {
  5713. platform: navigator.platform,
  5714. language: navigator.language
  5715. },
  5716. docInfo: _objectSpread(_objectSpread({}, docProperties), {}, {
  5717. actions: docActions
  5718. })
  5719. });
  5720. case 48:
  5721. this._eventBus.dispatch("sandboxcreated", {
  5722. source: this
  5723. });
  5724. _context2.next = 57;
  5725. break;
  5726. case 51:
  5727. _context2.prev = 51;
  5728. _context2.t1 = _context2["catch"](40);
  5729. console.error("PDFScriptingManager.setDocument: \"".concat(_context2.t1 === null || _context2.t1 === void 0 ? void 0 : _context2.t1.message, "\"."));
  5730. _context2.next = 56;
  5731. return this._destroyScripting();
  5732. case 56:
  5733. return _context2.abrupt("return");
  5734. case 57:
  5735. _context2.next = 59;
  5736. return (_this$_scripting = this._scripting) === null || _this$_scripting === void 0 ? void 0 : _this$_scripting.dispatchEventInSandbox({
  5737. id: "doc",
  5738. name: "Open"
  5739. });
  5740. case 59:
  5741. _context2.next = 61;
  5742. return this._dispatchPageOpen(this._pdfViewer.currentPageNumber, true);
  5743. case 61:
  5744. Promise.resolve().then(function () {
  5745. if (pdfDocument === _this2._pdfDocument) {
  5746. _this2._ready = true;
  5747. }
  5748. });
  5749. case 62:
  5750. case "end":
  5751. return _context2.stop();
  5752. }
  5753. }
  5754. }, _callee2, this, [[19, 23], [40, 51]]);
  5755. }));
  5756. function setDocument(_x) {
  5757. return _setDocument.apply(this, arguments);
  5758. }
  5759. return setDocument;
  5760. }()
  5761. }, {
  5762. key: "dispatchWillSave",
  5763. value: function () {
  5764. var _dispatchWillSave = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee3(detail) {
  5765. var _this$_scripting2;
  5766. return _regenerator["default"].wrap(function _callee3$(_context3) {
  5767. while (1) {
  5768. switch (_context3.prev = _context3.next) {
  5769. case 0:
  5770. return _context3.abrupt("return", (_this$_scripting2 = this._scripting) === null || _this$_scripting2 === void 0 ? void 0 : _this$_scripting2.dispatchEventInSandbox({
  5771. id: "doc",
  5772. name: "WillSave"
  5773. }));
  5774. case 1:
  5775. case "end":
  5776. return _context3.stop();
  5777. }
  5778. }
  5779. }, _callee3, this);
  5780. }));
  5781. function dispatchWillSave(_x3) {
  5782. return _dispatchWillSave.apply(this, arguments);
  5783. }
  5784. return dispatchWillSave;
  5785. }()
  5786. }, {
  5787. key: "dispatchDidSave",
  5788. value: function () {
  5789. var _dispatchDidSave = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee4(detail) {
  5790. var _this$_scripting3;
  5791. return _regenerator["default"].wrap(function _callee4$(_context4) {
  5792. while (1) {
  5793. switch (_context4.prev = _context4.next) {
  5794. case 0:
  5795. return _context4.abrupt("return", (_this$_scripting3 = this._scripting) === null || _this$_scripting3 === void 0 ? void 0 : _this$_scripting3.dispatchEventInSandbox({
  5796. id: "doc",
  5797. name: "DidSave"
  5798. }));
  5799. case 1:
  5800. case "end":
  5801. return _context4.stop();
  5802. }
  5803. }
  5804. }, _callee4, this);
  5805. }));
  5806. function dispatchDidSave(_x4) {
  5807. return _dispatchDidSave.apply(this, arguments);
  5808. }
  5809. return dispatchDidSave;
  5810. }()
  5811. }, {
  5812. key: "dispatchWillPrint",
  5813. value: function () {
  5814. var _dispatchWillPrint = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee5(detail) {
  5815. var _this$_scripting4;
  5816. return _regenerator["default"].wrap(function _callee5$(_context5) {
  5817. while (1) {
  5818. switch (_context5.prev = _context5.next) {
  5819. case 0:
  5820. return _context5.abrupt("return", (_this$_scripting4 = this._scripting) === null || _this$_scripting4 === void 0 ? void 0 : _this$_scripting4.dispatchEventInSandbox({
  5821. id: "doc",
  5822. name: "WillPrint"
  5823. }));
  5824. case 1:
  5825. case "end":
  5826. return _context5.stop();
  5827. }
  5828. }
  5829. }, _callee5, this);
  5830. }));
  5831. function dispatchWillPrint(_x5) {
  5832. return _dispatchWillPrint.apply(this, arguments);
  5833. }
  5834. return dispatchWillPrint;
  5835. }()
  5836. }, {
  5837. key: "dispatchDidPrint",
  5838. value: function () {
  5839. var _dispatchDidPrint = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee6(detail) {
  5840. var _this$_scripting5;
  5841. return _regenerator["default"].wrap(function _callee6$(_context6) {
  5842. while (1) {
  5843. switch (_context6.prev = _context6.next) {
  5844. case 0:
  5845. return _context6.abrupt("return", (_this$_scripting5 = this._scripting) === null || _this$_scripting5 === void 0 ? void 0 : _this$_scripting5.dispatchEventInSandbox({
  5846. id: "doc",
  5847. name: "DidPrint"
  5848. }));
  5849. case 1:
  5850. case "end":
  5851. return _context6.stop();
  5852. }
  5853. }
  5854. }, _callee6, this);
  5855. }));
  5856. function dispatchDidPrint(_x6) {
  5857. return _dispatchDidPrint.apply(this, arguments);
  5858. }
  5859. return dispatchDidPrint;
  5860. }()
  5861. }, {
  5862. key: "mouseState",
  5863. get: function get() {
  5864. return this._mouseState;
  5865. }
  5866. }, {
  5867. key: "destroyPromise",
  5868. get: function get() {
  5869. var _this$_destroyCapabil;
  5870. return ((_this$_destroyCapabil = this._destroyCapability) === null || _this$_destroyCapabil === void 0 ? void 0 : _this$_destroyCapabil.promise) || null;
  5871. }
  5872. }, {
  5873. key: "ready",
  5874. get: function get() {
  5875. return this._ready;
  5876. }
  5877. }, {
  5878. key: "_internalEvents",
  5879. get: function get() {
  5880. return (0, _pdfjsLib.shadow)(this, "_internalEvents", new Map());
  5881. }
  5882. }, {
  5883. key: "_domEvents",
  5884. get: function get() {
  5885. return (0, _pdfjsLib.shadow)(this, "_domEvents", new Map());
  5886. }
  5887. }, {
  5888. key: "_pageOpenPending",
  5889. get: function get() {
  5890. return (0, _pdfjsLib.shadow)(this, "_pageOpenPending", new Set());
  5891. }
  5892. }, {
  5893. key: "_visitedPages",
  5894. get: function get() {
  5895. return (0, _pdfjsLib.shadow)(this, "_visitedPages", new Map());
  5896. }
  5897. }, {
  5898. key: "_updateFromSandbox",
  5899. value: function () {
  5900. var _updateFromSandbox2 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee7(detail) {
  5901. var isInPresentationMode, id, siblings, command, value, ids, _iterator3, _step3, elementId, element, _this$_pdfDocument;
  5902. return _regenerator["default"].wrap(function _callee7$(_context7) {
  5903. while (1) {
  5904. switch (_context7.prev = _context7.next) {
  5905. case 0:
  5906. isInPresentationMode = this._pdfViewer.isInPresentationMode || this._pdfViewer.isChangingPresentationMode;
  5907. id = detail.id, siblings = detail.siblings, command = detail.command, value = detail.value;
  5908. if (id) {
  5909. _context7.next = 25;
  5910. break;
  5911. }
  5912. _context7.t0 = command;
  5913. _context7.next = _context7.t0 === "clear" ? 6 : _context7.t0 === "error" ? 8 : _context7.t0 === "layout" ? 10 : _context7.t0 === "page-num" ? 12 : _context7.t0 === "print" ? 14 : _context7.t0 === "println" ? 18 : _context7.t0 === "zoom" ? 20 : 24;
  5914. break;
  5915. case 6:
  5916. console.clear();
  5917. return _context7.abrupt("break", 24);
  5918. case 8:
  5919. console.error(value);
  5920. return _context7.abrupt("break", 24);
  5921. case 10:
  5922. this._pdfViewer.spreadMode = (0, _ui_utils.apiPageLayoutToSpreadMode)(value);
  5923. return _context7.abrupt("break", 24);
  5924. case 12:
  5925. this._pdfViewer.currentPageNumber = value + 1;
  5926. return _context7.abrupt("break", 24);
  5927. case 14:
  5928. _context7.next = 16;
  5929. return this._pdfViewer.pagesPromise;
  5930. case 16:
  5931. this._eventBus.dispatch("print", {
  5932. source: this
  5933. });
  5934. return _context7.abrupt("break", 24);
  5935. case 18:
  5936. console.log(value);
  5937. return _context7.abrupt("break", 24);
  5938. case 20:
  5939. if (!isInPresentationMode) {
  5940. _context7.next = 22;
  5941. break;
  5942. }
  5943. return _context7.abrupt("return");
  5944. case 22:
  5945. this._pdfViewer.currentScaleValue = value;
  5946. return _context7.abrupt("break", 24);
  5947. case 24:
  5948. return _context7.abrupt("return");
  5949. case 25:
  5950. if (!isInPresentationMode) {
  5951. _context7.next = 28;
  5952. break;
  5953. }
  5954. if (!detail.focus) {
  5955. _context7.next = 28;
  5956. break;
  5957. }
  5958. return _context7.abrupt("return");
  5959. case 28:
  5960. delete detail.id;
  5961. delete detail.siblings;
  5962. ids = siblings ? [id].concat(_toConsumableArray(siblings)) : [id];
  5963. _iterator3 = _createForOfIteratorHelper(ids);
  5964. try {
  5965. for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
  5966. elementId = _step3.value;
  5967. element = document.getElementById(elementId);
  5968. if (element) {
  5969. element.dispatchEvent(new CustomEvent("updatefromsandbox", {
  5970. detail: detail
  5971. }));
  5972. } else {
  5973. (_this$_pdfDocument = this._pdfDocument) === null || _this$_pdfDocument === void 0 ? void 0 : _this$_pdfDocument.annotationStorage.setValue(elementId, detail);
  5974. }
  5975. }
  5976. } catch (err) {
  5977. _iterator3.e(err);
  5978. } finally {
  5979. _iterator3.f();
  5980. }
  5981. case 33:
  5982. case "end":
  5983. return _context7.stop();
  5984. }
  5985. }
  5986. }, _callee7, this);
  5987. }));
  5988. function _updateFromSandbox(_x7) {
  5989. return _updateFromSandbox2.apply(this, arguments);
  5990. }
  5991. return _updateFromSandbox;
  5992. }()
  5993. }, {
  5994. key: "_dispatchPageOpen",
  5995. value: function () {
  5996. var _dispatchPageOpen2 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee9(pageNumber) {
  5997. var _this3 = this;
  5998. var initialize,
  5999. pdfDocument,
  6000. visitedPages,
  6001. pageView,
  6002. actionsPromise,
  6003. _args9 = arguments;
  6004. return _regenerator["default"].wrap(function _callee9$(_context9) {
  6005. while (1) {
  6006. switch (_context9.prev = _context9.next) {
  6007. case 0:
  6008. initialize = _args9.length > 1 && _args9[1] !== undefined ? _args9[1] : false;
  6009. pdfDocument = this._pdfDocument, visitedPages = this._visitedPages;
  6010. if (initialize) {
  6011. this._closeCapability = (0, _pdfjsLib.createPromiseCapability)();
  6012. }
  6013. if (this._closeCapability) {
  6014. _context9.next = 5;
  6015. break;
  6016. }
  6017. return _context9.abrupt("return");
  6018. case 5:
  6019. pageView = this._pdfViewer.getPageView(pageNumber - 1);
  6020. if (!((pageView === null || pageView === void 0 ? void 0 : pageView.renderingState) !== _pdf_rendering_queue.RenderingStates.FINISHED)) {
  6021. _context9.next = 9;
  6022. break;
  6023. }
  6024. this._pageOpenPending.add(pageNumber);
  6025. return _context9.abrupt("return");
  6026. case 9:
  6027. this._pageOpenPending["delete"](pageNumber);
  6028. actionsPromise = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee8() {
  6029. var _pageView$pdfPage, _this3$_scripting;
  6030. var actions;
  6031. return _regenerator["default"].wrap(function _callee8$(_context8) {
  6032. while (1) {
  6033. switch (_context8.prev = _context8.next) {
  6034. case 0:
  6035. _context8.next = 2;
  6036. return !visitedPages.has(pageNumber) ? (_pageView$pdfPage = pageView.pdfPage) === null || _pageView$pdfPage === void 0 ? void 0 : _pageView$pdfPage.getJSActions() : null;
  6037. case 2:
  6038. actions = _context8.sent;
  6039. if (!(pdfDocument !== _this3._pdfDocument)) {
  6040. _context8.next = 5;
  6041. break;
  6042. }
  6043. return _context8.abrupt("return");
  6044. case 5:
  6045. _context8.next = 7;
  6046. return (_this3$_scripting = _this3._scripting) === null || _this3$_scripting === void 0 ? void 0 : _this3$_scripting.dispatchEventInSandbox({
  6047. id: "page",
  6048. name: "PageOpen",
  6049. pageNumber: pageNumber,
  6050. actions: actions
  6051. });
  6052. case 7:
  6053. case "end":
  6054. return _context8.stop();
  6055. }
  6056. }
  6057. }, _callee8);
  6058. }))();
  6059. visitedPages.set(pageNumber, actionsPromise);
  6060. case 12:
  6061. case "end":
  6062. return _context9.stop();
  6063. }
  6064. }
  6065. }, _callee9, this);
  6066. }));
  6067. function _dispatchPageOpen(_x8) {
  6068. return _dispatchPageOpen2.apply(this, arguments);
  6069. }
  6070. return _dispatchPageOpen;
  6071. }()
  6072. }, {
  6073. key: "_dispatchPageClose",
  6074. value: function () {
  6075. var _dispatchPageClose2 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee10(pageNumber) {
  6076. var _this$_scripting6;
  6077. var pdfDocument, visitedPages, actionsPromise;
  6078. return _regenerator["default"].wrap(function _callee10$(_context10) {
  6079. while (1) {
  6080. switch (_context10.prev = _context10.next) {
  6081. case 0:
  6082. pdfDocument = this._pdfDocument, visitedPages = this._visitedPages;
  6083. if (this._closeCapability) {
  6084. _context10.next = 3;
  6085. break;
  6086. }
  6087. return _context10.abrupt("return");
  6088. case 3:
  6089. if (!this._pageOpenPending.has(pageNumber)) {
  6090. _context10.next = 5;
  6091. break;
  6092. }
  6093. return _context10.abrupt("return");
  6094. case 5:
  6095. actionsPromise = visitedPages.get(pageNumber);
  6096. if (actionsPromise) {
  6097. _context10.next = 8;
  6098. break;
  6099. }
  6100. return _context10.abrupt("return");
  6101. case 8:
  6102. visitedPages.set(pageNumber, null);
  6103. _context10.next = 11;
  6104. return actionsPromise;
  6105. case 11:
  6106. if (!(pdfDocument !== this._pdfDocument)) {
  6107. _context10.next = 13;
  6108. break;
  6109. }
  6110. return _context10.abrupt("return");
  6111. case 13:
  6112. _context10.next = 15;
  6113. return (_this$_scripting6 = this._scripting) === null || _this$_scripting6 === void 0 ? void 0 : _this$_scripting6.dispatchEventInSandbox({
  6114. id: "page",
  6115. name: "PageClose",
  6116. pageNumber: pageNumber
  6117. });
  6118. case 15:
  6119. case "end":
  6120. return _context10.stop();
  6121. }
  6122. }
  6123. }, _callee10, this);
  6124. }));
  6125. function _dispatchPageClose(_x9) {
  6126. return _dispatchPageClose2.apply(this, arguments);
  6127. }
  6128. return _dispatchPageClose;
  6129. }()
  6130. }, {
  6131. key: "_getDocProperties",
  6132. value: function () {
  6133. var _getDocProperties2 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee11() {
  6134. var _require, docPropertiesLookup;
  6135. return _regenerator["default"].wrap(function _callee11$(_context11) {
  6136. while (1) {
  6137. switch (_context11.prev = _context11.next) {
  6138. case 0:
  6139. if (!this._docPropertiesLookup) {
  6140. _context11.next = 2;
  6141. break;
  6142. }
  6143. return _context11.abrupt("return", this._docPropertiesLookup(this._pdfDocument));
  6144. case 2:
  6145. _require = __w_pdfjs_require__(19), docPropertiesLookup = _require.docPropertiesLookup;
  6146. return _context11.abrupt("return", docPropertiesLookup(this._pdfDocument));
  6147. case 4:
  6148. case "end":
  6149. return _context11.stop();
  6150. }
  6151. }
  6152. }, _callee11, this);
  6153. }));
  6154. function _getDocProperties() {
  6155. return _getDocProperties2.apply(this, arguments);
  6156. }
  6157. return _getDocProperties;
  6158. }()
  6159. }, {
  6160. key: "_createScripting",
  6161. value: function _createScripting() {
  6162. this._destroyCapability = (0, _pdfjsLib.createPromiseCapability)();
  6163. if (this._scripting) {
  6164. throw new Error("_createScripting: Scripting already exists.");
  6165. }
  6166. if (this._scriptingFactory) {
  6167. return this._scriptingFactory.createScripting({
  6168. sandboxBundleSrc: this._sandboxBundleSrc
  6169. });
  6170. }
  6171. var _require2 = __w_pdfjs_require__(19),
  6172. GenericScripting = _require2.GenericScripting;
  6173. return new GenericScripting(this._sandboxBundleSrc);
  6174. }
  6175. }, {
  6176. key: "_destroyScripting",
  6177. value: function () {
  6178. var _destroyScripting2 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee12() {
  6179. var _this$_destroyCapabil3;
  6180. var _this$_destroyCapabil2, _iterator4, _step4, _step4$value, name, listener, _iterator5, _step5, _step5$value, _name2, _listener2;
  6181. return _regenerator["default"].wrap(function _callee12$(_context12) {
  6182. while (1) {
  6183. switch (_context12.prev = _context12.next) {
  6184. case 0:
  6185. if (this._scripting) {
  6186. _context12.next = 4;
  6187. break;
  6188. }
  6189. this._pdfDocument = null;
  6190. (_this$_destroyCapabil2 = this._destroyCapability) === null || _this$_destroyCapabil2 === void 0 ? void 0 : _this$_destroyCapabil2.resolve();
  6191. return _context12.abrupt("return");
  6192. case 4:
  6193. if (!this._closeCapability) {
  6194. _context12.next = 8;
  6195. break;
  6196. }
  6197. _context12.next = 7;
  6198. return Promise.race([this._closeCapability.promise, new Promise(function (resolve) {
  6199. setTimeout(resolve, 1000);
  6200. })])["catch"](function (reason) {});
  6201. case 7:
  6202. this._closeCapability = null;
  6203. case 8:
  6204. this._pdfDocument = null;
  6205. _context12.prev = 9;
  6206. _context12.next = 12;
  6207. return this._scripting.destroySandbox();
  6208. case 12:
  6209. _context12.next = 16;
  6210. break;
  6211. case 14:
  6212. _context12.prev = 14;
  6213. _context12.t0 = _context12["catch"](9);
  6214. case 16:
  6215. _iterator4 = _createForOfIteratorHelper(this._internalEvents);
  6216. try {
  6217. for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
  6218. _step4$value = _slicedToArray(_step4.value, 2), name = _step4$value[0], listener = _step4$value[1];
  6219. this._eventBus._off(name, listener);
  6220. }
  6221. } catch (err) {
  6222. _iterator4.e(err);
  6223. } finally {
  6224. _iterator4.f();
  6225. }
  6226. this._internalEvents.clear();
  6227. _iterator5 = _createForOfIteratorHelper(this._domEvents);
  6228. try {
  6229. for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
  6230. _step5$value = _slicedToArray(_step5.value, 2), _name2 = _step5$value[0], _listener2 = _step5$value[1];
  6231. window.removeEventListener(_name2, _listener2);
  6232. }
  6233. } catch (err) {
  6234. _iterator5.e(err);
  6235. } finally {
  6236. _iterator5.f();
  6237. }
  6238. this._domEvents.clear();
  6239. this._pageOpenPending.clear();
  6240. this._visitedPages.clear();
  6241. this._scripting = null;
  6242. delete this._mouseState.isDown;
  6243. this._ready = false;
  6244. (_this$_destroyCapabil3 = this._destroyCapability) === null || _this$_destroyCapabil3 === void 0 ? void 0 : _this$_destroyCapabil3.resolve();
  6245. case 28:
  6246. case "end":
  6247. return _context12.stop();
  6248. }
  6249. }
  6250. }, _callee12, this, [[9, 14]]);
  6251. }));
  6252. function _destroyScripting() {
  6253. return _destroyScripting2.apply(this, arguments);
  6254. }
  6255. return _destroyScripting;
  6256. }()
  6257. }]);
  6258. return PDFScriptingManager;
  6259. }();
  6260. exports.PDFScriptingManager = PDFScriptingManager;
  6261. /***/ }),
  6262. /* 19 */
  6263. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  6264. Object.defineProperty(exports, "__esModule", ({
  6265. value: true
  6266. }));
  6267. exports.docPropertiesLookup = docPropertiesLookup;
  6268. exports.GenericScripting = void 0;
  6269. var _regenerator = _interopRequireDefault(__w_pdfjs_require__(4));
  6270. var _pdfjsLib = __w_pdfjs_require__(2);
  6271. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  6272. function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
  6273. function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
  6274. function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
  6275. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  6276. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  6277. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  6278. function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
  6279. function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
  6280. function docPropertiesLookup(_x) {
  6281. return _docPropertiesLookup.apply(this, arguments);
  6282. }
  6283. function _docPropertiesLookup() {
  6284. _docPropertiesLookup = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee4(pdfDocument) {
  6285. var url, baseUrl, _yield$pdfDocument$ge, info, metadata, contentDispositionFilename, contentLength, _yield$pdfDocument$ge2, length;
  6286. return _regenerator["default"].wrap(function _callee4$(_context4) {
  6287. while (1) {
  6288. switch (_context4.prev = _context4.next) {
  6289. case 0:
  6290. url = "", baseUrl = url.split("#")[0];
  6291. _context4.next = 3;
  6292. return pdfDocument.getMetadata();
  6293. case 3:
  6294. _yield$pdfDocument$ge = _context4.sent;
  6295. info = _yield$pdfDocument$ge.info;
  6296. metadata = _yield$pdfDocument$ge.metadata;
  6297. contentDispositionFilename = _yield$pdfDocument$ge.contentDispositionFilename;
  6298. contentLength = _yield$pdfDocument$ge.contentLength;
  6299. if (contentLength) {
  6300. _context4.next = 14;
  6301. break;
  6302. }
  6303. _context4.next = 11;
  6304. return pdfDocument.getDownloadInfo();
  6305. case 11:
  6306. _yield$pdfDocument$ge2 = _context4.sent;
  6307. length = _yield$pdfDocument$ge2.length;
  6308. contentLength = length;
  6309. case 14:
  6310. return _context4.abrupt("return", _objectSpread(_objectSpread({}, info), {}, {
  6311. baseURL: baseUrl,
  6312. filesize: contentLength,
  6313. filename: contentDispositionFilename || (0, _pdfjsLib.getPdfFilenameFromUrl)(url),
  6314. metadata: metadata === null || metadata === void 0 ? void 0 : metadata.getRaw(),
  6315. authors: metadata === null || metadata === void 0 ? void 0 : metadata.get("dc:creator"),
  6316. numPages: pdfDocument.numPages,
  6317. URL: url
  6318. }));
  6319. case 15:
  6320. case "end":
  6321. return _context4.stop();
  6322. }
  6323. }
  6324. }, _callee4);
  6325. }));
  6326. return _docPropertiesLookup.apply(this, arguments);
  6327. }
  6328. var GenericScripting = /*#__PURE__*/function () {
  6329. function GenericScripting(sandboxBundleSrc) {
  6330. _classCallCheck(this, GenericScripting);
  6331. this._ready = (0, _pdfjsLib.loadScript)(sandboxBundleSrc, true).then(function () {
  6332. return window.pdfjsSandbox.QuickJSSandbox();
  6333. });
  6334. }
  6335. _createClass(GenericScripting, [{
  6336. key: "createSandbox",
  6337. value: function () {
  6338. var _createSandbox = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee(data) {
  6339. var sandbox;
  6340. return _regenerator["default"].wrap(function _callee$(_context) {
  6341. while (1) {
  6342. switch (_context.prev = _context.next) {
  6343. case 0:
  6344. _context.next = 2;
  6345. return this._ready;
  6346. case 2:
  6347. sandbox = _context.sent;
  6348. sandbox.create(data);
  6349. case 4:
  6350. case "end":
  6351. return _context.stop();
  6352. }
  6353. }
  6354. }, _callee, this);
  6355. }));
  6356. function createSandbox(_x2) {
  6357. return _createSandbox.apply(this, arguments);
  6358. }
  6359. return createSandbox;
  6360. }()
  6361. }, {
  6362. key: "dispatchEventInSandbox",
  6363. value: function () {
  6364. var _dispatchEventInSandbox = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee2(event) {
  6365. var sandbox;
  6366. return _regenerator["default"].wrap(function _callee2$(_context2) {
  6367. while (1) {
  6368. switch (_context2.prev = _context2.next) {
  6369. case 0:
  6370. _context2.next = 2;
  6371. return this._ready;
  6372. case 2:
  6373. sandbox = _context2.sent;
  6374. sandbox.dispatchEvent(event);
  6375. case 4:
  6376. case "end":
  6377. return _context2.stop();
  6378. }
  6379. }
  6380. }, _callee2, this);
  6381. }));
  6382. function dispatchEventInSandbox(_x3) {
  6383. return _dispatchEventInSandbox.apply(this, arguments);
  6384. }
  6385. return dispatchEventInSandbox;
  6386. }()
  6387. }, {
  6388. key: "destroySandbox",
  6389. value: function () {
  6390. var _destroySandbox = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee3() {
  6391. var sandbox;
  6392. return _regenerator["default"].wrap(function _callee3$(_context3) {
  6393. while (1) {
  6394. switch (_context3.prev = _context3.next) {
  6395. case 0:
  6396. _context3.next = 2;
  6397. return this._ready;
  6398. case 2:
  6399. sandbox = _context3.sent;
  6400. sandbox.nukeSandbox();
  6401. case 4:
  6402. case "end":
  6403. return _context3.stop();
  6404. }
  6405. }
  6406. }, _callee3, this);
  6407. }));
  6408. function destroySandbox() {
  6409. return _destroySandbox.apply(this, arguments);
  6410. }
  6411. return destroySandbox;
  6412. }()
  6413. }]);
  6414. return GenericScripting;
  6415. }();
  6416. exports.GenericScripting = GenericScripting;
  6417. /***/ }),
  6418. /* 20 */
  6419. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  6420. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  6421. Object.defineProperty(exports, "__esModule", ({
  6422. value: true
  6423. }));
  6424. exports.PDFSinglePageViewer = void 0;
  6425. var _base_viewer = __w_pdfjs_require__(21);
  6426. var _pdfjsLib = __w_pdfjs_require__(2);
  6427. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  6428. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  6429. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  6430. function _get(target, property, receiver) { if (typeof Reflect !== "undefined" && Reflect.get) { _get = Reflect.get; } else { _get = function _get(target, property, receiver) { var base = _superPropBase(target, property); if (!base) return; var desc = Object.getOwnPropertyDescriptor(base, property); if (desc.get) { return desc.get.call(receiver); } return desc.value; }; } return _get(target, property, receiver || target); }
  6431. function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
  6432. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  6433. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  6434. function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  6435. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  6436. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  6437. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
  6438. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  6439. var PDFSinglePageViewer = /*#__PURE__*/function (_BaseViewer) {
  6440. _inherits(PDFSinglePageViewer, _BaseViewer);
  6441. var _super = _createSuper(PDFSinglePageViewer);
  6442. function PDFSinglePageViewer(options) {
  6443. var _this;
  6444. _classCallCheck(this, PDFSinglePageViewer);
  6445. _this = _super.call(this, options);
  6446. _this.eventBus._on("pagesinit", function (evt) {
  6447. _this._ensurePageViewVisible();
  6448. });
  6449. return _this;
  6450. }
  6451. _createClass(PDFSinglePageViewer, [{
  6452. key: "_viewerElement",
  6453. get: function get() {
  6454. return (0, _pdfjsLib.shadow)(this, "_viewerElement", this._shadowViewer);
  6455. }
  6456. }, {
  6457. key: "_pageWidthScaleFactor",
  6458. get: function get() {
  6459. return 1;
  6460. }
  6461. }, {
  6462. key: "_resetView",
  6463. value: function _resetView() {
  6464. _get(_getPrototypeOf(PDFSinglePageViewer.prototype), "_resetView", this).call(this);
  6465. this._previousPageNumber = 1;
  6466. this._shadowViewer = document.createDocumentFragment();
  6467. this._updateScrollDown = null;
  6468. }
  6469. }, {
  6470. key: "_ensurePageViewVisible",
  6471. value: function _ensurePageViewVisible() {
  6472. var pageView = this._pages[this._currentPageNumber - 1];
  6473. var previousPageView = this._pages[this._previousPageNumber - 1];
  6474. var viewerNodes = this.viewer.childNodes;
  6475. switch (viewerNodes.length) {
  6476. case 0:
  6477. this.viewer.appendChild(pageView.div);
  6478. break;
  6479. case 1:
  6480. if (viewerNodes[0] !== previousPageView.div) {
  6481. throw new Error("_ensurePageViewVisible: Unexpected previously visible page.");
  6482. }
  6483. if (pageView === previousPageView) {
  6484. break;
  6485. }
  6486. this._shadowViewer.appendChild(previousPageView.div);
  6487. this.viewer.appendChild(pageView.div);
  6488. this.container.scrollTop = 0;
  6489. break;
  6490. default:
  6491. throw new Error("_ensurePageViewVisible: Only one page should be visible at a time.");
  6492. }
  6493. this._previousPageNumber = this._currentPageNumber;
  6494. }
  6495. }, {
  6496. key: "_scrollUpdate",
  6497. value: function _scrollUpdate() {
  6498. if (this._updateScrollDown) {
  6499. this._updateScrollDown();
  6500. }
  6501. _get(_getPrototypeOf(PDFSinglePageViewer.prototype), "_scrollUpdate", this).call(this);
  6502. }
  6503. }, {
  6504. key: "_scrollIntoView",
  6505. value: function _scrollIntoView(_ref) {
  6506. var _this2 = this;
  6507. var pageDiv = _ref.pageDiv,
  6508. _ref$pageSpot = _ref.pageSpot,
  6509. pageSpot = _ref$pageSpot === void 0 ? null : _ref$pageSpot,
  6510. _ref$pageNumber = _ref.pageNumber,
  6511. pageNumber = _ref$pageNumber === void 0 ? null : _ref$pageNumber;
  6512. if (pageNumber) {
  6513. this._setCurrentPageNumber(pageNumber);
  6514. }
  6515. var scrolledDown = this._currentPageNumber >= this._previousPageNumber;
  6516. this._ensurePageViewVisible();
  6517. this.update();
  6518. _get(_getPrototypeOf(PDFSinglePageViewer.prototype), "_scrollIntoView", this).call(this, {
  6519. pageDiv: pageDiv,
  6520. pageSpot: pageSpot,
  6521. pageNumber: pageNumber
  6522. });
  6523. this._updateScrollDown = function () {
  6524. _this2.scroll.down = scrolledDown;
  6525. _this2._updateScrollDown = null;
  6526. };
  6527. }
  6528. }, {
  6529. key: "_getVisiblePages",
  6530. value: function _getVisiblePages() {
  6531. return this._getCurrentVisiblePage();
  6532. }
  6533. }, {
  6534. key: "_updateHelper",
  6535. value: function _updateHelper(visiblePages) {}
  6536. }, {
  6537. key: "_isScrollModeHorizontal",
  6538. get: function get() {
  6539. return (0, _pdfjsLib.shadow)(this, "_isScrollModeHorizontal", false);
  6540. }
  6541. }, {
  6542. key: "_updateScrollMode",
  6543. value: function _updateScrollMode() {}
  6544. }, {
  6545. key: "_updateSpreadMode",
  6546. value: function _updateSpreadMode() {}
  6547. }, {
  6548. key: "_getPageAdvance",
  6549. value: function _getPageAdvance() {
  6550. return 1;
  6551. }
  6552. }]);
  6553. return PDFSinglePageViewer;
  6554. }(_base_viewer.BaseViewer);
  6555. exports.PDFSinglePageViewer = PDFSinglePageViewer;
  6556. /***/ }),
  6557. /* 21 */
  6558. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  6559. Object.defineProperty(exports, "__esModule", ({
  6560. value: true
  6561. }));
  6562. exports.BaseViewer = void 0;
  6563. var _pdfjsLib = __w_pdfjs_require__(2);
  6564. var _ui_utils = __w_pdfjs_require__(7);
  6565. var _pdf_rendering_queue = __w_pdfjs_require__(17);
  6566. var _annotation_layer_builder = __w_pdfjs_require__(1);
  6567. var _l10n_utils = __w_pdfjs_require__(3);
  6568. var _pdf_page_view = __w_pdfjs_require__(16);
  6569. var _pdf_link_service = __w_pdfjs_require__(6);
  6570. var _struct_tree_layer_builder = __w_pdfjs_require__(22);
  6571. var _text_layer_builder = __w_pdfjs_require__(8);
  6572. var _xfa_layer_builder = __w_pdfjs_require__(23);
  6573. function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
  6574. function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
  6575. function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
  6576. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  6577. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  6578. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  6579. var DEFAULT_CACHE_SIZE = 10;
  6580. function PDFPageViewBuffer(size) {
  6581. var data = [];
  6582. this.push = function (view) {
  6583. var i = data.indexOf(view);
  6584. if (i >= 0) {
  6585. data.splice(i, 1);
  6586. }
  6587. data.push(view);
  6588. if (data.length > size) {
  6589. data.shift().destroy();
  6590. }
  6591. };
  6592. this.resize = function (newSize, pagesToKeep) {
  6593. size = newSize;
  6594. if (pagesToKeep) {
  6595. var pageIdsToKeep = new Set();
  6596. for (var i = 0, iMax = pagesToKeep.length; i < iMax; ++i) {
  6597. pageIdsToKeep.add(pagesToKeep[i].id);
  6598. }
  6599. (0, _ui_utils.moveToEndOfArray)(data, function (page) {
  6600. return pageIdsToKeep.has(page.id);
  6601. });
  6602. }
  6603. while (data.length > size) {
  6604. data.shift().destroy();
  6605. }
  6606. };
  6607. this.has = function (view) {
  6608. return data.includes(view);
  6609. };
  6610. }
  6611. function isSameScale(oldScale, newScale) {
  6612. if (newScale === oldScale) {
  6613. return true;
  6614. }
  6615. if (Math.abs(newScale - oldScale) < 1e-15) {
  6616. return true;
  6617. }
  6618. return false;
  6619. }
  6620. var BaseViewer = /*#__PURE__*/function () {
  6621. function BaseViewer(options) {
  6622. var _this$container,
  6623. _this$viewer,
  6624. _this = this;
  6625. _classCallCheck(this, BaseViewer);
  6626. if (this.constructor === BaseViewer) {
  6627. throw new Error("Cannot initialize BaseViewer.");
  6628. }
  6629. var viewerVersion = '2.10.377';
  6630. if (_pdfjsLib.version !== viewerVersion) {
  6631. throw new Error("The API version \"".concat(_pdfjsLib.version, "\" does not match the Viewer version \"").concat(viewerVersion, "\"."));
  6632. }
  6633. this._name = this.constructor.name;
  6634. this.container = options.container;
  6635. this.viewer = options.viewer || options.container.firstElementChild;
  6636. if (!(((_this$container = this.container) === null || _this$container === void 0 ? void 0 : _this$container.tagName.toUpperCase()) === "DIV" && ((_this$viewer = this.viewer) === null || _this$viewer === void 0 ? void 0 : _this$viewer.tagName.toUpperCase()) === "DIV")) {
  6637. throw new Error("Invalid `container` and/or `viewer` option.");
  6638. }
  6639. if (this.container.offsetParent && getComputedStyle(this.container).position !== "absolute") {
  6640. throw new Error("The `container` must be absolutely positioned.");
  6641. }
  6642. this.eventBus = options.eventBus;
  6643. this.linkService = options.linkService || new _pdf_link_service.SimpleLinkService();
  6644. this.downloadManager = options.downloadManager || null;
  6645. this.findController = options.findController || null;
  6646. this._scriptingManager = options.scriptingManager || null;
  6647. this.removePageBorders = options.removePageBorders || false;
  6648. this.textLayerMode = Number.isInteger(options.textLayerMode) ? options.textLayerMode : _ui_utils.TextLayerMode.ENABLE;
  6649. this.imageResourcesPath = options.imageResourcesPath || "";
  6650. this.renderInteractiveForms = options.renderInteractiveForms !== false;
  6651. this.enablePrintAutoRotate = options.enablePrintAutoRotate || false;
  6652. this.renderer = options.renderer || _ui_utils.RendererType.CANVAS;
  6653. this.useOnlyCssZoom = options.useOnlyCssZoom || false;
  6654. this.maxCanvasPixels = options.maxCanvasPixels;
  6655. this.l10n = options.l10n || _l10n_utils.NullL10n;
  6656. this.enableScripting = options.enableScripting === true && !!this._scriptingManager;
  6657. this.defaultRenderingQueue = !options.renderingQueue;
  6658. if (this.defaultRenderingQueue) {
  6659. this.renderingQueue = new _pdf_rendering_queue.PDFRenderingQueue();
  6660. this.renderingQueue.setViewer(this);
  6661. } else {
  6662. this.renderingQueue = options.renderingQueue;
  6663. }
  6664. this.scroll = (0, _ui_utils.watchScroll)(this.container, this._scrollUpdate.bind(this));
  6665. this.presentationModeState = _ui_utils.PresentationModeState.UNKNOWN;
  6666. this._onBeforeDraw = this._onAfterDraw = null;
  6667. this._resetView();
  6668. if (this.removePageBorders) {
  6669. this.viewer.classList.add("removePageBorders");
  6670. }
  6671. Promise.resolve().then(function () {
  6672. _this.eventBus.dispatch("baseviewerinit", {
  6673. source: _this
  6674. });
  6675. });
  6676. }
  6677. _createClass(BaseViewer, [{
  6678. key: "pagesCount",
  6679. get: function get() {
  6680. return this._pages.length;
  6681. }
  6682. }, {
  6683. key: "getPageView",
  6684. value: function getPageView(index) {
  6685. return this._pages[index];
  6686. }
  6687. }, {
  6688. key: "pageViewsReady",
  6689. get: function get() {
  6690. if (!this._pagesCapability.settled) {
  6691. return false;
  6692. }
  6693. return this._pages.every(function (pageView) {
  6694. return pageView === null || pageView === void 0 ? void 0 : pageView.pdfPage;
  6695. });
  6696. }
  6697. }, {
  6698. key: "currentPageNumber",
  6699. get: function get() {
  6700. return this._currentPageNumber;
  6701. },
  6702. set: function set(val) {
  6703. if (!Number.isInteger(val)) {
  6704. throw new Error("Invalid page number.");
  6705. }
  6706. if (!this.pdfDocument) {
  6707. return;
  6708. }
  6709. if (!this._setCurrentPageNumber(val, true)) {
  6710. console.error("".concat(this._name, ".currentPageNumber: \"").concat(val, "\" is not a valid page."));
  6711. }
  6712. }
  6713. }, {
  6714. key: "_setCurrentPageNumber",
  6715. value: function _setCurrentPageNumber(val) {
  6716. var _this$_pageLabels, _this$_pageLabels2;
  6717. var resetCurrentPageView = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  6718. if (this._currentPageNumber === val) {
  6719. if (resetCurrentPageView) {
  6720. this._resetCurrentPageView();
  6721. }
  6722. return true;
  6723. }
  6724. if (!(0 < val && val <= this.pagesCount)) {
  6725. return false;
  6726. }
  6727. var previous = this._currentPageNumber;
  6728. this._currentPageNumber = val;
  6729. this.eventBus.dispatch("pagechanging", {
  6730. source: this,
  6731. pageNumber: val,
  6732. pageLabel: (_this$_pageLabels = (_this$_pageLabels2 = this._pageLabels) === null || _this$_pageLabels2 === void 0 ? void 0 : _this$_pageLabels2[val - 1]) !== null && _this$_pageLabels !== void 0 ? _this$_pageLabels : null,
  6733. previous: previous
  6734. });
  6735. if (resetCurrentPageView) {
  6736. this._resetCurrentPageView();
  6737. }
  6738. return true;
  6739. }
  6740. }, {
  6741. key: "currentPageLabel",
  6742. get: function get() {
  6743. var _this$_pageLabels3, _this$_pageLabels4;
  6744. return (_this$_pageLabels3 = (_this$_pageLabels4 = this._pageLabels) === null || _this$_pageLabels4 === void 0 ? void 0 : _this$_pageLabels4[this._currentPageNumber - 1]) !== null && _this$_pageLabels3 !== void 0 ? _this$_pageLabels3 : null;
  6745. },
  6746. set: function set(val) {
  6747. if (!this.pdfDocument) {
  6748. return;
  6749. }
  6750. var page = val | 0;
  6751. if (this._pageLabels) {
  6752. var i = this._pageLabels.indexOf(val);
  6753. if (i >= 0) {
  6754. page = i + 1;
  6755. }
  6756. }
  6757. if (!this._setCurrentPageNumber(page, true)) {
  6758. console.error("".concat(this._name, ".currentPageLabel: \"").concat(val, "\" is not a valid page."));
  6759. }
  6760. }
  6761. }, {
  6762. key: "currentScale",
  6763. get: function get() {
  6764. return this._currentScale !== _ui_utils.UNKNOWN_SCALE ? this._currentScale : _ui_utils.DEFAULT_SCALE;
  6765. },
  6766. set: function set(val) {
  6767. if (isNaN(val)) {
  6768. throw new Error("Invalid numeric scale.");
  6769. }
  6770. if (!this.pdfDocument) {
  6771. return;
  6772. }
  6773. this._setScale(val, false);
  6774. }
  6775. }, {
  6776. key: "currentScaleValue",
  6777. get: function get() {
  6778. return this._currentScaleValue;
  6779. },
  6780. set: function set(val) {
  6781. if (!this.pdfDocument) {
  6782. return;
  6783. }
  6784. this._setScale(val, false);
  6785. }
  6786. }, {
  6787. key: "pagesRotation",
  6788. get: function get() {
  6789. return this._pagesRotation;
  6790. },
  6791. set: function set(rotation) {
  6792. if (!(0, _ui_utils.isValidRotation)(rotation)) {
  6793. throw new Error("Invalid pages rotation angle.");
  6794. }
  6795. if (!this.pdfDocument) {
  6796. return;
  6797. }
  6798. rotation %= 360;
  6799. if (rotation < 0) {
  6800. rotation += 360;
  6801. }
  6802. if (this._pagesRotation === rotation) {
  6803. return;
  6804. }
  6805. this._pagesRotation = rotation;
  6806. var pageNumber = this._currentPageNumber;
  6807. for (var i = 0, ii = this._pages.length; i < ii; i++) {
  6808. var pageView = this._pages[i];
  6809. pageView.update(pageView.scale, rotation);
  6810. }
  6811. if (this._currentScaleValue) {
  6812. this._setScale(this._currentScaleValue, true);
  6813. }
  6814. this.eventBus.dispatch("rotationchanging", {
  6815. source: this,
  6816. pagesRotation: rotation,
  6817. pageNumber: pageNumber
  6818. });
  6819. if (this.defaultRenderingQueue) {
  6820. this.update();
  6821. }
  6822. }
  6823. }, {
  6824. key: "firstPagePromise",
  6825. get: function get() {
  6826. return this.pdfDocument ? this._firstPageCapability.promise : null;
  6827. }
  6828. }, {
  6829. key: "onePageRendered",
  6830. get: function get() {
  6831. return this.pdfDocument ? this._onePageRenderedCapability.promise : null;
  6832. }
  6833. }, {
  6834. key: "pagesPromise",
  6835. get: function get() {
  6836. return this.pdfDocument ? this._pagesCapability.promise : null;
  6837. }
  6838. }, {
  6839. key: "_viewerElement",
  6840. get: function get() {
  6841. throw new Error("Not implemented: _viewerElement");
  6842. }
  6843. }, {
  6844. key: "_onePageRenderedOrForceFetch",
  6845. value: function _onePageRenderedOrForceFetch() {
  6846. if (!this.container.offsetParent || this._getVisiblePages().views.length === 0) {
  6847. return Promise.resolve();
  6848. }
  6849. return this._onePageRenderedCapability.promise;
  6850. }
  6851. }, {
  6852. key: "setDocument",
  6853. value: function setDocument(pdfDocument) {
  6854. var _this2 = this;
  6855. if (this.pdfDocument) {
  6856. this.eventBus.dispatch("pagesdestroy", {
  6857. source: this
  6858. });
  6859. this._cancelRendering();
  6860. this._resetView();
  6861. if (this.findController) {
  6862. this.findController.setDocument(null);
  6863. }
  6864. if (this._scriptingManager) {
  6865. this._scriptingManager.setDocument(null);
  6866. }
  6867. }
  6868. this.pdfDocument = pdfDocument;
  6869. if (!pdfDocument) {
  6870. return;
  6871. }
  6872. var isPureXfa = pdfDocument.isPureXfa;
  6873. var pagesCount = pdfDocument.numPages;
  6874. var firstPagePromise = pdfDocument.getPage(1);
  6875. var optionalContentConfigPromise = pdfDocument.getOptionalContentConfig();
  6876. this._pagesCapability.promise.then(function () {
  6877. _this2.eventBus.dispatch("pagesloaded", {
  6878. source: _this2,
  6879. pagesCount: pagesCount
  6880. });
  6881. });
  6882. this._onBeforeDraw = function (evt) {
  6883. var pageView = _this2._pages[evt.pageNumber - 1];
  6884. if (!pageView) {
  6885. return;
  6886. }
  6887. _this2._buffer.push(pageView);
  6888. };
  6889. this.eventBus._on("pagerender", this._onBeforeDraw);
  6890. this._onAfterDraw = function (evt) {
  6891. if (evt.cssTransform || _this2._onePageRenderedCapability.settled) {
  6892. return;
  6893. }
  6894. _this2._onePageRenderedCapability.resolve();
  6895. _this2.eventBus._off("pagerendered", _this2._onAfterDraw);
  6896. _this2._onAfterDraw = null;
  6897. };
  6898. this.eventBus._on("pagerendered", this._onAfterDraw);
  6899. firstPagePromise.then(function (firstPdfPage) {
  6900. _this2._firstPageCapability.resolve(firstPdfPage);
  6901. _this2._optionalContentConfigPromise = optionalContentConfigPromise;
  6902. var scale = _this2.currentScale;
  6903. var viewport = firstPdfPage.getViewport({
  6904. scale: scale * _ui_utils.CSS_UNITS
  6905. });
  6906. var textLayerFactory = _this2.textLayerMode !== _ui_utils.TextLayerMode.DISABLE ? _this2 : null;
  6907. var xfaLayerFactory = isPureXfa ? _this2 : null;
  6908. for (var pageNum = 1; pageNum <= pagesCount; ++pageNum) {
  6909. var pageView = new _pdf_page_view.PDFPageView({
  6910. container: _this2._viewerElement,
  6911. eventBus: _this2.eventBus,
  6912. id: pageNum,
  6913. scale: scale,
  6914. defaultViewport: viewport.clone(),
  6915. optionalContentConfigPromise: optionalContentConfigPromise,
  6916. renderingQueue: _this2.renderingQueue,
  6917. textLayerFactory: textLayerFactory,
  6918. textLayerMode: _this2.textLayerMode,
  6919. annotationLayerFactory: _this2,
  6920. xfaLayerFactory: xfaLayerFactory,
  6921. structTreeLayerFactory: _this2,
  6922. imageResourcesPath: _this2.imageResourcesPath,
  6923. renderInteractiveForms: _this2.renderInteractiveForms,
  6924. renderer: _this2.renderer,
  6925. useOnlyCssZoom: _this2.useOnlyCssZoom,
  6926. maxCanvasPixels: _this2.maxCanvasPixels,
  6927. l10n: _this2.l10n
  6928. });
  6929. _this2._pages.push(pageView);
  6930. }
  6931. var firstPageView = _this2._pages[0];
  6932. if (firstPageView) {
  6933. firstPageView.setPdfPage(firstPdfPage);
  6934. _this2.linkService.cachePageRef(1, firstPdfPage.ref);
  6935. }
  6936. if (_this2._spreadMode !== _ui_utils.SpreadMode.NONE) {
  6937. _this2._updateSpreadMode();
  6938. }
  6939. _this2._onePageRenderedOrForceFetch().then(function () {
  6940. if (_this2.findController) {
  6941. _this2.findController.setDocument(pdfDocument);
  6942. }
  6943. if (_this2.enableScripting) {
  6944. _this2._scriptingManager.setDocument(pdfDocument);
  6945. }
  6946. if (pdfDocument.loadingParams.disableAutoFetch || pagesCount > 7500) {
  6947. _this2._pagesCapability.resolve();
  6948. return;
  6949. }
  6950. var getPagesLeft = pagesCount - 1;
  6951. if (getPagesLeft <= 0) {
  6952. _this2._pagesCapability.resolve();
  6953. return;
  6954. }
  6955. var _loop = function _loop(_pageNum) {
  6956. pdfDocument.getPage(_pageNum).then(function (pdfPage) {
  6957. var pageView = _this2._pages[_pageNum - 1];
  6958. if (!pageView.pdfPage) {
  6959. pageView.setPdfPage(pdfPage);
  6960. }
  6961. _this2.linkService.cachePageRef(_pageNum, pdfPage.ref);
  6962. if (--getPagesLeft === 0) {
  6963. _this2._pagesCapability.resolve();
  6964. }
  6965. }, function (reason) {
  6966. console.error("Unable to get page ".concat(_pageNum, " to initialize viewer"), reason);
  6967. if (--getPagesLeft === 0) {
  6968. _this2._pagesCapability.resolve();
  6969. }
  6970. });
  6971. };
  6972. for (var _pageNum = 2; _pageNum <= pagesCount; ++_pageNum) {
  6973. _loop(_pageNum);
  6974. }
  6975. });
  6976. _this2.eventBus.dispatch("pagesinit", {
  6977. source: _this2
  6978. });
  6979. if (_this2.defaultRenderingQueue) {
  6980. _this2.update();
  6981. }
  6982. })["catch"](function (reason) {
  6983. console.error("Unable to initialize viewer", reason);
  6984. });
  6985. }
  6986. }, {
  6987. key: "setPageLabels",
  6988. value: function setPageLabels(labels) {
  6989. if (!this.pdfDocument) {
  6990. return;
  6991. }
  6992. if (!labels) {
  6993. this._pageLabels = null;
  6994. } else if (!(Array.isArray(labels) && this.pdfDocument.numPages === labels.length)) {
  6995. this._pageLabels = null;
  6996. console.error("".concat(this._name, ".setPageLabels: Invalid page labels."));
  6997. } else {
  6998. this._pageLabels = labels;
  6999. }
  7000. for (var i = 0, ii = this._pages.length; i < ii; i++) {
  7001. var _this$_pageLabels$i, _this$_pageLabels5;
  7002. this._pages[i].setPageLabel((_this$_pageLabels$i = (_this$_pageLabels5 = this._pageLabels) === null || _this$_pageLabels5 === void 0 ? void 0 : _this$_pageLabels5[i]) !== null && _this$_pageLabels$i !== void 0 ? _this$_pageLabels$i : null);
  7003. }
  7004. }
  7005. }, {
  7006. key: "_resetView",
  7007. value: function _resetView() {
  7008. this._pages = [];
  7009. this._currentPageNumber = 1;
  7010. this._currentScale = _ui_utils.UNKNOWN_SCALE;
  7011. this._currentScaleValue = null;
  7012. this._pageLabels = null;
  7013. this._buffer = new PDFPageViewBuffer(DEFAULT_CACHE_SIZE);
  7014. this._location = null;
  7015. this._pagesRotation = 0;
  7016. this._optionalContentConfigPromise = null;
  7017. this._pagesRequests = new WeakMap();
  7018. this._firstPageCapability = (0, _pdfjsLib.createPromiseCapability)();
  7019. this._onePageRenderedCapability = (0, _pdfjsLib.createPromiseCapability)();
  7020. this._pagesCapability = (0, _pdfjsLib.createPromiseCapability)();
  7021. this._scrollMode = _ui_utils.ScrollMode.VERTICAL;
  7022. this._spreadMode = _ui_utils.SpreadMode.NONE;
  7023. if (this._onBeforeDraw) {
  7024. this.eventBus._off("pagerender", this._onBeforeDraw);
  7025. this._onBeforeDraw = null;
  7026. }
  7027. if (this._onAfterDraw) {
  7028. this.eventBus._off("pagerendered", this._onAfterDraw);
  7029. this._onAfterDraw = null;
  7030. }
  7031. this.viewer.textContent = "";
  7032. this._updateScrollMode();
  7033. }
  7034. }, {
  7035. key: "_scrollUpdate",
  7036. value: function _scrollUpdate() {
  7037. if (this.pagesCount === 0) {
  7038. return;
  7039. }
  7040. this.update();
  7041. }
  7042. }, {
  7043. key: "_scrollIntoView",
  7044. value: function _scrollIntoView(_ref) {
  7045. var pageDiv = _ref.pageDiv,
  7046. _ref$pageSpot = _ref.pageSpot,
  7047. pageSpot = _ref$pageSpot === void 0 ? null : _ref$pageSpot,
  7048. _ref$pageNumber = _ref.pageNumber,
  7049. pageNumber = _ref$pageNumber === void 0 ? null : _ref$pageNumber;
  7050. (0, _ui_utils.scrollIntoView)(pageDiv, pageSpot);
  7051. }
  7052. }, {
  7053. key: "_setScaleUpdatePages",
  7054. value: function _setScaleUpdatePages(newScale, newValue) {
  7055. var noScroll = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  7056. var preset = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
  7057. this._currentScaleValue = newValue.toString();
  7058. if (isSameScale(this._currentScale, newScale)) {
  7059. if (preset) {
  7060. this.eventBus.dispatch("scalechanging", {
  7061. source: this,
  7062. scale: newScale,
  7063. presetValue: newValue
  7064. });
  7065. }
  7066. return;
  7067. }
  7068. for (var i = 0, ii = this._pages.length; i < ii; i++) {
  7069. this._pages[i].update(newScale);
  7070. }
  7071. this._currentScale = newScale;
  7072. if (!noScroll) {
  7073. var page = this._currentPageNumber,
  7074. dest;
  7075. if (this._location && !(this.isInPresentationMode || this.isChangingPresentationMode)) {
  7076. page = this._location.pageNumber;
  7077. dest = [null, {
  7078. name: "XYZ"
  7079. }, this._location.left, this._location.top, null];
  7080. }
  7081. this.scrollPageIntoView({
  7082. pageNumber: page,
  7083. destArray: dest,
  7084. allowNegativeOffset: true
  7085. });
  7086. }
  7087. this.eventBus.dispatch("scalechanging", {
  7088. source: this,
  7089. scale: newScale,
  7090. presetValue: preset ? newValue : undefined
  7091. });
  7092. if (this.defaultRenderingQueue) {
  7093. this.update();
  7094. }
  7095. }
  7096. }, {
  7097. key: "_pageWidthScaleFactor",
  7098. get: function get() {
  7099. if (this._spreadMode !== _ui_utils.SpreadMode.NONE && this._scrollMode !== _ui_utils.ScrollMode.HORIZONTAL && !this.isInPresentationMode) {
  7100. return 2;
  7101. }
  7102. return 1;
  7103. }
  7104. }, {
  7105. key: "_setScale",
  7106. value: function _setScale(value) {
  7107. var noScroll = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  7108. var scale = parseFloat(value);
  7109. if (scale > 0) {
  7110. this._setScaleUpdatePages(scale, value, noScroll, false);
  7111. } else {
  7112. var currentPage = this._pages[this._currentPageNumber - 1];
  7113. if (!currentPage) {
  7114. return;
  7115. }
  7116. var noPadding = this.isInPresentationMode || this.removePageBorders;
  7117. var hPadding = noPadding ? 0 : _ui_utils.SCROLLBAR_PADDING;
  7118. var vPadding = noPadding ? 0 : _ui_utils.VERTICAL_PADDING;
  7119. if (!noPadding && this._isScrollModeHorizontal) {
  7120. var _ref2 = [vPadding, hPadding];
  7121. hPadding = _ref2[0];
  7122. vPadding = _ref2[1];
  7123. }
  7124. var pageWidthScale = (this.container.clientWidth - hPadding) / currentPage.width * currentPage.scale / this._pageWidthScaleFactor;
  7125. var pageHeightScale = (this.container.clientHeight - vPadding) / currentPage.height * currentPage.scale;
  7126. switch (value) {
  7127. case "page-actual":
  7128. scale = 1;
  7129. break;
  7130. case "page-width":
  7131. scale = pageWidthScale;
  7132. break;
  7133. case "page-height":
  7134. scale = pageHeightScale;
  7135. break;
  7136. case "page-fit":
  7137. scale = Math.min(pageWidthScale, pageHeightScale);
  7138. break;
  7139. case "auto":
  7140. var horizontalScale = (0, _ui_utils.isPortraitOrientation)(currentPage) ? pageWidthScale : Math.min(pageHeightScale, pageWidthScale);
  7141. scale = Math.min(_ui_utils.MAX_AUTO_SCALE, horizontalScale);
  7142. break;
  7143. default:
  7144. console.error("".concat(this._name, "._setScale: \"").concat(value, "\" is an unknown zoom value."));
  7145. return;
  7146. }
  7147. this._setScaleUpdatePages(scale, value, noScroll, true);
  7148. }
  7149. }
  7150. }, {
  7151. key: "_resetCurrentPageView",
  7152. value: function _resetCurrentPageView() {
  7153. if (this.isInPresentationMode) {
  7154. this._setScale(this._currentScaleValue, true);
  7155. }
  7156. var pageView = this._pages[this._currentPageNumber - 1];
  7157. this._scrollIntoView({
  7158. pageDiv: pageView.div
  7159. });
  7160. }
  7161. }, {
  7162. key: "pageLabelToPageNumber",
  7163. value: function pageLabelToPageNumber(label) {
  7164. if (!this._pageLabels) {
  7165. return null;
  7166. }
  7167. var i = this._pageLabels.indexOf(label);
  7168. if (i < 0) {
  7169. return null;
  7170. }
  7171. return i + 1;
  7172. }
  7173. }, {
  7174. key: "scrollPageIntoView",
  7175. value: function scrollPageIntoView(_ref3) {
  7176. var pageNumber = _ref3.pageNumber,
  7177. _ref3$destArray = _ref3.destArray,
  7178. destArray = _ref3$destArray === void 0 ? null : _ref3$destArray,
  7179. _ref3$allowNegativeOf = _ref3.allowNegativeOffset,
  7180. allowNegativeOffset = _ref3$allowNegativeOf === void 0 ? false : _ref3$allowNegativeOf,
  7181. _ref3$ignoreDestinati = _ref3.ignoreDestinationZoom,
  7182. ignoreDestinationZoom = _ref3$ignoreDestinati === void 0 ? false : _ref3$ignoreDestinati;
  7183. if (!this.pdfDocument) {
  7184. return;
  7185. }
  7186. var pageView = Number.isInteger(pageNumber) && this._pages[pageNumber - 1];
  7187. if (!pageView) {
  7188. console.error("".concat(this._name, ".scrollPageIntoView: ") + "\"".concat(pageNumber, "\" is not a valid pageNumber parameter."));
  7189. return;
  7190. }
  7191. if (this.isInPresentationMode || !destArray) {
  7192. this._setCurrentPageNumber(pageNumber, true);
  7193. return;
  7194. }
  7195. var x = 0,
  7196. y = 0;
  7197. var width = 0,
  7198. height = 0,
  7199. widthScale,
  7200. heightScale;
  7201. var changeOrientation = pageView.rotation % 180 !== 0;
  7202. var pageWidth = (changeOrientation ? pageView.height : pageView.width) / pageView.scale / _ui_utils.CSS_UNITS;
  7203. var pageHeight = (changeOrientation ? pageView.width : pageView.height) / pageView.scale / _ui_utils.CSS_UNITS;
  7204. var scale = 0;
  7205. switch (destArray[1].name) {
  7206. case "XYZ":
  7207. x = destArray[2];
  7208. y = destArray[3];
  7209. scale = destArray[4];
  7210. x = x !== null ? x : 0;
  7211. y = y !== null ? y : pageHeight;
  7212. break;
  7213. case "Fit":
  7214. case "FitB":
  7215. scale = "page-fit";
  7216. break;
  7217. case "FitH":
  7218. case "FitBH":
  7219. y = destArray[2];
  7220. scale = "page-width";
  7221. if (y === null && this._location) {
  7222. x = this._location.left;
  7223. y = this._location.top;
  7224. } else if (typeof y !== "number") {
  7225. y = pageHeight;
  7226. }
  7227. break;
  7228. case "FitV":
  7229. case "FitBV":
  7230. x = destArray[2];
  7231. width = pageWidth;
  7232. height = pageHeight;
  7233. scale = "page-height";
  7234. break;
  7235. case "FitR":
  7236. x = destArray[2];
  7237. y = destArray[3];
  7238. width = destArray[4] - x;
  7239. height = destArray[5] - y;
  7240. var hPadding = this.removePageBorders ? 0 : _ui_utils.SCROLLBAR_PADDING;
  7241. var vPadding = this.removePageBorders ? 0 : _ui_utils.VERTICAL_PADDING;
  7242. widthScale = (this.container.clientWidth - hPadding) / width / _ui_utils.CSS_UNITS;
  7243. heightScale = (this.container.clientHeight - vPadding) / height / _ui_utils.CSS_UNITS;
  7244. scale = Math.min(Math.abs(widthScale), Math.abs(heightScale));
  7245. break;
  7246. default:
  7247. console.error("".concat(this._name, ".scrollPageIntoView: ") + "\"".concat(destArray[1].name, "\" is not a valid destination type."));
  7248. return;
  7249. }
  7250. if (!ignoreDestinationZoom) {
  7251. if (scale && scale !== this._currentScale) {
  7252. this.currentScaleValue = scale;
  7253. } else if (this._currentScale === _ui_utils.UNKNOWN_SCALE) {
  7254. this.currentScaleValue = _ui_utils.DEFAULT_SCALE_VALUE;
  7255. }
  7256. }
  7257. if (scale === "page-fit" && !destArray[4]) {
  7258. this._scrollIntoView({
  7259. pageDiv: pageView.div,
  7260. pageNumber: pageNumber
  7261. });
  7262. return;
  7263. }
  7264. var boundingRect = [pageView.viewport.convertToViewportPoint(x, y), pageView.viewport.convertToViewportPoint(x + width, y + height)];
  7265. var left = Math.min(boundingRect[0][0], boundingRect[1][0]);
  7266. var top = Math.min(boundingRect[0][1], boundingRect[1][1]);
  7267. if (!allowNegativeOffset) {
  7268. left = Math.max(left, 0);
  7269. top = Math.max(top, 0);
  7270. }
  7271. this._scrollIntoView({
  7272. pageDiv: pageView.div,
  7273. pageSpot: {
  7274. left: left,
  7275. top: top
  7276. },
  7277. pageNumber: pageNumber
  7278. });
  7279. }
  7280. }, {
  7281. key: "_updateLocation",
  7282. value: function _updateLocation(firstPage) {
  7283. var currentScale = this._currentScale;
  7284. var currentScaleValue = this._currentScaleValue;
  7285. var normalizedScaleValue = parseFloat(currentScaleValue) === currentScale ? Math.round(currentScale * 10000) / 100 : currentScaleValue;
  7286. var pageNumber = firstPage.id;
  7287. var pdfOpenParams = "#page=" + pageNumber;
  7288. pdfOpenParams += "&zoom=" + normalizedScaleValue;
  7289. var currentPageView = this._pages[pageNumber - 1];
  7290. var container = this.container;
  7291. var topLeft = currentPageView.getPagePoint(container.scrollLeft - firstPage.x, container.scrollTop - firstPage.y);
  7292. var intLeft = Math.round(topLeft[0]);
  7293. var intTop = Math.round(topLeft[1]);
  7294. pdfOpenParams += "," + intLeft + "," + intTop;
  7295. this._location = {
  7296. pageNumber: pageNumber,
  7297. scale: normalizedScaleValue,
  7298. top: intTop,
  7299. left: intLeft,
  7300. rotation: this._pagesRotation,
  7301. pdfOpenParams: pdfOpenParams
  7302. };
  7303. }
  7304. }, {
  7305. key: "_updateHelper",
  7306. value: function _updateHelper(visiblePages) {
  7307. throw new Error("Not implemented: _updateHelper");
  7308. }
  7309. }, {
  7310. key: "update",
  7311. value: function update() {
  7312. var visible = this._getVisiblePages();
  7313. var visiblePages = visible.views,
  7314. numVisiblePages = visiblePages.length;
  7315. if (numVisiblePages === 0) {
  7316. return;
  7317. }
  7318. var newCacheSize = Math.max(DEFAULT_CACHE_SIZE, 2 * numVisiblePages + 1);
  7319. this._buffer.resize(newCacheSize, visiblePages);
  7320. this.renderingQueue.renderHighestPriority(visible);
  7321. this._updateHelper(visiblePages);
  7322. this._updateLocation(visible.first);
  7323. this.eventBus.dispatch("updateviewarea", {
  7324. source: this,
  7325. location: this._location
  7326. });
  7327. }
  7328. }, {
  7329. key: "containsElement",
  7330. value: function containsElement(element) {
  7331. return this.container.contains(element);
  7332. }
  7333. }, {
  7334. key: "focus",
  7335. value: function focus() {
  7336. this.container.focus();
  7337. }
  7338. }, {
  7339. key: "_isScrollModeHorizontal",
  7340. get: function get() {
  7341. return this.isInPresentationMode ? false : this._scrollMode === _ui_utils.ScrollMode.HORIZONTAL;
  7342. }
  7343. }, {
  7344. key: "_isContainerRtl",
  7345. get: function get() {
  7346. return getComputedStyle(this.container).direction === "rtl";
  7347. }
  7348. }, {
  7349. key: "isInPresentationMode",
  7350. get: function get() {
  7351. return this.presentationModeState === _ui_utils.PresentationModeState.FULLSCREEN;
  7352. }
  7353. }, {
  7354. key: "isChangingPresentationMode",
  7355. get: function get() {
  7356. return this.presentationModeState === _ui_utils.PresentationModeState.CHANGING;
  7357. }
  7358. }, {
  7359. key: "isHorizontalScrollbarEnabled",
  7360. get: function get() {
  7361. return this.isInPresentationMode ? false : this.container.scrollWidth > this.container.clientWidth;
  7362. }
  7363. }, {
  7364. key: "isVerticalScrollbarEnabled",
  7365. get: function get() {
  7366. return this.isInPresentationMode ? false : this.container.scrollHeight > this.container.clientHeight;
  7367. }
  7368. }, {
  7369. key: "_getCurrentVisiblePage",
  7370. value: function _getCurrentVisiblePage() {
  7371. if (!this.pagesCount) {
  7372. return {
  7373. views: []
  7374. };
  7375. }
  7376. var pageView = this._pages[this._currentPageNumber - 1];
  7377. var element = pageView.div;
  7378. var view = {
  7379. id: pageView.id,
  7380. x: element.offsetLeft + element.clientLeft,
  7381. y: element.offsetTop + element.clientTop,
  7382. view: pageView
  7383. };
  7384. return {
  7385. first: view,
  7386. last: view,
  7387. views: [view]
  7388. };
  7389. }
  7390. }, {
  7391. key: "_getVisiblePages",
  7392. value: function _getVisiblePages() {
  7393. return (0, _ui_utils.getVisibleElements)({
  7394. scrollEl: this.container,
  7395. views: this._pages,
  7396. sortByVisibility: true,
  7397. horizontal: this._isScrollModeHorizontal,
  7398. rtl: this._isScrollModeHorizontal && this._isContainerRtl
  7399. });
  7400. }
  7401. }, {
  7402. key: "isPageVisible",
  7403. value: function isPageVisible(pageNumber) {
  7404. if (!this.pdfDocument) {
  7405. return false;
  7406. }
  7407. if (!(Number.isInteger(pageNumber) && pageNumber > 0 && pageNumber <= this.pagesCount)) {
  7408. console.error("".concat(this._name, ".isPageVisible: \"").concat(pageNumber, "\" is not a valid page."));
  7409. return false;
  7410. }
  7411. return this._getVisiblePages().views.some(function (view) {
  7412. return view.id === pageNumber;
  7413. });
  7414. }
  7415. }, {
  7416. key: "isPageCached",
  7417. value: function isPageCached(pageNumber) {
  7418. if (!this.pdfDocument || !this._buffer) {
  7419. return false;
  7420. }
  7421. if (!(Number.isInteger(pageNumber) && pageNumber > 0 && pageNumber <= this.pagesCount)) {
  7422. console.error("".concat(this._name, ".isPageCached: \"").concat(pageNumber, "\" is not a valid page."));
  7423. return false;
  7424. }
  7425. var pageView = this._pages[pageNumber - 1];
  7426. if (!pageView) {
  7427. return false;
  7428. }
  7429. return this._buffer.has(pageView);
  7430. }
  7431. }, {
  7432. key: "cleanup",
  7433. value: function cleanup() {
  7434. for (var i = 0, ii = this._pages.length; i < ii; i++) {
  7435. if (this._pages[i] && this._pages[i].renderingState !== _pdf_rendering_queue.RenderingStates.FINISHED) {
  7436. this._pages[i].reset();
  7437. }
  7438. }
  7439. }
  7440. }, {
  7441. key: "_cancelRendering",
  7442. value: function _cancelRendering() {
  7443. for (var i = 0, ii = this._pages.length; i < ii; i++) {
  7444. if (this._pages[i]) {
  7445. this._pages[i].cancelRendering();
  7446. }
  7447. }
  7448. }
  7449. }, {
  7450. key: "_ensurePdfPageLoaded",
  7451. value: function _ensurePdfPageLoaded(pageView) {
  7452. var _this3 = this;
  7453. if (pageView.pdfPage) {
  7454. return Promise.resolve(pageView.pdfPage);
  7455. }
  7456. if (this._pagesRequests.has(pageView)) {
  7457. return this._pagesRequests.get(pageView);
  7458. }
  7459. var promise = this.pdfDocument.getPage(pageView.id).then(function (pdfPage) {
  7460. if (!pageView.pdfPage) {
  7461. pageView.setPdfPage(pdfPage);
  7462. }
  7463. _this3._pagesRequests["delete"](pageView);
  7464. return pdfPage;
  7465. })["catch"](function (reason) {
  7466. console.error("Unable to get page for page view", reason);
  7467. _this3._pagesRequests["delete"](pageView);
  7468. });
  7469. this._pagesRequests.set(pageView, promise);
  7470. return promise;
  7471. }
  7472. }, {
  7473. key: "forceRendering",
  7474. value: function forceRendering(currentlyVisiblePages) {
  7475. var _this4 = this;
  7476. var visiblePages = currentlyVisiblePages || this._getVisiblePages();
  7477. var scrollAhead = this._isScrollModeHorizontal ? this.scroll.right : this.scroll.down;
  7478. var pageView = this.renderingQueue.getHighestPriority(visiblePages, this._pages, scrollAhead);
  7479. if (pageView) {
  7480. this._ensurePdfPageLoaded(pageView).then(function () {
  7481. _this4.renderingQueue.renderView(pageView);
  7482. });
  7483. return true;
  7484. }
  7485. return false;
  7486. }
  7487. }, {
  7488. key: "createTextLayerBuilder",
  7489. value: function createTextLayerBuilder(textLayerDiv, pageIndex, viewport) {
  7490. var enhanceTextSelection = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
  7491. var eventBus = arguments.length > 4 ? arguments[4] : undefined;
  7492. return new _text_layer_builder.TextLayerBuilder({
  7493. textLayerDiv: textLayerDiv,
  7494. eventBus: eventBus,
  7495. pageIndex: pageIndex,
  7496. viewport: viewport,
  7497. findController: this.isInPresentationMode ? null : this.findController,
  7498. enhanceTextSelection: this.isInPresentationMode ? false : enhanceTextSelection
  7499. });
  7500. }
  7501. }, {
  7502. key: "createAnnotationLayerBuilder",
  7503. value: function createAnnotationLayerBuilder(pageDiv, pdfPage) {
  7504. var _this$pdfDocument, _this$pdfDocument2, _this$_scriptingManag;
  7505. var annotationStorage = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
  7506. var imageResourcesPath = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : "";
  7507. var renderInteractiveForms = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
  7508. var l10n = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : _l10n_utils.NullL10n;
  7509. var enableScripting = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : null;
  7510. var hasJSActionsPromise = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : null;
  7511. var mouseState = arguments.length > 8 && arguments[8] !== undefined ? arguments[8] : null;
  7512. return new _annotation_layer_builder.AnnotationLayerBuilder({
  7513. pageDiv: pageDiv,
  7514. pdfPage: pdfPage,
  7515. annotationStorage: annotationStorage || ((_this$pdfDocument = this.pdfDocument) === null || _this$pdfDocument === void 0 ? void 0 : _this$pdfDocument.annotationStorage),
  7516. imageResourcesPath: imageResourcesPath,
  7517. renderInteractiveForms: renderInteractiveForms,
  7518. linkService: this.linkService,
  7519. downloadManager: this.downloadManager,
  7520. l10n: l10n,
  7521. enableScripting: enableScripting !== null && enableScripting !== void 0 ? enableScripting : this.enableScripting,
  7522. hasJSActionsPromise: hasJSActionsPromise || ((_this$pdfDocument2 = this.pdfDocument) === null || _this$pdfDocument2 === void 0 ? void 0 : _this$pdfDocument2.hasJSActions()),
  7523. mouseState: mouseState || ((_this$_scriptingManag = this._scriptingManager) === null || _this$_scriptingManag === void 0 ? void 0 : _this$_scriptingManag.mouseState)
  7524. });
  7525. }
  7526. }, {
  7527. key: "createXfaLayerBuilder",
  7528. value: function createXfaLayerBuilder(pageDiv, pdfPage) {
  7529. var _this$pdfDocument3;
  7530. var annotationStorage = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
  7531. return new _xfa_layer_builder.XfaLayerBuilder({
  7532. pageDiv: pageDiv,
  7533. pdfPage: pdfPage,
  7534. annotationStorage: annotationStorage || ((_this$pdfDocument3 = this.pdfDocument) === null || _this$pdfDocument3 === void 0 ? void 0 : _this$pdfDocument3.annotationStorage)
  7535. });
  7536. }
  7537. }, {
  7538. key: "createStructTreeLayerBuilder",
  7539. value: function createStructTreeLayerBuilder(pdfPage) {
  7540. return new _struct_tree_layer_builder.StructTreeLayerBuilder({
  7541. pdfPage: pdfPage
  7542. });
  7543. }
  7544. }, {
  7545. key: "hasEqualPageSizes",
  7546. get: function get() {
  7547. var firstPageView = this._pages[0];
  7548. for (var i = 1, ii = this._pages.length; i < ii; ++i) {
  7549. var pageView = this._pages[i];
  7550. if (pageView.width !== firstPageView.width || pageView.height !== firstPageView.height) {
  7551. return false;
  7552. }
  7553. }
  7554. return true;
  7555. }
  7556. }, {
  7557. key: "getPagesOverview",
  7558. value: function getPagesOverview() {
  7559. var _this5 = this;
  7560. return this._pages.map(function (pageView) {
  7561. var viewport = pageView.pdfPage.getViewport({
  7562. scale: 1
  7563. });
  7564. if (!_this5.enablePrintAutoRotate || (0, _ui_utils.isPortraitOrientation)(viewport)) {
  7565. return {
  7566. width: viewport.width,
  7567. height: viewport.height,
  7568. rotation: viewport.rotation
  7569. };
  7570. }
  7571. return {
  7572. width: viewport.height,
  7573. height: viewport.width,
  7574. rotation: (viewport.rotation - 90) % 360
  7575. };
  7576. });
  7577. }
  7578. }, {
  7579. key: "optionalContentConfigPromise",
  7580. get: function get() {
  7581. if (!this.pdfDocument) {
  7582. return Promise.resolve(null);
  7583. }
  7584. if (!this._optionalContentConfigPromise) {
  7585. return this.pdfDocument.getOptionalContentConfig();
  7586. }
  7587. return this._optionalContentConfigPromise;
  7588. },
  7589. set: function set(promise) {
  7590. if (!(promise instanceof Promise)) {
  7591. throw new Error("Invalid optionalContentConfigPromise: ".concat(promise));
  7592. }
  7593. if (!this.pdfDocument) {
  7594. return;
  7595. }
  7596. if (!this._optionalContentConfigPromise) {
  7597. return;
  7598. }
  7599. this._optionalContentConfigPromise = promise;
  7600. var _iterator = _createForOfIteratorHelper(this._pages),
  7601. _step;
  7602. try {
  7603. for (_iterator.s(); !(_step = _iterator.n()).done;) {
  7604. var pageView = _step.value;
  7605. pageView.update(pageView.scale, pageView.rotation, promise);
  7606. }
  7607. } catch (err) {
  7608. _iterator.e(err);
  7609. } finally {
  7610. _iterator.f();
  7611. }
  7612. this.update();
  7613. this.eventBus.dispatch("optionalcontentconfigchanged", {
  7614. source: this,
  7615. promise: promise
  7616. });
  7617. }
  7618. }, {
  7619. key: "scrollMode",
  7620. get: function get() {
  7621. return this._scrollMode;
  7622. },
  7623. set: function set(mode) {
  7624. if (this._scrollMode === mode) {
  7625. return;
  7626. }
  7627. if (!(0, _ui_utils.isValidScrollMode)(mode)) {
  7628. throw new Error("Invalid scroll mode: ".concat(mode));
  7629. }
  7630. this._scrollMode = mode;
  7631. this.eventBus.dispatch("scrollmodechanged", {
  7632. source: this,
  7633. mode: mode
  7634. });
  7635. this._updateScrollMode(this._currentPageNumber);
  7636. }
  7637. }, {
  7638. key: "_updateScrollMode",
  7639. value: function _updateScrollMode() {
  7640. var pageNumber = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
  7641. var scrollMode = this._scrollMode,
  7642. viewer = this.viewer;
  7643. viewer.classList.toggle("scrollHorizontal", scrollMode === _ui_utils.ScrollMode.HORIZONTAL);
  7644. viewer.classList.toggle("scrollWrapped", scrollMode === _ui_utils.ScrollMode.WRAPPED);
  7645. if (!this.pdfDocument || !pageNumber) {
  7646. return;
  7647. }
  7648. if (this._currentScaleValue && isNaN(this._currentScaleValue)) {
  7649. this._setScale(this._currentScaleValue, true);
  7650. }
  7651. this._setCurrentPageNumber(pageNumber, true);
  7652. this.update();
  7653. }
  7654. }, {
  7655. key: "spreadMode",
  7656. get: function get() {
  7657. return this._spreadMode;
  7658. },
  7659. set: function set(mode) {
  7660. if (this._spreadMode === mode) {
  7661. return;
  7662. }
  7663. if (!(0, _ui_utils.isValidSpreadMode)(mode)) {
  7664. throw new Error("Invalid spread mode: ".concat(mode));
  7665. }
  7666. this._spreadMode = mode;
  7667. this.eventBus.dispatch("spreadmodechanged", {
  7668. source: this,
  7669. mode: mode
  7670. });
  7671. this._updateSpreadMode(this._currentPageNumber);
  7672. }
  7673. }, {
  7674. key: "_updateSpreadMode",
  7675. value: function _updateSpreadMode() {
  7676. var pageNumber = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
  7677. if (!this.pdfDocument) {
  7678. return;
  7679. }
  7680. var viewer = this.viewer,
  7681. pages = this._pages;
  7682. viewer.textContent = "";
  7683. if (this._spreadMode === _ui_utils.SpreadMode.NONE) {
  7684. for (var i = 0, iMax = pages.length; i < iMax; ++i) {
  7685. viewer.appendChild(pages[i].div);
  7686. }
  7687. } else {
  7688. var parity = this._spreadMode - 1;
  7689. var spread = null;
  7690. for (var _i = 0, _iMax = pages.length; _i < _iMax; ++_i) {
  7691. if (spread === null) {
  7692. spread = document.createElement("div");
  7693. spread.className = "spread";
  7694. viewer.appendChild(spread);
  7695. } else if (_i % 2 === parity) {
  7696. spread = spread.cloneNode(false);
  7697. viewer.appendChild(spread);
  7698. }
  7699. spread.appendChild(pages[_i].div);
  7700. }
  7701. }
  7702. if (!pageNumber) {
  7703. return;
  7704. }
  7705. if (this._currentScaleValue && isNaN(this._currentScaleValue)) {
  7706. this._setScale(this._currentScaleValue, true);
  7707. }
  7708. this._setCurrentPageNumber(pageNumber, true);
  7709. this.update();
  7710. }
  7711. }, {
  7712. key: "_getPageAdvance",
  7713. value: function _getPageAdvance(currentPageNumber) {
  7714. var previous = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  7715. if (this.isInPresentationMode) {
  7716. return 1;
  7717. }
  7718. switch (this._scrollMode) {
  7719. case _ui_utils.ScrollMode.WRAPPED:
  7720. {
  7721. var _this$_getVisiblePage = this._getVisiblePages(),
  7722. views = _this$_getVisiblePage.views,
  7723. pageLayout = new Map();
  7724. var _iterator2 = _createForOfIteratorHelper(views),
  7725. _step2;
  7726. try {
  7727. for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
  7728. var _step2$value = _step2.value,
  7729. id = _step2$value.id,
  7730. y = _step2$value.y,
  7731. percent = _step2$value.percent,
  7732. widthPercent = _step2$value.widthPercent;
  7733. if (percent === 0 || widthPercent < 100) {
  7734. continue;
  7735. }
  7736. var yArray = pageLayout.get(y);
  7737. if (!yArray) {
  7738. pageLayout.set(y, yArray || (yArray = []));
  7739. }
  7740. yArray.push(id);
  7741. }
  7742. } catch (err) {
  7743. _iterator2.e(err);
  7744. } finally {
  7745. _iterator2.f();
  7746. }
  7747. var _iterator3 = _createForOfIteratorHelper(pageLayout.values()),
  7748. _step3;
  7749. try {
  7750. for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
  7751. var _yArray = _step3.value;
  7752. var currentIndex = _yArray.indexOf(currentPageNumber);
  7753. if (currentIndex === -1) {
  7754. continue;
  7755. }
  7756. var numPages = _yArray.length;
  7757. if (numPages === 1) {
  7758. break;
  7759. }
  7760. if (previous) {
  7761. for (var i = currentIndex - 1, ii = 0; i >= ii; i--) {
  7762. var currentId = _yArray[i],
  7763. expectedId = _yArray[i + 1] - 1;
  7764. if (currentId < expectedId) {
  7765. return currentPageNumber - expectedId;
  7766. }
  7767. }
  7768. } else {
  7769. for (var _i2 = currentIndex + 1, _ii = numPages; _i2 < _ii; _i2++) {
  7770. var _currentId = _yArray[_i2],
  7771. _expectedId = _yArray[_i2 - 1] + 1;
  7772. if (_currentId > _expectedId) {
  7773. return _expectedId - currentPageNumber;
  7774. }
  7775. }
  7776. }
  7777. if (previous) {
  7778. var firstId = _yArray[0];
  7779. if (firstId < currentPageNumber) {
  7780. return currentPageNumber - firstId + 1;
  7781. }
  7782. } else {
  7783. var lastId = _yArray[numPages - 1];
  7784. if (lastId > currentPageNumber) {
  7785. return lastId - currentPageNumber + 1;
  7786. }
  7787. }
  7788. break;
  7789. }
  7790. } catch (err) {
  7791. _iterator3.e(err);
  7792. } finally {
  7793. _iterator3.f();
  7794. }
  7795. break;
  7796. }
  7797. case _ui_utils.ScrollMode.HORIZONTAL:
  7798. {
  7799. break;
  7800. }
  7801. case _ui_utils.ScrollMode.VERTICAL:
  7802. {
  7803. if (this._spreadMode === _ui_utils.SpreadMode.NONE) {
  7804. break;
  7805. }
  7806. var parity = this._spreadMode - 1;
  7807. if (previous && currentPageNumber % 2 !== parity) {
  7808. break;
  7809. } else if (!previous && currentPageNumber % 2 === parity) {
  7810. break;
  7811. }
  7812. var _this$_getVisiblePage2 = this._getVisiblePages(),
  7813. _views = _this$_getVisiblePage2.views,
  7814. _expectedId2 = previous ? currentPageNumber - 1 : currentPageNumber + 1;
  7815. var _iterator4 = _createForOfIteratorHelper(_views),
  7816. _step4;
  7817. try {
  7818. for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
  7819. var _step4$value = _step4.value,
  7820. _id = _step4$value.id,
  7821. _percent = _step4$value.percent,
  7822. _widthPercent = _step4$value.widthPercent;
  7823. if (_id !== _expectedId2) {
  7824. continue;
  7825. }
  7826. if (_percent > 0 && _widthPercent === 100) {
  7827. return 2;
  7828. }
  7829. break;
  7830. }
  7831. } catch (err) {
  7832. _iterator4.e(err);
  7833. } finally {
  7834. _iterator4.f();
  7835. }
  7836. break;
  7837. }
  7838. }
  7839. return 1;
  7840. }
  7841. }, {
  7842. key: "nextPage",
  7843. value: function nextPage() {
  7844. var currentPageNumber = this._currentPageNumber,
  7845. pagesCount = this.pagesCount;
  7846. if (currentPageNumber >= pagesCount) {
  7847. return false;
  7848. }
  7849. var advance = this._getPageAdvance(currentPageNumber, false) || 1;
  7850. this.currentPageNumber = Math.min(currentPageNumber + advance, pagesCount);
  7851. return true;
  7852. }
  7853. }, {
  7854. key: "previousPage",
  7855. value: function previousPage() {
  7856. var currentPageNumber = this._currentPageNumber;
  7857. if (currentPageNumber <= 1) {
  7858. return false;
  7859. }
  7860. var advance = this._getPageAdvance(currentPageNumber, true) || 1;
  7861. this.currentPageNumber = Math.max(currentPageNumber - advance, 1);
  7862. return true;
  7863. }
  7864. }]);
  7865. return BaseViewer;
  7866. }();
  7867. exports.BaseViewer = BaseViewer;
  7868. /***/ }),
  7869. /* 22 */
  7870. /***/ ((__unused_webpack_module, exports) => {
  7871. Object.defineProperty(exports, "__esModule", ({
  7872. value: true
  7873. }));
  7874. exports.StructTreeLayerBuilder = exports.DefaultStructTreeLayerFactory = void 0;
  7875. function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
  7876. function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
  7877. function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
  7878. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  7879. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  7880. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  7881. var PDF_ROLE_TO_HTML_ROLE = {
  7882. Document: null,
  7883. DocumentFragment: null,
  7884. Part: "group",
  7885. Sect: "group",
  7886. Div: "group",
  7887. Aside: "note",
  7888. NonStruct: "none",
  7889. P: null,
  7890. H: "heading",
  7891. Title: null,
  7892. FENote: "note",
  7893. Sub: "group",
  7894. Lbl: null,
  7895. Span: null,
  7896. Em: null,
  7897. Strong: null,
  7898. Link: "link",
  7899. Annot: "note",
  7900. Form: "form",
  7901. Ruby: null,
  7902. RB: null,
  7903. RT: null,
  7904. RP: null,
  7905. Warichu: null,
  7906. WT: null,
  7907. WP: null,
  7908. L: "list",
  7909. LI: "listitem",
  7910. LBody: null,
  7911. Table: "table",
  7912. TR: "row",
  7913. TH: "columnheader",
  7914. TD: "cell",
  7915. THead: "columnheader",
  7916. TBody: null,
  7917. TFoot: null,
  7918. Caption: null,
  7919. Figure: "figure",
  7920. Formula: null,
  7921. Artifact: null
  7922. };
  7923. var HEADING_PATTERN = /^H(\d+)$/;
  7924. var StructTreeLayerBuilder = /*#__PURE__*/function () {
  7925. function StructTreeLayerBuilder(_ref) {
  7926. var pdfPage = _ref.pdfPage;
  7927. _classCallCheck(this, StructTreeLayerBuilder);
  7928. this.pdfPage = pdfPage;
  7929. }
  7930. _createClass(StructTreeLayerBuilder, [{
  7931. key: "render",
  7932. value: function render(structTree) {
  7933. return this._walk(structTree);
  7934. }
  7935. }, {
  7936. key: "_setAttributes",
  7937. value: function _setAttributes(structElement, htmlElement) {
  7938. if (structElement.alt !== undefined) {
  7939. htmlElement.setAttribute("aria-label", structElement.alt);
  7940. }
  7941. if (structElement.id !== undefined) {
  7942. htmlElement.setAttribute("aria-owns", structElement.id);
  7943. }
  7944. }
  7945. }, {
  7946. key: "_walk",
  7947. value: function _walk(node) {
  7948. if (!node) {
  7949. return null;
  7950. }
  7951. var element = document.createElement("span");
  7952. if ("role" in node) {
  7953. var role = node.role;
  7954. var match = role.match(HEADING_PATTERN);
  7955. if (match) {
  7956. element.setAttribute("role", "heading");
  7957. element.setAttribute("aria-level", match[1]);
  7958. } else if (PDF_ROLE_TO_HTML_ROLE[role]) {
  7959. element.setAttribute("role", PDF_ROLE_TO_HTML_ROLE[role]);
  7960. }
  7961. }
  7962. this._setAttributes(node, element);
  7963. if (node.children) {
  7964. if (node.children.length === 1 && "id" in node.children[0]) {
  7965. this._setAttributes(node.children[0], element);
  7966. } else {
  7967. var _iterator = _createForOfIteratorHelper(node.children),
  7968. _step;
  7969. try {
  7970. for (_iterator.s(); !(_step = _iterator.n()).done;) {
  7971. var kid = _step.value;
  7972. element.appendChild(this._walk(kid));
  7973. }
  7974. } catch (err) {
  7975. _iterator.e(err);
  7976. } finally {
  7977. _iterator.f();
  7978. }
  7979. }
  7980. }
  7981. return element;
  7982. }
  7983. }]);
  7984. return StructTreeLayerBuilder;
  7985. }();
  7986. exports.StructTreeLayerBuilder = StructTreeLayerBuilder;
  7987. var DefaultStructTreeLayerFactory = /*#__PURE__*/function () {
  7988. function DefaultStructTreeLayerFactory() {
  7989. _classCallCheck(this, DefaultStructTreeLayerFactory);
  7990. }
  7991. _createClass(DefaultStructTreeLayerFactory, [{
  7992. key: "createStructTreeLayerBuilder",
  7993. value: function createStructTreeLayerBuilder(pdfPage) {
  7994. return new StructTreeLayerBuilder({
  7995. pdfPage: pdfPage
  7996. });
  7997. }
  7998. }]);
  7999. return DefaultStructTreeLayerFactory;
  8000. }();
  8001. exports.DefaultStructTreeLayerFactory = DefaultStructTreeLayerFactory;
  8002. /***/ }),
  8003. /* 23 */
  8004. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  8005. Object.defineProperty(exports, "__esModule", ({
  8006. value: true
  8007. }));
  8008. exports.XfaLayerBuilder = exports.DefaultXfaLayerFactory = void 0;
  8009. var _pdfjsLib = __w_pdfjs_require__(2);
  8010. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  8011. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  8012. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  8013. var XfaLayerBuilder = /*#__PURE__*/function () {
  8014. function XfaLayerBuilder(_ref) {
  8015. var pageDiv = _ref.pageDiv,
  8016. pdfPage = _ref.pdfPage,
  8017. xfaHtml = _ref.xfaHtml,
  8018. annotationStorage = _ref.annotationStorage;
  8019. _classCallCheck(this, XfaLayerBuilder);
  8020. this.pageDiv = pageDiv;
  8021. this.pdfPage = pdfPage;
  8022. this.xfaHtml = xfaHtml;
  8023. this.annotationStorage = annotationStorage;
  8024. this.div = null;
  8025. this._cancelled = false;
  8026. }
  8027. _createClass(XfaLayerBuilder, [{
  8028. key: "render",
  8029. value: function render(viewport) {
  8030. var _this = this;
  8031. var intent = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "display";
  8032. if (intent === "print") {
  8033. var parameters = {
  8034. viewport: viewport.clone({
  8035. dontFlip: true
  8036. }),
  8037. div: this.div,
  8038. xfa: this.xfaHtml,
  8039. page: null,
  8040. annotationStorage: this.annotationStorage,
  8041. intent: intent
  8042. };
  8043. var div = document.createElement("div");
  8044. this.pageDiv.appendChild(div);
  8045. parameters.div = div;
  8046. _pdfjsLib.XfaLayer.render(parameters);
  8047. return Promise.resolve();
  8048. }
  8049. return this.pdfPage.getXfa().then(function (xfa) {
  8050. if (_this._cancelled) {
  8051. return;
  8052. }
  8053. var parameters = {
  8054. viewport: viewport.clone({
  8055. dontFlip: true
  8056. }),
  8057. div: _this.div,
  8058. xfa: xfa,
  8059. page: _this.pdfPage,
  8060. annotationStorage: _this.annotationStorage,
  8061. intent: intent
  8062. };
  8063. if (_this.div) {
  8064. _pdfjsLib.XfaLayer.update(parameters);
  8065. } else {
  8066. _this.div = document.createElement("div");
  8067. _this.pageDiv.appendChild(_this.div);
  8068. parameters.div = _this.div;
  8069. _pdfjsLib.XfaLayer.render(parameters);
  8070. }
  8071. })["catch"](function (error) {
  8072. console.error(error);
  8073. });
  8074. }
  8075. }, {
  8076. key: "cancel",
  8077. value: function cancel() {
  8078. this._cancelled = true;
  8079. }
  8080. }, {
  8081. key: "hide",
  8082. value: function hide() {
  8083. if (!this.div) {
  8084. return;
  8085. }
  8086. this.div.hidden = true;
  8087. }
  8088. }]);
  8089. return XfaLayerBuilder;
  8090. }();
  8091. exports.XfaLayerBuilder = XfaLayerBuilder;
  8092. var DefaultXfaLayerFactory = /*#__PURE__*/function () {
  8093. function DefaultXfaLayerFactory() {
  8094. _classCallCheck(this, DefaultXfaLayerFactory);
  8095. }
  8096. _createClass(DefaultXfaLayerFactory, [{
  8097. key: "createXfaLayerBuilder",
  8098. value: function createXfaLayerBuilder(pageDiv, pdfPage) {
  8099. var annotationStorage = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
  8100. var xfaHtml = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
  8101. return new XfaLayerBuilder({
  8102. pageDiv: pageDiv,
  8103. pdfPage: pdfPage,
  8104. annotationStorage: annotationStorage,
  8105. xfaHtml: xfaHtml
  8106. });
  8107. }
  8108. }]);
  8109. return DefaultXfaLayerFactory;
  8110. }();
  8111. exports.DefaultXfaLayerFactory = DefaultXfaLayerFactory;
  8112. /***/ }),
  8113. /* 24 */
  8114. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  8115. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  8116. Object.defineProperty(exports, "__esModule", ({
  8117. value: true
  8118. }));
  8119. exports.PDFViewer = void 0;
  8120. var _ui_utils = __w_pdfjs_require__(7);
  8121. var _base_viewer = __w_pdfjs_require__(21);
  8122. var _pdfjsLib = __w_pdfjs_require__(2);
  8123. function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
  8124. function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
  8125. function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
  8126. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  8127. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  8128. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  8129. function _get(target, property, receiver) { if (typeof Reflect !== "undefined" && Reflect.get) { _get = Reflect.get; } else { _get = function _get(target, property, receiver) { var base = _superPropBase(target, property); if (!base) return; var desc = Object.getOwnPropertyDescriptor(base, property); if (desc.get) { return desc.get.call(receiver); } return desc.value; }; } return _get(target, property, receiver || target); }
  8130. function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
  8131. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  8132. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  8133. function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  8134. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  8135. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  8136. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
  8137. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  8138. var PDFViewer = /*#__PURE__*/function (_BaseViewer) {
  8139. _inherits(PDFViewer, _BaseViewer);
  8140. var _super = _createSuper(PDFViewer);
  8141. function PDFViewer() {
  8142. _classCallCheck(this, PDFViewer);
  8143. return _super.apply(this, arguments);
  8144. }
  8145. _createClass(PDFViewer, [{
  8146. key: "_viewerElement",
  8147. get: function get() {
  8148. return (0, _pdfjsLib.shadow)(this, "_viewerElement", this.viewer);
  8149. }
  8150. }, {
  8151. key: "_scrollIntoView",
  8152. value: function _scrollIntoView(_ref) {
  8153. var pageDiv = _ref.pageDiv,
  8154. _ref$pageSpot = _ref.pageSpot,
  8155. pageSpot = _ref$pageSpot === void 0 ? null : _ref$pageSpot,
  8156. _ref$pageNumber = _ref.pageNumber,
  8157. pageNumber = _ref$pageNumber === void 0 ? null : _ref$pageNumber;
  8158. if (!pageSpot && !this.isInPresentationMode) {
  8159. var left = pageDiv.offsetLeft + pageDiv.clientLeft;
  8160. var right = left + pageDiv.clientWidth;
  8161. var _this$container = this.container,
  8162. scrollLeft = _this$container.scrollLeft,
  8163. clientWidth = _this$container.clientWidth;
  8164. if (this._isScrollModeHorizontal || left < scrollLeft || right > scrollLeft + clientWidth) {
  8165. pageSpot = {
  8166. left: 0,
  8167. top: 0
  8168. };
  8169. }
  8170. }
  8171. _get(_getPrototypeOf(PDFViewer.prototype), "_scrollIntoView", this).call(this, {
  8172. pageDiv: pageDiv,
  8173. pageSpot: pageSpot,
  8174. pageNumber: pageNumber
  8175. });
  8176. }
  8177. }, {
  8178. key: "_getVisiblePages",
  8179. value: function _getVisiblePages() {
  8180. if (this.isInPresentationMode) {
  8181. return this._getCurrentVisiblePage();
  8182. }
  8183. return _get(_getPrototypeOf(PDFViewer.prototype), "_getVisiblePages", this).call(this);
  8184. }
  8185. }, {
  8186. key: "_updateHelper",
  8187. value: function _updateHelper(visiblePages) {
  8188. if (this.isInPresentationMode) {
  8189. return;
  8190. }
  8191. var currentId = this._currentPageNumber;
  8192. var stillFullyVisible = false;
  8193. var _iterator = _createForOfIteratorHelper(visiblePages),
  8194. _step;
  8195. try {
  8196. for (_iterator.s(); !(_step = _iterator.n()).done;) {
  8197. var page = _step.value;
  8198. if (page.percent < 100) {
  8199. break;
  8200. }
  8201. if (page.id === currentId && this._scrollMode === _ui_utils.ScrollMode.VERTICAL && this._spreadMode === _ui_utils.SpreadMode.NONE) {
  8202. stillFullyVisible = true;
  8203. break;
  8204. }
  8205. }
  8206. } catch (err) {
  8207. _iterator.e(err);
  8208. } finally {
  8209. _iterator.f();
  8210. }
  8211. if (!stillFullyVisible) {
  8212. currentId = visiblePages[0].id;
  8213. }
  8214. this._setCurrentPageNumber(currentId);
  8215. }
  8216. }]);
  8217. return PDFViewer;
  8218. }(_base_viewer.BaseViewer);
  8219. exports.PDFViewer = PDFViewer;
  8220. /***/ })
  8221. /******/ ]);
  8222. /************************************************************************/
  8223. /******/ // The module cache
  8224. /******/ var __webpack_module_cache__ = {};
  8225. /******/
  8226. /******/ // The require function
  8227. /******/ function __w_pdfjs_require__(moduleId) {
  8228. /******/ // Check if module is in cache
  8229. /******/ var cachedModule = __webpack_module_cache__[moduleId];
  8230. /******/ if (cachedModule !== undefined) {
  8231. /******/ return cachedModule.exports;
  8232. /******/ }
  8233. /******/ // Create a new module (and put it into the cache)
  8234. /******/ var module = __webpack_module_cache__[moduleId] = {
  8235. /******/ id: moduleId,
  8236. /******/ loaded: false,
  8237. /******/ exports: {}
  8238. /******/ };
  8239. /******/
  8240. /******/ // Execute the module function
  8241. /******/ __webpack_modules__[moduleId](module, module.exports, __w_pdfjs_require__);
  8242. /******/
  8243. /******/ // Flag the module as loaded
  8244. /******/ module.loaded = true;
  8245. /******/
  8246. /******/ // Return the exports of the module
  8247. /******/ return module.exports;
  8248. /******/ }
  8249. /******/
  8250. /************************************************************************/
  8251. /******/ /* webpack/runtime/node module decorator */
  8252. /******/ (() => {
  8253. /******/ __w_pdfjs_require__.nmd = (module) => {
  8254. /******/ module.paths = [];
  8255. /******/ if (!module.children) module.children = [];
  8256. /******/ return module;
  8257. /******/ };
  8258. /******/ })();
  8259. /******/
  8260. /************************************************************************/
  8261. var __webpack_exports__ = {};
  8262. // This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk.
  8263. (() => {
  8264. var exports = __webpack_exports__;
  8265. Object.defineProperty(exports, "__esModule", ({
  8266. value: true
  8267. }));
  8268. Object.defineProperty(exports, "AnnotationLayerBuilder", ({
  8269. enumerable: true,
  8270. get: function get() {
  8271. return _annotation_layer_builder.AnnotationLayerBuilder;
  8272. }
  8273. }));
  8274. Object.defineProperty(exports, "DefaultAnnotationLayerFactory", ({
  8275. enumerable: true,
  8276. get: function get() {
  8277. return _annotation_layer_builder.DefaultAnnotationLayerFactory;
  8278. }
  8279. }));
  8280. Object.defineProperty(exports, "DefaultTextLayerFactory", ({
  8281. enumerable: true,
  8282. get: function get() {
  8283. return _text_layer_builder.DefaultTextLayerFactory;
  8284. }
  8285. }));
  8286. Object.defineProperty(exports, "TextLayerBuilder", ({
  8287. enumerable: true,
  8288. get: function get() {
  8289. return _text_layer_builder.TextLayerBuilder;
  8290. }
  8291. }));
  8292. Object.defineProperty(exports, "EventBus", ({
  8293. enumerable: true,
  8294. get: function get() {
  8295. return _ui_utils.EventBus;
  8296. }
  8297. }));
  8298. Object.defineProperty(exports, "ProgressBar", ({
  8299. enumerable: true,
  8300. get: function get() {
  8301. return _ui_utils.ProgressBar;
  8302. }
  8303. }));
  8304. Object.defineProperty(exports, "PDFLinkService", ({
  8305. enumerable: true,
  8306. get: function get() {
  8307. return _pdf_link_service.PDFLinkService;
  8308. }
  8309. }));
  8310. Object.defineProperty(exports, "SimpleLinkService", ({
  8311. enumerable: true,
  8312. get: function get() {
  8313. return _pdf_link_service.SimpleLinkService;
  8314. }
  8315. }));
  8316. Object.defineProperty(exports, "DownloadManager", ({
  8317. enumerable: true,
  8318. get: function get() {
  8319. return _download_manager.DownloadManager;
  8320. }
  8321. }));
  8322. Object.defineProperty(exports, "GenericL10n", ({
  8323. enumerable: true,
  8324. get: function get() {
  8325. return _genericl10n.GenericL10n;
  8326. }
  8327. }));
  8328. Object.defineProperty(exports, "NullL10n", ({
  8329. enumerable: true,
  8330. get: function get() {
  8331. return _l10n_utils.NullL10n;
  8332. }
  8333. }));
  8334. Object.defineProperty(exports, "PDFFindController", ({
  8335. enumerable: true,
  8336. get: function get() {
  8337. return _pdf_find_controller.PDFFindController;
  8338. }
  8339. }));
  8340. Object.defineProperty(exports, "PDFHistory", ({
  8341. enumerable: true,
  8342. get: function get() {
  8343. return _pdf_history.PDFHistory;
  8344. }
  8345. }));
  8346. Object.defineProperty(exports, "PDFPageView", ({
  8347. enumerable: true,
  8348. get: function get() {
  8349. return _pdf_page_view.PDFPageView;
  8350. }
  8351. }));
  8352. Object.defineProperty(exports, "PDFScriptingManager", ({
  8353. enumerable: true,
  8354. get: function get() {
  8355. return _pdf_scripting_manager.PDFScriptingManager;
  8356. }
  8357. }));
  8358. Object.defineProperty(exports, "PDFSinglePageViewer", ({
  8359. enumerable: true,
  8360. get: function get() {
  8361. return _pdf_single_page_viewer.PDFSinglePageViewer;
  8362. }
  8363. }));
  8364. Object.defineProperty(exports, "PDFViewer", ({
  8365. enumerable: true,
  8366. get: function get() {
  8367. return _pdf_viewer.PDFViewer;
  8368. }
  8369. }));
  8370. var _annotation_layer_builder = __w_pdfjs_require__(1);
  8371. var _text_layer_builder = __w_pdfjs_require__(8);
  8372. var _ui_utils = __w_pdfjs_require__(7);
  8373. var _pdf_link_service = __w_pdfjs_require__(6);
  8374. var _download_manager = __w_pdfjs_require__(9);
  8375. var _genericl10n = __w_pdfjs_require__(11);
  8376. var _l10n_utils = __w_pdfjs_require__(3);
  8377. var _pdf_find_controller = __w_pdfjs_require__(13);
  8378. var _pdf_history = __w_pdfjs_require__(15);
  8379. var _pdf_page_view = __w_pdfjs_require__(16);
  8380. var _pdf_scripting_manager = __w_pdfjs_require__(18);
  8381. var _pdf_single_page_viewer = __w_pdfjs_require__(20);
  8382. var _pdf_viewer = __w_pdfjs_require__(24);
  8383. var pdfjsVersion = '2.10.377';
  8384. var pdfjsBuild = '156762c48';
  8385. })();
  8386. /******/ return __webpack_exports__;
  8387. /******/ })()
  8388. ;
  8389. });
  8390. //# sourceMappingURL=pdf_viewer.js.map