viewer.js 495 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291
  1. /**
  2. * @licstart The following is the entire license notice for the
  3. * Javascript code in this page
  4. *
  5. * Copyright 2020 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(modules) { // webpackBootstrap
  23. /******/ // The module cache
  24. /******/ var installedModules = {};
  25. /******/
  26. /******/ // The require function
  27. /******/ function __webpack_require__(moduleId) {
  28. /******/
  29. /******/ // Check if module is in cache
  30. /******/ if(installedModules[moduleId]) {
  31. /******/ return installedModules[moduleId].exports;
  32. /******/ }
  33. /******/ // Create a new module (and put it into the cache)
  34. /******/ var module = installedModules[moduleId] = {
  35. /******/ i: moduleId,
  36. /******/ l: false,
  37. /******/ exports: {}
  38. /******/ };
  39. /******/
  40. /******/ // Execute the module function
  41. /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  42. /******/
  43. /******/ // Flag the module as loaded
  44. /******/ module.l = true;
  45. /******/
  46. /******/ // Return the exports of the module
  47. /******/ return module.exports;
  48. /******/ }
  49. /******/
  50. /******/
  51. /******/ // expose the modules object (__webpack_modules__)
  52. /******/ __webpack_require__.m = modules;
  53. /******/
  54. /******/ // expose the module cache
  55. /******/ __webpack_require__.c = installedModules;
  56. /******/
  57. /******/ // define getter function for harmony exports
  58. /******/ __webpack_require__.d = function(exports, name, getter) {
  59. /******/ if(!__webpack_require__.o(exports, name)) {
  60. /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
  61. /******/ }
  62. /******/ };
  63. /******/
  64. /******/ // define __esModule on exports
  65. /******/ __webpack_require__.r = function(exports) {
  66. /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
  67. /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
  68. /******/ }
  69. /******/ Object.defineProperty(exports, '__esModule', { value: true });
  70. /******/ };
  71. /******/
  72. /******/ // create a fake namespace object
  73. /******/ // mode & 1: value is a module id, require it
  74. /******/ // mode & 2: merge all properties of value into the ns
  75. /******/ // mode & 4: return value when already ns object
  76. /******/ // mode & 8|1: behave like require
  77. /******/ __webpack_require__.t = function(value, mode) {
  78. /******/ if(mode & 1) value = __webpack_require__(value);
  79. /******/ if(mode & 8) return value;
  80. /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
  81. /******/ var ns = Object.create(null);
  82. /******/ __webpack_require__.r(ns);
  83. /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
  84. /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
  85. /******/ return ns;
  86. /******/ };
  87. /******/
  88. /******/ // getDefaultExport function for compatibility with non-harmony modules
  89. /******/ __webpack_require__.n = function(module) {
  90. /******/ var getter = module && module.__esModule ?
  91. /******/ function getDefault() { return module['default']; } :
  92. /******/ function getModuleExports() { return module; };
  93. /******/ __webpack_require__.d(getter, 'a', getter);
  94. /******/ return getter;
  95. /******/ };
  96. /******/
  97. /******/ // Object.prototype.hasOwnProperty.call
  98. /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
  99. /******/
  100. /******/ // __webpack_public_path__
  101. /******/ __webpack_require__.p = "";
  102. /******/
  103. /******/
  104. /******/ // Load entry module and return exports
  105. /******/ return __webpack_require__(__webpack_require__.s = 0);
  106. /******/ })
  107. /************************************************************************/
  108. /******/ ([
  109. /* 0 */
  110. /***/ (function(module, exports, __webpack_require__) {
  111. "use strict";
  112. ;
  113. var pdfjsWebApp, pdfjsWebAppOptions;
  114. {
  115. pdfjsWebApp = __webpack_require__(1);
  116. pdfjsWebAppOptions = __webpack_require__(6);
  117. }
  118. ;
  119. {
  120. __webpack_require__(36);
  121. }
  122. ;
  123. {
  124. __webpack_require__(41);
  125. }
  126. function getViewerConfiguration() {
  127. return {
  128. appContainer: document.body,
  129. mainContainer: document.getElementById("viewerContainer"),
  130. viewerContainer: document.getElementById("viewer"),
  131. eventBus: null,
  132. toolbar: {
  133. container: document.getElementById("toolbarViewer"),
  134. numPages: document.getElementById("numPages"),
  135. pageNumber: document.getElementById("pageNumber"),
  136. scaleSelectContainer: document.getElementById("scaleSelectContainer"),
  137. scaleSelect: document.getElementById("scaleSelect"),
  138. customScaleOption: document.getElementById("customScaleOption"),
  139. previous: document.getElementById("previous"),
  140. next: document.getElementById("next"),
  141. zoomIn: document.getElementById("zoomIn"),
  142. zoomOut: document.getElementById("zoomOut"),
  143. viewFind: document.getElementById("viewFind"),
  144. openFile: document.getElementById("openFile"),
  145. print: document.getElementById("print"),
  146. presentationModeButton: document.getElementById("presentationMode"),
  147. download: document.getElementById("download"),
  148. viewBookmark: document.getElementById("viewBookmark")
  149. },
  150. secondaryToolbar: {
  151. toolbar: document.getElementById("secondaryToolbar"),
  152. toggleButton: document.getElementById("secondaryToolbarToggle"),
  153. toolbarButtonContainer: document.getElementById("secondaryToolbarButtonContainer"),
  154. presentationModeButton: document.getElementById("secondaryPresentationMode"),
  155. openFileButton: document.getElementById("secondaryOpenFile"),
  156. printButton: document.getElementById("secondaryPrint"),
  157. downloadButton: document.getElementById("secondaryDownload"),
  158. viewBookmarkButton: document.getElementById("secondaryViewBookmark"),
  159. firstPageButton: document.getElementById("firstPage"),
  160. lastPageButton: document.getElementById("lastPage"),
  161. pageRotateCwButton: document.getElementById("pageRotateCw"),
  162. pageRotateCcwButton: document.getElementById("pageRotateCcw"),
  163. cursorSelectToolButton: document.getElementById("cursorSelectTool"),
  164. cursorHandToolButton: document.getElementById("cursorHandTool"),
  165. scrollVerticalButton: document.getElementById("scrollVertical"),
  166. scrollHorizontalButton: document.getElementById("scrollHorizontal"),
  167. scrollWrappedButton: document.getElementById("scrollWrapped"),
  168. spreadNoneButton: document.getElementById("spreadNone"),
  169. spreadOddButton: document.getElementById("spreadOdd"),
  170. spreadEvenButton: document.getElementById("spreadEven"),
  171. documentPropertiesButton: document.getElementById("documentProperties")
  172. },
  173. fullscreen: {
  174. contextFirstPage: document.getElementById("contextFirstPage"),
  175. contextLastPage: document.getElementById("contextLastPage"),
  176. contextPageRotateCw: document.getElementById("contextPageRotateCw"),
  177. contextPageRotateCcw: document.getElementById("contextPageRotateCcw")
  178. },
  179. sidebar: {
  180. outerContainer: document.getElementById("outerContainer"),
  181. viewerContainer: document.getElementById("viewerContainer"),
  182. toggleButton: document.getElementById("sidebarToggle"),
  183. thumbnailButton: document.getElementById("viewThumbnail"),
  184. outlineButton: document.getElementById("viewOutline"),
  185. attachmentsButton: document.getElementById("viewAttachments"),
  186. thumbnailView: document.getElementById("thumbnailView"),
  187. outlineView: document.getElementById("outlineView"),
  188. attachmentsView: document.getElementById("attachmentsView")
  189. },
  190. sidebarResizer: {
  191. outerContainer: document.getElementById("outerContainer"),
  192. resizer: document.getElementById("sidebarResizer")
  193. },
  194. findBar: {
  195. bar: document.getElementById("findbar"),
  196. toggleButton: document.getElementById("viewFind"),
  197. findField: document.getElementById("findInput"),
  198. highlightAllCheckbox: document.getElementById("findHighlightAll"),
  199. caseSensitiveCheckbox: document.getElementById("findMatchCase"),
  200. entireWordCheckbox: document.getElementById("findEntireWord"),
  201. findMsg: document.getElementById("findMsg"),
  202. findResultsCount: document.getElementById("findResultsCount"),
  203. findPreviousButton: document.getElementById("findPrevious"),
  204. findNextButton: document.getElementById("findNext")
  205. },
  206. passwordOverlay: {
  207. overlayName: "passwordOverlay",
  208. container: document.getElementById("passwordOverlay"),
  209. label: document.getElementById("passwordText"),
  210. input: document.getElementById("password"),
  211. submitButton: document.getElementById("passwordSubmit"),
  212. cancelButton: document.getElementById("passwordCancel")
  213. },
  214. documentProperties: {
  215. overlayName: "documentPropertiesOverlay",
  216. container: document.getElementById("documentPropertiesOverlay"),
  217. closeButton: document.getElementById("documentPropertiesClose"),
  218. fields: {
  219. fileName: document.getElementById("fileNameField"),
  220. fileSize: document.getElementById("fileSizeField"),
  221. title: document.getElementById("titleField"),
  222. author: document.getElementById("authorField"),
  223. subject: document.getElementById("subjectField"),
  224. keywords: document.getElementById("keywordsField"),
  225. creationDate: document.getElementById("creationDateField"),
  226. modificationDate: document.getElementById("modificationDateField"),
  227. creator: document.getElementById("creatorField"),
  228. producer: document.getElementById("producerField"),
  229. version: document.getElementById("versionField"),
  230. pageCount: document.getElementById("pageCountField"),
  231. pageSize: document.getElementById("pageSizeField"),
  232. linearized: document.getElementById("linearizedField")
  233. }
  234. },
  235. errorWrapper: {
  236. container: document.getElementById("errorWrapper"),
  237. errorMessage: document.getElementById("errorMessage"),
  238. closeButton: document.getElementById("errorClose"),
  239. errorMoreInfo: document.getElementById("errorMoreInfo"),
  240. moreInfoButton: document.getElementById("errorShowMore"),
  241. lessInfoButton: document.getElementById("errorShowLess")
  242. },
  243. printContainer: document.getElementById("printContainer"),
  244. openFileInputName: "fileInput",
  245. debuggerScriptPath: "./debugger.js"
  246. };
  247. }
  248. function webViewerLoad() {
  249. var config = getViewerConfiguration();
  250. window.PDFViewerApplication = pdfjsWebApp.PDFViewerApplication;
  251. window.PDFViewerApplicationOptions = pdfjsWebAppOptions.AppOptions;
  252. var event = document.createEvent("CustomEvent");
  253. event.initCustomEvent("webviewerloaded", true, true, {
  254. source: window
  255. });
  256. try {
  257. parent.document.dispatchEvent(event);
  258. } catch (ex) {
  259. console.error("webviewerloaded: ".concat(ex));
  260. document.dispatchEvent(event);
  261. }
  262. pdfjsWebApp.PDFViewerApplication.run(config);
  263. }
  264. if (document.readyState === "interactive" || document.readyState === "complete") {
  265. webViewerLoad();
  266. } else {
  267. document.addEventListener("DOMContentLoaded", webViewerLoad, true);
  268. }
  269. /***/ }),
  270. /* 1 */
  271. /***/ (function(module, exports, __webpack_require__) {
  272. "use strict";
  273. Object.defineProperty(exports, "__esModule", {
  274. value: true
  275. });
  276. exports.PDFPrintServiceFactory = exports.DefaultExternalServices = exports.PDFViewerApplication = void 0;
  277. var _regenerator = _interopRequireDefault(__webpack_require__(2));
  278. var _ui_utils = __webpack_require__(5);
  279. var _app_options = __webpack_require__(6);
  280. var _pdfjsLib = __webpack_require__(8);
  281. var _pdf_cursor_tools = __webpack_require__(9);
  282. var _pdf_rendering_queue = __webpack_require__(11);
  283. var _pdf_sidebar = __webpack_require__(12);
  284. var _overlay_manager = __webpack_require__(13);
  285. var _password_prompt = __webpack_require__(14);
  286. var _pdf_attachment_viewer = __webpack_require__(15);
  287. var _pdf_document_properties = __webpack_require__(16);
  288. var _pdf_find_bar = __webpack_require__(17);
  289. var _pdf_find_controller = __webpack_require__(18);
  290. var _pdf_history = __webpack_require__(20);
  291. var _pdf_link_service = __webpack_require__(21);
  292. var _pdf_outline_viewer = __webpack_require__(22);
  293. var _pdf_presentation_mode = __webpack_require__(23);
  294. var _pdf_sidebar_resizer = __webpack_require__(24);
  295. var _pdf_thumbnail_viewer = __webpack_require__(25);
  296. var _pdf_viewer = __webpack_require__(27);
  297. var _secondary_toolbar = __webpack_require__(32);
  298. var _toolbar = __webpack_require__(34);
  299. var _view_history = __webpack_require__(35);
  300. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  301. function _createForOfIteratorHelper(o, allowArrayLike) { var it; if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { 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 = o[Symbol.iterator](); }, 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; } } }; }
  302. function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
  303. 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."); }
  304. 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); }
  305. 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; }
  306. function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_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; }
  307. function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
  308. 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); } }
  309. 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); }); }; }
  310. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  311. 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); } }
  312. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  313. var DEFAULT_SCALE_DELTA = 1.1;
  314. var DISABLE_AUTO_FETCH_LOADING_BAR_TIMEOUT = 5000;
  315. var FORCE_PAGES_LOADED_TIMEOUT = 10000;
  316. var WHEEL_ZOOM_DISABLED_TIMEOUT = 1000;
  317. var ENABLE_PERMISSIONS_CLASS = "enablePermissions";
  318. var ViewOnLoad = {
  319. UNKNOWN: -1,
  320. PREVIOUS: 0,
  321. INITIAL: 1
  322. };
  323. var DefaultExternalServices = /*#__PURE__*/function () {
  324. function DefaultExternalServices() {
  325. _classCallCheck(this, DefaultExternalServices);
  326. throw new Error("Cannot initialize DefaultExternalServices.");
  327. }
  328. _createClass(DefaultExternalServices, null, [{
  329. key: "updateFindControlState",
  330. value: function updateFindControlState(data) {}
  331. }, {
  332. key: "updateFindMatchesCount",
  333. value: function updateFindMatchesCount(data) {}
  334. }, {
  335. key: "initPassiveLoading",
  336. value: function initPassiveLoading(callbacks) {}
  337. }, {
  338. key: "fallback",
  339. value: function fallback(data, callback) {}
  340. }, {
  341. key: "reportTelemetry",
  342. value: function reportTelemetry(data) {}
  343. }, {
  344. key: "createDownloadManager",
  345. value: function createDownloadManager(options) {
  346. throw new Error("Not implemented: createDownloadManager");
  347. }
  348. }, {
  349. key: "createPreferences",
  350. value: function createPreferences() {
  351. throw new Error("Not implemented: createPreferences");
  352. }
  353. }, {
  354. key: "createL10n",
  355. value: function createL10n(options) {
  356. throw new Error("Not implemented: createL10n");
  357. }
  358. }, {
  359. key: "supportsIntegratedFind",
  360. get: function get() {
  361. return (0, _pdfjsLib.shadow)(this, "supportsIntegratedFind", false);
  362. }
  363. }, {
  364. key: "supportsDocumentFonts",
  365. get: function get() {
  366. return (0, _pdfjsLib.shadow)(this, "supportsDocumentFonts", true);
  367. }
  368. }, {
  369. key: "supportedMouseWheelZoomModifierKeys",
  370. get: function get() {
  371. return (0, _pdfjsLib.shadow)(this, "supportedMouseWheelZoomModifierKeys", {
  372. ctrlKey: true,
  373. metaKey: true
  374. });
  375. }
  376. }, {
  377. key: "isInAutomation",
  378. get: function get() {
  379. return (0, _pdfjsLib.shadow)(this, "isInAutomation", false);
  380. }
  381. }]);
  382. return DefaultExternalServices;
  383. }();
  384. exports.DefaultExternalServices = DefaultExternalServices;
  385. var PDFViewerApplication = {
  386. initialBookmark: document.location.hash.substring(1),
  387. _initializedCapability: (0, _pdfjsLib.createPromiseCapability)(),
  388. fellback: false,
  389. appConfig: null,
  390. pdfDocument: null,
  391. pdfLoadingTask: null,
  392. printService: null,
  393. pdfViewer: null,
  394. pdfThumbnailViewer: null,
  395. pdfRenderingQueue: null,
  396. pdfPresentationMode: null,
  397. pdfDocumentProperties: null,
  398. pdfLinkService: null,
  399. pdfHistory: null,
  400. pdfSidebar: null,
  401. pdfSidebarResizer: null,
  402. pdfOutlineViewer: null,
  403. pdfAttachmentViewer: null,
  404. pdfCursorTools: null,
  405. store: null,
  406. downloadManager: null,
  407. overlayManager: null,
  408. preferences: null,
  409. toolbar: null,
  410. secondaryToolbar: null,
  411. eventBus: null,
  412. l10n: null,
  413. isInitialViewSet: false,
  414. downloadComplete: false,
  415. isViewerEmbedded: window.parent !== window,
  416. url: "",
  417. baseUrl: "",
  418. externalServices: DefaultExternalServices,
  419. _boundEvents: {},
  420. contentDispositionFilename: null,
  421. initialize: function initialize(appConfig) {
  422. var _this = this;
  423. return _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
  424. var appContainer;
  425. return _regenerator["default"].wrap(function _callee$(_context) {
  426. while (1) {
  427. switch (_context.prev = _context.next) {
  428. case 0:
  429. _this.preferences = _this.externalServices.createPreferences();
  430. _this.appConfig = appConfig;
  431. _context.next = 4;
  432. return _this._readPreferences();
  433. case 4:
  434. _context.next = 6;
  435. return _this._parseHashParameters();
  436. case 6:
  437. _context.next = 8;
  438. return _this._initializeL10n();
  439. case 8:
  440. if (_this.isViewerEmbedded && _app_options.AppOptions.get("externalLinkTarget") === _pdfjsLib.LinkTarget.NONE) {
  441. _app_options.AppOptions.set("externalLinkTarget", _pdfjsLib.LinkTarget.TOP);
  442. }
  443. _context.next = 11;
  444. return _this._initializeViewerComponents();
  445. case 11:
  446. _this.bindEvents();
  447. _this.bindWindowEvents();
  448. appContainer = appConfig.appContainer || document.documentElement;
  449. _this.l10n.translate(appContainer).then(function () {
  450. _this.eventBus.dispatch("localized", {
  451. source: _this
  452. });
  453. });
  454. _this._initializedCapability.resolve();
  455. case 16:
  456. case "end":
  457. return _context.stop();
  458. }
  459. }
  460. }, _callee);
  461. }))();
  462. },
  463. _readPreferences: function _readPreferences() {
  464. var _this2 = this;
  465. return _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee2() {
  466. var prefs, name;
  467. return _regenerator["default"].wrap(function _callee2$(_context2) {
  468. while (1) {
  469. switch (_context2.prev = _context2.next) {
  470. case 0:
  471. if (!_app_options.AppOptions.get("disablePreferences")) {
  472. _context2.next = 2;
  473. break;
  474. }
  475. return _context2.abrupt("return");
  476. case 2:
  477. _context2.prev = 2;
  478. _context2.next = 5;
  479. return _this2.preferences.getAll();
  480. case 5:
  481. prefs = _context2.sent;
  482. for (name in prefs) {
  483. _app_options.AppOptions.set(name, prefs[name]);
  484. }
  485. _context2.next = 12;
  486. break;
  487. case 9:
  488. _context2.prev = 9;
  489. _context2.t0 = _context2["catch"](2);
  490. console.error("_readPreferences: \"".concat(_context2.t0.message, "\"."));
  491. case 12:
  492. case "end":
  493. return _context2.stop();
  494. }
  495. }
  496. }, _callee2, null, [[2, 9]]);
  497. }))();
  498. },
  499. _parseHashParameters: function _parseHashParameters() {
  500. var _this3 = this;
  501. return _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee3() {
  502. var hash, hashParams, waitOn, viewer, enabled;
  503. return _regenerator["default"].wrap(function _callee3$(_context3) {
  504. while (1) {
  505. switch (_context3.prev = _context3.next) {
  506. case 0:
  507. if (_app_options.AppOptions.get("pdfBugEnabled")) {
  508. _context3.next = 2;
  509. break;
  510. }
  511. return _context3.abrupt("return", undefined);
  512. case 2:
  513. hash = document.location.hash.substring(1);
  514. if (hash) {
  515. _context3.next = 5;
  516. break;
  517. }
  518. return _context3.abrupt("return", undefined);
  519. case 5:
  520. hashParams = (0, _ui_utils.parseQueryString)(hash), waitOn = [];
  521. if ("disableworker" in hashParams && hashParams.disableworker === "true") {
  522. waitOn.push(loadFakeWorker());
  523. }
  524. if ("disablerange" in hashParams) {
  525. _app_options.AppOptions.set("disableRange", hashParams.disablerange === "true");
  526. }
  527. if ("disablestream" in hashParams) {
  528. _app_options.AppOptions.set("disableStream", hashParams.disablestream === "true");
  529. }
  530. if ("disableautofetch" in hashParams) {
  531. _app_options.AppOptions.set("disableAutoFetch", hashParams.disableautofetch === "true");
  532. }
  533. if ("disablefontface" in hashParams) {
  534. _app_options.AppOptions.set("disableFontFace", hashParams.disablefontface === "true");
  535. }
  536. if ("disablehistory" in hashParams) {
  537. _app_options.AppOptions.set("disableHistory", hashParams.disablehistory === "true");
  538. }
  539. if ("webgl" in hashParams) {
  540. _app_options.AppOptions.set("enableWebGL", hashParams.webgl === "true");
  541. }
  542. if ("verbosity" in hashParams) {
  543. _app_options.AppOptions.set("verbosity", hashParams.verbosity | 0);
  544. }
  545. if (!("textlayer" in hashParams)) {
  546. _context3.next = 23;
  547. break;
  548. }
  549. _context3.t0 = hashParams.textlayer;
  550. _context3.next = _context3.t0 === "off" ? 18 : _context3.t0 === "visible" ? 20 : _context3.t0 === "shadow" ? 20 : _context3.t0 === "hover" ? 20 : 23;
  551. break;
  552. case 18:
  553. _app_options.AppOptions.set("textLayerMode", _ui_utils.TextLayerMode.DISABLE);
  554. return _context3.abrupt("break", 23);
  555. case 20:
  556. viewer = _this3.appConfig.viewerContainer;
  557. viewer.classList.add("textLayer-" + hashParams.textlayer);
  558. return _context3.abrupt("break", 23);
  559. case 23:
  560. if ("pdfbug" in hashParams) {
  561. _app_options.AppOptions.set("pdfBug", true);
  562. _app_options.AppOptions.set("fontExtraProperties", true);
  563. enabled = hashParams.pdfbug.split(",");
  564. waitOn.push(loadAndEnablePDFBug(enabled));
  565. }
  566. if ("locale" in hashParams) {
  567. _app_options.AppOptions.set("locale", hashParams.locale);
  568. }
  569. return _context3.abrupt("return", Promise.all(waitOn)["catch"](function (reason) {
  570. console.error("_parseHashParameters: \"".concat(reason.message, "\"."));
  571. }));
  572. case 26:
  573. case "end":
  574. return _context3.stop();
  575. }
  576. }
  577. }, _callee3);
  578. }))();
  579. },
  580. _initializeL10n: function _initializeL10n() {
  581. var _this4 = this;
  582. return _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee4() {
  583. var dir;
  584. return _regenerator["default"].wrap(function _callee4$(_context4) {
  585. while (1) {
  586. switch (_context4.prev = _context4.next) {
  587. case 0:
  588. _this4.l10n = _this4.externalServices.createL10n({
  589. locale: _app_options.AppOptions.get("locale")
  590. });
  591. _context4.next = 3;
  592. return _this4.l10n.getDirection();
  593. case 3:
  594. dir = _context4.sent;
  595. document.getElementsByTagName("html")[0].dir = dir;
  596. case 5:
  597. case "end":
  598. return _context4.stop();
  599. }
  600. }
  601. }, _callee4);
  602. }))();
  603. },
  604. _initializeViewerComponents: function _initializeViewerComponents() {
  605. var _this5 = this;
  606. return _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee5() {
  607. var appConfig, eventBus, pdfRenderingQueue, pdfLinkService, downloadManager, findController, container, viewer;
  608. return _regenerator["default"].wrap(function _callee5$(_context5) {
  609. while (1) {
  610. switch (_context5.prev = _context5.next) {
  611. case 0:
  612. appConfig = _this5.appConfig;
  613. eventBus = appConfig.eventBus || new _ui_utils.EventBus({
  614. isInAutomation: _this5.externalServices.isInAutomation
  615. });
  616. _this5.eventBus = eventBus;
  617. _this5.overlayManager = new _overlay_manager.OverlayManager();
  618. pdfRenderingQueue = new _pdf_rendering_queue.PDFRenderingQueue();
  619. pdfRenderingQueue.onIdle = _this5.cleanup.bind(_this5);
  620. _this5.pdfRenderingQueue = pdfRenderingQueue;
  621. pdfLinkService = new _pdf_link_service.PDFLinkService({
  622. eventBus: eventBus,
  623. externalLinkTarget: _app_options.AppOptions.get("externalLinkTarget"),
  624. externalLinkRel: _app_options.AppOptions.get("externalLinkRel"),
  625. ignoreDestinationZoom: _app_options.AppOptions.get("ignoreDestinationZoom")
  626. });
  627. _this5.pdfLinkService = pdfLinkService;
  628. downloadManager = _this5.externalServices.createDownloadManager({
  629. disableCreateObjectURL: _app_options.AppOptions.get("disableCreateObjectURL")
  630. });
  631. _this5.downloadManager = downloadManager;
  632. findController = new _pdf_find_controller.PDFFindController({
  633. linkService: pdfLinkService,
  634. eventBus: eventBus
  635. });
  636. _this5.findController = findController;
  637. container = appConfig.mainContainer;
  638. viewer = appConfig.viewerContainer;
  639. _this5.pdfViewer = new _pdf_viewer.PDFViewer({
  640. container: container,
  641. viewer: viewer,
  642. eventBus: eventBus,
  643. renderingQueue: pdfRenderingQueue,
  644. linkService: pdfLinkService,
  645. downloadManager: downloadManager,
  646. findController: findController,
  647. renderer: _app_options.AppOptions.get("renderer"),
  648. enableWebGL: _app_options.AppOptions.get("enableWebGL"),
  649. l10n: _this5.l10n,
  650. textLayerMode: _app_options.AppOptions.get("textLayerMode"),
  651. imageResourcesPath: _app_options.AppOptions.get("imageResourcesPath"),
  652. renderInteractiveForms: _app_options.AppOptions.get("renderInteractiveForms"),
  653. enablePrintAutoRotate: _app_options.AppOptions.get("enablePrintAutoRotate"),
  654. useOnlyCssZoom: _app_options.AppOptions.get("useOnlyCssZoom"),
  655. maxCanvasPixels: _app_options.AppOptions.get("maxCanvasPixels")
  656. });
  657. pdfRenderingQueue.setViewer(_this5.pdfViewer);
  658. pdfLinkService.setViewer(_this5.pdfViewer);
  659. _this5.pdfThumbnailViewer = new _pdf_thumbnail_viewer.PDFThumbnailViewer({
  660. container: appConfig.sidebar.thumbnailView,
  661. renderingQueue: pdfRenderingQueue,
  662. linkService: pdfLinkService,
  663. l10n: _this5.l10n
  664. });
  665. pdfRenderingQueue.setThumbnailViewer(_this5.pdfThumbnailViewer);
  666. _this5.pdfHistory = new _pdf_history.PDFHistory({
  667. linkService: pdfLinkService,
  668. eventBus: eventBus
  669. });
  670. pdfLinkService.setHistory(_this5.pdfHistory);
  671. if (!_this5.supportsIntegratedFind) {
  672. _this5.findBar = new _pdf_find_bar.PDFFindBar(appConfig.findBar, eventBus, _this5.l10n);
  673. }
  674. _this5.pdfDocumentProperties = new _pdf_document_properties.PDFDocumentProperties(appConfig.documentProperties, _this5.overlayManager, eventBus, _this5.l10n);
  675. _this5.pdfCursorTools = new _pdf_cursor_tools.PDFCursorTools({
  676. container: container,
  677. eventBus: eventBus,
  678. cursorToolOnLoad: _app_options.AppOptions.get("cursorToolOnLoad")
  679. });
  680. _this5.toolbar = new _toolbar.Toolbar(appConfig.toolbar, eventBus, _this5.l10n);
  681. _this5.secondaryToolbar = new _secondary_toolbar.SecondaryToolbar(appConfig.secondaryToolbar, container, eventBus);
  682. if (_this5.supportsFullscreen) {
  683. _this5.pdfPresentationMode = new _pdf_presentation_mode.PDFPresentationMode({
  684. container: container,
  685. pdfViewer: _this5.pdfViewer,
  686. eventBus: eventBus,
  687. contextMenuItems: appConfig.fullscreen
  688. });
  689. }
  690. _this5.passwordPrompt = new _password_prompt.PasswordPrompt(appConfig.passwordOverlay, _this5.overlayManager, _this5.l10n);
  691. _this5.pdfOutlineViewer = new _pdf_outline_viewer.PDFOutlineViewer({
  692. container: appConfig.sidebar.outlineView,
  693. eventBus: eventBus,
  694. linkService: pdfLinkService
  695. });
  696. _this5.pdfAttachmentViewer = new _pdf_attachment_viewer.PDFAttachmentViewer({
  697. container: appConfig.sidebar.attachmentsView,
  698. eventBus: eventBus,
  699. downloadManager: downloadManager
  700. });
  701. _this5.pdfSidebar = new _pdf_sidebar.PDFSidebar({
  702. elements: appConfig.sidebar,
  703. pdfViewer: _this5.pdfViewer,
  704. pdfThumbnailViewer: _this5.pdfThumbnailViewer,
  705. eventBus: eventBus,
  706. l10n: _this5.l10n
  707. });
  708. _this5.pdfSidebar.onToggled = _this5.forceRendering.bind(_this5);
  709. _this5.pdfSidebarResizer = new _pdf_sidebar_resizer.PDFSidebarResizer(appConfig.sidebarResizer, eventBus, _this5.l10n);
  710. case 34:
  711. case "end":
  712. return _context5.stop();
  713. }
  714. }
  715. }, _callee5);
  716. }))();
  717. },
  718. run: function run(config) {
  719. this.initialize(config).then(webViewerInitialized);
  720. },
  721. get initialized() {
  722. return this._initializedCapability.settled;
  723. },
  724. get initializedPromise() {
  725. return this._initializedCapability.promise;
  726. },
  727. zoomIn: function zoomIn(ticks) {
  728. if (this.pdfViewer.isInPresentationMode) {
  729. return;
  730. }
  731. var newScale = this.pdfViewer.currentScale;
  732. do {
  733. newScale = (newScale * DEFAULT_SCALE_DELTA).toFixed(2);
  734. newScale = Math.ceil(newScale * 10) / 10;
  735. newScale = Math.min(_ui_utils.MAX_SCALE, newScale);
  736. } while (--ticks > 0 && newScale < _ui_utils.MAX_SCALE);
  737. this.pdfViewer.currentScaleValue = newScale;
  738. },
  739. zoomOut: function zoomOut(ticks) {
  740. if (this.pdfViewer.isInPresentationMode) {
  741. return;
  742. }
  743. var newScale = this.pdfViewer.currentScale;
  744. do {
  745. newScale = (newScale / DEFAULT_SCALE_DELTA).toFixed(2);
  746. newScale = Math.floor(newScale * 10) / 10;
  747. newScale = Math.max(_ui_utils.MIN_SCALE, newScale);
  748. } while (--ticks > 0 && newScale > _ui_utils.MIN_SCALE);
  749. this.pdfViewer.currentScaleValue = newScale;
  750. },
  751. zoomReset: function zoomReset() {
  752. if (this.pdfViewer.isInPresentationMode) {
  753. return;
  754. }
  755. this.pdfViewer.currentScaleValue = _ui_utils.DEFAULT_SCALE_VALUE;
  756. },
  757. get pagesCount() {
  758. return this.pdfDocument ? this.pdfDocument.numPages : 0;
  759. },
  760. get page() {
  761. return this.pdfViewer.currentPageNumber;
  762. },
  763. set page(val) {
  764. this.pdfViewer.currentPageNumber = val;
  765. },
  766. get printing() {
  767. return !!this.printService;
  768. },
  769. get supportsPrinting() {
  770. return PDFPrintServiceFactory.instance.supportsPrinting;
  771. },
  772. get supportsFullscreen() {
  773. var support;
  774. var doc = document.documentElement;
  775. support = !!(doc.requestFullscreen || doc.mozRequestFullScreen || doc.webkitRequestFullScreen || doc.msRequestFullscreen);
  776. if (document.fullscreenEnabled === false || document.mozFullScreenEnabled === false || document.webkitFullscreenEnabled === false || document.msFullscreenEnabled === false) {
  777. support = false;
  778. }
  779. return (0, _pdfjsLib.shadow)(this, "supportsFullscreen", support);
  780. },
  781. get supportsIntegratedFind() {
  782. return this.externalServices.supportsIntegratedFind;
  783. },
  784. get supportsDocumentFonts() {
  785. return this.externalServices.supportsDocumentFonts;
  786. },
  787. get loadingBar() {
  788. var bar = new _ui_utils.ProgressBar("#loadingBar");
  789. return (0, _pdfjsLib.shadow)(this, "loadingBar", bar);
  790. },
  791. get supportedMouseWheelZoomModifierKeys() {
  792. return this.externalServices.supportedMouseWheelZoomModifierKeys;
  793. },
  794. initPassiveLoading: function initPassiveLoading() {
  795. throw new Error("Not implemented: initPassiveLoading");
  796. },
  797. setTitleUsingUrl: function setTitleUsingUrl() {
  798. var url = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "";
  799. this.url = url;
  800. this.baseUrl = url.split("#")[0];
  801. var title = (0, _ui_utils.getPDFFileNameFromURL)(url, "");
  802. if (!title) {
  803. try {
  804. title = decodeURIComponent((0, _pdfjsLib.getFilenameFromUrl)(url)) || url;
  805. } catch (ex) {
  806. title = url;
  807. }
  808. }
  809. this.setTitle(title);
  810. },
  811. setTitle: function setTitle(title) {
  812. if (this.isViewerEmbedded) {
  813. return;
  814. }
  815. document.title = title;
  816. },
  817. close: function close() {
  818. var _this6 = this;
  819. return _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee6() {
  820. var errorWrapper, promise;
  821. return _regenerator["default"].wrap(function _callee6$(_context6) {
  822. while (1) {
  823. switch (_context6.prev = _context6.next) {
  824. case 0:
  825. errorWrapper = _this6.appConfig.errorWrapper.container;
  826. errorWrapper.setAttribute("hidden", "true");
  827. if (_this6.pdfLoadingTask) {
  828. _context6.next = 4;
  829. break;
  830. }
  831. return _context6.abrupt("return", undefined);
  832. case 4:
  833. promise = _this6.pdfLoadingTask.destroy();
  834. _this6.pdfLoadingTask = null;
  835. if (_this6.pdfDocument) {
  836. _this6.pdfDocument = null;
  837. _this6.pdfThumbnailViewer.setDocument(null);
  838. _this6.pdfViewer.setDocument(null);
  839. _this6.pdfLinkService.setDocument(null);
  840. _this6.pdfDocumentProperties.setDocument(null);
  841. }
  842. webViewerResetPermissions();
  843. _this6.store = null;
  844. _this6.isInitialViewSet = false;
  845. _this6.downloadComplete = false;
  846. _this6.url = "";
  847. _this6.baseUrl = "";
  848. _this6.contentDispositionFilename = null;
  849. _this6.pdfSidebar.reset();
  850. _this6.pdfOutlineViewer.reset();
  851. _this6.pdfAttachmentViewer.reset();
  852. if (_this6.pdfHistory) {
  853. _this6.pdfHistory.reset();
  854. }
  855. if (_this6.findBar) {
  856. _this6.findBar.reset();
  857. }
  858. _this6.toolbar.reset();
  859. _this6.secondaryToolbar.reset();
  860. if (typeof PDFBug !== "undefined") {
  861. PDFBug.cleanup();
  862. }
  863. return _context6.abrupt("return", promise);
  864. case 23:
  865. case "end":
  866. return _context6.stop();
  867. }
  868. }
  869. }, _callee6);
  870. }))();
  871. },
  872. open: function open(file, args) {
  873. var _this7 = this;
  874. return _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee7() {
  875. var workerParameters, key, parameters, apiParameters, _key, value, _key2, _value, loadingTask;
  876. return _regenerator["default"].wrap(function _callee7$(_context7) {
  877. while (1) {
  878. switch (_context7.prev = _context7.next) {
  879. case 0:
  880. if (!_this7.pdfLoadingTask) {
  881. _context7.next = 3;
  882. break;
  883. }
  884. _context7.next = 3;
  885. return _this7.close();
  886. case 3:
  887. workerParameters = _app_options.AppOptions.getAll(_app_options.OptionKind.WORKER);
  888. for (key in workerParameters) {
  889. _pdfjsLib.GlobalWorkerOptions[key] = workerParameters[key];
  890. }
  891. parameters = Object.create(null);
  892. if (typeof file === "string") {
  893. _this7.setTitleUsingUrl(file);
  894. parameters.url = file;
  895. } else if (file && "byteLength" in file) {
  896. parameters.data = file;
  897. } else if (file.url && file.originalUrl) {
  898. _this7.setTitleUsingUrl(file.originalUrl);
  899. parameters.url = file.url;
  900. }
  901. apiParameters = _app_options.AppOptions.getAll(_app_options.OptionKind.API);
  902. for (_key in apiParameters) {
  903. value = apiParameters[_key];
  904. if (_key === "docBaseUrl" && !value) {}
  905. parameters[_key] = value;
  906. }
  907. if (args) {
  908. for (_key2 in args) {
  909. _value = args[_key2];
  910. if (_key2 === "length") {
  911. _this7.pdfDocumentProperties.setFileSize(_value);
  912. }
  913. parameters[_key2] = _value;
  914. }
  915. }
  916. loadingTask = (0, _pdfjsLib.getDocument)(parameters);
  917. _this7.pdfLoadingTask = loadingTask;
  918. loadingTask.onPassword = function (updateCallback, reason) {
  919. _this7.pdfLinkService.externalLinkEnabled = false;
  920. _this7.passwordPrompt.setUpdateCallback(updateCallback, reason);
  921. _this7.passwordPrompt.open();
  922. };
  923. loadingTask.onProgress = function (_ref) {
  924. var loaded = _ref.loaded,
  925. total = _ref.total;
  926. _this7.progress(loaded / total);
  927. };
  928. loadingTask.onUnsupportedFeature = _this7.fallback.bind(_this7);
  929. return _context7.abrupt("return", loadingTask.promise.then(function (pdfDocument) {
  930. _this7.load(pdfDocument);
  931. }, function (exception) {
  932. if (loadingTask !== _this7.pdfLoadingTask) {
  933. return undefined;
  934. }
  935. var message = exception && exception.message;
  936. var loadingErrorMessage;
  937. if (exception instanceof _pdfjsLib.InvalidPDFException) {
  938. loadingErrorMessage = _this7.l10n.get("invalid_file_error", null, "Invalid or corrupted PDF file.");
  939. } else if (exception instanceof _pdfjsLib.MissingPDFException) {
  940. loadingErrorMessage = _this7.l10n.get("missing_file_error", null, "Missing PDF file.");
  941. } else if (exception instanceof _pdfjsLib.UnexpectedResponseException) {
  942. loadingErrorMessage = _this7.l10n.get("unexpected_response_error", null, "Unexpected server response.");
  943. } else {
  944. loadingErrorMessage = _this7.l10n.get("loading_error", null, "An error occurred while loading the PDF.");
  945. }
  946. return loadingErrorMessage.then(function (msg) {
  947. _this7.error(msg, {
  948. message: message
  949. });
  950. throw exception;
  951. });
  952. }));
  953. case 16:
  954. case "end":
  955. return _context7.stop();
  956. }
  957. }
  958. }, _callee7);
  959. }))();
  960. },
  961. download: function download() {
  962. var _this8 = this;
  963. function downloadByUrl() {
  964. downloadManager.downloadUrl(url, filename);
  965. }
  966. var url = this.baseUrl;
  967. var filename = this.contentDispositionFilename || (0, _ui_utils.getPDFFileNameFromURL)(this.url);
  968. var downloadManager = this.downloadManager;
  969. downloadManager.onerror = function (err) {
  970. _this8.error("PDF failed to download: ".concat(err));
  971. };
  972. if (!this.pdfDocument || !this.downloadComplete) {
  973. downloadByUrl();
  974. return;
  975. }
  976. this.pdfDocument.getData().then(function (data) {
  977. var blob = new Blob([data], {
  978. type: "application/pdf"
  979. });
  980. downloadManager.download(blob, url, filename);
  981. })["catch"](downloadByUrl);
  982. },
  983. fallback: function fallback(featureId) {
  984. if (this.fellback) {
  985. return;
  986. }
  987. this.fellback = true;
  988. this.externalServices.fallback({
  989. featureId: featureId,
  990. url: this.baseUrl
  991. }, function response(download) {
  992. if (!download) {
  993. return;
  994. }
  995. PDFViewerApplication.download();
  996. });
  997. },
  998. error: function error(message, moreInfo) {
  999. var moreInfoText = [this.l10n.get("error_version_info", {
  1000. version: _pdfjsLib.version || "?",
  1001. build: _pdfjsLib.build || "?"
  1002. }, "PDF.js v{{version}} (build: {{build}})")];
  1003. if (moreInfo) {
  1004. moreInfoText.push(this.l10n.get("error_message", {
  1005. message: moreInfo.message
  1006. }, "Message: {{message}}"));
  1007. if (moreInfo.stack) {
  1008. moreInfoText.push(this.l10n.get("error_stack", {
  1009. stack: moreInfo.stack
  1010. }, "Stack: {{stack}}"));
  1011. } else {
  1012. if (moreInfo.filename) {
  1013. moreInfoText.push(this.l10n.get("error_file", {
  1014. file: moreInfo.filename
  1015. }, "File: {{file}}"));
  1016. }
  1017. if (moreInfo.lineNumber) {
  1018. moreInfoText.push(this.l10n.get("error_line", {
  1019. line: moreInfo.lineNumber
  1020. }, "Line: {{line}}"));
  1021. }
  1022. }
  1023. }
  1024. var errorWrapperConfig = this.appConfig.errorWrapper;
  1025. var errorWrapper = errorWrapperConfig.container;
  1026. errorWrapper.removeAttribute("hidden");
  1027. var errorMessage = errorWrapperConfig.errorMessage;
  1028. errorMessage.textContent = message;
  1029. var closeButton = errorWrapperConfig.closeButton;
  1030. closeButton.onclick = function () {
  1031. errorWrapper.setAttribute("hidden", "true");
  1032. };
  1033. var errorMoreInfo = errorWrapperConfig.errorMoreInfo;
  1034. var moreInfoButton = errorWrapperConfig.moreInfoButton;
  1035. var lessInfoButton = errorWrapperConfig.lessInfoButton;
  1036. moreInfoButton.onclick = function () {
  1037. errorMoreInfo.removeAttribute("hidden");
  1038. moreInfoButton.setAttribute("hidden", "true");
  1039. lessInfoButton.removeAttribute("hidden");
  1040. errorMoreInfo.style.height = errorMoreInfo.scrollHeight + "px";
  1041. };
  1042. lessInfoButton.onclick = function () {
  1043. errorMoreInfo.setAttribute("hidden", "true");
  1044. moreInfoButton.removeAttribute("hidden");
  1045. lessInfoButton.setAttribute("hidden", "true");
  1046. };
  1047. moreInfoButton.oncontextmenu = _ui_utils.noContextMenuHandler;
  1048. lessInfoButton.oncontextmenu = _ui_utils.noContextMenuHandler;
  1049. closeButton.oncontextmenu = _ui_utils.noContextMenuHandler;
  1050. moreInfoButton.removeAttribute("hidden");
  1051. lessInfoButton.setAttribute("hidden", "true");
  1052. Promise.all(moreInfoText).then(function (parts) {
  1053. errorMoreInfo.value = parts.join("\n");
  1054. });
  1055. },
  1056. progress: function progress(level) {
  1057. var _this9 = this;
  1058. if (this.downloadComplete) {
  1059. return;
  1060. }
  1061. var percent = Math.round(level * 100);
  1062. if (percent > this.loadingBar.percent || isNaN(percent)) {
  1063. this.loadingBar.percent = percent;
  1064. var disableAutoFetch = this.pdfDocument ? this.pdfDocument.loadingParams.disableAutoFetch : _app_options.AppOptions.get("disableAutoFetch");
  1065. if (disableAutoFetch && percent) {
  1066. if (this.disableAutoFetchLoadingBarTimeout) {
  1067. clearTimeout(this.disableAutoFetchLoadingBarTimeout);
  1068. this.disableAutoFetchLoadingBarTimeout = null;
  1069. }
  1070. this.loadingBar.show();
  1071. this.disableAutoFetchLoadingBarTimeout = setTimeout(function () {
  1072. _this9.loadingBar.hide();
  1073. _this9.disableAutoFetchLoadingBarTimeout = null;
  1074. }, DISABLE_AUTO_FETCH_LOADING_BAR_TIMEOUT);
  1075. }
  1076. }
  1077. },
  1078. load: function load(pdfDocument) {
  1079. var _this10 = this;
  1080. this.pdfDocument = pdfDocument;
  1081. pdfDocument.getDownloadInfo().then(function () {
  1082. _this10.downloadComplete = true;
  1083. _this10.loadingBar.hide();
  1084. firstPagePromise.then(function () {
  1085. _this10.eventBus.dispatch("documentloaded", {
  1086. source: _this10
  1087. });
  1088. });
  1089. });
  1090. var pageLayoutPromise = pdfDocument.getPageLayout()["catch"](function () {});
  1091. var pageModePromise = pdfDocument.getPageMode()["catch"](function () {});
  1092. var openActionPromise = pdfDocument.getOpenAction()["catch"](function () {});
  1093. this.toolbar.setPagesCount(pdfDocument.numPages, false);
  1094. this.secondaryToolbar.setPagesCount(pdfDocument.numPages);
  1095. var baseDocumentUrl;
  1096. baseDocumentUrl = null;
  1097. this.pdfLinkService.setDocument(pdfDocument, baseDocumentUrl);
  1098. this.pdfDocumentProperties.setDocument(pdfDocument, this.url);
  1099. var pdfViewer = this.pdfViewer;
  1100. pdfViewer.setDocument(pdfDocument);
  1101. var firstPagePromise = pdfViewer.firstPagePromise,
  1102. onePageRendered = pdfViewer.onePageRendered,
  1103. pagesPromise = pdfViewer.pagesPromise;
  1104. var pdfThumbnailViewer = this.pdfThumbnailViewer;
  1105. pdfThumbnailViewer.setDocument(pdfDocument);
  1106. var storedPromise = (this.store = new _view_history.ViewHistory(pdfDocument.fingerprint)).getMultiple({
  1107. page: null,
  1108. zoom: _ui_utils.DEFAULT_SCALE_VALUE,
  1109. scrollLeft: "0",
  1110. scrollTop: "0",
  1111. rotation: null,
  1112. sidebarView: _pdf_sidebar.SidebarView.UNKNOWN,
  1113. scrollMode: _ui_utils.ScrollMode.UNKNOWN,
  1114. spreadMode: _ui_utils.SpreadMode.UNKNOWN
  1115. })["catch"](function () {
  1116. return Object.create(null);
  1117. });
  1118. firstPagePromise.then(function (pdfPage) {
  1119. _this10.loadingBar.setWidth(_this10.appConfig.viewerContainer);
  1120. Promise.all([_ui_utils.animationStarted, storedPromise, pageLayoutPromise, pageModePromise, openActionPromise]).then( /*#__PURE__*/function () {
  1121. var _ref3 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee8(_ref2) {
  1122. var _ref4, timeStamp, stored, pageLayout, pageMode, openAction, viewOnLoad, initialBookmark, zoom, hash, rotation, sidebarView, scrollMode, spreadMode;
  1123. return _regenerator["default"].wrap(function _callee8$(_context8) {
  1124. while (1) {
  1125. switch (_context8.prev = _context8.next) {
  1126. case 0:
  1127. _ref4 = _slicedToArray(_ref2, 5), timeStamp = _ref4[0], stored = _ref4[1], pageLayout = _ref4[2], pageMode = _ref4[3], openAction = _ref4[4];
  1128. viewOnLoad = _app_options.AppOptions.get("viewOnLoad");
  1129. _this10._initializePdfHistory({
  1130. fingerprint: pdfDocument.fingerprint,
  1131. viewOnLoad: viewOnLoad,
  1132. initialDest: openAction && openAction.dest
  1133. });
  1134. initialBookmark = _this10.initialBookmark;
  1135. zoom = _app_options.AppOptions.get("defaultZoomValue");
  1136. hash = zoom ? "zoom=".concat(zoom) : null;
  1137. rotation = null;
  1138. sidebarView = _app_options.AppOptions.get("sidebarViewOnLoad");
  1139. scrollMode = _app_options.AppOptions.get("scrollModeOnLoad");
  1140. spreadMode = _app_options.AppOptions.get("spreadModeOnLoad");
  1141. if (stored.page && viewOnLoad !== ViewOnLoad.INITIAL) {
  1142. hash = "page=".concat(stored.page, "&zoom=").concat(zoom || stored.zoom, ",") + "".concat(stored.scrollLeft, ",").concat(stored.scrollTop);
  1143. rotation = parseInt(stored.rotation, 10);
  1144. if (sidebarView === _pdf_sidebar.SidebarView.UNKNOWN) {
  1145. sidebarView = stored.sidebarView | 0;
  1146. }
  1147. if (scrollMode === _ui_utils.ScrollMode.UNKNOWN) {
  1148. scrollMode = stored.scrollMode | 0;
  1149. }
  1150. if (spreadMode === _ui_utils.SpreadMode.UNKNOWN) {
  1151. spreadMode = stored.spreadMode | 0;
  1152. }
  1153. }
  1154. if (pageMode && sidebarView === _pdf_sidebar.SidebarView.UNKNOWN) {
  1155. sidebarView = apiPageModeToSidebarView(pageMode);
  1156. }
  1157. if (pageLayout && spreadMode === _ui_utils.SpreadMode.UNKNOWN) {
  1158. spreadMode = apiPageLayoutToSpreadMode(pageLayout);
  1159. }
  1160. _this10.setInitialView(hash, {
  1161. rotation: rotation,
  1162. sidebarView: sidebarView,
  1163. scrollMode: scrollMode,
  1164. spreadMode: spreadMode
  1165. });
  1166. _this10.eventBus.dispatch("documentinit", {
  1167. source: _this10
  1168. });
  1169. if (!_this10.isViewerEmbedded) {
  1170. pdfViewer.focus();
  1171. }
  1172. _this10._initializePermissions(pdfDocument);
  1173. _context8.next = 19;
  1174. return Promise.race([pagesPromise, new Promise(function (resolve) {
  1175. setTimeout(resolve, FORCE_PAGES_LOADED_TIMEOUT);
  1176. })]);
  1177. case 19:
  1178. if (!(!initialBookmark && !hash)) {
  1179. _context8.next = 21;
  1180. break;
  1181. }
  1182. return _context8.abrupt("return");
  1183. case 21:
  1184. if (!pdfViewer.hasEqualPageSizes) {
  1185. _context8.next = 23;
  1186. break;
  1187. }
  1188. return _context8.abrupt("return");
  1189. case 23:
  1190. _this10.initialBookmark = initialBookmark;
  1191. pdfViewer.currentScaleValue = pdfViewer.currentScaleValue;
  1192. _this10.setInitialView(hash);
  1193. case 26:
  1194. case "end":
  1195. return _context8.stop();
  1196. }
  1197. }
  1198. }, _callee8);
  1199. }));
  1200. return function (_x) {
  1201. return _ref3.apply(this, arguments);
  1202. };
  1203. }())["catch"](function () {
  1204. _this10.setInitialView();
  1205. }).then(function () {
  1206. pdfViewer.update();
  1207. });
  1208. });
  1209. pagesPromise.then(function () {
  1210. _this10._initializeAutoPrint(pdfDocument, openActionPromise);
  1211. });
  1212. onePageRendered.then(function () {
  1213. pdfDocument.getOutline().then(function (outline) {
  1214. _this10.pdfOutlineViewer.render({
  1215. outline: outline
  1216. });
  1217. });
  1218. pdfDocument.getAttachments().then(function (attachments) {
  1219. _this10.pdfAttachmentViewer.render({
  1220. attachments: attachments
  1221. });
  1222. });
  1223. });
  1224. this._initializePageLabels(pdfDocument);
  1225. this._initializeMetadata(pdfDocument);
  1226. },
  1227. _initializeAutoPrint: function _initializeAutoPrint(pdfDocument, openActionPromise) {
  1228. var _this11 = this;
  1229. return _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee9() {
  1230. var _yield$Promise$all, _yield$Promise$all2, openAction, javaScript, triggerAutoPrint, _iterator, _step, js;
  1231. return _regenerator["default"].wrap(function _callee9$(_context9) {
  1232. while (1) {
  1233. switch (_context9.prev = _context9.next) {
  1234. case 0:
  1235. _context9.next = 2;
  1236. return Promise.all([openActionPromise, pdfDocument.getJavaScript()]);
  1237. case 2:
  1238. _yield$Promise$all = _context9.sent;
  1239. _yield$Promise$all2 = _slicedToArray(_yield$Promise$all, 2);
  1240. openAction = _yield$Promise$all2[0];
  1241. javaScript = _yield$Promise$all2[1];
  1242. if (!(pdfDocument !== _this11.pdfDocument)) {
  1243. _context9.next = 8;
  1244. break;
  1245. }
  1246. return _context9.abrupt("return");
  1247. case 8:
  1248. triggerAutoPrint = false;
  1249. if (openAction && openAction.action === "Print") {
  1250. triggerAutoPrint = true;
  1251. }
  1252. if (!javaScript) {
  1253. _context9.next = 31;
  1254. break;
  1255. }
  1256. javaScript.some(function (js) {
  1257. if (!js) {
  1258. return false;
  1259. }
  1260. console.warn("Warning: JavaScript is not supported");
  1261. _this11.fallback(_pdfjsLib.UNSUPPORTED_FEATURES.javaScript);
  1262. return true;
  1263. });
  1264. if (triggerAutoPrint) {
  1265. _context9.next = 31;
  1266. break;
  1267. }
  1268. _iterator = _createForOfIteratorHelper(javaScript);
  1269. _context9.prev = 14;
  1270. _iterator.s();
  1271. case 16:
  1272. if ((_step = _iterator.n()).done) {
  1273. _context9.next = 23;
  1274. break;
  1275. }
  1276. js = _step.value;
  1277. if (!(js && _ui_utils.AutoPrintRegExp.test(js))) {
  1278. _context9.next = 21;
  1279. break;
  1280. }
  1281. triggerAutoPrint = true;
  1282. return _context9.abrupt("break", 23);
  1283. case 21:
  1284. _context9.next = 16;
  1285. break;
  1286. case 23:
  1287. _context9.next = 28;
  1288. break;
  1289. case 25:
  1290. _context9.prev = 25;
  1291. _context9.t0 = _context9["catch"](14);
  1292. _iterator.e(_context9.t0);
  1293. case 28:
  1294. _context9.prev = 28;
  1295. _iterator.f();
  1296. return _context9.finish(28);
  1297. case 31:
  1298. if (_this11.supportsPrinting) {
  1299. _context9.next = 33;
  1300. break;
  1301. }
  1302. return _context9.abrupt("return");
  1303. case 33:
  1304. if (triggerAutoPrint) {
  1305. setTimeout(function () {
  1306. window.print();
  1307. });
  1308. }
  1309. case 34:
  1310. case "end":
  1311. return _context9.stop();
  1312. }
  1313. }
  1314. }, _callee9, null, [[14, 25, 28, 31]]);
  1315. }))();
  1316. },
  1317. _initializeMetadata: function _initializeMetadata(pdfDocument) {
  1318. var _this12 = this;
  1319. return _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee10() {
  1320. var _yield$pdfDocument$ge, info, metadata, contentDispositionFilename, pdfTitle, infoTitle, metadataTitle, versionId, KNOWN_VERSIONS, generatorId, KNOWN_GENERATORS, producer, formType;
  1321. return _regenerator["default"].wrap(function _callee10$(_context10) {
  1322. while (1) {
  1323. switch (_context10.prev = _context10.next) {
  1324. case 0:
  1325. _context10.next = 2;
  1326. return pdfDocument.getMetadata();
  1327. case 2:
  1328. _yield$pdfDocument$ge = _context10.sent;
  1329. info = _yield$pdfDocument$ge.info;
  1330. metadata = _yield$pdfDocument$ge.metadata;
  1331. contentDispositionFilename = _yield$pdfDocument$ge.contentDispositionFilename;
  1332. if (!(pdfDocument !== _this12.pdfDocument)) {
  1333. _context10.next = 8;
  1334. break;
  1335. }
  1336. return _context10.abrupt("return");
  1337. case 8:
  1338. _this12.documentInfo = info;
  1339. _this12.metadata = metadata;
  1340. _this12.contentDispositionFilename = contentDispositionFilename;
  1341. console.log("PDF ".concat(pdfDocument.fingerprint, " [").concat(info.PDFFormatVersion, " ") + "".concat((info.Producer || "-").trim(), " / ").concat((info.Creator || "-").trim(), "] ") + "(PDF.js: ".concat(_pdfjsLib.version || "-") + "".concat(_this12.pdfViewer.enableWebGL ? " [WebGL]" : "", ")"));
  1342. infoTitle = info && info.Title;
  1343. if (infoTitle) {
  1344. pdfTitle = infoTitle;
  1345. }
  1346. metadataTitle = metadata && metadata.get("dc:title");
  1347. if (metadataTitle) {
  1348. if (metadataTitle !== "Untitled" && !/[\uFFF0-\uFFFF]/g.test(metadataTitle)) {
  1349. pdfTitle = metadataTitle;
  1350. }
  1351. }
  1352. if (pdfTitle) {
  1353. _this12.setTitle("".concat(pdfTitle, " - ").concat(contentDispositionFilename || document.title));
  1354. } else if (contentDispositionFilename) {
  1355. _this12.setTitle(contentDispositionFilename);
  1356. }
  1357. if (info.IsAcroFormPresent) {
  1358. console.warn("Warning: AcroForm/XFA is not supported");
  1359. _this12.fallback(_pdfjsLib.UNSUPPORTED_FEATURES.forms);
  1360. }
  1361. versionId = "other";
  1362. KNOWN_VERSIONS = ["1.0", "1.1", "1.2", "1.3", "1.4", "1.5", "1.6", "1.7", "1.8", "1.9", "2.0", "2.1", "2.2", "2.3"];
  1363. if (KNOWN_VERSIONS.includes(info.PDFFormatVersion)) {
  1364. versionId = "v".concat(info.PDFFormatVersion.replace(".", "_"));
  1365. }
  1366. generatorId = "other";
  1367. KNOWN_GENERATORS = ["acrobat distiller", "acrobat pdfwriter", "adobe livecycle", "adobe pdf library", "adobe photoshop", "ghostscript", "tcpdf", "cairo", "dvipdfm", "dvips", "pdftex", "pdfkit", "itext", "prince", "quarkxpress", "mac os x", "microsoft", "openoffice", "oracle", "luradocument", "pdf-xchange", "antenna house", "aspose.cells", "fpdf"];
  1368. if (info.Producer) {
  1369. producer = info.Producer.toLowerCase();
  1370. KNOWN_GENERATORS.some(function (generator) {
  1371. if (!producer.includes(generator)) {
  1372. return false;
  1373. }
  1374. generatorId = generator.replace(/[ .\-]/g, "_");
  1375. return true;
  1376. });
  1377. }
  1378. formType = null;
  1379. if (info.IsAcroFormPresent) {
  1380. formType = info.IsXFAPresent ? "xfa" : "acroform";
  1381. }
  1382. _this12.externalServices.reportTelemetry({
  1383. type: "documentInfo",
  1384. version: versionId,
  1385. generator: generatorId,
  1386. formType: formType
  1387. });
  1388. case 27:
  1389. case "end":
  1390. return _context10.stop();
  1391. }
  1392. }
  1393. }, _callee10);
  1394. }))();
  1395. },
  1396. _initializePageLabels: function _initializePageLabels(pdfDocument) {
  1397. var _this13 = this;
  1398. return _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee11() {
  1399. var labels, numLabels, i, pdfViewer, pdfThumbnailViewer, toolbar;
  1400. return _regenerator["default"].wrap(function _callee11$(_context11) {
  1401. while (1) {
  1402. switch (_context11.prev = _context11.next) {
  1403. case 0:
  1404. _context11.next = 2;
  1405. return pdfDocument.getPageLabels();
  1406. case 2:
  1407. labels = _context11.sent;
  1408. if (!(pdfDocument !== _this13.pdfDocument)) {
  1409. _context11.next = 5;
  1410. break;
  1411. }
  1412. return _context11.abrupt("return");
  1413. case 5:
  1414. if (!(!labels || _app_options.AppOptions.get("disablePageLabels"))) {
  1415. _context11.next = 7;
  1416. break;
  1417. }
  1418. return _context11.abrupt("return");
  1419. case 7:
  1420. numLabels = labels.length;
  1421. if (!(numLabels !== _this13.pagesCount)) {
  1422. _context11.next = 11;
  1423. break;
  1424. }
  1425. console.error("The number of Page Labels does not match the number of pages in the document.");
  1426. return _context11.abrupt("return");
  1427. case 11:
  1428. i = 0;
  1429. while (i < numLabels && labels[i] === (i + 1).toString()) {
  1430. i++;
  1431. }
  1432. if (!(i === numLabels)) {
  1433. _context11.next = 15;
  1434. break;
  1435. }
  1436. return _context11.abrupt("return");
  1437. case 15:
  1438. pdfViewer = _this13.pdfViewer, pdfThumbnailViewer = _this13.pdfThumbnailViewer, toolbar = _this13.toolbar;
  1439. pdfViewer.setPageLabels(labels);
  1440. pdfThumbnailViewer.setPageLabels(labels);
  1441. toolbar.setPagesCount(numLabels, true);
  1442. toolbar.setPageNumber(pdfViewer.currentPageNumber, pdfViewer.currentPageLabel);
  1443. case 20:
  1444. case "end":
  1445. return _context11.stop();
  1446. }
  1447. }
  1448. }, _callee11);
  1449. }))();
  1450. },
  1451. _initializePdfHistory: function _initializePdfHistory(_ref5) {
  1452. var fingerprint = _ref5.fingerprint,
  1453. viewOnLoad = _ref5.viewOnLoad,
  1454. _ref5$initialDest = _ref5.initialDest,
  1455. initialDest = _ref5$initialDest === void 0 ? null : _ref5$initialDest;
  1456. if (this.isViewerEmbedded || _app_options.AppOptions.get("disableHistory")) {
  1457. return;
  1458. }
  1459. this.pdfHistory.initialize({
  1460. fingerprint: fingerprint,
  1461. resetHistory: viewOnLoad === ViewOnLoad.INITIAL,
  1462. updateUrl: _app_options.AppOptions.get("historyUpdateUrl")
  1463. });
  1464. if (this.pdfHistory.initialBookmark) {
  1465. this.initialBookmark = this.pdfHistory.initialBookmark;
  1466. this.initialRotation = this.pdfHistory.initialRotation;
  1467. }
  1468. if (initialDest && !this.initialBookmark && viewOnLoad === ViewOnLoad.UNKNOWN) {
  1469. this.initialBookmark = JSON.stringify(initialDest);
  1470. this.pdfHistory.push({
  1471. explicitDest: initialDest,
  1472. pageNumber: null
  1473. });
  1474. }
  1475. },
  1476. _initializePermissions: function _initializePermissions(pdfDocument) {
  1477. var _this14 = this;
  1478. return _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee12() {
  1479. var permissions;
  1480. return _regenerator["default"].wrap(function _callee12$(_context12) {
  1481. while (1) {
  1482. switch (_context12.prev = _context12.next) {
  1483. case 0:
  1484. _context12.next = 2;
  1485. return pdfDocument.getPermissions();
  1486. case 2:
  1487. permissions = _context12.sent;
  1488. if (!(pdfDocument !== _this14.pdfDocument)) {
  1489. _context12.next = 5;
  1490. break;
  1491. }
  1492. return _context12.abrupt("return");
  1493. case 5:
  1494. if (!(!permissions || !_app_options.AppOptions.get("enablePermissions"))) {
  1495. _context12.next = 7;
  1496. break;
  1497. }
  1498. return _context12.abrupt("return");
  1499. case 7:
  1500. if (!permissions.includes(_pdfjsLib.PermissionFlag.COPY)) {
  1501. _this14.appConfig.viewerContainer.classList.add(ENABLE_PERMISSIONS_CLASS);
  1502. }
  1503. case 8:
  1504. case "end":
  1505. return _context12.stop();
  1506. }
  1507. }
  1508. }, _callee12);
  1509. }))();
  1510. },
  1511. setInitialView: function setInitialView(storedHash) {
  1512. var _this15 = this;
  1513. var _ref6 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
  1514. rotation = _ref6.rotation,
  1515. sidebarView = _ref6.sidebarView,
  1516. scrollMode = _ref6.scrollMode,
  1517. spreadMode = _ref6.spreadMode;
  1518. var setRotation = function setRotation(angle) {
  1519. if ((0, _ui_utils.isValidRotation)(angle)) {
  1520. _this15.pdfViewer.pagesRotation = angle;
  1521. }
  1522. };
  1523. var setViewerModes = function setViewerModes(scroll, spread) {
  1524. if ((0, _ui_utils.isValidScrollMode)(scroll)) {
  1525. _this15.pdfViewer.scrollMode = scroll;
  1526. }
  1527. if ((0, _ui_utils.isValidSpreadMode)(spread)) {
  1528. _this15.pdfViewer.spreadMode = spread;
  1529. }
  1530. };
  1531. this.isInitialViewSet = true;
  1532. this.pdfSidebar.setInitialView(sidebarView);
  1533. setViewerModes(scrollMode, spreadMode);
  1534. if (this.initialBookmark) {
  1535. setRotation(this.initialRotation);
  1536. delete this.initialRotation;
  1537. this.pdfLinkService.setHash(this.initialBookmark);
  1538. this.initialBookmark = null;
  1539. } else if (storedHash) {
  1540. setRotation(rotation);
  1541. this.pdfLinkService.setHash(storedHash);
  1542. }
  1543. this.toolbar.setPageNumber(this.pdfViewer.currentPageNumber, this.pdfViewer.currentPageLabel);
  1544. this.secondaryToolbar.setPageNumber(this.pdfViewer.currentPageNumber);
  1545. if (!this.pdfViewer.currentScaleValue) {
  1546. this.pdfViewer.currentScaleValue = _ui_utils.DEFAULT_SCALE_VALUE;
  1547. }
  1548. },
  1549. cleanup: function cleanup() {
  1550. if (!this.pdfDocument) {
  1551. return;
  1552. }
  1553. this.pdfViewer.cleanup();
  1554. this.pdfThumbnailViewer.cleanup();
  1555. if (this.pdfViewer.renderer !== _ui_utils.RendererType.SVG) {
  1556. this.pdfDocument.cleanup();
  1557. }
  1558. },
  1559. forceRendering: function forceRendering() {
  1560. this.pdfRenderingQueue.printing = this.printing;
  1561. this.pdfRenderingQueue.isThumbnailViewEnabled = this.pdfSidebar.isThumbnailViewVisible;
  1562. this.pdfRenderingQueue.renderHighestPriority();
  1563. },
  1564. beforePrint: function beforePrint() {
  1565. var _this16 = this;
  1566. if (this.printService) {
  1567. return;
  1568. }
  1569. if (!this.supportsPrinting) {
  1570. this.l10n.get("printing_not_supported", null, "Warning: Printing is not fully supported by this browser.").then(function (printMessage) {
  1571. _this16.error(printMessage);
  1572. });
  1573. return;
  1574. }
  1575. if (!this.pdfViewer.pageViewsReady) {
  1576. this.l10n.get("printing_not_ready", null, "Warning: The PDF is not fully loaded for printing.").then(function (notReadyMessage) {
  1577. window.alert(notReadyMessage);
  1578. });
  1579. return;
  1580. }
  1581. var pagesOverview = this.pdfViewer.getPagesOverview();
  1582. var printContainer = this.appConfig.printContainer;
  1583. var printService = PDFPrintServiceFactory.instance.createPrintService(this.pdfDocument, pagesOverview, printContainer, this.l10n);
  1584. this.printService = printService;
  1585. this.forceRendering();
  1586. printService.layout();
  1587. this.externalServices.reportTelemetry({
  1588. type: "print"
  1589. });
  1590. },
  1591. afterPrint: function afterPrint() {
  1592. if (this.printService) {
  1593. this.printService.destroy();
  1594. this.printService = null;
  1595. }
  1596. this.forceRendering();
  1597. },
  1598. rotatePages: function rotatePages(delta) {
  1599. if (!this.pdfDocument) {
  1600. return;
  1601. }
  1602. var newRotation = (this.pdfViewer.pagesRotation + 360 + delta) % 360;
  1603. this.pdfViewer.pagesRotation = newRotation;
  1604. },
  1605. requestPresentationMode: function requestPresentationMode() {
  1606. if (!this.pdfPresentationMode) {
  1607. return;
  1608. }
  1609. this.pdfPresentationMode.request();
  1610. },
  1611. bindEvents: function bindEvents() {
  1612. var eventBus = this.eventBus,
  1613. _boundEvents = this._boundEvents;
  1614. _boundEvents.beforePrint = this.beforePrint.bind(this);
  1615. _boundEvents.afterPrint = this.afterPrint.bind(this);
  1616. eventBus._on("resize", webViewerResize);
  1617. eventBus._on("hashchange", webViewerHashchange);
  1618. eventBus._on("beforeprint", _boundEvents.beforePrint);
  1619. eventBus._on("afterprint", _boundEvents.afterPrint);
  1620. eventBus._on("pagerendered", webViewerPageRendered);
  1621. eventBus._on("updateviewarea", webViewerUpdateViewarea);
  1622. eventBus._on("pagechanging", webViewerPageChanging);
  1623. eventBus._on("scalechanging", webViewerScaleChanging);
  1624. eventBus._on("rotationchanging", webViewerRotationChanging);
  1625. eventBus._on("sidebarviewchanged", webViewerSidebarViewChanged);
  1626. eventBus._on("pagemode", webViewerPageMode);
  1627. eventBus._on("namedaction", webViewerNamedAction);
  1628. eventBus._on("presentationmodechanged", webViewerPresentationModeChanged);
  1629. eventBus._on("presentationmode", webViewerPresentationMode);
  1630. eventBus._on("print", webViewerPrint);
  1631. eventBus._on("download", webViewerDownload);
  1632. eventBus._on("firstpage", webViewerFirstPage);
  1633. eventBus._on("lastpage", webViewerLastPage);
  1634. eventBus._on("nextpage", webViewerNextPage);
  1635. eventBus._on("previouspage", webViewerPreviousPage);
  1636. eventBus._on("zoomin", webViewerZoomIn);
  1637. eventBus._on("zoomout", webViewerZoomOut);
  1638. eventBus._on("zoomreset", webViewerZoomReset);
  1639. eventBus._on("pagenumberchanged", webViewerPageNumberChanged);
  1640. eventBus._on("scalechanged", webViewerScaleChanged);
  1641. eventBus._on("rotatecw", webViewerRotateCw);
  1642. eventBus._on("rotateccw", webViewerRotateCcw);
  1643. eventBus._on("switchscrollmode", webViewerSwitchScrollMode);
  1644. eventBus._on("scrollmodechanged", webViewerScrollModeChanged);
  1645. eventBus._on("switchspreadmode", webViewerSwitchSpreadMode);
  1646. eventBus._on("spreadmodechanged", webViewerSpreadModeChanged);
  1647. eventBus._on("documentproperties", webViewerDocumentProperties);
  1648. eventBus._on("find", webViewerFind);
  1649. eventBus._on("findfromurlhash", webViewerFindFromUrlHash);
  1650. eventBus._on("updatefindmatchescount", webViewerUpdateFindMatchesCount);
  1651. eventBus._on("updatefindcontrolstate", webViewerUpdateFindControlState);
  1652. eventBus._on("fileinputchange", webViewerFileInputChange);
  1653. eventBus._on("openfile", webViewerOpenFile);
  1654. },
  1655. bindWindowEvents: function bindWindowEvents() {
  1656. var eventBus = this.eventBus,
  1657. _boundEvents = this._boundEvents;
  1658. _boundEvents.windowResize = function () {
  1659. eventBus.dispatch("resize", {
  1660. source: window
  1661. });
  1662. };
  1663. _boundEvents.windowHashChange = function () {
  1664. eventBus.dispatch("hashchange", {
  1665. source: window,
  1666. hash: document.location.hash.substring(1)
  1667. });
  1668. };
  1669. _boundEvents.windowBeforePrint = function () {
  1670. eventBus.dispatch("beforeprint", {
  1671. source: window
  1672. });
  1673. };
  1674. _boundEvents.windowAfterPrint = function () {
  1675. eventBus.dispatch("afterprint", {
  1676. source: window
  1677. });
  1678. };
  1679. window.addEventListener("visibilitychange", webViewerVisibilityChange);
  1680. window.addEventListener("wheel", webViewerWheel, {
  1681. passive: false
  1682. });
  1683. window.addEventListener("click", webViewerClick);
  1684. window.addEventListener("keydown", webViewerKeyDown);
  1685. window.addEventListener("resize", _boundEvents.windowResize);
  1686. window.addEventListener("hashchange", _boundEvents.windowHashChange);
  1687. window.addEventListener("beforeprint", _boundEvents.windowBeforePrint);
  1688. window.addEventListener("afterprint", _boundEvents.windowAfterPrint);
  1689. },
  1690. unbindEvents: function unbindEvents() {
  1691. var eventBus = this.eventBus,
  1692. _boundEvents = this._boundEvents;
  1693. eventBus._off("resize", webViewerResize);
  1694. eventBus._off("hashchange", webViewerHashchange);
  1695. eventBus._off("beforeprint", _boundEvents.beforePrint);
  1696. eventBus._off("afterprint", _boundEvents.afterPrint);
  1697. eventBus._off("pagerendered", webViewerPageRendered);
  1698. eventBus._off("updateviewarea", webViewerUpdateViewarea);
  1699. eventBus._off("pagechanging", webViewerPageChanging);
  1700. eventBus._off("scalechanging", webViewerScaleChanging);
  1701. eventBus._off("rotationchanging", webViewerRotationChanging);
  1702. eventBus._off("sidebarviewchanged", webViewerSidebarViewChanged);
  1703. eventBus._off("pagemode", webViewerPageMode);
  1704. eventBus._off("namedaction", webViewerNamedAction);
  1705. eventBus._off("presentationmodechanged", webViewerPresentationModeChanged);
  1706. eventBus._off("presentationmode", webViewerPresentationMode);
  1707. eventBus._off("print", webViewerPrint);
  1708. eventBus._off("download", webViewerDownload);
  1709. eventBus._off("firstpage", webViewerFirstPage);
  1710. eventBus._off("lastpage", webViewerLastPage);
  1711. eventBus._off("nextpage", webViewerNextPage);
  1712. eventBus._off("previouspage", webViewerPreviousPage);
  1713. eventBus._off("zoomin", webViewerZoomIn);
  1714. eventBus._off("zoomout", webViewerZoomOut);
  1715. eventBus._off("zoomreset", webViewerZoomReset);
  1716. eventBus._off("pagenumberchanged", webViewerPageNumberChanged);
  1717. eventBus._off("scalechanged", webViewerScaleChanged);
  1718. eventBus._off("rotatecw", webViewerRotateCw);
  1719. eventBus._off("rotateccw", webViewerRotateCcw);
  1720. eventBus._off("switchscrollmode", webViewerSwitchScrollMode);
  1721. eventBus._off("scrollmodechanged", webViewerScrollModeChanged);
  1722. eventBus._off("switchspreadmode", webViewerSwitchSpreadMode);
  1723. eventBus._off("spreadmodechanged", webViewerSpreadModeChanged);
  1724. eventBus._off("documentproperties", webViewerDocumentProperties);
  1725. eventBus._off("find", webViewerFind);
  1726. eventBus._off("findfromurlhash", webViewerFindFromUrlHash);
  1727. eventBus._off("updatefindmatchescount", webViewerUpdateFindMatchesCount);
  1728. eventBus._off("updatefindcontrolstate", webViewerUpdateFindControlState);
  1729. eventBus._off("fileinputchange", webViewerFileInputChange);
  1730. eventBus._off("openfile", webViewerOpenFile);
  1731. _boundEvents.beforePrint = null;
  1732. _boundEvents.afterPrint = null;
  1733. },
  1734. unbindWindowEvents: function unbindWindowEvents() {
  1735. var _boundEvents = this._boundEvents;
  1736. window.removeEventListener("visibilitychange", webViewerVisibilityChange);
  1737. window.removeEventListener("wheel", webViewerWheel, {
  1738. passive: false
  1739. });
  1740. window.removeEventListener("click", webViewerClick);
  1741. window.removeEventListener("keydown", webViewerKeyDown);
  1742. window.removeEventListener("resize", _boundEvents.windowResize);
  1743. window.removeEventListener("hashchange", _boundEvents.windowHashChange);
  1744. window.removeEventListener("beforeprint", _boundEvents.windowBeforePrint);
  1745. window.removeEventListener("afterprint", _boundEvents.windowAfterPrint);
  1746. _boundEvents.windowResize = null;
  1747. _boundEvents.windowHashChange = null;
  1748. _boundEvents.windowBeforePrint = null;
  1749. _boundEvents.windowAfterPrint = null;
  1750. }
  1751. };
  1752. exports.PDFViewerApplication = PDFViewerApplication;
  1753. var validateFileURL;
  1754. {
  1755. var HOSTED_VIEWER_ORIGINS = ["null", "http://mozilla.github.io", "https://mozilla.github.io"];
  1756. validateFileURL = function validateFileURL(file) {
  1757. if (file === undefined) {
  1758. return;
  1759. }
  1760. try {
  1761. var viewerOrigin = new URL(window.location.href).origin || "null";
  1762. if (HOSTED_VIEWER_ORIGINS.includes(viewerOrigin)) {
  1763. return;
  1764. }
  1765. var _URL = new URL(file, window.location.href),
  1766. origin = _URL.origin,
  1767. protocol = _URL.protocol;
  1768. if (origin !== viewerOrigin && protocol !== "blob:") {
  1769. // throw new Error("file origin does not match viewer's");
  1770. }
  1771. } catch (ex) {
  1772. var message = ex && ex.message;
  1773. PDFViewerApplication.l10n.get("loading_error", null, "An error occurred while loading the PDF.").then(function (loadingErrorMessage) {
  1774. PDFViewerApplication.error(loadingErrorMessage, {
  1775. message: message
  1776. });
  1777. });
  1778. throw ex;
  1779. }
  1780. };
  1781. }
  1782. function loadFakeWorker() {
  1783. return _loadFakeWorker.apply(this, arguments);
  1784. }
  1785. function _loadFakeWorker() {
  1786. _loadFakeWorker = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee13() {
  1787. return _regenerator["default"].wrap(function _callee13$(_context13) {
  1788. while (1) {
  1789. switch (_context13.prev = _context13.next) {
  1790. case 0:
  1791. if (!_pdfjsLib.GlobalWorkerOptions.workerSrc) {
  1792. _pdfjsLib.GlobalWorkerOptions.workerSrc = _app_options.AppOptions.get("workerSrc");
  1793. }
  1794. return _context13.abrupt("return", (0, _pdfjsLib.loadScript)(_pdfjsLib.PDFWorker.getWorkerSrc()));
  1795. case 2:
  1796. case "end":
  1797. return _context13.stop();
  1798. }
  1799. }
  1800. }, _callee13);
  1801. }));
  1802. return _loadFakeWorker.apply(this, arguments);
  1803. }
  1804. function loadAndEnablePDFBug(enabledTabs) {
  1805. var appConfig = PDFViewerApplication.appConfig;
  1806. return (0, _pdfjsLib.loadScript)(appConfig.debuggerScriptPath).then(function () {
  1807. PDFBug.enable(enabledTabs);
  1808. PDFBug.init({
  1809. OPS: _pdfjsLib.OPS
  1810. }, appConfig.mainContainer);
  1811. });
  1812. }
  1813. function webViewerInitialized() {
  1814. var appConfig = PDFViewerApplication.appConfig;
  1815. var file;
  1816. var queryString = document.location.search.substring(1);
  1817. var params = (0, _ui_utils.parseQueryString)(queryString);
  1818. // file = "file" in params ? params.file : _app_options.AppOptions.get("defaultUrl");
  1819. file = localStorage.getItem('r-print-url');
  1820. validateFileURL(file);
  1821. var fileInput = document.createElement("input");
  1822. fileInput.id = appConfig.openFileInputName;
  1823. fileInput.className = "fileInput";
  1824. fileInput.setAttribute("type", "file");
  1825. fileInput.oncontextmenu = _ui_utils.noContextMenuHandler;
  1826. document.body.appendChild(fileInput);
  1827. if (!window.File || !window.FileReader || !window.FileList || !window.Blob) {
  1828. appConfig.toolbar.openFile.setAttribute("hidden", "true");
  1829. appConfig.secondaryToolbar.openFileButton.setAttribute("hidden", "true");
  1830. } else {
  1831. fileInput.value = null;
  1832. }
  1833. fileInput.addEventListener("change", function (evt) {
  1834. var files = evt.target.files;
  1835. if (!files || files.length === 0) {
  1836. return;
  1837. }
  1838. PDFViewerApplication.eventBus.dispatch("fileinputchange", {
  1839. source: this,
  1840. fileInput: evt.target
  1841. });
  1842. });
  1843. appConfig.mainContainer.addEventListener("dragover", function (evt) {
  1844. evt.preventDefault();
  1845. evt.dataTransfer.dropEffect = "move";
  1846. });
  1847. appConfig.mainContainer.addEventListener("drop", function (evt) {
  1848. evt.preventDefault();
  1849. var files = evt.dataTransfer.files;
  1850. if (!files || files.length === 0) {
  1851. return;
  1852. }
  1853. PDFViewerApplication.eventBus.dispatch("fileinputchange", {
  1854. source: this,
  1855. fileInput: evt.dataTransfer
  1856. });
  1857. });
  1858. if (!PDFViewerApplication.supportsDocumentFonts) {
  1859. _app_options.AppOptions.set("disableFontFace", true);
  1860. PDFViewerApplication.l10n.get("web_fonts_disabled", null, "Web fonts are disabled: unable to use embedded PDF fonts.").then(function (msg) {
  1861. console.warn(msg);
  1862. });
  1863. }
  1864. if (!PDFViewerApplication.supportsPrinting) {
  1865. appConfig.toolbar.print.classList.add("hidden");
  1866. appConfig.secondaryToolbar.printButton.classList.add("hidden");
  1867. }
  1868. if (!PDFViewerApplication.supportsFullscreen) {
  1869. appConfig.toolbar.presentationModeButton.classList.add("hidden");
  1870. appConfig.secondaryToolbar.presentationModeButton.classList.add("hidden");
  1871. }
  1872. if (PDFViewerApplication.supportsIntegratedFind) {
  1873. appConfig.toolbar.viewFind.classList.add("hidden");
  1874. }
  1875. appConfig.mainContainer.addEventListener("transitionend", function (evt) {
  1876. if (evt.target === this) {
  1877. PDFViewerApplication.eventBus.dispatch("resize", {
  1878. source: this
  1879. });
  1880. }
  1881. }, true);
  1882. try {
  1883. webViewerOpenFileViaURL(file);
  1884. } catch (reason) {
  1885. PDFViewerApplication.l10n.get("loading_error", null, "An error occurred while loading the PDF.").then(function (msg) {
  1886. PDFViewerApplication.error(msg, reason);
  1887. });
  1888. }
  1889. }
  1890. var webViewerOpenFileViaURL;
  1891. {
  1892. webViewerOpenFileViaURL = function webViewerOpenFileViaURL(file) {
  1893. if (file && file.lastIndexOf("file:", 0) === 0) {
  1894. PDFViewerApplication.setTitleUsingUrl(file);
  1895. var xhr = new XMLHttpRequest();
  1896. xhr.onload = function () {
  1897. PDFViewerApplication.open(new Uint8Array(xhr.response));
  1898. };
  1899. xhr.open("GET", file);
  1900. xhr.responseType = "arraybuffer";
  1901. xhr.send();
  1902. return;
  1903. }
  1904. if (file) {
  1905. PDFViewerApplication.open(file);
  1906. }
  1907. };
  1908. }
  1909. function webViewerResetPermissions() {
  1910. var appConfig = PDFViewerApplication.appConfig;
  1911. if (!appConfig) {
  1912. return;
  1913. }
  1914. appConfig.viewerContainer.classList.remove(ENABLE_PERMISSIONS_CLASS);
  1915. }
  1916. function webViewerPageRendered(evt) {
  1917. var pageNumber = evt.pageNumber;
  1918. var pageIndex = pageNumber - 1;
  1919. var pageView = PDFViewerApplication.pdfViewer.getPageView(pageIndex);
  1920. if (pageNumber === PDFViewerApplication.page) {
  1921. PDFViewerApplication.toolbar.updateLoadingIndicatorState(false);
  1922. }
  1923. if (!pageView) {
  1924. return;
  1925. }
  1926. if (PDFViewerApplication.pdfSidebar.isThumbnailViewVisible) {
  1927. var thumbnailView = PDFViewerApplication.pdfThumbnailViewer.getThumbnail(pageIndex);
  1928. thumbnailView.setImage(pageView);
  1929. }
  1930. if (typeof Stats !== "undefined" && Stats.enabled && pageView.stats) {
  1931. Stats.add(pageNumber, pageView.stats);
  1932. }
  1933. if (pageView.error) {
  1934. PDFViewerApplication.l10n.get("rendering_error", null, "An error occurred while rendering the page.").then(function (msg) {
  1935. PDFViewerApplication.error(msg, pageView.error);
  1936. });
  1937. }
  1938. PDFViewerApplication.externalServices.reportTelemetry({
  1939. type: "pageInfo",
  1940. timestamp: evt.timestamp
  1941. });
  1942. PDFViewerApplication.pdfDocument.getStats().then(function (stats) {
  1943. PDFViewerApplication.externalServices.reportTelemetry({
  1944. type: "documentStats",
  1945. stats: stats
  1946. });
  1947. });
  1948. }
  1949. function webViewerPageMode(_ref7) {
  1950. var mode = _ref7.mode;
  1951. var view;
  1952. switch (mode) {
  1953. case "thumbs":
  1954. view = _pdf_sidebar.SidebarView.THUMBS;
  1955. break;
  1956. case "bookmarks":
  1957. case "outline":
  1958. view = _pdf_sidebar.SidebarView.OUTLINE;
  1959. break;
  1960. case "attachments":
  1961. view = _pdf_sidebar.SidebarView.ATTACHMENTS;
  1962. break;
  1963. case "none":
  1964. view = _pdf_sidebar.SidebarView.NONE;
  1965. break;
  1966. default:
  1967. console.error('Invalid "pagemode" hash parameter: ' + mode);
  1968. return;
  1969. }
  1970. PDFViewerApplication.pdfSidebar.switchView(view, true);
  1971. }
  1972. function webViewerNamedAction(evt) {
  1973. var action = evt.action;
  1974. switch (action) {
  1975. case "GoToPage":
  1976. PDFViewerApplication.appConfig.toolbar.pageNumber.select();
  1977. break;
  1978. case "Find":
  1979. if (!PDFViewerApplication.supportsIntegratedFind) {
  1980. PDFViewerApplication.findBar.toggle();
  1981. }
  1982. break;
  1983. }
  1984. }
  1985. function webViewerPresentationModeChanged(_ref8) {
  1986. var active = _ref8.active,
  1987. switchInProgress = _ref8.switchInProgress;
  1988. var state = _ui_utils.PresentationModeState.NORMAL;
  1989. if (switchInProgress) {
  1990. state = _ui_utils.PresentationModeState.CHANGING;
  1991. } else if (active) {
  1992. state = _ui_utils.PresentationModeState.FULLSCREEN;
  1993. }
  1994. PDFViewerApplication.pdfViewer.presentationModeState = state;
  1995. }
  1996. function webViewerSidebarViewChanged(evt) {
  1997. PDFViewerApplication.pdfRenderingQueue.isThumbnailViewEnabled = PDFViewerApplication.pdfSidebar.isThumbnailViewVisible;
  1998. var store = PDFViewerApplication.store;
  1999. if (store && PDFViewerApplication.isInitialViewSet) {
  2000. store.set("sidebarView", evt.view)["catch"](function () {});
  2001. }
  2002. }
  2003. function webViewerUpdateViewarea(evt) {
  2004. var location = evt.location,
  2005. store = PDFViewerApplication.store;
  2006. if (store && PDFViewerApplication.isInitialViewSet) {
  2007. store.setMultiple({
  2008. page: location.pageNumber,
  2009. zoom: location.scale,
  2010. scrollLeft: location.left,
  2011. scrollTop: location.top,
  2012. rotation: location.rotation
  2013. })["catch"](function () {});
  2014. }
  2015. var href = PDFViewerApplication.pdfLinkService.getAnchorUrl(location.pdfOpenParams);
  2016. PDFViewerApplication.appConfig.toolbar.viewBookmark.href = href;
  2017. PDFViewerApplication.appConfig.secondaryToolbar.viewBookmarkButton.href = href;
  2018. var currentPage = PDFViewerApplication.pdfViewer.getPageView(PDFViewerApplication.page - 1);
  2019. var loading = currentPage.renderingState !== _pdf_rendering_queue.RenderingStates.FINISHED;
  2020. PDFViewerApplication.toolbar.updateLoadingIndicatorState(loading);
  2021. }
  2022. function webViewerScrollModeChanged(evt) {
  2023. var store = PDFViewerApplication.store;
  2024. if (store && PDFViewerApplication.isInitialViewSet) {
  2025. store.set("scrollMode", evt.mode)["catch"](function () {});
  2026. }
  2027. }
  2028. function webViewerSpreadModeChanged(evt) {
  2029. var store = PDFViewerApplication.store;
  2030. if (store && PDFViewerApplication.isInitialViewSet) {
  2031. store.set("spreadMode", evt.mode)["catch"](function () {});
  2032. }
  2033. }
  2034. function webViewerResize() {
  2035. var pdfDocument = PDFViewerApplication.pdfDocument,
  2036. pdfViewer = PDFViewerApplication.pdfViewer;
  2037. if (!pdfDocument) {
  2038. return;
  2039. }
  2040. var currentScaleValue = pdfViewer.currentScaleValue;
  2041. if (currentScaleValue === "auto" || currentScaleValue === "page-fit" || currentScaleValue === "page-width") {
  2042. pdfViewer.currentScaleValue = currentScaleValue;
  2043. }
  2044. pdfViewer.update();
  2045. }
  2046. function webViewerHashchange(evt) {
  2047. var hash = evt.hash;
  2048. if (!hash) {
  2049. return;
  2050. }
  2051. if (!PDFViewerApplication.isInitialViewSet) {
  2052. PDFViewerApplication.initialBookmark = hash;
  2053. } else if (!PDFViewerApplication.pdfHistory.popStateInProgress) {
  2054. PDFViewerApplication.pdfLinkService.setHash(hash);
  2055. }
  2056. }
  2057. var webViewerFileInputChange, webViewerOpenFile;
  2058. {
  2059. webViewerFileInputChange = function webViewerFileInputChange(evt) {
  2060. if (PDFViewerApplication.pdfViewer && PDFViewerApplication.pdfViewer.isInPresentationMode) {
  2061. return;
  2062. }
  2063. var file = evt.fileInput.files[0];
  2064. if (!_app_options.AppOptions.get("disableCreateObjectURL")) {
  2065. var url = URL.createObjectURL(file);
  2066. if (file.name) {
  2067. url = {
  2068. url: url,
  2069. originalUrl: file.name
  2070. };
  2071. }
  2072. PDFViewerApplication.open(url);
  2073. } else {
  2074. PDFViewerApplication.setTitleUsingUrl(file.name);
  2075. var fileReader = new FileReader();
  2076. fileReader.onload = function webViewerChangeFileReaderOnload(event) {
  2077. var buffer = event.target.result;
  2078. PDFViewerApplication.open(new Uint8Array(buffer));
  2079. };
  2080. fileReader.readAsArrayBuffer(file);
  2081. }
  2082. var appConfig = PDFViewerApplication.appConfig;
  2083. appConfig.toolbar.viewBookmark.setAttribute("hidden", "true");
  2084. appConfig.secondaryToolbar.viewBookmarkButton.setAttribute("hidden", "true");
  2085. appConfig.toolbar.download.setAttribute("hidden", "true");
  2086. appConfig.secondaryToolbar.downloadButton.setAttribute("hidden", "true");
  2087. };
  2088. webViewerOpenFile = function webViewerOpenFile(evt) {
  2089. var openFileInputName = PDFViewerApplication.appConfig.openFileInputName;
  2090. document.getElementById(openFileInputName).click();
  2091. };
  2092. }
  2093. function webViewerPresentationMode() {
  2094. PDFViewerApplication.requestPresentationMode();
  2095. }
  2096. function webViewerPrint() {
  2097. window.print();
  2098. }
  2099. function webViewerDownload() {
  2100. PDFViewerApplication.download();
  2101. }
  2102. function webViewerFirstPage() {
  2103. if (PDFViewerApplication.pdfDocument) {
  2104. PDFViewerApplication.page = 1;
  2105. }
  2106. }
  2107. function webViewerLastPage() {
  2108. if (PDFViewerApplication.pdfDocument) {
  2109. PDFViewerApplication.page = PDFViewerApplication.pagesCount;
  2110. }
  2111. }
  2112. function webViewerNextPage() {
  2113. PDFViewerApplication.page++;
  2114. }
  2115. function webViewerPreviousPage() {
  2116. PDFViewerApplication.page--;
  2117. }
  2118. function webViewerZoomIn() {
  2119. PDFViewerApplication.zoomIn();
  2120. }
  2121. function webViewerZoomOut() {
  2122. PDFViewerApplication.zoomOut();
  2123. }
  2124. function webViewerZoomReset() {
  2125. PDFViewerApplication.zoomReset();
  2126. }
  2127. function webViewerPageNumberChanged(evt) {
  2128. var pdfViewer = PDFViewerApplication.pdfViewer;
  2129. if (evt.value !== "") {
  2130. pdfViewer.currentPageLabel = evt.value;
  2131. }
  2132. if (evt.value !== pdfViewer.currentPageNumber.toString() && evt.value !== pdfViewer.currentPageLabel) {
  2133. PDFViewerApplication.toolbar.setPageNumber(pdfViewer.currentPageNumber, pdfViewer.currentPageLabel);
  2134. }
  2135. }
  2136. function webViewerScaleChanged(evt) {
  2137. PDFViewerApplication.pdfViewer.currentScaleValue = evt.value;
  2138. }
  2139. function webViewerRotateCw() {
  2140. PDFViewerApplication.rotatePages(90);
  2141. }
  2142. function webViewerRotateCcw() {
  2143. PDFViewerApplication.rotatePages(-90);
  2144. }
  2145. function webViewerSwitchScrollMode(evt) {
  2146. PDFViewerApplication.pdfViewer.scrollMode = evt.mode;
  2147. }
  2148. function webViewerSwitchSpreadMode(evt) {
  2149. PDFViewerApplication.pdfViewer.spreadMode = evt.mode;
  2150. }
  2151. function webViewerDocumentProperties() {
  2152. PDFViewerApplication.pdfDocumentProperties.open();
  2153. }
  2154. function webViewerFind(evt) {
  2155. PDFViewerApplication.findController.executeCommand("find" + evt.type, {
  2156. query: evt.query,
  2157. phraseSearch: evt.phraseSearch,
  2158. caseSensitive: evt.caseSensitive,
  2159. entireWord: evt.entireWord,
  2160. highlightAll: evt.highlightAll,
  2161. findPrevious: evt.findPrevious
  2162. });
  2163. }
  2164. function webViewerFindFromUrlHash(evt) {
  2165. PDFViewerApplication.findController.executeCommand("find", {
  2166. query: evt.query,
  2167. phraseSearch: evt.phraseSearch,
  2168. caseSensitive: false,
  2169. entireWord: false,
  2170. highlightAll: true,
  2171. findPrevious: false
  2172. });
  2173. }
  2174. function webViewerUpdateFindMatchesCount(_ref9) {
  2175. var matchesCount = _ref9.matchesCount;
  2176. if (PDFViewerApplication.supportsIntegratedFind) {
  2177. PDFViewerApplication.externalServices.updateFindMatchesCount(matchesCount);
  2178. } else {
  2179. PDFViewerApplication.findBar.updateResultsCount(matchesCount);
  2180. }
  2181. }
  2182. function webViewerUpdateFindControlState(_ref10) {
  2183. var state = _ref10.state,
  2184. previous = _ref10.previous,
  2185. matchesCount = _ref10.matchesCount;
  2186. if (PDFViewerApplication.supportsIntegratedFind) {
  2187. PDFViewerApplication.externalServices.updateFindControlState({
  2188. result: state,
  2189. findPrevious: previous,
  2190. matchesCount: matchesCount
  2191. });
  2192. } else {
  2193. PDFViewerApplication.findBar.updateUIState(state, previous, matchesCount);
  2194. }
  2195. }
  2196. function webViewerScaleChanging(evt) {
  2197. PDFViewerApplication.toolbar.setPageScale(evt.presetValue, evt.scale);
  2198. PDFViewerApplication.pdfViewer.update();
  2199. }
  2200. function webViewerRotationChanging(evt) {
  2201. PDFViewerApplication.pdfThumbnailViewer.pagesRotation = evt.pagesRotation;
  2202. PDFViewerApplication.forceRendering();
  2203. PDFViewerApplication.pdfViewer.currentPageNumber = evt.pageNumber;
  2204. }
  2205. function webViewerPageChanging(evt) {
  2206. var page = evt.pageNumber;
  2207. PDFViewerApplication.toolbar.setPageNumber(page, evt.pageLabel || null);
  2208. PDFViewerApplication.secondaryToolbar.setPageNumber(page);
  2209. if (PDFViewerApplication.pdfSidebar.isThumbnailViewVisible) {
  2210. PDFViewerApplication.pdfThumbnailViewer.scrollThumbnailIntoView(page);
  2211. }
  2212. if (typeof Stats !== "undefined" && Stats.enabled) {
  2213. var pageView = PDFViewerApplication.pdfViewer.getPageView(page - 1);
  2214. if (pageView && pageView.stats) {
  2215. Stats.add(page, pageView.stats);
  2216. }
  2217. }
  2218. }
  2219. function webViewerVisibilityChange(evt) {
  2220. if (document.visibilityState === "visible") {
  2221. setZoomDisabledTimeout();
  2222. }
  2223. }
  2224. var zoomDisabledTimeout = null;
  2225. function setZoomDisabledTimeout() {
  2226. if (zoomDisabledTimeout) {
  2227. clearTimeout(zoomDisabledTimeout);
  2228. }
  2229. zoomDisabledTimeout = setTimeout(function () {
  2230. zoomDisabledTimeout = null;
  2231. }, WHEEL_ZOOM_DISABLED_TIMEOUT);
  2232. }
  2233. function webViewerWheel(evt) {
  2234. var pdfViewer = PDFViewerApplication.pdfViewer,
  2235. supportedMouseWheelZoomModifierKeys = PDFViewerApplication.supportedMouseWheelZoomModifierKeys;
  2236. if (pdfViewer.isInPresentationMode) {
  2237. return;
  2238. }
  2239. if (evt.ctrlKey && supportedMouseWheelZoomModifierKeys.ctrlKey || evt.metaKey && supportedMouseWheelZoomModifierKeys.metaKey) {
  2240. evt.preventDefault();
  2241. if (zoomDisabledTimeout || document.visibilityState === "hidden") {
  2242. return;
  2243. }
  2244. var previousScale = pdfViewer.currentScale;
  2245. var delta = (0, _ui_utils.normalizeWheelEventDelta)(evt);
  2246. var MOUSE_WHEEL_DELTA_PER_PAGE_SCALE = 3.0;
  2247. var ticks = delta * MOUSE_WHEEL_DELTA_PER_PAGE_SCALE;
  2248. if (ticks < 0) {
  2249. PDFViewerApplication.zoomOut(-ticks);
  2250. } else {
  2251. PDFViewerApplication.zoomIn(ticks);
  2252. }
  2253. var currentScale = pdfViewer.currentScale;
  2254. if (previousScale !== currentScale) {
  2255. var scaleCorrectionFactor = currentScale / previousScale - 1;
  2256. var rect = pdfViewer.container.getBoundingClientRect();
  2257. var dx = evt.clientX - rect.left;
  2258. var dy = evt.clientY - rect.top;
  2259. pdfViewer.container.scrollLeft += dx * scaleCorrectionFactor;
  2260. pdfViewer.container.scrollTop += dy * scaleCorrectionFactor;
  2261. }
  2262. } else {
  2263. setZoomDisabledTimeout();
  2264. }
  2265. }
  2266. function webViewerClick(evt) {
  2267. if (!PDFViewerApplication.secondaryToolbar.isOpen) {
  2268. return;
  2269. }
  2270. var appConfig = PDFViewerApplication.appConfig;
  2271. if (PDFViewerApplication.pdfViewer.containsElement(evt.target) || appConfig.toolbar.container.contains(evt.target) && evt.target !== appConfig.secondaryToolbar.toggleButton) {
  2272. PDFViewerApplication.secondaryToolbar.close();
  2273. }
  2274. }
  2275. function webViewerKeyDown(evt) {
  2276. if (PDFViewerApplication.overlayManager.active) {
  2277. return;
  2278. }
  2279. var handled = false,
  2280. ensureViewerFocused = false;
  2281. var cmd = (evt.ctrlKey ? 1 : 0) | (evt.altKey ? 2 : 0) | (evt.shiftKey ? 4 : 0) | (evt.metaKey ? 8 : 0);
  2282. var pdfViewer = PDFViewerApplication.pdfViewer;
  2283. var isViewerInPresentationMode = pdfViewer && pdfViewer.isInPresentationMode;
  2284. if (cmd === 1 || cmd === 8 || cmd === 5 || cmd === 12) {
  2285. switch (evt.keyCode) {
  2286. case 70:
  2287. if (!PDFViewerApplication.supportsIntegratedFind) {
  2288. PDFViewerApplication.findBar.open();
  2289. handled = true;
  2290. }
  2291. break;
  2292. case 71:
  2293. if (!PDFViewerApplication.supportsIntegratedFind) {
  2294. var findState = PDFViewerApplication.findController.state;
  2295. if (findState) {
  2296. PDFViewerApplication.findController.executeCommand("findagain", {
  2297. query: findState.query,
  2298. phraseSearch: findState.phraseSearch,
  2299. caseSensitive: findState.caseSensitive,
  2300. entireWord: findState.entireWord,
  2301. highlightAll: findState.highlightAll,
  2302. findPrevious: cmd === 5 || cmd === 12
  2303. });
  2304. }
  2305. handled = true;
  2306. }
  2307. break;
  2308. case 61:
  2309. case 107:
  2310. case 187:
  2311. case 171:
  2312. if (!isViewerInPresentationMode) {
  2313. PDFViewerApplication.zoomIn();
  2314. }
  2315. handled = true;
  2316. break;
  2317. case 173:
  2318. case 109:
  2319. case 189:
  2320. if (!isViewerInPresentationMode) {
  2321. PDFViewerApplication.zoomOut();
  2322. }
  2323. handled = true;
  2324. break;
  2325. case 48:
  2326. case 96:
  2327. if (!isViewerInPresentationMode) {
  2328. setTimeout(function () {
  2329. PDFViewerApplication.zoomReset();
  2330. });
  2331. handled = false;
  2332. }
  2333. break;
  2334. case 38:
  2335. if (isViewerInPresentationMode || PDFViewerApplication.page > 1) {
  2336. PDFViewerApplication.page = 1;
  2337. handled = true;
  2338. ensureViewerFocused = true;
  2339. }
  2340. break;
  2341. case 40:
  2342. if (isViewerInPresentationMode || PDFViewerApplication.page < PDFViewerApplication.pagesCount) {
  2343. PDFViewerApplication.page = PDFViewerApplication.pagesCount;
  2344. handled = true;
  2345. ensureViewerFocused = true;
  2346. }
  2347. break;
  2348. }
  2349. }
  2350. var eventBus = PDFViewerApplication.eventBus;
  2351. if (cmd === 1 || cmd === 8) {
  2352. switch (evt.keyCode) {
  2353. case 83:
  2354. eventBus.dispatch("download", {
  2355. source: window
  2356. });
  2357. handled = true;
  2358. break;
  2359. case 79:
  2360. {
  2361. eventBus.dispatch("openfile", {
  2362. source: window
  2363. });
  2364. handled = true;
  2365. }
  2366. break;
  2367. }
  2368. }
  2369. if (cmd === 3 || cmd === 10) {
  2370. switch (evt.keyCode) {
  2371. case 80:
  2372. PDFViewerApplication.requestPresentationMode();
  2373. handled = true;
  2374. break;
  2375. case 71:
  2376. PDFViewerApplication.appConfig.toolbar.pageNumber.select();
  2377. handled = true;
  2378. break;
  2379. }
  2380. }
  2381. if (handled) {
  2382. if (ensureViewerFocused && !isViewerInPresentationMode) {
  2383. pdfViewer.focus();
  2384. }
  2385. evt.preventDefault();
  2386. return;
  2387. }
  2388. var curElement = document.activeElement || document.querySelector(":focus");
  2389. var curElementTagName = curElement && curElement.tagName.toUpperCase();
  2390. if (curElementTagName === "INPUT" || curElementTagName === "TEXTAREA" || curElementTagName === "SELECT" || curElement && curElement.isContentEditable) {
  2391. if (evt.keyCode !== 27) {
  2392. return;
  2393. }
  2394. }
  2395. if (cmd === 0) {
  2396. var turnPage = 0,
  2397. turnOnlyIfPageFit = false;
  2398. switch (evt.keyCode) {
  2399. case 38:
  2400. case 33:
  2401. if (pdfViewer.isVerticalScrollbarEnabled) {
  2402. turnOnlyIfPageFit = true;
  2403. }
  2404. turnPage = -1;
  2405. break;
  2406. case 8:
  2407. if (!isViewerInPresentationMode) {
  2408. turnOnlyIfPageFit = true;
  2409. }
  2410. turnPage = -1;
  2411. break;
  2412. case 37:
  2413. if (pdfViewer.isHorizontalScrollbarEnabled) {
  2414. turnOnlyIfPageFit = true;
  2415. }
  2416. case 75:
  2417. case 80:
  2418. turnPage = -1;
  2419. break;
  2420. case 27:
  2421. if (PDFViewerApplication.secondaryToolbar.isOpen) {
  2422. PDFViewerApplication.secondaryToolbar.close();
  2423. handled = true;
  2424. }
  2425. if (!PDFViewerApplication.supportsIntegratedFind && PDFViewerApplication.findBar.opened) {
  2426. PDFViewerApplication.findBar.close();
  2427. handled = true;
  2428. }
  2429. break;
  2430. case 40:
  2431. case 34:
  2432. if (pdfViewer.isVerticalScrollbarEnabled) {
  2433. turnOnlyIfPageFit = true;
  2434. }
  2435. turnPage = 1;
  2436. break;
  2437. case 13:
  2438. case 32:
  2439. if (!isViewerInPresentationMode) {
  2440. turnOnlyIfPageFit = true;
  2441. }
  2442. turnPage = 1;
  2443. break;
  2444. case 39:
  2445. if (pdfViewer.isHorizontalScrollbarEnabled) {
  2446. turnOnlyIfPageFit = true;
  2447. }
  2448. case 74:
  2449. case 78:
  2450. turnPage = 1;
  2451. break;
  2452. case 36:
  2453. if (isViewerInPresentationMode || PDFViewerApplication.page > 1) {
  2454. PDFViewerApplication.page = 1;
  2455. handled = true;
  2456. ensureViewerFocused = true;
  2457. }
  2458. break;
  2459. case 35:
  2460. if (isViewerInPresentationMode || PDFViewerApplication.page < PDFViewerApplication.pagesCount) {
  2461. PDFViewerApplication.page = PDFViewerApplication.pagesCount;
  2462. handled = true;
  2463. ensureViewerFocused = true;
  2464. }
  2465. break;
  2466. case 83:
  2467. PDFViewerApplication.pdfCursorTools.switchTool(_pdf_cursor_tools.CursorTool.SELECT);
  2468. break;
  2469. case 72:
  2470. PDFViewerApplication.pdfCursorTools.switchTool(_pdf_cursor_tools.CursorTool.HAND);
  2471. break;
  2472. case 82:
  2473. PDFViewerApplication.rotatePages(90);
  2474. break;
  2475. case 115:
  2476. PDFViewerApplication.pdfSidebar.toggle();
  2477. break;
  2478. }
  2479. if (turnPage !== 0 && (!turnOnlyIfPageFit || pdfViewer.currentScaleValue === "page-fit")) {
  2480. if (turnPage > 0) {
  2481. if (PDFViewerApplication.page < PDFViewerApplication.pagesCount) {
  2482. PDFViewerApplication.page++;
  2483. }
  2484. } else {
  2485. if (PDFViewerApplication.page > 1) {
  2486. PDFViewerApplication.page--;
  2487. }
  2488. }
  2489. handled = true;
  2490. }
  2491. }
  2492. if (cmd === 4) {
  2493. switch (evt.keyCode) {
  2494. case 13:
  2495. case 32:
  2496. if (!isViewerInPresentationMode && pdfViewer.currentScaleValue !== "page-fit") {
  2497. break;
  2498. }
  2499. if (PDFViewerApplication.page > 1) {
  2500. PDFViewerApplication.page--;
  2501. }
  2502. handled = true;
  2503. break;
  2504. case 82:
  2505. PDFViewerApplication.rotatePages(-90);
  2506. break;
  2507. }
  2508. }
  2509. if (!handled && !isViewerInPresentationMode) {
  2510. if (evt.keyCode >= 33 && evt.keyCode <= 40 || evt.keyCode === 32 && curElementTagName !== "BUTTON") {
  2511. ensureViewerFocused = true;
  2512. }
  2513. }
  2514. if (ensureViewerFocused && !pdfViewer.containsElement(curElement)) {
  2515. pdfViewer.focus();
  2516. }
  2517. if (handled) {
  2518. evt.preventDefault();
  2519. }
  2520. }
  2521. function apiPageLayoutToSpreadMode(layout) {
  2522. switch (layout) {
  2523. case "SinglePage":
  2524. case "OneColumn":
  2525. return _ui_utils.SpreadMode.NONE;
  2526. case "TwoColumnLeft":
  2527. case "TwoPageLeft":
  2528. return _ui_utils.SpreadMode.ODD;
  2529. case "TwoColumnRight":
  2530. case "TwoPageRight":
  2531. return _ui_utils.SpreadMode.EVEN;
  2532. }
  2533. return _ui_utils.SpreadMode.NONE;
  2534. }
  2535. function apiPageModeToSidebarView(mode) {
  2536. switch (mode) {
  2537. case "UseNone":
  2538. return _pdf_sidebar.SidebarView.NONE;
  2539. case "UseThumbs":
  2540. return _pdf_sidebar.SidebarView.THUMBS;
  2541. case "UseOutlines":
  2542. return _pdf_sidebar.SidebarView.OUTLINE;
  2543. case "UseAttachments":
  2544. return _pdf_sidebar.SidebarView.ATTACHMENTS;
  2545. case "UseOC":
  2546. }
  2547. return _pdf_sidebar.SidebarView.NONE;
  2548. }
  2549. var PDFPrintServiceFactory = {
  2550. instance: {
  2551. supportsPrinting: false,
  2552. createPrintService: function createPrintService() {
  2553. throw new Error("Not implemented: createPrintService");
  2554. }
  2555. }
  2556. };
  2557. exports.PDFPrintServiceFactory = PDFPrintServiceFactory;
  2558. /***/ }),
  2559. /* 2 */
  2560. /***/ (function(module, exports, __webpack_require__) {
  2561. "use strict";
  2562. module.exports = __webpack_require__(3);
  2563. /***/ }),
  2564. /* 3 */
  2565. /***/ (function(module, exports, __webpack_require__) {
  2566. "use strict";
  2567. /* WEBPACK VAR INJECTION */(function(module) {
  2568. 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); }
  2569. var runtime = function (exports) {
  2570. "use strict";
  2571. var Op = Object.prototype;
  2572. var hasOwn = Op.hasOwnProperty;
  2573. var undefined;
  2574. var $Symbol = typeof Symbol === "function" ? Symbol : {};
  2575. var iteratorSymbol = $Symbol.iterator || "@@iterator";
  2576. var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator";
  2577. var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
  2578. function wrap(innerFn, outerFn, self, tryLocsList) {
  2579. var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator;
  2580. var generator = Object.create(protoGenerator.prototype);
  2581. var context = new Context(tryLocsList || []);
  2582. generator._invoke = makeInvokeMethod(innerFn, self, context);
  2583. return generator;
  2584. }
  2585. exports.wrap = wrap;
  2586. function tryCatch(fn, obj, arg) {
  2587. try {
  2588. return {
  2589. type: "normal",
  2590. arg: fn.call(obj, arg)
  2591. };
  2592. } catch (err) {
  2593. return {
  2594. type: "throw",
  2595. arg: err
  2596. };
  2597. }
  2598. }
  2599. var GenStateSuspendedStart = "suspendedStart";
  2600. var GenStateSuspendedYield = "suspendedYield";
  2601. var GenStateExecuting = "executing";
  2602. var GenStateCompleted = "completed";
  2603. var ContinueSentinel = {};
  2604. function Generator() {}
  2605. function GeneratorFunction() {}
  2606. function GeneratorFunctionPrototype() {}
  2607. var IteratorPrototype = {};
  2608. IteratorPrototype[iteratorSymbol] = function () {
  2609. return this;
  2610. };
  2611. var getProto = Object.getPrototypeOf;
  2612. var NativeIteratorPrototype = getProto && getProto(getProto(values([])));
  2613. if (NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) {
  2614. IteratorPrototype = NativeIteratorPrototype;
  2615. }
  2616. var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype);
  2617. GeneratorFunction.prototype = Gp.constructor = GeneratorFunctionPrototype;
  2618. GeneratorFunctionPrototype.constructor = GeneratorFunction;
  2619. GeneratorFunctionPrototype[toStringTagSymbol] = GeneratorFunction.displayName = "GeneratorFunction";
  2620. function defineIteratorMethods(prototype) {
  2621. ["next", "throw", "return"].forEach(function (method) {
  2622. prototype[method] = function (arg) {
  2623. return this._invoke(method, arg);
  2624. };
  2625. });
  2626. }
  2627. exports.isGeneratorFunction = function (genFun) {
  2628. var ctor = typeof genFun === "function" && genFun.constructor;
  2629. return ctor ? ctor === GeneratorFunction || (ctor.displayName || ctor.name) === "GeneratorFunction" : false;
  2630. };
  2631. exports.mark = function (genFun) {
  2632. if (Object.setPrototypeOf) {
  2633. Object.setPrototypeOf(genFun, GeneratorFunctionPrototype);
  2634. } else {
  2635. genFun.__proto__ = GeneratorFunctionPrototype;
  2636. if (!(toStringTagSymbol in genFun)) {
  2637. genFun[toStringTagSymbol] = "GeneratorFunction";
  2638. }
  2639. }
  2640. genFun.prototype = Object.create(Gp);
  2641. return genFun;
  2642. };
  2643. exports.awrap = function (arg) {
  2644. return {
  2645. __await: arg
  2646. };
  2647. };
  2648. function AsyncIterator(generator, PromiseImpl) {
  2649. function invoke(method, arg, resolve, reject) {
  2650. var record = tryCatch(generator[method], generator, arg);
  2651. if (record.type === "throw") {
  2652. reject(record.arg);
  2653. } else {
  2654. var result = record.arg;
  2655. var value = result.value;
  2656. if (value && _typeof(value) === "object" && hasOwn.call(value, "__await")) {
  2657. return PromiseImpl.resolve(value.__await).then(function (value) {
  2658. invoke("next", value, resolve, reject);
  2659. }, function (err) {
  2660. invoke("throw", err, resolve, reject);
  2661. });
  2662. }
  2663. return PromiseImpl.resolve(value).then(function (unwrapped) {
  2664. result.value = unwrapped;
  2665. resolve(result);
  2666. }, function (error) {
  2667. return invoke("throw", error, resolve, reject);
  2668. });
  2669. }
  2670. }
  2671. var previousPromise;
  2672. function enqueue(method, arg) {
  2673. function callInvokeWithMethodAndArg() {
  2674. return new PromiseImpl(function (resolve, reject) {
  2675. invoke(method, arg, resolve, reject);
  2676. });
  2677. }
  2678. return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
  2679. }
  2680. this._invoke = enqueue;
  2681. }
  2682. defineIteratorMethods(AsyncIterator.prototype);
  2683. AsyncIterator.prototype[asyncIteratorSymbol] = function () {
  2684. return this;
  2685. };
  2686. exports.AsyncIterator = AsyncIterator;
  2687. exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) {
  2688. if (PromiseImpl === void 0) PromiseImpl = Promise;
  2689. var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl);
  2690. return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) {
  2691. return result.done ? result.value : iter.next();
  2692. });
  2693. };
  2694. function makeInvokeMethod(innerFn, self, context) {
  2695. var state = GenStateSuspendedStart;
  2696. return function invoke(method, arg) {
  2697. if (state === GenStateExecuting) {
  2698. throw new Error("Generator is already running");
  2699. }
  2700. if (state === GenStateCompleted) {
  2701. if (method === "throw") {
  2702. throw arg;
  2703. }
  2704. return doneResult();
  2705. }
  2706. context.method = method;
  2707. context.arg = arg;
  2708. while (true) {
  2709. var delegate = context.delegate;
  2710. if (delegate) {
  2711. var delegateResult = maybeInvokeDelegate(delegate, context);
  2712. if (delegateResult) {
  2713. if (delegateResult === ContinueSentinel) continue;
  2714. return delegateResult;
  2715. }
  2716. }
  2717. if (context.method === "next") {
  2718. context.sent = context._sent = context.arg;
  2719. } else if (context.method === "throw") {
  2720. if (state === GenStateSuspendedStart) {
  2721. state = GenStateCompleted;
  2722. throw context.arg;
  2723. }
  2724. context.dispatchException(context.arg);
  2725. } else if (context.method === "return") {
  2726. context.abrupt("return", context.arg);
  2727. }
  2728. state = GenStateExecuting;
  2729. var record = tryCatch(innerFn, self, context);
  2730. if (record.type === "normal") {
  2731. state = context.done ? GenStateCompleted : GenStateSuspendedYield;
  2732. if (record.arg === ContinueSentinel) {
  2733. continue;
  2734. }
  2735. return {
  2736. value: record.arg,
  2737. done: context.done
  2738. };
  2739. } else if (record.type === "throw") {
  2740. state = GenStateCompleted;
  2741. context.method = "throw";
  2742. context.arg = record.arg;
  2743. }
  2744. }
  2745. };
  2746. }
  2747. function maybeInvokeDelegate(delegate, context) {
  2748. var method = delegate.iterator[context.method];
  2749. if (method === undefined) {
  2750. context.delegate = null;
  2751. if (context.method === "throw") {
  2752. if (delegate.iterator["return"]) {
  2753. context.method = "return";
  2754. context.arg = undefined;
  2755. maybeInvokeDelegate(delegate, context);
  2756. if (context.method === "throw") {
  2757. return ContinueSentinel;
  2758. }
  2759. }
  2760. context.method = "throw";
  2761. context.arg = new TypeError("The iterator does not provide a 'throw' method");
  2762. }
  2763. return ContinueSentinel;
  2764. }
  2765. var record = tryCatch(method, delegate.iterator, context.arg);
  2766. if (record.type === "throw") {
  2767. context.method = "throw";
  2768. context.arg = record.arg;
  2769. context.delegate = null;
  2770. return ContinueSentinel;
  2771. }
  2772. var info = record.arg;
  2773. if (!info) {
  2774. context.method = "throw";
  2775. context.arg = new TypeError("iterator result is not an object");
  2776. context.delegate = null;
  2777. return ContinueSentinel;
  2778. }
  2779. if (info.done) {
  2780. context[delegate.resultName] = info.value;
  2781. context.next = delegate.nextLoc;
  2782. if (context.method !== "return") {
  2783. context.method = "next";
  2784. context.arg = undefined;
  2785. }
  2786. } else {
  2787. return info;
  2788. }
  2789. context.delegate = null;
  2790. return ContinueSentinel;
  2791. }
  2792. defineIteratorMethods(Gp);
  2793. Gp[toStringTagSymbol] = "Generator";
  2794. Gp[iteratorSymbol] = function () {
  2795. return this;
  2796. };
  2797. Gp.toString = function () {
  2798. return "[object Generator]";
  2799. };
  2800. function pushTryEntry(locs) {
  2801. var entry = {
  2802. tryLoc: locs[0]
  2803. };
  2804. if (1 in locs) {
  2805. entry.catchLoc = locs[1];
  2806. }
  2807. if (2 in locs) {
  2808. entry.finallyLoc = locs[2];
  2809. entry.afterLoc = locs[3];
  2810. }
  2811. this.tryEntries.push(entry);
  2812. }
  2813. function resetTryEntry(entry) {
  2814. var record = entry.completion || {};
  2815. record.type = "normal";
  2816. delete record.arg;
  2817. entry.completion = record;
  2818. }
  2819. function Context(tryLocsList) {
  2820. this.tryEntries = [{
  2821. tryLoc: "root"
  2822. }];
  2823. tryLocsList.forEach(pushTryEntry, this);
  2824. this.reset(true);
  2825. }
  2826. exports.keys = function (object) {
  2827. var keys = [];
  2828. for (var key in object) {
  2829. keys.push(key);
  2830. }
  2831. keys.reverse();
  2832. return function next() {
  2833. while (keys.length) {
  2834. var key = keys.pop();
  2835. if (key in object) {
  2836. next.value = key;
  2837. next.done = false;
  2838. return next;
  2839. }
  2840. }
  2841. next.done = true;
  2842. return next;
  2843. };
  2844. };
  2845. function values(iterable) {
  2846. if (iterable) {
  2847. var iteratorMethod = iterable[iteratorSymbol];
  2848. if (iteratorMethod) {
  2849. return iteratorMethod.call(iterable);
  2850. }
  2851. if (typeof iterable.next === "function") {
  2852. return iterable;
  2853. }
  2854. if (!isNaN(iterable.length)) {
  2855. var i = -1,
  2856. next = function next() {
  2857. while (++i < iterable.length) {
  2858. if (hasOwn.call(iterable, i)) {
  2859. next.value = iterable[i];
  2860. next.done = false;
  2861. return next;
  2862. }
  2863. }
  2864. next.value = undefined;
  2865. next.done = true;
  2866. return next;
  2867. };
  2868. return next.next = next;
  2869. }
  2870. }
  2871. return {
  2872. next: doneResult
  2873. };
  2874. }
  2875. exports.values = values;
  2876. function doneResult() {
  2877. return {
  2878. value: undefined,
  2879. done: true
  2880. };
  2881. }
  2882. Context.prototype = {
  2883. constructor: Context,
  2884. reset: function reset(skipTempReset) {
  2885. this.prev = 0;
  2886. this.next = 0;
  2887. this.sent = this._sent = undefined;
  2888. this.done = false;
  2889. this.delegate = null;
  2890. this.method = "next";
  2891. this.arg = undefined;
  2892. this.tryEntries.forEach(resetTryEntry);
  2893. if (!skipTempReset) {
  2894. for (var name in this) {
  2895. if (name.charAt(0) === "t" && hasOwn.call(this, name) && !isNaN(+name.slice(1))) {
  2896. this[name] = undefined;
  2897. }
  2898. }
  2899. }
  2900. },
  2901. stop: function stop() {
  2902. this.done = true;
  2903. var rootEntry = this.tryEntries[0];
  2904. var rootRecord = rootEntry.completion;
  2905. if (rootRecord.type === "throw") {
  2906. throw rootRecord.arg;
  2907. }
  2908. return this.rval;
  2909. },
  2910. dispatchException: function dispatchException(exception) {
  2911. if (this.done) {
  2912. throw exception;
  2913. }
  2914. var context = this;
  2915. function handle(loc, caught) {
  2916. record.type = "throw";
  2917. record.arg = exception;
  2918. context.next = loc;
  2919. if (caught) {
  2920. context.method = "next";
  2921. context.arg = undefined;
  2922. }
  2923. return !!caught;
  2924. }
  2925. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  2926. var entry = this.tryEntries[i];
  2927. var record = entry.completion;
  2928. if (entry.tryLoc === "root") {
  2929. return handle("end");
  2930. }
  2931. if (entry.tryLoc <= this.prev) {
  2932. var hasCatch = hasOwn.call(entry, "catchLoc");
  2933. var hasFinally = hasOwn.call(entry, "finallyLoc");
  2934. if (hasCatch && hasFinally) {
  2935. if (this.prev < entry.catchLoc) {
  2936. return handle(entry.catchLoc, true);
  2937. } else if (this.prev < entry.finallyLoc) {
  2938. return handle(entry.finallyLoc);
  2939. }
  2940. } else if (hasCatch) {
  2941. if (this.prev < entry.catchLoc) {
  2942. return handle(entry.catchLoc, true);
  2943. }
  2944. } else if (hasFinally) {
  2945. if (this.prev < entry.finallyLoc) {
  2946. return handle(entry.finallyLoc);
  2947. }
  2948. } else {
  2949. throw new Error("try statement without catch or finally");
  2950. }
  2951. }
  2952. }
  2953. },
  2954. abrupt: function abrupt(type, arg) {
  2955. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  2956. var entry = this.tryEntries[i];
  2957. if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
  2958. var finallyEntry = entry;
  2959. break;
  2960. }
  2961. }
  2962. if (finallyEntry && (type === "break" || type === "continue") && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc) {
  2963. finallyEntry = null;
  2964. }
  2965. var record = finallyEntry ? finallyEntry.completion : {};
  2966. record.type = type;
  2967. record.arg = arg;
  2968. if (finallyEntry) {
  2969. this.method = "next";
  2970. this.next = finallyEntry.finallyLoc;
  2971. return ContinueSentinel;
  2972. }
  2973. return this.complete(record);
  2974. },
  2975. complete: function complete(record, afterLoc) {
  2976. if (record.type === "throw") {
  2977. throw record.arg;
  2978. }
  2979. if (record.type === "break" || record.type === "continue") {
  2980. this.next = record.arg;
  2981. } else if (record.type === "return") {
  2982. this.rval = this.arg = record.arg;
  2983. this.method = "return";
  2984. this.next = "end";
  2985. } else if (record.type === "normal" && afterLoc) {
  2986. this.next = afterLoc;
  2987. }
  2988. return ContinueSentinel;
  2989. },
  2990. finish: function finish(finallyLoc) {
  2991. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  2992. var entry = this.tryEntries[i];
  2993. if (entry.finallyLoc === finallyLoc) {
  2994. this.complete(entry.completion, entry.afterLoc);
  2995. resetTryEntry(entry);
  2996. return ContinueSentinel;
  2997. }
  2998. }
  2999. },
  3000. "catch": function _catch(tryLoc) {
  3001. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  3002. var entry = this.tryEntries[i];
  3003. if (entry.tryLoc === tryLoc) {
  3004. var record = entry.completion;
  3005. if (record.type === "throw") {
  3006. var thrown = record.arg;
  3007. resetTryEntry(entry);
  3008. }
  3009. return thrown;
  3010. }
  3011. }
  3012. throw new Error("illegal catch attempt");
  3013. },
  3014. delegateYield: function delegateYield(iterable, resultName, nextLoc) {
  3015. this.delegate = {
  3016. iterator: values(iterable),
  3017. resultName: resultName,
  3018. nextLoc: nextLoc
  3019. };
  3020. if (this.method === "next") {
  3021. this.arg = undefined;
  3022. }
  3023. return ContinueSentinel;
  3024. }
  3025. };
  3026. return exports;
  3027. }(( false ? undefined : _typeof(module)) === "object" ? module.exports : {});
  3028. try {
  3029. regeneratorRuntime = runtime;
  3030. } catch (accidentalStrictMode) {
  3031. Function("r", "regeneratorRuntime = r")(runtime);
  3032. }
  3033. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(4)(module)))
  3034. /***/ }),
  3035. /* 4 */
  3036. /***/ (function(module, exports, __webpack_require__) {
  3037. "use strict";
  3038. module.exports = function (module) {
  3039. if (!module.webpackPolyfill) {
  3040. module.deprecate = function () {};
  3041. module.paths = [];
  3042. if (!module.children) module.children = [];
  3043. Object.defineProperty(module, "loaded", {
  3044. enumerable: true,
  3045. get: function get() {
  3046. return module.l;
  3047. }
  3048. });
  3049. Object.defineProperty(module, "id", {
  3050. enumerable: true,
  3051. get: function get() {
  3052. return module.i;
  3053. }
  3054. });
  3055. module.webpackPolyfill = 1;
  3056. }
  3057. return module;
  3058. };
  3059. /***/ }),
  3060. /* 5 */
  3061. /***/ (function(module, exports, __webpack_require__) {
  3062. "use strict";
  3063. Object.defineProperty(exports, "__esModule", {
  3064. value: true
  3065. });
  3066. exports.isValidRotation = isValidRotation;
  3067. exports.isValidScrollMode = isValidScrollMode;
  3068. exports.isValidSpreadMode = isValidSpreadMode;
  3069. exports.isPortraitOrientation = isPortraitOrientation;
  3070. exports.clamp = clamp;
  3071. exports.getPDFFileNameFromURL = getPDFFileNameFromURL;
  3072. exports.noContextMenuHandler = noContextMenuHandler;
  3073. exports.parseQueryString = parseQueryString;
  3074. exports.backtrackBeforeAllVisibleElements = backtrackBeforeAllVisibleElements;
  3075. exports.getVisibleElements = getVisibleElements;
  3076. exports.roundToDivide = roundToDivide;
  3077. exports.getPageSizeInches = getPageSizeInches;
  3078. exports.approximateFraction = approximateFraction;
  3079. exports.getOutputScale = getOutputScale;
  3080. exports.scrollIntoView = scrollIntoView;
  3081. exports.watchScroll = watchScroll;
  3082. exports.binarySearchFirstItem = binarySearchFirstItem;
  3083. exports.normalizeWheelEventDelta = normalizeWheelEventDelta;
  3084. exports.waitOnEventOrTimeout = waitOnEventOrTimeout;
  3085. exports.moveToEndOfArray = moveToEndOfArray;
  3086. exports.WaitOnType = exports.animationStarted = exports.ProgressBar = exports.EventBus = exports.NullL10n = exports.SpreadMode = exports.ScrollMode = exports.TextLayerMode = exports.RendererType = exports.PresentationModeState = exports.VERTICAL_PADDING = exports.SCROLLBAR_PADDING = exports.MAX_AUTO_SCALE = exports.UNKNOWN_SCALE = exports.MAX_SCALE = exports.MIN_SCALE = exports.DEFAULT_SCALE = exports.DEFAULT_SCALE_VALUE = exports.CSS_UNITS = exports.AutoPrintRegExp = void 0;
  3087. var _regenerator = _interopRequireDefault(__webpack_require__(2));
  3088. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  3089. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  3090. 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); } }
  3091. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  3092. 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); }
  3093. function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
  3094. 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."); }
  3095. 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); }
  3096. 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; }
  3097. function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_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; }
  3098. function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
  3099. 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); } }
  3100. 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); }); }; }
  3101. var CSS_UNITS = 96.0 / 72.0;
  3102. exports.CSS_UNITS = CSS_UNITS;
  3103. var DEFAULT_SCALE_VALUE = "auto";
  3104. exports.DEFAULT_SCALE_VALUE = DEFAULT_SCALE_VALUE;
  3105. var DEFAULT_SCALE = 1.0;
  3106. exports.DEFAULT_SCALE = DEFAULT_SCALE;
  3107. var MIN_SCALE = 0.1;
  3108. exports.MIN_SCALE = MIN_SCALE;
  3109. var MAX_SCALE = 10.0;
  3110. exports.MAX_SCALE = MAX_SCALE;
  3111. var UNKNOWN_SCALE = 0;
  3112. exports.UNKNOWN_SCALE = UNKNOWN_SCALE;
  3113. var MAX_AUTO_SCALE = 1.25;
  3114. exports.MAX_AUTO_SCALE = MAX_AUTO_SCALE;
  3115. var SCROLLBAR_PADDING = 40;
  3116. exports.SCROLLBAR_PADDING = SCROLLBAR_PADDING;
  3117. var VERTICAL_PADDING = 5;
  3118. exports.VERTICAL_PADDING = VERTICAL_PADDING;
  3119. var PresentationModeState = {
  3120. UNKNOWN: 0,
  3121. NORMAL: 1,
  3122. CHANGING: 2,
  3123. FULLSCREEN: 3
  3124. };
  3125. exports.PresentationModeState = PresentationModeState;
  3126. var RendererType = {
  3127. CANVAS: "canvas",
  3128. SVG: "svg"
  3129. };
  3130. exports.RendererType = RendererType;
  3131. var TextLayerMode = {
  3132. DISABLE: 0,
  3133. ENABLE: 1,
  3134. ENABLE_ENHANCE: 2
  3135. };
  3136. exports.TextLayerMode = TextLayerMode;
  3137. var ScrollMode = {
  3138. UNKNOWN: -1,
  3139. VERTICAL: 0,
  3140. HORIZONTAL: 1,
  3141. WRAPPED: 2
  3142. };
  3143. exports.ScrollMode = ScrollMode;
  3144. var SpreadMode = {
  3145. UNKNOWN: -1,
  3146. NONE: 0,
  3147. ODD: 1,
  3148. EVEN: 2
  3149. };
  3150. exports.SpreadMode = SpreadMode;
  3151. var AutoPrintRegExp = /\bprint\s*\(/;
  3152. exports.AutoPrintRegExp = AutoPrintRegExp;
  3153. function formatL10nValue(text, args) {
  3154. if (!args) {
  3155. return text;
  3156. }
  3157. return text.replace(/\{\{\s*(\w+)\s*\}\}/g, function (all, name) {
  3158. return name in args ? args[name] : "{{" + name + "}}";
  3159. });
  3160. }
  3161. var NullL10n = {
  3162. getLanguage: function getLanguage() {
  3163. return _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
  3164. return _regenerator["default"].wrap(function _callee$(_context) {
  3165. while (1) {
  3166. switch (_context.prev = _context.next) {
  3167. case 0:
  3168. return _context.abrupt("return", "en-us");
  3169. case 1:
  3170. case "end":
  3171. return _context.stop();
  3172. }
  3173. }
  3174. }, _callee);
  3175. }))();
  3176. },
  3177. getDirection: function getDirection() {
  3178. return _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee2() {
  3179. return _regenerator["default"].wrap(function _callee2$(_context2) {
  3180. while (1) {
  3181. switch (_context2.prev = _context2.next) {
  3182. case 0:
  3183. return _context2.abrupt("return", "ltr");
  3184. case 1:
  3185. case "end":
  3186. return _context2.stop();
  3187. }
  3188. }
  3189. }, _callee2);
  3190. }))();
  3191. },
  3192. get: function get(property, args, fallback) {
  3193. return _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee3() {
  3194. return _regenerator["default"].wrap(function _callee3$(_context3) {
  3195. while (1) {
  3196. switch (_context3.prev = _context3.next) {
  3197. case 0:
  3198. return _context3.abrupt("return", formatL10nValue(fallback, args));
  3199. case 1:
  3200. case "end":
  3201. return _context3.stop();
  3202. }
  3203. }
  3204. }, _callee3);
  3205. }))();
  3206. },
  3207. translate: function translate(element) {
  3208. return _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee4() {
  3209. return _regenerator["default"].wrap(function _callee4$(_context4) {
  3210. while (1) {
  3211. switch (_context4.prev = _context4.next) {
  3212. case 0:
  3213. case "end":
  3214. return _context4.stop();
  3215. }
  3216. }
  3217. }, _callee4);
  3218. }))();
  3219. }
  3220. };
  3221. exports.NullL10n = NullL10n;
  3222. function getOutputScale(ctx) {
  3223. var devicePixelRatio = window.devicePixelRatio || 1;
  3224. var backingStoreRatio = ctx.webkitBackingStorePixelRatio || ctx.mozBackingStorePixelRatio || ctx.msBackingStorePixelRatio || ctx.oBackingStorePixelRatio || ctx.backingStorePixelRatio || 1;
  3225. var pixelRatio = devicePixelRatio / backingStoreRatio;
  3226. return {
  3227. sx: pixelRatio,
  3228. sy: pixelRatio,
  3229. scaled: pixelRatio !== 1
  3230. };
  3231. }
  3232. function scrollIntoView(element, spot) {
  3233. var skipOverflowHiddenElements = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  3234. var parent = element.offsetParent;
  3235. if (!parent) {
  3236. console.error("offsetParent is not set -- cannot scroll");
  3237. return;
  3238. }
  3239. var offsetY = element.offsetTop + element.clientTop;
  3240. var offsetX = element.offsetLeft + element.clientLeft;
  3241. while (parent.clientHeight === parent.scrollHeight && parent.clientWidth === parent.scrollWidth || skipOverflowHiddenElements && getComputedStyle(parent).overflow === "hidden") {
  3242. if (parent.dataset._scaleY) {
  3243. offsetY /= parent.dataset._scaleY;
  3244. offsetX /= parent.dataset._scaleX;
  3245. }
  3246. offsetY += parent.offsetTop;
  3247. offsetX += parent.offsetLeft;
  3248. parent = parent.offsetParent;
  3249. if (!parent) {
  3250. return;
  3251. }
  3252. }
  3253. if (spot) {
  3254. if (spot.top !== undefined) {
  3255. offsetY += spot.top;
  3256. }
  3257. if (spot.left !== undefined) {
  3258. offsetX += spot.left;
  3259. parent.scrollLeft = offsetX;
  3260. }
  3261. }
  3262. parent.scrollTop = offsetY;
  3263. }
  3264. function watchScroll(viewAreaElement, callback) {
  3265. var debounceScroll = function debounceScroll(evt) {
  3266. if (rAF) {
  3267. return;
  3268. }
  3269. rAF = window.requestAnimationFrame(function viewAreaElementScrolled() {
  3270. rAF = null;
  3271. var currentX = viewAreaElement.scrollLeft;
  3272. var lastX = state.lastX;
  3273. if (currentX !== lastX) {
  3274. state.right = currentX > lastX;
  3275. }
  3276. state.lastX = currentX;
  3277. var currentY = viewAreaElement.scrollTop;
  3278. var lastY = state.lastY;
  3279. if (currentY !== lastY) {
  3280. state.down = currentY > lastY;
  3281. }
  3282. state.lastY = currentY;
  3283. callback(state);
  3284. });
  3285. };
  3286. var state = {
  3287. right: true,
  3288. down: true,
  3289. lastX: viewAreaElement.scrollLeft,
  3290. lastY: viewAreaElement.scrollTop,
  3291. _eventHandler: debounceScroll
  3292. };
  3293. var rAF = null;
  3294. viewAreaElement.addEventListener("scroll", debounceScroll, true);
  3295. return state;
  3296. }
  3297. function parseQueryString(query) {
  3298. var parts = query.split("&");
  3299. var params = Object.create(null);
  3300. for (var i = 0, ii = parts.length; i < ii; ++i) {
  3301. var param = parts[i].split("=");
  3302. var key = param[0].toLowerCase();
  3303. var value = param.length > 1 ? param[1] : null;
  3304. params[decodeURIComponent(key)] = decodeURIComponent(value);
  3305. }
  3306. return params;
  3307. }
  3308. function binarySearchFirstItem(items, condition) {
  3309. var minIndex = 0;
  3310. var maxIndex = items.length - 1;
  3311. if (maxIndex < 0 || !condition(items[maxIndex])) {
  3312. return items.length;
  3313. }
  3314. if (condition(items[minIndex])) {
  3315. return minIndex;
  3316. }
  3317. while (minIndex < maxIndex) {
  3318. var currentIndex = minIndex + maxIndex >> 1;
  3319. var currentItem = items[currentIndex];
  3320. if (condition(currentItem)) {
  3321. maxIndex = currentIndex;
  3322. } else {
  3323. minIndex = currentIndex + 1;
  3324. }
  3325. }
  3326. return minIndex;
  3327. }
  3328. function approximateFraction(x) {
  3329. if (Math.floor(x) === x) {
  3330. return [x, 1];
  3331. }
  3332. var xinv = 1 / x;
  3333. var limit = 8;
  3334. if (xinv > limit) {
  3335. return [1, limit];
  3336. } else if (Math.floor(xinv) === xinv) {
  3337. return [1, xinv];
  3338. }
  3339. var x_ = x > 1 ? xinv : x;
  3340. var a = 0,
  3341. b = 1,
  3342. c = 1,
  3343. d = 1;
  3344. while (true) {
  3345. var p = a + c,
  3346. q = b + d;
  3347. if (q > limit) {
  3348. break;
  3349. }
  3350. if (x_ <= p / q) {
  3351. c = p;
  3352. d = q;
  3353. } else {
  3354. a = p;
  3355. b = q;
  3356. }
  3357. }
  3358. var result;
  3359. if (x_ - a / b < c / d - x_) {
  3360. result = x_ === x ? [a, b] : [b, a];
  3361. } else {
  3362. result = x_ === x ? [c, d] : [d, c];
  3363. }
  3364. return result;
  3365. }
  3366. function roundToDivide(x, div) {
  3367. var r = x % div;
  3368. return r === 0 ? x : Math.round(x - r + div);
  3369. }
  3370. function getPageSizeInches(_ref) {
  3371. var view = _ref.view,
  3372. userUnit = _ref.userUnit,
  3373. rotate = _ref.rotate;
  3374. var _view = _slicedToArray(view, 4),
  3375. x1 = _view[0],
  3376. y1 = _view[1],
  3377. x2 = _view[2],
  3378. y2 = _view[3];
  3379. var changeOrientation = rotate % 180 !== 0;
  3380. var width = (x2 - x1) / 72 * userUnit;
  3381. var height = (y2 - y1) / 72 * userUnit;
  3382. return {
  3383. width: changeOrientation ? height : width,
  3384. height: changeOrientation ? width : height
  3385. };
  3386. }
  3387. function backtrackBeforeAllVisibleElements(index, views, top) {
  3388. if (index < 2) {
  3389. return index;
  3390. }
  3391. var elt = views[index].div;
  3392. var pageTop = elt.offsetTop + elt.clientTop;
  3393. if (pageTop >= top) {
  3394. elt = views[index - 1].div;
  3395. pageTop = elt.offsetTop + elt.clientTop;
  3396. }
  3397. for (var i = index - 2; i >= 0; --i) {
  3398. elt = views[i].div;
  3399. if (elt.offsetTop + elt.clientTop + elt.clientHeight <= pageTop) {
  3400. break;
  3401. }
  3402. index = i;
  3403. }
  3404. return index;
  3405. }
  3406. function getVisibleElements(scrollEl, views) {
  3407. var sortByVisibility = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  3408. var horizontal = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
  3409. var top = scrollEl.scrollTop,
  3410. bottom = top + scrollEl.clientHeight;
  3411. var left = scrollEl.scrollLeft,
  3412. right = left + scrollEl.clientWidth;
  3413. function isElementBottomAfterViewTop(view) {
  3414. var element = view.div;
  3415. var elementBottom = element.offsetTop + element.clientTop + element.clientHeight;
  3416. return elementBottom > top;
  3417. }
  3418. function isElementRightAfterViewLeft(view) {
  3419. var element = view.div;
  3420. var elementRight = element.offsetLeft + element.clientLeft + element.clientWidth;
  3421. return elementRight > left;
  3422. }
  3423. var visible = [],
  3424. numViews = views.length;
  3425. var firstVisibleElementInd = numViews === 0 ? 0 : binarySearchFirstItem(views, horizontal ? isElementRightAfterViewLeft : isElementBottomAfterViewTop);
  3426. if (firstVisibleElementInd > 0 && firstVisibleElementInd < numViews && !horizontal) {
  3427. firstVisibleElementInd = backtrackBeforeAllVisibleElements(firstVisibleElementInd, views, top);
  3428. }
  3429. var lastEdge = horizontal ? right : -1;
  3430. for (var i = firstVisibleElementInd; i < numViews; i++) {
  3431. var view = views[i],
  3432. element = view.div;
  3433. var currentWidth = element.offsetLeft + element.clientLeft;
  3434. var currentHeight = element.offsetTop + element.clientTop;
  3435. var viewWidth = element.clientWidth,
  3436. viewHeight = element.clientHeight;
  3437. var viewRight = currentWidth + viewWidth;
  3438. var viewBottom = currentHeight + viewHeight;
  3439. if (lastEdge === -1) {
  3440. if (viewBottom >= bottom) {
  3441. lastEdge = viewBottom;
  3442. }
  3443. } else if ((horizontal ? currentWidth : currentHeight) > lastEdge) {
  3444. break;
  3445. }
  3446. if (viewBottom <= top || currentHeight >= bottom || viewRight <= left || currentWidth >= right) {
  3447. continue;
  3448. }
  3449. var hiddenHeight = Math.max(0, top - currentHeight) + Math.max(0, viewBottom - bottom);
  3450. var hiddenWidth = Math.max(0, left - currentWidth) + Math.max(0, viewRight - right);
  3451. var percent = (viewHeight - hiddenHeight) * (viewWidth - hiddenWidth) * 100 / viewHeight / viewWidth | 0;
  3452. visible.push({
  3453. id: view.id,
  3454. x: currentWidth,
  3455. y: currentHeight,
  3456. view: view,
  3457. percent: percent
  3458. });
  3459. }
  3460. var first = visible[0],
  3461. last = visible[visible.length - 1];
  3462. if (sortByVisibility) {
  3463. visible.sort(function (a, b) {
  3464. var pc = a.percent - b.percent;
  3465. if (Math.abs(pc) > 0.001) {
  3466. return -pc;
  3467. }
  3468. return a.id - b.id;
  3469. });
  3470. }
  3471. return {
  3472. first: first,
  3473. last: last,
  3474. views: visible
  3475. };
  3476. }
  3477. function noContextMenuHandler(evt) {
  3478. evt.preventDefault();
  3479. }
  3480. function isDataSchema(url) {
  3481. var i = 0;
  3482. var ii = url.length;
  3483. while (i < ii && url[i].trim() === "") {
  3484. i++;
  3485. }
  3486. return url.substring(i, i + 5).toLowerCase() === "data:";
  3487. }
  3488. function getPDFFileNameFromURL(url) {
  3489. var defaultFilename = ''
  3490. if(localStorage.getItem('fileName')){
  3491. defaultFilename = localStorage.getItem('fileName')
  3492. }
  3493. else {
  3494. defaultFilename = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "document.pdf";
  3495. }
  3496. if (typeof url !== "string") {
  3497. return defaultFilename;
  3498. }
  3499. if (isDataSchema(url)) {
  3500. console.warn("getPDFFileNameFromURL: " + 'ignoring "data:" URL for performance reasons.');
  3501. return defaultFilename;
  3502. }
  3503. var reURI = /^(?:(?:[^:]+:)?\/\/[^\/]+)?([^?#]*)(\?[^#]*)?(#.*)?$/;
  3504. var reFilename = /[^\/?#=]+\.pdf\b(?!.*\.pdf\b)/i;
  3505. var splitURI = reURI.exec(url);
  3506. var suggestedFilename = reFilename.exec(splitURI[1]) || reFilename.exec(splitURI[2]) || reFilename.exec(splitURI[3]);
  3507. if (suggestedFilename) {
  3508. suggestedFilename = suggestedFilename[0];
  3509. if (suggestedFilename.includes("%")) {
  3510. try {
  3511. suggestedFilename = reFilename.exec(decodeURIComponent(suggestedFilename))[0];
  3512. } catch (ex) {}
  3513. }
  3514. }
  3515. return suggestedFilename || defaultFilename;
  3516. }
  3517. function normalizeWheelEventDelta(evt) {
  3518. var delta = Math.sqrt(evt.deltaX * evt.deltaX + evt.deltaY * evt.deltaY);
  3519. var angle = Math.atan2(evt.deltaY, evt.deltaX);
  3520. if (-0.25 * Math.PI < angle && angle < 0.75 * Math.PI) {
  3521. delta = -delta;
  3522. }
  3523. var MOUSE_DOM_DELTA_PIXEL_MODE = 0;
  3524. var MOUSE_DOM_DELTA_LINE_MODE = 1;
  3525. var MOUSE_PIXELS_PER_LINE = 30;
  3526. var MOUSE_LINES_PER_PAGE = 30;
  3527. if (evt.deltaMode === MOUSE_DOM_DELTA_PIXEL_MODE) {
  3528. delta /= MOUSE_PIXELS_PER_LINE * MOUSE_LINES_PER_PAGE;
  3529. } else if (evt.deltaMode === MOUSE_DOM_DELTA_LINE_MODE) {
  3530. delta /= MOUSE_LINES_PER_PAGE;
  3531. }
  3532. return delta;
  3533. }
  3534. function isValidRotation(angle) {
  3535. return Number.isInteger(angle) && angle % 90 === 0;
  3536. }
  3537. function isValidScrollMode(mode) {
  3538. return Number.isInteger(mode) && Object.values(ScrollMode).includes(mode) && mode !== ScrollMode.UNKNOWN;
  3539. }
  3540. function isValidSpreadMode(mode) {
  3541. return Number.isInteger(mode) && Object.values(SpreadMode).includes(mode) && mode !== SpreadMode.UNKNOWN;
  3542. }
  3543. function isPortraitOrientation(size) {
  3544. return size.width <= size.height;
  3545. }
  3546. var WaitOnType = {
  3547. EVENT: "event",
  3548. TIMEOUT: "timeout"
  3549. };
  3550. exports.WaitOnType = WaitOnType;
  3551. function waitOnEventOrTimeout(_ref2) {
  3552. var target = _ref2.target,
  3553. name = _ref2.name,
  3554. _ref2$delay = _ref2.delay,
  3555. delay = _ref2$delay === void 0 ? 0 : _ref2$delay;
  3556. return new Promise(function (resolve, reject) {
  3557. if (_typeof(target) !== "object" || !(name && typeof name === "string") || !(Number.isInteger(delay) && delay >= 0)) {
  3558. throw new Error("waitOnEventOrTimeout - invalid parameters.");
  3559. }
  3560. function handler(type) {
  3561. if (target instanceof EventBus) {
  3562. target._off(name, eventHandler);
  3563. } else {
  3564. target.removeEventListener(name, eventHandler);
  3565. }
  3566. if (timeout) {
  3567. clearTimeout(timeout);
  3568. }
  3569. resolve(type);
  3570. }
  3571. var eventHandler = handler.bind(null, WaitOnType.EVENT);
  3572. if (target instanceof EventBus) {
  3573. target._on(name, eventHandler);
  3574. } else {
  3575. target.addEventListener(name, eventHandler);
  3576. }
  3577. var timeoutHandler = handler.bind(null, WaitOnType.TIMEOUT);
  3578. var timeout = setTimeout(timeoutHandler, delay);
  3579. });
  3580. }
  3581. var animationStarted = new Promise(function (resolve) {
  3582. window.requestAnimationFrame(resolve);
  3583. });
  3584. exports.animationStarted = animationStarted;
  3585. function dispatchDOMEvent(eventName) {
  3586. var args = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  3587. throw new Error("Not implemented: dispatchDOMEvent");
  3588. }
  3589. var EventBus = /*#__PURE__*/function () {
  3590. function EventBus(options) {
  3591. _classCallCheck(this, EventBus);
  3592. this._listeners = Object.create(null);
  3593. }
  3594. _createClass(EventBus, [{
  3595. key: "on",
  3596. value: function on(eventName, listener) {
  3597. this._on(eventName, listener, {
  3598. external: true
  3599. });
  3600. }
  3601. }, {
  3602. key: "off",
  3603. value: function off(eventName, listener) {
  3604. this._off(eventName, listener, {
  3605. external: true
  3606. });
  3607. }
  3608. }, {
  3609. key: "dispatch",
  3610. value: function dispatch(eventName) {
  3611. var eventListeners = this._listeners[eventName];
  3612. if (!eventListeners || eventListeners.length === 0) {
  3613. return;
  3614. }
  3615. var args = Array.prototype.slice.call(arguments, 1);
  3616. var externalListeners;
  3617. eventListeners.slice(0).forEach(function (_ref3) {
  3618. var listener = _ref3.listener,
  3619. external = _ref3.external;
  3620. if (external) {
  3621. if (!externalListeners) {
  3622. externalListeners = [];
  3623. }
  3624. externalListeners.push(listener);
  3625. return;
  3626. }
  3627. listener.apply(null, args);
  3628. });
  3629. if (externalListeners) {
  3630. externalListeners.forEach(function (listener) {
  3631. listener.apply(null, args);
  3632. });
  3633. externalListeners = null;
  3634. }
  3635. }
  3636. }, {
  3637. key: "_on",
  3638. value: function _on(eventName, listener) {
  3639. var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
  3640. var eventListeners = this._listeners[eventName];
  3641. if (!eventListeners) {
  3642. this._listeners[eventName] = eventListeners = [];
  3643. }
  3644. eventListeners.push({
  3645. listener: listener,
  3646. external: (options && options.external) === true
  3647. });
  3648. }
  3649. }, {
  3650. key: "_off",
  3651. value: function _off(eventName, listener) {
  3652. var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
  3653. var eventListeners = this._listeners[eventName];
  3654. if (!eventListeners) {
  3655. return;
  3656. }
  3657. for (var i = 0, ii = eventListeners.length; i < ii; i++) {
  3658. if (eventListeners[i].listener === listener) {
  3659. eventListeners.splice(i, 1);
  3660. return;
  3661. }
  3662. }
  3663. }
  3664. }]);
  3665. return EventBus;
  3666. }();
  3667. exports.EventBus = EventBus;
  3668. function clamp(v, min, max) {
  3669. return Math.min(Math.max(v, min), max);
  3670. }
  3671. var ProgressBar = /*#__PURE__*/function () {
  3672. function ProgressBar(id) {
  3673. var _ref4 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
  3674. height = _ref4.height,
  3675. width = _ref4.width,
  3676. units = _ref4.units;
  3677. _classCallCheck(this, ProgressBar);
  3678. this.visible = true;
  3679. this.div = document.querySelector(id + " .progress");
  3680. this.bar = this.div.parentNode;
  3681. this.height = height || 100;
  3682. this.width = width || 100;
  3683. this.units = units || "%";
  3684. this.div.style.height = this.height + this.units;
  3685. this.percent = 0;
  3686. }
  3687. _createClass(ProgressBar, [{
  3688. key: "_updateBar",
  3689. value: function _updateBar() {
  3690. if (this._indeterminate) {
  3691. this.div.classList.add("indeterminate");
  3692. this.div.style.width = this.width + this.units;
  3693. return;
  3694. }
  3695. this.div.classList.remove("indeterminate");
  3696. var progressSize = this.width * this._percent / 100;
  3697. this.div.style.width = progressSize + this.units;
  3698. }
  3699. }, {
  3700. key: "setWidth",
  3701. value: function setWidth(viewer) {
  3702. if (!viewer) {
  3703. return;
  3704. }
  3705. var container = viewer.parentNode;
  3706. var scrollbarWidth = container.offsetWidth - viewer.offsetWidth;
  3707. if (scrollbarWidth > 0) {
  3708. this.bar.style.width = "calc(100% - ".concat(scrollbarWidth, "px)");
  3709. }
  3710. }
  3711. }, {
  3712. key: "hide",
  3713. value: function hide() {
  3714. if (!this.visible) {
  3715. return;
  3716. }
  3717. this.visible = false;
  3718. this.bar.classList.add("hidden");
  3719. document.body.classList.remove("loadingInProgress");
  3720. }
  3721. }, {
  3722. key: "show",
  3723. value: function show() {
  3724. if (this.visible) {
  3725. return;
  3726. }
  3727. this.visible = true;
  3728. document.body.classList.add("loadingInProgress");
  3729. this.bar.classList.remove("hidden");
  3730. }
  3731. }, {
  3732. key: "percent",
  3733. get: function get() {
  3734. return this._percent;
  3735. },
  3736. set: function set(val) {
  3737. this._indeterminate = isNaN(val);
  3738. this._percent = clamp(val, 0, 100);
  3739. this._updateBar();
  3740. }
  3741. }]);
  3742. return ProgressBar;
  3743. }();
  3744. exports.ProgressBar = ProgressBar;
  3745. function moveToEndOfArray(arr, condition) {
  3746. var moved = [],
  3747. len = arr.length;
  3748. var write = 0;
  3749. for (var read = 0; read < len; ++read) {
  3750. if (condition(arr[read])) {
  3751. moved.push(arr[read]);
  3752. } else {
  3753. arr[write] = arr[read];
  3754. ++write;
  3755. }
  3756. }
  3757. for (var _read = 0; write < len; ++_read, ++write) {
  3758. arr[write] = moved[_read];
  3759. }
  3760. }
  3761. /***/ }),
  3762. /* 6 */
  3763. /***/ (function(module, exports, __webpack_require__) {
  3764. "use strict";
  3765. Object.defineProperty(exports, "__esModule", {
  3766. value: true
  3767. });
  3768. exports.OptionKind = exports.AppOptions = void 0;
  3769. var _viewer_compatibility = __webpack_require__(7);
  3770. 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); }
  3771. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  3772. 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); } }
  3773. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  3774. var OptionKind = {
  3775. VIEWER: 0x02,
  3776. API: 0x04,
  3777. WORKER: 0x08,
  3778. PREFERENCE: 0x80
  3779. };
  3780. exports.OptionKind = OptionKind;
  3781. var defaultOptions = {
  3782. cursorToolOnLoad: {
  3783. value: 0,
  3784. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  3785. },
  3786. defaultUrl: {
  3787. value: "compressed.tracemonkey-pldi-09.pdf",
  3788. kind: OptionKind.VIEWER
  3789. },
  3790. defaultZoomValue: {
  3791. value: "",
  3792. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  3793. },
  3794. disableCreateObjectURL: {
  3795. value: false,
  3796. compatibility: _viewer_compatibility.viewerCompatibilityParams.disableCreateObjectURL,
  3797. kind: OptionKind.VIEWER
  3798. },
  3799. disableHistory: {
  3800. value: false,
  3801. kind: OptionKind.VIEWER
  3802. },
  3803. disablePageLabels: {
  3804. value: false,
  3805. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  3806. },
  3807. enablePermissions: {
  3808. value: false,
  3809. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  3810. },
  3811. enablePrintAutoRotate: {
  3812. value: false,
  3813. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  3814. },
  3815. enableWebGL: {
  3816. value: false,
  3817. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  3818. },
  3819. externalLinkRel: {
  3820. value: "noopener noreferrer nofollow",
  3821. kind: OptionKind.VIEWER
  3822. },
  3823. externalLinkTarget: {
  3824. value: 0,
  3825. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  3826. },
  3827. historyUpdateUrl: {
  3828. value: false,
  3829. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  3830. },
  3831. ignoreDestinationZoom: {
  3832. value: false,
  3833. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  3834. },
  3835. imageResourcesPath: {
  3836. value: "./images/",
  3837. kind: OptionKind.VIEWER
  3838. },
  3839. maxCanvasPixels: {
  3840. value: 16777216,
  3841. compatibility: _viewer_compatibility.viewerCompatibilityParams.maxCanvasPixels,
  3842. kind: OptionKind.VIEWER
  3843. },
  3844. pdfBugEnabled: {
  3845. value: false,
  3846. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  3847. },
  3848. printResolution: {
  3849. value: 150,
  3850. kind: OptionKind.VIEWER
  3851. },
  3852. renderer: {
  3853. value: "canvas",
  3854. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  3855. },
  3856. renderInteractiveForms: {
  3857. value: false,
  3858. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  3859. },
  3860. sidebarViewOnLoad: {
  3861. value: -1,
  3862. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  3863. },
  3864. scrollModeOnLoad: {
  3865. value: -1,
  3866. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  3867. },
  3868. spreadModeOnLoad: {
  3869. value: -1,
  3870. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  3871. },
  3872. textLayerMode: {
  3873. value: 1,
  3874. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  3875. },
  3876. useOnlyCssZoom: {
  3877. value: false,
  3878. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  3879. },
  3880. viewOnLoad: {
  3881. value: 0,
  3882. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  3883. },
  3884. cMapPacked: {
  3885. value: true,
  3886. kind: OptionKind.API
  3887. },
  3888. cMapUrl: {
  3889. value: "../web/cmaps/",
  3890. kind: OptionKind.API
  3891. },
  3892. disableAutoFetch: {
  3893. value: false,
  3894. kind: OptionKind.API + OptionKind.PREFERENCE
  3895. },
  3896. disableFontFace: {
  3897. value: false,
  3898. kind: OptionKind.API + OptionKind.PREFERENCE
  3899. },
  3900. disableRange: {
  3901. value: false,
  3902. kind: OptionKind.API + OptionKind.PREFERENCE
  3903. },
  3904. disableStream: {
  3905. value: false,
  3906. kind: OptionKind.API + OptionKind.PREFERENCE
  3907. },
  3908. docBaseUrl: {
  3909. value: "",
  3910. kind: OptionKind.API
  3911. },
  3912. fontExtraProperties: {
  3913. value: false,
  3914. kind: OptionKind.API
  3915. },
  3916. isEvalSupported: {
  3917. value: true,
  3918. kind: OptionKind.API
  3919. },
  3920. maxImageSize: {
  3921. value: -1,
  3922. kind: OptionKind.API
  3923. },
  3924. pdfBug: {
  3925. value: false,
  3926. kind: OptionKind.API
  3927. },
  3928. verbosity: {
  3929. value: 1,
  3930. kind: OptionKind.API
  3931. },
  3932. workerPort: {
  3933. value: null,
  3934. kind: OptionKind.WORKER
  3935. },
  3936. workerSrc: {
  3937. value: "../build/pdf.worker.js",
  3938. kind: OptionKind.WORKER
  3939. }
  3940. };
  3941. {
  3942. defaultOptions.disablePreferences = {
  3943. value: false,
  3944. kind: OptionKind.VIEWER
  3945. };
  3946. defaultOptions.locale = {
  3947. value: typeof navigator !== "undefined" ? navigator.language : "en-US",
  3948. kind: OptionKind.VIEWER
  3949. };
  3950. }
  3951. var userOptions = Object.create(null);
  3952. var AppOptions = /*#__PURE__*/function () {
  3953. function AppOptions() {
  3954. _classCallCheck(this, AppOptions);
  3955. throw new Error("Cannot initialize AppOptions.");
  3956. }
  3957. _createClass(AppOptions, null, [{
  3958. key: "get",
  3959. value: function get(name) {
  3960. var userOption = userOptions[name];
  3961. if (userOption !== undefined) {
  3962. return userOption;
  3963. }
  3964. var defaultOption = defaultOptions[name];
  3965. if (defaultOption !== undefined) {
  3966. return defaultOption.compatibility || defaultOption.value;
  3967. }
  3968. return undefined;
  3969. }
  3970. }, {
  3971. key: "getAll",
  3972. value: function getAll() {
  3973. var kind = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
  3974. var options = Object.create(null);
  3975. for (var name in defaultOptions) {
  3976. var defaultOption = defaultOptions[name];
  3977. if (kind) {
  3978. if ((kind & defaultOption.kind) === 0) {
  3979. continue;
  3980. }
  3981. if (kind === OptionKind.PREFERENCE) {
  3982. var value = defaultOption.value,
  3983. valueType = _typeof(value);
  3984. if (valueType === "boolean" || valueType === "string" || valueType === "number" && Number.isInteger(value)) {
  3985. options[name] = value;
  3986. continue;
  3987. }
  3988. throw new Error("Invalid type for preference: ".concat(name));
  3989. }
  3990. }
  3991. var userOption = userOptions[name];
  3992. options[name] = userOption !== undefined ? userOption : defaultOption.compatibility || defaultOption.value;
  3993. }
  3994. return options;
  3995. }
  3996. }, {
  3997. key: "set",
  3998. value: function set(name, value) {
  3999. userOptions[name] = value;
  4000. }
  4001. }, {
  4002. key: "remove",
  4003. value: function remove(name) {
  4004. delete userOptions[name];
  4005. }
  4006. }]);
  4007. return AppOptions;
  4008. }();
  4009. exports.AppOptions = AppOptions;
  4010. /***/ }),
  4011. /* 7 */
  4012. /***/ (function(module, exports, __webpack_require__) {
  4013. "use strict";
  4014. Object.defineProperty(exports, "__esModule", {
  4015. value: true
  4016. });
  4017. exports.viewerCompatibilityParams = void 0;
  4018. var compatibilityParams = Object.create(null);
  4019. {
  4020. var userAgent = typeof navigator !== "undefined" && navigator.userAgent || "";
  4021. var platform = typeof navigator !== "undefined" && navigator.platform || "";
  4022. var maxTouchPoints = typeof navigator !== "undefined" && navigator.maxTouchPoints || 1;
  4023. var isAndroid = /Android/.test(userAgent);
  4024. var isIE = /Trident/.test(userAgent);
  4025. var isIOS = /\b(iPad|iPhone|iPod)(?=;)/.test(userAgent) || platform === "MacIntel" && maxTouchPoints > 1;
  4026. var isIOSChrome = /CriOS/.test(userAgent);
  4027. (function checkOnBlobSupport() {
  4028. if (isIE || isIOSChrome) {
  4029. compatibilityParams.disableCreateObjectURL = true;
  4030. }
  4031. })();
  4032. (function checkCanvasSizeLimitation() {
  4033. if (isIOS || isAndroid) {
  4034. compatibilityParams.maxCanvasPixels = 5242880;
  4035. }
  4036. })();
  4037. }
  4038. var viewerCompatibilityParams = Object.freeze(compatibilityParams);
  4039. exports.viewerCompatibilityParams = viewerCompatibilityParams;
  4040. /***/ }),
  4041. /* 8 */
  4042. /***/ (function(module, exports, __webpack_require__) {
  4043. "use strict";
  4044. var pdfjsLib;
  4045. if (typeof window !== "undefined" && window["pdfjs-dist/build/pdf"]) {
  4046. pdfjsLib = window["pdfjs-dist/build/pdf"];
  4047. } else {
  4048. pdfjsLib = require("../build/pdf.js");
  4049. }
  4050. module.exports = pdfjsLib;
  4051. /***/ }),
  4052. /* 9 */
  4053. /***/ (function(module, exports, __webpack_require__) {
  4054. "use strict";
  4055. Object.defineProperty(exports, "__esModule", {
  4056. value: true
  4057. });
  4058. exports.PDFCursorTools = exports.CursorTool = void 0;
  4059. var _grab_to_pan = __webpack_require__(10);
  4060. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  4061. 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); } }
  4062. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  4063. var CursorTool = {
  4064. SELECT: 0,
  4065. HAND: 1,
  4066. ZOOM: 2
  4067. };
  4068. exports.CursorTool = CursorTool;
  4069. var PDFCursorTools = /*#__PURE__*/function () {
  4070. function PDFCursorTools(_ref) {
  4071. var _this = this;
  4072. var container = _ref.container,
  4073. eventBus = _ref.eventBus,
  4074. _ref$cursorToolOnLoad = _ref.cursorToolOnLoad,
  4075. cursorToolOnLoad = _ref$cursorToolOnLoad === void 0 ? CursorTool.SELECT : _ref$cursorToolOnLoad;
  4076. _classCallCheck(this, PDFCursorTools);
  4077. this.container = container;
  4078. this.eventBus = eventBus;
  4079. this.active = CursorTool.SELECT;
  4080. this.activeBeforePresentationMode = null;
  4081. this.handTool = new _grab_to_pan.GrabToPan({
  4082. element: this.container
  4083. });
  4084. this._addEventListeners();
  4085. Promise.resolve().then(function () {
  4086. _this.switchTool(cursorToolOnLoad);
  4087. });
  4088. }
  4089. _createClass(PDFCursorTools, [{
  4090. key: "switchTool",
  4091. value: function switchTool(tool) {
  4092. var _this2 = this;
  4093. if (this.activeBeforePresentationMode !== null) {
  4094. return;
  4095. }
  4096. if (tool === this.active) {
  4097. return;
  4098. }
  4099. var disableActiveTool = function disableActiveTool() {
  4100. switch (_this2.active) {
  4101. case CursorTool.SELECT:
  4102. break;
  4103. case CursorTool.HAND:
  4104. _this2.handTool.deactivate();
  4105. break;
  4106. case CursorTool.ZOOM:
  4107. }
  4108. };
  4109. switch (tool) {
  4110. case CursorTool.SELECT:
  4111. disableActiveTool();
  4112. break;
  4113. case CursorTool.HAND:
  4114. disableActiveTool();
  4115. this.handTool.activate();
  4116. break;
  4117. case CursorTool.ZOOM:
  4118. default:
  4119. console.error("switchTool: \"".concat(tool, "\" is an unsupported value."));
  4120. return;
  4121. }
  4122. this.active = tool;
  4123. this._dispatchEvent();
  4124. }
  4125. }, {
  4126. key: "_dispatchEvent",
  4127. value: function _dispatchEvent() {
  4128. this.eventBus.dispatch("cursortoolchanged", {
  4129. source: this,
  4130. tool: this.active
  4131. });
  4132. }
  4133. }, {
  4134. key: "_addEventListeners",
  4135. value: function _addEventListeners() {
  4136. var _this3 = this;
  4137. this.eventBus._on("switchcursortool", function (evt) {
  4138. _this3.switchTool(evt.tool);
  4139. });
  4140. this.eventBus._on("presentationmodechanged", function (evt) {
  4141. if (evt.switchInProgress) {
  4142. return;
  4143. }
  4144. var previouslyActive;
  4145. if (evt.active) {
  4146. previouslyActive = _this3.active;
  4147. _this3.switchTool(CursorTool.SELECT);
  4148. _this3.activeBeforePresentationMode = previouslyActive;
  4149. } else {
  4150. previouslyActive = _this3.activeBeforePresentationMode;
  4151. _this3.activeBeforePresentationMode = null;
  4152. _this3.switchTool(previouslyActive);
  4153. }
  4154. });
  4155. }
  4156. }, {
  4157. key: "activeTool",
  4158. get: function get() {
  4159. return this.active;
  4160. }
  4161. }]);
  4162. return PDFCursorTools;
  4163. }();
  4164. exports.PDFCursorTools = PDFCursorTools;
  4165. /***/ }),
  4166. /* 10 */
  4167. /***/ (function(module, exports, __webpack_require__) {
  4168. "use strict";
  4169. Object.defineProperty(exports, "__esModule", {
  4170. value: true
  4171. });
  4172. exports.GrabToPan = GrabToPan;
  4173. function GrabToPan(options) {
  4174. this.element = options.element;
  4175. this.document = options.element.ownerDocument;
  4176. if (typeof options.ignoreTarget === "function") {
  4177. this.ignoreTarget = options.ignoreTarget;
  4178. }
  4179. this.onActiveChanged = options.onActiveChanged;
  4180. this.activate = this.activate.bind(this);
  4181. this.deactivate = this.deactivate.bind(this);
  4182. this.toggle = this.toggle.bind(this);
  4183. this._onmousedown = this._onmousedown.bind(this);
  4184. this._onmousemove = this._onmousemove.bind(this);
  4185. this._endPan = this._endPan.bind(this);
  4186. var overlay = this.overlay = document.createElement("div");
  4187. overlay.className = "grab-to-pan-grabbing";
  4188. }
  4189. GrabToPan.prototype = {
  4190. CSS_CLASS_GRAB: "grab-to-pan-grab",
  4191. activate: function GrabToPan_activate() {
  4192. if (!this.active) {
  4193. this.active = true;
  4194. this.element.addEventListener("mousedown", this._onmousedown, true);
  4195. this.element.classList.add(this.CSS_CLASS_GRAB);
  4196. if (this.onActiveChanged) {
  4197. this.onActiveChanged(true);
  4198. }
  4199. }
  4200. },
  4201. deactivate: function GrabToPan_deactivate() {
  4202. if (this.active) {
  4203. this.active = false;
  4204. this.element.removeEventListener("mousedown", this._onmousedown, true);
  4205. this._endPan();
  4206. this.element.classList.remove(this.CSS_CLASS_GRAB);
  4207. if (this.onActiveChanged) {
  4208. this.onActiveChanged(false);
  4209. }
  4210. }
  4211. },
  4212. toggle: function GrabToPan_toggle() {
  4213. if (this.active) {
  4214. this.deactivate();
  4215. } else {
  4216. this.activate();
  4217. }
  4218. },
  4219. ignoreTarget: function GrabToPan_ignoreTarget(node) {
  4220. return node[matchesSelector]("a[href], a[href] *, input, textarea, button, button *, select, option");
  4221. },
  4222. _onmousedown: function GrabToPan__onmousedown(event) {
  4223. if (event.button !== 0 || this.ignoreTarget(event.target)) {
  4224. return;
  4225. }
  4226. if (event.originalTarget) {
  4227. try {
  4228. event.originalTarget.tagName;
  4229. } catch (e) {
  4230. return;
  4231. }
  4232. }
  4233. this.scrollLeftStart = this.element.scrollLeft;
  4234. this.scrollTopStart = this.element.scrollTop;
  4235. this.clientXStart = event.clientX;
  4236. this.clientYStart = event.clientY;
  4237. this.document.addEventListener("mousemove", this._onmousemove, true);
  4238. this.document.addEventListener("mouseup", this._endPan, true);
  4239. this.element.addEventListener("scroll", this._endPan, true);
  4240. event.preventDefault();
  4241. event.stopPropagation();
  4242. var focusedElement = document.activeElement;
  4243. if (focusedElement && !focusedElement.contains(event.target)) {
  4244. focusedElement.blur();
  4245. }
  4246. },
  4247. _onmousemove: function GrabToPan__onmousemove(event) {
  4248. this.element.removeEventListener("scroll", this._endPan, true);
  4249. if (isLeftMouseReleased(event)) {
  4250. this._endPan();
  4251. return;
  4252. }
  4253. var xDiff = event.clientX - this.clientXStart;
  4254. var yDiff = event.clientY - this.clientYStart;
  4255. var scrollTop = this.scrollTopStart - yDiff;
  4256. var scrollLeft = this.scrollLeftStart - xDiff;
  4257. if (this.element.scrollTo) {
  4258. this.element.scrollTo({
  4259. top: scrollTop,
  4260. left: scrollLeft,
  4261. behavior: "instant"
  4262. });
  4263. } else {
  4264. this.element.scrollTop = scrollTop;
  4265. this.element.scrollLeft = scrollLeft;
  4266. }
  4267. if (!this.overlay.parentNode) {
  4268. document.body.appendChild(this.overlay);
  4269. }
  4270. },
  4271. _endPan: function GrabToPan__endPan() {
  4272. this.element.removeEventListener("scroll", this._endPan, true);
  4273. this.document.removeEventListener("mousemove", this._onmousemove, true);
  4274. this.document.removeEventListener("mouseup", this._endPan, true);
  4275. this.overlay.remove();
  4276. }
  4277. };
  4278. var matchesSelector;
  4279. ["webkitM", "mozM", "msM", "oM", "m"].some(function (prefix) {
  4280. var name = prefix + "atches";
  4281. if (name in document.documentElement) {
  4282. matchesSelector = name;
  4283. }
  4284. name += "Selector";
  4285. if (name in document.documentElement) {
  4286. matchesSelector = name;
  4287. }
  4288. return matchesSelector;
  4289. });
  4290. var isNotIEorIsIE10plus = !document.documentMode || document.documentMode > 9;
  4291. var chrome = window.chrome;
  4292. var isChrome15OrOpera15plus = chrome && (chrome.webstore || chrome.app);
  4293. var isSafari6plus = /Apple/.test(navigator.vendor) && /Version\/([6-9]\d*|[1-5]\d+)/.test(navigator.userAgent);
  4294. function isLeftMouseReleased(event) {
  4295. if ("buttons" in event && isNotIEorIsIE10plus) {
  4296. return !(event.buttons & 1);
  4297. }
  4298. if (isChrome15OrOpera15plus || isSafari6plus) {
  4299. return event.which === 0;
  4300. }
  4301. return false;
  4302. }
  4303. /***/ }),
  4304. /* 11 */
  4305. /***/ (function(module, exports, __webpack_require__) {
  4306. "use strict";
  4307. Object.defineProperty(exports, "__esModule", {
  4308. value: true
  4309. });
  4310. exports.PDFRenderingQueue = exports.RenderingStates = void 0;
  4311. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  4312. 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); } }
  4313. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  4314. var CLEANUP_TIMEOUT = 30000;
  4315. var RenderingStates = {
  4316. INITIAL: 0,
  4317. RUNNING: 1,
  4318. PAUSED: 2,
  4319. FINISHED: 3
  4320. };
  4321. exports.RenderingStates = RenderingStates;
  4322. var PDFRenderingQueue = /*#__PURE__*/function () {
  4323. function PDFRenderingQueue() {
  4324. _classCallCheck(this, PDFRenderingQueue);
  4325. this.pdfViewer = null;
  4326. this.pdfThumbnailViewer = null;
  4327. this.onIdle = null;
  4328. this.highestPriorityPage = null;
  4329. this.idleTimeout = null;
  4330. this.printing = false;
  4331. this.isThumbnailViewEnabled = false;
  4332. }
  4333. _createClass(PDFRenderingQueue, [{
  4334. key: "setViewer",
  4335. value: function setViewer(pdfViewer) {
  4336. this.pdfViewer = pdfViewer;
  4337. }
  4338. }, {
  4339. key: "setThumbnailViewer",
  4340. value: function setThumbnailViewer(pdfThumbnailViewer) {
  4341. this.pdfThumbnailViewer = pdfThumbnailViewer;
  4342. }
  4343. }, {
  4344. key: "isHighestPriority",
  4345. value: function isHighestPriority(view) {
  4346. return this.highestPriorityPage === view.renderingId;
  4347. }
  4348. }, {
  4349. key: "renderHighestPriority",
  4350. value: function renderHighestPriority(currentlyVisiblePages) {
  4351. if (this.idleTimeout) {
  4352. clearTimeout(this.idleTimeout);
  4353. this.idleTimeout = null;
  4354. }
  4355. if (this.pdfViewer.forceRendering(currentlyVisiblePages)) {
  4356. return;
  4357. }
  4358. if (this.pdfThumbnailViewer && this.isThumbnailViewEnabled) {
  4359. if (this.pdfThumbnailViewer.forceRendering()) {
  4360. return;
  4361. }
  4362. }
  4363. if (this.printing) {
  4364. return;
  4365. }
  4366. if (this.onIdle) {
  4367. this.idleTimeout = setTimeout(this.onIdle.bind(this), CLEANUP_TIMEOUT);
  4368. }
  4369. }
  4370. }, {
  4371. key: "getHighestPriority",
  4372. value: function getHighestPriority(visible, views, scrolledDown) {
  4373. var visibleViews = visible.views;
  4374. var numVisible = visibleViews.length;
  4375. if (numVisible === 0) {
  4376. return null;
  4377. }
  4378. for (var i = 0; i < numVisible; ++i) {
  4379. var view = visibleViews[i].view;
  4380. if (!this.isViewFinished(view)) {
  4381. return view;
  4382. }
  4383. }
  4384. if (scrolledDown) {
  4385. var nextPageIndex = visible.last.id;
  4386. if (views[nextPageIndex] && !this.isViewFinished(views[nextPageIndex])) {
  4387. return views[nextPageIndex];
  4388. }
  4389. } else {
  4390. var previousPageIndex = visible.first.id - 2;
  4391. if (views[previousPageIndex] && !this.isViewFinished(views[previousPageIndex])) {
  4392. return views[previousPageIndex];
  4393. }
  4394. }
  4395. return null;
  4396. }
  4397. }, {
  4398. key: "isViewFinished",
  4399. value: function isViewFinished(view) {
  4400. return view.renderingState === RenderingStates.FINISHED;
  4401. }
  4402. }, {
  4403. key: "renderView",
  4404. value: function renderView(view) {
  4405. var _this = this;
  4406. switch (view.renderingState) {
  4407. case RenderingStates.FINISHED:
  4408. return false;
  4409. case RenderingStates.PAUSED:
  4410. this.highestPriorityPage = view.renderingId;
  4411. view.resume();
  4412. break;
  4413. case RenderingStates.RUNNING:
  4414. this.highestPriorityPage = view.renderingId;
  4415. break;
  4416. case RenderingStates.INITIAL:
  4417. this.highestPriorityPage = view.renderingId;
  4418. view.draw()["finally"](function () {
  4419. _this.renderHighestPriority();
  4420. })["catch"](function (reason) {
  4421. console.error("renderView: \"".concat(reason, "\""));
  4422. });
  4423. break;
  4424. }
  4425. return true;
  4426. }
  4427. }]);
  4428. return PDFRenderingQueue;
  4429. }();
  4430. exports.PDFRenderingQueue = PDFRenderingQueue;
  4431. /***/ }),
  4432. /* 12 */
  4433. /***/ (function(module, exports, __webpack_require__) {
  4434. "use strict";
  4435. Object.defineProperty(exports, "__esModule", {
  4436. value: true
  4437. });
  4438. exports.PDFSidebar = exports.SidebarView = void 0;
  4439. var _ui_utils = __webpack_require__(5);
  4440. var _pdf_rendering_queue = __webpack_require__(11);
  4441. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  4442. 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); } }
  4443. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  4444. var UI_NOTIFICATION_CLASS = "pdfSidebarNotification";
  4445. var SidebarView = {
  4446. UNKNOWN: -1,
  4447. NONE: 0,
  4448. THUMBS: 1,
  4449. OUTLINE: 2,
  4450. ATTACHMENTS: 3,
  4451. LAYERS: 4
  4452. };
  4453. exports.SidebarView = SidebarView;
  4454. var PDFSidebar = /*#__PURE__*/function () {
  4455. function PDFSidebar(_ref) {
  4456. var elements = _ref.elements,
  4457. pdfViewer = _ref.pdfViewer,
  4458. pdfThumbnailViewer = _ref.pdfThumbnailViewer,
  4459. eventBus = _ref.eventBus,
  4460. _ref$l10n = _ref.l10n,
  4461. l10n = _ref$l10n === void 0 ? _ui_utils.NullL10n : _ref$l10n,
  4462. _ref$disableNotificat = _ref.disableNotification,
  4463. disableNotification = _ref$disableNotificat === void 0 ? false : _ref$disableNotificat;
  4464. _classCallCheck(this, PDFSidebar);
  4465. this.isOpen = false;
  4466. this.active = SidebarView.THUMBS;
  4467. this.isInitialViewSet = false;
  4468. this.onToggled = null;
  4469. this.pdfViewer = pdfViewer;
  4470. this.pdfThumbnailViewer = pdfThumbnailViewer;
  4471. this.outerContainer = elements.outerContainer;
  4472. this.viewerContainer = elements.viewerContainer;
  4473. this.toggleButton = elements.toggleButton;
  4474. this.thumbnailButton = elements.thumbnailButton;
  4475. this.outlineButton = elements.outlineButton;
  4476. this.attachmentsButton = elements.attachmentsButton;
  4477. this.thumbnailView = elements.thumbnailView;
  4478. this.outlineView = elements.outlineView;
  4479. this.attachmentsView = elements.attachmentsView;
  4480. this.eventBus = eventBus;
  4481. this.l10n = l10n;
  4482. this._disableNotification = disableNotification;
  4483. this._addEventListeners();
  4484. }
  4485. _createClass(PDFSidebar, [{
  4486. key: "reset",
  4487. value: function reset() {
  4488. this.isInitialViewSet = false;
  4489. this._hideUINotification(null);
  4490. this.switchView(SidebarView.THUMBS);
  4491. this.outlineButton.disabled = false;
  4492. this.attachmentsButton.disabled = false;
  4493. }
  4494. }, {
  4495. key: "setInitialView",
  4496. value: function setInitialView() {
  4497. var view = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : SidebarView.NONE;
  4498. if (this.isInitialViewSet) {
  4499. return;
  4500. }
  4501. this.isInitialViewSet = true;
  4502. if (view === SidebarView.NONE || view === SidebarView.UNKNOWN) {
  4503. this._dispatchEvent();
  4504. return;
  4505. }
  4506. if (!this._switchView(view, true)) {
  4507. this._dispatchEvent();
  4508. }
  4509. }
  4510. }, {
  4511. key: "switchView",
  4512. value: function switchView(view) {
  4513. var forceOpen = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  4514. this._switchView(view, forceOpen);
  4515. }
  4516. }, {
  4517. key: "_switchView",
  4518. value: function _switchView(view) {
  4519. var forceOpen = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  4520. var isViewChanged = view !== this.active;
  4521. var shouldForceRendering = false;
  4522. switch (view) {
  4523. case SidebarView.NONE:
  4524. if (this.isOpen) {
  4525. this.close();
  4526. return true;
  4527. }
  4528. return false;
  4529. case SidebarView.THUMBS:
  4530. if (this.isOpen && isViewChanged) {
  4531. shouldForceRendering = true;
  4532. }
  4533. break;
  4534. case SidebarView.OUTLINE:
  4535. if (this.outlineButton.disabled) {
  4536. return false;
  4537. }
  4538. break;
  4539. case SidebarView.ATTACHMENTS:
  4540. if (this.attachmentsButton.disabled) {
  4541. return false;
  4542. }
  4543. break;
  4544. default:
  4545. console.error("PDFSidebar._switchView: \"".concat(view, "\" is not a valid view."));
  4546. return false;
  4547. }
  4548. this.active = view;
  4549. this.thumbnailButton.classList.toggle("toggled", view === SidebarView.THUMBS);
  4550. this.outlineButton.classList.toggle("toggled", view === SidebarView.OUTLINE);
  4551. this.attachmentsButton.classList.toggle("toggled", view === SidebarView.ATTACHMENTS);
  4552. this.thumbnailView.classList.toggle("hidden", view !== SidebarView.THUMBS);
  4553. this.outlineView.classList.toggle("hidden", view !== SidebarView.OUTLINE);
  4554. this.attachmentsView.classList.toggle("hidden", view !== SidebarView.ATTACHMENTS);
  4555. if (forceOpen && !this.isOpen) {
  4556. this.open();
  4557. return true;
  4558. }
  4559. if (shouldForceRendering) {
  4560. this._updateThumbnailViewer();
  4561. this._forceRendering();
  4562. }
  4563. if (isViewChanged) {
  4564. this._dispatchEvent();
  4565. }
  4566. this._hideUINotification(this.active);
  4567. return isViewChanged;
  4568. }
  4569. }, {
  4570. key: "open",
  4571. value: function open() {
  4572. if (this.isOpen) {
  4573. return;
  4574. }
  4575. this.isOpen = true;
  4576. this.toggleButton.classList.add("toggled");
  4577. this.outerContainer.classList.add("sidebarMoving", "sidebarOpen");
  4578. if (this.active === SidebarView.THUMBS) {
  4579. this._updateThumbnailViewer();
  4580. }
  4581. this._forceRendering();
  4582. this._dispatchEvent();
  4583. this._hideUINotification(this.active);
  4584. }
  4585. }, {
  4586. key: "close",
  4587. value: function close() {
  4588. if (!this.isOpen) {
  4589. return;
  4590. }
  4591. this.isOpen = false;
  4592. this.toggleButton.classList.remove("toggled");
  4593. this.outerContainer.classList.add("sidebarMoving");
  4594. this.outerContainer.classList.remove("sidebarOpen");
  4595. this._forceRendering();
  4596. this._dispatchEvent();
  4597. }
  4598. }, {
  4599. key: "toggle",
  4600. value: function toggle() {
  4601. if (this.isOpen) {
  4602. this.close();
  4603. } else {
  4604. this.open();
  4605. }
  4606. }
  4607. }, {
  4608. key: "_dispatchEvent",
  4609. value: function _dispatchEvent() {
  4610. this.eventBus.dispatch("sidebarviewchanged", {
  4611. source: this,
  4612. view: this.visibleView
  4613. });
  4614. }
  4615. }, {
  4616. key: "_forceRendering",
  4617. value: function _forceRendering() {
  4618. if (this.onToggled) {
  4619. this.onToggled();
  4620. } else {
  4621. this.pdfViewer.forceRendering();
  4622. this.pdfThumbnailViewer.forceRendering();
  4623. }
  4624. }
  4625. }, {
  4626. key: "_updateThumbnailViewer",
  4627. value: function _updateThumbnailViewer() {
  4628. var pdfViewer = this.pdfViewer,
  4629. pdfThumbnailViewer = this.pdfThumbnailViewer;
  4630. var pagesCount = pdfViewer.pagesCount;
  4631. for (var pageIndex = 0; pageIndex < pagesCount; pageIndex++) {
  4632. var pageView = pdfViewer.getPageView(pageIndex);
  4633. if (pageView && pageView.renderingState === _pdf_rendering_queue.RenderingStates.FINISHED) {
  4634. var thumbnailView = pdfThumbnailViewer.getThumbnail(pageIndex);
  4635. thumbnailView.setImage(pageView);
  4636. }
  4637. }
  4638. pdfThumbnailViewer.scrollThumbnailIntoView(pdfViewer.currentPageNumber);
  4639. }
  4640. }, {
  4641. key: "_showUINotification",
  4642. value: function _showUINotification(view) {
  4643. var _this = this;
  4644. if (this._disableNotification) {
  4645. return;
  4646. }
  4647. this.l10n.get("toggle_sidebar_notification.title", null, "Toggle Sidebar (document contains outline/attachments)").then(function (msg) {
  4648. _this.toggleButton.title = msg;
  4649. });
  4650. if (!this.isOpen) {
  4651. this.toggleButton.classList.add(UI_NOTIFICATION_CLASS);
  4652. } else if (view === this.active) {
  4653. return;
  4654. }
  4655. switch (view) {
  4656. case SidebarView.OUTLINE:
  4657. this.outlineButton.classList.add(UI_NOTIFICATION_CLASS);
  4658. break;
  4659. case SidebarView.ATTACHMENTS:
  4660. this.attachmentsButton.classList.add(UI_NOTIFICATION_CLASS);
  4661. break;
  4662. }
  4663. }
  4664. }, {
  4665. key: "_hideUINotification",
  4666. value: function _hideUINotification(view) {
  4667. var _this2 = this;
  4668. if (this._disableNotification) {
  4669. return;
  4670. }
  4671. var removeNotification = function removeNotification(sidebarView) {
  4672. switch (sidebarView) {
  4673. case SidebarView.OUTLINE:
  4674. _this2.outlineButton.classList.remove(UI_NOTIFICATION_CLASS);
  4675. break;
  4676. case SidebarView.ATTACHMENTS:
  4677. _this2.attachmentsButton.classList.remove(UI_NOTIFICATION_CLASS);
  4678. break;
  4679. }
  4680. };
  4681. if (!this.isOpen && view !== null) {
  4682. return;
  4683. }
  4684. this.toggleButton.classList.remove(UI_NOTIFICATION_CLASS);
  4685. if (view !== null) {
  4686. removeNotification(view);
  4687. return;
  4688. }
  4689. for (view in SidebarView) {
  4690. removeNotification(SidebarView[view]);
  4691. }
  4692. this.l10n.get("toggle_sidebar.title", null, "Toggle Sidebar").then(function (msg) {
  4693. _this2.toggleButton.title = msg;
  4694. });
  4695. }
  4696. }, {
  4697. key: "_addEventListeners",
  4698. value: function _addEventListeners() {
  4699. var _this3 = this;
  4700. this.viewerContainer.addEventListener("transitionend", function (evt) {
  4701. if (evt.target === _this3.viewerContainer) {
  4702. _this3.outerContainer.classList.remove("sidebarMoving");
  4703. }
  4704. });
  4705. this.toggleButton.addEventListener("click", function () {
  4706. _this3.toggle();
  4707. });
  4708. this.thumbnailButton.addEventListener("click", function () {
  4709. _this3.switchView(SidebarView.THUMBS);
  4710. });
  4711. this.outlineButton.addEventListener("click", function () {
  4712. _this3.switchView(SidebarView.OUTLINE);
  4713. });
  4714. this.outlineButton.addEventListener("dblclick", function () {
  4715. _this3.eventBus.dispatch("toggleoutlinetree", {
  4716. source: _this3
  4717. });
  4718. });
  4719. this.attachmentsButton.addEventListener("click", function () {
  4720. _this3.switchView(SidebarView.ATTACHMENTS);
  4721. });
  4722. this.eventBus._on("outlineloaded", function (evt) {
  4723. var outlineCount = evt.outlineCount;
  4724. _this3.outlineButton.disabled = !outlineCount;
  4725. if (outlineCount) {
  4726. _this3._showUINotification(SidebarView.OUTLINE);
  4727. } else if (_this3.active === SidebarView.OUTLINE) {
  4728. _this3.switchView(SidebarView.THUMBS);
  4729. }
  4730. });
  4731. this.eventBus._on("attachmentsloaded", function (evt) {
  4732. if (evt.attachmentsCount) {
  4733. _this3.attachmentsButton.disabled = false;
  4734. _this3._showUINotification(SidebarView.ATTACHMENTS);
  4735. return;
  4736. }
  4737. Promise.resolve().then(function () {
  4738. if (_this3.attachmentsView.hasChildNodes()) {
  4739. return;
  4740. }
  4741. _this3.attachmentsButton.disabled = true;
  4742. if (_this3.active === SidebarView.ATTACHMENTS) {
  4743. _this3.switchView(SidebarView.THUMBS);
  4744. }
  4745. });
  4746. });
  4747. this.eventBus._on("presentationmodechanged", function (evt) {
  4748. if (!evt.active && !evt.switchInProgress && _this3.isThumbnailViewVisible) {
  4749. _this3._updateThumbnailViewer();
  4750. }
  4751. });
  4752. }
  4753. }, {
  4754. key: "visibleView",
  4755. get: function get() {
  4756. return this.isOpen ? this.active : SidebarView.NONE;
  4757. }
  4758. }, {
  4759. key: "isThumbnailViewVisible",
  4760. get: function get() {
  4761. return this.isOpen && this.active === SidebarView.THUMBS;
  4762. }
  4763. }, {
  4764. key: "isOutlineViewVisible",
  4765. get: function get() {
  4766. return this.isOpen && this.active === SidebarView.OUTLINE;
  4767. }
  4768. }, {
  4769. key: "isAttachmentsViewVisible",
  4770. get: function get() {
  4771. return this.isOpen && this.active === SidebarView.ATTACHMENTS;
  4772. }
  4773. }]);
  4774. return PDFSidebar;
  4775. }();
  4776. exports.PDFSidebar = PDFSidebar;
  4777. /***/ }),
  4778. /* 13 */
  4779. /***/ (function(module, exports, __webpack_require__) {
  4780. "use strict";
  4781. Object.defineProperty(exports, "__esModule", {
  4782. value: true
  4783. });
  4784. exports.OverlayManager = void 0;
  4785. var _regenerator = _interopRequireDefault(__webpack_require__(2));
  4786. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  4787. 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); } }
  4788. 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); }); }; }
  4789. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  4790. 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); } }
  4791. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  4792. var OverlayManager = /*#__PURE__*/function () {
  4793. function OverlayManager() {
  4794. _classCallCheck(this, OverlayManager);
  4795. this._overlays = {};
  4796. this._active = null;
  4797. this._keyDownBound = this._keyDown.bind(this);
  4798. }
  4799. _createClass(OverlayManager, [{
  4800. key: "register",
  4801. value: function () {
  4802. var _register = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee(name, element) {
  4803. var callerCloseMethod,
  4804. canForceClose,
  4805. container,
  4806. _args = arguments;
  4807. return _regenerator["default"].wrap(function _callee$(_context) {
  4808. while (1) {
  4809. switch (_context.prev = _context.next) {
  4810. case 0:
  4811. callerCloseMethod = _args.length > 2 && _args[2] !== undefined ? _args[2] : null;
  4812. canForceClose = _args.length > 3 && _args[3] !== undefined ? _args[3] : false;
  4813. if (!(!name || !element || !(container = element.parentNode))) {
  4814. _context.next = 6;
  4815. break;
  4816. }
  4817. throw new Error("Not enough parameters.");
  4818. case 6:
  4819. if (!this._overlays[name]) {
  4820. _context.next = 8;
  4821. break;
  4822. }
  4823. throw new Error("The overlay is already registered.");
  4824. case 8:
  4825. this._overlays[name] = {
  4826. element: element,
  4827. container: container,
  4828. callerCloseMethod: callerCloseMethod,
  4829. canForceClose: canForceClose
  4830. };
  4831. case 9:
  4832. case "end":
  4833. return _context.stop();
  4834. }
  4835. }
  4836. }, _callee, this);
  4837. }));
  4838. function register(_x, _x2) {
  4839. return _register.apply(this, arguments);
  4840. }
  4841. return register;
  4842. }()
  4843. }, {
  4844. key: "unregister",
  4845. value: function () {
  4846. var _unregister = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee2(name) {
  4847. return _regenerator["default"].wrap(function _callee2$(_context2) {
  4848. while (1) {
  4849. switch (_context2.prev = _context2.next) {
  4850. case 0:
  4851. if (this._overlays[name]) {
  4852. _context2.next = 4;
  4853. break;
  4854. }
  4855. throw new Error("The overlay does not exist.");
  4856. case 4:
  4857. if (!(this._active === name)) {
  4858. _context2.next = 6;
  4859. break;
  4860. }
  4861. throw new Error("The overlay cannot be removed while it is active.");
  4862. case 6:
  4863. delete this._overlays[name];
  4864. case 7:
  4865. case "end":
  4866. return _context2.stop();
  4867. }
  4868. }
  4869. }, _callee2, this);
  4870. }));
  4871. function unregister(_x3) {
  4872. return _unregister.apply(this, arguments);
  4873. }
  4874. return unregister;
  4875. }()
  4876. }, {
  4877. key: "open",
  4878. value: function () {
  4879. var _open = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee3(name) {
  4880. return _regenerator["default"].wrap(function _callee3$(_context3) {
  4881. while (1) {
  4882. switch (_context3.prev = _context3.next) {
  4883. case 0:
  4884. if (this._overlays[name]) {
  4885. _context3.next = 4;
  4886. break;
  4887. }
  4888. throw new Error("The overlay does not exist.");
  4889. case 4:
  4890. if (!this._active) {
  4891. _context3.next = 14;
  4892. break;
  4893. }
  4894. if (!this._overlays[name].canForceClose) {
  4895. _context3.next = 9;
  4896. break;
  4897. }
  4898. this._closeThroughCaller();
  4899. _context3.next = 14;
  4900. break;
  4901. case 9:
  4902. if (!(this._active === name)) {
  4903. _context3.next = 13;
  4904. break;
  4905. }
  4906. throw new Error("The overlay is already active.");
  4907. case 13:
  4908. throw new Error("Another overlay is currently active.");
  4909. case 14:
  4910. this._active = name;
  4911. this._overlays[this._active].element.classList.remove("hidden");
  4912. this._overlays[this._active].container.classList.remove("hidden");
  4913. window.addEventListener("keydown", this._keyDownBound);
  4914. case 18:
  4915. case "end":
  4916. return _context3.stop();
  4917. }
  4918. }
  4919. }, _callee3, this);
  4920. }));
  4921. function open(_x4) {
  4922. return _open.apply(this, arguments);
  4923. }
  4924. return open;
  4925. }()
  4926. }, {
  4927. key: "close",
  4928. value: function () {
  4929. var _close = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee4(name) {
  4930. return _regenerator["default"].wrap(function _callee4$(_context4) {
  4931. while (1) {
  4932. switch (_context4.prev = _context4.next) {
  4933. case 0:
  4934. if (this._overlays[name]) {
  4935. _context4.next = 4;
  4936. break;
  4937. }
  4938. throw new Error("The overlay does not exist.");
  4939. case 4:
  4940. if (this._active) {
  4941. _context4.next = 8;
  4942. break;
  4943. }
  4944. throw new Error("The overlay is currently not active.");
  4945. case 8:
  4946. if (!(this._active !== name)) {
  4947. _context4.next = 10;
  4948. break;
  4949. }
  4950. throw new Error("Another overlay is currently active.");
  4951. case 10:
  4952. this._overlays[this._active].container.classList.add("hidden");
  4953. this._overlays[this._active].element.classList.add("hidden");
  4954. this._active = null;
  4955. window.removeEventListener("keydown", this._keyDownBound);
  4956. case 14:
  4957. case "end":
  4958. return _context4.stop();
  4959. }
  4960. }
  4961. }, _callee4, this);
  4962. }));
  4963. function close(_x5) {
  4964. return _close.apply(this, arguments);
  4965. }
  4966. return close;
  4967. }()
  4968. }, {
  4969. key: "_keyDown",
  4970. value: function _keyDown(evt) {
  4971. if (this._active && evt.keyCode === 27) {
  4972. this._closeThroughCaller();
  4973. evt.preventDefault();
  4974. }
  4975. }
  4976. }, {
  4977. key: "_closeThroughCaller",
  4978. value: function _closeThroughCaller() {
  4979. if (this._overlays[this._active].callerCloseMethod) {
  4980. this._overlays[this._active].callerCloseMethod();
  4981. }
  4982. if (this._active) {
  4983. this.close(this._active);
  4984. }
  4985. }
  4986. }, {
  4987. key: "active",
  4988. get: function get() {
  4989. return this._active;
  4990. }
  4991. }]);
  4992. return OverlayManager;
  4993. }();
  4994. exports.OverlayManager = OverlayManager;
  4995. /***/ }),
  4996. /* 14 */
  4997. /***/ (function(module, exports, __webpack_require__) {
  4998. "use strict";
  4999. Object.defineProperty(exports, "__esModule", {
  5000. value: true
  5001. });
  5002. exports.PasswordPrompt = void 0;
  5003. var _ui_utils = __webpack_require__(5);
  5004. var _pdfjsLib = __webpack_require__(8);
  5005. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  5006. 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); } }
  5007. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  5008. var PasswordPrompt = /*#__PURE__*/function () {
  5009. function PasswordPrompt(options, overlayManager) {
  5010. var _this = this;
  5011. var l10n = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : _ui_utils.NullL10n;
  5012. _classCallCheck(this, PasswordPrompt);
  5013. this.overlayName = options.overlayName;
  5014. this.container = options.container;
  5015. this.label = options.label;
  5016. this.input = options.input;
  5017. this.submitButton = options.submitButton;
  5018. this.cancelButton = options.cancelButton;
  5019. this.overlayManager = overlayManager;
  5020. this.l10n = l10n;
  5021. this.updateCallback = null;
  5022. this.reason = null;
  5023. this.submitButton.addEventListener("click", this.verify.bind(this));
  5024. this.cancelButton.addEventListener("click", this.close.bind(this));
  5025. this.input.addEventListener("keydown", function (e) {
  5026. if (e.keyCode === 13) {
  5027. _this.verify();
  5028. }
  5029. });
  5030. this.overlayManager.register(this.overlayName, this.container, this.close.bind(this), true);
  5031. }
  5032. _createClass(PasswordPrompt, [{
  5033. key: "open",
  5034. value: function open() {
  5035. var _this2 = this;
  5036. this.overlayManager.open(this.overlayName).then(function () {
  5037. _this2.input.focus();
  5038. var promptString;
  5039. if (_this2.reason === _pdfjsLib.PasswordResponses.INCORRECT_PASSWORD) {
  5040. promptString = _this2.l10n.get("password_invalid", null, "Invalid password. Please try again.");
  5041. } else {
  5042. promptString = _this2.l10n.get("password_label", null, "Enter the password to open this PDF file.");
  5043. }
  5044. promptString.then(function (msg) {
  5045. _this2.label.textContent = msg;
  5046. });
  5047. });
  5048. }
  5049. }, {
  5050. key: "close",
  5051. value: function close() {
  5052. var _this3 = this;
  5053. this.overlayManager.close(this.overlayName).then(function () {
  5054. _this3.input.value = "";
  5055. });
  5056. }
  5057. }, {
  5058. key: "verify",
  5059. value: function verify() {
  5060. var password = this.input.value;
  5061. if (password && password.length > 0) {
  5062. this.close();
  5063. this.updateCallback(password);
  5064. }
  5065. }
  5066. }, {
  5067. key: "setUpdateCallback",
  5068. value: function setUpdateCallback(updateCallback, reason) {
  5069. this.updateCallback = updateCallback;
  5070. this.reason = reason;
  5071. }
  5072. }]);
  5073. return PasswordPrompt;
  5074. }();
  5075. exports.PasswordPrompt = PasswordPrompt;
  5076. /***/ }),
  5077. /* 15 */
  5078. /***/ (function(module, exports, __webpack_require__) {
  5079. "use strict";
  5080. Object.defineProperty(exports, "__esModule", {
  5081. value: true
  5082. });
  5083. exports.PDFAttachmentViewer = void 0;
  5084. var _pdfjsLib = __webpack_require__(8);
  5085. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  5086. 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); } }
  5087. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  5088. var PDFAttachmentViewer = /*#__PURE__*/function () {
  5089. function PDFAttachmentViewer(_ref) {
  5090. var container = _ref.container,
  5091. eventBus = _ref.eventBus,
  5092. downloadManager = _ref.downloadManager;
  5093. _classCallCheck(this, PDFAttachmentViewer);
  5094. this.container = container;
  5095. this.eventBus = eventBus;
  5096. this.downloadManager = downloadManager;
  5097. this.reset();
  5098. this.eventBus._on("fileattachmentannotation", this._appendAttachment.bind(this));
  5099. }
  5100. _createClass(PDFAttachmentViewer, [{
  5101. key: "reset",
  5102. value: function reset() {
  5103. var keepRenderedCapability = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  5104. this.attachments = null;
  5105. this.container.textContent = "";
  5106. if (!keepRenderedCapability) {
  5107. this._renderedCapability = (0, _pdfjsLib.createPromiseCapability)();
  5108. }
  5109. }
  5110. }, {
  5111. key: "_dispatchEvent",
  5112. value: function _dispatchEvent(attachmentsCount) {
  5113. this._renderedCapability.resolve();
  5114. this.eventBus.dispatch("attachmentsloaded", {
  5115. source: this,
  5116. attachmentsCount: attachmentsCount
  5117. });
  5118. }
  5119. }, {
  5120. key: "_bindPdfLink",
  5121. value: function _bindPdfLink(button, content, filename) {
  5122. var _this = this;
  5123. var blobUrl;
  5124. button.onclick = function () {
  5125. if (!blobUrl) {
  5126. blobUrl = URL.createObjectURL(new Blob([content], {
  5127. type: "application/pdf"
  5128. }));
  5129. }
  5130. var viewerUrl;
  5131. viewerUrl = "?file=" + encodeURIComponent(blobUrl + "#" + filename);
  5132. try {
  5133. window.open(viewerUrl);
  5134. } catch (ex) {
  5135. console.error("_bindPdfLink: ".concat(ex));
  5136. URL.revokeObjectURL(blobUrl);
  5137. blobUrl = null;
  5138. _this.downloadManager.downloadData(content, filename, "application/pdf");
  5139. }
  5140. return false;
  5141. };
  5142. }
  5143. }, {
  5144. key: "_bindLink",
  5145. value: function _bindLink(button, content, filename) {
  5146. var _this2 = this;
  5147. button.onclick = function () {
  5148. _this2.downloadManager.downloadData(content, filename, "");
  5149. return false;
  5150. };
  5151. }
  5152. }, {
  5153. key: "render",
  5154. value: function render(_ref2) {
  5155. var attachments = _ref2.attachments,
  5156. _ref2$keepRenderedCap = _ref2.keepRenderedCapability,
  5157. keepRenderedCapability = _ref2$keepRenderedCap === void 0 ? false : _ref2$keepRenderedCap;
  5158. var attachmentsCount = 0;
  5159. if (this.attachments) {
  5160. this.reset(keepRenderedCapability === true);
  5161. }
  5162. this.attachments = attachments || null;
  5163. if (!attachments) {
  5164. this._dispatchEvent(attachmentsCount);
  5165. return;
  5166. }
  5167. var names = Object.keys(attachments).sort(function (a, b) {
  5168. return a.toLowerCase().localeCompare(b.toLowerCase());
  5169. });
  5170. attachmentsCount = names.length;
  5171. for (var i = 0; i < attachmentsCount; i++) {
  5172. var item = attachments[names[i]];
  5173. var filename = (0, _pdfjsLib.removeNullCharacters)((0, _pdfjsLib.getFilenameFromUrl)(item.filename));
  5174. var div = document.createElement("div");
  5175. div.className = "attachmentsItem";
  5176. var button = document.createElement("button");
  5177. button.textContent = filename;
  5178. if (/\.pdf$/i.test(filename) && !this.downloadManager.disableCreateObjectURL) {
  5179. this._bindPdfLink(button, item.content, filename);
  5180. } else {
  5181. this._bindLink(button, item.content, filename);
  5182. }
  5183. div.appendChild(button);
  5184. this.container.appendChild(div);
  5185. }
  5186. this._dispatchEvent(attachmentsCount);
  5187. }
  5188. }, {
  5189. key: "_appendAttachment",
  5190. value: function _appendAttachment(_ref3) {
  5191. var _this3 = this;
  5192. var id = _ref3.id,
  5193. filename = _ref3.filename,
  5194. content = _ref3.content;
  5195. this._renderedCapability.promise.then(function () {
  5196. var attachments = _this3.attachments;
  5197. if (!attachments) {
  5198. attachments = Object.create(null);
  5199. } else {
  5200. for (var name in attachments) {
  5201. if (id === name) {
  5202. return;
  5203. }
  5204. }
  5205. }
  5206. attachments[id] = {
  5207. filename: filename,
  5208. content: content
  5209. };
  5210. _this3.render({
  5211. attachments: attachments,
  5212. keepRenderedCapability: true
  5213. });
  5214. });
  5215. }
  5216. }]);
  5217. return PDFAttachmentViewer;
  5218. }();
  5219. exports.PDFAttachmentViewer = PDFAttachmentViewer;
  5220. /***/ }),
  5221. /* 16 */
  5222. /***/ (function(module, exports, __webpack_require__) {
  5223. "use strict";
  5224. Object.defineProperty(exports, "__esModule", {
  5225. value: true
  5226. });
  5227. exports.PDFDocumentProperties = void 0;
  5228. var _regenerator = _interopRequireDefault(__webpack_require__(2));
  5229. var _pdfjsLib = __webpack_require__(8);
  5230. var _ui_utils = __webpack_require__(5);
  5231. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  5232. 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); } }
  5233. 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); }); }; }
  5234. function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
  5235. 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."); }
  5236. 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); }
  5237. 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; }
  5238. function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_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; }
  5239. function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
  5240. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  5241. 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); } }
  5242. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  5243. var DEFAULT_FIELD_CONTENT = "-";
  5244. var NON_METRIC_LOCALES = ["en-us", "en-lr", "my"];
  5245. var US_PAGE_NAMES = {
  5246. "8.5x11": "Letter",
  5247. "8.5x14": "Legal"
  5248. };
  5249. var METRIC_PAGE_NAMES = {
  5250. "297x420": "A3",
  5251. "210x297": "A4"
  5252. };
  5253. function getPageName(size, isPortrait, pageNames) {
  5254. var width = isPortrait ? size.width : size.height;
  5255. var height = isPortrait ? size.height : size.width;
  5256. return pageNames["".concat(width, "x").concat(height)];
  5257. }
  5258. var PDFDocumentProperties = /*#__PURE__*/function () {
  5259. function PDFDocumentProperties(_ref, overlayManager, eventBus) {
  5260. var _this = this;
  5261. var overlayName = _ref.overlayName,
  5262. fields = _ref.fields,
  5263. container = _ref.container,
  5264. closeButton = _ref.closeButton;
  5265. var l10n = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : _ui_utils.NullL10n;
  5266. _classCallCheck(this, PDFDocumentProperties);
  5267. this.overlayName = overlayName;
  5268. this.fields = fields;
  5269. this.container = container;
  5270. this.overlayManager = overlayManager;
  5271. this.l10n = l10n;
  5272. this._reset();
  5273. closeButton.addEventListener("click", this.close.bind(this));
  5274. this.overlayManager.register(this.overlayName, this.container, this.close.bind(this));
  5275. eventBus._on("pagechanging", function (evt) {
  5276. _this._currentPageNumber = evt.pageNumber;
  5277. });
  5278. eventBus._on("rotationchanging", function (evt) {
  5279. _this._pagesRotation = evt.pagesRotation;
  5280. });
  5281. this._isNonMetricLocale = true;
  5282. l10n.getLanguage().then(function (locale) {
  5283. _this._isNonMetricLocale = NON_METRIC_LOCALES.includes(locale);
  5284. });
  5285. }
  5286. _createClass(PDFDocumentProperties, [{
  5287. key: "open",
  5288. value: function open() {
  5289. var _this2 = this;
  5290. var freezeFieldData = function freezeFieldData(data) {
  5291. Object.defineProperty(_this2, "fieldData", {
  5292. value: Object.freeze(data),
  5293. writable: false,
  5294. enumerable: true,
  5295. configurable: true
  5296. });
  5297. };
  5298. Promise.all([this.overlayManager.open(this.overlayName), this._dataAvailableCapability.promise]).then(function () {
  5299. var currentPageNumber = _this2._currentPageNumber;
  5300. var pagesRotation = _this2._pagesRotation;
  5301. if (_this2.fieldData && currentPageNumber === _this2.fieldData._currentPageNumber && pagesRotation === _this2.fieldData._pagesRotation) {
  5302. _this2._updateUI();
  5303. return;
  5304. }
  5305. _this2.pdfDocument.getMetadata().then(function (_ref2) {
  5306. var info = _ref2.info,
  5307. metadata = _ref2.metadata,
  5308. contentDispositionFilename = _ref2.contentDispositionFilename;
  5309. return Promise.all([info, metadata, contentDispositionFilename || (0, _ui_utils.getPDFFileNameFromURL)(_this2.url), _this2._parseFileSize(_this2.maybeFileSize), _this2._parseDate(info.CreationDate), _this2._parseDate(info.ModDate), _this2.pdfDocument.getPage(currentPageNumber).then(function (pdfPage) {
  5310. return _this2._parsePageSize((0, _ui_utils.getPageSizeInches)(pdfPage), pagesRotation);
  5311. }), _this2._parseLinearization(info.IsLinearized)]);
  5312. }).then(function (_ref3) {
  5313. var _ref4 = _slicedToArray(_ref3, 8),
  5314. info = _ref4[0],
  5315. metadata = _ref4[1],
  5316. fileName = _ref4[2],
  5317. fileSize = _ref4[3],
  5318. creationDate = _ref4[4],
  5319. modDate = _ref4[5],
  5320. pageSize = _ref4[6],
  5321. isLinearized = _ref4[7];
  5322. freezeFieldData({
  5323. fileName: fileName,
  5324. fileSize: fileSize,
  5325. title: info.Title,
  5326. author: info.Author,
  5327. subject: info.Subject,
  5328. keywords: info.Keywords,
  5329. creationDate: creationDate,
  5330. modificationDate: modDate,
  5331. creator: info.Creator,
  5332. producer: info.Producer,
  5333. version: info.PDFFormatVersion,
  5334. pageCount: _this2.pdfDocument.numPages,
  5335. pageSize: pageSize,
  5336. linearized: isLinearized,
  5337. _currentPageNumber: currentPageNumber,
  5338. _pagesRotation: pagesRotation
  5339. });
  5340. _this2._updateUI();
  5341. return _this2.pdfDocument.getDownloadInfo();
  5342. }).then(function (_ref5) {
  5343. var length = _ref5.length;
  5344. _this2.maybeFileSize = length;
  5345. return _this2._parseFileSize(length);
  5346. }).then(function (fileSize) {
  5347. if (fileSize === _this2.fieldData.fileSize) {
  5348. return;
  5349. }
  5350. var data = Object.assign(Object.create(null), _this2.fieldData);
  5351. data.fileSize = fileSize;
  5352. freezeFieldData(data);
  5353. _this2._updateUI();
  5354. });
  5355. });
  5356. }
  5357. }, {
  5358. key: "close",
  5359. value: function close() {
  5360. this.overlayManager.close(this.overlayName);
  5361. }
  5362. }, {
  5363. key: "setDocument",
  5364. value: function setDocument(pdfDocument) {
  5365. var url = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  5366. if (this.pdfDocument) {
  5367. this._reset();
  5368. this._updateUI(true);
  5369. }
  5370. if (!pdfDocument) {
  5371. return;
  5372. }
  5373. this.pdfDocument = pdfDocument;
  5374. this.url = url;
  5375. this._dataAvailableCapability.resolve();
  5376. }
  5377. }, {
  5378. key: "setFileSize",
  5379. value: function setFileSize(fileSize) {
  5380. if (Number.isInteger(fileSize) && fileSize > 0) {
  5381. this.maybeFileSize = fileSize;
  5382. }
  5383. }
  5384. }, {
  5385. key: "_reset",
  5386. value: function _reset() {
  5387. this.pdfDocument = null;
  5388. this.url = null;
  5389. this.maybeFileSize = 0;
  5390. delete this.fieldData;
  5391. this._dataAvailableCapability = (0, _pdfjsLib.createPromiseCapability)();
  5392. this._currentPageNumber = 1;
  5393. this._pagesRotation = 0;
  5394. }
  5395. }, {
  5396. key: "_updateUI",
  5397. value: function _updateUI() {
  5398. var reset = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  5399. if (reset || !this.fieldData) {
  5400. for (var id in this.fields) {
  5401. this.fields[id].textContent = DEFAULT_FIELD_CONTENT;
  5402. }
  5403. return;
  5404. }
  5405. if (this.overlayManager.active !== this.overlayName) {
  5406. return;
  5407. }
  5408. for (var _id in this.fields) {
  5409. var content = this.fieldData[_id];
  5410. this.fields[_id].textContent = content || content === 0 ? content : DEFAULT_FIELD_CONTENT;
  5411. }
  5412. }
  5413. }, {
  5414. key: "_parseFileSize",
  5415. value: function () {
  5416. var _parseFileSize2 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
  5417. var fileSize,
  5418. kb,
  5419. _args = arguments;
  5420. return _regenerator["default"].wrap(function _callee$(_context) {
  5421. while (1) {
  5422. switch (_context.prev = _context.next) {
  5423. case 0:
  5424. fileSize = _args.length > 0 && _args[0] !== undefined ? _args[0] : 0;
  5425. kb = fileSize / 1024;
  5426. if (kb) {
  5427. _context.next = 6;
  5428. break;
  5429. }
  5430. return _context.abrupt("return", undefined);
  5431. case 6:
  5432. if (!(kb < 1024)) {
  5433. _context.next = 8;
  5434. break;
  5435. }
  5436. return _context.abrupt("return", this.l10n.get("document_properties_kb", {
  5437. size_kb: (+kb.toPrecision(3)).toLocaleString(),
  5438. size_b: fileSize.toLocaleString()
  5439. }, "{{size_kb}} KB ({{size_b}} bytes)"));
  5440. case 8:
  5441. return _context.abrupt("return", this.l10n.get("document_properties_mb", {
  5442. size_mb: (+(kb / 1024).toPrecision(3)).toLocaleString(),
  5443. size_b: fileSize.toLocaleString()
  5444. }, "{{size_mb}} MB ({{size_b}} bytes)"));
  5445. case 9:
  5446. case "end":
  5447. return _context.stop();
  5448. }
  5449. }
  5450. }, _callee, this);
  5451. }));
  5452. function _parseFileSize() {
  5453. return _parseFileSize2.apply(this, arguments);
  5454. }
  5455. return _parseFileSize;
  5456. }()
  5457. }, {
  5458. key: "_parsePageSize",
  5459. value: function () {
  5460. var _parsePageSize2 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee2(pageSizeInches, pagesRotation) {
  5461. var _this3 = this;
  5462. var isPortrait, sizeInches, sizeMillimeters, pageName, rawName, exactMillimeters, intMillimeters;
  5463. return _regenerator["default"].wrap(function _callee2$(_context2) {
  5464. while (1) {
  5465. switch (_context2.prev = _context2.next) {
  5466. case 0:
  5467. if (pageSizeInches) {
  5468. _context2.next = 2;
  5469. break;
  5470. }
  5471. return _context2.abrupt("return", undefined);
  5472. case 2:
  5473. if (pagesRotation % 180 !== 0) {
  5474. pageSizeInches = {
  5475. width: pageSizeInches.height,
  5476. height: pageSizeInches.width
  5477. };
  5478. }
  5479. isPortrait = (0, _ui_utils.isPortraitOrientation)(pageSizeInches);
  5480. sizeInches = {
  5481. width: Math.round(pageSizeInches.width * 100) / 100,
  5482. height: Math.round(pageSizeInches.height * 100) / 100
  5483. };
  5484. sizeMillimeters = {
  5485. width: Math.round(pageSizeInches.width * 25.4 * 10) / 10,
  5486. height: Math.round(pageSizeInches.height * 25.4 * 10) / 10
  5487. };
  5488. pageName = null;
  5489. rawName = getPageName(sizeInches, isPortrait, US_PAGE_NAMES) || getPageName(sizeMillimeters, isPortrait, METRIC_PAGE_NAMES);
  5490. if (!rawName && !(Number.isInteger(sizeMillimeters.width) && Number.isInteger(sizeMillimeters.height))) {
  5491. exactMillimeters = {
  5492. width: pageSizeInches.width * 25.4,
  5493. height: pageSizeInches.height * 25.4
  5494. };
  5495. intMillimeters = {
  5496. width: Math.round(sizeMillimeters.width),
  5497. height: Math.round(sizeMillimeters.height)
  5498. };
  5499. if (Math.abs(exactMillimeters.width - intMillimeters.width) < 0.1 && Math.abs(exactMillimeters.height - intMillimeters.height) < 0.1) {
  5500. rawName = getPageName(intMillimeters, isPortrait, METRIC_PAGE_NAMES);
  5501. if (rawName) {
  5502. sizeInches = {
  5503. width: Math.round(intMillimeters.width / 25.4 * 100) / 100,
  5504. height: Math.round(intMillimeters.height / 25.4 * 100) / 100
  5505. };
  5506. sizeMillimeters = intMillimeters;
  5507. }
  5508. }
  5509. }
  5510. if (rawName) {
  5511. pageName = this.l10n.get("document_properties_page_size_name_" + rawName.toLowerCase(), null, rawName);
  5512. }
  5513. return _context2.abrupt("return", Promise.all([this._isNonMetricLocale ? sizeInches : sizeMillimeters, this.l10n.get("document_properties_page_size_unit_" + (this._isNonMetricLocale ? "inches" : "millimeters"), null, this._isNonMetricLocale ? "in" : "mm"), pageName, this.l10n.get("document_properties_page_size_orientation_" + (isPortrait ? "portrait" : "landscape"), null, isPortrait ? "portrait" : "landscape")]).then(function (_ref6) {
  5514. var _ref7 = _slicedToArray(_ref6, 4),
  5515. _ref7$ = _ref7[0],
  5516. width = _ref7$.width,
  5517. height = _ref7$.height,
  5518. unit = _ref7[1],
  5519. name = _ref7[2],
  5520. orientation = _ref7[3];
  5521. return _this3.l10n.get("document_properties_page_size_dimension_" + (name ? "name_" : "") + "string", {
  5522. width: width.toLocaleString(),
  5523. height: height.toLocaleString(),
  5524. unit: unit,
  5525. name: name,
  5526. orientation: orientation
  5527. }, "{{width}} × {{height}} {{unit}} (" + (name ? "{{name}}, " : "") + "{{orientation}})");
  5528. }));
  5529. case 11:
  5530. case "end":
  5531. return _context2.stop();
  5532. }
  5533. }
  5534. }, _callee2, this);
  5535. }));
  5536. function _parsePageSize(_x, _x2) {
  5537. return _parsePageSize2.apply(this, arguments);
  5538. }
  5539. return _parsePageSize;
  5540. }()
  5541. }, {
  5542. key: "_parseDate",
  5543. value: function () {
  5544. var _parseDate2 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee3(inputDate) {
  5545. var dateObject;
  5546. return _regenerator["default"].wrap(function _callee3$(_context3) {
  5547. while (1) {
  5548. switch (_context3.prev = _context3.next) {
  5549. case 0:
  5550. dateObject = _pdfjsLib.PDFDateString.toDateObject(inputDate);
  5551. if (dateObject) {
  5552. _context3.next = 3;
  5553. break;
  5554. }
  5555. return _context3.abrupt("return", undefined);
  5556. case 3:
  5557. return _context3.abrupt("return", this.l10n.get("document_properties_date_string", {
  5558. date: dateObject.toLocaleDateString(),
  5559. time: dateObject.toLocaleTimeString()
  5560. }, "{{date}}, {{time}}"));
  5561. case 4:
  5562. case "end":
  5563. return _context3.stop();
  5564. }
  5565. }
  5566. }, _callee3, this);
  5567. }));
  5568. function _parseDate(_x3) {
  5569. return _parseDate2.apply(this, arguments);
  5570. }
  5571. return _parseDate;
  5572. }()
  5573. }, {
  5574. key: "_parseLinearization",
  5575. value: function _parseLinearization(isLinearized) {
  5576. return this.l10n.get("document_properties_linearized_" + (isLinearized ? "yes" : "no"), null, isLinearized ? "Yes" : "No");
  5577. }
  5578. }]);
  5579. return PDFDocumentProperties;
  5580. }();
  5581. exports.PDFDocumentProperties = PDFDocumentProperties;
  5582. /***/ }),
  5583. /* 17 */
  5584. /***/ (function(module, exports, __webpack_require__) {
  5585. "use strict";
  5586. Object.defineProperty(exports, "__esModule", {
  5587. value: true
  5588. });
  5589. exports.PDFFindBar = void 0;
  5590. var _pdf_find_controller = __webpack_require__(18);
  5591. var _ui_utils = __webpack_require__(5);
  5592. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  5593. 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); } }
  5594. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  5595. var MATCHES_COUNT_LIMIT = 1000;
  5596. var PDFFindBar = /*#__PURE__*/function () {
  5597. function PDFFindBar(options, eventBus) {
  5598. var _this = this;
  5599. var l10n = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : _ui_utils.NullL10n;
  5600. _classCallCheck(this, PDFFindBar);
  5601. this.opened = false;
  5602. this.bar = options.bar || null;
  5603. this.toggleButton = options.toggleButton || null;
  5604. this.findField = options.findField || null;
  5605. this.highlightAll = options.highlightAllCheckbox || null;
  5606. this.caseSensitive = options.caseSensitiveCheckbox || null;
  5607. this.entireWord = options.entireWordCheckbox || null;
  5608. this.findMsg = options.findMsg || null;
  5609. this.findResultsCount = options.findResultsCount || null;
  5610. this.findPreviousButton = options.findPreviousButton || null;
  5611. this.findNextButton = options.findNextButton || null;
  5612. this.eventBus = eventBus;
  5613. this.l10n = l10n;
  5614. this.toggleButton.addEventListener("click", function () {
  5615. _this.toggle();
  5616. });
  5617. this.findField.addEventListener("input", function () {
  5618. _this.dispatchEvent("");
  5619. });
  5620. this.bar.addEventListener("keydown", function (e) {
  5621. switch (e.keyCode) {
  5622. case 13:
  5623. if (e.target === _this.findField) {
  5624. _this.dispatchEvent("again", e.shiftKey);
  5625. }
  5626. break;
  5627. case 27:
  5628. _this.close();
  5629. break;
  5630. }
  5631. });
  5632. this.findPreviousButton.addEventListener("click", function () {
  5633. _this.dispatchEvent("again", true);
  5634. });
  5635. this.findNextButton.addEventListener("click", function () {
  5636. _this.dispatchEvent("again", false);
  5637. });
  5638. this.highlightAll.addEventListener("click", function () {
  5639. _this.dispatchEvent("highlightallchange");
  5640. });
  5641. this.caseSensitive.addEventListener("click", function () {
  5642. _this.dispatchEvent("casesensitivitychange");
  5643. });
  5644. this.entireWord.addEventListener("click", function () {
  5645. _this.dispatchEvent("entirewordchange");
  5646. });
  5647. this.eventBus._on("resize", this._adjustWidth.bind(this));
  5648. }
  5649. _createClass(PDFFindBar, [{
  5650. key: "reset",
  5651. value: function reset() {
  5652. this.updateUIState();
  5653. }
  5654. }, {
  5655. key: "dispatchEvent",
  5656. value: function dispatchEvent(type, findPrev) {
  5657. this.eventBus.dispatch("find", {
  5658. source: this,
  5659. type: type,
  5660. query: this.findField.value,
  5661. phraseSearch: true,
  5662. caseSensitive: this.caseSensitive.checked,
  5663. entireWord: this.entireWord.checked,
  5664. highlightAll: this.highlightAll.checked,
  5665. findPrevious: findPrev
  5666. });
  5667. }
  5668. }, {
  5669. key: "updateUIState",
  5670. value: function updateUIState(state, previous, matchesCount) {
  5671. var _this2 = this;
  5672. var notFound = false;
  5673. var findMsg = "";
  5674. var status = "";
  5675. switch (state) {
  5676. case _pdf_find_controller.FindState.FOUND:
  5677. break;
  5678. case _pdf_find_controller.FindState.PENDING:
  5679. status = "pending";
  5680. break;
  5681. case _pdf_find_controller.FindState.NOT_FOUND:
  5682. findMsg = this.l10n.get("find_not_found", null, "Phrase not found");
  5683. notFound = true;
  5684. break;
  5685. case _pdf_find_controller.FindState.WRAPPED:
  5686. if (previous) {
  5687. findMsg = this.l10n.get("find_reached_top", null, "Reached top of document, continued from bottom");
  5688. } else {
  5689. findMsg = this.l10n.get("find_reached_bottom", null, "Reached end of document, continued from top");
  5690. }
  5691. break;
  5692. }
  5693. this.findField.classList.toggle("notFound", notFound);
  5694. this.findField.setAttribute("data-status", status);
  5695. Promise.resolve(findMsg).then(function (msg) {
  5696. _this2.findMsg.textContent = msg;
  5697. _this2._adjustWidth();
  5698. });
  5699. this.updateResultsCount(matchesCount);
  5700. }
  5701. }, {
  5702. key: "updateResultsCount",
  5703. value: function updateResultsCount() {
  5704. var _this3 = this;
  5705. var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
  5706. _ref$current = _ref.current,
  5707. current = _ref$current === void 0 ? 0 : _ref$current,
  5708. _ref$total = _ref.total,
  5709. total = _ref$total === void 0 ? 0 : _ref$total;
  5710. if (!this.findResultsCount) {
  5711. return;
  5712. }
  5713. var limit = MATCHES_COUNT_LIMIT;
  5714. var matchesCountMsg = "";
  5715. if (total > 0) {
  5716. if (total > limit) {
  5717. matchesCountMsg = this.l10n.get("find_match_count_limit", {
  5718. limit: limit
  5719. }, "More than {{limit}} match" + (limit !== 1 ? "es" : ""));
  5720. } else {
  5721. matchesCountMsg = this.l10n.get("find_match_count", {
  5722. current: current,
  5723. total: total
  5724. }, "{{current}} of {{total}} match" + (total !== 1 ? "es" : ""));
  5725. }
  5726. }
  5727. Promise.resolve(matchesCountMsg).then(function (msg) {
  5728. _this3.findResultsCount.textContent = msg;
  5729. _this3.findResultsCount.classList.toggle("hidden", !total);
  5730. _this3._adjustWidth();
  5731. });
  5732. }
  5733. }, {
  5734. key: "open",
  5735. value: function open() {
  5736. if (!this.opened) {
  5737. this.opened = true;
  5738. this.toggleButton.classList.add("toggled");
  5739. this.bar.classList.remove("hidden");
  5740. }
  5741. this.findField.select();
  5742. this.findField.focus();
  5743. this._adjustWidth();
  5744. }
  5745. }, {
  5746. key: "close",
  5747. value: function close() {
  5748. if (!this.opened) {
  5749. return;
  5750. }
  5751. this.opened = false;
  5752. this.toggleButton.classList.remove("toggled");
  5753. this.bar.classList.add("hidden");
  5754. this.eventBus.dispatch("findbarclose", {
  5755. source: this
  5756. });
  5757. }
  5758. }, {
  5759. key: "toggle",
  5760. value: function toggle() {
  5761. if (this.opened) {
  5762. this.close();
  5763. } else {
  5764. this.open();
  5765. }
  5766. }
  5767. }, {
  5768. key: "_adjustWidth",
  5769. value: function _adjustWidth() {
  5770. if (!this.opened) {
  5771. return;
  5772. }
  5773. this.bar.classList.remove("wrapContainers");
  5774. var findbarHeight = this.bar.clientHeight;
  5775. var inputContainerHeight = this.bar.firstElementChild.clientHeight;
  5776. if (findbarHeight > inputContainerHeight) {
  5777. this.bar.classList.add("wrapContainers");
  5778. }
  5779. }
  5780. }]);
  5781. return PDFFindBar;
  5782. }();
  5783. exports.PDFFindBar = PDFFindBar;
  5784. /***/ }),
  5785. /* 18 */
  5786. /***/ (function(module, exports, __webpack_require__) {
  5787. "use strict";
  5788. Object.defineProperty(exports, "__esModule", {
  5789. value: true
  5790. });
  5791. exports.PDFFindController = exports.FindState = void 0;
  5792. var _pdfjsLib = __webpack_require__(8);
  5793. var _pdf_find_utils = __webpack_require__(19);
  5794. var _ui_utils = __webpack_require__(5);
  5795. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  5796. 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); } }
  5797. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  5798. var FindState = {
  5799. FOUND: 0,
  5800. NOT_FOUND: 1,
  5801. WRAPPED: 2,
  5802. PENDING: 3
  5803. };
  5804. exports.FindState = FindState;
  5805. var FIND_TIMEOUT = 250;
  5806. var MATCH_SCROLL_OFFSET_TOP = -50;
  5807. var MATCH_SCROLL_OFFSET_LEFT = -400;
  5808. var CHARACTERS_TO_NORMALIZE = {
  5809. "\u2018": "'",
  5810. "\u2019": "'",
  5811. "\u201A": "'",
  5812. "\u201B": "'",
  5813. "\u201C": '"',
  5814. "\u201D": '"',
  5815. "\u201E": '"',
  5816. "\u201F": '"',
  5817. "\xBC": "1/4",
  5818. "\xBD": "1/2",
  5819. "\xBE": "3/4"
  5820. };
  5821. var normalizationRegex = null;
  5822. function normalize(text) {
  5823. if (!normalizationRegex) {
  5824. var replace = Object.keys(CHARACTERS_TO_NORMALIZE).join("");
  5825. normalizationRegex = new RegExp("[".concat(replace, "]"), "g");
  5826. }
  5827. return text.replace(normalizationRegex, function (ch) {
  5828. return CHARACTERS_TO_NORMALIZE[ch];
  5829. });
  5830. }
  5831. var PDFFindController = /*#__PURE__*/function () {
  5832. function PDFFindController(_ref) {
  5833. var linkService = _ref.linkService,
  5834. eventBus = _ref.eventBus;
  5835. _classCallCheck(this, PDFFindController);
  5836. this._linkService = linkService;
  5837. this._eventBus = eventBus;
  5838. this._reset();
  5839. eventBus._on("findbarclose", this._onFindBarClose.bind(this));
  5840. }
  5841. _createClass(PDFFindController, [{
  5842. key: "setDocument",
  5843. value: function setDocument(pdfDocument) {
  5844. if (this._pdfDocument) {
  5845. this._reset();
  5846. }
  5847. if (!pdfDocument) {
  5848. return;
  5849. }
  5850. this._pdfDocument = pdfDocument;
  5851. this._firstPageCapability.resolve();
  5852. }
  5853. }, {
  5854. key: "executeCommand",
  5855. value: function executeCommand(cmd, state) {
  5856. var _this = this;
  5857. if (!state) {
  5858. return;
  5859. }
  5860. var pdfDocument = this._pdfDocument;
  5861. if (this._state === null || this._shouldDirtyMatch(cmd, state)) {
  5862. this._dirtyMatch = true;
  5863. }
  5864. this._state = state;
  5865. if (cmd !== "findhighlightallchange") {
  5866. this._updateUIState(FindState.PENDING);
  5867. }
  5868. this._firstPageCapability.promise.then(function () {
  5869. if (!_this._pdfDocument || pdfDocument && _this._pdfDocument !== pdfDocument) {
  5870. return;
  5871. }
  5872. _this._extractText();
  5873. var findbarClosed = !_this._highlightMatches;
  5874. var pendingTimeout = !!_this._findTimeout;
  5875. if (_this._findTimeout) {
  5876. clearTimeout(_this._findTimeout);
  5877. _this._findTimeout = null;
  5878. }
  5879. if (cmd === "find") {
  5880. _this._findTimeout = setTimeout(function () {
  5881. _this._nextMatch();
  5882. _this._findTimeout = null;
  5883. }, FIND_TIMEOUT);
  5884. } else if (_this._dirtyMatch) {
  5885. _this._nextMatch();
  5886. } else if (cmd === "findagain") {
  5887. _this._nextMatch();
  5888. if (findbarClosed && _this._state.highlightAll) {
  5889. _this._updateAllPages();
  5890. }
  5891. } else if (cmd === "findhighlightallchange") {
  5892. if (pendingTimeout) {
  5893. _this._nextMatch();
  5894. } else {
  5895. _this._highlightMatches = true;
  5896. }
  5897. _this._updateAllPages();
  5898. } else {
  5899. _this._nextMatch();
  5900. }
  5901. });
  5902. }
  5903. }, {
  5904. key: "scrollMatchIntoView",
  5905. value: function scrollMatchIntoView(_ref2) {
  5906. var _ref2$element = _ref2.element,
  5907. element = _ref2$element === void 0 ? null : _ref2$element,
  5908. _ref2$pageIndex = _ref2.pageIndex,
  5909. pageIndex = _ref2$pageIndex === void 0 ? -1 : _ref2$pageIndex,
  5910. _ref2$matchIndex = _ref2.matchIndex,
  5911. matchIndex = _ref2$matchIndex === void 0 ? -1 : _ref2$matchIndex;
  5912. if (!this._scrollMatches || !element) {
  5913. return;
  5914. } else if (matchIndex === -1 || matchIndex !== this._selected.matchIdx) {
  5915. return;
  5916. } else if (pageIndex === -1 || pageIndex !== this._selected.pageIdx) {
  5917. return;
  5918. }
  5919. this._scrollMatches = false;
  5920. var spot = {
  5921. top: MATCH_SCROLL_OFFSET_TOP,
  5922. left: MATCH_SCROLL_OFFSET_LEFT
  5923. };
  5924. (0, _ui_utils.scrollIntoView)(element, spot, true);
  5925. }
  5926. }, {
  5927. key: "_reset",
  5928. value: function _reset() {
  5929. this._highlightMatches = false;
  5930. this._scrollMatches = false;
  5931. this._pdfDocument = null;
  5932. this._pageMatches = [];
  5933. this._pageMatchesLength = [];
  5934. this._state = null;
  5935. this._selected = {
  5936. pageIdx: -1,
  5937. matchIdx: -1
  5938. };
  5939. this._offset = {
  5940. pageIdx: null,
  5941. matchIdx: null,
  5942. wrapped: false
  5943. };
  5944. this._extractTextPromises = [];
  5945. this._pageContents = [];
  5946. this._matchesCountTotal = 0;
  5947. this._pagesToSearch = null;
  5948. this._pendingFindMatches = Object.create(null);
  5949. this._resumePageIdx = null;
  5950. this._dirtyMatch = false;
  5951. clearTimeout(this._findTimeout);
  5952. this._findTimeout = null;
  5953. this._firstPageCapability = (0, _pdfjsLib.createPromiseCapability)();
  5954. }
  5955. }, {
  5956. key: "_shouldDirtyMatch",
  5957. value: function _shouldDirtyMatch(cmd, state) {
  5958. if (state.query !== this._state.query) {
  5959. return true;
  5960. }
  5961. switch (cmd) {
  5962. case "findagain":
  5963. var pageNumber = this._selected.pageIdx + 1;
  5964. var linkService = this._linkService;
  5965. if (pageNumber >= 1 && pageNumber <= linkService.pagesCount && pageNumber !== linkService.page && !linkService.isPageVisible(pageNumber)) {
  5966. return true;
  5967. }
  5968. return false;
  5969. case "findhighlightallchange":
  5970. return false;
  5971. }
  5972. return true;
  5973. }
  5974. }, {
  5975. key: "_prepareMatches",
  5976. value: function _prepareMatches(matchesWithLength, matches, matchesLength) {
  5977. function isSubTerm(currentIndex) {
  5978. var currentElem = matchesWithLength[currentIndex];
  5979. var nextElem = matchesWithLength[currentIndex + 1];
  5980. if (currentIndex < matchesWithLength.length - 1 && currentElem.match === nextElem.match) {
  5981. currentElem.skipped = true;
  5982. return true;
  5983. }
  5984. for (var i = currentIndex - 1; i >= 0; i--) {
  5985. var prevElem = matchesWithLength[i];
  5986. if (prevElem.skipped) {
  5987. continue;
  5988. }
  5989. if (prevElem.match + prevElem.matchLength < currentElem.match) {
  5990. break;
  5991. }
  5992. if (prevElem.match + prevElem.matchLength >= currentElem.match + currentElem.matchLength) {
  5993. currentElem.skipped = true;
  5994. return true;
  5995. }
  5996. }
  5997. return false;
  5998. }
  5999. matchesWithLength.sort(function (a, b) {
  6000. return a.match === b.match ? a.matchLength - b.matchLength : a.match - b.match;
  6001. });
  6002. for (var i = 0, len = matchesWithLength.length; i < len; i++) {
  6003. if (isSubTerm(i)) {
  6004. continue;
  6005. }
  6006. matches.push(matchesWithLength[i].match);
  6007. matchesLength.push(matchesWithLength[i].matchLength);
  6008. }
  6009. }
  6010. }, {
  6011. key: "_isEntireWord",
  6012. value: function _isEntireWord(content, startIdx, length) {
  6013. if (startIdx > 0) {
  6014. var first = content.charCodeAt(startIdx);
  6015. var limit = content.charCodeAt(startIdx - 1);
  6016. if ((0, _pdf_find_utils.getCharacterType)(first) === (0, _pdf_find_utils.getCharacterType)(limit)) {
  6017. return false;
  6018. }
  6019. }
  6020. var endIdx = startIdx + length - 1;
  6021. if (endIdx < content.length - 1) {
  6022. var last = content.charCodeAt(endIdx);
  6023. var _limit = content.charCodeAt(endIdx + 1);
  6024. if ((0, _pdf_find_utils.getCharacterType)(last) === (0, _pdf_find_utils.getCharacterType)(_limit)) {
  6025. return false;
  6026. }
  6027. }
  6028. return true;
  6029. }
  6030. }, {
  6031. key: "_calculatePhraseMatch",
  6032. value: function _calculatePhraseMatch(query, pageIndex, pageContent, entireWord) {
  6033. var matches = [];
  6034. var queryLen = query.length;
  6035. var matchIdx = -queryLen;
  6036. while (true) {
  6037. matchIdx = pageContent.indexOf(query, matchIdx + queryLen);
  6038. if (matchIdx === -1) {
  6039. break;
  6040. }
  6041. if (entireWord && !this._isEntireWord(pageContent, matchIdx, queryLen)) {
  6042. continue;
  6043. }
  6044. matches.push(matchIdx);
  6045. }
  6046. this._pageMatches[pageIndex] = matches;
  6047. }
  6048. }, {
  6049. key: "_calculateWordMatch",
  6050. value: function _calculateWordMatch(query, pageIndex, pageContent, entireWord) {
  6051. var matchesWithLength = [];
  6052. var queryArray = query.match(/\S+/g);
  6053. for (var i = 0, len = queryArray.length; i < len; i++) {
  6054. var subquery = queryArray[i];
  6055. var subqueryLen = subquery.length;
  6056. var matchIdx = -subqueryLen;
  6057. while (true) {
  6058. matchIdx = pageContent.indexOf(subquery, matchIdx + subqueryLen);
  6059. if (matchIdx === -1) {
  6060. break;
  6061. }
  6062. if (entireWord && !this._isEntireWord(pageContent, matchIdx, subqueryLen)) {
  6063. continue;
  6064. }
  6065. matchesWithLength.push({
  6066. match: matchIdx,
  6067. matchLength: subqueryLen,
  6068. skipped: false
  6069. });
  6070. }
  6071. }
  6072. this._pageMatchesLength[pageIndex] = [];
  6073. this._pageMatches[pageIndex] = [];
  6074. this._prepareMatches(matchesWithLength, this._pageMatches[pageIndex], this._pageMatchesLength[pageIndex]);
  6075. }
  6076. }, {
  6077. key: "_calculateMatch",
  6078. value: function _calculateMatch(pageIndex) {
  6079. var pageContent = this._pageContents[pageIndex];
  6080. var query = this._query;
  6081. var _this$_state = this._state,
  6082. caseSensitive = _this$_state.caseSensitive,
  6083. entireWord = _this$_state.entireWord,
  6084. phraseSearch = _this$_state.phraseSearch;
  6085. if (query.length === 0) {
  6086. return;
  6087. }
  6088. if (!caseSensitive) {
  6089. pageContent = pageContent.toLowerCase();
  6090. query = query.toLowerCase();
  6091. }
  6092. if (phraseSearch) {
  6093. this._calculatePhraseMatch(query, pageIndex, pageContent, entireWord);
  6094. } else {
  6095. this._calculateWordMatch(query, pageIndex, pageContent, entireWord);
  6096. }
  6097. if (this._state.highlightAll) {
  6098. this._updatePage(pageIndex);
  6099. }
  6100. if (this._resumePageIdx === pageIndex) {
  6101. this._resumePageIdx = null;
  6102. this._nextPageMatch();
  6103. }
  6104. var pageMatchesCount = this._pageMatches[pageIndex].length;
  6105. if (pageMatchesCount > 0) {
  6106. this._matchesCountTotal += pageMatchesCount;
  6107. this._updateUIResultsCount();
  6108. }
  6109. }
  6110. }, {
  6111. key: "_extractText",
  6112. value: function _extractText() {
  6113. var _this2 = this;
  6114. if (this._extractTextPromises.length > 0) {
  6115. return;
  6116. }
  6117. var promise = Promise.resolve();
  6118. var _loop = function _loop(i, ii) {
  6119. var extractTextCapability = (0, _pdfjsLib.createPromiseCapability)();
  6120. _this2._extractTextPromises[i] = extractTextCapability.promise;
  6121. promise = promise.then(function () {
  6122. return _this2._pdfDocument.getPage(i + 1).then(function (pdfPage) {
  6123. return pdfPage.getTextContent({
  6124. normalizeWhitespace: true
  6125. });
  6126. }).then(function (textContent) {
  6127. var textItems = textContent.items;
  6128. var strBuf = [];
  6129. for (var j = 0, jj = textItems.length; j < jj; j++) {
  6130. strBuf.push(textItems[j].str);
  6131. }
  6132. _this2._pageContents[i] = normalize(strBuf.join(""));
  6133. extractTextCapability.resolve(i);
  6134. }, function (reason) {
  6135. console.error("Unable to get text content for page ".concat(i + 1), reason);
  6136. _this2._pageContents[i] = "";
  6137. extractTextCapability.resolve(i);
  6138. });
  6139. });
  6140. };
  6141. for (var i = 0, ii = this._linkService.pagesCount; i < ii; i++) {
  6142. _loop(i, ii);
  6143. }
  6144. }
  6145. }, {
  6146. key: "_updatePage",
  6147. value: function _updatePage(index) {
  6148. if (this._scrollMatches && this._selected.pageIdx === index) {
  6149. this._linkService.page = index + 1;
  6150. }
  6151. this._eventBus.dispatch("updatetextlayermatches", {
  6152. source: this,
  6153. pageIndex: index
  6154. });
  6155. }
  6156. }, {
  6157. key: "_updateAllPages",
  6158. value: function _updateAllPages() {
  6159. this._eventBus.dispatch("updatetextlayermatches", {
  6160. source: this,
  6161. pageIndex: -1
  6162. });
  6163. }
  6164. }, {
  6165. key: "_nextMatch",
  6166. value: function _nextMatch() {
  6167. var _this3 = this;
  6168. var previous = this._state.findPrevious;
  6169. var currentPageIndex = this._linkService.page - 1;
  6170. var numPages = this._linkService.pagesCount;
  6171. this._highlightMatches = true;
  6172. if (this._dirtyMatch) {
  6173. this._dirtyMatch = false;
  6174. this._selected.pageIdx = this._selected.matchIdx = -1;
  6175. this._offset.pageIdx = currentPageIndex;
  6176. this._offset.matchIdx = null;
  6177. this._offset.wrapped = false;
  6178. this._resumePageIdx = null;
  6179. this._pageMatches.length = 0;
  6180. this._pageMatchesLength.length = 0;
  6181. this._matchesCountTotal = 0;
  6182. this._updateAllPages();
  6183. for (var i = 0; i < numPages; i++) {
  6184. if (this._pendingFindMatches[i] === true) {
  6185. continue;
  6186. }
  6187. this._pendingFindMatches[i] = true;
  6188. this._extractTextPromises[i].then(function (pageIdx) {
  6189. delete _this3._pendingFindMatches[pageIdx];
  6190. _this3._calculateMatch(pageIdx);
  6191. });
  6192. }
  6193. }
  6194. if (this._query === "") {
  6195. this._updateUIState(FindState.FOUND);
  6196. return;
  6197. }
  6198. if (this._resumePageIdx) {
  6199. return;
  6200. }
  6201. var offset = this._offset;
  6202. this._pagesToSearch = numPages;
  6203. if (offset.matchIdx !== null) {
  6204. var numPageMatches = this._pageMatches[offset.pageIdx].length;
  6205. if (!previous && offset.matchIdx + 1 < numPageMatches || previous && offset.matchIdx > 0) {
  6206. offset.matchIdx = previous ? offset.matchIdx - 1 : offset.matchIdx + 1;
  6207. this._updateMatch(true);
  6208. return;
  6209. }
  6210. this._advanceOffsetPage(previous);
  6211. }
  6212. this._nextPageMatch();
  6213. }
  6214. }, {
  6215. key: "_matchesReady",
  6216. value: function _matchesReady(matches) {
  6217. var offset = this._offset;
  6218. var numMatches = matches.length;
  6219. var previous = this._state.findPrevious;
  6220. if (numMatches) {
  6221. offset.matchIdx = previous ? numMatches - 1 : 0;
  6222. this._updateMatch(true);
  6223. return true;
  6224. }
  6225. this._advanceOffsetPage(previous);
  6226. if (offset.wrapped) {
  6227. offset.matchIdx = null;
  6228. if (this._pagesToSearch < 0) {
  6229. this._updateMatch(false);
  6230. return true;
  6231. }
  6232. }
  6233. return false;
  6234. }
  6235. }, {
  6236. key: "_nextPageMatch",
  6237. value: function _nextPageMatch() {
  6238. if (this._resumePageIdx !== null) {
  6239. console.error("There can only be one pending page.");
  6240. }
  6241. var matches = null;
  6242. do {
  6243. var pageIdx = this._offset.pageIdx;
  6244. matches = this._pageMatches[pageIdx];
  6245. if (!matches) {
  6246. this._resumePageIdx = pageIdx;
  6247. break;
  6248. }
  6249. } while (!this._matchesReady(matches));
  6250. }
  6251. }, {
  6252. key: "_advanceOffsetPage",
  6253. value: function _advanceOffsetPage(previous) {
  6254. var offset = this._offset;
  6255. var numPages = this._linkService.pagesCount;
  6256. offset.pageIdx = previous ? offset.pageIdx - 1 : offset.pageIdx + 1;
  6257. offset.matchIdx = null;
  6258. this._pagesToSearch--;
  6259. if (offset.pageIdx >= numPages || offset.pageIdx < 0) {
  6260. offset.pageIdx = previous ? numPages - 1 : 0;
  6261. offset.wrapped = true;
  6262. }
  6263. }
  6264. }, {
  6265. key: "_updateMatch",
  6266. value: function _updateMatch() {
  6267. var found = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  6268. var state = FindState.NOT_FOUND;
  6269. var wrapped = this._offset.wrapped;
  6270. this._offset.wrapped = false;
  6271. if (found) {
  6272. var previousPage = this._selected.pageIdx;
  6273. this._selected.pageIdx = this._offset.pageIdx;
  6274. this._selected.matchIdx = this._offset.matchIdx;
  6275. state = wrapped ? FindState.WRAPPED : FindState.FOUND;
  6276. if (previousPage !== -1 && previousPage !== this._selected.pageIdx) {
  6277. this._updatePage(previousPage);
  6278. }
  6279. }
  6280. this._updateUIState(state, this._state.findPrevious);
  6281. if (this._selected.pageIdx !== -1) {
  6282. this._scrollMatches = true;
  6283. this._updatePage(this._selected.pageIdx);
  6284. }
  6285. }
  6286. }, {
  6287. key: "_onFindBarClose",
  6288. value: function _onFindBarClose(evt) {
  6289. var _this4 = this;
  6290. var pdfDocument = this._pdfDocument;
  6291. this._firstPageCapability.promise.then(function () {
  6292. if (!_this4._pdfDocument || pdfDocument && _this4._pdfDocument !== pdfDocument) {
  6293. return;
  6294. }
  6295. if (_this4._findTimeout) {
  6296. clearTimeout(_this4._findTimeout);
  6297. _this4._findTimeout = null;
  6298. }
  6299. if (_this4._resumePageIdx) {
  6300. _this4._resumePageIdx = null;
  6301. _this4._dirtyMatch = true;
  6302. }
  6303. _this4._updateUIState(FindState.FOUND);
  6304. _this4._highlightMatches = false;
  6305. _this4._updateAllPages();
  6306. });
  6307. }
  6308. }, {
  6309. key: "_requestMatchesCount",
  6310. value: function _requestMatchesCount() {
  6311. var _this$_selected = this._selected,
  6312. pageIdx = _this$_selected.pageIdx,
  6313. matchIdx = _this$_selected.matchIdx;
  6314. var current = 0,
  6315. total = this._matchesCountTotal;
  6316. if (matchIdx !== -1) {
  6317. for (var i = 0; i < pageIdx; i++) {
  6318. current += this._pageMatches[i] && this._pageMatches[i].length || 0;
  6319. }
  6320. current += matchIdx + 1;
  6321. }
  6322. if (current < 1 || current > total) {
  6323. current = total = 0;
  6324. }
  6325. return {
  6326. current: current,
  6327. total: total
  6328. };
  6329. }
  6330. }, {
  6331. key: "_updateUIResultsCount",
  6332. value: function _updateUIResultsCount() {
  6333. this._eventBus.dispatch("updatefindmatchescount", {
  6334. source: this,
  6335. matchesCount: this._requestMatchesCount()
  6336. });
  6337. }
  6338. }, {
  6339. key: "_updateUIState",
  6340. value: function _updateUIState(state, previous) {
  6341. this._eventBus.dispatch("updatefindcontrolstate", {
  6342. source: this,
  6343. state: state,
  6344. previous: previous,
  6345. matchesCount: this._requestMatchesCount()
  6346. });
  6347. }
  6348. }, {
  6349. key: "highlightMatches",
  6350. get: function get() {
  6351. return this._highlightMatches;
  6352. }
  6353. }, {
  6354. key: "pageMatches",
  6355. get: function get() {
  6356. return this._pageMatches;
  6357. }
  6358. }, {
  6359. key: "pageMatchesLength",
  6360. get: function get() {
  6361. return this._pageMatchesLength;
  6362. }
  6363. }, {
  6364. key: "selected",
  6365. get: function get() {
  6366. return this._selected;
  6367. }
  6368. }, {
  6369. key: "state",
  6370. get: function get() {
  6371. return this._state;
  6372. }
  6373. }, {
  6374. key: "_query",
  6375. get: function get() {
  6376. if (this._state.query !== this._rawQuery) {
  6377. this._rawQuery = this._state.query;
  6378. this._normalizedQuery = normalize(this._state.query);
  6379. }
  6380. return this._normalizedQuery;
  6381. }
  6382. }]);
  6383. return PDFFindController;
  6384. }();
  6385. exports.PDFFindController = PDFFindController;
  6386. /***/ }),
  6387. /* 19 */
  6388. /***/ (function(module, exports, __webpack_require__) {
  6389. "use strict";
  6390. Object.defineProperty(exports, "__esModule", {
  6391. value: true
  6392. });
  6393. exports.getCharacterType = getCharacterType;
  6394. exports.CharacterType = void 0;
  6395. var CharacterType = {
  6396. SPACE: 0,
  6397. ALPHA_LETTER: 1,
  6398. PUNCT: 2,
  6399. HAN_LETTER: 3,
  6400. KATAKANA_LETTER: 4,
  6401. HIRAGANA_LETTER: 5,
  6402. HALFWIDTH_KATAKANA_LETTER: 6,
  6403. THAI_LETTER: 7
  6404. };
  6405. exports.CharacterType = CharacterType;
  6406. function isAlphabeticalScript(charCode) {
  6407. return charCode < 0x2e80;
  6408. }
  6409. function isAscii(charCode) {
  6410. return (charCode & 0xff80) === 0;
  6411. }
  6412. function isAsciiAlpha(charCode) {
  6413. return charCode >= 0x61 && charCode <= 0x7a || charCode >= 0x41 && charCode <= 0x5a;
  6414. }
  6415. function isAsciiDigit(charCode) {
  6416. return charCode >= 0x30 && charCode <= 0x39;
  6417. }
  6418. function isAsciiSpace(charCode) {
  6419. return charCode === 0x20 || charCode === 0x09 || charCode === 0x0d || charCode === 0x0a;
  6420. }
  6421. function isHan(charCode) {
  6422. return charCode >= 0x3400 && charCode <= 0x9fff || charCode >= 0xf900 && charCode <= 0xfaff;
  6423. }
  6424. function isKatakana(charCode) {
  6425. return charCode >= 0x30a0 && charCode <= 0x30ff;
  6426. }
  6427. function isHiragana(charCode) {
  6428. return charCode >= 0x3040 && charCode <= 0x309f;
  6429. }
  6430. function isHalfwidthKatakana(charCode) {
  6431. return charCode >= 0xff60 && charCode <= 0xff9f;
  6432. }
  6433. function isThai(charCode) {
  6434. return (charCode & 0xff80) === 0x0e00;
  6435. }
  6436. function getCharacterType(charCode) {
  6437. if (isAlphabeticalScript(charCode)) {
  6438. if (isAscii(charCode)) {
  6439. if (isAsciiSpace(charCode)) {
  6440. return CharacterType.SPACE;
  6441. } else if (isAsciiAlpha(charCode) || isAsciiDigit(charCode) || charCode === 0x5f) {
  6442. return CharacterType.ALPHA_LETTER;
  6443. }
  6444. return CharacterType.PUNCT;
  6445. } else if (isThai(charCode)) {
  6446. return CharacterType.THAI_LETTER;
  6447. } else if (charCode === 0xa0) {
  6448. return CharacterType.SPACE;
  6449. }
  6450. return CharacterType.ALPHA_LETTER;
  6451. }
  6452. if (isHan(charCode)) {
  6453. return CharacterType.HAN_LETTER;
  6454. } else if (isKatakana(charCode)) {
  6455. return CharacterType.KATAKANA_LETTER;
  6456. } else if (isHiragana(charCode)) {
  6457. return CharacterType.HIRAGANA_LETTER;
  6458. } else if (isHalfwidthKatakana(charCode)) {
  6459. return CharacterType.HALFWIDTH_KATAKANA_LETTER;
  6460. }
  6461. return CharacterType.ALPHA_LETTER;
  6462. }
  6463. /***/ }),
  6464. /* 20 */
  6465. /***/ (function(module, exports, __webpack_require__) {
  6466. "use strict";
  6467. Object.defineProperty(exports, "__esModule", {
  6468. value: true
  6469. });
  6470. exports.isDestHashesEqual = isDestHashesEqual;
  6471. exports.isDestArraysEqual = isDestArraysEqual;
  6472. exports.PDFHistory = void 0;
  6473. var _ui_utils = __webpack_require__(5);
  6474. 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); }
  6475. function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
  6476. 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."); }
  6477. 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); }
  6478. 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; }
  6479. function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_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; }
  6480. function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
  6481. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  6482. 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); } }
  6483. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  6484. var HASH_CHANGE_TIMEOUT = 1000;
  6485. var POSITION_UPDATED_THRESHOLD = 50;
  6486. var UPDATE_VIEWAREA_TIMEOUT = 1000;
  6487. function getCurrentHash() {
  6488. return document.location.hash;
  6489. }
  6490. var PDFHistory = /*#__PURE__*/function () {
  6491. function PDFHistory(_ref) {
  6492. var _this = this;
  6493. var linkService = _ref.linkService,
  6494. eventBus = _ref.eventBus;
  6495. _classCallCheck(this, PDFHistory);
  6496. this.linkService = linkService;
  6497. this.eventBus = eventBus;
  6498. this._initialized = false;
  6499. this._fingerprint = "";
  6500. this.reset();
  6501. this._boundEvents = null;
  6502. this._isViewerInPresentationMode = false;
  6503. this.eventBus._on("presentationmodechanged", function (evt) {
  6504. _this._isViewerInPresentationMode = evt.active || evt.switchInProgress;
  6505. });
  6506. this.eventBus._on("pagesinit", function () {
  6507. _this._isPagesLoaded = false;
  6508. var onPagesLoaded = function onPagesLoaded(evt) {
  6509. _this.eventBus._off("pagesloaded", onPagesLoaded);
  6510. _this._isPagesLoaded = !!evt.pagesCount;
  6511. };
  6512. _this.eventBus._on("pagesloaded", onPagesLoaded);
  6513. });
  6514. }
  6515. _createClass(PDFHistory, [{
  6516. key: "initialize",
  6517. value: function initialize(_ref2) {
  6518. var fingerprint = _ref2.fingerprint,
  6519. _ref2$resetHistory = _ref2.resetHistory,
  6520. resetHistory = _ref2$resetHistory === void 0 ? false : _ref2$resetHistory,
  6521. _ref2$updateUrl = _ref2.updateUrl,
  6522. updateUrl = _ref2$updateUrl === void 0 ? false : _ref2$updateUrl;
  6523. if (!fingerprint || typeof fingerprint !== "string") {
  6524. console.error('PDFHistory.initialize: The "fingerprint" must be a non-empty string.');
  6525. return;
  6526. }
  6527. if (this._initialized) {
  6528. this.reset();
  6529. }
  6530. var reInitialized = this._fingerprint !== "" && this._fingerprint !== fingerprint;
  6531. this._fingerprint = fingerprint;
  6532. this._updateUrl = updateUrl === true;
  6533. this._initialized = true;
  6534. this._bindEvents();
  6535. var state = window.history.state;
  6536. this._popStateInProgress = false;
  6537. this._blockHashChange = 0;
  6538. this._currentHash = getCurrentHash();
  6539. this._numPositionUpdates = 0;
  6540. this._uid = this._maxUid = 0;
  6541. this._destination = null;
  6542. this._position = null;
  6543. if (!this._isValidState(state, true) || resetHistory) {
  6544. var _this$_parseCurrentHa = this._parseCurrentHash(true),
  6545. hash = _this$_parseCurrentHa.hash,
  6546. page = _this$_parseCurrentHa.page,
  6547. rotation = _this$_parseCurrentHa.rotation;
  6548. if (!hash || reInitialized || resetHistory) {
  6549. this._pushOrReplaceState(null, true);
  6550. return;
  6551. }
  6552. this._pushOrReplaceState({
  6553. hash: hash,
  6554. page: page,
  6555. rotation: rotation
  6556. }, true);
  6557. return;
  6558. }
  6559. var destination = state.destination;
  6560. this._updateInternalState(destination, state.uid, true);
  6561. if (this._uid > this._maxUid) {
  6562. this._maxUid = this._uid;
  6563. }
  6564. if (destination.rotation !== undefined) {
  6565. this._initialRotation = destination.rotation;
  6566. }
  6567. if (destination.dest) {
  6568. this._initialBookmark = JSON.stringify(destination.dest);
  6569. this._destination.page = null;
  6570. } else if (destination.hash) {
  6571. this._initialBookmark = destination.hash;
  6572. } else if (destination.page) {
  6573. this._initialBookmark = "page=".concat(destination.page);
  6574. }
  6575. }
  6576. }, {
  6577. key: "reset",
  6578. value: function reset() {
  6579. if (this._initialized) {
  6580. this._pageHide();
  6581. this._initialized = false;
  6582. this._unbindEvents();
  6583. }
  6584. if (this._updateViewareaTimeout) {
  6585. clearTimeout(this._updateViewareaTimeout);
  6586. this._updateViewareaTimeout = null;
  6587. }
  6588. this._initialBookmark = null;
  6589. this._initialRotation = null;
  6590. }
  6591. }, {
  6592. key: "push",
  6593. value: function push(_ref3) {
  6594. var _this2 = this;
  6595. var _ref3$namedDest = _ref3.namedDest,
  6596. namedDest = _ref3$namedDest === void 0 ? null : _ref3$namedDest,
  6597. explicitDest = _ref3.explicitDest,
  6598. pageNumber = _ref3.pageNumber;
  6599. if (!this._initialized) {
  6600. return;
  6601. }
  6602. if (namedDest && typeof namedDest !== "string") {
  6603. console.error("PDFHistory.push: " + "\"".concat(namedDest, "\" is not a valid namedDest parameter."));
  6604. return;
  6605. } else if (!Array.isArray(explicitDest)) {
  6606. console.error("PDFHistory.push: " + "\"".concat(explicitDest, "\" is not a valid explicitDest parameter."));
  6607. return;
  6608. } else if (!(Number.isInteger(pageNumber) && pageNumber > 0 && pageNumber <= this.linkService.pagesCount)) {
  6609. if (pageNumber !== null || this._destination) {
  6610. console.error("PDFHistory.push: " + "\"".concat(pageNumber, "\" is not a valid pageNumber parameter."));
  6611. return;
  6612. }
  6613. }
  6614. var hash = namedDest || JSON.stringify(explicitDest);
  6615. if (!hash) {
  6616. return;
  6617. }
  6618. var forceReplace = false;
  6619. if (this._destination && (isDestHashesEqual(this._destination.hash, hash) || isDestArraysEqual(this._destination.dest, explicitDest))) {
  6620. if (this._destination.page) {
  6621. return;
  6622. }
  6623. forceReplace = true;
  6624. }
  6625. if (this._popStateInProgress && !forceReplace) {
  6626. return;
  6627. }
  6628. this._pushOrReplaceState({
  6629. dest: explicitDest,
  6630. hash: hash,
  6631. page: pageNumber,
  6632. rotation: this.linkService.rotation
  6633. }, forceReplace);
  6634. if (!this._popStateInProgress) {
  6635. this._popStateInProgress = true;
  6636. Promise.resolve().then(function () {
  6637. _this2._popStateInProgress = false;
  6638. });
  6639. }
  6640. }
  6641. }, {
  6642. key: "pushCurrentPosition",
  6643. value: function pushCurrentPosition() {
  6644. if (!this._initialized || this._popStateInProgress) {
  6645. return;
  6646. }
  6647. this._tryPushCurrentPosition();
  6648. }
  6649. }, {
  6650. key: "back",
  6651. value: function back() {
  6652. if (!this._initialized || this._popStateInProgress) {
  6653. return;
  6654. }
  6655. var state = window.history.state;
  6656. if (this._isValidState(state) && state.uid > 0) {
  6657. window.history.back();
  6658. }
  6659. }
  6660. }, {
  6661. key: "forward",
  6662. value: function forward() {
  6663. if (!this._initialized || this._popStateInProgress) {
  6664. return;
  6665. }
  6666. var state = window.history.state;
  6667. if (this._isValidState(state) && state.uid < this._maxUid) {
  6668. window.history.forward();
  6669. }
  6670. }
  6671. }, {
  6672. key: "_pushOrReplaceState",
  6673. value: function _pushOrReplaceState(destination) {
  6674. var forceReplace = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  6675. var shouldReplace = forceReplace || !this._destination;
  6676. var newState = {
  6677. fingerprint: this._fingerprint,
  6678. uid: shouldReplace ? this._uid : this._uid + 1,
  6679. destination: destination
  6680. };
  6681. this._updateInternalState(destination, newState.uid);
  6682. var newUrl;
  6683. if (this._updateUrl && destination && destination.hash) {
  6684. var baseUrl = document.location.href.split("#")[0];
  6685. if (!baseUrl.startsWith("file://")) {
  6686. newUrl = "".concat(baseUrl, "#").concat(destination.hash);
  6687. }
  6688. }
  6689. if (shouldReplace) {
  6690. window.history.replaceState(newState, "", newUrl);
  6691. } else {
  6692. this._maxUid = this._uid;
  6693. window.history.pushState(newState, "", newUrl);
  6694. }
  6695. }
  6696. }, {
  6697. key: "_tryPushCurrentPosition",
  6698. value: function _tryPushCurrentPosition() {
  6699. var temporary = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  6700. if (!this._position) {
  6701. return;
  6702. }
  6703. var position = this._position;
  6704. if (temporary) {
  6705. position = Object.assign(Object.create(null), this._position);
  6706. position.temporary = true;
  6707. }
  6708. if (!this._destination) {
  6709. this._pushOrReplaceState(position);
  6710. return;
  6711. }
  6712. if (this._destination.temporary) {
  6713. this._pushOrReplaceState(position, true);
  6714. return;
  6715. }
  6716. if (this._destination.hash === position.hash) {
  6717. return;
  6718. }
  6719. if (!this._destination.page && (POSITION_UPDATED_THRESHOLD <= 0 || this._numPositionUpdates <= POSITION_UPDATED_THRESHOLD)) {
  6720. return;
  6721. }
  6722. var forceReplace = false;
  6723. if (this._destination.page >= position.first && this._destination.page <= position.page) {
  6724. if (this._destination.dest || !this._destination.first) {
  6725. return;
  6726. }
  6727. forceReplace = true;
  6728. }
  6729. this._pushOrReplaceState(position, forceReplace);
  6730. }
  6731. }, {
  6732. key: "_isValidState",
  6733. value: function _isValidState(state) {
  6734. var checkReload = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  6735. if (!state) {
  6736. return false;
  6737. }
  6738. if (state.fingerprint !== this._fingerprint) {
  6739. if (checkReload) {
  6740. if (typeof state.fingerprint !== "string" || state.fingerprint.length !== this._fingerprint.length) {
  6741. return false;
  6742. }
  6743. var _performance$getEntri = performance.getEntriesByType("navigation"),
  6744. _performance$getEntri2 = _slicedToArray(_performance$getEntri, 1),
  6745. perfEntry = _performance$getEntri2[0];
  6746. if (!perfEntry || perfEntry.type !== "reload") {
  6747. return false;
  6748. }
  6749. } else {
  6750. return false;
  6751. }
  6752. }
  6753. if (!Number.isInteger(state.uid) || state.uid < 0) {
  6754. return false;
  6755. }
  6756. if (state.destination === null || _typeof(state.destination) !== "object") {
  6757. return false;
  6758. }
  6759. return true;
  6760. }
  6761. }, {
  6762. key: "_updateInternalState",
  6763. value: function _updateInternalState(destination, uid) {
  6764. var removeTemporary = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  6765. if (this._updateViewareaTimeout) {
  6766. clearTimeout(this._updateViewareaTimeout);
  6767. this._updateViewareaTimeout = null;
  6768. }
  6769. if (removeTemporary && destination && destination.temporary) {
  6770. delete destination.temporary;
  6771. }
  6772. this._destination = destination;
  6773. this._uid = uid;
  6774. this._numPositionUpdates = 0;
  6775. }
  6776. }, {
  6777. key: "_parseCurrentHash",
  6778. value: function _parseCurrentHash() {
  6779. var checkNameddest = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  6780. var hash = unescape(getCurrentHash()).substring(1);
  6781. var params = (0, _ui_utils.parseQueryString)(hash);
  6782. var nameddest = params.nameddest || "";
  6783. var page = params.page | 0;
  6784. if (!(Number.isInteger(page) && page > 0 && page <= this.linkService.pagesCount) || checkNameddest && nameddest.length > 0) {
  6785. page = null;
  6786. }
  6787. return {
  6788. hash: hash,
  6789. page: page,
  6790. rotation: this.linkService.rotation
  6791. };
  6792. }
  6793. }, {
  6794. key: "_updateViewarea",
  6795. value: function _updateViewarea(_ref4) {
  6796. var _this3 = this;
  6797. var location = _ref4.location;
  6798. if (this._updateViewareaTimeout) {
  6799. clearTimeout(this._updateViewareaTimeout);
  6800. this._updateViewareaTimeout = null;
  6801. }
  6802. this._position = {
  6803. hash: this._isViewerInPresentationMode ? "page=".concat(location.pageNumber) : location.pdfOpenParams.substring(1),
  6804. page: this.linkService.page,
  6805. first: location.pageNumber,
  6806. rotation: location.rotation
  6807. };
  6808. if (this._popStateInProgress) {
  6809. return;
  6810. }
  6811. if (POSITION_UPDATED_THRESHOLD > 0 && this._isPagesLoaded && this._destination && !this._destination.page) {
  6812. this._numPositionUpdates++;
  6813. }
  6814. if (UPDATE_VIEWAREA_TIMEOUT > 0) {
  6815. this._updateViewareaTimeout = setTimeout(function () {
  6816. if (!_this3._popStateInProgress) {
  6817. _this3._tryPushCurrentPosition(true);
  6818. }
  6819. _this3._updateViewareaTimeout = null;
  6820. }, UPDATE_VIEWAREA_TIMEOUT);
  6821. }
  6822. }
  6823. }, {
  6824. key: "_popState",
  6825. value: function _popState(_ref5) {
  6826. var _this4 = this;
  6827. var state = _ref5.state;
  6828. var newHash = getCurrentHash(),
  6829. hashChanged = this._currentHash !== newHash;
  6830. this._currentHash = newHash;
  6831. if (!state) {
  6832. this._uid++;
  6833. var _this$_parseCurrentHa2 = this._parseCurrentHash(),
  6834. hash = _this$_parseCurrentHa2.hash,
  6835. page = _this$_parseCurrentHa2.page,
  6836. rotation = _this$_parseCurrentHa2.rotation;
  6837. this._pushOrReplaceState({
  6838. hash: hash,
  6839. page: page,
  6840. rotation: rotation
  6841. }, true);
  6842. return;
  6843. }
  6844. if (!this._isValidState(state)) {
  6845. return;
  6846. }
  6847. this._popStateInProgress = true;
  6848. if (hashChanged) {
  6849. this._blockHashChange++;
  6850. (0, _ui_utils.waitOnEventOrTimeout)({
  6851. target: window,
  6852. name: "hashchange",
  6853. delay: HASH_CHANGE_TIMEOUT
  6854. }).then(function () {
  6855. _this4._blockHashChange--;
  6856. });
  6857. }
  6858. var destination = state.destination;
  6859. this._updateInternalState(destination, state.uid, true);
  6860. if (this._uid > this._maxUid) {
  6861. this._maxUid = this._uid;
  6862. }
  6863. if ((0, _ui_utils.isValidRotation)(destination.rotation)) {
  6864. this.linkService.rotation = destination.rotation;
  6865. }
  6866. if (destination.dest) {
  6867. this.linkService.navigateTo(destination.dest);
  6868. } else if (destination.hash) {
  6869. this.linkService.setHash(destination.hash);
  6870. } else if (destination.page) {
  6871. this.linkService.page = destination.page;
  6872. }
  6873. Promise.resolve().then(function () {
  6874. _this4._popStateInProgress = false;
  6875. });
  6876. }
  6877. }, {
  6878. key: "_pageHide",
  6879. value: function _pageHide() {
  6880. if (!this._destination || this._destination.temporary) {
  6881. this._tryPushCurrentPosition();
  6882. }
  6883. }
  6884. }, {
  6885. key: "_bindEvents",
  6886. value: function _bindEvents() {
  6887. if (this._boundEvents) {
  6888. return;
  6889. }
  6890. this._boundEvents = {
  6891. updateViewarea: this._updateViewarea.bind(this),
  6892. popState: this._popState.bind(this),
  6893. pageHide: this._pageHide.bind(this)
  6894. };
  6895. this.eventBus._on("updateviewarea", this._boundEvents.updateViewarea);
  6896. window.addEventListener("popstate", this._boundEvents.popState);
  6897. window.addEventListener("pagehide", this._boundEvents.pageHide);
  6898. }
  6899. }, {
  6900. key: "_unbindEvents",
  6901. value: function _unbindEvents() {
  6902. if (!this._boundEvents) {
  6903. return;
  6904. }
  6905. this.eventBus._off("updateviewarea", this._boundEvents.updateViewarea);
  6906. window.removeEventListener("popstate", this._boundEvents.popState);
  6907. window.removeEventListener("pagehide", this._boundEvents.pageHide);
  6908. this._boundEvents = null;
  6909. }
  6910. }, {
  6911. key: "popStateInProgress",
  6912. get: function get() {
  6913. return this._initialized && (this._popStateInProgress || this._blockHashChange > 0);
  6914. }
  6915. }, {
  6916. key: "initialBookmark",
  6917. get: function get() {
  6918. return this._initialized ? this._initialBookmark : null;
  6919. }
  6920. }, {
  6921. key: "initialRotation",
  6922. get: function get() {
  6923. return this._initialized ? this._initialRotation : null;
  6924. }
  6925. }]);
  6926. return PDFHistory;
  6927. }();
  6928. exports.PDFHistory = PDFHistory;
  6929. function isDestHashesEqual(destHash, pushHash) {
  6930. if (typeof destHash !== "string" || typeof pushHash !== "string") {
  6931. return false;
  6932. }
  6933. if (destHash === pushHash) {
  6934. return true;
  6935. }
  6936. var _parseQueryString = (0, _ui_utils.parseQueryString)(destHash),
  6937. nameddest = _parseQueryString.nameddest;
  6938. if (nameddest === pushHash) {
  6939. return true;
  6940. }
  6941. return false;
  6942. }
  6943. function isDestArraysEqual(firstDest, secondDest) {
  6944. function isEntryEqual(first, second) {
  6945. if (_typeof(first) !== _typeof(second)) {
  6946. return false;
  6947. }
  6948. if (Array.isArray(first) || Array.isArray(second)) {
  6949. return false;
  6950. }
  6951. if (first !== null && _typeof(first) === "object" && second !== null) {
  6952. if (Object.keys(first).length !== Object.keys(second).length) {
  6953. return false;
  6954. }
  6955. for (var key in first) {
  6956. if (!isEntryEqual(first[key], second[key])) {
  6957. return false;
  6958. }
  6959. }
  6960. return true;
  6961. }
  6962. return first === second || Number.isNaN(first) && Number.isNaN(second);
  6963. }
  6964. if (!(Array.isArray(firstDest) && Array.isArray(secondDest))) {
  6965. return false;
  6966. }
  6967. if (firstDest.length !== secondDest.length) {
  6968. return false;
  6969. }
  6970. for (var i = 0, ii = firstDest.length; i < ii; i++) {
  6971. if (!isEntryEqual(firstDest[i], secondDest[i])) {
  6972. return false;
  6973. }
  6974. }
  6975. return true;
  6976. }
  6977. /***/ }),
  6978. /* 21 */
  6979. /***/ (function(module, exports, __webpack_require__) {
  6980. "use strict";
  6981. Object.defineProperty(exports, "__esModule", {
  6982. value: true
  6983. });
  6984. exports.SimpleLinkService = exports.PDFLinkService = void 0;
  6985. var _ui_utils = __webpack_require__(5);
  6986. 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); }
  6987. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  6988. 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); } }
  6989. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  6990. var PDFLinkService = /*#__PURE__*/function () {
  6991. function PDFLinkService() {
  6992. var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
  6993. eventBus = _ref.eventBus,
  6994. _ref$externalLinkTarg = _ref.externalLinkTarget,
  6995. externalLinkTarget = _ref$externalLinkTarg === void 0 ? null : _ref$externalLinkTarg,
  6996. _ref$externalLinkRel = _ref.externalLinkRel,
  6997. externalLinkRel = _ref$externalLinkRel === void 0 ? null : _ref$externalLinkRel,
  6998. _ref$externalLinkEnab = _ref.externalLinkEnabled,
  6999. externalLinkEnabled = _ref$externalLinkEnab === void 0 ? true : _ref$externalLinkEnab,
  7000. _ref$ignoreDestinatio = _ref.ignoreDestinationZoom,
  7001. ignoreDestinationZoom = _ref$ignoreDestinatio === void 0 ? false : _ref$ignoreDestinatio;
  7002. _classCallCheck(this, PDFLinkService);
  7003. this.eventBus = eventBus;
  7004. this.externalLinkTarget = externalLinkTarget;
  7005. this.externalLinkRel = externalLinkRel;
  7006. this.externalLinkEnabled = externalLinkEnabled;
  7007. this._ignoreDestinationZoom = ignoreDestinationZoom;
  7008. this.baseUrl = null;
  7009. this.pdfDocument = null;
  7010. this.pdfViewer = null;
  7011. this.pdfHistory = null;
  7012. this._pagesRefCache = null;
  7013. }
  7014. _createClass(PDFLinkService, [{
  7015. key: "setDocument",
  7016. value: function setDocument(pdfDocument) {
  7017. var baseUrl = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  7018. this.baseUrl = baseUrl;
  7019. this.pdfDocument = pdfDocument;
  7020. this._pagesRefCache = Object.create(null);
  7021. }
  7022. }, {
  7023. key: "setViewer",
  7024. value: function setViewer(pdfViewer) {
  7025. this.pdfViewer = pdfViewer;
  7026. }
  7027. }, {
  7028. key: "setHistory",
  7029. value: function setHistory(pdfHistory) {
  7030. this.pdfHistory = pdfHistory;
  7031. }
  7032. }, {
  7033. key: "navigateTo",
  7034. value: function navigateTo(dest) {
  7035. var _this = this;
  7036. var goToDestination = function goToDestination(_ref2) {
  7037. var namedDest = _ref2.namedDest,
  7038. explicitDest = _ref2.explicitDest;
  7039. var destRef = explicitDest[0];
  7040. var pageNumber;
  7041. if (destRef instanceof Object) {
  7042. pageNumber = _this._cachedPageNumber(destRef);
  7043. if (pageNumber === null) {
  7044. _this.pdfDocument.getPageIndex(destRef).then(function (pageIndex) {
  7045. _this.cachePageRef(pageIndex + 1, destRef);
  7046. goToDestination({
  7047. namedDest: namedDest,
  7048. explicitDest: explicitDest
  7049. });
  7050. })["catch"](function () {
  7051. console.error("PDFLinkService.navigateTo: \"".concat(destRef, "\" is not ") + "a valid page reference, for dest=\"".concat(dest, "\"."));
  7052. });
  7053. return;
  7054. }
  7055. } else if (Number.isInteger(destRef)) {
  7056. pageNumber = destRef + 1;
  7057. } else {
  7058. console.error("PDFLinkService.navigateTo: \"".concat(destRef, "\" is not ") + "a valid destination reference, for dest=\"".concat(dest, "\"."));
  7059. return;
  7060. }
  7061. if (!pageNumber || pageNumber < 1 || pageNumber > _this.pagesCount) {
  7062. console.error("PDFLinkService.navigateTo: \"".concat(pageNumber, "\" is not ") + "a valid page number, for dest=\"".concat(dest, "\"."));
  7063. return;
  7064. }
  7065. if (_this.pdfHistory) {
  7066. _this.pdfHistory.pushCurrentPosition();
  7067. _this.pdfHistory.push({
  7068. namedDest: namedDest,
  7069. explicitDest: explicitDest,
  7070. pageNumber: pageNumber
  7071. });
  7072. }
  7073. _this.pdfViewer.scrollPageIntoView({
  7074. pageNumber: pageNumber,
  7075. destArray: explicitDest,
  7076. ignoreDestinationZoom: _this._ignoreDestinationZoom
  7077. });
  7078. };
  7079. new Promise(function (resolve, reject) {
  7080. if (typeof dest === "string") {
  7081. _this.pdfDocument.getDestination(dest).then(function (destArray) {
  7082. resolve({
  7083. namedDest: dest,
  7084. explicitDest: destArray
  7085. });
  7086. });
  7087. return;
  7088. }
  7089. resolve({
  7090. namedDest: "",
  7091. explicitDest: dest
  7092. });
  7093. }).then(function (data) {
  7094. if (!Array.isArray(data.explicitDest)) {
  7095. console.error("PDFLinkService.navigateTo: \"".concat(data.explicitDest, "\" is") + " not a valid destination array, for dest=\"".concat(dest, "\"."));
  7096. return;
  7097. }
  7098. goToDestination(data);
  7099. });
  7100. }
  7101. }, {
  7102. key: "getDestinationHash",
  7103. value: function getDestinationHash(dest) {
  7104. if (typeof dest === "string") {
  7105. return this.getAnchorUrl("#" + escape(dest));
  7106. }
  7107. if (Array.isArray(dest)) {
  7108. var str = JSON.stringify(dest);
  7109. return this.getAnchorUrl("#" + escape(str));
  7110. }
  7111. return this.getAnchorUrl("");
  7112. }
  7113. }, {
  7114. key: "getAnchorUrl",
  7115. value: function getAnchorUrl(anchor) {
  7116. return (this.baseUrl || "") + anchor;
  7117. }
  7118. }, {
  7119. key: "setHash",
  7120. value: function setHash(hash) {
  7121. var pageNumber, dest;
  7122. if (hash.includes("=")) {
  7123. var params = (0, _ui_utils.parseQueryString)(hash);
  7124. if ("search" in params) {
  7125. this.eventBus.dispatch("findfromurlhash", {
  7126. source: this,
  7127. query: params.search.replace(/"/g, ""),
  7128. phraseSearch: params.phrase === "true"
  7129. });
  7130. }
  7131. if ("page" in params) {
  7132. pageNumber = params.page | 0 || 1;
  7133. }
  7134. if ("zoom" in params) {
  7135. var zoomArgs = params.zoom.split(",");
  7136. var zoomArg = zoomArgs[0];
  7137. var zoomArgNumber = parseFloat(zoomArg);
  7138. if (!zoomArg.includes("Fit")) {
  7139. dest = [null, {
  7140. name: "XYZ"
  7141. }, zoomArgs.length > 1 ? zoomArgs[1] | 0 : null, zoomArgs.length > 2 ? zoomArgs[2] | 0 : null, zoomArgNumber ? zoomArgNumber / 100 : zoomArg];
  7142. } else {
  7143. if (zoomArg === "Fit" || zoomArg === "FitB") {
  7144. dest = [null, {
  7145. name: zoomArg
  7146. }];
  7147. } else if (zoomArg === "FitH" || zoomArg === "FitBH" || zoomArg === "FitV" || zoomArg === "FitBV") {
  7148. dest = [null, {
  7149. name: zoomArg
  7150. }, zoomArgs.length > 1 ? zoomArgs[1] | 0 : null];
  7151. } else if (zoomArg === "FitR") {
  7152. if (zoomArgs.length !== 5) {
  7153. console.error('PDFLinkService.setHash: Not enough parameters for "FitR".');
  7154. } else {
  7155. dest = [null, {
  7156. name: zoomArg
  7157. }, zoomArgs[1] | 0, zoomArgs[2] | 0, zoomArgs[3] | 0, zoomArgs[4] | 0];
  7158. }
  7159. } else {
  7160. console.error("PDFLinkService.setHash: \"".concat(zoomArg, "\" is not ") + "a valid zoom value.");
  7161. }
  7162. }
  7163. }
  7164. if (dest) {
  7165. this.pdfViewer.scrollPageIntoView({
  7166. pageNumber: pageNumber || this.page,
  7167. destArray: dest,
  7168. allowNegativeOffset: true
  7169. });
  7170. } else if (pageNumber) {
  7171. this.page = pageNumber;
  7172. }
  7173. if ("pagemode" in params) {
  7174. this.eventBus.dispatch("pagemode", {
  7175. source: this,
  7176. mode: params.pagemode
  7177. });
  7178. }
  7179. if ("nameddest" in params) {
  7180. this.navigateTo(params.nameddest);
  7181. }
  7182. } else {
  7183. dest = unescape(hash);
  7184. try {
  7185. dest = JSON.parse(dest);
  7186. if (!Array.isArray(dest)) {
  7187. dest = dest.toString();
  7188. }
  7189. } catch (ex) {}
  7190. if (typeof dest === "string" || isValidExplicitDestination(dest)) {
  7191. this.navigateTo(dest);
  7192. return;
  7193. }
  7194. console.error("PDFLinkService.setHash: \"".concat(unescape(hash), "\" is not ") + "a valid destination.");
  7195. }
  7196. }
  7197. }, {
  7198. key: "executeNamedAction",
  7199. value: function executeNamedAction(action) {
  7200. switch (action) {
  7201. case "GoBack":
  7202. if (this.pdfHistory) {
  7203. this.pdfHistory.back();
  7204. }
  7205. break;
  7206. case "GoForward":
  7207. if (this.pdfHistory) {
  7208. this.pdfHistory.forward();
  7209. }
  7210. break;
  7211. case "NextPage":
  7212. if (this.page < this.pagesCount) {
  7213. this.page++;
  7214. }
  7215. break;
  7216. case "PrevPage":
  7217. if (this.page > 1) {
  7218. this.page--;
  7219. }
  7220. break;
  7221. case "LastPage":
  7222. this.page = this.pagesCount;
  7223. break;
  7224. case "FirstPage":
  7225. this.page = 1;
  7226. break;
  7227. default:
  7228. break;
  7229. }
  7230. this.eventBus.dispatch("namedaction", {
  7231. source: this,
  7232. action: action
  7233. });
  7234. }
  7235. }, {
  7236. key: "cachePageRef",
  7237. value: function cachePageRef(pageNum, pageRef) {
  7238. if (!pageRef) {
  7239. return;
  7240. }
  7241. var refStr = pageRef.gen === 0 ? "".concat(pageRef.num, "R") : "".concat(pageRef.num, "R").concat(pageRef.gen);
  7242. this._pagesRefCache[refStr] = pageNum;
  7243. }
  7244. }, {
  7245. key: "_cachedPageNumber",
  7246. value: function _cachedPageNumber(pageRef) {
  7247. var refStr = pageRef.gen === 0 ? "".concat(pageRef.num, "R") : "".concat(pageRef.num, "R").concat(pageRef.gen);
  7248. return this._pagesRefCache && this._pagesRefCache[refStr] || null;
  7249. }
  7250. }, {
  7251. key: "isPageVisible",
  7252. value: function isPageVisible(pageNumber) {
  7253. return this.pdfViewer.isPageVisible(pageNumber);
  7254. }
  7255. }, {
  7256. key: "pagesCount",
  7257. get: function get() {
  7258. return this.pdfDocument ? this.pdfDocument.numPages : 0;
  7259. }
  7260. }, {
  7261. key: "page",
  7262. get: function get() {
  7263. return this.pdfViewer.currentPageNumber;
  7264. },
  7265. set: function set(value) {
  7266. this.pdfViewer.currentPageNumber = value;
  7267. }
  7268. }, {
  7269. key: "rotation",
  7270. get: function get() {
  7271. return this.pdfViewer.pagesRotation;
  7272. },
  7273. set: function set(value) {
  7274. this.pdfViewer.pagesRotation = value;
  7275. }
  7276. }]);
  7277. return PDFLinkService;
  7278. }();
  7279. exports.PDFLinkService = PDFLinkService;
  7280. function isValidExplicitDestination(dest) {
  7281. if (!Array.isArray(dest)) {
  7282. return false;
  7283. }
  7284. var destLength = dest.length;
  7285. if (destLength < 2) {
  7286. return false;
  7287. }
  7288. var page = dest[0];
  7289. if (!(_typeof(page) === "object" && Number.isInteger(page.num) && Number.isInteger(page.gen)) && !(Number.isInteger(page) && page >= 0)) {
  7290. return false;
  7291. }
  7292. var zoom = dest[1];
  7293. if (!(_typeof(zoom) === "object" && typeof zoom.name === "string")) {
  7294. return false;
  7295. }
  7296. var allowNull = true;
  7297. switch (zoom.name) {
  7298. case "XYZ":
  7299. if (destLength !== 5) {
  7300. return false;
  7301. }
  7302. break;
  7303. case "Fit":
  7304. case "FitB":
  7305. return destLength === 2;
  7306. case "FitH":
  7307. case "FitBH":
  7308. case "FitV":
  7309. case "FitBV":
  7310. if (destLength !== 3) {
  7311. return false;
  7312. }
  7313. break;
  7314. case "FitR":
  7315. if (destLength !== 6) {
  7316. return false;
  7317. }
  7318. allowNull = false;
  7319. break;
  7320. default:
  7321. return false;
  7322. }
  7323. for (var i = 2; i < destLength; i++) {
  7324. var param = dest[i];
  7325. if (!(typeof param === "number" || allowNull && param === null)) {
  7326. return false;
  7327. }
  7328. }
  7329. return true;
  7330. }
  7331. var SimpleLinkService = /*#__PURE__*/function () {
  7332. function SimpleLinkService() {
  7333. _classCallCheck(this, SimpleLinkService);
  7334. this.externalLinkTarget = null;
  7335. this.externalLinkRel = null;
  7336. this.externalLinkEnabled = true;
  7337. this._ignoreDestinationZoom = false;
  7338. }
  7339. _createClass(SimpleLinkService, [{
  7340. key: "navigateTo",
  7341. value: function navigateTo(dest) {}
  7342. }, {
  7343. key: "getDestinationHash",
  7344. value: function getDestinationHash(dest) {
  7345. return "#";
  7346. }
  7347. }, {
  7348. key: "getAnchorUrl",
  7349. value: function getAnchorUrl(hash) {
  7350. return "#";
  7351. }
  7352. }, {
  7353. key: "setHash",
  7354. value: function setHash(hash) {}
  7355. }, {
  7356. key: "executeNamedAction",
  7357. value: function executeNamedAction(action) {}
  7358. }, {
  7359. key: "cachePageRef",
  7360. value: function cachePageRef(pageNum, pageRef) {}
  7361. }, {
  7362. key: "isPageVisible",
  7363. value: function isPageVisible(pageNumber) {
  7364. return true;
  7365. }
  7366. }, {
  7367. key: "pagesCount",
  7368. get: function get() {
  7369. return 0;
  7370. }
  7371. }, {
  7372. key: "page",
  7373. get: function get() {
  7374. return 0;
  7375. },
  7376. set: function set(value) {}
  7377. }, {
  7378. key: "rotation",
  7379. get: function get() {
  7380. return 0;
  7381. },
  7382. set: function set(value) {}
  7383. }]);
  7384. return SimpleLinkService;
  7385. }();
  7386. exports.SimpleLinkService = SimpleLinkService;
  7387. /***/ }),
  7388. /* 22 */
  7389. /***/ (function(module, exports, __webpack_require__) {
  7390. "use strict";
  7391. Object.defineProperty(exports, "__esModule", {
  7392. value: true
  7393. });
  7394. exports.PDFOutlineViewer = void 0;
  7395. var _pdfjsLib = __webpack_require__(8);
  7396. function _createForOfIteratorHelper(o, allowArrayLike) { var it; if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { 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 = o[Symbol.iterator](); }, 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; } } }; }
  7397. 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); }
  7398. 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; }
  7399. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  7400. 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); } }
  7401. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  7402. var DEFAULT_TITLE = "\u2013";
  7403. var PDFOutlineViewer = /*#__PURE__*/function () {
  7404. function PDFOutlineViewer(_ref) {
  7405. var container = _ref.container,
  7406. linkService = _ref.linkService,
  7407. eventBus = _ref.eventBus;
  7408. _classCallCheck(this, PDFOutlineViewer);
  7409. this.container = container;
  7410. this.linkService = linkService;
  7411. this.eventBus = eventBus;
  7412. this.reset();
  7413. eventBus._on("toggleoutlinetree", this.toggleOutlineTree.bind(this));
  7414. }
  7415. _createClass(PDFOutlineViewer, [{
  7416. key: "reset",
  7417. value: function reset() {
  7418. this.outline = null;
  7419. this.lastToggleIsShow = true;
  7420. this.container.textContent = "";
  7421. this.container.classList.remove("outlineWithDeepNesting");
  7422. }
  7423. }, {
  7424. key: "_dispatchEvent",
  7425. value: function _dispatchEvent(outlineCount) {
  7426. this.eventBus.dispatch("outlineloaded", {
  7427. source: this,
  7428. outlineCount: outlineCount
  7429. });
  7430. }
  7431. }, {
  7432. key: "_bindLink",
  7433. value: function _bindLink(element, _ref2) {
  7434. var url = _ref2.url,
  7435. newWindow = _ref2.newWindow,
  7436. dest = _ref2.dest;
  7437. var linkService = this.linkService;
  7438. if (url) {
  7439. (0, _pdfjsLib.addLinkAttributes)(element, {
  7440. url: url,
  7441. target: newWindow ? _pdfjsLib.LinkTarget.BLANK : linkService.externalLinkTarget,
  7442. rel: linkService.externalLinkRel,
  7443. enabled: linkService.externalLinkEnabled
  7444. });
  7445. return;
  7446. }
  7447. element.href = linkService.getDestinationHash(dest);
  7448. element.onclick = function () {
  7449. if (dest) {
  7450. linkService.navigateTo(dest);
  7451. }
  7452. return false;
  7453. };
  7454. }
  7455. }, {
  7456. key: "_setStyles",
  7457. value: function _setStyles(element, _ref3) {
  7458. var bold = _ref3.bold,
  7459. italic = _ref3.italic;
  7460. if (bold) {
  7461. element.style.fontWeight = "bold";
  7462. }
  7463. if (italic) {
  7464. element.style.fontStyle = "italic";
  7465. }
  7466. }
  7467. }, {
  7468. key: "_addToggleButton",
  7469. value: function _addToggleButton(div, _ref4) {
  7470. var _this = this;
  7471. var count = _ref4.count,
  7472. items = _ref4.items;
  7473. var toggler = document.createElement("div");
  7474. toggler.className = "outlineItemToggler";
  7475. if (count < 0 && Math.abs(count) === items.length) {
  7476. toggler.classList.add("outlineItemsHidden");
  7477. }
  7478. toggler.onclick = function (evt) {
  7479. evt.stopPropagation();
  7480. toggler.classList.toggle("outlineItemsHidden");
  7481. if (evt.shiftKey) {
  7482. var shouldShowAll = !toggler.classList.contains("outlineItemsHidden");
  7483. _this._toggleOutlineItem(div, shouldShowAll);
  7484. }
  7485. };
  7486. div.insertBefore(toggler, div.firstChild);
  7487. }
  7488. }, {
  7489. key: "_toggleOutlineItem",
  7490. value: function _toggleOutlineItem(root) {
  7491. var show = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  7492. this.lastToggleIsShow = show;
  7493. var _iterator = _createForOfIteratorHelper(root.querySelectorAll(".outlineItemToggler")),
  7494. _step;
  7495. try {
  7496. for (_iterator.s(); !(_step = _iterator.n()).done;) {
  7497. var toggler = _step.value;
  7498. toggler.classList.toggle("outlineItemsHidden", !show);
  7499. }
  7500. } catch (err) {
  7501. _iterator.e(err);
  7502. } finally {
  7503. _iterator.f();
  7504. }
  7505. }
  7506. }, {
  7507. key: "toggleOutlineTree",
  7508. value: function toggleOutlineTree() {
  7509. if (!this.outline) {
  7510. return;
  7511. }
  7512. this._toggleOutlineItem(this.container, !this.lastToggleIsShow);
  7513. }
  7514. }, {
  7515. key: "render",
  7516. value: function render(_ref5) {
  7517. var outline = _ref5.outline;
  7518. var outlineCount = 0;
  7519. if (this.outline) {
  7520. this.reset();
  7521. }
  7522. this.outline = outline || null;
  7523. if (!outline) {
  7524. this._dispatchEvent(outlineCount);
  7525. return;
  7526. }
  7527. var fragment = document.createDocumentFragment();
  7528. var queue = [{
  7529. parent: fragment,
  7530. items: this.outline
  7531. }];
  7532. var hasAnyNesting = false;
  7533. while (queue.length > 0) {
  7534. var levelData = queue.shift();
  7535. var _iterator2 = _createForOfIteratorHelper(levelData.items),
  7536. _step2;
  7537. try {
  7538. for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
  7539. var item = _step2.value;
  7540. var div = document.createElement("div");
  7541. div.className = "outlineItem";
  7542. var element = document.createElement("a");
  7543. this._bindLink(element, item);
  7544. this._setStyles(element, item);
  7545. element.textContent = (0, _pdfjsLib.removeNullCharacters)(item.title) || DEFAULT_TITLE;
  7546. div.appendChild(element);
  7547. if (item.items.length > 0) {
  7548. hasAnyNesting = true;
  7549. this._addToggleButton(div, item);
  7550. var itemsDiv = document.createElement("div");
  7551. itemsDiv.className = "outlineItems";
  7552. div.appendChild(itemsDiv);
  7553. queue.push({
  7554. parent: itemsDiv,
  7555. items: item.items
  7556. });
  7557. }
  7558. levelData.parent.appendChild(div);
  7559. outlineCount++;
  7560. }
  7561. } catch (err) {
  7562. _iterator2.e(err);
  7563. } finally {
  7564. _iterator2.f();
  7565. }
  7566. }
  7567. if (hasAnyNesting) {
  7568. this.container.classList.add("outlineWithDeepNesting");
  7569. this.lastToggleIsShow = fragment.querySelectorAll(".outlineItemsHidden").length === 0;
  7570. }
  7571. this.container.appendChild(fragment);
  7572. this._dispatchEvent(outlineCount);
  7573. }
  7574. }]);
  7575. return PDFOutlineViewer;
  7576. }();
  7577. exports.PDFOutlineViewer = PDFOutlineViewer;
  7578. /***/ }),
  7579. /* 23 */
  7580. /***/ (function(module, exports, __webpack_require__) {
  7581. "use strict";
  7582. Object.defineProperty(exports, "__esModule", {
  7583. value: true
  7584. });
  7585. exports.PDFPresentationMode = void 0;
  7586. var _ui_utils = __webpack_require__(5);
  7587. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  7588. 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); } }
  7589. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  7590. var DELAY_BEFORE_RESETTING_SWITCH_IN_PROGRESS = 1500;
  7591. var DELAY_BEFORE_HIDING_CONTROLS = 3000;
  7592. var ACTIVE_SELECTOR = "pdfPresentationMode";
  7593. var CONTROLS_SELECTOR = "pdfPresentationModeControls";
  7594. var MOUSE_SCROLL_COOLDOWN_TIME = 50;
  7595. var PAGE_SWITCH_THRESHOLD = 0.1;
  7596. var SWIPE_MIN_DISTANCE_THRESHOLD = 50;
  7597. var SWIPE_ANGLE_THRESHOLD = Math.PI / 6;
  7598. var PDFPresentationMode = /*#__PURE__*/function () {
  7599. function PDFPresentationMode(_ref) {
  7600. var _this = this;
  7601. var container = _ref.container,
  7602. pdfViewer = _ref.pdfViewer,
  7603. eventBus = _ref.eventBus,
  7604. _ref$contextMenuItems = _ref.contextMenuItems,
  7605. contextMenuItems = _ref$contextMenuItems === void 0 ? null : _ref$contextMenuItems;
  7606. _classCallCheck(this, PDFPresentationMode);
  7607. this.container = container;
  7608. this.pdfViewer = pdfViewer;
  7609. this.eventBus = eventBus;
  7610. this.active = false;
  7611. this.args = null;
  7612. this.contextMenuOpen = false;
  7613. this.mouseScrollTimeStamp = 0;
  7614. this.mouseScrollDelta = 0;
  7615. this.touchSwipeState = null;
  7616. if (contextMenuItems) {
  7617. contextMenuItems.contextFirstPage.addEventListener("click", function () {
  7618. _this.contextMenuOpen = false;
  7619. _this.eventBus.dispatch("firstpage", {
  7620. source: _this
  7621. });
  7622. });
  7623. contextMenuItems.contextLastPage.addEventListener("click", function () {
  7624. _this.contextMenuOpen = false;
  7625. _this.eventBus.dispatch("lastpage", {
  7626. source: _this
  7627. });
  7628. });
  7629. contextMenuItems.contextPageRotateCw.addEventListener("click", function () {
  7630. _this.contextMenuOpen = false;
  7631. _this.eventBus.dispatch("rotatecw", {
  7632. source: _this
  7633. });
  7634. });
  7635. contextMenuItems.contextPageRotateCcw.addEventListener("click", function () {
  7636. _this.contextMenuOpen = false;
  7637. _this.eventBus.dispatch("rotateccw", {
  7638. source: _this
  7639. });
  7640. });
  7641. }
  7642. }
  7643. _createClass(PDFPresentationMode, [{
  7644. key: "request",
  7645. value: function request() {
  7646. if (this.switchInProgress || this.active || !this.pdfViewer.pagesCount) {
  7647. return false;
  7648. }
  7649. this._addFullscreenChangeListeners();
  7650. this._setSwitchInProgress();
  7651. this._notifyStateChange();
  7652. if (this.container.requestFullscreen) {
  7653. this.container.requestFullscreen();
  7654. } else if (this.container.mozRequestFullScreen) {
  7655. this.container.mozRequestFullScreen();
  7656. } else if (this.container.webkitRequestFullscreen) {
  7657. this.container.webkitRequestFullscreen(Element.ALLOW_KEYBOARD_INPUT);
  7658. } else if (this.container.msRequestFullscreen) {
  7659. this.container.msRequestFullscreen();
  7660. } else {
  7661. return false;
  7662. }
  7663. this.args = {
  7664. page: this.pdfViewer.currentPageNumber,
  7665. previousScale: this.pdfViewer.currentScaleValue
  7666. };
  7667. return true;
  7668. }
  7669. }, {
  7670. key: "_mouseWheel",
  7671. value: function _mouseWheel(evt) {
  7672. if (!this.active) {
  7673. return;
  7674. }
  7675. evt.preventDefault();
  7676. var delta = (0, _ui_utils.normalizeWheelEventDelta)(evt);
  7677. var currentTime = new Date().getTime();
  7678. var storedTime = this.mouseScrollTimeStamp;
  7679. if (currentTime > storedTime && currentTime - storedTime < MOUSE_SCROLL_COOLDOWN_TIME) {
  7680. return;
  7681. }
  7682. if (this.mouseScrollDelta > 0 && delta < 0 || this.mouseScrollDelta < 0 && delta > 0) {
  7683. this._resetMouseScrollState();
  7684. }
  7685. this.mouseScrollDelta += delta;
  7686. if (Math.abs(this.mouseScrollDelta) >= PAGE_SWITCH_THRESHOLD) {
  7687. var totalDelta = this.mouseScrollDelta;
  7688. this._resetMouseScrollState();
  7689. var success = totalDelta > 0 ? this._goToPreviousPage() : this._goToNextPage();
  7690. if (success) {
  7691. this.mouseScrollTimeStamp = currentTime;
  7692. }
  7693. }
  7694. }
  7695. }, {
  7696. key: "_goToPreviousPage",
  7697. value: function _goToPreviousPage() {
  7698. var page = this.pdfViewer.currentPageNumber;
  7699. if (page <= 1) {
  7700. return false;
  7701. }
  7702. this.pdfViewer.currentPageNumber = page - 1;
  7703. return true;
  7704. }
  7705. }, {
  7706. key: "_goToNextPage",
  7707. value: function _goToNextPage() {
  7708. var page = this.pdfViewer.currentPageNumber;
  7709. if (page >= this.pdfViewer.pagesCount) {
  7710. return false;
  7711. }
  7712. this.pdfViewer.currentPageNumber = page + 1;
  7713. return true;
  7714. }
  7715. }, {
  7716. key: "_notifyStateChange",
  7717. value: function _notifyStateChange() {
  7718. this.eventBus.dispatch("presentationmodechanged", {
  7719. source: this,
  7720. active: this.active,
  7721. switchInProgress: !!this.switchInProgress
  7722. });
  7723. }
  7724. }, {
  7725. key: "_setSwitchInProgress",
  7726. value: function _setSwitchInProgress() {
  7727. var _this2 = this;
  7728. if (this.switchInProgress) {
  7729. clearTimeout(this.switchInProgress);
  7730. }
  7731. this.switchInProgress = setTimeout(function () {
  7732. _this2._removeFullscreenChangeListeners();
  7733. delete _this2.switchInProgress;
  7734. _this2._notifyStateChange();
  7735. }, DELAY_BEFORE_RESETTING_SWITCH_IN_PROGRESS);
  7736. }
  7737. }, {
  7738. key: "_resetSwitchInProgress",
  7739. value: function _resetSwitchInProgress() {
  7740. if (this.switchInProgress) {
  7741. clearTimeout(this.switchInProgress);
  7742. delete this.switchInProgress;
  7743. }
  7744. }
  7745. }, {
  7746. key: "_enter",
  7747. value: function _enter() {
  7748. var _this3 = this;
  7749. this.active = true;
  7750. this._resetSwitchInProgress();
  7751. this._notifyStateChange();
  7752. this.container.classList.add(ACTIVE_SELECTOR);
  7753. setTimeout(function () {
  7754. _this3.pdfViewer.currentPageNumber = _this3.args.page;
  7755. _this3.pdfViewer.currentScaleValue = "page-fit";
  7756. }, 0);
  7757. this._addWindowListeners();
  7758. this._showControls();
  7759. this.contextMenuOpen = false;
  7760. this.container.setAttribute("contextmenu", "viewerContextMenu");
  7761. window.getSelection().removeAllRanges();
  7762. }
  7763. }, {
  7764. key: "_exit",
  7765. value: function _exit() {
  7766. var _this4 = this;
  7767. var page = this.pdfViewer.currentPageNumber;
  7768. this.container.classList.remove(ACTIVE_SELECTOR);
  7769. setTimeout(function () {
  7770. _this4.active = false;
  7771. _this4._removeFullscreenChangeListeners();
  7772. _this4._notifyStateChange();
  7773. _this4.pdfViewer.currentScaleValue = _this4.args.previousScale;
  7774. _this4.pdfViewer.currentPageNumber = page;
  7775. _this4.args = null;
  7776. }, 0);
  7777. this._removeWindowListeners();
  7778. this._hideControls();
  7779. this._resetMouseScrollState();
  7780. this.container.removeAttribute("contextmenu");
  7781. this.contextMenuOpen = false;
  7782. }
  7783. }, {
  7784. key: "_mouseDown",
  7785. value: function _mouseDown(evt) {
  7786. if (this.contextMenuOpen) {
  7787. this.contextMenuOpen = false;
  7788. evt.preventDefault();
  7789. return;
  7790. }
  7791. if (evt.button === 0) {
  7792. var isInternalLink = evt.target.href && evt.target.classList.contains("internalLink");
  7793. if (!isInternalLink) {
  7794. evt.preventDefault();
  7795. if (evt.shiftKey) {
  7796. this._goToPreviousPage();
  7797. } else {
  7798. this._goToNextPage();
  7799. }
  7800. }
  7801. }
  7802. }
  7803. }, {
  7804. key: "_contextMenu",
  7805. value: function _contextMenu() {
  7806. this.contextMenuOpen = true;
  7807. }
  7808. }, {
  7809. key: "_showControls",
  7810. value: function _showControls() {
  7811. var _this5 = this;
  7812. if (this.controlsTimeout) {
  7813. clearTimeout(this.controlsTimeout);
  7814. } else {
  7815. this.container.classList.add(CONTROLS_SELECTOR);
  7816. }
  7817. this.controlsTimeout = setTimeout(function () {
  7818. _this5.container.classList.remove(CONTROLS_SELECTOR);
  7819. delete _this5.controlsTimeout;
  7820. }, DELAY_BEFORE_HIDING_CONTROLS);
  7821. }
  7822. }, {
  7823. key: "_hideControls",
  7824. value: function _hideControls() {
  7825. if (!this.controlsTimeout) {
  7826. return;
  7827. }
  7828. clearTimeout(this.controlsTimeout);
  7829. this.container.classList.remove(CONTROLS_SELECTOR);
  7830. delete this.controlsTimeout;
  7831. }
  7832. }, {
  7833. key: "_resetMouseScrollState",
  7834. value: function _resetMouseScrollState() {
  7835. this.mouseScrollTimeStamp = 0;
  7836. this.mouseScrollDelta = 0;
  7837. }
  7838. }, {
  7839. key: "_touchSwipe",
  7840. value: function _touchSwipe(evt) {
  7841. if (!this.active) {
  7842. return;
  7843. }
  7844. if (evt.touches.length > 1) {
  7845. this.touchSwipeState = null;
  7846. return;
  7847. }
  7848. switch (evt.type) {
  7849. case "touchstart":
  7850. this.touchSwipeState = {
  7851. startX: evt.touches[0].pageX,
  7852. startY: evt.touches[0].pageY,
  7853. endX: evt.touches[0].pageX,
  7854. endY: evt.touches[0].pageY
  7855. };
  7856. break;
  7857. case "touchmove":
  7858. if (this.touchSwipeState === null) {
  7859. return;
  7860. }
  7861. this.touchSwipeState.endX = evt.touches[0].pageX;
  7862. this.touchSwipeState.endY = evt.touches[0].pageY;
  7863. evt.preventDefault();
  7864. break;
  7865. case "touchend":
  7866. if (this.touchSwipeState === null) {
  7867. return;
  7868. }
  7869. var delta = 0;
  7870. var dx = this.touchSwipeState.endX - this.touchSwipeState.startX;
  7871. var dy = this.touchSwipeState.endY - this.touchSwipeState.startY;
  7872. var absAngle = Math.abs(Math.atan2(dy, dx));
  7873. if (Math.abs(dx) > SWIPE_MIN_DISTANCE_THRESHOLD && (absAngle <= SWIPE_ANGLE_THRESHOLD || absAngle >= Math.PI - SWIPE_ANGLE_THRESHOLD)) {
  7874. delta = dx;
  7875. } else if (Math.abs(dy) > SWIPE_MIN_DISTANCE_THRESHOLD && Math.abs(absAngle - Math.PI / 2) <= SWIPE_ANGLE_THRESHOLD) {
  7876. delta = dy;
  7877. }
  7878. if (delta > 0) {
  7879. this._goToPreviousPage();
  7880. } else if (delta < 0) {
  7881. this._goToNextPage();
  7882. }
  7883. break;
  7884. }
  7885. }
  7886. }, {
  7887. key: "_addWindowListeners",
  7888. value: function _addWindowListeners() {
  7889. this.showControlsBind = this._showControls.bind(this);
  7890. this.mouseDownBind = this._mouseDown.bind(this);
  7891. this.mouseWheelBind = this._mouseWheel.bind(this);
  7892. this.resetMouseScrollStateBind = this._resetMouseScrollState.bind(this);
  7893. this.contextMenuBind = this._contextMenu.bind(this);
  7894. this.touchSwipeBind = this._touchSwipe.bind(this);
  7895. window.addEventListener("mousemove", this.showControlsBind);
  7896. window.addEventListener("mousedown", this.mouseDownBind);
  7897. window.addEventListener("wheel", this.mouseWheelBind, {
  7898. passive: false
  7899. });
  7900. window.addEventListener("keydown", this.resetMouseScrollStateBind);
  7901. window.addEventListener("contextmenu", this.contextMenuBind);
  7902. window.addEventListener("touchstart", this.touchSwipeBind);
  7903. window.addEventListener("touchmove", this.touchSwipeBind);
  7904. window.addEventListener("touchend", this.touchSwipeBind);
  7905. }
  7906. }, {
  7907. key: "_removeWindowListeners",
  7908. value: function _removeWindowListeners() {
  7909. window.removeEventListener("mousemove", this.showControlsBind);
  7910. window.removeEventListener("mousedown", this.mouseDownBind);
  7911. window.removeEventListener("wheel", this.mouseWheelBind, {
  7912. passive: false
  7913. });
  7914. window.removeEventListener("keydown", this.resetMouseScrollStateBind);
  7915. window.removeEventListener("contextmenu", this.contextMenuBind);
  7916. window.removeEventListener("touchstart", this.touchSwipeBind);
  7917. window.removeEventListener("touchmove", this.touchSwipeBind);
  7918. window.removeEventListener("touchend", this.touchSwipeBind);
  7919. delete this.showControlsBind;
  7920. delete this.mouseDownBind;
  7921. delete this.mouseWheelBind;
  7922. delete this.resetMouseScrollStateBind;
  7923. delete this.contextMenuBind;
  7924. delete this.touchSwipeBind;
  7925. }
  7926. }, {
  7927. key: "_fullscreenChange",
  7928. value: function _fullscreenChange() {
  7929. if (this.isFullscreen) {
  7930. this._enter();
  7931. } else {
  7932. this._exit();
  7933. }
  7934. }
  7935. }, {
  7936. key: "_addFullscreenChangeListeners",
  7937. value: function _addFullscreenChangeListeners() {
  7938. this.fullscreenChangeBind = this._fullscreenChange.bind(this);
  7939. window.addEventListener("fullscreenchange", this.fullscreenChangeBind);
  7940. window.addEventListener("mozfullscreenchange", this.fullscreenChangeBind);
  7941. window.addEventListener("webkitfullscreenchange", this.fullscreenChangeBind);
  7942. window.addEventListener("MSFullscreenChange", this.fullscreenChangeBind);
  7943. }
  7944. }, {
  7945. key: "_removeFullscreenChangeListeners",
  7946. value: function _removeFullscreenChangeListeners() {
  7947. window.removeEventListener("fullscreenchange", this.fullscreenChangeBind);
  7948. window.removeEventListener("mozfullscreenchange", this.fullscreenChangeBind);
  7949. window.removeEventListener("webkitfullscreenchange", this.fullscreenChangeBind);
  7950. window.removeEventListener("MSFullscreenChange", this.fullscreenChangeBind);
  7951. delete this.fullscreenChangeBind;
  7952. }
  7953. }, {
  7954. key: "isFullscreen",
  7955. get: function get() {
  7956. return !!(document.fullscreenElement || document.mozFullScreen || document.webkitIsFullScreen || document.msFullscreenElement);
  7957. }
  7958. }]);
  7959. return PDFPresentationMode;
  7960. }();
  7961. exports.PDFPresentationMode = PDFPresentationMode;
  7962. /***/ }),
  7963. /* 24 */
  7964. /***/ (function(module, exports, __webpack_require__) {
  7965. "use strict";
  7966. Object.defineProperty(exports, "__esModule", {
  7967. value: true
  7968. });
  7969. exports.PDFSidebarResizer = void 0;
  7970. var _ui_utils = __webpack_require__(5);
  7971. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  7972. 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); } }
  7973. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  7974. var SIDEBAR_WIDTH_VAR = "--sidebar-width";
  7975. var SIDEBAR_MIN_WIDTH = 200;
  7976. var SIDEBAR_RESIZING_CLASS = "sidebarResizing";
  7977. var PDFSidebarResizer = /*#__PURE__*/function () {
  7978. function PDFSidebarResizer(options, eventBus) {
  7979. var _this = this;
  7980. var l10n = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : _ui_utils.NullL10n;
  7981. _classCallCheck(this, PDFSidebarResizer);
  7982. this.enabled = false;
  7983. this.isRTL = false;
  7984. this.sidebarOpen = false;
  7985. this.doc = document.documentElement;
  7986. this._width = null;
  7987. this._outerContainerWidth = null;
  7988. this._boundEvents = Object.create(null);
  7989. this.outerContainer = options.outerContainer;
  7990. this.resizer = options.resizer;
  7991. this.eventBus = eventBus;
  7992. this.l10n = l10n;
  7993. if (typeof CSS === "undefined" || typeof CSS.supports !== "function" || !CSS.supports(SIDEBAR_WIDTH_VAR, "calc(-1 * ".concat(SIDEBAR_MIN_WIDTH, "px)"))) {
  7994. console.warn("PDFSidebarResizer: " + "The browser does not support resizing of the sidebar.");
  7995. return;
  7996. }
  7997. this.enabled = true;
  7998. this.resizer.classList.remove("hidden");
  7999. this.l10n.getDirection().then(function (dir) {
  8000. _this.isRTL = dir === "rtl";
  8001. });
  8002. this._addEventListeners();
  8003. }
  8004. _createClass(PDFSidebarResizer, [{
  8005. key: "_updateWidth",
  8006. value: function _updateWidth() {
  8007. var width = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
  8008. if (!this.enabled) {
  8009. return false;
  8010. }
  8011. var newWidth = (0, _ui_utils.clamp)(width, SIDEBAR_MIN_WIDTH, Math.floor(this.outerContainerWidth / 2));
  8012. if (newWidth === this._width) {
  8013. return false;
  8014. }
  8015. this._width = newWidth;
  8016. this.doc.style.setProperty(SIDEBAR_WIDTH_VAR, "".concat(newWidth, "px"));
  8017. return true;
  8018. }
  8019. }, {
  8020. key: "_mouseMove",
  8021. value: function _mouseMove(evt) {
  8022. var width = evt.clientX;
  8023. if (this.isRTL) {
  8024. width = this.outerContainerWidth - width;
  8025. }
  8026. this._updateWidth(width);
  8027. }
  8028. }, {
  8029. key: "_mouseUp",
  8030. value: function _mouseUp(evt) {
  8031. this.outerContainer.classList.remove(SIDEBAR_RESIZING_CLASS);
  8032. this.eventBus.dispatch("resize", {
  8033. source: this
  8034. });
  8035. var _boundEvents = this._boundEvents;
  8036. window.removeEventListener("mousemove", _boundEvents.mouseMove);
  8037. window.removeEventListener("mouseup", _boundEvents.mouseUp);
  8038. }
  8039. }, {
  8040. key: "_addEventListeners",
  8041. value: function _addEventListeners() {
  8042. var _this2 = this;
  8043. if (!this.enabled) {
  8044. return;
  8045. }
  8046. var _boundEvents = this._boundEvents;
  8047. _boundEvents.mouseMove = this._mouseMove.bind(this);
  8048. _boundEvents.mouseUp = this._mouseUp.bind(this);
  8049. this.resizer.addEventListener("mousedown", function (evt) {
  8050. if (evt.button !== 0) {
  8051. return;
  8052. }
  8053. _this2.outerContainer.classList.add(SIDEBAR_RESIZING_CLASS);
  8054. window.addEventListener("mousemove", _boundEvents.mouseMove);
  8055. window.addEventListener("mouseup", _boundEvents.mouseUp);
  8056. });
  8057. this.eventBus._on("sidebarviewchanged", function (evt) {
  8058. _this2.sidebarOpen = !!(evt && evt.view);
  8059. });
  8060. this.eventBus._on("resize", function (evt) {
  8061. if (!evt || evt.source !== window) {
  8062. return;
  8063. }
  8064. _this2._outerContainerWidth = null;
  8065. if (!_this2._width) {
  8066. return;
  8067. }
  8068. if (!_this2.sidebarOpen) {
  8069. _this2._updateWidth(_this2._width);
  8070. return;
  8071. }
  8072. _this2.outerContainer.classList.add(SIDEBAR_RESIZING_CLASS);
  8073. var updated = _this2._updateWidth(_this2._width);
  8074. Promise.resolve().then(function () {
  8075. _this2.outerContainer.classList.remove(SIDEBAR_RESIZING_CLASS);
  8076. if (updated) {
  8077. _this2.eventBus.dispatch("resize", {
  8078. source: _this2
  8079. });
  8080. }
  8081. });
  8082. });
  8083. }
  8084. }, {
  8085. key: "outerContainerWidth",
  8086. get: function get() {
  8087. if (!this._outerContainerWidth) {
  8088. this._outerContainerWidth = this.outerContainer.clientWidth;
  8089. }
  8090. return this._outerContainerWidth;
  8091. }
  8092. }]);
  8093. return PDFSidebarResizer;
  8094. }();
  8095. exports.PDFSidebarResizer = PDFSidebarResizer;
  8096. /***/ }),
  8097. /* 25 */
  8098. /***/ (function(module, exports, __webpack_require__) {
  8099. "use strict";
  8100. Object.defineProperty(exports, "__esModule", {
  8101. value: true
  8102. });
  8103. exports.PDFThumbnailViewer = void 0;
  8104. var _ui_utils = __webpack_require__(5);
  8105. var _pdf_thumbnail_view = __webpack_require__(26);
  8106. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  8107. 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); } }
  8108. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  8109. var THUMBNAIL_SCROLL_MARGIN = -19;
  8110. var THUMBNAIL_SELECTED_CLASS = "selected";
  8111. var PDFThumbnailViewer = /*#__PURE__*/function () {
  8112. function PDFThumbnailViewer(_ref) {
  8113. var container = _ref.container,
  8114. linkService = _ref.linkService,
  8115. renderingQueue = _ref.renderingQueue,
  8116. _ref$l10n = _ref.l10n,
  8117. l10n = _ref$l10n === void 0 ? _ui_utils.NullL10n : _ref$l10n;
  8118. _classCallCheck(this, PDFThumbnailViewer);
  8119. this.container = container;
  8120. this.linkService = linkService;
  8121. this.renderingQueue = renderingQueue;
  8122. this.l10n = l10n;
  8123. this.scroll = (0, _ui_utils.watchScroll)(this.container, this._scrollUpdated.bind(this));
  8124. this._resetView();
  8125. }
  8126. _createClass(PDFThumbnailViewer, [{
  8127. key: "_scrollUpdated",
  8128. value: function _scrollUpdated() {
  8129. this.renderingQueue.renderHighestPriority();
  8130. }
  8131. }, {
  8132. key: "getThumbnail",
  8133. value: function getThumbnail(index) {
  8134. return this._thumbnails[index];
  8135. }
  8136. }, {
  8137. key: "_getVisibleThumbs",
  8138. value: function _getVisibleThumbs() {
  8139. return (0, _ui_utils.getVisibleElements)(this.container, this._thumbnails);
  8140. }
  8141. }, {
  8142. key: "scrollThumbnailIntoView",
  8143. value: function scrollThumbnailIntoView(pageNumber) {
  8144. if (!this.pdfDocument) {
  8145. return;
  8146. }
  8147. var thumbnailView = this._thumbnails[pageNumber - 1];
  8148. if (!thumbnailView) {
  8149. console.error('scrollThumbnailIntoView: Invalid "pageNumber" parameter.');
  8150. return;
  8151. }
  8152. if (pageNumber !== this._currentPageNumber) {
  8153. var prevThumbnailView = this._thumbnails[this._currentPageNumber - 1];
  8154. prevThumbnailView.div.classList.remove(THUMBNAIL_SELECTED_CLASS);
  8155. thumbnailView.div.classList.add(THUMBNAIL_SELECTED_CLASS);
  8156. }
  8157. var visibleThumbs = this._getVisibleThumbs();
  8158. var numVisibleThumbs = visibleThumbs.views.length;
  8159. if (numVisibleThumbs > 0) {
  8160. var first = visibleThumbs.first.id;
  8161. var last = numVisibleThumbs > 1 ? visibleThumbs.last.id : first;
  8162. var shouldScroll = false;
  8163. if (pageNumber <= first || pageNumber >= last) {
  8164. shouldScroll = true;
  8165. } else {
  8166. visibleThumbs.views.some(function (view) {
  8167. if (view.id !== pageNumber) {
  8168. return false;
  8169. }
  8170. shouldScroll = view.percent < 100;
  8171. return true;
  8172. });
  8173. }
  8174. if (shouldScroll) {
  8175. (0, _ui_utils.scrollIntoView)(thumbnailView.div, {
  8176. top: THUMBNAIL_SCROLL_MARGIN
  8177. });
  8178. }
  8179. }
  8180. this._currentPageNumber = pageNumber;
  8181. }
  8182. }, {
  8183. key: "cleanup",
  8184. value: function cleanup() {
  8185. _pdf_thumbnail_view.PDFThumbnailView.cleanup();
  8186. }
  8187. }, {
  8188. key: "_resetView",
  8189. value: function _resetView() {
  8190. this._thumbnails = [];
  8191. this._currentPageNumber = 1;
  8192. this._pageLabels = null;
  8193. this._pagesRotation = 0;
  8194. this._pagesRequests = new WeakMap();
  8195. this.container.textContent = "";
  8196. }
  8197. }, {
  8198. key: "setDocument",
  8199. value: function setDocument(pdfDocument) {
  8200. var _this = this;
  8201. if (this.pdfDocument) {
  8202. this._cancelRendering();
  8203. this._resetView();
  8204. }
  8205. this.pdfDocument = pdfDocument;
  8206. if (!pdfDocument) {
  8207. return;
  8208. }
  8209. pdfDocument.getPage(1).then(function (firstPdfPage) {
  8210. var pagesCount = pdfDocument.numPages;
  8211. var viewport = firstPdfPage.getViewport({
  8212. scale: 1
  8213. });
  8214. for (var pageNum = 1; pageNum <= pagesCount; ++pageNum) {
  8215. var thumbnail = new _pdf_thumbnail_view.PDFThumbnailView({
  8216. container: _this.container,
  8217. id: pageNum,
  8218. defaultViewport: viewport.clone(),
  8219. linkService: _this.linkService,
  8220. renderingQueue: _this.renderingQueue,
  8221. disableCanvasToImageConversion: false,
  8222. l10n: _this.l10n
  8223. });
  8224. _this._thumbnails.push(thumbnail);
  8225. }
  8226. var firstThumbnailView = _this._thumbnails[0];
  8227. if (firstThumbnailView) {
  8228. firstThumbnailView.setPdfPage(firstPdfPage);
  8229. }
  8230. var thumbnailView = _this._thumbnails[_this._currentPageNumber - 1];
  8231. thumbnailView.div.classList.add(THUMBNAIL_SELECTED_CLASS);
  8232. })["catch"](function (reason) {
  8233. console.error("Unable to initialize thumbnail viewer", reason);
  8234. });
  8235. }
  8236. }, {
  8237. key: "_cancelRendering",
  8238. value: function _cancelRendering() {
  8239. for (var i = 0, ii = this._thumbnails.length; i < ii; i++) {
  8240. if (this._thumbnails[i]) {
  8241. this._thumbnails[i].cancelRendering();
  8242. }
  8243. }
  8244. }
  8245. }, {
  8246. key: "setPageLabels",
  8247. value: function setPageLabels(labels) {
  8248. if (!this.pdfDocument) {
  8249. return;
  8250. }
  8251. if (!labels) {
  8252. this._pageLabels = null;
  8253. } else if (!(Array.isArray(labels) && this.pdfDocument.numPages === labels.length)) {
  8254. this._pageLabels = null;
  8255. console.error("PDFThumbnailViewer_setPageLabels: Invalid page labels.");
  8256. } else {
  8257. this._pageLabels = labels;
  8258. }
  8259. for (var i = 0, ii = this._thumbnails.length; i < ii; i++) {
  8260. var label = this._pageLabels && this._pageLabels[i];
  8261. this._thumbnails[i].setPageLabel(label);
  8262. }
  8263. }
  8264. }, {
  8265. key: "_ensurePdfPageLoaded",
  8266. value: function _ensurePdfPageLoaded(thumbView) {
  8267. var _this2 = this;
  8268. if (thumbView.pdfPage) {
  8269. return Promise.resolve(thumbView.pdfPage);
  8270. }
  8271. if (this._pagesRequests.has(thumbView)) {
  8272. return this._pagesRequests.get(thumbView);
  8273. }
  8274. var promise = this.pdfDocument.getPage(thumbView.id).then(function (pdfPage) {
  8275. if (!thumbView.pdfPage) {
  8276. thumbView.setPdfPage(pdfPage);
  8277. }
  8278. _this2._pagesRequests["delete"](thumbView);
  8279. return pdfPage;
  8280. })["catch"](function (reason) {
  8281. console.error("Unable to get page for thumb view", reason);
  8282. _this2._pagesRequests["delete"](thumbView);
  8283. });
  8284. this._pagesRequests.set(thumbView, promise);
  8285. return promise;
  8286. }
  8287. }, {
  8288. key: "forceRendering",
  8289. value: function forceRendering() {
  8290. var _this3 = this;
  8291. var visibleThumbs = this._getVisibleThumbs();
  8292. var thumbView = this.renderingQueue.getHighestPriority(visibleThumbs, this._thumbnails, this.scroll.down);
  8293. if (thumbView) {
  8294. this._ensurePdfPageLoaded(thumbView).then(function () {
  8295. _this3.renderingQueue.renderView(thumbView);
  8296. });
  8297. return true;
  8298. }
  8299. return false;
  8300. }
  8301. }, {
  8302. key: "pagesRotation",
  8303. get: function get() {
  8304. return this._pagesRotation;
  8305. },
  8306. set: function set(rotation) {
  8307. if (!(0, _ui_utils.isValidRotation)(rotation)) {
  8308. throw new Error("Invalid thumbnails rotation angle.");
  8309. }
  8310. if (!this.pdfDocument) {
  8311. return;
  8312. }
  8313. if (this._pagesRotation === rotation) {
  8314. return;
  8315. }
  8316. this._pagesRotation = rotation;
  8317. for (var i = 0, ii = this._thumbnails.length; i < ii; i++) {
  8318. this._thumbnails[i].update(rotation);
  8319. }
  8320. }
  8321. }]);
  8322. return PDFThumbnailViewer;
  8323. }();
  8324. exports.PDFThumbnailViewer = PDFThumbnailViewer;
  8325. /***/ }),
  8326. /* 26 */
  8327. /***/ (function(module, exports, __webpack_require__) {
  8328. "use strict";
  8329. Object.defineProperty(exports, "__esModule", {
  8330. value: true
  8331. });
  8332. exports.PDFThumbnailView = void 0;
  8333. var _pdfjsLib = __webpack_require__(8);
  8334. var _ui_utils = __webpack_require__(5);
  8335. var _pdf_rendering_queue = __webpack_require__(11);
  8336. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  8337. 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); } }
  8338. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  8339. var MAX_NUM_SCALING_STEPS = 3;
  8340. var THUMBNAIL_CANVAS_BORDER_WIDTH = 1;
  8341. var THUMBNAIL_WIDTH = 98;
  8342. var TempImageFactory = function TempImageFactoryClosure() {
  8343. var tempCanvasCache = null;
  8344. return {
  8345. getCanvas: function getCanvas(width, height) {
  8346. var tempCanvas = tempCanvasCache;
  8347. if (!tempCanvas) {
  8348. tempCanvas = document.createElement("canvas");
  8349. tempCanvasCache = tempCanvas;
  8350. }
  8351. tempCanvas.width = width;
  8352. tempCanvas.height = height;
  8353. tempCanvas.mozOpaque = true;
  8354. var ctx = tempCanvas.getContext("2d", {
  8355. alpha: false
  8356. });
  8357. ctx.save();
  8358. ctx.fillStyle = "rgb(255, 255, 255)";
  8359. ctx.fillRect(0, 0, width, height);
  8360. ctx.restore();
  8361. return tempCanvas;
  8362. },
  8363. destroyCanvas: function destroyCanvas() {
  8364. var tempCanvas = tempCanvasCache;
  8365. if (tempCanvas) {
  8366. tempCanvas.width = 0;
  8367. tempCanvas.height = 0;
  8368. }
  8369. tempCanvasCache = null;
  8370. }
  8371. };
  8372. }();
  8373. var PDFThumbnailView = /*#__PURE__*/function () {
  8374. function PDFThumbnailView(_ref) {
  8375. var container = _ref.container,
  8376. id = _ref.id,
  8377. defaultViewport = _ref.defaultViewport,
  8378. linkService = _ref.linkService,
  8379. renderingQueue = _ref.renderingQueue,
  8380. _ref$disableCanvasToI = _ref.disableCanvasToImageConversion,
  8381. disableCanvasToImageConversion = _ref$disableCanvasToI === void 0 ? false : _ref$disableCanvasToI,
  8382. _ref$l10n = _ref.l10n,
  8383. l10n = _ref$l10n === void 0 ? _ui_utils.NullL10n : _ref$l10n;
  8384. _classCallCheck(this, PDFThumbnailView);
  8385. this.id = id;
  8386. this.renderingId = "thumbnail" + id;
  8387. this.pageLabel = null;
  8388. this.pdfPage = null;
  8389. this.rotation = 0;
  8390. this.viewport = defaultViewport;
  8391. this.pdfPageRotate = defaultViewport.rotation;
  8392. this.linkService = linkService;
  8393. this.renderingQueue = renderingQueue;
  8394. this.renderTask = null;
  8395. this.renderingState = _pdf_rendering_queue.RenderingStates.INITIAL;
  8396. this.resume = null;
  8397. this.disableCanvasToImageConversion = disableCanvasToImageConversion;
  8398. this.pageWidth = this.viewport.width;
  8399. this.pageHeight = this.viewport.height;
  8400. this.pageRatio = this.pageWidth / this.pageHeight;
  8401. this.canvasWidth = THUMBNAIL_WIDTH;
  8402. this.canvasHeight = this.canvasWidth / this.pageRatio | 0;
  8403. this.scale = this.canvasWidth / this.pageWidth;
  8404. this.l10n = l10n;
  8405. var anchor = document.createElement("a");
  8406. anchor.href = linkService.getAnchorUrl("#page=" + id);
  8407. this._thumbPageTitle.then(function (msg) {
  8408. anchor.title = msg;
  8409. });
  8410. anchor.onclick = function () {
  8411. linkService.page = id;
  8412. return false;
  8413. };
  8414. this.anchor = anchor;
  8415. var div = document.createElement("div");
  8416. div.className = "thumbnail";
  8417. div.setAttribute("data-page-number", this.id);
  8418. this.div = div;
  8419. var ring = document.createElement("div");
  8420. ring.className = "thumbnailSelectionRing";
  8421. var borderAdjustment = 2 * THUMBNAIL_CANVAS_BORDER_WIDTH;
  8422. ring.style.width = this.canvasWidth + borderAdjustment + "px";
  8423. ring.style.height = this.canvasHeight + borderAdjustment + "px";
  8424. this.ring = ring;
  8425. div.appendChild(ring);
  8426. anchor.appendChild(div);
  8427. container.appendChild(anchor);
  8428. }
  8429. _createClass(PDFThumbnailView, [{
  8430. key: "setPdfPage",
  8431. value: function setPdfPage(pdfPage) {
  8432. this.pdfPage = pdfPage;
  8433. this.pdfPageRotate = pdfPage.rotate;
  8434. var totalRotation = (this.rotation + this.pdfPageRotate) % 360;
  8435. this.viewport = pdfPage.getViewport({
  8436. scale: 1,
  8437. rotation: totalRotation
  8438. });
  8439. this.reset();
  8440. }
  8441. }, {
  8442. key: "reset",
  8443. value: function reset() {
  8444. this.cancelRendering();
  8445. this.renderingState = _pdf_rendering_queue.RenderingStates.INITIAL;
  8446. this.pageWidth = this.viewport.width;
  8447. this.pageHeight = this.viewport.height;
  8448. this.pageRatio = this.pageWidth / this.pageHeight;
  8449. this.canvasHeight = this.canvasWidth / this.pageRatio | 0;
  8450. this.scale = this.canvasWidth / this.pageWidth;
  8451. this.div.removeAttribute("data-loaded");
  8452. var ring = this.ring;
  8453. var childNodes = ring.childNodes;
  8454. for (var i = childNodes.length - 1; i >= 0; i--) {
  8455. ring.removeChild(childNodes[i]);
  8456. }
  8457. var borderAdjustment = 2 * THUMBNAIL_CANVAS_BORDER_WIDTH;
  8458. ring.style.width = this.canvasWidth + borderAdjustment + "px";
  8459. ring.style.height = this.canvasHeight + borderAdjustment + "px";
  8460. if (this.canvas) {
  8461. this.canvas.width = 0;
  8462. this.canvas.height = 0;
  8463. delete this.canvas;
  8464. }
  8465. if (this.image) {
  8466. this.image.removeAttribute("src");
  8467. delete this.image;
  8468. }
  8469. }
  8470. }, {
  8471. key: "update",
  8472. value: function update(rotation) {
  8473. if (typeof rotation !== "undefined") {
  8474. this.rotation = rotation;
  8475. }
  8476. var totalRotation = (this.rotation + this.pdfPageRotate) % 360;
  8477. this.viewport = this.viewport.clone({
  8478. scale: 1,
  8479. rotation: totalRotation
  8480. });
  8481. this.reset();
  8482. }
  8483. }, {
  8484. key: "cancelRendering",
  8485. value: function cancelRendering() {
  8486. if (this.renderTask) {
  8487. this.renderTask.cancel();
  8488. this.renderTask = null;
  8489. }
  8490. this.resume = null;
  8491. }
  8492. }, {
  8493. key: "_getPageDrawContext",
  8494. value: function _getPageDrawContext() {
  8495. var noCtxScale = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  8496. var canvas = document.createElement("canvas");
  8497. this.canvas = canvas;
  8498. canvas.mozOpaque = true;
  8499. var ctx = canvas.getContext("2d", {
  8500. alpha: false
  8501. });
  8502. var outputScale = (0, _ui_utils.getOutputScale)(ctx);
  8503. canvas.width = this.canvasWidth * outputScale.sx | 0;
  8504. canvas.height = this.canvasHeight * outputScale.sy | 0;
  8505. canvas.style.width = this.canvasWidth + "px";
  8506. canvas.style.height = this.canvasHeight + "px";
  8507. if (!noCtxScale && outputScale.scaled) {
  8508. ctx.scale(outputScale.sx, outputScale.sy);
  8509. }
  8510. return ctx;
  8511. }
  8512. }, {
  8513. key: "_convertCanvasToImage",
  8514. value: function _convertCanvasToImage() {
  8515. var _this = this;
  8516. if (!this.canvas) {
  8517. return;
  8518. }
  8519. if (this.renderingState !== _pdf_rendering_queue.RenderingStates.FINISHED) {
  8520. return;
  8521. }
  8522. var className = "thumbnailImage";
  8523. if (this.disableCanvasToImageConversion) {
  8524. this.canvas.className = className;
  8525. this._thumbPageCanvas.then(function (msg) {
  8526. _this.canvas.setAttribute("aria-label", msg);
  8527. });
  8528. this.div.setAttribute("data-loaded", true);
  8529. this.ring.appendChild(this.canvas);
  8530. return;
  8531. }
  8532. var image = document.createElement("img");
  8533. image.className = className;
  8534. this._thumbPageCanvas.then(function (msg) {
  8535. image.setAttribute("aria-label", msg);
  8536. });
  8537. image.style.width = this.canvasWidth + "px";
  8538. image.style.height = this.canvasHeight + "px";
  8539. image.src = this.canvas.toDataURL();
  8540. this.image = image;
  8541. this.div.setAttribute("data-loaded", true);
  8542. this.ring.appendChild(image);
  8543. this.canvas.width = 0;
  8544. this.canvas.height = 0;
  8545. delete this.canvas;
  8546. }
  8547. }, {
  8548. key: "draw",
  8549. value: function draw() {
  8550. var _this2 = this;
  8551. if (this.renderingState !== _pdf_rendering_queue.RenderingStates.INITIAL) {
  8552. console.error("Must be in new state before drawing");
  8553. return Promise.resolve(undefined);
  8554. }
  8555. var pdfPage = this.pdfPage;
  8556. if (!pdfPage) {
  8557. this.renderingState = _pdf_rendering_queue.RenderingStates.FINISHED;
  8558. return Promise.reject(new Error("pdfPage is not loaded"));
  8559. }
  8560. this.renderingState = _pdf_rendering_queue.RenderingStates.RUNNING;
  8561. var renderCapability = (0, _pdfjsLib.createPromiseCapability)();
  8562. var finishRenderTask = function finishRenderTask(error) {
  8563. if (renderTask === _this2.renderTask) {
  8564. _this2.renderTask = null;
  8565. }
  8566. if (error instanceof _pdfjsLib.RenderingCancelledException) {
  8567. renderCapability.resolve(undefined);
  8568. return;
  8569. }
  8570. _this2.renderingState = _pdf_rendering_queue.RenderingStates.FINISHED;
  8571. _this2._convertCanvasToImage();
  8572. if (!error) {
  8573. renderCapability.resolve(undefined);
  8574. } else {
  8575. renderCapability.reject(error);
  8576. }
  8577. };
  8578. var ctx = this._getPageDrawContext();
  8579. var drawViewport = this.viewport.clone({
  8580. scale: this.scale
  8581. });
  8582. var renderContinueCallback = function renderContinueCallback(cont) {
  8583. if (!_this2.renderingQueue.isHighestPriority(_this2)) {
  8584. _this2.renderingState = _pdf_rendering_queue.RenderingStates.PAUSED;
  8585. _this2.resume = function () {
  8586. _this2.renderingState = _pdf_rendering_queue.RenderingStates.RUNNING;
  8587. cont();
  8588. };
  8589. return;
  8590. }
  8591. cont();
  8592. };
  8593. var renderContext = {
  8594. canvasContext: ctx,
  8595. viewport: drawViewport
  8596. };
  8597. var renderTask = this.renderTask = pdfPage.render(renderContext);
  8598. renderTask.onContinue = renderContinueCallback;
  8599. renderTask.promise.then(function () {
  8600. finishRenderTask(null);
  8601. }, function (error) {
  8602. finishRenderTask(error);
  8603. });
  8604. return renderCapability.promise;
  8605. }
  8606. }, {
  8607. key: "setImage",
  8608. value: function setImage(pageView) {
  8609. if (this.renderingState !== _pdf_rendering_queue.RenderingStates.INITIAL) {
  8610. return;
  8611. }
  8612. var img = pageView.canvas;
  8613. if (!img) {
  8614. return;
  8615. }
  8616. if (!this.pdfPage) {
  8617. this.setPdfPage(pageView.pdfPage);
  8618. }
  8619. this.renderingState = _pdf_rendering_queue.RenderingStates.FINISHED;
  8620. var ctx = this._getPageDrawContext(true);
  8621. var canvas = ctx.canvas;
  8622. if (img.width <= 2 * canvas.width) {
  8623. ctx.drawImage(img, 0, 0, img.width, img.height, 0, 0, canvas.width, canvas.height);
  8624. this._convertCanvasToImage();
  8625. return;
  8626. }
  8627. var reducedWidth = canvas.width << MAX_NUM_SCALING_STEPS;
  8628. var reducedHeight = canvas.height << MAX_NUM_SCALING_STEPS;
  8629. var reducedImage = TempImageFactory.getCanvas(reducedWidth, reducedHeight);
  8630. var reducedImageCtx = reducedImage.getContext("2d");
  8631. while (reducedWidth > img.width || reducedHeight > img.height) {
  8632. reducedWidth >>= 1;
  8633. reducedHeight >>= 1;
  8634. }
  8635. reducedImageCtx.drawImage(img, 0, 0, img.width, img.height, 0, 0, reducedWidth, reducedHeight);
  8636. while (reducedWidth > 2 * canvas.width) {
  8637. reducedImageCtx.drawImage(reducedImage, 0, 0, reducedWidth, reducedHeight, 0, 0, reducedWidth >> 1, reducedHeight >> 1);
  8638. reducedWidth >>= 1;
  8639. reducedHeight >>= 1;
  8640. }
  8641. ctx.drawImage(reducedImage, 0, 0, reducedWidth, reducedHeight, 0, 0, canvas.width, canvas.height);
  8642. this._convertCanvasToImage();
  8643. }
  8644. }, {
  8645. key: "setPageLabel",
  8646. value: function setPageLabel(label) {
  8647. var _this3 = this;
  8648. this.pageLabel = typeof label === "string" ? label : null;
  8649. this._thumbPageTitle.then(function (msg) {
  8650. _this3.anchor.title = msg;
  8651. });
  8652. if (this.renderingState !== _pdf_rendering_queue.RenderingStates.FINISHED) {
  8653. return;
  8654. }
  8655. this._thumbPageCanvas.then(function (msg) {
  8656. if (_this3.image) {
  8657. _this3.image.setAttribute("aria-label", msg);
  8658. } else if (_this3.disableCanvasToImageConversion && _this3.canvas) {
  8659. _this3.canvas.setAttribute("aria-label", msg);
  8660. }
  8661. });
  8662. }
  8663. }, {
  8664. key: "_thumbPageTitle",
  8665. get: function get() {
  8666. return this.l10n.get("thumb_page_title", {
  8667. page: this.pageLabel !== null ? this.pageLabel : this.id
  8668. }, "Page {{page}}");
  8669. }
  8670. }, {
  8671. key: "_thumbPageCanvas",
  8672. get: function get() {
  8673. return this.l10n.get("thumb_page_canvas", {
  8674. page: this.pageLabel !== null ? this.pageLabel : this.id
  8675. }, "Thumbnail of Page {{page}}");
  8676. }
  8677. }], [{
  8678. key: "cleanup",
  8679. value: function cleanup() {
  8680. TempImageFactory.destroyCanvas();
  8681. }
  8682. }]);
  8683. return PDFThumbnailView;
  8684. }();
  8685. exports.PDFThumbnailView = PDFThumbnailView;
  8686. /***/ }),
  8687. /* 27 */
  8688. /***/ (function(module, exports, __webpack_require__) {
  8689. "use strict";
  8690. Object.defineProperty(exports, "__esModule", {
  8691. value: true
  8692. });
  8693. exports.PDFViewer = void 0;
  8694. var _base_viewer = __webpack_require__(28);
  8695. var _pdfjsLib = __webpack_require__(8);
  8696. 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); }
  8697. function _createForOfIteratorHelper(o, allowArrayLike) { var it; if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { 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 = o[Symbol.iterator](); }, 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; } } }; }
  8698. 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); }
  8699. 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; }
  8700. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  8701. 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); } }
  8702. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  8703. 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); }
  8704. function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
  8705. 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); }
  8706. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  8707. 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); }; }
  8708. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  8709. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  8710. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
  8711. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  8712. var PDFViewer = /*#__PURE__*/function (_BaseViewer) {
  8713. _inherits(PDFViewer, _BaseViewer);
  8714. var _super = _createSuper(PDFViewer);
  8715. function PDFViewer() {
  8716. _classCallCheck(this, PDFViewer);
  8717. return _super.apply(this, arguments);
  8718. }
  8719. _createClass(PDFViewer, [{
  8720. key: "_scrollIntoView",
  8721. value: function _scrollIntoView(_ref) {
  8722. var pageDiv = _ref.pageDiv,
  8723. _ref$pageSpot = _ref.pageSpot,
  8724. pageSpot = _ref$pageSpot === void 0 ? null : _ref$pageSpot,
  8725. _ref$pageNumber = _ref.pageNumber,
  8726. pageNumber = _ref$pageNumber === void 0 ? null : _ref$pageNumber;
  8727. if (!pageSpot && !this.isInPresentationMode) {
  8728. var left = pageDiv.offsetLeft + pageDiv.clientLeft;
  8729. var right = left + pageDiv.clientWidth;
  8730. var _this$container = this.container,
  8731. scrollLeft = _this$container.scrollLeft,
  8732. clientWidth = _this$container.clientWidth;
  8733. if (this._isScrollModeHorizontal || left < scrollLeft || right > scrollLeft + clientWidth) {
  8734. pageSpot = {
  8735. left: 0,
  8736. top: 0
  8737. };
  8738. }
  8739. }
  8740. _get(_getPrototypeOf(PDFViewer.prototype), "_scrollIntoView", this).call(this, {
  8741. pageDiv: pageDiv,
  8742. pageSpot: pageSpot,
  8743. pageNumber: pageNumber
  8744. });
  8745. }
  8746. }, {
  8747. key: "_getVisiblePages",
  8748. value: function _getVisiblePages() {
  8749. if (this.isInPresentationMode) {
  8750. return this._getCurrentVisiblePage();
  8751. }
  8752. return _get(_getPrototypeOf(PDFViewer.prototype), "_getVisiblePages", this).call(this);
  8753. }
  8754. }, {
  8755. key: "_updateHelper",
  8756. value: function _updateHelper(visiblePages) {
  8757. if (this.isInPresentationMode) {
  8758. return;
  8759. }
  8760. var currentId = this._currentPageNumber;
  8761. var stillFullyVisible = false;
  8762. var _iterator = _createForOfIteratorHelper(visiblePages),
  8763. _step;
  8764. try {
  8765. for (_iterator.s(); !(_step = _iterator.n()).done;) {
  8766. var page = _step.value;
  8767. if (page.percent < 100) {
  8768. break;
  8769. }
  8770. if (page.id === currentId) {
  8771. stillFullyVisible = true;
  8772. break;
  8773. }
  8774. }
  8775. } catch (err) {
  8776. _iterator.e(err);
  8777. } finally {
  8778. _iterator.f();
  8779. }
  8780. if (!stillFullyVisible) {
  8781. currentId = visiblePages[0].id;
  8782. }
  8783. this._setCurrentPageNumber(currentId);
  8784. }
  8785. }, {
  8786. key: "_viewerElement",
  8787. get: function get() {
  8788. return (0, _pdfjsLib.shadow)(this, "_viewerElement", this.viewer);
  8789. }
  8790. }]);
  8791. return PDFViewer;
  8792. }(_base_viewer.BaseViewer);
  8793. exports.PDFViewer = PDFViewer;
  8794. /***/ }),
  8795. /* 28 */
  8796. /***/ (function(module, exports, __webpack_require__) {
  8797. "use strict";
  8798. Object.defineProperty(exports, "__esModule", {
  8799. value: true
  8800. });
  8801. exports.BaseViewer = void 0;
  8802. var _ui_utils = __webpack_require__(5);
  8803. var _pdf_rendering_queue = __webpack_require__(11);
  8804. var _annotation_layer_builder = __webpack_require__(29);
  8805. var _pdfjsLib = __webpack_require__(8);
  8806. var _pdf_page_view = __webpack_require__(30);
  8807. var _pdf_link_service = __webpack_require__(21);
  8808. var _text_layer_builder = __webpack_require__(31);
  8809. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  8810. 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); } }
  8811. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  8812. var DEFAULT_CACHE_SIZE = 10;
  8813. function PDFPageViewBuffer(size) {
  8814. var data = [];
  8815. this.push = function (view) {
  8816. var i = data.indexOf(view);
  8817. if (i >= 0) {
  8818. data.splice(i, 1);
  8819. }
  8820. data.push(view);
  8821. if (data.length > size) {
  8822. data.shift().destroy();
  8823. }
  8824. };
  8825. this.resize = function (newSize, pagesToKeep) {
  8826. size = newSize;
  8827. if (pagesToKeep) {
  8828. var pageIdsToKeep = new Set();
  8829. for (var i = 0, iMax = pagesToKeep.length; i < iMax; ++i) {
  8830. pageIdsToKeep.add(pagesToKeep[i].id);
  8831. }
  8832. (0, _ui_utils.moveToEndOfArray)(data, function (page) {
  8833. return pageIdsToKeep.has(page.id);
  8834. });
  8835. }
  8836. while (data.length > size) {
  8837. data.shift().destroy();
  8838. }
  8839. };
  8840. }
  8841. function isSameScale(oldScale, newScale) {
  8842. if (newScale === oldScale) {
  8843. return true;
  8844. }
  8845. if (Math.abs(newScale - oldScale) < 1e-15) {
  8846. return true;
  8847. }
  8848. return false;
  8849. }
  8850. var BaseViewer = /*#__PURE__*/function () {
  8851. function BaseViewer(options) {
  8852. var _this = this;
  8853. _classCallCheck(this, BaseViewer);
  8854. if (this.constructor === BaseViewer) {
  8855. throw new Error("Cannot initialize BaseViewer.");
  8856. }
  8857. this._name = this.constructor.name;
  8858. this.container = options.container;
  8859. this.viewer = options.viewer || options.container.firstElementChild;
  8860. this.eventBus = options.eventBus;
  8861. this.linkService = options.linkService || new _pdf_link_service.SimpleLinkService();
  8862. this.downloadManager = options.downloadManager || null;
  8863. this.findController = options.findController || null;
  8864. this.removePageBorders = options.removePageBorders || false;
  8865. this.textLayerMode = Number.isInteger(options.textLayerMode) ? options.textLayerMode : _ui_utils.TextLayerMode.ENABLE;
  8866. this.imageResourcesPath = options.imageResourcesPath || "";
  8867. this.renderInteractiveForms = options.renderInteractiveForms || false;
  8868. this.enablePrintAutoRotate = options.enablePrintAutoRotate || false;
  8869. this.renderer = options.renderer || _ui_utils.RendererType.CANVAS;
  8870. this.enableWebGL = options.enableWebGL || false;
  8871. this.useOnlyCssZoom = options.useOnlyCssZoom || false;
  8872. this.maxCanvasPixels = options.maxCanvasPixels;
  8873. this.l10n = options.l10n || _ui_utils.NullL10n;
  8874. this.defaultRenderingQueue = !options.renderingQueue;
  8875. if (this.defaultRenderingQueue) {
  8876. this.renderingQueue = new _pdf_rendering_queue.PDFRenderingQueue();
  8877. this.renderingQueue.setViewer(this);
  8878. } else {
  8879. this.renderingQueue = options.renderingQueue;
  8880. }
  8881. this.scroll = (0, _ui_utils.watchScroll)(this.container, this._scrollUpdate.bind(this));
  8882. this.presentationModeState = _ui_utils.PresentationModeState.UNKNOWN;
  8883. this._onBeforeDraw = this._onAfterDraw = null;
  8884. this._resetView();
  8885. if (this.removePageBorders) {
  8886. this.viewer.classList.add("removePageBorders");
  8887. }
  8888. Promise.resolve().then(function () {
  8889. _this.eventBus.dispatch("baseviewerinit", {
  8890. source: _this
  8891. });
  8892. });
  8893. }
  8894. _createClass(BaseViewer, [{
  8895. key: "getPageView",
  8896. value: function getPageView(index) {
  8897. return this._pages[index];
  8898. }
  8899. }, {
  8900. key: "_setCurrentPageNumber",
  8901. value: function _setCurrentPageNumber(val) {
  8902. var resetCurrentPageView = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  8903. if (this._currentPageNumber === val) {
  8904. if (resetCurrentPageView) {
  8905. this._resetCurrentPageView();
  8906. }
  8907. return true;
  8908. }
  8909. if (!(0 < val && val <= this.pagesCount)) {
  8910. return false;
  8911. }
  8912. this._currentPageNumber = val;
  8913. this.eventBus.dispatch("pagechanging", {
  8914. source: this,
  8915. pageNumber: val,
  8916. pageLabel: this._pageLabels && this._pageLabels[val - 1]
  8917. });
  8918. if (resetCurrentPageView) {
  8919. this._resetCurrentPageView();
  8920. }
  8921. return true;
  8922. }
  8923. }, {
  8924. key: "_onePageRenderedOrForceFetch",
  8925. value: function _onePageRenderedOrForceFetch() {
  8926. if (!this.container.offsetParent || this._getVisiblePages().views.length === 0) {
  8927. return Promise.resolve();
  8928. }
  8929. return this._onePageRenderedCapability.promise;
  8930. }
  8931. }, {
  8932. key: "setDocument",
  8933. value: function setDocument(pdfDocument) {
  8934. var _this2 = this;
  8935. if (this.pdfDocument) {
  8936. this._cancelRendering();
  8937. this._resetView();
  8938. if (this.findController) {
  8939. this.findController.setDocument(null);
  8940. }
  8941. }
  8942. this.pdfDocument = pdfDocument;
  8943. if (!pdfDocument) {
  8944. return;
  8945. }
  8946. var pagesCount = pdfDocument.numPages;
  8947. var firstPagePromise = pdfDocument.getPage(1);
  8948. this._pagesCapability.promise.then(function () {
  8949. _this2.eventBus.dispatch("pagesloaded", {
  8950. source: _this2,
  8951. pagesCount: pagesCount
  8952. });
  8953. });
  8954. this._onBeforeDraw = function (evt) {
  8955. var pageView = _this2._pages[evt.pageNumber - 1];
  8956. if (!pageView) {
  8957. return;
  8958. }
  8959. _this2._buffer.push(pageView);
  8960. };
  8961. this.eventBus._on("pagerender", this._onBeforeDraw);
  8962. this._onAfterDraw = function (evt) {
  8963. if (evt.cssTransform || _this2._onePageRenderedCapability.settled) {
  8964. return;
  8965. }
  8966. _this2._onePageRenderedCapability.resolve();
  8967. _this2.eventBus._off("pagerendered", _this2._onAfterDraw);
  8968. _this2._onAfterDraw = null;
  8969. };
  8970. this.eventBus._on("pagerendered", this._onAfterDraw);
  8971. firstPagePromise.then(function (firstPdfPage) {
  8972. _this2._firstPageCapability.resolve(firstPdfPage);
  8973. var scale = _this2.currentScale;
  8974. var viewport = firstPdfPage.getViewport({
  8975. scale: scale * _ui_utils.CSS_UNITS
  8976. });
  8977. var textLayerFactory = _this2.textLayerMode !== _ui_utils.TextLayerMode.DISABLE ? _this2 : null;
  8978. for (var pageNum = 1; pageNum <= pagesCount; ++pageNum) {
  8979. var pageView = new _pdf_page_view.PDFPageView({
  8980. container: _this2._viewerElement,
  8981. eventBus: _this2.eventBus,
  8982. id: pageNum,
  8983. scale: scale,
  8984. defaultViewport: viewport.clone(),
  8985. renderingQueue: _this2.renderingQueue,
  8986. textLayerFactory: textLayerFactory,
  8987. textLayerMode: _this2.textLayerMode,
  8988. annotationLayerFactory: _this2,
  8989. imageResourcesPath: _this2.imageResourcesPath,
  8990. renderInteractiveForms: _this2.renderInteractiveForms,
  8991. renderer: _this2.renderer,
  8992. enableWebGL: _this2.enableWebGL,
  8993. useOnlyCssZoom: _this2.useOnlyCssZoom,
  8994. maxCanvasPixels: _this2.maxCanvasPixels,
  8995. l10n: _this2.l10n
  8996. });
  8997. _this2._pages.push(pageView);
  8998. }
  8999. var firstPageView = _this2._pages[0];
  9000. if (firstPageView) {
  9001. firstPageView.setPdfPage(firstPdfPage);
  9002. _this2.linkService.cachePageRef(1, firstPdfPage.ref);
  9003. }
  9004. if (_this2._spreadMode !== _ui_utils.SpreadMode.NONE) {
  9005. _this2._updateSpreadMode();
  9006. }
  9007. _this2._onePageRenderedOrForceFetch().then(function () {
  9008. if (_this2.findController) {
  9009. _this2.findController.setDocument(pdfDocument);
  9010. }
  9011. if (pdfDocument.loadingParams.disableAutoFetch || pagesCount > 7500) {
  9012. _this2._pagesCapability.resolve();
  9013. return;
  9014. }
  9015. var getPagesLeft = pagesCount - 1;
  9016. if (getPagesLeft <= 0) {
  9017. _this2._pagesCapability.resolve();
  9018. return;
  9019. }
  9020. var _loop = function _loop(_pageNum) {
  9021. pdfDocument.getPage(_pageNum).then(function (pdfPage) {
  9022. var pageView = _this2._pages[_pageNum - 1];
  9023. if (!pageView.pdfPage) {
  9024. pageView.setPdfPage(pdfPage);
  9025. }
  9026. _this2.linkService.cachePageRef(_pageNum, pdfPage.ref);
  9027. if (--getPagesLeft === 0) {
  9028. _this2._pagesCapability.resolve();
  9029. }
  9030. }, function (reason) {
  9031. console.error("Unable to get page ".concat(_pageNum, " to initialize viewer"), reason);
  9032. if (--getPagesLeft === 0) {
  9033. _this2._pagesCapability.resolve();
  9034. }
  9035. });
  9036. };
  9037. for (var _pageNum = 2; _pageNum <= pagesCount; ++_pageNum) {
  9038. _loop(_pageNum);
  9039. }
  9040. });
  9041. _this2.eventBus.dispatch("pagesinit", {
  9042. source: _this2
  9043. });
  9044. if (_this2.defaultRenderingQueue) {
  9045. _this2.update();
  9046. }
  9047. })["catch"](function (reason) {
  9048. console.error("Unable to initialize viewer", reason);
  9049. });
  9050. }
  9051. }, {
  9052. key: "setPageLabels",
  9053. value: function setPageLabels(labels) {
  9054. if (!this.pdfDocument) {
  9055. return;
  9056. }
  9057. if (!labels) {
  9058. this._pageLabels = null;
  9059. } else if (!(Array.isArray(labels) && this.pdfDocument.numPages === labels.length)) {
  9060. this._pageLabels = null;
  9061. console.error("".concat(this._name, ".setPageLabels: Invalid page labels."));
  9062. } else {
  9063. this._pageLabels = labels;
  9064. }
  9065. for (var i = 0, ii = this._pages.length; i < ii; i++) {
  9066. var pageView = this._pages[i];
  9067. var label = this._pageLabels && this._pageLabels[i];
  9068. pageView.setPageLabel(label);
  9069. }
  9070. }
  9071. }, {
  9072. key: "_resetView",
  9073. value: function _resetView() {
  9074. this._pages = [];
  9075. this._currentPageNumber = 1;
  9076. this._currentScale = _ui_utils.UNKNOWN_SCALE;
  9077. this._currentScaleValue = null;
  9078. this._pageLabels = null;
  9079. this._buffer = new PDFPageViewBuffer(DEFAULT_CACHE_SIZE);
  9080. this._location = null;
  9081. this._pagesRotation = 0;
  9082. this._pagesRequests = new WeakMap();
  9083. this._firstPageCapability = (0, _pdfjsLib.createPromiseCapability)();
  9084. this._onePageRenderedCapability = (0, _pdfjsLib.createPromiseCapability)();
  9085. this._pagesCapability = (0, _pdfjsLib.createPromiseCapability)();
  9086. this._scrollMode = _ui_utils.ScrollMode.VERTICAL;
  9087. this._spreadMode = _ui_utils.SpreadMode.NONE;
  9088. if (this._onBeforeDraw) {
  9089. this.eventBus._off("pagerender", this._onBeforeDraw);
  9090. this._onBeforeDraw = null;
  9091. }
  9092. if (this._onAfterDraw) {
  9093. this.eventBus._off("pagerendered", this._onAfterDraw);
  9094. this._onAfterDraw = null;
  9095. }
  9096. this.viewer.textContent = "";
  9097. this._updateScrollMode();
  9098. }
  9099. }, {
  9100. key: "_scrollUpdate",
  9101. value: function _scrollUpdate() {
  9102. if (this.pagesCount === 0) {
  9103. return;
  9104. }
  9105. this.update();
  9106. }
  9107. }, {
  9108. key: "_scrollIntoView",
  9109. value: function _scrollIntoView(_ref) {
  9110. var pageDiv = _ref.pageDiv,
  9111. _ref$pageSpot = _ref.pageSpot,
  9112. pageSpot = _ref$pageSpot === void 0 ? null : _ref$pageSpot,
  9113. _ref$pageNumber = _ref.pageNumber,
  9114. pageNumber = _ref$pageNumber === void 0 ? null : _ref$pageNumber;
  9115. (0, _ui_utils.scrollIntoView)(pageDiv, pageSpot);
  9116. }
  9117. }, {
  9118. key: "_setScaleUpdatePages",
  9119. value: function _setScaleUpdatePages(newScale, newValue) {
  9120. var noScroll = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  9121. var preset = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
  9122. this._currentScaleValue = newValue.toString();
  9123. if (isSameScale(this._currentScale, newScale)) {
  9124. if (preset) {
  9125. this.eventBus.dispatch("scalechanging", {
  9126. source: this,
  9127. scale: newScale,
  9128. presetValue: newValue
  9129. });
  9130. }
  9131. return;
  9132. }
  9133. for (var i = 0, ii = this._pages.length; i < ii; i++) {
  9134. this._pages[i].update(newScale);
  9135. }
  9136. this._currentScale = newScale;
  9137. if (!noScroll) {
  9138. var page = this._currentPageNumber,
  9139. dest;
  9140. if (this._location && !(this.isInPresentationMode || this.isChangingPresentationMode)) {
  9141. page = this._location.pageNumber;
  9142. dest = [null, {
  9143. name: "XYZ"
  9144. }, this._location.left, this._location.top, null];
  9145. }
  9146. this.scrollPageIntoView({
  9147. pageNumber: page,
  9148. destArray: dest,
  9149. allowNegativeOffset: true
  9150. });
  9151. }
  9152. this.eventBus.dispatch("scalechanging", {
  9153. source: this,
  9154. scale: newScale,
  9155. presetValue: preset ? newValue : undefined
  9156. });
  9157. if (this.defaultRenderingQueue) {
  9158. this.update();
  9159. }
  9160. }
  9161. }, {
  9162. key: "_setScale",
  9163. value: function _setScale(value) {
  9164. var noScroll = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  9165. var scale = parseFloat(value);
  9166. if (scale > 0) {
  9167. this._setScaleUpdatePages(scale, value, noScroll, false);
  9168. } else {
  9169. var currentPage = this._pages[this._currentPageNumber - 1];
  9170. if (!currentPage) {
  9171. return;
  9172. }
  9173. var noPadding = this.isInPresentationMode || this.removePageBorders;
  9174. var hPadding = noPadding ? 0 : _ui_utils.SCROLLBAR_PADDING;
  9175. var vPadding = noPadding ? 0 : _ui_utils.VERTICAL_PADDING;
  9176. if (!noPadding && this._isScrollModeHorizontal) {
  9177. var _ref2 = [vPadding, hPadding];
  9178. hPadding = _ref2[0];
  9179. vPadding = _ref2[1];
  9180. }
  9181. var pageWidthScale = (this.container.clientWidth - hPadding) / currentPage.width * currentPage.scale;
  9182. var pageHeightScale = (this.container.clientHeight - vPadding) / currentPage.height * currentPage.scale;
  9183. switch (value) {
  9184. case "page-actual":
  9185. scale = 1;
  9186. break;
  9187. case "page-width":
  9188. scale = pageWidthScale;
  9189. break;
  9190. case "page-height":
  9191. scale = pageHeightScale;
  9192. break;
  9193. case "page-fit":
  9194. scale = Math.min(pageWidthScale, pageHeightScale);
  9195. break;
  9196. case "auto":
  9197. var horizontalScale = (0, _ui_utils.isPortraitOrientation)(currentPage) ? pageWidthScale : Math.min(pageHeightScale, pageWidthScale);
  9198. scale = Math.min(_ui_utils.MAX_AUTO_SCALE, horizontalScale);
  9199. break;
  9200. default:
  9201. console.error("".concat(this._name, "._setScale: \"").concat(value, "\" is an unknown zoom value."));
  9202. return;
  9203. }
  9204. this._setScaleUpdatePages(scale, value, noScroll, true);
  9205. }
  9206. }
  9207. }, {
  9208. key: "_resetCurrentPageView",
  9209. value: function _resetCurrentPageView() {
  9210. if (this.isInPresentationMode) {
  9211. this._setScale(this._currentScaleValue, true);
  9212. }
  9213. var pageView = this._pages[this._currentPageNumber - 1];
  9214. this._scrollIntoView({
  9215. pageDiv: pageView.div
  9216. });
  9217. }
  9218. }, {
  9219. key: "scrollPageIntoView",
  9220. value: function scrollPageIntoView(_ref3) {
  9221. var pageNumber = _ref3.pageNumber,
  9222. _ref3$destArray = _ref3.destArray,
  9223. destArray = _ref3$destArray === void 0 ? null : _ref3$destArray,
  9224. _ref3$allowNegativeOf = _ref3.allowNegativeOffset,
  9225. allowNegativeOffset = _ref3$allowNegativeOf === void 0 ? false : _ref3$allowNegativeOf,
  9226. _ref3$ignoreDestinati = _ref3.ignoreDestinationZoom,
  9227. ignoreDestinationZoom = _ref3$ignoreDestinati === void 0 ? false : _ref3$ignoreDestinati;
  9228. if (!this.pdfDocument) {
  9229. return;
  9230. }
  9231. var pageView = Number.isInteger(pageNumber) && this._pages[pageNumber - 1];
  9232. if (!pageView) {
  9233. console.error("".concat(this._name, ".scrollPageIntoView: ") + "\"".concat(pageNumber, "\" is not a valid pageNumber parameter."));
  9234. return;
  9235. }
  9236. if (this.isInPresentationMode || !destArray) {
  9237. this._setCurrentPageNumber(pageNumber, true);
  9238. return;
  9239. }
  9240. var x = 0,
  9241. y = 0;
  9242. var width = 0,
  9243. height = 0,
  9244. widthScale,
  9245. heightScale;
  9246. var changeOrientation = pageView.rotation % 180 !== 0;
  9247. var pageWidth = (changeOrientation ? pageView.height : pageView.width) / pageView.scale / _ui_utils.CSS_UNITS;
  9248. var pageHeight = (changeOrientation ? pageView.width : pageView.height) / pageView.scale / _ui_utils.CSS_UNITS;
  9249. var scale = 0;
  9250. switch (destArray[1].name) {
  9251. case "XYZ":
  9252. x = destArray[2];
  9253. y = destArray[3];
  9254. scale = destArray[4];
  9255. x = x !== null ? x : 0;
  9256. y = y !== null ? y : pageHeight;
  9257. break;
  9258. case "Fit":
  9259. case "FitB":
  9260. scale = "page-fit";
  9261. break;
  9262. case "FitH":
  9263. case "FitBH":
  9264. y = destArray[2];
  9265. scale = "page-width";
  9266. if (y === null && this._location) {
  9267. x = this._location.left;
  9268. y = this._location.top;
  9269. }
  9270. break;
  9271. case "FitV":
  9272. case "FitBV":
  9273. x = destArray[2];
  9274. width = pageWidth;
  9275. height = pageHeight;
  9276. scale = "page-height";
  9277. break;
  9278. case "FitR":
  9279. x = destArray[2];
  9280. y = destArray[3];
  9281. width = destArray[4] - x;
  9282. height = destArray[5] - y;
  9283. var hPadding = this.removePageBorders ? 0 : _ui_utils.SCROLLBAR_PADDING;
  9284. var vPadding = this.removePageBorders ? 0 : _ui_utils.VERTICAL_PADDING;
  9285. widthScale = (this.container.clientWidth - hPadding) / width / _ui_utils.CSS_UNITS;
  9286. heightScale = (this.container.clientHeight - vPadding) / height / _ui_utils.CSS_UNITS;
  9287. scale = Math.min(Math.abs(widthScale), Math.abs(heightScale));
  9288. break;
  9289. default:
  9290. console.error("".concat(this._name, ".scrollPageIntoView: ") + "\"".concat(destArray[1].name, "\" is not a valid destination type."));
  9291. return;
  9292. }
  9293. if (!ignoreDestinationZoom) {
  9294. if (scale && scale !== this._currentScale) {
  9295. this.currentScaleValue = scale;
  9296. } else if (this._currentScale === _ui_utils.UNKNOWN_SCALE) {
  9297. this.currentScaleValue = _ui_utils.DEFAULT_SCALE_VALUE;
  9298. }
  9299. }
  9300. if (scale === "page-fit" && !destArray[4]) {
  9301. this._scrollIntoView({
  9302. pageDiv: pageView.div,
  9303. pageNumber: pageNumber
  9304. });
  9305. return;
  9306. }
  9307. var boundingRect = [pageView.viewport.convertToViewportPoint(x, y), pageView.viewport.convertToViewportPoint(x + width, y + height)];
  9308. var left = Math.min(boundingRect[0][0], boundingRect[1][0]);
  9309. var top = Math.min(boundingRect[0][1], boundingRect[1][1]);
  9310. if (!allowNegativeOffset) {
  9311. left = Math.max(left, 0);
  9312. top = Math.max(top, 0);
  9313. }
  9314. this._scrollIntoView({
  9315. pageDiv: pageView.div,
  9316. pageSpot: {
  9317. left: left,
  9318. top: top
  9319. },
  9320. pageNumber: pageNumber
  9321. });
  9322. }
  9323. }, {
  9324. key: "_updateLocation",
  9325. value: function _updateLocation(firstPage) {
  9326. var currentScale = this._currentScale;
  9327. var currentScaleValue = this._currentScaleValue;
  9328. var normalizedScaleValue = parseFloat(currentScaleValue) === currentScale ? Math.round(currentScale * 10000) / 100 : currentScaleValue;
  9329. var pageNumber = firstPage.id;
  9330. var pdfOpenParams = "#page=" + pageNumber;
  9331. pdfOpenParams += "&zoom=" + normalizedScaleValue;
  9332. var currentPageView = this._pages[pageNumber - 1];
  9333. var container = this.container;
  9334. var topLeft = currentPageView.getPagePoint(container.scrollLeft - firstPage.x, container.scrollTop - firstPage.y);
  9335. var intLeft = Math.round(topLeft[0]);
  9336. var intTop = Math.round(topLeft[1]);
  9337. pdfOpenParams += "," + intLeft + "," + intTop;
  9338. this._location = {
  9339. pageNumber: pageNumber,
  9340. scale: normalizedScaleValue,
  9341. top: intTop,
  9342. left: intLeft,
  9343. rotation: this._pagesRotation,
  9344. pdfOpenParams: pdfOpenParams
  9345. };
  9346. }
  9347. }, {
  9348. key: "_updateHelper",
  9349. value: function _updateHelper(visiblePages) {
  9350. throw new Error("Not implemented: _updateHelper");
  9351. }
  9352. }, {
  9353. key: "update",
  9354. value: function update() {
  9355. var visible = this._getVisiblePages();
  9356. var visiblePages = visible.views,
  9357. numVisiblePages = visiblePages.length;
  9358. if (numVisiblePages === 0) {
  9359. return;
  9360. }
  9361. var newCacheSize = Math.max(DEFAULT_CACHE_SIZE, 2 * numVisiblePages + 1);
  9362. this._buffer.resize(newCacheSize, visiblePages);
  9363. this.renderingQueue.renderHighestPriority(visible);
  9364. this._updateHelper(visiblePages);
  9365. this._updateLocation(visible.first);
  9366. this.eventBus.dispatch("updateviewarea", {
  9367. source: this,
  9368. location: this._location
  9369. });
  9370. }
  9371. }, {
  9372. key: "containsElement",
  9373. value: function containsElement(element) {
  9374. return this.container.contains(element);
  9375. }
  9376. }, {
  9377. key: "focus",
  9378. value: function focus() {
  9379. this.container.focus();
  9380. }
  9381. }, {
  9382. key: "_getCurrentVisiblePage",
  9383. value: function _getCurrentVisiblePage() {
  9384. if (!this.pagesCount) {
  9385. return {
  9386. views: []
  9387. };
  9388. }
  9389. var pageView = this._pages[this._currentPageNumber - 1];
  9390. var element = pageView.div;
  9391. var view = {
  9392. id: pageView.id,
  9393. x: element.offsetLeft + element.clientLeft,
  9394. y: element.offsetTop + element.clientTop,
  9395. view: pageView
  9396. };
  9397. return {
  9398. first: view,
  9399. last: view,
  9400. views: [view]
  9401. };
  9402. }
  9403. }, {
  9404. key: "_getVisiblePages",
  9405. value: function _getVisiblePages() {
  9406. return (0, _ui_utils.getVisibleElements)(this.container, this._pages, true, this._isScrollModeHorizontal);
  9407. }
  9408. }, {
  9409. key: "isPageVisible",
  9410. value: function isPageVisible(pageNumber) {
  9411. if (!this.pdfDocument) {
  9412. return false;
  9413. }
  9414. if (pageNumber < 1 || pageNumber > this.pagesCount) {
  9415. console.error("".concat(this._name, ".isPageVisible: \"").concat(pageNumber, "\" is out of bounds."));
  9416. return false;
  9417. }
  9418. return this._getVisiblePages().views.some(function (view) {
  9419. return view.id === pageNumber;
  9420. });
  9421. }
  9422. }, {
  9423. key: "cleanup",
  9424. value: function cleanup() {
  9425. for (var i = 0, ii = this._pages.length; i < ii; i++) {
  9426. if (this._pages[i] && this._pages[i].renderingState !== _pdf_rendering_queue.RenderingStates.FINISHED) {
  9427. this._pages[i].reset();
  9428. }
  9429. }
  9430. }
  9431. }, {
  9432. key: "_cancelRendering",
  9433. value: function _cancelRendering() {
  9434. for (var i = 0, ii = this._pages.length; i < ii; i++) {
  9435. if (this._pages[i]) {
  9436. this._pages[i].cancelRendering();
  9437. }
  9438. }
  9439. }
  9440. }, {
  9441. key: "_ensurePdfPageLoaded",
  9442. value: function _ensurePdfPageLoaded(pageView) {
  9443. var _this3 = this;
  9444. if (pageView.pdfPage) {
  9445. return Promise.resolve(pageView.pdfPage);
  9446. }
  9447. if (this._pagesRequests.has(pageView)) {
  9448. return this._pagesRequests.get(pageView);
  9449. }
  9450. var promise = this.pdfDocument.getPage(pageView.id).then(function (pdfPage) {
  9451. if (!pageView.pdfPage) {
  9452. pageView.setPdfPage(pdfPage);
  9453. }
  9454. _this3._pagesRequests["delete"](pageView);
  9455. return pdfPage;
  9456. })["catch"](function (reason) {
  9457. console.error("Unable to get page for page view", reason);
  9458. _this3._pagesRequests["delete"](pageView);
  9459. });
  9460. this._pagesRequests.set(pageView, promise);
  9461. return promise;
  9462. }
  9463. }, {
  9464. key: "forceRendering",
  9465. value: function forceRendering(currentlyVisiblePages) {
  9466. var _this4 = this;
  9467. var visiblePages = currentlyVisiblePages || this._getVisiblePages();
  9468. var scrollAhead = this._isScrollModeHorizontal ? this.scroll.right : this.scroll.down;
  9469. var pageView = this.renderingQueue.getHighestPriority(visiblePages, this._pages, scrollAhead);
  9470. if (pageView) {
  9471. this._ensurePdfPageLoaded(pageView).then(function () {
  9472. _this4.renderingQueue.renderView(pageView);
  9473. });
  9474. return true;
  9475. }
  9476. return false;
  9477. }
  9478. }, {
  9479. key: "createTextLayerBuilder",
  9480. value: function createTextLayerBuilder(textLayerDiv, pageIndex, viewport) {
  9481. var enhanceTextSelection = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
  9482. var eventBus = arguments.length > 4 ? arguments[4] : undefined;
  9483. return new _text_layer_builder.TextLayerBuilder({
  9484. textLayerDiv: textLayerDiv,
  9485. eventBus: eventBus,
  9486. pageIndex: pageIndex,
  9487. viewport: viewport,
  9488. findController: this.isInPresentationMode ? null : this.findController,
  9489. enhanceTextSelection: this.isInPresentationMode ? false : enhanceTextSelection
  9490. });
  9491. }
  9492. }, {
  9493. key: "createAnnotationLayerBuilder",
  9494. value: function createAnnotationLayerBuilder(pageDiv, pdfPage) {
  9495. var imageResourcesPath = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : "";
  9496. var renderInteractiveForms = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
  9497. var l10n = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : _ui_utils.NullL10n;
  9498. return new _annotation_layer_builder.AnnotationLayerBuilder({
  9499. pageDiv: pageDiv,
  9500. pdfPage: pdfPage,
  9501. imageResourcesPath: imageResourcesPath,
  9502. renderInteractiveForms: renderInteractiveForms,
  9503. linkService: this.linkService,
  9504. downloadManager: this.downloadManager,
  9505. l10n: l10n
  9506. });
  9507. }
  9508. }, {
  9509. key: "getPagesOverview",
  9510. value: function getPagesOverview() {
  9511. var pagesOverview = this._pages.map(function (pageView) {
  9512. var viewport = pageView.pdfPage.getViewport({
  9513. scale: 1
  9514. });
  9515. return {
  9516. width: viewport.width,
  9517. height: viewport.height,
  9518. rotation: viewport.rotation
  9519. };
  9520. });
  9521. if (!this.enablePrintAutoRotate) {
  9522. return pagesOverview;
  9523. }
  9524. var isFirstPagePortrait = (0, _ui_utils.isPortraitOrientation)(pagesOverview[0]);
  9525. return pagesOverview.map(function (size) {
  9526. if (isFirstPagePortrait === (0, _ui_utils.isPortraitOrientation)(size)) {
  9527. return size;
  9528. }
  9529. return {
  9530. width: size.height,
  9531. height: size.width,
  9532. rotation: (size.rotation + 90) % 360
  9533. };
  9534. });
  9535. }
  9536. }, {
  9537. key: "_updateScrollMode",
  9538. value: function _updateScrollMode() {
  9539. var pageNumber = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
  9540. var scrollMode = this._scrollMode,
  9541. viewer = this.viewer;
  9542. viewer.classList.toggle("scrollHorizontal", scrollMode === _ui_utils.ScrollMode.HORIZONTAL);
  9543. viewer.classList.toggle("scrollWrapped", scrollMode === _ui_utils.ScrollMode.WRAPPED);
  9544. if (!this.pdfDocument || !pageNumber) {
  9545. return;
  9546. }
  9547. if (this._currentScaleValue && isNaN(this._currentScaleValue)) {
  9548. this._setScale(this._currentScaleValue, true);
  9549. }
  9550. this._setCurrentPageNumber(pageNumber, true);
  9551. this.update();
  9552. }
  9553. }, {
  9554. key: "_updateSpreadMode",
  9555. value: function _updateSpreadMode() {
  9556. var pageNumber = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
  9557. if (!this.pdfDocument) {
  9558. return;
  9559. }
  9560. var viewer = this.viewer,
  9561. pages = this._pages;
  9562. viewer.textContent = "";
  9563. if (this._spreadMode === _ui_utils.SpreadMode.NONE) {
  9564. for (var i = 0, iMax = pages.length; i < iMax; ++i) {
  9565. viewer.appendChild(pages[i].div);
  9566. }
  9567. } else {
  9568. var parity = this._spreadMode - 1;
  9569. var spread = null;
  9570. for (var _i = 0, _iMax = pages.length; _i < _iMax; ++_i) {
  9571. if (spread === null) {
  9572. spread = document.createElement("div");
  9573. spread.className = "spread";
  9574. viewer.appendChild(spread);
  9575. } else if (_i % 2 === parity) {
  9576. spread = spread.cloneNode(false);
  9577. viewer.appendChild(spread);
  9578. }
  9579. spread.appendChild(pages[_i].div);
  9580. }
  9581. }
  9582. if (!pageNumber) {
  9583. return;
  9584. }
  9585. this._setCurrentPageNumber(pageNumber, true);
  9586. this.update();
  9587. }
  9588. }, {
  9589. key: "pagesCount",
  9590. get: function get() {
  9591. return this._pages.length;
  9592. }
  9593. }, {
  9594. key: "pageViewsReady",
  9595. get: function get() {
  9596. if (!this._pagesCapability.settled) {
  9597. return false;
  9598. }
  9599. return this._pages.every(function (pageView) {
  9600. return pageView && pageView.pdfPage;
  9601. });
  9602. }
  9603. }, {
  9604. key: "currentPageNumber",
  9605. get: function get() {
  9606. return this._currentPageNumber;
  9607. },
  9608. set: function set(val) {
  9609. if (!Number.isInteger(val)) {
  9610. throw new Error("Invalid page number.");
  9611. }
  9612. if (!this.pdfDocument) {
  9613. return;
  9614. }
  9615. if (!this._setCurrentPageNumber(val, true)) {
  9616. console.error("".concat(this._name, ".currentPageNumber: \"").concat(val, "\" is not a valid page."));
  9617. }
  9618. }
  9619. }, {
  9620. key: "currentPageLabel",
  9621. get: function get() {
  9622. return this._pageLabels && this._pageLabels[this._currentPageNumber - 1];
  9623. },
  9624. set: function set(val) {
  9625. if (!this.pdfDocument) {
  9626. return;
  9627. }
  9628. var page = val | 0;
  9629. if (this._pageLabels) {
  9630. var i = this._pageLabels.indexOf(val);
  9631. if (i >= 0) {
  9632. page = i + 1;
  9633. }
  9634. }
  9635. if (!this._setCurrentPageNumber(page, true)) {
  9636. console.error("".concat(this._name, ".currentPageLabel: \"").concat(val, "\" is not a valid page."));
  9637. }
  9638. }
  9639. }, {
  9640. key: "currentScale",
  9641. get: function get() {
  9642. return this._currentScale !== _ui_utils.UNKNOWN_SCALE ? this._currentScale : _ui_utils.DEFAULT_SCALE;
  9643. },
  9644. set: function set(val) {
  9645. if (isNaN(val)) {
  9646. throw new Error("Invalid numeric scale.");
  9647. }
  9648. if (!this.pdfDocument) {
  9649. return;
  9650. }
  9651. this._setScale(val, false);
  9652. }
  9653. }, {
  9654. key: "currentScaleValue",
  9655. get: function get() {
  9656. return this._currentScaleValue;
  9657. },
  9658. set: function set(val) {
  9659. if (!this.pdfDocument) {
  9660. return;
  9661. }
  9662. this._setScale(val, false);
  9663. }
  9664. }, {
  9665. key: "pagesRotation",
  9666. get: function get() {
  9667. return this._pagesRotation;
  9668. },
  9669. set: function set(rotation) {
  9670. if (!(0, _ui_utils.isValidRotation)(rotation)) {
  9671. throw new Error("Invalid pages rotation angle.");
  9672. }
  9673. if (!this.pdfDocument) {
  9674. return;
  9675. }
  9676. if (this._pagesRotation === rotation) {
  9677. return;
  9678. }
  9679. this._pagesRotation = rotation;
  9680. var pageNumber = this._currentPageNumber;
  9681. for (var i = 0, ii = this._pages.length; i < ii; i++) {
  9682. var pageView = this._pages[i];
  9683. pageView.update(pageView.scale, rotation);
  9684. }
  9685. if (this._currentScaleValue) {
  9686. this._setScale(this._currentScaleValue, true);
  9687. }
  9688. this.eventBus.dispatch("rotationchanging", {
  9689. source: this,
  9690. pagesRotation: rotation,
  9691. pageNumber: pageNumber
  9692. });
  9693. if (this.defaultRenderingQueue) {
  9694. this.update();
  9695. }
  9696. }
  9697. }, {
  9698. key: "firstPagePromise",
  9699. get: function get() {
  9700. return this.pdfDocument ? this._firstPageCapability.promise : null;
  9701. }
  9702. }, {
  9703. key: "onePageRendered",
  9704. get: function get() {
  9705. return this.pdfDocument ? this._onePageRenderedCapability.promise : null;
  9706. }
  9707. }, {
  9708. key: "pagesPromise",
  9709. get: function get() {
  9710. return this.pdfDocument ? this._pagesCapability.promise : null;
  9711. }
  9712. }, {
  9713. key: "_viewerElement",
  9714. get: function get() {
  9715. throw new Error("Not implemented: _viewerElement");
  9716. }
  9717. }, {
  9718. key: "_isScrollModeHorizontal",
  9719. get: function get() {
  9720. return this.isInPresentationMode ? false : this._scrollMode === _ui_utils.ScrollMode.HORIZONTAL;
  9721. }
  9722. }, {
  9723. key: "isInPresentationMode",
  9724. get: function get() {
  9725. return this.presentationModeState === _ui_utils.PresentationModeState.FULLSCREEN;
  9726. }
  9727. }, {
  9728. key: "isChangingPresentationMode",
  9729. get: function get() {
  9730. return this.presentationModeState === _ui_utils.PresentationModeState.CHANGING;
  9731. }
  9732. }, {
  9733. key: "isHorizontalScrollbarEnabled",
  9734. get: function get() {
  9735. return this.isInPresentationMode ? false : this.container.scrollWidth > this.container.clientWidth;
  9736. }
  9737. }, {
  9738. key: "isVerticalScrollbarEnabled",
  9739. get: function get() {
  9740. return this.isInPresentationMode ? false : this.container.scrollHeight > this.container.clientHeight;
  9741. }
  9742. }, {
  9743. key: "hasEqualPageSizes",
  9744. get: function get() {
  9745. var firstPageView = this._pages[0];
  9746. for (var i = 1, ii = this._pages.length; i < ii; ++i) {
  9747. var pageView = this._pages[i];
  9748. if (pageView.width !== firstPageView.width || pageView.height !== firstPageView.height) {
  9749. return false;
  9750. }
  9751. }
  9752. return true;
  9753. }
  9754. }, {
  9755. key: "scrollMode",
  9756. get: function get() {
  9757. return this._scrollMode;
  9758. },
  9759. set: function set(mode) {
  9760. if (this._scrollMode === mode) {
  9761. return;
  9762. }
  9763. if (!(0, _ui_utils.isValidScrollMode)(mode)) {
  9764. throw new Error("Invalid scroll mode: ".concat(mode));
  9765. }
  9766. this._scrollMode = mode;
  9767. this.eventBus.dispatch("scrollmodechanged", {
  9768. source: this,
  9769. mode: mode
  9770. });
  9771. this._updateScrollMode(this._currentPageNumber);
  9772. }
  9773. }, {
  9774. key: "spreadMode",
  9775. get: function get() {
  9776. return this._spreadMode;
  9777. },
  9778. set: function set(mode) {
  9779. if (this._spreadMode === mode) {
  9780. return;
  9781. }
  9782. if (!(0, _ui_utils.isValidSpreadMode)(mode)) {
  9783. throw new Error("Invalid spread mode: ".concat(mode));
  9784. }
  9785. this._spreadMode = mode;
  9786. this.eventBus.dispatch("spreadmodechanged", {
  9787. source: this,
  9788. mode: mode
  9789. });
  9790. this._updateSpreadMode(this._currentPageNumber);
  9791. }
  9792. }]);
  9793. return BaseViewer;
  9794. }();
  9795. exports.BaseViewer = BaseViewer;
  9796. /***/ }),
  9797. /* 29 */
  9798. /***/ (function(module, exports, __webpack_require__) {
  9799. "use strict";
  9800. Object.defineProperty(exports, "__esModule", {
  9801. value: true
  9802. });
  9803. exports.DefaultAnnotationLayerFactory = exports.AnnotationLayerBuilder = void 0;
  9804. var _pdfjsLib = __webpack_require__(8);
  9805. var _ui_utils = __webpack_require__(5);
  9806. var _pdf_link_service = __webpack_require__(21);
  9807. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  9808. 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); } }
  9809. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  9810. var AnnotationLayerBuilder = /*#__PURE__*/function () {
  9811. function AnnotationLayerBuilder(_ref) {
  9812. var pageDiv = _ref.pageDiv,
  9813. pdfPage = _ref.pdfPage,
  9814. linkService = _ref.linkService,
  9815. downloadManager = _ref.downloadManager,
  9816. _ref$imageResourcesPa = _ref.imageResourcesPath,
  9817. imageResourcesPath = _ref$imageResourcesPa === void 0 ? "" : _ref$imageResourcesPa,
  9818. _ref$renderInteractiv = _ref.renderInteractiveForms,
  9819. renderInteractiveForms = _ref$renderInteractiv === void 0 ? false : _ref$renderInteractiv,
  9820. _ref$l10n = _ref.l10n,
  9821. l10n = _ref$l10n === void 0 ? _ui_utils.NullL10n : _ref$l10n;
  9822. _classCallCheck(this, AnnotationLayerBuilder);
  9823. this.pageDiv = pageDiv;
  9824. this.pdfPage = pdfPage;
  9825. this.linkService = linkService;
  9826. this.downloadManager = downloadManager;
  9827. this.imageResourcesPath = imageResourcesPath;
  9828. this.renderInteractiveForms = renderInteractiveForms;
  9829. this.l10n = l10n;
  9830. this.div = null;
  9831. this._cancelled = false;
  9832. }
  9833. _createClass(AnnotationLayerBuilder, [{
  9834. key: "render",
  9835. value: function render(viewport) {
  9836. var _this = this;
  9837. var intent = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "display";
  9838. this.pdfPage.getAnnotations({
  9839. intent: intent
  9840. }).then(function (annotations) {
  9841. if (_this._cancelled) {
  9842. return;
  9843. }
  9844. var parameters = {
  9845. viewport: viewport.clone({
  9846. dontFlip: true
  9847. }),
  9848. div: _this.div,
  9849. annotations: annotations,
  9850. page: _this.pdfPage,
  9851. imageResourcesPath: _this.imageResourcesPath,
  9852. renderInteractiveForms: _this.renderInteractiveForms,
  9853. linkService: _this.linkService,
  9854. downloadManager: _this.downloadManager
  9855. };
  9856. if (_this.div) {
  9857. _pdfjsLib.AnnotationLayer.update(parameters);
  9858. } else {
  9859. if (annotations.length === 0) {
  9860. return;
  9861. }
  9862. _this.div = document.createElement("div");
  9863. _this.div.className = "annotationLayer";
  9864. _this.pageDiv.appendChild(_this.div);
  9865. parameters.div = _this.div;
  9866. _pdfjsLib.AnnotationLayer.render(parameters);
  9867. _this.l10n.translate(_this.div);
  9868. }
  9869. });
  9870. }
  9871. }, {
  9872. key: "cancel",
  9873. value: function cancel() {
  9874. this._cancelled = true;
  9875. }
  9876. }, {
  9877. key: "hide",
  9878. value: function hide() {
  9879. if (!this.div) {
  9880. return;
  9881. }
  9882. this.div.setAttribute("hidden", "true");
  9883. }
  9884. }]);
  9885. return AnnotationLayerBuilder;
  9886. }();
  9887. exports.AnnotationLayerBuilder = AnnotationLayerBuilder;
  9888. var DefaultAnnotationLayerFactory = /*#__PURE__*/function () {
  9889. function DefaultAnnotationLayerFactory() {
  9890. _classCallCheck(this, DefaultAnnotationLayerFactory);
  9891. }
  9892. _createClass(DefaultAnnotationLayerFactory, [{
  9893. key: "createAnnotationLayerBuilder",
  9894. value: function createAnnotationLayerBuilder(pageDiv, pdfPage) {
  9895. var imageResourcesPath = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : "";
  9896. var renderInteractiveForms = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
  9897. var l10n = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : _ui_utils.NullL10n;
  9898. return new AnnotationLayerBuilder({
  9899. pageDiv: pageDiv,
  9900. pdfPage: pdfPage,
  9901. imageResourcesPath: imageResourcesPath,
  9902. renderInteractiveForms: renderInteractiveForms,
  9903. linkService: new _pdf_link_service.SimpleLinkService(),
  9904. l10n: l10n
  9905. });
  9906. }
  9907. }]);
  9908. return DefaultAnnotationLayerFactory;
  9909. }();
  9910. exports.DefaultAnnotationLayerFactory = DefaultAnnotationLayerFactory;
  9911. /***/ }),
  9912. /* 30 */
  9913. /***/ (function(module, exports, __webpack_require__) {
  9914. "use strict";
  9915. Object.defineProperty(exports, "__esModule", {
  9916. value: true
  9917. });
  9918. exports.PDFPageView = void 0;
  9919. var _regenerator = _interopRequireDefault(__webpack_require__(2));
  9920. var _ui_utils = __webpack_require__(5);
  9921. var _pdfjsLib = __webpack_require__(8);
  9922. var _pdf_rendering_queue = __webpack_require__(11);
  9923. var _viewer_compatibility = __webpack_require__(7);
  9924. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  9925. 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); } }
  9926. 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); }); }; }
  9927. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  9928. 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); } }
  9929. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  9930. var MAX_CANVAS_PIXELS = _viewer_compatibility.viewerCompatibilityParams.maxCanvasPixels || 16777216;
  9931. var PDFPageView = /*#__PURE__*/function () {
  9932. function PDFPageView(options) {
  9933. _classCallCheck(this, PDFPageView);
  9934. var container = options.container;
  9935. var defaultViewport = options.defaultViewport;
  9936. this.id = options.id;
  9937. this.renderingId = "page" + this.id;
  9938. this.pdfPage = null;
  9939. this.pageLabel = null;
  9940. this.rotation = 0;
  9941. this.scale = options.scale || _ui_utils.DEFAULT_SCALE;
  9942. this.viewport = defaultViewport;
  9943. this.pdfPageRotate = defaultViewport.rotation;
  9944. this.hasRestrictedScaling = false;
  9945. this.textLayerMode = Number.isInteger(options.textLayerMode) ? options.textLayerMode : _ui_utils.TextLayerMode.ENABLE;
  9946. this.imageResourcesPath = options.imageResourcesPath || "";
  9947. this.renderInteractiveForms = options.renderInteractiveForms || false;
  9948. this.useOnlyCssZoom = options.useOnlyCssZoom || false;
  9949. this.maxCanvasPixels = options.maxCanvasPixels || MAX_CANVAS_PIXELS;
  9950. this.eventBus = options.eventBus;
  9951. this.renderingQueue = options.renderingQueue;
  9952. this.textLayerFactory = options.textLayerFactory;
  9953. this.annotationLayerFactory = options.annotationLayerFactory;
  9954. this.renderer = options.renderer || _ui_utils.RendererType.CANVAS;
  9955. this.enableWebGL = options.enableWebGL || false;
  9956. this.l10n = options.l10n || _ui_utils.NullL10n;
  9957. this.paintTask = null;
  9958. this.paintedViewportMap = new WeakMap();
  9959. this.renderingState = _pdf_rendering_queue.RenderingStates.INITIAL;
  9960. this.resume = null;
  9961. this.error = null;
  9962. this.annotationLayer = null;
  9963. this.textLayer = null;
  9964. this.zoomLayer = null;
  9965. var div = document.createElement("div");
  9966. div.className = "page";
  9967. div.style.width = Math.floor(this.viewport.width) + "px";
  9968. div.style.height = Math.floor(this.viewport.height) + "px";
  9969. div.setAttribute("data-page-number", this.id);
  9970. this.div = div;
  9971. container.appendChild(div);
  9972. }
  9973. _createClass(PDFPageView, [{
  9974. key: "setPdfPage",
  9975. value: function setPdfPage(pdfPage) {
  9976. this.pdfPage = pdfPage;
  9977. this.pdfPageRotate = pdfPage.rotate;
  9978. var totalRotation = (this.rotation + this.pdfPageRotate) % 360;
  9979. this.viewport = pdfPage.getViewport({
  9980. scale: this.scale * _ui_utils.CSS_UNITS,
  9981. rotation: totalRotation
  9982. });
  9983. this.stats = pdfPage.stats;
  9984. this.reset();
  9985. }
  9986. }, {
  9987. key: "destroy",
  9988. value: function destroy() {
  9989. this.reset();
  9990. if (this.pdfPage) {
  9991. this.pdfPage.cleanup();
  9992. }
  9993. }
  9994. }, {
  9995. key: "_resetZoomLayer",
  9996. value: function _resetZoomLayer() {
  9997. var removeFromDOM = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  9998. if (!this.zoomLayer) {
  9999. return;
  10000. }
  10001. var zoomLayerCanvas = this.zoomLayer.firstChild;
  10002. this.paintedViewportMap["delete"](zoomLayerCanvas);
  10003. zoomLayerCanvas.width = 0;
  10004. zoomLayerCanvas.height = 0;
  10005. if (removeFromDOM) {
  10006. this.zoomLayer.remove();
  10007. }
  10008. this.zoomLayer = null;
  10009. }
  10010. }, {
  10011. key: "reset",
  10012. value: function reset() {
  10013. var keepZoomLayer = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  10014. var keepAnnotations = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  10015. this.cancelRendering(keepAnnotations);
  10016. this.renderingState = _pdf_rendering_queue.RenderingStates.INITIAL;
  10017. var div = this.div;
  10018. div.style.width = Math.floor(this.viewport.width) + "px";
  10019. div.style.height = Math.floor(this.viewport.height) + "px";
  10020. var childNodes = div.childNodes;
  10021. var currentZoomLayerNode = keepZoomLayer && this.zoomLayer || null;
  10022. var currentAnnotationNode = keepAnnotations && this.annotationLayer && this.annotationLayer.div || null;
  10023. for (var i = childNodes.length - 1; i >= 0; i--) {
  10024. var node = childNodes[i];
  10025. if (currentZoomLayerNode === node || currentAnnotationNode === node) {
  10026. continue;
  10027. }
  10028. div.removeChild(node);
  10029. }
  10030. div.removeAttribute("data-loaded");
  10031. if (currentAnnotationNode) {
  10032. this.annotationLayer.hide();
  10033. } else if (this.annotationLayer) {
  10034. this.annotationLayer.cancel();
  10035. this.annotationLayer = null;
  10036. }
  10037. if (!currentZoomLayerNode) {
  10038. if (this.canvas) {
  10039. this.paintedViewportMap["delete"](this.canvas);
  10040. this.canvas.width = 0;
  10041. this.canvas.height = 0;
  10042. delete this.canvas;
  10043. }
  10044. this._resetZoomLayer();
  10045. }
  10046. if (this.svg) {
  10047. this.paintedViewportMap["delete"](this.svg);
  10048. delete this.svg;
  10049. }
  10050. this.loadingIconDiv = document.createElement("div");
  10051. this.loadingIconDiv.className = "loadingIcon";
  10052. div.appendChild(this.loadingIconDiv);
  10053. }
  10054. }, {
  10055. key: "update",
  10056. value: function update(scale, rotation) {
  10057. this.scale = scale || this.scale;
  10058. if (typeof rotation !== "undefined") {
  10059. this.rotation = rotation;
  10060. }
  10061. var totalRotation = (this.rotation + this.pdfPageRotate) % 360;
  10062. this.viewport = this.viewport.clone({
  10063. scale: this.scale * _ui_utils.CSS_UNITS,
  10064. rotation: totalRotation
  10065. });
  10066. if (this.svg) {
  10067. this.cssTransform(this.svg, true);
  10068. this.eventBus.dispatch("pagerendered", {
  10069. source: this,
  10070. pageNumber: this.id,
  10071. cssTransform: true,
  10072. timestamp: performance.now()
  10073. });
  10074. return;
  10075. }
  10076. var isScalingRestricted = false;
  10077. if (this.canvas && this.maxCanvasPixels > 0) {
  10078. var outputScale = this.outputScale;
  10079. if ((Math.floor(this.viewport.width) * outputScale.sx | 0) * (Math.floor(this.viewport.height) * outputScale.sy | 0) > this.maxCanvasPixels) {
  10080. isScalingRestricted = true;
  10081. }
  10082. }
  10083. if (this.canvas) {
  10084. if (this.useOnlyCssZoom || this.hasRestrictedScaling && isScalingRestricted) {
  10085. this.cssTransform(this.canvas, true);
  10086. this.eventBus.dispatch("pagerendered", {
  10087. source: this,
  10088. pageNumber: this.id,
  10089. cssTransform: true,
  10090. timestamp: performance.now()
  10091. });
  10092. return;
  10093. }
  10094. if (!this.zoomLayer && !this.canvas.hasAttribute("hidden")) {
  10095. this.zoomLayer = this.canvas.parentNode;
  10096. this.zoomLayer.style.position = "absolute";
  10097. }
  10098. }
  10099. if (this.zoomLayer) {
  10100. this.cssTransform(this.zoomLayer.firstChild);
  10101. }
  10102. this.reset(true, true);
  10103. }
  10104. }, {
  10105. key: "cancelRendering",
  10106. value: function cancelRendering() {
  10107. var keepAnnotations = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  10108. if (this.paintTask) {
  10109. this.paintTask.cancel();
  10110. this.paintTask = null;
  10111. }
  10112. this.resume = null;
  10113. if (this.textLayer) {
  10114. this.textLayer.cancel();
  10115. this.textLayer = null;
  10116. }
  10117. if (!keepAnnotations && this.annotationLayer) {
  10118. this.annotationLayer.cancel();
  10119. this.annotationLayer = null;
  10120. }
  10121. }
  10122. }, {
  10123. key: "cssTransform",
  10124. value: function cssTransform(target) {
  10125. var redrawAnnotations = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  10126. var width = this.viewport.width;
  10127. var height = this.viewport.height;
  10128. var div = this.div;
  10129. target.style.width = target.parentNode.style.width = div.style.width = Math.floor(width) + "px";
  10130. target.style.height = target.parentNode.style.height = div.style.height = Math.floor(height) + "px";
  10131. var relativeRotation = this.viewport.rotation - this.paintedViewportMap.get(target).rotation;
  10132. var absRotation = Math.abs(relativeRotation);
  10133. var scaleX = 1,
  10134. scaleY = 1;
  10135. if (absRotation === 90 || absRotation === 270) {
  10136. scaleX = height / width;
  10137. scaleY = width / height;
  10138. }
  10139. var cssTransform = "rotate(" + relativeRotation + "deg) " + "scale(" + scaleX + "," + scaleY + ")";
  10140. target.style.transform = cssTransform;
  10141. if (this.textLayer) {
  10142. var textLayerViewport = this.textLayer.viewport;
  10143. var textRelativeRotation = this.viewport.rotation - textLayerViewport.rotation;
  10144. var textAbsRotation = Math.abs(textRelativeRotation);
  10145. var scale = width / textLayerViewport.width;
  10146. if (textAbsRotation === 90 || textAbsRotation === 270) {
  10147. scale = width / textLayerViewport.height;
  10148. }
  10149. var textLayerDiv = this.textLayer.textLayerDiv;
  10150. var transX, transY;
  10151. switch (textAbsRotation) {
  10152. case 0:
  10153. transX = transY = 0;
  10154. break;
  10155. case 90:
  10156. transX = 0;
  10157. transY = "-" + textLayerDiv.style.height;
  10158. break;
  10159. case 180:
  10160. transX = "-" + textLayerDiv.style.width;
  10161. transY = "-" + textLayerDiv.style.height;
  10162. break;
  10163. case 270:
  10164. transX = "-" + textLayerDiv.style.width;
  10165. transY = 0;
  10166. break;
  10167. default:
  10168. console.error("Bad rotation value.");
  10169. break;
  10170. }
  10171. textLayerDiv.style.transform = "rotate(" + textAbsRotation + "deg) " + "scale(" + scale + ", " + scale + ") " + "translate(" + transX + ", " + transY + ")";
  10172. textLayerDiv.style.transformOrigin = "0% 0%";
  10173. }
  10174. if (redrawAnnotations && this.annotationLayer) {
  10175. this.annotationLayer.render(this.viewport, "display");
  10176. }
  10177. }
  10178. }, {
  10179. key: "getPagePoint",
  10180. value: function getPagePoint(x, y) {
  10181. return this.viewport.convertToPdfPoint(x, y);
  10182. }
  10183. }, {
  10184. key: "draw",
  10185. value: function draw() {
  10186. var _this = this;
  10187. if (this.renderingState !== _pdf_rendering_queue.RenderingStates.INITIAL) {
  10188. console.error("Must be in new state before drawing");
  10189. this.reset();
  10190. }
  10191. var div = this.div,
  10192. pdfPage = this.pdfPage;
  10193. if (!pdfPage) {
  10194. this.renderingState = _pdf_rendering_queue.RenderingStates.FINISHED;
  10195. if (this.loadingIconDiv) {
  10196. div.removeChild(this.loadingIconDiv);
  10197. delete this.loadingIconDiv;
  10198. }
  10199. return Promise.reject(new Error("pdfPage is not loaded"));
  10200. }
  10201. this.renderingState = _pdf_rendering_queue.RenderingStates.RUNNING;
  10202. var canvasWrapper = document.createElement("div");
  10203. canvasWrapper.style.width = div.style.width;
  10204. canvasWrapper.style.height = div.style.height;
  10205. canvasWrapper.classList.add("canvasWrapper");
  10206. if (this.annotationLayer && this.annotationLayer.div) {
  10207. div.insertBefore(canvasWrapper, this.annotationLayer.div);
  10208. } else {
  10209. div.appendChild(canvasWrapper);
  10210. }
  10211. var textLayer = null;
  10212. if (this.textLayerMode !== _ui_utils.TextLayerMode.DISABLE && this.textLayerFactory) {
  10213. var textLayerDiv = document.createElement("div");
  10214. textLayerDiv.className = "textLayer";
  10215. textLayerDiv.style.width = canvasWrapper.style.width;
  10216. textLayerDiv.style.height = canvasWrapper.style.height;
  10217. if (this.annotationLayer && this.annotationLayer.div) {
  10218. div.insertBefore(textLayerDiv, this.annotationLayer.div);
  10219. } else {
  10220. div.appendChild(textLayerDiv);
  10221. }
  10222. textLayer = this.textLayerFactory.createTextLayerBuilder(textLayerDiv, this.id - 1, this.viewport, this.textLayerMode === _ui_utils.TextLayerMode.ENABLE_ENHANCE, this.eventBus);
  10223. }
  10224. this.textLayer = textLayer;
  10225. var renderContinueCallback = null;
  10226. if (this.renderingQueue) {
  10227. renderContinueCallback = function renderContinueCallback(cont) {
  10228. if (!_this.renderingQueue.isHighestPriority(_this)) {
  10229. _this.renderingState = _pdf_rendering_queue.RenderingStates.PAUSED;
  10230. _this.resume = function () {
  10231. _this.renderingState = _pdf_rendering_queue.RenderingStates.RUNNING;
  10232. cont();
  10233. };
  10234. return;
  10235. }
  10236. cont();
  10237. };
  10238. }
  10239. var finishPaintTask = /*#__PURE__*/function () {
  10240. var _ref = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee(error) {
  10241. return _regenerator["default"].wrap(function _callee$(_context) {
  10242. while (1) {
  10243. switch (_context.prev = _context.next) {
  10244. case 0:
  10245. if (paintTask === _this.paintTask) {
  10246. _this.paintTask = null;
  10247. }
  10248. if (!(error instanceof _pdfjsLib.RenderingCancelledException)) {
  10249. _context.next = 4;
  10250. break;
  10251. }
  10252. _this.error = null;
  10253. return _context.abrupt("return");
  10254. case 4:
  10255. _this.renderingState = _pdf_rendering_queue.RenderingStates.FINISHED;
  10256. if (_this.loadingIconDiv) {
  10257. div.removeChild(_this.loadingIconDiv);
  10258. delete _this.loadingIconDiv;
  10259. }
  10260. _this._resetZoomLayer(true);
  10261. _this.error = error;
  10262. _this.stats = pdfPage.stats;
  10263. _this.eventBus.dispatch("pagerendered", {
  10264. source: _this,
  10265. pageNumber: _this.id,
  10266. cssTransform: false,
  10267. timestamp: performance.now()
  10268. });
  10269. if (!error) {
  10270. _context.next = 12;
  10271. break;
  10272. }
  10273. throw error;
  10274. case 12:
  10275. case "end":
  10276. return _context.stop();
  10277. }
  10278. }
  10279. }, _callee);
  10280. }));
  10281. return function finishPaintTask(_x) {
  10282. return _ref.apply(this, arguments);
  10283. };
  10284. }();
  10285. var paintTask = this.renderer === _ui_utils.RendererType.SVG ? this.paintOnSvg(canvasWrapper) : this.paintOnCanvas(canvasWrapper);
  10286. paintTask.onRenderContinue = renderContinueCallback;
  10287. this.paintTask = paintTask;
  10288. var resultPromise = paintTask.promise.then(function () {
  10289. return finishPaintTask(null).then(function () {
  10290. if (textLayer) {
  10291. var readableStream = pdfPage.streamTextContent({
  10292. normalizeWhitespace: true
  10293. });
  10294. textLayer.setTextContentStream(readableStream);
  10295. textLayer.render();
  10296. }
  10297. });
  10298. }, function (reason) {
  10299. return finishPaintTask(reason);
  10300. });
  10301. if (this.annotationLayerFactory) {
  10302. if (!this.annotationLayer) {
  10303. this.annotationLayer = this.annotationLayerFactory.createAnnotationLayerBuilder(div, pdfPage, this.imageResourcesPath, this.renderInteractiveForms, this.l10n);
  10304. }
  10305. this.annotationLayer.render(this.viewport, "display");
  10306. }
  10307. div.setAttribute("data-loaded", true);
  10308. this.eventBus.dispatch("pagerender", {
  10309. source: this,
  10310. pageNumber: this.id
  10311. });
  10312. return resultPromise;
  10313. }
  10314. }, {
  10315. key: "paintOnCanvas",
  10316. value: function paintOnCanvas(canvasWrapper) {
  10317. var renderCapability = (0, _pdfjsLib.createPromiseCapability)();
  10318. var result = {
  10319. promise: renderCapability.promise,
  10320. onRenderContinue: function onRenderContinue(cont) {
  10321. cont();
  10322. },
  10323. cancel: function cancel() {
  10324. renderTask.cancel();
  10325. }
  10326. };
  10327. var viewport = this.viewport;
  10328. var canvas = document.createElement("canvas");
  10329. this.l10n.get("page_canvas", {
  10330. page: this.id
  10331. }, "Page {{page}}").then(function (msg) {
  10332. canvas.setAttribute("aria-label", msg);
  10333. });
  10334. canvas.setAttribute("hidden", "hidden");
  10335. var isCanvasHidden = true;
  10336. var showCanvas = function showCanvas() {
  10337. if (isCanvasHidden) {
  10338. canvas.removeAttribute("hidden");
  10339. isCanvasHidden = false;
  10340. }
  10341. };
  10342. canvasWrapper.appendChild(canvas);
  10343. this.canvas = canvas;
  10344. canvas.mozOpaque = true;
  10345. var ctx = canvas.getContext("2d", {
  10346. alpha: false
  10347. });
  10348. var outputScale = (0, _ui_utils.getOutputScale)(ctx);
  10349. this.outputScale = outputScale;
  10350. if (this.useOnlyCssZoom) {
  10351. var actualSizeViewport = viewport.clone({
  10352. scale: _ui_utils.CSS_UNITS
  10353. });
  10354. outputScale.sx *= actualSizeViewport.width / viewport.width;
  10355. outputScale.sy *= actualSizeViewport.height / viewport.height;
  10356. outputScale.scaled = true;
  10357. }
  10358. if (this.maxCanvasPixels > 0) {
  10359. var pixelsInViewport = viewport.width * viewport.height;
  10360. var maxScale = Math.sqrt(this.maxCanvasPixels / pixelsInViewport);
  10361. if (outputScale.sx > maxScale || outputScale.sy > maxScale) {
  10362. outputScale.sx = maxScale;
  10363. outputScale.sy = maxScale;
  10364. outputScale.scaled = true;
  10365. this.hasRestrictedScaling = true;
  10366. } else {
  10367. this.hasRestrictedScaling = false;
  10368. }
  10369. }
  10370. var sfx = (0, _ui_utils.approximateFraction)(outputScale.sx);
  10371. var sfy = (0, _ui_utils.approximateFraction)(outputScale.sy);
  10372. canvas.width = (0, _ui_utils.roundToDivide)(viewport.width * outputScale.sx, sfx[0]);
  10373. canvas.height = (0, _ui_utils.roundToDivide)(viewport.height * outputScale.sy, sfy[0]);
  10374. canvas.style.width = (0, _ui_utils.roundToDivide)(viewport.width, sfx[1]) + "px";
  10375. canvas.style.height = (0, _ui_utils.roundToDivide)(viewport.height, sfy[1]) + "px";
  10376. this.paintedViewportMap.set(canvas, viewport);
  10377. var transform = !outputScale.scaled ? null : [outputScale.sx, 0, 0, outputScale.sy, 0, 0];
  10378. var renderContext = {
  10379. canvasContext: ctx,
  10380. transform: transform,
  10381. viewport: this.viewport,
  10382. enableWebGL: this.enableWebGL,
  10383. renderInteractiveForms: this.renderInteractiveForms
  10384. };
  10385. var renderTask = this.pdfPage.render(renderContext);
  10386. renderTask.onContinue = function (cont) {
  10387. showCanvas();
  10388. if (result.onRenderContinue) {
  10389. result.onRenderContinue(cont);
  10390. } else {
  10391. cont();
  10392. }
  10393. };
  10394. renderTask.promise.then(function () {
  10395. showCanvas();
  10396. renderCapability.resolve(undefined);
  10397. }, function (error) {
  10398. showCanvas();
  10399. renderCapability.reject(error);
  10400. });
  10401. return result;
  10402. }
  10403. }, {
  10404. key: "paintOnSvg",
  10405. value: function paintOnSvg(wrapper) {
  10406. var _this2 = this;
  10407. var cancelled = false;
  10408. var ensureNotCancelled = function ensureNotCancelled() {
  10409. if (cancelled) {
  10410. throw new _pdfjsLib.RenderingCancelledException("Rendering cancelled, page ".concat(_this2.id), "svg");
  10411. }
  10412. };
  10413. var pdfPage = this.pdfPage;
  10414. var actualSizeViewport = this.viewport.clone({
  10415. scale: _ui_utils.CSS_UNITS
  10416. });
  10417. var promise = pdfPage.getOperatorList().then(function (opList) {
  10418. ensureNotCancelled();
  10419. var svgGfx = new _pdfjsLib.SVGGraphics(pdfPage.commonObjs, pdfPage.objs);
  10420. return svgGfx.getSVG(opList, actualSizeViewport).then(function (svg) {
  10421. ensureNotCancelled();
  10422. _this2.svg = svg;
  10423. _this2.paintedViewportMap.set(svg, actualSizeViewport);
  10424. svg.style.width = wrapper.style.width;
  10425. svg.style.height = wrapper.style.height;
  10426. _this2.renderingState = _pdf_rendering_queue.RenderingStates.FINISHED;
  10427. wrapper.appendChild(svg);
  10428. });
  10429. });
  10430. return {
  10431. promise: promise,
  10432. onRenderContinue: function onRenderContinue(cont) {
  10433. cont();
  10434. },
  10435. cancel: function cancel() {
  10436. cancelled = true;
  10437. }
  10438. };
  10439. }
  10440. }, {
  10441. key: "setPageLabel",
  10442. value: function setPageLabel(label) {
  10443. this.pageLabel = typeof label === "string" ? label : null;
  10444. if (this.pageLabel !== null) {
  10445. this.div.setAttribute("data-page-label", this.pageLabel);
  10446. } else {
  10447. this.div.removeAttribute("data-page-label");
  10448. }
  10449. }
  10450. }, {
  10451. key: "width",
  10452. get: function get() {
  10453. return this.viewport.width;
  10454. }
  10455. }, {
  10456. key: "height",
  10457. get: function get() {
  10458. return this.viewport.height;
  10459. }
  10460. }]);
  10461. return PDFPageView;
  10462. }();
  10463. exports.PDFPageView = PDFPageView;
  10464. /***/ }),
  10465. /* 31 */
  10466. /***/ (function(module, exports, __webpack_require__) {
  10467. "use strict";
  10468. Object.defineProperty(exports, "__esModule", {
  10469. value: true
  10470. });
  10471. exports.DefaultTextLayerFactory = exports.TextLayerBuilder = void 0;
  10472. var _pdfjsLib = __webpack_require__(8);
  10473. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  10474. 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); } }
  10475. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  10476. var EXPAND_DIVS_TIMEOUT = 300;
  10477. var TextLayerBuilder = /*#__PURE__*/function () {
  10478. function TextLayerBuilder(_ref) {
  10479. var textLayerDiv = _ref.textLayerDiv,
  10480. eventBus = _ref.eventBus,
  10481. pageIndex = _ref.pageIndex,
  10482. viewport = _ref.viewport,
  10483. _ref$findController = _ref.findController,
  10484. findController = _ref$findController === void 0 ? null : _ref$findController,
  10485. _ref$enhanceTextSelec = _ref.enhanceTextSelection,
  10486. enhanceTextSelection = _ref$enhanceTextSelec === void 0 ? false : _ref$enhanceTextSelec;
  10487. _classCallCheck(this, TextLayerBuilder);
  10488. this.textLayerDiv = textLayerDiv;
  10489. this.eventBus = eventBus;
  10490. this.textContent = null;
  10491. this.textContentItemsStr = [];
  10492. this.textContentStream = null;
  10493. this.renderingDone = false;
  10494. this.pageIdx = pageIndex;
  10495. this.pageNumber = this.pageIdx + 1;
  10496. this.matches = [];
  10497. this.viewport = viewport;
  10498. this.textDivs = [];
  10499. this.findController = findController;
  10500. this.textLayerRenderTask = null;
  10501. this.enhanceTextSelection = enhanceTextSelection;
  10502. this._onUpdateTextLayerMatches = null;
  10503. this._bindMouse();
  10504. }
  10505. _createClass(TextLayerBuilder, [{
  10506. key: "_finishRendering",
  10507. value: function _finishRendering() {
  10508. this.renderingDone = true;
  10509. if (!this.enhanceTextSelection) {
  10510. var endOfContent = document.createElement("div");
  10511. endOfContent.className = "endOfContent";
  10512. this.textLayerDiv.appendChild(endOfContent);
  10513. }
  10514. this.eventBus.dispatch("textlayerrendered", {
  10515. source: this,
  10516. pageNumber: this.pageNumber,
  10517. numTextDivs: this.textDivs.length
  10518. });
  10519. }
  10520. }, {
  10521. key: "render",
  10522. value: function render() {
  10523. var _this = this;
  10524. var timeout = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
  10525. if (!(this.textContent || this.textContentStream) || this.renderingDone) {
  10526. return;
  10527. }
  10528. this.cancel();
  10529. this.textDivs = [];
  10530. var textLayerFrag = document.createDocumentFragment();
  10531. this.textLayerRenderTask = (0, _pdfjsLib.renderTextLayer)({
  10532. textContent: this.textContent,
  10533. textContentStream: this.textContentStream,
  10534. container: textLayerFrag,
  10535. viewport: this.viewport,
  10536. textDivs: this.textDivs,
  10537. textContentItemsStr: this.textContentItemsStr,
  10538. timeout: timeout,
  10539. enhanceTextSelection: this.enhanceTextSelection
  10540. });
  10541. this.textLayerRenderTask.promise.then(function () {
  10542. _this.textLayerDiv.appendChild(textLayerFrag);
  10543. _this._finishRendering();
  10544. _this._updateMatches();
  10545. }, function (reason) {});
  10546. if (!this._onUpdateTextLayerMatches) {
  10547. this._onUpdateTextLayerMatches = function (evt) {
  10548. if (evt.pageIndex === _this.pageIdx || evt.pageIndex === -1) {
  10549. _this._updateMatches();
  10550. }
  10551. };
  10552. this.eventBus._on("updatetextlayermatches", this._onUpdateTextLayerMatches);
  10553. }
  10554. }
  10555. }, {
  10556. key: "cancel",
  10557. value: function cancel() {
  10558. if (this.textLayerRenderTask) {
  10559. this.textLayerRenderTask.cancel();
  10560. this.textLayerRenderTask = null;
  10561. }
  10562. if (this._onUpdateTextLayerMatches) {
  10563. this.eventBus._off("updatetextlayermatches", this._onUpdateTextLayerMatches);
  10564. this._onUpdateTextLayerMatches = null;
  10565. }
  10566. }
  10567. }, {
  10568. key: "setTextContentStream",
  10569. value: function setTextContentStream(readableStream) {
  10570. this.cancel();
  10571. this.textContentStream = readableStream;
  10572. }
  10573. }, {
  10574. key: "setTextContent",
  10575. value: function setTextContent(textContent) {
  10576. this.cancel();
  10577. this.textContent = textContent;
  10578. }
  10579. }, {
  10580. key: "_convertMatches",
  10581. value: function _convertMatches(matches, matchesLength) {
  10582. if (!matches) {
  10583. return [];
  10584. }
  10585. var findController = this.findController,
  10586. textContentItemsStr = this.textContentItemsStr;
  10587. var i = 0,
  10588. iIndex = 0;
  10589. var end = textContentItemsStr.length - 1;
  10590. var queryLen = findController.state.query.length;
  10591. var result = [];
  10592. for (var m = 0, mm = matches.length; m < mm; m++) {
  10593. var matchIdx = matches[m];
  10594. while (i !== end && matchIdx >= iIndex + textContentItemsStr[i].length) {
  10595. iIndex += textContentItemsStr[i].length;
  10596. i++;
  10597. }
  10598. if (i === textContentItemsStr.length) {
  10599. console.error("Could not find a matching mapping");
  10600. }
  10601. var match = {
  10602. begin: {
  10603. divIdx: i,
  10604. offset: matchIdx - iIndex
  10605. }
  10606. };
  10607. if (matchesLength) {
  10608. matchIdx += matchesLength[m];
  10609. } else {
  10610. matchIdx += queryLen;
  10611. }
  10612. while (i !== end && matchIdx > iIndex + textContentItemsStr[i].length) {
  10613. iIndex += textContentItemsStr[i].length;
  10614. i++;
  10615. }
  10616. match.end = {
  10617. divIdx: i,
  10618. offset: matchIdx - iIndex
  10619. };
  10620. result.push(match);
  10621. }
  10622. return result;
  10623. }
  10624. }, {
  10625. key: "_renderMatches",
  10626. value: function _renderMatches(matches) {
  10627. if (matches.length === 0) {
  10628. return;
  10629. }
  10630. var findController = this.findController,
  10631. pageIdx = this.pageIdx,
  10632. textContentItemsStr = this.textContentItemsStr,
  10633. textDivs = this.textDivs;
  10634. var isSelectedPage = pageIdx === findController.selected.pageIdx;
  10635. var selectedMatchIdx = findController.selected.matchIdx;
  10636. var highlightAll = findController.state.highlightAll;
  10637. var prevEnd = null;
  10638. var infinity = {
  10639. divIdx: -1,
  10640. offset: undefined
  10641. };
  10642. function beginText(begin, className) {
  10643. var divIdx = begin.divIdx;
  10644. textDivs[divIdx].textContent = "";
  10645. appendTextToDiv(divIdx, 0, begin.offset, className);
  10646. }
  10647. function appendTextToDiv(divIdx, fromOffset, toOffset, className) {
  10648. var div = textDivs[divIdx];
  10649. var content = textContentItemsStr[divIdx].substring(fromOffset, toOffset);
  10650. var node = document.createTextNode(content);
  10651. if (className) {
  10652. var span = document.createElement("span");
  10653. span.className = className;
  10654. span.appendChild(node);
  10655. div.appendChild(span);
  10656. return;
  10657. }
  10658. div.appendChild(node);
  10659. }
  10660. var i0 = selectedMatchIdx,
  10661. i1 = i0 + 1;
  10662. if (highlightAll) {
  10663. i0 = 0;
  10664. i1 = matches.length;
  10665. } else if (!isSelectedPage) {
  10666. return;
  10667. }
  10668. for (var i = i0; i < i1; i++) {
  10669. var match = matches[i];
  10670. var begin = match.begin;
  10671. var end = match.end;
  10672. var isSelected = isSelectedPage && i === selectedMatchIdx;
  10673. var highlightSuffix = isSelected ? " selected" : "";
  10674. if (isSelected) {
  10675. findController.scrollMatchIntoView({
  10676. element: textDivs[begin.divIdx],
  10677. pageIndex: pageIdx,
  10678. matchIndex: selectedMatchIdx
  10679. });
  10680. }
  10681. if (!prevEnd || begin.divIdx !== prevEnd.divIdx) {
  10682. if (prevEnd !== null) {
  10683. appendTextToDiv(prevEnd.divIdx, prevEnd.offset, infinity.offset);
  10684. }
  10685. beginText(begin);
  10686. } else {
  10687. appendTextToDiv(prevEnd.divIdx, prevEnd.offset, begin.offset);
  10688. }
  10689. if (begin.divIdx === end.divIdx) {
  10690. appendTextToDiv(begin.divIdx, begin.offset, end.offset, "highlight" + highlightSuffix);
  10691. } else {
  10692. appendTextToDiv(begin.divIdx, begin.offset, infinity.offset, "highlight begin" + highlightSuffix);
  10693. for (var n0 = begin.divIdx + 1, n1 = end.divIdx; n0 < n1; n0++) {
  10694. textDivs[n0].className = "highlight middle" + highlightSuffix;
  10695. }
  10696. beginText(end, "highlight end" + highlightSuffix);
  10697. }
  10698. prevEnd = end;
  10699. }
  10700. if (prevEnd) {
  10701. appendTextToDiv(prevEnd.divIdx, prevEnd.offset, infinity.offset);
  10702. }
  10703. }
  10704. }, {
  10705. key: "_updateMatches",
  10706. value: function _updateMatches() {
  10707. if (!this.renderingDone) {
  10708. return;
  10709. }
  10710. var findController = this.findController,
  10711. matches = this.matches,
  10712. pageIdx = this.pageIdx,
  10713. textContentItemsStr = this.textContentItemsStr,
  10714. textDivs = this.textDivs;
  10715. var clearedUntilDivIdx = -1;
  10716. for (var i = 0, ii = matches.length; i < ii; i++) {
  10717. var match = matches[i];
  10718. var begin = Math.max(clearedUntilDivIdx, match.begin.divIdx);
  10719. for (var n = begin, end = match.end.divIdx; n <= end; n++) {
  10720. var div = textDivs[n];
  10721. div.textContent = textContentItemsStr[n];
  10722. div.className = "";
  10723. }
  10724. clearedUntilDivIdx = match.end.divIdx + 1;
  10725. }
  10726. if (!findController || !findController.highlightMatches) {
  10727. return;
  10728. }
  10729. var pageMatches = findController.pageMatches[pageIdx] || null;
  10730. var pageMatchesLength = findController.pageMatchesLength[pageIdx] || null;
  10731. this.matches = this._convertMatches(pageMatches, pageMatchesLength);
  10732. this._renderMatches(this.matches);
  10733. }
  10734. }, {
  10735. key: "_bindMouse",
  10736. value: function _bindMouse() {
  10737. var _this2 = this;
  10738. var div = this.textLayerDiv;
  10739. var expandDivsTimer = null;
  10740. div.addEventListener("mousedown", function (evt) {
  10741. if (_this2.enhanceTextSelection && _this2.textLayerRenderTask) {
  10742. _this2.textLayerRenderTask.expandTextDivs(true);
  10743. if (expandDivsTimer) {
  10744. clearTimeout(expandDivsTimer);
  10745. expandDivsTimer = null;
  10746. }
  10747. return;
  10748. }
  10749. var end = div.querySelector(".endOfContent");
  10750. if (!end) {
  10751. return;
  10752. }
  10753. var adjustTop = evt.target !== div;
  10754. adjustTop = adjustTop && window.getComputedStyle(end).getPropertyValue("-moz-user-select") !== "none";
  10755. if (adjustTop) {
  10756. var divBounds = div.getBoundingClientRect();
  10757. var r = Math.max(0, (evt.pageY - divBounds.top) / divBounds.height);
  10758. end.style.top = (r * 100).toFixed(2) + "%";
  10759. }
  10760. end.classList.add("active");
  10761. });
  10762. div.addEventListener("mouseup", function () {
  10763. if (_this2.enhanceTextSelection && _this2.textLayerRenderTask) {
  10764. expandDivsTimer = setTimeout(function () {
  10765. if (_this2.textLayerRenderTask) {
  10766. _this2.textLayerRenderTask.expandTextDivs(false);
  10767. }
  10768. expandDivsTimer = null;
  10769. }, EXPAND_DIVS_TIMEOUT);
  10770. return;
  10771. }
  10772. var end = div.querySelector(".endOfContent");
  10773. if (!end) {
  10774. return;
  10775. }
  10776. end.style.top = "";
  10777. end.classList.remove("active");
  10778. });
  10779. }
  10780. }]);
  10781. return TextLayerBuilder;
  10782. }();
  10783. exports.TextLayerBuilder = TextLayerBuilder;
  10784. var DefaultTextLayerFactory = /*#__PURE__*/function () {
  10785. function DefaultTextLayerFactory() {
  10786. _classCallCheck(this, DefaultTextLayerFactory);
  10787. }
  10788. _createClass(DefaultTextLayerFactory, [{
  10789. key: "createTextLayerBuilder",
  10790. value: function createTextLayerBuilder(textLayerDiv, pageIndex, viewport) {
  10791. var enhanceTextSelection = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
  10792. var eventBus = arguments.length > 4 ? arguments[4] : undefined;
  10793. return new TextLayerBuilder({
  10794. textLayerDiv: textLayerDiv,
  10795. pageIndex: pageIndex,
  10796. viewport: viewport,
  10797. enhanceTextSelection: enhanceTextSelection,
  10798. eventBus: eventBus
  10799. });
  10800. }
  10801. }]);
  10802. return DefaultTextLayerFactory;
  10803. }();
  10804. exports.DefaultTextLayerFactory = DefaultTextLayerFactory;
  10805. /***/ }),
  10806. /* 32 */
  10807. /***/ (function(module, exports, __webpack_require__) {
  10808. "use strict";
  10809. Object.defineProperty(exports, "__esModule", {
  10810. value: true
  10811. });
  10812. exports.SecondaryToolbar = void 0;
  10813. var _ui_utils = __webpack_require__(5);
  10814. var _pdf_cursor_tools = __webpack_require__(9);
  10815. var _pdf_single_page_viewer = __webpack_require__(33);
  10816. function _createForOfIteratorHelper(o, allowArrayLike) { var it; if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { 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 = o[Symbol.iterator](); }, 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; } } }; }
  10817. 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); }
  10818. 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; }
  10819. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  10820. 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); } }
  10821. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  10822. var SecondaryToolbar = /*#__PURE__*/function () {
  10823. function SecondaryToolbar(options, mainContainer, eventBus) {
  10824. var _this = this;
  10825. _classCallCheck(this, SecondaryToolbar);
  10826. this.toolbar = options.toolbar;
  10827. this.toggleButton = options.toggleButton;
  10828. this.toolbarButtonContainer = options.toolbarButtonContainer;
  10829. this.buttons = [{
  10830. element: options.presentationModeButton,
  10831. eventName: "presentationmode",
  10832. close: true
  10833. }, {
  10834. element: options.openFileButton,
  10835. eventName: "openfile",
  10836. close: true
  10837. }, {
  10838. element: options.printButton,
  10839. eventName: "print",
  10840. close: true
  10841. }, {
  10842. element: options.downloadButton,
  10843. eventName: "download",
  10844. close: true
  10845. }, {
  10846. element: options.viewBookmarkButton,
  10847. eventName: null,
  10848. close: true
  10849. }, {
  10850. element: options.firstPageButton,
  10851. eventName: "firstpage",
  10852. close: true
  10853. }, {
  10854. element: options.lastPageButton,
  10855. eventName: "lastpage",
  10856. close: true
  10857. }, {
  10858. element: options.pageRotateCwButton,
  10859. eventName: "rotatecw",
  10860. close: false
  10861. }, {
  10862. element: options.pageRotateCcwButton,
  10863. eventName: "rotateccw",
  10864. close: false
  10865. }, {
  10866. element: options.cursorSelectToolButton,
  10867. eventName: "switchcursortool",
  10868. eventDetails: {
  10869. tool: _pdf_cursor_tools.CursorTool.SELECT
  10870. },
  10871. close: true
  10872. }, {
  10873. element: options.cursorHandToolButton,
  10874. eventName: "switchcursortool",
  10875. eventDetails: {
  10876. tool: _pdf_cursor_tools.CursorTool.HAND
  10877. },
  10878. close: true
  10879. }, {
  10880. element: options.scrollVerticalButton,
  10881. eventName: "switchscrollmode",
  10882. eventDetails: {
  10883. mode: _ui_utils.ScrollMode.VERTICAL
  10884. },
  10885. close: true
  10886. }, {
  10887. element: options.scrollHorizontalButton,
  10888. eventName: "switchscrollmode",
  10889. eventDetails: {
  10890. mode: _ui_utils.ScrollMode.HORIZONTAL
  10891. },
  10892. close: true
  10893. }, {
  10894. element: options.scrollWrappedButton,
  10895. eventName: "switchscrollmode",
  10896. eventDetails: {
  10897. mode: _ui_utils.ScrollMode.WRAPPED
  10898. },
  10899. close: true
  10900. }, {
  10901. element: options.spreadNoneButton,
  10902. eventName: "switchspreadmode",
  10903. eventDetails: {
  10904. mode: _ui_utils.SpreadMode.NONE
  10905. },
  10906. close: true
  10907. }, {
  10908. element: options.spreadOddButton,
  10909. eventName: "switchspreadmode",
  10910. eventDetails: {
  10911. mode: _ui_utils.SpreadMode.ODD
  10912. },
  10913. close: true
  10914. }, {
  10915. element: options.spreadEvenButton,
  10916. eventName: "switchspreadmode",
  10917. eventDetails: {
  10918. mode: _ui_utils.SpreadMode.EVEN
  10919. },
  10920. close: true
  10921. }, {
  10922. element: options.documentPropertiesButton,
  10923. eventName: "documentproperties",
  10924. close: true
  10925. }];
  10926. this.items = {
  10927. firstPage: options.firstPageButton,
  10928. lastPage: options.lastPageButton,
  10929. pageRotateCw: options.pageRotateCwButton,
  10930. pageRotateCcw: options.pageRotateCcwButton
  10931. };
  10932. this.mainContainer = mainContainer;
  10933. this.eventBus = eventBus;
  10934. this.opened = false;
  10935. this.containerHeight = null;
  10936. this.previousContainerHeight = null;
  10937. this.reset();
  10938. this._bindClickListeners();
  10939. this._bindCursorToolsListener(options);
  10940. this._bindScrollModeListener(options);
  10941. this._bindSpreadModeListener(options);
  10942. this.eventBus._on("resize", this._setMaxHeight.bind(this));
  10943. this.eventBus._on("baseviewerinit", function (evt) {
  10944. if (evt.source instanceof _pdf_single_page_viewer.PDFSinglePageViewer) {
  10945. _this.toolbarButtonContainer.classList.add("hiddenScrollModeButtons", "hiddenSpreadModeButtons");
  10946. } else {
  10947. _this.toolbarButtonContainer.classList.remove("hiddenScrollModeButtons", "hiddenSpreadModeButtons");
  10948. }
  10949. });
  10950. }
  10951. _createClass(SecondaryToolbar, [{
  10952. key: "setPageNumber",
  10953. value: function setPageNumber(pageNumber) {
  10954. this.pageNumber = pageNumber;
  10955. this._updateUIState();
  10956. }
  10957. }, {
  10958. key: "setPagesCount",
  10959. value: function setPagesCount(pagesCount) {
  10960. this.pagesCount = pagesCount;
  10961. this._updateUIState();
  10962. }
  10963. }, {
  10964. key: "reset",
  10965. value: function reset() {
  10966. this.pageNumber = 0;
  10967. this.pagesCount = 0;
  10968. this._updateUIState();
  10969. this.eventBus.dispatch("secondarytoolbarreset", {
  10970. source: this
  10971. });
  10972. }
  10973. }, {
  10974. key: "_updateUIState",
  10975. value: function _updateUIState() {
  10976. this.items.firstPage.disabled = this.pageNumber <= 1;
  10977. this.items.lastPage.disabled = this.pageNumber >= this.pagesCount;
  10978. this.items.pageRotateCw.disabled = this.pagesCount === 0;
  10979. this.items.pageRotateCcw.disabled = this.pagesCount === 0;
  10980. }
  10981. }, {
  10982. key: "_bindClickListeners",
  10983. value: function _bindClickListeners() {
  10984. var _this2 = this;
  10985. this.toggleButton.addEventListener("click", this.toggle.bind(this));
  10986. var _iterator = _createForOfIteratorHelper(this.buttons),
  10987. _step;
  10988. try {
  10989. var _loop = function _loop() {
  10990. var _step$value = _step.value,
  10991. element = _step$value.element,
  10992. eventName = _step$value.eventName,
  10993. close = _step$value.close,
  10994. eventDetails = _step$value.eventDetails;
  10995. element.addEventListener("click", function (evt) {
  10996. if (eventName !== null) {
  10997. var details = {
  10998. source: _this2
  10999. };
  11000. for (var property in eventDetails) {
  11001. details[property] = eventDetails[property];
  11002. }
  11003. _this2.eventBus.dispatch(eventName, details);
  11004. }
  11005. if (close) {
  11006. _this2.close();
  11007. }
  11008. });
  11009. };
  11010. for (_iterator.s(); !(_step = _iterator.n()).done;) {
  11011. _loop();
  11012. }
  11013. } catch (err) {
  11014. _iterator.e(err);
  11015. } finally {
  11016. _iterator.f();
  11017. }
  11018. }
  11019. }, {
  11020. key: "_bindCursorToolsListener",
  11021. value: function _bindCursorToolsListener(buttons) {
  11022. this.eventBus._on("cursortoolchanged", function (_ref) {
  11023. var tool = _ref.tool;
  11024. buttons.cursorSelectToolButton.classList.toggle("toggled", tool === _pdf_cursor_tools.CursorTool.SELECT);
  11025. buttons.cursorHandToolButton.classList.toggle("toggled", tool === _pdf_cursor_tools.CursorTool.HAND);
  11026. });
  11027. }
  11028. }, {
  11029. key: "_bindScrollModeListener",
  11030. value: function _bindScrollModeListener(buttons) {
  11031. var _this3 = this;
  11032. function scrollModeChanged(_ref2) {
  11033. var mode = _ref2.mode;
  11034. buttons.scrollVerticalButton.classList.toggle("toggled", mode === _ui_utils.ScrollMode.VERTICAL);
  11035. buttons.scrollHorizontalButton.classList.toggle("toggled", mode === _ui_utils.ScrollMode.HORIZONTAL);
  11036. buttons.scrollWrappedButton.classList.toggle("toggled", mode === _ui_utils.ScrollMode.WRAPPED);
  11037. var isScrollModeHorizontal = mode === _ui_utils.ScrollMode.HORIZONTAL;
  11038. buttons.spreadNoneButton.disabled = isScrollModeHorizontal;
  11039. buttons.spreadOddButton.disabled = isScrollModeHorizontal;
  11040. buttons.spreadEvenButton.disabled = isScrollModeHorizontal;
  11041. }
  11042. this.eventBus._on("scrollmodechanged", scrollModeChanged);
  11043. this.eventBus._on("secondarytoolbarreset", function (evt) {
  11044. if (evt.source === _this3) {
  11045. scrollModeChanged({
  11046. mode: _ui_utils.ScrollMode.VERTICAL
  11047. });
  11048. }
  11049. });
  11050. }
  11051. }, {
  11052. key: "_bindSpreadModeListener",
  11053. value: function _bindSpreadModeListener(buttons) {
  11054. var _this4 = this;
  11055. function spreadModeChanged(_ref3) {
  11056. var mode = _ref3.mode;
  11057. buttons.spreadNoneButton.classList.toggle("toggled", mode === _ui_utils.SpreadMode.NONE);
  11058. buttons.spreadOddButton.classList.toggle("toggled", mode === _ui_utils.SpreadMode.ODD);
  11059. buttons.spreadEvenButton.classList.toggle("toggled", mode === _ui_utils.SpreadMode.EVEN);
  11060. }
  11061. this.eventBus._on("spreadmodechanged", spreadModeChanged);
  11062. this.eventBus._on("secondarytoolbarreset", function (evt) {
  11063. if (evt.source === _this4) {
  11064. spreadModeChanged({
  11065. mode: _ui_utils.SpreadMode.NONE
  11066. });
  11067. }
  11068. });
  11069. }
  11070. }, {
  11071. key: "open",
  11072. value: function open() {
  11073. if (this.opened) {
  11074. return;
  11075. }
  11076. this.opened = true;
  11077. this._setMaxHeight();
  11078. this.toggleButton.classList.add("toggled");
  11079. this.toolbar.classList.remove("hidden");
  11080. }
  11081. }, {
  11082. key: "close",
  11083. value: function close() {
  11084. if (!this.opened) {
  11085. return;
  11086. }
  11087. this.opened = false;
  11088. this.toolbar.classList.add("hidden");
  11089. this.toggleButton.classList.remove("toggled");
  11090. }
  11091. }, {
  11092. key: "toggle",
  11093. value: function toggle() {
  11094. if (this.opened) {
  11095. this.close();
  11096. } else {
  11097. this.open();
  11098. }
  11099. }
  11100. }, {
  11101. key: "_setMaxHeight",
  11102. value: function _setMaxHeight() {
  11103. if (!this.opened) {
  11104. return;
  11105. }
  11106. this.containerHeight = this.mainContainer.clientHeight;
  11107. if (this.containerHeight === this.previousContainerHeight) {
  11108. return;
  11109. }
  11110. this.toolbarButtonContainer.style.maxHeight = "".concat(this.containerHeight - _ui_utils.SCROLLBAR_PADDING, "px");
  11111. this.previousContainerHeight = this.containerHeight;
  11112. }
  11113. }, {
  11114. key: "isOpen",
  11115. get: function get() {
  11116. return this.opened;
  11117. }
  11118. }]);
  11119. return SecondaryToolbar;
  11120. }();
  11121. exports.SecondaryToolbar = SecondaryToolbar;
  11122. /***/ }),
  11123. /* 33 */
  11124. /***/ (function(module, exports, __webpack_require__) {
  11125. "use strict";
  11126. Object.defineProperty(exports, "__esModule", {
  11127. value: true
  11128. });
  11129. exports.PDFSinglePageViewer = void 0;
  11130. var _base_viewer = __webpack_require__(28);
  11131. var _pdfjsLib = __webpack_require__(8);
  11132. 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); }
  11133. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  11134. 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); } }
  11135. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  11136. 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); }
  11137. function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
  11138. 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); }
  11139. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  11140. 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); }; }
  11141. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  11142. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  11143. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
  11144. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  11145. var PDFSinglePageViewer = /*#__PURE__*/function (_BaseViewer) {
  11146. _inherits(PDFSinglePageViewer, _BaseViewer);
  11147. var _super = _createSuper(PDFSinglePageViewer);
  11148. function PDFSinglePageViewer(options) {
  11149. var _this;
  11150. _classCallCheck(this, PDFSinglePageViewer);
  11151. _this = _super.call(this, options);
  11152. _this.eventBus._on("pagesinit", function (evt) {
  11153. _this._ensurePageViewVisible();
  11154. });
  11155. return _this;
  11156. }
  11157. _createClass(PDFSinglePageViewer, [{
  11158. key: "_resetView",
  11159. value: function _resetView() {
  11160. _get(_getPrototypeOf(PDFSinglePageViewer.prototype), "_resetView", this).call(this);
  11161. this._previousPageNumber = 1;
  11162. this._shadowViewer = document.createDocumentFragment();
  11163. this._updateScrollDown = null;
  11164. }
  11165. }, {
  11166. key: "_ensurePageViewVisible",
  11167. value: function _ensurePageViewVisible() {
  11168. var pageView = this._pages[this._currentPageNumber - 1];
  11169. var previousPageView = this._pages[this._previousPageNumber - 1];
  11170. var viewerNodes = this.viewer.childNodes;
  11171. switch (viewerNodes.length) {
  11172. case 0:
  11173. this.viewer.appendChild(pageView.div);
  11174. break;
  11175. case 1:
  11176. if (viewerNodes[0] !== previousPageView.div) {
  11177. throw new Error("_ensurePageViewVisible: Unexpected previously visible page.");
  11178. }
  11179. if (pageView === previousPageView) {
  11180. break;
  11181. }
  11182. this._shadowViewer.appendChild(previousPageView.div);
  11183. this.viewer.appendChild(pageView.div);
  11184. this.container.scrollTop = 0;
  11185. break;
  11186. default:
  11187. throw new Error("_ensurePageViewVisible: Only one page should be visible at a time.");
  11188. }
  11189. this._previousPageNumber = this._currentPageNumber;
  11190. }
  11191. }, {
  11192. key: "_scrollUpdate",
  11193. value: function _scrollUpdate() {
  11194. if (this._updateScrollDown) {
  11195. this._updateScrollDown();
  11196. }
  11197. _get(_getPrototypeOf(PDFSinglePageViewer.prototype), "_scrollUpdate", this).call(this);
  11198. }
  11199. }, {
  11200. key: "_scrollIntoView",
  11201. value: function _scrollIntoView(_ref) {
  11202. var _this2 = this;
  11203. var pageDiv = _ref.pageDiv,
  11204. _ref$pageSpot = _ref.pageSpot,
  11205. pageSpot = _ref$pageSpot === void 0 ? null : _ref$pageSpot,
  11206. _ref$pageNumber = _ref.pageNumber,
  11207. pageNumber = _ref$pageNumber === void 0 ? null : _ref$pageNumber;
  11208. if (pageNumber) {
  11209. this._setCurrentPageNumber(pageNumber);
  11210. }
  11211. var scrolledDown = this._currentPageNumber >= this._previousPageNumber;
  11212. this._ensurePageViewVisible();
  11213. this.update();
  11214. _get(_getPrototypeOf(PDFSinglePageViewer.prototype), "_scrollIntoView", this).call(this, {
  11215. pageDiv: pageDiv,
  11216. pageSpot: pageSpot,
  11217. pageNumber: pageNumber
  11218. });
  11219. this._updateScrollDown = function () {
  11220. _this2.scroll.down = scrolledDown;
  11221. _this2._updateScrollDown = null;
  11222. };
  11223. }
  11224. }, {
  11225. key: "_getVisiblePages",
  11226. value: function _getVisiblePages() {
  11227. return this._getCurrentVisiblePage();
  11228. }
  11229. }, {
  11230. key: "_updateHelper",
  11231. value: function _updateHelper(visiblePages) {}
  11232. }, {
  11233. key: "_updateScrollMode",
  11234. value: function _updateScrollMode() {}
  11235. }, {
  11236. key: "_updateSpreadMode",
  11237. value: function _updateSpreadMode() {}
  11238. }, {
  11239. key: "_viewerElement",
  11240. get: function get() {
  11241. return (0, _pdfjsLib.shadow)(this, "_viewerElement", this._shadowViewer);
  11242. }
  11243. }, {
  11244. key: "_isScrollModeHorizontal",
  11245. get: function get() {
  11246. return (0, _pdfjsLib.shadow)(this, "_isScrollModeHorizontal", false);
  11247. }
  11248. }]);
  11249. return PDFSinglePageViewer;
  11250. }(_base_viewer.BaseViewer);
  11251. exports.PDFSinglePageViewer = PDFSinglePageViewer;
  11252. /***/ }),
  11253. /* 34 */
  11254. /***/ (function(module, exports, __webpack_require__) {
  11255. "use strict";
  11256. Object.defineProperty(exports, "__esModule", {
  11257. value: true
  11258. });
  11259. exports.Toolbar = void 0;
  11260. var _regenerator = _interopRequireDefault(__webpack_require__(2));
  11261. var _ui_utils = __webpack_require__(5);
  11262. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  11263. 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); } }
  11264. 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); }); }; }
  11265. function _createForOfIteratorHelper(o, allowArrayLike) { var it; if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { 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 = o[Symbol.iterator](); }, 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; } } }; }
  11266. 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); }
  11267. 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; }
  11268. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  11269. 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); } }
  11270. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  11271. var PAGE_NUMBER_LOADING_INDICATOR = "visiblePageIsLoading";
  11272. var SCALE_SELECT_CONTAINER_WIDTH = 140;
  11273. var SCALE_SELECT_WIDTH = 162;
  11274. var Toolbar = /*#__PURE__*/function () {
  11275. function Toolbar(options, eventBus) {
  11276. var l10n = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : _ui_utils.NullL10n;
  11277. _classCallCheck(this, Toolbar);
  11278. this.toolbar = options.container;
  11279. this.eventBus = eventBus;
  11280. this.l10n = l10n;
  11281. this.buttons = [{
  11282. element: options.previous,
  11283. eventName: "previouspage"
  11284. }, {
  11285. element: options.next,
  11286. eventName: "nextpage"
  11287. }, {
  11288. element: options.zoomIn,
  11289. eventName: "zoomin"
  11290. }, {
  11291. element: options.zoomOut,
  11292. eventName: "zoomout"
  11293. }, {
  11294. element: options.openFile,
  11295. eventName: "openfile"
  11296. }, {
  11297. element: options.print,
  11298. eventName: "print"
  11299. }, {
  11300. element: options.presentationModeButton,
  11301. eventName: "presentationmode"
  11302. }, {
  11303. element: options.download,
  11304. eventName: "download"
  11305. }, {
  11306. element: options.viewBookmark,
  11307. eventName: null
  11308. }];
  11309. this.items = {
  11310. numPages: options.numPages,
  11311. pageNumber: options.pageNumber,
  11312. scaleSelectContainer: options.scaleSelectContainer,
  11313. scaleSelect: options.scaleSelect,
  11314. customScaleOption: options.customScaleOption,
  11315. previous: options.previous,
  11316. next: options.next,
  11317. zoomIn: options.zoomIn,
  11318. zoomOut: options.zoomOut
  11319. };
  11320. this._wasLocalized = false;
  11321. this.reset();
  11322. this._bindListeners();
  11323. }
  11324. _createClass(Toolbar, [{
  11325. key: "setPageNumber",
  11326. value: function setPageNumber(pageNumber, pageLabel) {
  11327. this.pageNumber = pageNumber;
  11328. this.pageLabel = pageLabel;
  11329. this._updateUIState(false);
  11330. }
  11331. }, {
  11332. key: "setPagesCount",
  11333. value: function setPagesCount(pagesCount, hasPageLabels) {
  11334. this.pagesCount = pagesCount;
  11335. this.hasPageLabels = hasPageLabels;
  11336. this._updateUIState(true);
  11337. }
  11338. }, {
  11339. key: "setPageScale",
  11340. value: function setPageScale(pageScaleValue, pageScale) {
  11341. this.pageScaleValue = (pageScaleValue || pageScale).toString();
  11342. this.pageScale = pageScale;
  11343. this._updateUIState(false);
  11344. }
  11345. }, {
  11346. key: "reset",
  11347. value: function reset() {
  11348. this.pageNumber = 0;
  11349. this.pageLabel = null;
  11350. this.hasPageLabels = false;
  11351. this.pagesCount = 0;
  11352. this.pageScaleValue = _ui_utils.DEFAULT_SCALE_VALUE;
  11353. this.pageScale = _ui_utils.DEFAULT_SCALE;
  11354. this._updateUIState(true);
  11355. this.updateLoadingIndicatorState();
  11356. }
  11357. }, {
  11358. key: "_bindListeners",
  11359. value: function _bindListeners() {
  11360. var _this = this;
  11361. var _this$items = this.items,
  11362. pageNumber = _this$items.pageNumber,
  11363. scaleSelect = _this$items.scaleSelect;
  11364. var self = this;
  11365. var _iterator = _createForOfIteratorHelper(this.buttons),
  11366. _step;
  11367. try {
  11368. var _loop = function _loop() {
  11369. var _step$value = _step.value,
  11370. element = _step$value.element,
  11371. eventName = _step$value.eventName;
  11372. element.addEventListener("click", function (evt) {
  11373. if (eventName !== null) {
  11374. _this.eventBus.dispatch(eventName, {
  11375. source: _this
  11376. });
  11377. }
  11378. });
  11379. };
  11380. for (_iterator.s(); !(_step = _iterator.n()).done;) {
  11381. _loop();
  11382. }
  11383. } catch (err) {
  11384. _iterator.e(err);
  11385. } finally {
  11386. _iterator.f();
  11387. }
  11388. pageNumber.addEventListener("click", function () {
  11389. this.select();
  11390. });
  11391. pageNumber.addEventListener("change", function () {
  11392. self.eventBus.dispatch("pagenumberchanged", {
  11393. source: self,
  11394. value: this.value
  11395. });
  11396. });
  11397. scaleSelect.addEventListener("change", function () {
  11398. if (this.value === "custom") {
  11399. return;
  11400. }
  11401. self.eventBus.dispatch("scalechanged", {
  11402. source: self,
  11403. value: this.value
  11404. });
  11405. });
  11406. scaleSelect.oncontextmenu = _ui_utils.noContextMenuHandler;
  11407. this.eventBus._on("localized", function () {
  11408. _this._wasLocalized = true;
  11409. _this._adjustScaleWidth();
  11410. _this._updateUIState(true);
  11411. });
  11412. }
  11413. }, {
  11414. key: "_updateUIState",
  11415. value: function _updateUIState() {
  11416. var resetNumPages = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  11417. if (!this._wasLocalized) {
  11418. return;
  11419. }
  11420. var pageNumber = this.pageNumber,
  11421. pagesCount = this.pagesCount,
  11422. pageScaleValue = this.pageScaleValue,
  11423. pageScale = this.pageScale,
  11424. items = this.items;
  11425. if (resetNumPages) {
  11426. if (this.hasPageLabels) {
  11427. items.pageNumber.type = "text";
  11428. } else {
  11429. items.pageNumber.type = "number";
  11430. this.l10n.get("of_pages", {
  11431. pagesCount: pagesCount
  11432. }, "of {{pagesCount}}").then(function (msg) {
  11433. items.numPages.textContent = msg;
  11434. });
  11435. }
  11436. items.pageNumber.max = pagesCount;
  11437. }
  11438. if (this.hasPageLabels) {
  11439. items.pageNumber.value = this.pageLabel;
  11440. this.l10n.get("page_of_pages", {
  11441. pageNumber: pageNumber,
  11442. pagesCount: pagesCount
  11443. }, "({{pageNumber}} of {{pagesCount}})").then(function (msg) {
  11444. items.numPages.textContent = msg;
  11445. });
  11446. } else {
  11447. items.pageNumber.value = pageNumber;
  11448. }
  11449. items.previous.disabled = pageNumber <= 1;
  11450. items.next.disabled = pageNumber >= pagesCount;
  11451. items.zoomOut.disabled = pageScale <= _ui_utils.MIN_SCALE;
  11452. items.zoomIn.disabled = pageScale >= _ui_utils.MAX_SCALE;
  11453. var customScale = Math.round(pageScale * 10000) / 100;
  11454. this.l10n.get("page_scale_percent", {
  11455. scale: customScale
  11456. }, "{{scale}}%").then(function (msg) {
  11457. var predefinedValueFound = false;
  11458. var _iterator2 = _createForOfIteratorHelper(items.scaleSelect.options),
  11459. _step2;
  11460. try {
  11461. for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
  11462. var option = _step2.value;
  11463. if (option.value !== pageScaleValue) {
  11464. option.selected = false;
  11465. continue;
  11466. }
  11467. option.selected = true;
  11468. predefinedValueFound = true;
  11469. }
  11470. } catch (err) {
  11471. _iterator2.e(err);
  11472. } finally {
  11473. _iterator2.f();
  11474. }
  11475. if (!predefinedValueFound) {
  11476. items.customScaleOption.textContent = msg;
  11477. items.customScaleOption.selected = true;
  11478. }
  11479. });
  11480. }
  11481. }, {
  11482. key: "updateLoadingIndicatorState",
  11483. value: function updateLoadingIndicatorState() {
  11484. var loading = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  11485. var pageNumberInput = this.items.pageNumber;
  11486. pageNumberInput.classList.toggle(PAGE_NUMBER_LOADING_INDICATOR, loading);
  11487. }
  11488. }, {
  11489. key: "_adjustScaleWidth",
  11490. value: function () {
  11491. var _adjustScaleWidth2 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
  11492. var items, l10n, predefinedValuesPromise, canvas, ctx, _getComputedStyle, fontSize, fontFamily, maxWidth, _iterator3, _step3, predefinedValue, _ctx$measureText, width, overflow;
  11493. return _regenerator["default"].wrap(function _callee$(_context) {
  11494. while (1) {
  11495. switch (_context.prev = _context.next) {
  11496. case 0:
  11497. items = this.items, l10n = this.l10n;
  11498. predefinedValuesPromise = Promise.all([l10n.get("page_scale_auto", null, "Automatic Zoom"), l10n.get("page_scale_actual", null, "Actual Size"), l10n.get("page_scale_fit", null, "Page Fit"), l10n.get("page_scale_width", null, "Page Width")]);
  11499. canvas = document.createElement("canvas");
  11500. canvas.mozOpaque = true;
  11501. ctx = canvas.getContext("2d", {
  11502. alpha: false
  11503. });
  11504. _context.next = 7;
  11505. return _ui_utils.animationStarted;
  11506. case 7:
  11507. _getComputedStyle = getComputedStyle(items.scaleSelect), fontSize = _getComputedStyle.fontSize, fontFamily = _getComputedStyle.fontFamily;
  11508. ctx.font = "".concat(fontSize, " ").concat(fontFamily);
  11509. maxWidth = 0;
  11510. _context.t0 = _createForOfIteratorHelper;
  11511. _context.next = 13;
  11512. return predefinedValuesPromise;
  11513. case 13:
  11514. _context.t1 = _context.sent;
  11515. _iterator3 = (0, _context.t0)(_context.t1);
  11516. try {
  11517. for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
  11518. predefinedValue = _step3.value;
  11519. _ctx$measureText = ctx.measureText(predefinedValue), width = _ctx$measureText.width;
  11520. if (width > maxWidth) {
  11521. maxWidth = width;
  11522. }
  11523. }
  11524. } catch (err) {
  11525. _iterator3.e(err);
  11526. } finally {
  11527. _iterator3.f();
  11528. }
  11529. overflow = SCALE_SELECT_WIDTH - SCALE_SELECT_CONTAINER_WIDTH;
  11530. maxWidth += 1.5 * overflow;
  11531. if (maxWidth > SCALE_SELECT_CONTAINER_WIDTH) {
  11532. items.scaleSelect.style.width = "".concat(maxWidth + overflow, "px");
  11533. items.scaleSelectContainer.style.width = "".concat(maxWidth, "px");
  11534. }
  11535. canvas.width = 0;
  11536. canvas.height = 0;
  11537. canvas = ctx = null;
  11538. case 22:
  11539. case "end":
  11540. return _context.stop();
  11541. }
  11542. }
  11543. }, _callee, this);
  11544. }));
  11545. function _adjustScaleWidth() {
  11546. return _adjustScaleWidth2.apply(this, arguments);
  11547. }
  11548. return _adjustScaleWidth;
  11549. }()
  11550. }]);
  11551. return Toolbar;
  11552. }();
  11553. exports.Toolbar = Toolbar;
  11554. /***/ }),
  11555. /* 35 */
  11556. /***/ (function(module, exports, __webpack_require__) {
  11557. "use strict";
  11558. Object.defineProperty(exports, "__esModule", {
  11559. value: true
  11560. });
  11561. exports.ViewHistory = void 0;
  11562. var _regenerator = _interopRequireDefault(__webpack_require__(2));
  11563. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  11564. 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); } }
  11565. 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); }); }; }
  11566. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  11567. 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); } }
  11568. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  11569. var DEFAULT_VIEW_HISTORY_CACHE_SIZE = 20;
  11570. var ViewHistory = /*#__PURE__*/function () {
  11571. function ViewHistory(fingerprint) {
  11572. var _this = this;
  11573. var cacheSize = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : DEFAULT_VIEW_HISTORY_CACHE_SIZE;
  11574. _classCallCheck(this, ViewHistory);
  11575. this.fingerprint = fingerprint;
  11576. this.cacheSize = cacheSize;
  11577. this._initializedPromise = this._readFromStorage().then(function (databaseStr) {
  11578. var database = JSON.parse(databaseStr || "{}");
  11579. var index = -1;
  11580. if (!Array.isArray(database.files)) {
  11581. database.files = [];
  11582. } else {
  11583. while (database.files.length >= _this.cacheSize) {
  11584. database.files.shift();
  11585. }
  11586. for (var i = 0, ii = database.files.length; i < ii; i++) {
  11587. var branch = database.files[i];
  11588. if (branch.fingerprint === _this.fingerprint) {
  11589. index = i;
  11590. break;
  11591. }
  11592. }
  11593. }
  11594. if (index === -1) {
  11595. index = database.files.push({
  11596. fingerprint: _this.fingerprint
  11597. }) - 1;
  11598. }
  11599. _this.file = database.files[index];
  11600. _this.database = database;
  11601. });
  11602. }
  11603. _createClass(ViewHistory, [{
  11604. key: "_writeToStorage",
  11605. value: function () {
  11606. var _writeToStorage2 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
  11607. var databaseStr;
  11608. return _regenerator["default"].wrap(function _callee$(_context) {
  11609. while (1) {
  11610. switch (_context.prev = _context.next) {
  11611. case 0:
  11612. databaseStr = JSON.stringify(this.database);
  11613. localStorage.setItem("pdfjs.history", databaseStr);
  11614. case 2:
  11615. case "end":
  11616. return _context.stop();
  11617. }
  11618. }
  11619. }, _callee, this);
  11620. }));
  11621. function _writeToStorage() {
  11622. return _writeToStorage2.apply(this, arguments);
  11623. }
  11624. return _writeToStorage;
  11625. }()
  11626. }, {
  11627. key: "_readFromStorage",
  11628. value: function () {
  11629. var _readFromStorage2 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee2() {
  11630. return _regenerator["default"].wrap(function _callee2$(_context2) {
  11631. while (1) {
  11632. switch (_context2.prev = _context2.next) {
  11633. case 0:
  11634. return _context2.abrupt("return", localStorage.getItem("pdfjs.history"));
  11635. case 1:
  11636. case "end":
  11637. return _context2.stop();
  11638. }
  11639. }
  11640. }, _callee2);
  11641. }));
  11642. function _readFromStorage() {
  11643. return _readFromStorage2.apply(this, arguments);
  11644. }
  11645. return _readFromStorage;
  11646. }()
  11647. }, {
  11648. key: "set",
  11649. value: function () {
  11650. var _set = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee3(name, val) {
  11651. return _regenerator["default"].wrap(function _callee3$(_context3) {
  11652. while (1) {
  11653. switch (_context3.prev = _context3.next) {
  11654. case 0:
  11655. _context3.next = 2;
  11656. return this._initializedPromise;
  11657. case 2:
  11658. this.file[name] = val;
  11659. return _context3.abrupt("return", this._writeToStorage());
  11660. case 4:
  11661. case "end":
  11662. return _context3.stop();
  11663. }
  11664. }
  11665. }, _callee3, this);
  11666. }));
  11667. function set(_x, _x2) {
  11668. return _set.apply(this, arguments);
  11669. }
  11670. return set;
  11671. }()
  11672. }, {
  11673. key: "setMultiple",
  11674. value: function () {
  11675. var _setMultiple = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee4(properties) {
  11676. var name;
  11677. return _regenerator["default"].wrap(function _callee4$(_context4) {
  11678. while (1) {
  11679. switch (_context4.prev = _context4.next) {
  11680. case 0:
  11681. _context4.next = 2;
  11682. return this._initializedPromise;
  11683. case 2:
  11684. for (name in properties) {
  11685. this.file[name] = properties[name];
  11686. }
  11687. return _context4.abrupt("return", this._writeToStorage());
  11688. case 4:
  11689. case "end":
  11690. return _context4.stop();
  11691. }
  11692. }
  11693. }, _callee4, this);
  11694. }));
  11695. function setMultiple(_x3) {
  11696. return _setMultiple.apply(this, arguments);
  11697. }
  11698. return setMultiple;
  11699. }()
  11700. }, {
  11701. key: "get",
  11702. value: function () {
  11703. var _get = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee5(name, defaultValue) {
  11704. var val;
  11705. return _regenerator["default"].wrap(function _callee5$(_context5) {
  11706. while (1) {
  11707. switch (_context5.prev = _context5.next) {
  11708. case 0:
  11709. _context5.next = 2;
  11710. return this._initializedPromise;
  11711. case 2:
  11712. val = this.file[name];
  11713. return _context5.abrupt("return", val !== undefined ? val : defaultValue);
  11714. case 4:
  11715. case "end":
  11716. return _context5.stop();
  11717. }
  11718. }
  11719. }, _callee5, this);
  11720. }));
  11721. function get(_x4, _x5) {
  11722. return _get.apply(this, arguments);
  11723. }
  11724. return get;
  11725. }()
  11726. }, {
  11727. key: "getMultiple",
  11728. value: function () {
  11729. var _getMultiple = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee6(properties) {
  11730. var values, name, val;
  11731. return _regenerator["default"].wrap(function _callee6$(_context6) {
  11732. while (1) {
  11733. switch (_context6.prev = _context6.next) {
  11734. case 0:
  11735. _context6.next = 2;
  11736. return this._initializedPromise;
  11737. case 2:
  11738. values = Object.create(null);
  11739. for (name in properties) {
  11740. val = this.file[name];
  11741. values[name] = val !== undefined ? val : properties[name];
  11742. }
  11743. return _context6.abrupt("return", values);
  11744. case 5:
  11745. case "end":
  11746. return _context6.stop();
  11747. }
  11748. }
  11749. }, _callee6, this);
  11750. }));
  11751. function getMultiple(_x6) {
  11752. return _getMultiple.apply(this, arguments);
  11753. }
  11754. return getMultiple;
  11755. }()
  11756. }]);
  11757. return ViewHistory;
  11758. }();
  11759. exports.ViewHistory = ViewHistory;
  11760. /***/ }),
  11761. /* 36 */
  11762. /***/ (function(module, exports, __webpack_require__) {
  11763. "use strict";
  11764. Object.defineProperty(exports, "__esModule", {
  11765. value: true
  11766. });
  11767. exports.GenericCom = void 0;
  11768. var _regenerator = _interopRequireDefault(__webpack_require__(2));
  11769. var _app = __webpack_require__(1);
  11770. var _preferences = __webpack_require__(37);
  11771. var _download_manager = __webpack_require__(38);
  11772. var _genericl10n = __webpack_require__(39);
  11773. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  11774. 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); }
  11775. 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); } }
  11776. 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); }); }; }
  11777. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  11778. 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); } }
  11779. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  11780. 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); }
  11781. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  11782. 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); }; }
  11783. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  11784. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  11785. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
  11786. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  11787. ;
  11788. var GenericCom = {};
  11789. exports.GenericCom = GenericCom;
  11790. var GenericPreferences = /*#__PURE__*/function (_BasePreferences) {
  11791. _inherits(GenericPreferences, _BasePreferences);
  11792. var _super = _createSuper(GenericPreferences);
  11793. function GenericPreferences() {
  11794. _classCallCheck(this, GenericPreferences);
  11795. return _super.apply(this, arguments);
  11796. }
  11797. _createClass(GenericPreferences, [{
  11798. key: "_writeToStorage",
  11799. value: function () {
  11800. var _writeToStorage2 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee(prefObj) {
  11801. return _regenerator["default"].wrap(function _callee$(_context) {
  11802. while (1) {
  11803. switch (_context.prev = _context.next) {
  11804. case 0:
  11805. localStorage.setItem("pdfjs.preferences", JSON.stringify(prefObj));
  11806. case 1:
  11807. case "end":
  11808. return _context.stop();
  11809. }
  11810. }
  11811. }, _callee);
  11812. }));
  11813. function _writeToStorage(_x) {
  11814. return _writeToStorage2.apply(this, arguments);
  11815. }
  11816. return _writeToStorage;
  11817. }()
  11818. }, {
  11819. key: "_readFromStorage",
  11820. value: function () {
  11821. var _readFromStorage2 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee2(prefObj) {
  11822. return _regenerator["default"].wrap(function _callee2$(_context2) {
  11823. while (1) {
  11824. switch (_context2.prev = _context2.next) {
  11825. case 0:
  11826. return _context2.abrupt("return", JSON.parse(localStorage.getItem("pdfjs.preferences")));
  11827. case 1:
  11828. case "end":
  11829. return _context2.stop();
  11830. }
  11831. }
  11832. }, _callee2);
  11833. }));
  11834. function _readFromStorage(_x2) {
  11835. return _readFromStorage2.apply(this, arguments);
  11836. }
  11837. return _readFromStorage;
  11838. }()
  11839. }]);
  11840. return GenericPreferences;
  11841. }(_preferences.BasePreferences);
  11842. var GenericExternalServices = /*#__PURE__*/function (_DefaultExternalServi) {
  11843. _inherits(GenericExternalServices, _DefaultExternalServi);
  11844. var _super2 = _createSuper(GenericExternalServices);
  11845. function GenericExternalServices() {
  11846. _classCallCheck(this, GenericExternalServices);
  11847. return _super2.apply(this, arguments);
  11848. }
  11849. _createClass(GenericExternalServices, null, [{
  11850. key: "createDownloadManager",
  11851. value: function createDownloadManager(options) {
  11852. return new _download_manager.DownloadManager(options);
  11853. }
  11854. }, {
  11855. key: "createPreferences",
  11856. value: function createPreferences() {
  11857. return new GenericPreferences();
  11858. }
  11859. }, {
  11860. key: "createL10n",
  11861. value: function createL10n(_ref) {
  11862. var _ref$locale = _ref.locale,
  11863. locale = _ref$locale === void 0 ? "en-US" : _ref$locale;
  11864. return new _genericl10n.GenericL10n(locale);
  11865. }
  11866. }]);
  11867. return GenericExternalServices;
  11868. }(_app.DefaultExternalServices);
  11869. _app.PDFViewerApplication.externalServices = GenericExternalServices;
  11870. /***/ }),
  11871. /* 37 */
  11872. /***/ (function(module, exports, __webpack_require__) {
  11873. "use strict";
  11874. Object.defineProperty(exports, "__esModule", {
  11875. value: true
  11876. });
  11877. exports.BasePreferences = void 0;
  11878. var _regenerator = _interopRequireDefault(__webpack_require__(2));
  11879. var _app_options = __webpack_require__(6);
  11880. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  11881. 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); } }
  11882. 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); }); }; }
  11883. 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); }
  11884. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  11885. 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); } }
  11886. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  11887. var defaultPreferences = null;
  11888. function getDefaultPreferences() {
  11889. if (!defaultPreferences) {
  11890. defaultPreferences = Promise.resolve({
  11891. "cursorToolOnLoad": 0,
  11892. "defaultZoomValue": "",
  11893. "disablePageLabels": false,
  11894. "enablePermissions": false,
  11895. "enablePrintAutoRotate": false,
  11896. "enableWebGL": false,
  11897. "externalLinkTarget": 0,
  11898. "historyUpdateUrl": false,
  11899. "ignoreDestinationZoom": false,
  11900. "pdfBugEnabled": false,
  11901. "renderer": "canvas",
  11902. "renderInteractiveForms": false,
  11903. "sidebarViewOnLoad": -1,
  11904. "scrollModeOnLoad": -1,
  11905. "spreadModeOnLoad": -1,
  11906. "textLayerMode": 1,
  11907. "useOnlyCssZoom": false,
  11908. "viewOnLoad": 0,
  11909. "disableAutoFetch": false,
  11910. "disableFontFace": false,
  11911. "disableRange": false,
  11912. "disableStream": false
  11913. });
  11914. }
  11915. return defaultPreferences;
  11916. }
  11917. var BasePreferences = /*#__PURE__*/function () {
  11918. function BasePreferences() {
  11919. var _this = this;
  11920. _classCallCheck(this, BasePreferences);
  11921. if (this.constructor === BasePreferences) {
  11922. throw new Error("Cannot initialize BasePreferences.");
  11923. }
  11924. this.prefs = null;
  11925. this._initializedPromise = getDefaultPreferences().then(function (defaults) {
  11926. Object.defineProperty(_this, "defaults", {
  11927. value: Object.freeze(defaults),
  11928. writable: false,
  11929. enumerable: true,
  11930. configurable: false
  11931. });
  11932. _this.prefs = Object.assign(Object.create(null), defaults);
  11933. return _this._readFromStorage(defaults);
  11934. }).then(function (prefs) {
  11935. if (!prefs) {
  11936. return;
  11937. }
  11938. for (var name in prefs) {
  11939. var defaultValue = _this.defaults[name],
  11940. prefValue = prefs[name];
  11941. if (defaultValue === undefined || _typeof(prefValue) !== _typeof(defaultValue)) {
  11942. continue;
  11943. }
  11944. _this.prefs[name] = prefValue;
  11945. }
  11946. });
  11947. }
  11948. _createClass(BasePreferences, [{
  11949. key: "_writeToStorage",
  11950. value: function () {
  11951. var _writeToStorage2 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee(prefObj) {
  11952. return _regenerator["default"].wrap(function _callee$(_context) {
  11953. while (1) {
  11954. switch (_context.prev = _context.next) {
  11955. case 0:
  11956. throw new Error("Not implemented: _writeToStorage");
  11957. case 1:
  11958. case "end":
  11959. return _context.stop();
  11960. }
  11961. }
  11962. }, _callee);
  11963. }));
  11964. function _writeToStorage(_x) {
  11965. return _writeToStorage2.apply(this, arguments);
  11966. }
  11967. return _writeToStorage;
  11968. }()
  11969. }, {
  11970. key: "_readFromStorage",
  11971. value: function () {
  11972. var _readFromStorage2 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee2(prefObj) {
  11973. return _regenerator["default"].wrap(function _callee2$(_context2) {
  11974. while (1) {
  11975. switch (_context2.prev = _context2.next) {
  11976. case 0:
  11977. throw new Error("Not implemented: _readFromStorage");
  11978. case 1:
  11979. case "end":
  11980. return _context2.stop();
  11981. }
  11982. }
  11983. }, _callee2);
  11984. }));
  11985. function _readFromStorage(_x2) {
  11986. return _readFromStorage2.apply(this, arguments);
  11987. }
  11988. return _readFromStorage;
  11989. }()
  11990. }, {
  11991. key: "reset",
  11992. value: function () {
  11993. var _reset = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee3() {
  11994. return _regenerator["default"].wrap(function _callee3$(_context3) {
  11995. while (1) {
  11996. switch (_context3.prev = _context3.next) {
  11997. case 0:
  11998. _context3.next = 2;
  11999. return this._initializedPromise;
  12000. case 2:
  12001. this.prefs = Object.assign(Object.create(null), this.defaults);
  12002. return _context3.abrupt("return", this._writeToStorage(this.defaults));
  12003. case 4:
  12004. case "end":
  12005. return _context3.stop();
  12006. }
  12007. }
  12008. }, _callee3, this);
  12009. }));
  12010. function reset() {
  12011. return _reset.apply(this, arguments);
  12012. }
  12013. return reset;
  12014. }()
  12015. }, {
  12016. key: "set",
  12017. value: function () {
  12018. var _set = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee4(name, value) {
  12019. var defaultValue, valueType, defaultType;
  12020. return _regenerator["default"].wrap(function _callee4$(_context4) {
  12021. while (1) {
  12022. switch (_context4.prev = _context4.next) {
  12023. case 0:
  12024. _context4.next = 2;
  12025. return this._initializedPromise;
  12026. case 2:
  12027. defaultValue = this.defaults[name];
  12028. if (!(defaultValue === undefined)) {
  12029. _context4.next = 7;
  12030. break;
  12031. }
  12032. throw new Error("Set preference: \"".concat(name, "\" is undefined."));
  12033. case 7:
  12034. if (!(value === undefined)) {
  12035. _context4.next = 9;
  12036. break;
  12037. }
  12038. throw new Error("Set preference: no value is specified.");
  12039. case 9:
  12040. valueType = _typeof(value);
  12041. defaultType = _typeof(defaultValue);
  12042. if (!(valueType !== defaultType)) {
  12043. _context4.next = 19;
  12044. break;
  12045. }
  12046. if (!(valueType === "number" && defaultType === "string")) {
  12047. _context4.next = 16;
  12048. break;
  12049. }
  12050. value = value.toString();
  12051. _context4.next = 17;
  12052. break;
  12053. case 16:
  12054. throw new Error("Set preference: \"".concat(value, "\" is a ").concat(valueType, ", ") + "expected a ".concat(defaultType, "."));
  12055. case 17:
  12056. _context4.next = 21;
  12057. break;
  12058. case 19:
  12059. if (!(valueType === "number" && !Number.isInteger(value))) {
  12060. _context4.next = 21;
  12061. break;
  12062. }
  12063. throw new Error("Set preference: \"".concat(value, "\" must be an integer."));
  12064. case 21:
  12065. this.prefs[name] = value;
  12066. return _context4.abrupt("return", this._writeToStorage(this.prefs));
  12067. case 23:
  12068. case "end":
  12069. return _context4.stop();
  12070. }
  12071. }
  12072. }, _callee4, this);
  12073. }));
  12074. function set(_x3, _x4) {
  12075. return _set.apply(this, arguments);
  12076. }
  12077. return set;
  12078. }()
  12079. }, {
  12080. key: "get",
  12081. value: function () {
  12082. var _get = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee5(name) {
  12083. var defaultValue, prefValue;
  12084. return _regenerator["default"].wrap(function _callee5$(_context5) {
  12085. while (1) {
  12086. switch (_context5.prev = _context5.next) {
  12087. case 0:
  12088. _context5.next = 2;
  12089. return this._initializedPromise;
  12090. case 2:
  12091. defaultValue = this.defaults[name];
  12092. if (!(defaultValue === undefined)) {
  12093. _context5.next = 7;
  12094. break;
  12095. }
  12096. throw new Error("Get preference: \"".concat(name, "\" is undefined."));
  12097. case 7:
  12098. prefValue = this.prefs[name];
  12099. if (!(prefValue !== undefined)) {
  12100. _context5.next = 10;
  12101. break;
  12102. }
  12103. return _context5.abrupt("return", prefValue);
  12104. case 10:
  12105. return _context5.abrupt("return", defaultValue);
  12106. case 11:
  12107. case "end":
  12108. return _context5.stop();
  12109. }
  12110. }
  12111. }, _callee5, this);
  12112. }));
  12113. function get(_x5) {
  12114. return _get.apply(this, arguments);
  12115. }
  12116. return get;
  12117. }()
  12118. }, {
  12119. key: "getAll",
  12120. value: function () {
  12121. var _getAll = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee6() {
  12122. return _regenerator["default"].wrap(function _callee6$(_context6) {
  12123. while (1) {
  12124. switch (_context6.prev = _context6.next) {
  12125. case 0:
  12126. _context6.next = 2;
  12127. return this._initializedPromise;
  12128. case 2:
  12129. return _context6.abrupt("return", Object.assign(Object.create(null), this.defaults, this.prefs));
  12130. case 3:
  12131. case "end":
  12132. return _context6.stop();
  12133. }
  12134. }
  12135. }, _callee6, this);
  12136. }));
  12137. function getAll() {
  12138. return _getAll.apply(this, arguments);
  12139. }
  12140. return getAll;
  12141. }()
  12142. }]);
  12143. return BasePreferences;
  12144. }();
  12145. exports.BasePreferences = BasePreferences;
  12146. /***/ }),
  12147. /* 38 */
  12148. /***/ (function(module, exports, __webpack_require__) {
  12149. "use strict";
  12150. Object.defineProperty(exports, "__esModule", {
  12151. value: true
  12152. });
  12153. exports.DownloadManager = void 0;
  12154. var _pdfjsLib = __webpack_require__(8);
  12155. var _viewer_compatibility = __webpack_require__(7);
  12156. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  12157. 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); } }
  12158. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  12159. ;
  12160. var DISABLE_CREATE_OBJECT_URL = _viewer_compatibility.viewerCompatibilityParams.disableCreateObjectURL || false;
  12161. function _download(blobUrl, filename) {
  12162. var a = document.createElement("a");
  12163. if (!a.click) {
  12164. throw new Error('DownloadManager: "a.click()" is not supported.');
  12165. }
  12166. a.href = blobUrl;
  12167. a.target = "_parent";
  12168. if ("download" in a) {
  12169. a.download = filename;
  12170. }
  12171. (document.body || document.documentElement).appendChild(a);
  12172. a.click();
  12173. a.remove();
  12174. }
  12175. var DownloadManager = /*#__PURE__*/function () {
  12176. function DownloadManager(_ref) {
  12177. var _ref$disableCreateObj = _ref.disableCreateObjectURL,
  12178. disableCreateObjectURL = _ref$disableCreateObj === void 0 ? DISABLE_CREATE_OBJECT_URL : _ref$disableCreateObj;
  12179. _classCallCheck(this, DownloadManager);
  12180. this.disableCreateObjectURL = disableCreateObjectURL;
  12181. }
  12182. _createClass(DownloadManager, [{
  12183. key: "downloadUrl",
  12184. value: function downloadUrl(url, filename) {
  12185. if (!(0, _pdfjsLib.createValidAbsoluteUrl)(url, "http://example.com")) {
  12186. return;
  12187. }
  12188. _download(url + "#pdfjs.action=download", filename);
  12189. }
  12190. }, {
  12191. key: "downloadData",
  12192. value: function downloadData(data, filename, contentType) {
  12193. if (navigator.msSaveBlob) {
  12194. navigator.msSaveBlob(new Blob([data], {
  12195. type: contentType
  12196. }), filename);
  12197. return;
  12198. }
  12199. var blobUrl = (0, _pdfjsLib.createObjectURL)(data, contentType, this.disableCreateObjectURL);
  12200. _download(blobUrl, filename);
  12201. }
  12202. }, {
  12203. key: "download",
  12204. value: function download(blob, url, filename) {
  12205. if (navigator.msSaveBlob) {
  12206. if (!navigator.msSaveBlob(blob, filename)) {
  12207. this.downloadUrl(url, filename);
  12208. }
  12209. return;
  12210. }
  12211. if (this.disableCreateObjectURL) {
  12212. this.downloadUrl(url, filename);
  12213. return;
  12214. }
  12215. var blobUrl = URL.createObjectURL(blob);
  12216. _download(blobUrl, filename);
  12217. }
  12218. }]);
  12219. return DownloadManager;
  12220. }();
  12221. exports.DownloadManager = DownloadManager;
  12222. /***/ }),
  12223. /* 39 */
  12224. /***/ (function(module, exports, __webpack_require__) {
  12225. "use strict";
  12226. Object.defineProperty(exports, "__esModule", {
  12227. value: true
  12228. });
  12229. exports.GenericL10n = void 0;
  12230. var _regenerator = _interopRequireDefault(__webpack_require__(2));
  12231. __webpack_require__(40);
  12232. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  12233. 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); } }
  12234. 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); }); }; }
  12235. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  12236. 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); } }
  12237. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  12238. var webL10n = document.webL10n;
  12239. var GenericL10n = /*#__PURE__*/function () {
  12240. function GenericL10n(lang) {
  12241. _classCallCheck(this, GenericL10n);
  12242. this._lang = lang;
  12243. this._ready = new Promise(function (resolve, reject) {
  12244. webL10n.setLanguage(lang, function () {
  12245. resolve(webL10n);
  12246. });
  12247. });
  12248. }
  12249. _createClass(GenericL10n, [{
  12250. key: "getLanguage",
  12251. value: function () {
  12252. var _getLanguage = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
  12253. var l10n;
  12254. return _regenerator["default"].wrap(function _callee$(_context) {
  12255. while (1) {
  12256. switch (_context.prev = _context.next) {
  12257. case 0:
  12258. _context.next = 2;
  12259. return this._ready;
  12260. case 2:
  12261. l10n = _context.sent;
  12262. return _context.abrupt("return", l10n.getLanguage());
  12263. case 4:
  12264. case "end":
  12265. return _context.stop();
  12266. }
  12267. }
  12268. }, _callee, this);
  12269. }));
  12270. function getLanguage() {
  12271. return _getLanguage.apply(this, arguments);
  12272. }
  12273. return getLanguage;
  12274. }()
  12275. }, {
  12276. key: "getDirection",
  12277. value: function () {
  12278. var _getDirection = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee2() {
  12279. var l10n;
  12280. return _regenerator["default"].wrap(function _callee2$(_context2) {
  12281. while (1) {
  12282. switch (_context2.prev = _context2.next) {
  12283. case 0:
  12284. _context2.next = 2;
  12285. return this._ready;
  12286. case 2:
  12287. l10n = _context2.sent;
  12288. return _context2.abrupt("return", l10n.getDirection());
  12289. case 4:
  12290. case "end":
  12291. return _context2.stop();
  12292. }
  12293. }
  12294. }, _callee2, this);
  12295. }));
  12296. function getDirection() {
  12297. return _getDirection.apply(this, arguments);
  12298. }
  12299. return getDirection;
  12300. }()
  12301. }, {
  12302. key: "get",
  12303. value: function () {
  12304. var _get = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee3(property, args, fallback) {
  12305. var l10n;
  12306. return _regenerator["default"].wrap(function _callee3$(_context3) {
  12307. while (1) {
  12308. switch (_context3.prev = _context3.next) {
  12309. case 0:
  12310. _context3.next = 2;
  12311. return this._ready;
  12312. case 2:
  12313. l10n = _context3.sent;
  12314. return _context3.abrupt("return", l10n.get(property, args, fallback));
  12315. case 4:
  12316. case "end":
  12317. return _context3.stop();
  12318. }
  12319. }
  12320. }, _callee3, this);
  12321. }));
  12322. function get(_x, _x2, _x3) {
  12323. return _get.apply(this, arguments);
  12324. }
  12325. return get;
  12326. }()
  12327. }, {
  12328. key: "translate",
  12329. value: function () {
  12330. var _translate = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee4(element) {
  12331. var l10n;
  12332. return _regenerator["default"].wrap(function _callee4$(_context4) {
  12333. while (1) {
  12334. switch (_context4.prev = _context4.next) {
  12335. case 0:
  12336. _context4.next = 2;
  12337. return this._ready;
  12338. case 2:
  12339. l10n = _context4.sent;
  12340. return _context4.abrupt("return", l10n.translate(element));
  12341. case 4:
  12342. case "end":
  12343. return _context4.stop();
  12344. }
  12345. }
  12346. }, _callee4, this);
  12347. }));
  12348. function translate(_x4) {
  12349. return _translate.apply(this, arguments);
  12350. }
  12351. return translate;
  12352. }()
  12353. }]);
  12354. return GenericL10n;
  12355. }();
  12356. exports.GenericL10n = GenericL10n;
  12357. /***/ }),
  12358. /* 40 */
  12359. /***/ (function(module, exports, __webpack_require__) {
  12360. "use strict";
  12361. document.webL10n = function (window, document, undefined) {
  12362. var gL10nData = {};
  12363. var gTextData = '';
  12364. var gTextProp = 'textContent';
  12365. var gLanguage = '';
  12366. var gMacros = {};
  12367. var gReadyState = 'loading';
  12368. var gAsyncResourceLoading = true;
  12369. function getL10nResourceLinks() {
  12370. return document.querySelectorAll('link[type="application/l10n"]');
  12371. }
  12372. function getL10nDictionary() {
  12373. var script = document.querySelector('script[type="application/l10n"]');
  12374. return script ? JSON.parse(script.innerHTML) : null;
  12375. }
  12376. function getTranslatableChildren(element) {
  12377. return element ? element.querySelectorAll('*[data-l10n-id]') : [];
  12378. }
  12379. function getL10nAttributes(element) {
  12380. if (!element) return {};
  12381. var l10nId = element.getAttribute('data-l10n-id');
  12382. var l10nArgs = element.getAttribute('data-l10n-args');
  12383. var args = {};
  12384. if (l10nArgs) {
  12385. try {
  12386. args = JSON.parse(l10nArgs);
  12387. } catch (e) {
  12388. console.warn('could not parse arguments for #' + l10nId);
  12389. }
  12390. }
  12391. return {
  12392. id: l10nId,
  12393. args: args
  12394. };
  12395. }
  12396. function xhrLoadText(url, onSuccess, onFailure) {
  12397. onSuccess = onSuccess || function _onSuccess(data) {};
  12398. onFailure = onFailure || function _onFailure() {};
  12399. var xhr = new XMLHttpRequest();
  12400. xhr.open('GET', url, gAsyncResourceLoading);
  12401. if (xhr.overrideMimeType) {
  12402. xhr.overrideMimeType('text/plain; charset=utf-8');
  12403. }
  12404. xhr.onreadystatechange = function () {
  12405. if (xhr.readyState == 4) {
  12406. if (xhr.status == 200 || xhr.status === 0) {
  12407. onSuccess(xhr.responseText);
  12408. } else {
  12409. onFailure();
  12410. }
  12411. }
  12412. };
  12413. xhr.onerror = onFailure;
  12414. xhr.ontimeout = onFailure;
  12415. try {
  12416. xhr.send(null);
  12417. } catch (e) {
  12418. onFailure();
  12419. }
  12420. }
  12421. function parseResource(href, lang, successCallback, failureCallback) {
  12422. var baseURL = href.replace(/[^\/]*$/, '') || './';
  12423. function evalString(text) {
  12424. if (text.lastIndexOf('\\') < 0) return text;
  12425. 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, "'");
  12426. }
  12427. function parseProperties(text, parsedPropertiesCallback) {
  12428. var dictionary = {};
  12429. var reBlank = /^\s*|\s*$/;
  12430. var reComment = /^\s*#|^\s*$/;
  12431. var reSection = /^\s*\[(.*)\]\s*$/;
  12432. var reImport = /^\s*@import\s+url\((.*)\)\s*$/i;
  12433. var reSplit = /^([^=\s]*)\s*=\s*(.+)$/;
  12434. function parseRawLines(rawText, extendedSyntax, parsedRawLinesCallback) {
  12435. var entries = rawText.replace(reBlank, '').split(/[\r\n]+/);
  12436. var currentLang = '*';
  12437. var genericLang = lang.split('-', 1)[0];
  12438. var skipLang = false;
  12439. var match = '';
  12440. function nextEntry() {
  12441. while (true) {
  12442. if (!entries.length) {
  12443. parsedRawLinesCallback();
  12444. return;
  12445. }
  12446. var line = entries.shift();
  12447. if (reComment.test(line)) continue;
  12448. if (extendedSyntax) {
  12449. match = reSection.exec(line);
  12450. if (match) {
  12451. currentLang = match[1].toLowerCase();
  12452. skipLang = currentLang !== '*' && currentLang !== lang && currentLang !== genericLang;
  12453. continue;
  12454. } else if (skipLang) {
  12455. continue;
  12456. }
  12457. match = reImport.exec(line);
  12458. if (match) {
  12459. loadImport(baseURL + match[1], nextEntry);
  12460. return;
  12461. }
  12462. }
  12463. var tmp = line.match(reSplit);
  12464. if (tmp && tmp.length == 3) {
  12465. dictionary[tmp[1]] = evalString(tmp[2]);
  12466. }
  12467. }
  12468. }
  12469. nextEntry();
  12470. }
  12471. function loadImport(url, callback) {
  12472. xhrLoadText(url, function (content) {
  12473. parseRawLines(content, false, callback);
  12474. }, function () {
  12475. console.warn(url + ' not found.');
  12476. callback();
  12477. });
  12478. }
  12479. parseRawLines(text, true, function () {
  12480. parsedPropertiesCallback(dictionary);
  12481. });
  12482. }
  12483. xhrLoadText(href, function (response) {
  12484. gTextData += response;
  12485. parseProperties(response, function (data) {
  12486. for (var key in data) {
  12487. var id,
  12488. prop,
  12489. index = key.lastIndexOf('.');
  12490. if (index > 0) {
  12491. id = key.substring(0, index);
  12492. prop = key.substring(index + 1);
  12493. } else {
  12494. id = key;
  12495. prop = gTextProp;
  12496. }
  12497. if (!gL10nData[id]) {
  12498. gL10nData[id] = {};
  12499. }
  12500. gL10nData[id][prop] = data[key];
  12501. }
  12502. if (successCallback) {
  12503. successCallback();
  12504. }
  12505. });
  12506. }, failureCallback);
  12507. }
  12508. function loadLocale(lang, callback) {
  12509. if (lang) {
  12510. lang = lang.toLowerCase();
  12511. }
  12512. callback = callback || function _callback() {};
  12513. clear();
  12514. gLanguage = lang;
  12515. var langLinks = getL10nResourceLinks();
  12516. var langCount = langLinks.length;
  12517. if (langCount === 0) {
  12518. var dict = getL10nDictionary();
  12519. if (dict && dict.locales && dict.default_locale) {
  12520. console.log('using the embedded JSON directory, early way out');
  12521. gL10nData = dict.locales[lang];
  12522. if (!gL10nData) {
  12523. var defaultLocale = dict.default_locale.toLowerCase();
  12524. for (var anyCaseLang in dict.locales) {
  12525. anyCaseLang = anyCaseLang.toLowerCase();
  12526. if (anyCaseLang === lang) {
  12527. gL10nData = dict.locales[lang];
  12528. break;
  12529. } else if (anyCaseLang === defaultLocale) {
  12530. gL10nData = dict.locales[defaultLocale];
  12531. }
  12532. }
  12533. }
  12534. callback();
  12535. } else {
  12536. console.log('no resource to load, early way out');
  12537. }
  12538. gReadyState = 'complete';
  12539. return;
  12540. }
  12541. var onResourceLoaded = null;
  12542. var gResourceCount = 0;
  12543. onResourceLoaded = function onResourceLoaded() {
  12544. gResourceCount++;
  12545. if (gResourceCount >= langCount) {
  12546. callback();
  12547. gReadyState = 'complete';
  12548. }
  12549. };
  12550. function L10nResourceLink(link) {
  12551. var href = link.href;
  12552. this.load = function (lang, callback) {
  12553. parseResource(href, lang, callback, function () {
  12554. console.warn(href + ' not found.');
  12555. console.warn('"' + lang + '" resource not found');
  12556. gLanguage = '';
  12557. callback();
  12558. });
  12559. };
  12560. }
  12561. for (var i = 0; i < langCount; i++) {
  12562. var resource = new L10nResourceLink(langLinks[i]);
  12563. resource.load(lang, onResourceLoaded);
  12564. }
  12565. }
  12566. function clear() {
  12567. gL10nData = {};
  12568. gTextData = '';
  12569. gLanguage = '';
  12570. }
  12571. function getPluralRules(lang) {
  12572. var locales2rules = {
  12573. 'af': 3,
  12574. 'ak': 4,
  12575. 'am': 4,
  12576. 'ar': 1,
  12577. 'asa': 3,
  12578. 'az': 0,
  12579. 'be': 11,
  12580. 'bem': 3,
  12581. 'bez': 3,
  12582. 'bg': 3,
  12583. 'bh': 4,
  12584. 'bm': 0,
  12585. 'bn': 3,
  12586. 'bo': 0,
  12587. 'br': 20,
  12588. 'brx': 3,
  12589. 'bs': 11,
  12590. 'ca': 3,
  12591. 'cgg': 3,
  12592. 'chr': 3,
  12593. 'cs': 12,
  12594. 'cy': 17,
  12595. 'da': 3,
  12596. 'de': 3,
  12597. 'dv': 3,
  12598. 'dz': 0,
  12599. 'ee': 3,
  12600. 'el': 3,
  12601. 'en': 3,
  12602. 'eo': 3,
  12603. 'es': 3,
  12604. 'et': 3,
  12605. 'eu': 3,
  12606. 'fa': 0,
  12607. 'ff': 5,
  12608. 'fi': 3,
  12609. 'fil': 4,
  12610. 'fo': 3,
  12611. 'fr': 5,
  12612. 'fur': 3,
  12613. 'fy': 3,
  12614. 'ga': 8,
  12615. 'gd': 24,
  12616. 'gl': 3,
  12617. 'gsw': 3,
  12618. 'gu': 3,
  12619. 'guw': 4,
  12620. 'gv': 23,
  12621. 'ha': 3,
  12622. 'haw': 3,
  12623. 'he': 2,
  12624. 'hi': 4,
  12625. 'hr': 11,
  12626. 'hu': 0,
  12627. 'id': 0,
  12628. 'ig': 0,
  12629. 'ii': 0,
  12630. 'is': 3,
  12631. 'it': 3,
  12632. 'iu': 7,
  12633. 'ja': 0,
  12634. 'jmc': 3,
  12635. 'jv': 0,
  12636. 'ka': 0,
  12637. 'kab': 5,
  12638. 'kaj': 3,
  12639. 'kcg': 3,
  12640. 'kde': 0,
  12641. 'kea': 0,
  12642. 'kk': 3,
  12643. 'kl': 3,
  12644. 'km': 0,
  12645. 'kn': 0,
  12646. 'ko': 0,
  12647. 'ksb': 3,
  12648. 'ksh': 21,
  12649. 'ku': 3,
  12650. 'kw': 7,
  12651. 'lag': 18,
  12652. 'lb': 3,
  12653. 'lg': 3,
  12654. 'ln': 4,
  12655. 'lo': 0,
  12656. 'lt': 10,
  12657. 'lv': 6,
  12658. 'mas': 3,
  12659. 'mg': 4,
  12660. 'mk': 16,
  12661. 'ml': 3,
  12662. 'mn': 3,
  12663. 'mo': 9,
  12664. 'mr': 3,
  12665. 'ms': 0,
  12666. 'mt': 15,
  12667. 'my': 0,
  12668. 'nah': 3,
  12669. 'naq': 7,
  12670. 'nb': 3,
  12671. 'nd': 3,
  12672. 'ne': 3,
  12673. 'nl': 3,
  12674. 'nn': 3,
  12675. 'no': 3,
  12676. 'nr': 3,
  12677. 'nso': 4,
  12678. 'ny': 3,
  12679. 'nyn': 3,
  12680. 'om': 3,
  12681. 'or': 3,
  12682. 'pa': 3,
  12683. 'pap': 3,
  12684. 'pl': 13,
  12685. 'ps': 3,
  12686. 'pt': 3,
  12687. 'rm': 3,
  12688. 'ro': 9,
  12689. 'rof': 3,
  12690. 'ru': 11,
  12691. 'rwk': 3,
  12692. 'sah': 0,
  12693. 'saq': 3,
  12694. 'se': 7,
  12695. 'seh': 3,
  12696. 'ses': 0,
  12697. 'sg': 0,
  12698. 'sh': 11,
  12699. 'shi': 19,
  12700. 'sk': 12,
  12701. 'sl': 14,
  12702. 'sma': 7,
  12703. 'smi': 7,
  12704. 'smj': 7,
  12705. 'smn': 7,
  12706. 'sms': 7,
  12707. 'sn': 3,
  12708. 'so': 3,
  12709. 'sq': 3,
  12710. 'sr': 11,
  12711. 'ss': 3,
  12712. 'ssy': 3,
  12713. 'st': 3,
  12714. 'sv': 3,
  12715. 'sw': 3,
  12716. 'syr': 3,
  12717. 'ta': 3,
  12718. 'te': 3,
  12719. 'teo': 3,
  12720. 'th': 0,
  12721. 'ti': 4,
  12722. 'tig': 3,
  12723. 'tk': 3,
  12724. 'tl': 4,
  12725. 'tn': 3,
  12726. 'to': 0,
  12727. 'tr': 0,
  12728. 'ts': 3,
  12729. 'tzm': 22,
  12730. 'uk': 11,
  12731. 'ur': 3,
  12732. 've': 3,
  12733. 'vi': 0,
  12734. 'vun': 3,
  12735. 'wa': 4,
  12736. 'wae': 3,
  12737. 'wo': 0,
  12738. 'xh': 3,
  12739. 'xog': 3,
  12740. 'yo': 0,
  12741. 'zh': 0,
  12742. 'zu': 3
  12743. };
  12744. function isIn(n, list) {
  12745. return list.indexOf(n) !== -1;
  12746. }
  12747. function isBetween(n, start, end) {
  12748. return start <= n && n <= end;
  12749. }
  12750. var pluralRules = {
  12751. '0': function _(n) {
  12752. return 'other';
  12753. },
  12754. '1': function _(n) {
  12755. if (isBetween(n % 100, 3, 10)) return 'few';
  12756. if (n === 0) return 'zero';
  12757. if (isBetween(n % 100, 11, 99)) return 'many';
  12758. if (n == 2) return 'two';
  12759. if (n == 1) return 'one';
  12760. return 'other';
  12761. },
  12762. '2': function _(n) {
  12763. if (n !== 0 && n % 10 === 0) return 'many';
  12764. if (n == 2) return 'two';
  12765. if (n == 1) return 'one';
  12766. return 'other';
  12767. },
  12768. '3': function _(n) {
  12769. if (n == 1) return 'one';
  12770. return 'other';
  12771. },
  12772. '4': function _(n) {
  12773. if (isBetween(n, 0, 1)) return 'one';
  12774. return 'other';
  12775. },
  12776. '5': function _(n) {
  12777. if (isBetween(n, 0, 2) && n != 2) return 'one';
  12778. return 'other';
  12779. },
  12780. '6': function _(n) {
  12781. if (n === 0) return 'zero';
  12782. if (n % 10 == 1 && n % 100 != 11) return 'one';
  12783. return 'other';
  12784. },
  12785. '7': function _(n) {
  12786. if (n == 2) return 'two';
  12787. if (n == 1) return 'one';
  12788. return 'other';
  12789. },
  12790. '8': function _(n) {
  12791. if (isBetween(n, 3, 6)) return 'few';
  12792. if (isBetween(n, 7, 10)) return 'many';
  12793. if (n == 2) return 'two';
  12794. if (n == 1) return 'one';
  12795. return 'other';
  12796. },
  12797. '9': function _(n) {
  12798. if (n === 0 || n != 1 && isBetween(n % 100, 1, 19)) return 'few';
  12799. if (n == 1) return 'one';
  12800. return 'other';
  12801. },
  12802. '10': function _(n) {
  12803. if (isBetween(n % 10, 2, 9) && !isBetween(n % 100, 11, 19)) return 'few';
  12804. if (n % 10 == 1 && !isBetween(n % 100, 11, 19)) return 'one';
  12805. return 'other';
  12806. },
  12807. '11': function _(n) {
  12808. if (isBetween(n % 10, 2, 4) && !isBetween(n % 100, 12, 14)) return 'few';
  12809. if (n % 10 === 0 || isBetween(n % 10, 5, 9) || isBetween(n % 100, 11, 14)) return 'many';
  12810. if (n % 10 == 1 && n % 100 != 11) return 'one';
  12811. return 'other';
  12812. },
  12813. '12': function _(n) {
  12814. if (isBetween(n, 2, 4)) return 'few';
  12815. if (n == 1) return 'one';
  12816. return 'other';
  12817. },
  12818. '13': function _(n) {
  12819. if (isBetween(n % 10, 2, 4) && !isBetween(n % 100, 12, 14)) return 'few';
  12820. if (n != 1 && isBetween(n % 10, 0, 1) || isBetween(n % 10, 5, 9) || isBetween(n % 100, 12, 14)) return 'many';
  12821. if (n == 1) return 'one';
  12822. return 'other';
  12823. },
  12824. '14': function _(n) {
  12825. if (isBetween(n % 100, 3, 4)) return 'few';
  12826. if (n % 100 == 2) return 'two';
  12827. if (n % 100 == 1) return 'one';
  12828. return 'other';
  12829. },
  12830. '15': function _(n) {
  12831. if (n === 0 || isBetween(n % 100, 2, 10)) return 'few';
  12832. if (isBetween(n % 100, 11, 19)) return 'many';
  12833. if (n == 1) return 'one';
  12834. return 'other';
  12835. },
  12836. '16': function _(n) {
  12837. if (n % 10 == 1 && n != 11) return 'one';
  12838. return 'other';
  12839. },
  12840. '17': function _(n) {
  12841. if (n == 3) return 'few';
  12842. if (n === 0) return 'zero';
  12843. if (n == 6) return 'many';
  12844. if (n == 2) return 'two';
  12845. if (n == 1) return 'one';
  12846. return 'other';
  12847. },
  12848. '18': function _(n) {
  12849. if (n === 0) return 'zero';
  12850. if (isBetween(n, 0, 2) && n !== 0 && n != 2) return 'one';
  12851. return 'other';
  12852. },
  12853. '19': function _(n) {
  12854. if (isBetween(n, 2, 10)) return 'few';
  12855. if (isBetween(n, 0, 1)) return 'one';
  12856. return 'other';
  12857. },
  12858. '20': function _(n) {
  12859. 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';
  12860. if (n % 1000000 === 0 && n !== 0) return 'many';
  12861. if (n % 10 == 2 && !isIn(n % 100, [12, 72, 92])) return 'two';
  12862. if (n % 10 == 1 && !isIn(n % 100, [11, 71, 91])) return 'one';
  12863. return 'other';
  12864. },
  12865. '21': function _(n) {
  12866. if (n === 0) return 'zero';
  12867. if (n == 1) return 'one';
  12868. return 'other';
  12869. },
  12870. '22': function _(n) {
  12871. if (isBetween(n, 0, 1) || isBetween(n, 11, 99)) return 'one';
  12872. return 'other';
  12873. },
  12874. '23': function _(n) {
  12875. if (isBetween(n % 10, 1, 2) || n % 20 === 0) return 'one';
  12876. return 'other';
  12877. },
  12878. '24': function _(n) {
  12879. if (isBetween(n, 3, 10) || isBetween(n, 13, 19)) return 'few';
  12880. if (isIn(n, [2, 12])) return 'two';
  12881. if (isIn(n, [1, 11])) return 'one';
  12882. return 'other';
  12883. }
  12884. };
  12885. var index = locales2rules[lang.replace(/-.*$/, '')];
  12886. if (!(index in pluralRules)) {
  12887. console.warn('plural form unknown for [' + lang + ']');
  12888. return function () {
  12889. return 'other';
  12890. };
  12891. }
  12892. return pluralRules[index];
  12893. }
  12894. gMacros.plural = function (str, param, key, prop) {
  12895. var n = parseFloat(param);
  12896. if (isNaN(n)) return str;
  12897. if (prop != gTextProp) return str;
  12898. if (!gMacros._pluralRules) {
  12899. gMacros._pluralRules = getPluralRules(gLanguage);
  12900. }
  12901. var index = '[' + gMacros._pluralRules(n) + ']';
  12902. if (n === 0 && key + '[zero]' in gL10nData) {
  12903. str = gL10nData[key + '[zero]'][prop];
  12904. } else if (n == 1 && key + '[one]' in gL10nData) {
  12905. str = gL10nData[key + '[one]'][prop];
  12906. } else if (n == 2 && key + '[two]' in gL10nData) {
  12907. str = gL10nData[key + '[two]'][prop];
  12908. } else if (key + index in gL10nData) {
  12909. str = gL10nData[key + index][prop];
  12910. } else if (key + '[other]' in gL10nData) {
  12911. str = gL10nData[key + '[other]'][prop];
  12912. }
  12913. return str;
  12914. };
  12915. function getL10nData(key, args, fallback) {
  12916. var data = gL10nData[key];
  12917. if (!data) {
  12918. console.warn('#' + key + ' is undefined.');
  12919. if (!fallback) {
  12920. return null;
  12921. }
  12922. data = fallback;
  12923. }
  12924. var rv = {};
  12925. for (var prop in data) {
  12926. var str = data[prop];
  12927. str = substIndexes(str, args, key, prop);
  12928. str = substArguments(str, args, key);
  12929. rv[prop] = str;
  12930. }
  12931. return rv;
  12932. }
  12933. function substIndexes(str, args, key, prop) {
  12934. var reIndex = /\{\[\s*([a-zA-Z]+)\(([a-zA-Z]+)\)\s*\]\}/;
  12935. var reMatch = reIndex.exec(str);
  12936. if (!reMatch || !reMatch.length) return str;
  12937. var macroName = reMatch[1];
  12938. var paramName = reMatch[2];
  12939. var param;
  12940. if (args && paramName in args) {
  12941. param = args[paramName];
  12942. } else if (paramName in gL10nData) {
  12943. param = gL10nData[paramName];
  12944. }
  12945. if (macroName in gMacros) {
  12946. var macro = gMacros[macroName];
  12947. str = macro(str, param, key, prop);
  12948. }
  12949. return str;
  12950. }
  12951. function substArguments(str, args, key) {
  12952. var reArgs = /\{\{\s*(.+?)\s*\}\}/g;
  12953. return str.replace(reArgs, function (matched_text, arg) {
  12954. if (args && arg in args) {
  12955. return args[arg];
  12956. }
  12957. if (arg in gL10nData) {
  12958. return gL10nData[arg];
  12959. }
  12960. console.log('argument {{' + arg + '}} for #' + key + ' is undefined.');
  12961. return matched_text;
  12962. });
  12963. }
  12964. function translateElement(element) {
  12965. var l10n = getL10nAttributes(element);
  12966. if (!l10n.id) return;
  12967. var data = getL10nData(l10n.id, l10n.args);
  12968. if (!data) {
  12969. console.warn('#' + l10n.id + ' is undefined.');
  12970. return;
  12971. }
  12972. if (data[gTextProp]) {
  12973. if (getChildElementCount(element) === 0) {
  12974. element[gTextProp] = data[gTextProp];
  12975. } else {
  12976. var children = element.childNodes;
  12977. var found = false;
  12978. for (var i = 0, l = children.length; i < l; i++) {
  12979. if (children[i].nodeType === 3 && /\S/.test(children[i].nodeValue)) {
  12980. if (found) {
  12981. children[i].nodeValue = '';
  12982. } else {
  12983. children[i].nodeValue = data[gTextProp];
  12984. found = true;
  12985. }
  12986. }
  12987. }
  12988. if (!found) {
  12989. var textNode = document.createTextNode(data[gTextProp]);
  12990. element.insertBefore(textNode, element.firstChild);
  12991. }
  12992. }
  12993. delete data[gTextProp];
  12994. }
  12995. for (var k in data) {
  12996. element[k] = data[k];
  12997. }
  12998. }
  12999. function getChildElementCount(element) {
  13000. if (element.children) {
  13001. return element.children.length;
  13002. }
  13003. if (typeof element.childElementCount !== 'undefined') {
  13004. return element.childElementCount;
  13005. }
  13006. var count = 0;
  13007. for (var i = 0; i < element.childNodes.length; i++) {
  13008. count += element.nodeType === 1 ? 1 : 0;
  13009. }
  13010. return count;
  13011. }
  13012. function translateFragment(element) {
  13013. element = element || document.documentElement;
  13014. var children = getTranslatableChildren(element);
  13015. var elementCount = children.length;
  13016. for (var i = 0; i < elementCount; i++) {
  13017. translateElement(children[i]);
  13018. }
  13019. translateElement(element);
  13020. }
  13021. return {
  13022. get: function get(key, args, fallbackString) {
  13023. var index = key.lastIndexOf('.');
  13024. var prop = gTextProp;
  13025. if (index > 0) {
  13026. prop = key.substring(index + 1);
  13027. key = key.substring(0, index);
  13028. }
  13029. var fallback;
  13030. if (fallbackString) {
  13031. fallback = {};
  13032. fallback[prop] = fallbackString;
  13033. }
  13034. var data = getL10nData(key, args, fallback);
  13035. if (data && prop in data) {
  13036. return data[prop];
  13037. }
  13038. return '{{' + key + '}}';
  13039. },
  13040. getData: function getData() {
  13041. return gL10nData;
  13042. },
  13043. getText: function getText() {
  13044. return gTextData;
  13045. },
  13046. getLanguage: function getLanguage() {
  13047. return gLanguage;
  13048. },
  13049. setLanguage: function setLanguage(lang, callback) {
  13050. loadLocale(lang, function () {
  13051. if (callback) callback();
  13052. });
  13053. },
  13054. getDirection: function getDirection() {
  13055. var rtlList = ['ar', 'he', 'fa', 'ps', 'ur'];
  13056. var shortCode = gLanguage.split('-', 1)[0];
  13057. return rtlList.indexOf(shortCode) >= 0 ? 'rtl' : 'ltr';
  13058. },
  13059. translate: translateFragment,
  13060. getReadyState: function getReadyState() {
  13061. return gReadyState;
  13062. },
  13063. ready: function ready(callback) {
  13064. if (!callback) {
  13065. return;
  13066. } else if (gReadyState == 'complete' || gReadyState == 'interactive') {
  13067. window.setTimeout(function () {
  13068. callback();
  13069. });
  13070. } else if (document.addEventListener) {
  13071. document.addEventListener('localized', function once() {
  13072. document.removeEventListener('localized', once);
  13073. callback();
  13074. });
  13075. }
  13076. }
  13077. };
  13078. }(window, document);
  13079. /***/ }),
  13080. /* 41 */
  13081. /***/ (function(module, exports, __webpack_require__) {
  13082. "use strict";
  13083. Object.defineProperty(exports, "__esModule", {
  13084. value: true
  13085. });
  13086. exports.PDFPrintService = PDFPrintService;
  13087. var _ui_utils = __webpack_require__(5);
  13088. var _app = __webpack_require__(1);
  13089. var _app_options = __webpack_require__(6);
  13090. var activeService = null;
  13091. var overlayManager = null;
  13092. function renderPage(activeServiceOnEntry, pdfDocument, pageNumber, size) {
  13093. var scratchCanvas = activeService.scratchCanvas;
  13094. var PRINT_RESOLUTION = _app_options.AppOptions.get("printResolution") || 150;
  13095. var PRINT_UNITS = PRINT_RESOLUTION / 72.0;
  13096. scratchCanvas.width = Math.floor(size.width * PRINT_UNITS);
  13097. scratchCanvas.height = Math.floor(size.height * PRINT_UNITS);
  13098. var width = Math.floor(size.width * _ui_utils.CSS_UNITS) + "px";
  13099. var height = Math.floor(size.height * _ui_utils.CSS_UNITS) + "px";
  13100. var ctx = scratchCanvas.getContext("2d");
  13101. ctx.save();
  13102. ctx.fillStyle = "rgb(255, 255, 255)";
  13103. ctx.fillRect(0, 0, scratchCanvas.width, scratchCanvas.height);
  13104. ctx.restore();
  13105. return pdfDocument.getPage(pageNumber).then(function (pdfPage) {
  13106. var renderContext = {
  13107. canvasContext: ctx,
  13108. transform: [PRINT_UNITS, 0, 0, PRINT_UNITS, 0, 0],
  13109. viewport: pdfPage.getViewport({
  13110. scale: 1,
  13111. rotation: size.rotation
  13112. }),
  13113. intent: "print"
  13114. };
  13115. return pdfPage.render(renderContext).promise;
  13116. }).then(function () {
  13117. return {
  13118. width: width,
  13119. height: height
  13120. };
  13121. });
  13122. }
  13123. function PDFPrintService(pdfDocument, pagesOverview, printContainer, l10n) {
  13124. this.pdfDocument = pdfDocument;
  13125. this.pagesOverview = pagesOverview;
  13126. this.printContainer = printContainer;
  13127. this.l10n = l10n || _ui_utils.NullL10n;
  13128. this.disableCreateObjectURL = _app_options.AppOptions.get("disableCreateObjectURL");
  13129. this.currentPage = -1;
  13130. this.scratchCanvas = document.createElement("canvas");
  13131. }
  13132. PDFPrintService.prototype = {
  13133. layout: function layout() {
  13134. this.throwIfInactive();
  13135. var body = document.querySelector("body");
  13136. body.setAttribute("data-pdfjsprinting", true);
  13137. var hasEqualPageSizes = this.pagesOverview.every(function (size) {
  13138. return size.width === this.pagesOverview[0].width && size.height === this.pagesOverview[0].height;
  13139. }, this);
  13140. if (!hasEqualPageSizes) {
  13141. console.warn("Not all pages have the same size. The printed " + "result may be incorrect!");
  13142. }
  13143. this.pageStyleSheet = document.createElement("style");
  13144. var pageSize = this.pagesOverview[0];
  13145. this.pageStyleSheet.textContent = "@supports ((size:A4) and (size:1pt 1pt)) {" + "@page { size: " + pageSize.width + "pt " + pageSize.height + "pt;}" + "}";
  13146. body.appendChild(this.pageStyleSheet);
  13147. },
  13148. destroy: function destroy() {
  13149. if (activeService !== this) {
  13150. return;
  13151. }
  13152. this.printContainer.textContent = "";
  13153. var body = document.querySelector("body");
  13154. body.removeAttribute("data-pdfjsprinting");
  13155. if (this.pageStyleSheet) {
  13156. this.pageStyleSheet.remove();
  13157. this.pageStyleSheet = null;
  13158. }
  13159. this.scratchCanvas.width = this.scratchCanvas.height = 0;
  13160. this.scratchCanvas = null;
  13161. activeService = null;
  13162. ensureOverlay().then(function () {
  13163. if (overlayManager.active !== "printServiceOverlay") {
  13164. return;
  13165. }
  13166. overlayManager.close("printServiceOverlay");
  13167. });
  13168. },
  13169. renderPages: function renderPages() {
  13170. var _this = this;
  13171. var pageCount = this.pagesOverview.length;
  13172. var renderNextPage = function renderNextPage(resolve, reject) {
  13173. _this.throwIfInactive();
  13174. if (++_this.currentPage >= pageCount) {
  13175. renderProgress(pageCount, pageCount, _this.l10n);
  13176. resolve();
  13177. return;
  13178. }
  13179. var index = _this.currentPage;
  13180. renderProgress(index, pageCount, _this.l10n);
  13181. renderPage(_this, _this.pdfDocument, index + 1, _this.pagesOverview[index]).then(_this.useRenderedPage.bind(_this)).then(function () {
  13182. renderNextPage(resolve, reject);
  13183. }, reject);
  13184. };
  13185. return new Promise(renderNextPage);
  13186. },
  13187. useRenderedPage: function useRenderedPage(printItem) {
  13188. this.throwIfInactive();
  13189. var img = document.createElement("img");
  13190. img.style.width = printItem.width;
  13191. img.style.height = printItem.height;
  13192. var scratchCanvas = this.scratchCanvas;
  13193. if ("toBlob" in scratchCanvas && !this.disableCreateObjectURL) {
  13194. scratchCanvas.toBlob(function (blob) {
  13195. img.src = URL.createObjectURL(blob);
  13196. });
  13197. } else {
  13198. img.src = scratchCanvas.toDataURL();
  13199. }
  13200. var wrapper = document.createElement("div");
  13201. wrapper.appendChild(img);
  13202. this.printContainer.appendChild(wrapper);
  13203. return new Promise(function (resolve, reject) {
  13204. img.onload = resolve;
  13205. img.onerror = reject;
  13206. });
  13207. },
  13208. performPrint: function performPrint() {
  13209. var _this2 = this;
  13210. this.throwIfInactive();
  13211. return new Promise(function (resolve) {
  13212. setTimeout(function () {
  13213. if (!_this2.active) {
  13214. resolve();
  13215. return;
  13216. }
  13217. print.call(window);
  13218. setTimeout(resolve, 20);
  13219. }, 0);
  13220. });
  13221. },
  13222. get active() {
  13223. return this === activeService;
  13224. },
  13225. throwIfInactive: function throwIfInactive() {
  13226. if (!this.active) {
  13227. throw new Error("This print request was cancelled or completed.");
  13228. }
  13229. }
  13230. };
  13231. var print = window.print;
  13232. window.print = function () {
  13233. if (activeService) {
  13234. console.warn("Ignored window.print() because of a pending print job.");
  13235. return;
  13236. }
  13237. ensureOverlay().then(function () {
  13238. if (activeService) {
  13239. overlayManager.open("printServiceOverlay");
  13240. }
  13241. });
  13242. try {
  13243. dispatchEvent("beforeprint");
  13244. } finally {
  13245. if (!activeService) {
  13246. console.error("Expected print service to be initialized.");
  13247. ensureOverlay().then(function () {
  13248. if (overlayManager.active === "printServiceOverlay") {
  13249. overlayManager.close("printServiceOverlay");
  13250. }
  13251. });
  13252. return;
  13253. }
  13254. var activeServiceOnEntry = activeService;
  13255. activeService.renderPages().then(function () {
  13256. return activeServiceOnEntry.performPrint();
  13257. })["catch"](function () {}).then(function () {
  13258. if (activeServiceOnEntry.active) {
  13259. abort();
  13260. }
  13261. });
  13262. }
  13263. };
  13264. function dispatchEvent(eventType) {
  13265. var event = document.createEvent("CustomEvent");
  13266. event.initCustomEvent(eventType, false, false, "custom");
  13267. window.dispatchEvent(event);
  13268. }
  13269. function abort() {
  13270. if (activeService) {
  13271. activeService.destroy();
  13272. dispatchEvent("afterprint");
  13273. }
  13274. }
  13275. function renderProgress(index, total, l10n) {
  13276. var progressContainer = document.getElementById("printServiceOverlay");
  13277. var progress = Math.round(100 * index / total);
  13278. var progressBar = progressContainer.querySelector("progress");
  13279. var progressPerc = progressContainer.querySelector(".relative-progress");
  13280. progressBar.value = progress;
  13281. l10n.get("print_progress_percent", {
  13282. progress: progress
  13283. }, progress + "%").then(function (msg) {
  13284. progressPerc.textContent = msg;
  13285. });
  13286. }
  13287. window.addEventListener("keydown", function (event) {
  13288. if (event.keyCode === 80 && (event.ctrlKey || event.metaKey) && !event.altKey && (!event.shiftKey || window.chrome || window.opera)) {
  13289. window.print();
  13290. event.preventDefault();
  13291. if (event.stopImmediatePropagation) {
  13292. event.stopImmediatePropagation();
  13293. } else {
  13294. event.stopPropagation();
  13295. }
  13296. }
  13297. }, true);
  13298. if ("onbeforeprint" in window) {
  13299. var stopPropagationIfNeeded = function stopPropagationIfNeeded(event) {
  13300. if (event.detail !== "custom" && event.stopImmediatePropagation) {
  13301. event.stopImmediatePropagation();
  13302. }
  13303. };
  13304. window.addEventListener("beforeprint", stopPropagationIfNeeded);
  13305. window.addEventListener("afterprint", stopPropagationIfNeeded);
  13306. }
  13307. var overlayPromise;
  13308. function ensureOverlay() {
  13309. if (!overlayPromise) {
  13310. overlayManager = _app.PDFViewerApplication.overlayManager;
  13311. if (!overlayManager) {
  13312. throw new Error("The overlay manager has not yet been initialized.");
  13313. }
  13314. overlayPromise = overlayManager.register("printServiceOverlay", document.getElementById("printServiceOverlay"), abort, true);
  13315. document.getElementById("printCancel").onclick = abort;
  13316. }
  13317. return overlayPromise;
  13318. }
  13319. _app.PDFPrintServiceFactory.instance = {
  13320. supportsPrinting: true,
  13321. createPrintService: function createPrintService(pdfDocument, pagesOverview, printContainer, l10n) {
  13322. if (activeService) {
  13323. throw new Error("The print service is created and active.");
  13324. }
  13325. activeService = new PDFPrintService(pdfDocument, pagesOverview, printContainer, l10n);
  13326. return activeService;
  13327. }
  13328. };
  13329. /***/ })
  13330. /******/ ]);
  13331. //# sourceMappingURL=viewer.js.map