viewer.js 465 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692
  1. /**
  2. * @licstart The following is the entire license notice for the
  3. * Javascript code in this page
  4. *
  5. * Copyright 2019 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. document.dispatchEvent(event);
  255. pdfjsWebApp.PDFViewerApplication.run(config);
  256. }
  257. if (document.readyState === 'interactive' || document.readyState === 'complete') {
  258. webViewerLoad();
  259. } else {
  260. document.addEventListener('DOMContentLoaded', webViewerLoad, true);
  261. }
  262. /***/ }),
  263. /* 1 */
  264. /***/ (function(module, exports, __webpack_require__) {
  265. "use strict";
  266. Object.defineProperty(exports, "__esModule", {
  267. value: true
  268. });
  269. exports.PDFPrintServiceFactory = exports.DefaultExternalServices = exports.PDFViewerApplication = void 0;
  270. var _regenerator = _interopRequireDefault(__webpack_require__(2));
  271. var _ui_utils = __webpack_require__(5);
  272. var _app_options = __webpack_require__(6);
  273. var _pdfjsLib = __webpack_require__(7);
  274. var _pdf_cursor_tools = __webpack_require__(9);
  275. var _pdf_rendering_queue = __webpack_require__(11);
  276. var _pdf_sidebar = __webpack_require__(12);
  277. var _overlay_manager = __webpack_require__(13);
  278. var _password_prompt = __webpack_require__(14);
  279. var _pdf_attachment_viewer = __webpack_require__(15);
  280. var _pdf_document_properties = __webpack_require__(16);
  281. var _pdf_find_bar = __webpack_require__(17);
  282. var _pdf_find_controller = __webpack_require__(18);
  283. var _pdf_history = __webpack_require__(20);
  284. var _pdf_link_service = __webpack_require__(21);
  285. var _pdf_outline_viewer = __webpack_require__(22);
  286. var _pdf_presentation_mode = __webpack_require__(23);
  287. var _pdf_sidebar_resizer = __webpack_require__(24);
  288. var _pdf_thumbnail_viewer = __webpack_require__(25);
  289. var _pdf_viewer = __webpack_require__(27);
  290. var _secondary_toolbar = __webpack_require__(32);
  291. var _toolbar = __webpack_require__(34);
  292. var _view_history = __webpack_require__(35);
  293. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  294. function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); }
  295. function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance"); }
  296. function _iterableToArrayLimit(arr, i) { if (!(Symbol.iterator in Object(arr) || Object.prototype.toString.call(arr) === "[object Arguments]")) { 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; }
  297. function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
  298. 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); } }
  299. 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); }); }; }
  300. var DEFAULT_SCALE_DELTA = 1.1;
  301. var DISABLE_AUTO_FETCH_LOADING_BAR_TIMEOUT = 5000;
  302. var FORCE_PAGES_LOADED_TIMEOUT = 10000;
  303. var WHEEL_ZOOM_DISABLED_TIMEOUT = 1000;
  304. var ViewOnLoad = {
  305. UNKNOWN: -1,
  306. PREVIOUS: 0,
  307. INITIAL: 1
  308. };
  309. var DefaultExternalServices = {
  310. updateFindControlState: function updateFindControlState(data) {},
  311. updateFindMatchesCount: function updateFindMatchesCount(data) {},
  312. initPassiveLoading: function initPassiveLoading(callbacks) {},
  313. fallback: function fallback(data, callback) {},
  314. reportTelemetry: function reportTelemetry(data) {},
  315. createDownloadManager: function createDownloadManager(options) {
  316. throw new Error('Not implemented: createDownloadManager');
  317. },
  318. createPreferences: function createPreferences() {
  319. throw new Error('Not implemented: createPreferences');
  320. },
  321. createL10n: function createL10n(options) {
  322. throw new Error('Not implemented: createL10n');
  323. },
  324. supportsIntegratedFind: false,
  325. supportsDocumentFonts: true,
  326. supportsDocumentColors: true,
  327. supportedMouseWheelZoomModifierKeys: {
  328. ctrlKey: true,
  329. metaKey: true
  330. }
  331. };
  332. exports.DefaultExternalServices = DefaultExternalServices;
  333. var PDFViewerApplication = {
  334. initialBookmark: document.location.hash.substring(1),
  335. initialized: false,
  336. fellback: false,
  337. appConfig: null,
  338. pdfDocument: null,
  339. pdfLoadingTask: null,
  340. printService: null,
  341. pdfViewer: null,
  342. pdfThumbnailViewer: null,
  343. pdfRenderingQueue: null,
  344. pdfPresentationMode: null,
  345. pdfDocumentProperties: null,
  346. pdfLinkService: null,
  347. pdfHistory: null,
  348. pdfSidebar: null,
  349. pdfSidebarResizer: null,
  350. pdfOutlineViewer: null,
  351. pdfAttachmentViewer: null,
  352. pdfCursorTools: null,
  353. store: null,
  354. downloadManager: null,
  355. overlayManager: null,
  356. preferences: null,
  357. toolbar: null,
  358. secondaryToolbar: null,
  359. eventBus: null,
  360. l10n: null,
  361. isInitialViewSet: false,
  362. downloadComplete: false,
  363. isViewerEmbedded: window.parent !== window,
  364. url: '',
  365. baseUrl: '',
  366. externalServices: DefaultExternalServices,
  367. _boundEvents: {},
  368. contentDispositionFilename: null,
  369. initialize: function () {
  370. var _initialize = _asyncToGenerator(
  371. /*#__PURE__*/
  372. _regenerator["default"].mark(function _callee(appConfig) {
  373. var _this = this;
  374. var appContainer;
  375. return _regenerator["default"].wrap(function _callee$(_context) {
  376. while (1) {
  377. switch (_context.prev = _context.next) {
  378. case 0:
  379. this.preferences = this.externalServices.createPreferences();
  380. this.appConfig = appConfig;
  381. _context.next = 4;
  382. return this._readPreferences();
  383. case 4:
  384. _context.next = 6;
  385. return this._parseHashParameters();
  386. case 6:
  387. _context.next = 8;
  388. return this._initializeL10n();
  389. case 8:
  390. if (this.isViewerEmbedded && _app_options.AppOptions.get('externalLinkTarget') === _pdfjsLib.LinkTarget.NONE) {
  391. _app_options.AppOptions.set('externalLinkTarget', _pdfjsLib.LinkTarget.TOP);
  392. }
  393. _context.next = 11;
  394. return this._initializeViewerComponents();
  395. case 11:
  396. this.bindEvents();
  397. this.bindWindowEvents();
  398. appContainer = appConfig.appContainer || document.documentElement;
  399. this.l10n.translate(appContainer).then(function () {
  400. _this.eventBus.dispatch('localized', {
  401. source: _this
  402. });
  403. });
  404. this.initialized = true;
  405. case 16:
  406. case "end":
  407. return _context.stop();
  408. }
  409. }
  410. }, _callee, this);
  411. }));
  412. function initialize(_x) {
  413. return _initialize.apply(this, arguments);
  414. }
  415. return initialize;
  416. }(),
  417. _readPreferences: function () {
  418. var _readPreferences2 = _asyncToGenerator(
  419. /*#__PURE__*/
  420. _regenerator["default"].mark(function _callee2() {
  421. var prefs, name;
  422. return _regenerator["default"].wrap(function _callee2$(_context2) {
  423. while (1) {
  424. switch (_context2.prev = _context2.next) {
  425. case 0:
  426. if (!(_app_options.AppOptions.get('disablePreferences') === true)) {
  427. _context2.next = 2;
  428. break;
  429. }
  430. return _context2.abrupt("return");
  431. case 2:
  432. _context2.prev = 2;
  433. _context2.next = 5;
  434. return this.preferences.getAll();
  435. case 5:
  436. prefs = _context2.sent;
  437. for (name in prefs) {
  438. _app_options.AppOptions.set(name, prefs[name]);
  439. }
  440. _context2.next = 12;
  441. break;
  442. case 9:
  443. _context2.prev = 9;
  444. _context2.t0 = _context2["catch"](2);
  445. console.error("_readPreferences: \"".concat(_context2.t0.message, "\"."));
  446. case 12:
  447. case "end":
  448. return _context2.stop();
  449. }
  450. }
  451. }, _callee2, this, [[2, 9]]);
  452. }));
  453. function _readPreferences() {
  454. return _readPreferences2.apply(this, arguments);
  455. }
  456. return _readPreferences;
  457. }(),
  458. _parseHashParameters: function () {
  459. var _parseHashParameters2 = _asyncToGenerator(
  460. /*#__PURE__*/
  461. _regenerator["default"].mark(function _callee3() {
  462. var waitOn, hash, hashParams, viewer, enabled;
  463. return _regenerator["default"].wrap(function _callee3$(_context3) {
  464. while (1) {
  465. switch (_context3.prev = _context3.next) {
  466. case 0:
  467. if (_app_options.AppOptions.get('pdfBugEnabled')) {
  468. _context3.next = 2;
  469. break;
  470. }
  471. return _context3.abrupt("return", undefined);
  472. case 2:
  473. waitOn = [];
  474. hash = document.location.hash.substring(1);
  475. hashParams = (0, _ui_utils.parseQueryString)(hash);
  476. if ('disableworker' in hashParams && hashParams['disableworker'] === 'true') {
  477. waitOn.push(loadFakeWorker());
  478. }
  479. if ('disablerange' in hashParams) {
  480. _app_options.AppOptions.set('disableRange', hashParams['disablerange'] === 'true');
  481. }
  482. if ('disablestream' in hashParams) {
  483. _app_options.AppOptions.set('disableStream', hashParams['disablestream'] === 'true');
  484. }
  485. if ('disableautofetch' in hashParams) {
  486. _app_options.AppOptions.set('disableAutoFetch', hashParams['disableautofetch'] === 'true');
  487. }
  488. if ('disablefontface' in hashParams) {
  489. _app_options.AppOptions.set('disableFontFace', hashParams['disablefontface'] === 'true');
  490. }
  491. if ('disablehistory' in hashParams) {
  492. _app_options.AppOptions.set('disableHistory', hashParams['disablehistory'] === 'true');
  493. }
  494. if ('webgl' in hashParams) {
  495. _app_options.AppOptions.set('enableWebGL', hashParams['webgl'] === 'true');
  496. }
  497. if ('useonlycsszoom' in hashParams) {
  498. _app_options.AppOptions.set('useOnlyCssZoom', hashParams['useonlycsszoom'] === 'true');
  499. }
  500. if ('verbosity' in hashParams) {
  501. _app_options.AppOptions.set('verbosity', hashParams['verbosity'] | 0);
  502. }
  503. if (!('textlayer' in hashParams)) {
  504. _context3.next = 23;
  505. break;
  506. }
  507. _context3.t0 = hashParams['textlayer'];
  508. _context3.next = _context3.t0 === 'off' ? 18 : _context3.t0 === 'visible' ? 20 : _context3.t0 === 'shadow' ? 20 : _context3.t0 === 'hover' ? 20 : 23;
  509. break;
  510. case 18:
  511. _app_options.AppOptions.set('textLayerMode', _ui_utils.TextLayerMode.DISABLE);
  512. return _context3.abrupt("break", 23);
  513. case 20:
  514. viewer = this.appConfig.viewerContainer;
  515. viewer.classList.add('textLayer-' + hashParams['textlayer']);
  516. return _context3.abrupt("break", 23);
  517. case 23:
  518. if ('pdfbug' in hashParams) {
  519. _app_options.AppOptions.set('pdfBug', true);
  520. enabled = hashParams['pdfbug'].split(',');
  521. waitOn.push(loadAndEnablePDFBug(enabled));
  522. }
  523. if ('locale' in hashParams) {
  524. _app_options.AppOptions.set('locale', hashParams['locale']);
  525. }
  526. return _context3.abrupt("return", Promise.all(waitOn)["catch"](function (reason) {
  527. console.error("_parseHashParameters: \"".concat(reason.message, "\"."));
  528. }));
  529. case 26:
  530. case "end":
  531. return _context3.stop();
  532. }
  533. }
  534. }, _callee3, this);
  535. }));
  536. function _parseHashParameters() {
  537. return _parseHashParameters2.apply(this, arguments);
  538. }
  539. return _parseHashParameters;
  540. }(),
  541. _initializeL10n: function () {
  542. var _initializeL10n2 = _asyncToGenerator(
  543. /*#__PURE__*/
  544. _regenerator["default"].mark(function _callee4() {
  545. var dir;
  546. return _regenerator["default"].wrap(function _callee4$(_context4) {
  547. while (1) {
  548. switch (_context4.prev = _context4.next) {
  549. case 0:
  550. this.l10n = this.externalServices.createL10n({
  551. locale: _app_options.AppOptions.get('locale')
  552. });
  553. _context4.next = 3;
  554. return this.l10n.getDirection();
  555. case 3:
  556. dir = _context4.sent;
  557. document.getElementsByTagName('html')[0].dir = dir;
  558. case 5:
  559. case "end":
  560. return _context4.stop();
  561. }
  562. }
  563. }, _callee4, this);
  564. }));
  565. function _initializeL10n() {
  566. return _initializeL10n2.apply(this, arguments);
  567. }
  568. return _initializeL10n;
  569. }(),
  570. _initializeViewerComponents: function () {
  571. var _initializeViewerComponents2 = _asyncToGenerator(
  572. /*#__PURE__*/
  573. _regenerator["default"].mark(function _callee5() {
  574. var appConfig, eventBus, pdfRenderingQueue, pdfLinkService, downloadManager, findController, container, viewer;
  575. return _regenerator["default"].wrap(function _callee5$(_context5) {
  576. while (1) {
  577. switch (_context5.prev = _context5.next) {
  578. case 0:
  579. appConfig = this.appConfig;
  580. this.overlayManager = new _overlay_manager.OverlayManager();
  581. eventBus = appConfig.eventBus || (0, _ui_utils.getGlobalEventBus)(_app_options.AppOptions.get('eventBusDispatchToDOM'));
  582. this.eventBus = eventBus;
  583. pdfRenderingQueue = new _pdf_rendering_queue.PDFRenderingQueue();
  584. pdfRenderingQueue.onIdle = this.cleanup.bind(this);
  585. this.pdfRenderingQueue = pdfRenderingQueue;
  586. pdfLinkService = new _pdf_link_service.PDFLinkService({
  587. eventBus: eventBus,
  588. externalLinkTarget: _app_options.AppOptions.get('externalLinkTarget'),
  589. externalLinkRel: _app_options.AppOptions.get('externalLinkRel')
  590. });
  591. this.pdfLinkService = pdfLinkService;
  592. downloadManager = this.externalServices.createDownloadManager({
  593. disableCreateObjectURL: _app_options.AppOptions.get('disableCreateObjectURL')
  594. });
  595. this.downloadManager = downloadManager;
  596. findController = new _pdf_find_controller.PDFFindController({
  597. linkService: pdfLinkService,
  598. eventBus: eventBus
  599. });
  600. this.findController = findController;
  601. container = appConfig.mainContainer;
  602. viewer = appConfig.viewerContainer;
  603. this.pdfViewer = new _pdf_viewer.PDFViewer({
  604. container: container,
  605. viewer: viewer,
  606. eventBus: eventBus,
  607. renderingQueue: pdfRenderingQueue,
  608. linkService: pdfLinkService,
  609. downloadManager: downloadManager,
  610. findController: findController,
  611. renderer: _app_options.AppOptions.get('renderer'),
  612. enableWebGL: _app_options.AppOptions.get('enableWebGL'),
  613. l10n: this.l10n,
  614. textLayerMode: _app_options.AppOptions.get('textLayerMode'),
  615. imageResourcesPath: _app_options.AppOptions.get('imageResourcesPath'),
  616. renderInteractiveForms: _app_options.AppOptions.get('renderInteractiveForms'),
  617. enablePrintAutoRotate: _app_options.AppOptions.get('enablePrintAutoRotate'),
  618. useOnlyCssZoom: _app_options.AppOptions.get('useOnlyCssZoom'),
  619. maxCanvasPixels: _app_options.AppOptions.get('maxCanvasPixels')
  620. });
  621. pdfRenderingQueue.setViewer(this.pdfViewer);
  622. pdfLinkService.setViewer(this.pdfViewer);
  623. this.pdfThumbnailViewer = new _pdf_thumbnail_viewer.PDFThumbnailViewer({
  624. container: appConfig.sidebar.thumbnailView,
  625. renderingQueue: pdfRenderingQueue,
  626. linkService: pdfLinkService,
  627. l10n: this.l10n
  628. });
  629. pdfRenderingQueue.setThumbnailViewer(this.pdfThumbnailViewer);
  630. this.pdfHistory = new _pdf_history.PDFHistory({
  631. linkService: pdfLinkService,
  632. eventBus: eventBus
  633. });
  634. pdfLinkService.setHistory(this.pdfHistory);
  635. if (!this.supportsIntegratedFind) {
  636. this.findBar = new _pdf_find_bar.PDFFindBar(appConfig.findBar, eventBus, this.l10n);
  637. }
  638. this.pdfDocumentProperties = new _pdf_document_properties.PDFDocumentProperties(appConfig.documentProperties, this.overlayManager, eventBus, this.l10n);
  639. this.pdfCursorTools = new _pdf_cursor_tools.PDFCursorTools({
  640. container: container,
  641. eventBus: eventBus,
  642. cursorToolOnLoad: _app_options.AppOptions.get('cursorToolOnLoad')
  643. });
  644. this.toolbar = new _toolbar.Toolbar(appConfig.toolbar, eventBus, this.l10n);
  645. this.secondaryToolbar = new _secondary_toolbar.SecondaryToolbar(appConfig.secondaryToolbar, container, eventBus);
  646. if (this.supportsFullscreen) {
  647. this.pdfPresentationMode = new _pdf_presentation_mode.PDFPresentationMode({
  648. container: container,
  649. viewer: viewer,
  650. pdfViewer: this.pdfViewer,
  651. eventBus: eventBus,
  652. contextMenuItems: appConfig.fullscreen
  653. });
  654. }
  655. this.passwordPrompt = new _password_prompt.PasswordPrompt(appConfig.passwordOverlay, this.overlayManager, this.l10n);
  656. this.pdfOutlineViewer = new _pdf_outline_viewer.PDFOutlineViewer({
  657. container: appConfig.sidebar.outlineView,
  658. eventBus: eventBus,
  659. linkService: pdfLinkService
  660. });
  661. this.pdfAttachmentViewer = new _pdf_attachment_viewer.PDFAttachmentViewer({
  662. container: appConfig.sidebar.attachmentsView,
  663. eventBus: eventBus,
  664. downloadManager: downloadManager
  665. });
  666. this.pdfSidebar = new _pdf_sidebar.PDFSidebar({
  667. elements: appConfig.sidebar,
  668. pdfViewer: this.pdfViewer,
  669. pdfThumbnailViewer: this.pdfThumbnailViewer,
  670. eventBus: eventBus,
  671. l10n: this.l10n
  672. });
  673. this.pdfSidebar.onToggled = this.forceRendering.bind(this);
  674. this.pdfSidebarResizer = new _pdf_sidebar_resizer.PDFSidebarResizer(appConfig.sidebarResizer, eventBus, this.l10n);
  675. case 34:
  676. case "end":
  677. return _context5.stop();
  678. }
  679. }
  680. }, _callee5, this);
  681. }));
  682. function _initializeViewerComponents() {
  683. return _initializeViewerComponents2.apply(this, arguments);
  684. }
  685. return _initializeViewerComponents;
  686. }(),
  687. run: function run(config) {
  688. this.initialize(config).then(webViewerInitialized);
  689. },
  690. zoomIn: function zoomIn(ticks) {
  691. if (this.pdfViewer.isInPresentationMode) {
  692. return;
  693. }
  694. var newScale = this.pdfViewer.currentScale;
  695. do {
  696. newScale = (newScale * DEFAULT_SCALE_DELTA).toFixed(2);
  697. newScale = Math.ceil(newScale * 10) / 10;
  698. newScale = Math.min(_ui_utils.MAX_SCALE, newScale);
  699. } while (--ticks > 0 && newScale < _ui_utils.MAX_SCALE);
  700. this.pdfViewer.currentScaleValue = newScale;
  701. },
  702. zoomOut: function zoomOut(ticks) {
  703. if (this.pdfViewer.isInPresentationMode) {
  704. return;
  705. }
  706. var newScale = this.pdfViewer.currentScale;
  707. do {
  708. newScale = (newScale / DEFAULT_SCALE_DELTA).toFixed(2);
  709. newScale = Math.floor(newScale * 10) / 10;
  710. newScale = Math.max(_ui_utils.MIN_SCALE, newScale);
  711. } while (--ticks > 0 && newScale > _ui_utils.MIN_SCALE);
  712. this.pdfViewer.currentScaleValue = newScale;
  713. },
  714. zoomReset: function zoomReset() {
  715. if (this.pdfViewer.isInPresentationMode) {
  716. return;
  717. }
  718. this.pdfViewer.currentScaleValue = _ui_utils.DEFAULT_SCALE_VALUE;
  719. },
  720. get pagesCount() {
  721. return this.pdfDocument ? this.pdfDocument.numPages : 0;
  722. },
  723. set page(val) {
  724. this.pdfViewer.currentPageNumber = val;
  725. },
  726. get page() {
  727. return this.pdfViewer.currentPageNumber;
  728. },
  729. get printing() {
  730. return !!this.printService;
  731. },
  732. get supportsPrinting() {
  733. return PDFPrintServiceFactory.instance.supportsPrinting;
  734. },
  735. get supportsFullscreen() {
  736. var support;
  737. var doc = document.documentElement;
  738. support = !!(doc.requestFullscreen || doc.mozRequestFullScreen || doc.webkitRequestFullScreen || doc.msRequestFullscreen);
  739. if (document.fullscreenEnabled === false || document.mozFullScreenEnabled === false || document.webkitFullscreenEnabled === false || document.msFullscreenEnabled === false) {
  740. support = false;
  741. }
  742. return (0, _pdfjsLib.shadow)(this, 'supportsFullscreen', support);
  743. },
  744. get supportsIntegratedFind() {
  745. return this.externalServices.supportsIntegratedFind;
  746. },
  747. get supportsDocumentFonts() {
  748. return this.externalServices.supportsDocumentFonts;
  749. },
  750. get supportsDocumentColors() {
  751. return this.externalServices.supportsDocumentColors;
  752. },
  753. get loadingBar() {
  754. var bar = new _ui_utils.ProgressBar('#loadingBar');
  755. return (0, _pdfjsLib.shadow)(this, 'loadingBar', bar);
  756. },
  757. get supportedMouseWheelZoomModifierKeys() {
  758. return this.externalServices.supportedMouseWheelZoomModifierKeys;
  759. },
  760. initPassiveLoading: function initPassiveLoading() {
  761. throw new Error('Not implemented: initPassiveLoading');
  762. },
  763. setTitleUsingUrl: function setTitleUsingUrl() {
  764. var url = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
  765. this.url = url;
  766. this.baseUrl = url.split('#')[0];
  767. var title = (0, _ui_utils.getPDFFileNameFromURL)(url, '');
  768. if (!title) {
  769. try {
  770. title = decodeURIComponent((0, _pdfjsLib.getFilenameFromUrl)(url)) || url;
  771. } catch (ex) {
  772. title = url;
  773. }
  774. }
  775. this.setTitle(title);
  776. },
  777. setTitle: function setTitle(title) {
  778. if (this.isViewerEmbedded) {
  779. return;
  780. }
  781. document.title = title;
  782. },
  783. close: function () {
  784. var _close = _asyncToGenerator(
  785. /*#__PURE__*/
  786. _regenerator["default"].mark(function _callee6() {
  787. var errorWrapper, promise;
  788. return _regenerator["default"].wrap(function _callee6$(_context6) {
  789. while (1) {
  790. switch (_context6.prev = _context6.next) {
  791. case 0:
  792. errorWrapper = this.appConfig.errorWrapper.container;
  793. errorWrapper.setAttribute('hidden', 'true');
  794. if (this.pdfLoadingTask) {
  795. _context6.next = 4;
  796. break;
  797. }
  798. return _context6.abrupt("return", undefined);
  799. case 4:
  800. promise = this.pdfLoadingTask.destroy();
  801. this.pdfLoadingTask = null;
  802. if (this.pdfDocument) {
  803. this.pdfDocument = null;
  804. this.pdfThumbnailViewer.setDocument(null);
  805. this.pdfViewer.setDocument(null);
  806. this.pdfLinkService.setDocument(null);
  807. this.pdfDocumentProperties.setDocument(null);
  808. }
  809. this.store = null;
  810. this.isInitialViewSet = false;
  811. this.downloadComplete = false;
  812. this.url = '';
  813. this.baseUrl = '';
  814. this.contentDispositionFilename = null;
  815. this.pdfSidebar.reset();
  816. this.pdfOutlineViewer.reset();
  817. this.pdfAttachmentViewer.reset();
  818. if (this.findBar) {
  819. this.findBar.reset();
  820. }
  821. this.toolbar.reset();
  822. this.secondaryToolbar.reset();
  823. if (typeof PDFBug !== 'undefined') {
  824. PDFBug.cleanup();
  825. }
  826. return _context6.abrupt("return", promise);
  827. case 21:
  828. case "end":
  829. return _context6.stop();
  830. }
  831. }
  832. }, _callee6, this);
  833. }));
  834. function close() {
  835. return _close.apply(this, arguments);
  836. }
  837. return close;
  838. }(),
  839. open: function () {
  840. var _open = _asyncToGenerator(
  841. /*#__PURE__*/
  842. _regenerator["default"].mark(function _callee7(file, args) {
  843. var _this2 = this;
  844. var workerParameters, key, parameters, apiParameters, _key, value, _key2, _value, loadingTask;
  845. return _regenerator["default"].wrap(function _callee7$(_context7) {
  846. while (1) {
  847. switch (_context7.prev = _context7.next) {
  848. case 0:
  849. if (!this.pdfLoadingTask) {
  850. _context7.next = 3;
  851. break;
  852. }
  853. _context7.next = 3;
  854. return this.close();
  855. case 3:
  856. workerParameters = _app_options.AppOptions.getAll(_app_options.OptionKind.WORKER);
  857. for (key in workerParameters) {
  858. _pdfjsLib.GlobalWorkerOptions[key] = workerParameters[key];
  859. }
  860. parameters = Object.create(null);
  861. if (typeof file === 'string') {
  862. this.setTitleUsingUrl(file);
  863. parameters.url = file;
  864. } else if (file && 'byteLength' in file) {
  865. parameters.data = file;
  866. } else if (file.url && file.originalUrl) {
  867. this.setTitleUsingUrl(file.originalUrl);
  868. parameters.url = file.url;
  869. }
  870. apiParameters = _app_options.AppOptions.getAll(_app_options.OptionKind.API);
  871. for (_key in apiParameters) {
  872. value = apiParameters[_key];
  873. if (_key === 'docBaseUrl' && !value) {}
  874. parameters[_key] = value;
  875. }
  876. if (args) {
  877. for (_key2 in args) {
  878. _value = args[_key2];
  879. if (_key2 === 'length') {
  880. this.pdfDocumentProperties.setFileSize(_value);
  881. }
  882. parameters[_key2] = _value;
  883. }
  884. }
  885. loadingTask = (0, _pdfjsLib.getDocument)(parameters);
  886. this.pdfLoadingTask = loadingTask;
  887. loadingTask.onPassword = function (updateCallback, reason) {
  888. _this2.pdfLinkService.externalLinkEnabled = false;
  889. _this2.passwordPrompt.setUpdateCallback(updateCallback, reason);
  890. _this2.passwordPrompt.open();
  891. };
  892. loadingTask.onProgress = function (_ref) {
  893. var loaded = _ref.loaded,
  894. total = _ref.total;
  895. _this2.progress(loaded / total);
  896. };
  897. loadingTask.onUnsupportedFeature = this.fallback.bind(this);
  898. return _context7.abrupt("return", loadingTask.promise.then(function (pdfDocument) {
  899. _this2.load(pdfDocument);
  900. }, function (exception) {
  901. if (loadingTask !== _this2.pdfLoadingTask) {
  902. return undefined;
  903. }
  904. var message = exception && exception.message;
  905. var loadingErrorMessage;
  906. if (exception instanceof _pdfjsLib.InvalidPDFException) {
  907. loadingErrorMessage = _this2.l10n.get('invalid_file_error', null, 'Invalid or corrupted PDF file.');
  908. } else if (exception instanceof _pdfjsLib.MissingPDFException) {
  909. loadingErrorMessage = _this2.l10n.get('missing_file_error', null, 'Missing PDF file.');
  910. } else if (exception instanceof _pdfjsLib.UnexpectedResponseException) {
  911. loadingErrorMessage = _this2.l10n.get('unexpected_response_error', null, 'Unexpected server response.');
  912. } else {
  913. loadingErrorMessage = _this2.l10n.get('loading_error', null, 'An error occurred while loading the PDF.');
  914. }
  915. return loadingErrorMessage.then(function (msg) {
  916. _this2.error(msg, {
  917. message: message
  918. });
  919. throw new Error(msg);
  920. });
  921. }));
  922. case 16:
  923. case "end":
  924. return _context7.stop();
  925. }
  926. }
  927. }, _callee7, this);
  928. }));
  929. function open(_x2, _x3) {
  930. return _open.apply(this, arguments);
  931. }
  932. return open;
  933. }(),
  934. download: function download() {
  935. var _this3 = this;
  936. function downloadByUrl() {
  937. downloadManager.downloadUrl(url, filename);
  938. }
  939. var url = this.baseUrl;
  940. var filename = this.contentDispositionFilename || (0, _ui_utils.getPDFFileNameFromURL)(this.url);
  941. var downloadManager = this.downloadManager;
  942. downloadManager.onerror = function (err) {
  943. _this3.error("PDF failed to download: ".concat(err));
  944. };
  945. if (!this.pdfDocument || !this.downloadComplete) {
  946. downloadByUrl();
  947. return;
  948. }
  949. this.pdfDocument.getData().then(function (data) {
  950. var blob = new Blob([data], {
  951. type: 'application/pdf'
  952. });
  953. downloadManager.download(blob, url, filename);
  954. })["catch"](downloadByUrl);
  955. },
  956. fallback: function fallback(featureId) {},
  957. error: function error(message, moreInfo) {
  958. var moreInfoText = [this.l10n.get('error_version_info', {
  959. version: _pdfjsLib.version || '?',
  960. build: _pdfjsLib.build || '?'
  961. }, 'PDF.js v{{version}} (build: {{build}})')];
  962. if (moreInfo) {
  963. moreInfoText.push(this.l10n.get('error_message', {
  964. message: moreInfo.message
  965. }, 'Message: {{message}}'));
  966. if (moreInfo.stack) {
  967. moreInfoText.push(this.l10n.get('error_stack', {
  968. stack: moreInfo.stack
  969. }, 'Stack: {{stack}}'));
  970. } else {
  971. if (moreInfo.filename) {
  972. moreInfoText.push(this.l10n.get('error_file', {
  973. file: moreInfo.filename
  974. }, 'File: {{file}}'));
  975. }
  976. if (moreInfo.lineNumber) {
  977. moreInfoText.push(this.l10n.get('error_line', {
  978. line: moreInfo.lineNumber
  979. }, 'Line: {{line}}'));
  980. }
  981. }
  982. }
  983. var errorWrapperConfig = this.appConfig.errorWrapper;
  984. var errorWrapper = errorWrapperConfig.container;
  985. errorWrapper.removeAttribute('hidden');
  986. var errorMessage = errorWrapperConfig.errorMessage;
  987. errorMessage.textContent = message;
  988. var closeButton = errorWrapperConfig.closeButton;
  989. closeButton.onclick = function () {
  990. errorWrapper.setAttribute('hidden', 'true');
  991. };
  992. var errorMoreInfo = errorWrapperConfig.errorMoreInfo;
  993. var moreInfoButton = errorWrapperConfig.moreInfoButton;
  994. var lessInfoButton = errorWrapperConfig.lessInfoButton;
  995. moreInfoButton.onclick = function () {
  996. errorMoreInfo.removeAttribute('hidden');
  997. moreInfoButton.setAttribute('hidden', 'true');
  998. lessInfoButton.removeAttribute('hidden');
  999. errorMoreInfo.style.height = errorMoreInfo.scrollHeight + 'px';
  1000. };
  1001. lessInfoButton.onclick = function () {
  1002. errorMoreInfo.setAttribute('hidden', 'true');
  1003. moreInfoButton.removeAttribute('hidden');
  1004. lessInfoButton.setAttribute('hidden', 'true');
  1005. };
  1006. moreInfoButton.oncontextmenu = _ui_utils.noContextMenuHandler;
  1007. lessInfoButton.oncontextmenu = _ui_utils.noContextMenuHandler;
  1008. closeButton.oncontextmenu = _ui_utils.noContextMenuHandler;
  1009. moreInfoButton.removeAttribute('hidden');
  1010. lessInfoButton.setAttribute('hidden', 'true');
  1011. Promise.all(moreInfoText).then(function (parts) {
  1012. errorMoreInfo.value = parts.join('\n');
  1013. });
  1014. },
  1015. progress: function progress(level) {
  1016. var _this4 = this;
  1017. if (this.downloadComplete) {
  1018. return;
  1019. }
  1020. var percent = Math.round(level * 100);
  1021. if (percent > this.loadingBar.percent || isNaN(percent)) {
  1022. this.loadingBar.percent = percent;
  1023. var disableAutoFetch = this.pdfDocument ? this.pdfDocument.loadingParams['disableAutoFetch'] : _app_options.AppOptions.get('disableAutoFetch');
  1024. if (disableAutoFetch && percent) {
  1025. if (this.disableAutoFetchLoadingBarTimeout) {
  1026. clearTimeout(this.disableAutoFetchLoadingBarTimeout);
  1027. this.disableAutoFetchLoadingBarTimeout = null;
  1028. }
  1029. this.loadingBar.show();
  1030. this.disableAutoFetchLoadingBarTimeout = setTimeout(function () {
  1031. _this4.loadingBar.hide();
  1032. _this4.disableAutoFetchLoadingBarTimeout = null;
  1033. }, DISABLE_AUTO_FETCH_LOADING_BAR_TIMEOUT);
  1034. }
  1035. }
  1036. },
  1037. load: function load(pdfDocument) {
  1038. var _this5 = this;
  1039. this.pdfDocument = pdfDocument;
  1040. pdfDocument.getDownloadInfo().then(function () {
  1041. _this5.downloadComplete = true;
  1042. _this5.loadingBar.hide();
  1043. firstPagePromise.then(function () {
  1044. _this5.eventBus.dispatch('documentloaded', {
  1045. source: _this5
  1046. });
  1047. });
  1048. });
  1049. var pageLayoutPromise = pdfDocument.getPageLayout()["catch"](function () {});
  1050. var pageModePromise = pdfDocument.getPageMode()["catch"](function () {});
  1051. var openActionDestPromise = pdfDocument.getOpenActionDestination()["catch"](function () {});
  1052. this.toolbar.setPagesCount(pdfDocument.numPages, false);
  1053. this.secondaryToolbar.setPagesCount(pdfDocument.numPages);
  1054. var store = this.store = new _view_history.ViewHistory(pdfDocument.fingerprint);
  1055. var baseDocumentUrl;
  1056. baseDocumentUrl = null;
  1057. this.pdfLinkService.setDocument(pdfDocument, baseDocumentUrl);
  1058. this.pdfDocumentProperties.setDocument(pdfDocument, this.url);
  1059. var pdfViewer = this.pdfViewer;
  1060. pdfViewer.setDocument(pdfDocument);
  1061. var firstPagePromise = pdfViewer.firstPagePromise;
  1062. var pagesPromise = pdfViewer.pagesPromise;
  1063. var onePageRendered = pdfViewer.onePageRendered;
  1064. var pdfThumbnailViewer = this.pdfThumbnailViewer;
  1065. pdfThumbnailViewer.setDocument(pdfDocument);
  1066. firstPagePromise.then(function (pdfPage) {
  1067. _this5.loadingBar.setWidth(_this5.appConfig.viewerContainer);
  1068. var storePromise = store.getMultiple({
  1069. page: null,
  1070. zoom: _ui_utils.DEFAULT_SCALE_VALUE,
  1071. scrollLeft: '0',
  1072. scrollTop: '0',
  1073. rotation: null,
  1074. sidebarView: _pdf_sidebar.SidebarView.UNKNOWN,
  1075. scrollMode: _ui_utils.ScrollMode.UNKNOWN,
  1076. spreadMode: _ui_utils.SpreadMode.UNKNOWN
  1077. })["catch"](function () {});
  1078. Promise.all([_ui_utils.animationStarted, storePromise, pageLayoutPromise, pageModePromise, openActionDestPromise]).then(
  1079. /*#__PURE__*/
  1080. function () {
  1081. var _ref3 = _asyncToGenerator(
  1082. /*#__PURE__*/
  1083. _regenerator["default"].mark(function _callee8(_ref2) {
  1084. var _ref4, timeStamp, _ref4$, values, pageLayout, pageMode, openActionDest, viewOnLoad, initialBookmark, zoom, hash, rotation, sidebarView, scrollMode, spreadMode;
  1085. return _regenerator["default"].wrap(function _callee8$(_context8) {
  1086. while (1) {
  1087. switch (_context8.prev = _context8.next) {
  1088. case 0:
  1089. _ref4 = _slicedToArray(_ref2, 5), timeStamp = _ref4[0], _ref4$ = _ref4[1], values = _ref4$ === void 0 ? {} : _ref4$, pageLayout = _ref4[2], pageMode = _ref4[3], openActionDest = _ref4[4];
  1090. viewOnLoad = _app_options.AppOptions.get('viewOnLoad');
  1091. _this5._initializePdfHistory({
  1092. fingerprint: pdfDocument.fingerprint,
  1093. viewOnLoad: viewOnLoad,
  1094. initialDest: openActionDest
  1095. });
  1096. initialBookmark = _this5.initialBookmark;
  1097. zoom = _app_options.AppOptions.get('defaultZoomValue');
  1098. hash = zoom ? "zoom=".concat(zoom) : null;
  1099. rotation = null;
  1100. sidebarView = _app_options.AppOptions.get('sidebarViewOnLoad');
  1101. scrollMode = _app_options.AppOptions.get('scrollModeOnLoad');
  1102. spreadMode = _app_options.AppOptions.get('spreadModeOnLoad');
  1103. if (values.page && viewOnLoad !== ViewOnLoad.INITIAL) {
  1104. hash = "page=".concat(values.page, "&zoom=").concat(zoom || values.zoom, ",") + "".concat(values.scrollLeft, ",").concat(values.scrollTop);
  1105. rotation = parseInt(values.rotation, 10);
  1106. if (sidebarView === _pdf_sidebar.SidebarView.UNKNOWN) {
  1107. sidebarView = values.sidebarView | 0;
  1108. }
  1109. if (scrollMode === _ui_utils.ScrollMode.UNKNOWN) {
  1110. scrollMode = values.scrollMode | 0;
  1111. }
  1112. if (spreadMode === _ui_utils.SpreadMode.UNKNOWN) {
  1113. spreadMode = values.spreadMode | 0;
  1114. }
  1115. }
  1116. if (pageMode && sidebarView === _pdf_sidebar.SidebarView.UNKNOWN) {
  1117. sidebarView = apiPageModeToSidebarView(pageMode);
  1118. }
  1119. if (pageLayout && spreadMode === _ui_utils.SpreadMode.UNKNOWN) {
  1120. spreadMode = apiPageLayoutToSpreadMode(pageLayout);
  1121. }
  1122. _this5.setInitialView(hash, {
  1123. rotation: rotation,
  1124. sidebarView: sidebarView,
  1125. scrollMode: scrollMode,
  1126. spreadMode: spreadMode
  1127. });
  1128. _this5.eventBus.dispatch('documentinit', {
  1129. source: _this5
  1130. });
  1131. if (!_this5.isViewerEmbedded) {
  1132. pdfViewer.focus();
  1133. }
  1134. _context8.next = 18;
  1135. return Promise.race([pagesPromise, new Promise(function (resolve) {
  1136. setTimeout(resolve, FORCE_PAGES_LOADED_TIMEOUT);
  1137. })]);
  1138. case 18:
  1139. if (!(!initialBookmark && !hash)) {
  1140. _context8.next = 20;
  1141. break;
  1142. }
  1143. return _context8.abrupt("return");
  1144. case 20:
  1145. if (!pdfViewer.hasEqualPageSizes) {
  1146. _context8.next = 22;
  1147. break;
  1148. }
  1149. return _context8.abrupt("return");
  1150. case 22:
  1151. _this5.initialBookmark = initialBookmark;
  1152. pdfViewer.currentScaleValue = pdfViewer.currentScaleValue;
  1153. _this5.setInitialView(hash);
  1154. case 25:
  1155. case "end":
  1156. return _context8.stop();
  1157. }
  1158. }
  1159. }, _callee8);
  1160. }));
  1161. return function (_x4) {
  1162. return _ref3.apply(this, arguments);
  1163. };
  1164. }())["catch"](function () {
  1165. _this5.setInitialView();
  1166. }).then(function () {
  1167. pdfViewer.update();
  1168. });
  1169. });
  1170. pdfDocument.getPageLabels().then(function (labels) {
  1171. if (!labels || _app_options.AppOptions.get('disablePageLabels')) {
  1172. return;
  1173. }
  1174. var i = 0,
  1175. numLabels = labels.length;
  1176. if (numLabels !== _this5.pagesCount) {
  1177. console.error('The number of Page Labels does not match ' + 'the number of pages in the document.');
  1178. return;
  1179. }
  1180. while (i < numLabels && labels[i] === (i + 1).toString()) {
  1181. i++;
  1182. }
  1183. if (i === numLabels) {
  1184. return;
  1185. }
  1186. pdfViewer.setPageLabels(labels);
  1187. pdfThumbnailViewer.setPageLabels(labels);
  1188. _this5.toolbar.setPagesCount(pdfDocument.numPages, true);
  1189. _this5.toolbar.setPageNumber(pdfViewer.currentPageNumber, pdfViewer.currentPageLabel);
  1190. });
  1191. pagesPromise.then(function () {
  1192. if (!_this5.supportsPrinting) {
  1193. return;
  1194. }
  1195. pdfDocument.getJavaScript().then(function (javaScript) {
  1196. if (!javaScript) {
  1197. return;
  1198. }
  1199. javaScript.some(function (js) {
  1200. if (!js) {
  1201. return false;
  1202. }
  1203. console.warn('Warning: JavaScript is not supported');
  1204. _this5.fallback(_pdfjsLib.UNSUPPORTED_FEATURES.javaScript);
  1205. return true;
  1206. });
  1207. var regex = /\bprint\s*\(/;
  1208. for (var i = 0, ii = javaScript.length; i < ii; i++) {
  1209. var js = javaScript[i];
  1210. if (js && regex.test(js)) {
  1211. setTimeout(function () {
  1212. window.print();
  1213. });
  1214. return;
  1215. }
  1216. }
  1217. });
  1218. });
  1219. onePageRendered.then(function () {
  1220. pdfDocument.getOutline().then(function (outline) {
  1221. _this5.pdfOutlineViewer.render({
  1222. outline: outline
  1223. });
  1224. });
  1225. pdfDocument.getAttachments().then(function (attachments) {
  1226. _this5.pdfAttachmentViewer.render({
  1227. attachments: attachments
  1228. });
  1229. });
  1230. });
  1231. pdfDocument.getMetadata().then(function (_ref5) {
  1232. var info = _ref5.info,
  1233. metadata = _ref5.metadata,
  1234. contentDispositionFilename = _ref5.contentDispositionFilename;
  1235. _this5.documentInfo = info;
  1236. _this5.metadata = metadata;
  1237. _this5.contentDispositionFilename = contentDispositionFilename;
  1238. console.log('PDF ' + pdfDocument.fingerprint + ' [' + info.PDFFormatVersion + ' ' + (info.Producer || '-').trim() + ' / ' + (info.Creator || '-').trim() + ']' + ' (PDF.js: ' + (_pdfjsLib.version || '-') + (_app_options.AppOptions.get('enableWebGL') ? ' [WebGL]' : '') + ')');
  1239. var pdfTitle;
  1240. if (metadata && metadata.has('dc:title')) {
  1241. var title = metadata.get('dc:title');
  1242. if (title !== 'Untitled') {
  1243. pdfTitle = title;
  1244. }
  1245. }
  1246. if (!pdfTitle && info && info['Title']) {
  1247. pdfTitle = info['Title'];
  1248. }
  1249. if (pdfTitle) {
  1250. _this5.setTitle("".concat(pdfTitle, " - ").concat(contentDispositionFilename || document.title));
  1251. } else if (contentDispositionFilename) {
  1252. _this5.setTitle(contentDispositionFilename);
  1253. }
  1254. if (info.IsAcroFormPresent) {
  1255. console.warn('Warning: AcroForm/XFA is not supported');
  1256. _this5.fallback(_pdfjsLib.UNSUPPORTED_FEATURES.forms);
  1257. }
  1258. });
  1259. },
  1260. _initializePdfHistory: function _initializePdfHistory(_ref6) {
  1261. var fingerprint = _ref6.fingerprint,
  1262. viewOnLoad = _ref6.viewOnLoad,
  1263. _ref6$initialDest = _ref6.initialDest,
  1264. initialDest = _ref6$initialDest === void 0 ? null : _ref6$initialDest;
  1265. if (_app_options.AppOptions.get('disableHistory') || this.isViewerEmbedded) {
  1266. return;
  1267. }
  1268. this.pdfHistory.initialize({
  1269. fingerprint: fingerprint,
  1270. resetHistory: viewOnLoad === ViewOnLoad.INITIAL,
  1271. updateUrl: _app_options.AppOptions.get('historyUpdateUrl')
  1272. });
  1273. if (this.pdfHistory.initialBookmark) {
  1274. this.initialBookmark = this.pdfHistory.initialBookmark;
  1275. this.initialRotation = this.pdfHistory.initialRotation;
  1276. }
  1277. if (initialDest && !this.initialBookmark && viewOnLoad === ViewOnLoad.UNKNOWN) {
  1278. this.initialBookmark = JSON.stringify(initialDest);
  1279. this.pdfHistory.push({
  1280. explicitDest: initialDest,
  1281. pageNumber: null
  1282. });
  1283. }
  1284. },
  1285. setInitialView: function setInitialView(storedHash) {
  1286. var _this6 = this;
  1287. var _ref7 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
  1288. rotation = _ref7.rotation,
  1289. sidebarView = _ref7.sidebarView,
  1290. scrollMode = _ref7.scrollMode,
  1291. spreadMode = _ref7.spreadMode;
  1292. var setRotation = function setRotation(angle) {
  1293. if ((0, _ui_utils.isValidRotation)(angle)) {
  1294. _this6.pdfViewer.pagesRotation = angle;
  1295. }
  1296. };
  1297. var setViewerModes = function setViewerModes(scroll, spread) {
  1298. if ((0, _ui_utils.isValidScrollMode)(scroll)) {
  1299. _this6.pdfViewer.scrollMode = scroll;
  1300. }
  1301. if ((0, _ui_utils.isValidSpreadMode)(spread)) {
  1302. _this6.pdfViewer.spreadMode = spread;
  1303. }
  1304. };
  1305. this.isInitialViewSet = true;
  1306. this.pdfSidebar.setInitialView(sidebarView);
  1307. setViewerModes(scrollMode, spreadMode);
  1308. if (this.initialBookmark) {
  1309. setRotation(this.initialRotation);
  1310. delete this.initialRotation;
  1311. this.pdfLinkService.setHash(this.initialBookmark);
  1312. this.initialBookmark = null;
  1313. } else if (storedHash) {
  1314. setRotation(rotation);
  1315. this.pdfLinkService.setHash(storedHash);
  1316. }
  1317. this.toolbar.setPageNumber(this.pdfViewer.currentPageNumber, this.pdfViewer.currentPageLabel);
  1318. this.secondaryToolbar.setPageNumber(this.pdfViewer.currentPageNumber);
  1319. if (!this.pdfViewer.currentScaleValue) {
  1320. this.pdfViewer.currentScaleValue = _ui_utils.DEFAULT_SCALE_VALUE;
  1321. }
  1322. },
  1323. cleanup: function cleanup() {
  1324. if (!this.pdfDocument) {
  1325. return;
  1326. }
  1327. this.pdfViewer.cleanup();
  1328. this.pdfThumbnailViewer.cleanup();
  1329. if (this.pdfViewer.renderer !== _ui_utils.RendererType.SVG) {
  1330. this.pdfDocument.cleanup();
  1331. }
  1332. },
  1333. forceRendering: function forceRendering() {
  1334. this.pdfRenderingQueue.printing = this.printing;
  1335. this.pdfRenderingQueue.isThumbnailViewEnabled = this.pdfSidebar.isThumbnailViewVisible;
  1336. this.pdfRenderingQueue.renderHighestPriority();
  1337. },
  1338. beforePrint: function beforePrint() {
  1339. var _this7 = this;
  1340. if (this.printService) {
  1341. return;
  1342. }
  1343. if (!this.supportsPrinting) {
  1344. this.l10n.get('printing_not_supported', null, 'Warning: Printing is not fully supported by ' + 'this browser.').then(function (printMessage) {
  1345. _this7.error(printMessage);
  1346. });
  1347. return;
  1348. }
  1349. if (!this.pdfViewer.pageViewsReady) {
  1350. this.l10n.get('printing_not_ready', null, 'Warning: The PDF is not fully loaded for printing.').then(function (notReadyMessage) {
  1351. window.alert(notReadyMessage);
  1352. });
  1353. return;
  1354. }
  1355. var pagesOverview = this.pdfViewer.getPagesOverview();
  1356. var printContainer = this.appConfig.printContainer;
  1357. var printService = PDFPrintServiceFactory.instance.createPrintService(this.pdfDocument, pagesOverview, printContainer, this.l10n);
  1358. this.printService = printService;
  1359. this.forceRendering();
  1360. printService.layout();
  1361. },
  1362. afterPrint: function afterPrint() {
  1363. if (this.printService) {
  1364. this.printService.destroy();
  1365. this.printService = null;
  1366. }
  1367. this.forceRendering();
  1368. },
  1369. rotatePages: function rotatePages(delta) {
  1370. if (!this.pdfDocument) {
  1371. return;
  1372. }
  1373. var newRotation = (this.pdfViewer.pagesRotation + 360 + delta) % 360;
  1374. this.pdfViewer.pagesRotation = newRotation;
  1375. },
  1376. requestPresentationMode: function requestPresentationMode() {
  1377. if (!this.pdfPresentationMode) {
  1378. return;
  1379. }
  1380. this.pdfPresentationMode.request();
  1381. },
  1382. bindEvents: function bindEvents() {
  1383. var eventBus = this.eventBus,
  1384. _boundEvents = this._boundEvents;
  1385. _boundEvents.beforePrint = this.beforePrint.bind(this);
  1386. _boundEvents.afterPrint = this.afterPrint.bind(this);
  1387. eventBus.on('resize', webViewerResize);
  1388. eventBus.on('hashchange', webViewerHashchange);
  1389. eventBus.on('beforeprint', _boundEvents.beforePrint);
  1390. eventBus.on('afterprint', _boundEvents.afterPrint);
  1391. eventBus.on('pagerendered', webViewerPageRendered);
  1392. eventBus.on('textlayerrendered', webViewerTextLayerRendered);
  1393. eventBus.on('updateviewarea', webViewerUpdateViewarea);
  1394. eventBus.on('pagechanging', webViewerPageChanging);
  1395. eventBus.on('scalechanging', webViewerScaleChanging);
  1396. eventBus.on('rotationchanging', webViewerRotationChanging);
  1397. eventBus.on('sidebarviewchanged', webViewerSidebarViewChanged);
  1398. eventBus.on('pagemode', webViewerPageMode);
  1399. eventBus.on('namedaction', webViewerNamedAction);
  1400. eventBus.on('presentationmodechanged', webViewerPresentationModeChanged);
  1401. eventBus.on('presentationmode', webViewerPresentationMode);
  1402. eventBus.on('openfile', webViewerOpenFile);
  1403. eventBus.on('print', webViewerPrint);
  1404. eventBus.on('download', webViewerDownload);
  1405. eventBus.on('firstpage', webViewerFirstPage);
  1406. eventBus.on('lastpage', webViewerLastPage);
  1407. eventBus.on('nextpage', webViewerNextPage);
  1408. eventBus.on('previouspage', webViewerPreviousPage);
  1409. eventBus.on('zoomin', webViewerZoomIn);
  1410. eventBus.on('zoomout', webViewerZoomOut);
  1411. eventBus.on('zoomreset', webViewerZoomReset);
  1412. eventBus.on('pagenumberchanged', webViewerPageNumberChanged);
  1413. eventBus.on('scalechanged', webViewerScaleChanged);
  1414. eventBus.on('rotatecw', webViewerRotateCw);
  1415. eventBus.on('rotateccw', webViewerRotateCcw);
  1416. eventBus.on('switchscrollmode', webViewerSwitchScrollMode);
  1417. eventBus.on('scrollmodechanged', webViewerScrollModeChanged);
  1418. eventBus.on('switchspreadmode', webViewerSwitchSpreadMode);
  1419. eventBus.on('spreadmodechanged', webViewerSpreadModeChanged);
  1420. eventBus.on('documentproperties', webViewerDocumentProperties);
  1421. eventBus.on('find', webViewerFind);
  1422. eventBus.on('findfromurlhash', webViewerFindFromUrlHash);
  1423. eventBus.on('updatefindmatchescount', webViewerUpdateFindMatchesCount);
  1424. eventBus.on('updatefindcontrolstate', webViewerUpdateFindControlState);
  1425. eventBus.on('fileinputchange', webViewerFileInputChange);
  1426. },
  1427. bindWindowEvents: function bindWindowEvents() {
  1428. var eventBus = this.eventBus,
  1429. _boundEvents = this._boundEvents;
  1430. _boundEvents.windowResize = function () {
  1431. eventBus.dispatch('resize', {
  1432. source: window
  1433. });
  1434. };
  1435. _boundEvents.windowHashChange = function () {
  1436. eventBus.dispatch('hashchange', {
  1437. source: window,
  1438. hash: document.location.hash.substring(1)
  1439. });
  1440. };
  1441. _boundEvents.windowBeforePrint = function () {
  1442. eventBus.dispatch('beforeprint', {
  1443. source: window
  1444. });
  1445. };
  1446. _boundEvents.windowAfterPrint = function () {
  1447. eventBus.dispatch('afterprint', {
  1448. source: window
  1449. });
  1450. };
  1451. window.addEventListener('visibilitychange', webViewerVisibilityChange);
  1452. window.addEventListener('wheel', webViewerWheel, {
  1453. passive: false
  1454. });
  1455. window.addEventListener('click', webViewerClick);
  1456. window.addEventListener('keydown', webViewerKeyDown);
  1457. window.addEventListener('resize', _boundEvents.windowResize);
  1458. window.addEventListener('hashchange', _boundEvents.windowHashChange);
  1459. window.addEventListener('beforeprint', _boundEvents.windowBeforePrint);
  1460. window.addEventListener('afterprint', _boundEvents.windowAfterPrint);
  1461. },
  1462. unbindEvents: function unbindEvents() {
  1463. var eventBus = this.eventBus,
  1464. _boundEvents = this._boundEvents;
  1465. eventBus.off('resize', webViewerResize);
  1466. eventBus.off('hashchange', webViewerHashchange);
  1467. eventBus.off('beforeprint', _boundEvents.beforePrint);
  1468. eventBus.off('afterprint', _boundEvents.afterPrint);
  1469. eventBus.off('pagerendered', webViewerPageRendered);
  1470. eventBus.off('textlayerrendered', webViewerTextLayerRendered);
  1471. eventBus.off('updateviewarea', webViewerUpdateViewarea);
  1472. eventBus.off('pagechanging', webViewerPageChanging);
  1473. eventBus.off('scalechanging', webViewerScaleChanging);
  1474. eventBus.off('rotationchanging', webViewerRotationChanging);
  1475. eventBus.off('sidebarviewchanged', webViewerSidebarViewChanged);
  1476. eventBus.off('pagemode', webViewerPageMode);
  1477. eventBus.off('namedaction', webViewerNamedAction);
  1478. eventBus.off('presentationmodechanged', webViewerPresentationModeChanged);
  1479. eventBus.off('presentationmode', webViewerPresentationMode);
  1480. eventBus.off('openfile', webViewerOpenFile);
  1481. eventBus.off('print', webViewerPrint);
  1482. eventBus.off('download', webViewerDownload);
  1483. eventBus.off('firstpage', webViewerFirstPage);
  1484. eventBus.off('lastpage', webViewerLastPage);
  1485. eventBus.off('nextpage', webViewerNextPage);
  1486. eventBus.off('previouspage', webViewerPreviousPage);
  1487. eventBus.off('zoomin', webViewerZoomIn);
  1488. eventBus.off('zoomout', webViewerZoomOut);
  1489. eventBus.off('zoomreset', webViewerZoomReset);
  1490. eventBus.off('pagenumberchanged', webViewerPageNumberChanged);
  1491. eventBus.off('scalechanged', webViewerScaleChanged);
  1492. eventBus.off('rotatecw', webViewerRotateCw);
  1493. eventBus.off('rotateccw', webViewerRotateCcw);
  1494. eventBus.off('switchscrollmode', webViewerSwitchScrollMode);
  1495. eventBus.off('scrollmodechanged', webViewerScrollModeChanged);
  1496. eventBus.off('switchspreadmode', webViewerSwitchSpreadMode);
  1497. eventBus.off('spreadmodechanged', webViewerSpreadModeChanged);
  1498. eventBus.off('documentproperties', webViewerDocumentProperties);
  1499. eventBus.off('find', webViewerFind);
  1500. eventBus.off('findfromurlhash', webViewerFindFromUrlHash);
  1501. eventBus.off('updatefindmatchescount', webViewerUpdateFindMatchesCount);
  1502. eventBus.off('updatefindcontrolstate', webViewerUpdateFindControlState);
  1503. eventBus.off('fileinputchange', webViewerFileInputChange);
  1504. _boundEvents.beforePrint = null;
  1505. _boundEvents.afterPrint = null;
  1506. },
  1507. unbindWindowEvents: function unbindWindowEvents() {
  1508. var _boundEvents = this._boundEvents;
  1509. window.removeEventListener('visibilitychange', webViewerVisibilityChange);
  1510. window.removeEventListener('wheel', webViewerWheel);
  1511. window.removeEventListener('click', webViewerClick);
  1512. window.removeEventListener('keydown', webViewerKeyDown);
  1513. window.removeEventListener('resize', _boundEvents.windowResize);
  1514. window.removeEventListener('hashchange', _boundEvents.windowHashChange);
  1515. window.removeEventListener('beforeprint', _boundEvents.windowBeforePrint);
  1516. window.removeEventListener('afterprint', _boundEvents.windowAfterPrint);
  1517. _boundEvents.windowResize = null;
  1518. _boundEvents.windowHashChange = null;
  1519. _boundEvents.windowBeforePrint = null;
  1520. _boundEvents.windowAfterPrint = null;
  1521. }
  1522. };
  1523. exports.PDFViewerApplication = PDFViewerApplication;
  1524. var validateFileURL;
  1525. {
  1526. var HOSTED_VIEWER_ORIGINS = ['null', 'http://mozilla.github.io', 'https://mozilla.github.io'];
  1527. validateFileURL = function validateFileURL(file) {
  1528. if (file === undefined) {
  1529. return;
  1530. }
  1531. try {
  1532. var viewerOrigin = new URL(window.location.href).origin || 'null';
  1533. if (HOSTED_VIEWER_ORIGINS.includes(viewerOrigin)) {
  1534. return;
  1535. }
  1536. var _ref8 = new URL(file, window.location.href),
  1537. origin = _ref8.origin,
  1538. protocol = _ref8.protocol;
  1539. // if (origin !== viewerOrigin && protocol !== 'blob:') {
  1540. // throw new Error('file origin does not match viewer\'s');
  1541. // }
  1542. } catch (ex) {
  1543. var message = ex && ex.message;
  1544. PDFViewerApplication.l10n.get('loading_error', null, 'An error occurred while loading the PDF.').then(function (loadingErrorMessage) {
  1545. PDFViewerApplication.error(loadingErrorMessage, {
  1546. message: message
  1547. });
  1548. });
  1549. throw ex;
  1550. }
  1551. };
  1552. }
  1553. function loadFakeWorker() {
  1554. if (!_pdfjsLib.GlobalWorkerOptions.workerSrc) {
  1555. _pdfjsLib.GlobalWorkerOptions.workerSrc = _app_options.AppOptions.get('workerSrc');
  1556. }
  1557. return (0, _pdfjsLib.loadScript)(_pdfjsLib.PDFWorker.getWorkerSrc());
  1558. }
  1559. function loadAndEnablePDFBug(enabledTabs) {
  1560. var appConfig = PDFViewerApplication.appConfig;
  1561. return (0, _pdfjsLib.loadScript)(appConfig.debuggerScriptPath).then(function () {
  1562. PDFBug.enable(enabledTabs);
  1563. PDFBug.init({
  1564. OPS: _pdfjsLib.OPS,
  1565. createObjectURL: _pdfjsLib.createObjectURL
  1566. }, appConfig.mainContainer);
  1567. });
  1568. }
  1569. function webViewerInitialized() {
  1570. var appConfig = PDFViewerApplication.appConfig;
  1571. var file;
  1572. var queryString = document.location.search.substring(1);
  1573. var params = (0, _ui_utils.parseQueryString)(queryString);
  1574. file = 'file' in params ? params.file : _app_options.AppOptions.get('defaultUrl');
  1575. validateFileURL(file);
  1576. var fileInput = document.createElement('input');
  1577. fileInput.id = appConfig.openFileInputName;
  1578. fileInput.className = 'fileInput';
  1579. fileInput.setAttribute('type', 'file');
  1580. fileInput.oncontextmenu = _ui_utils.noContextMenuHandler;
  1581. document.body.appendChild(fileInput);
  1582. if (!window.File || !window.FileReader || !window.FileList || !window.Blob) {
  1583. appConfig.toolbar.openFile.setAttribute('hidden', 'true');
  1584. appConfig.secondaryToolbar.openFileButton.setAttribute('hidden', 'true');
  1585. } else {
  1586. fileInput.value = null;
  1587. }
  1588. fileInput.addEventListener('change', function (evt) {
  1589. var files = evt.target.files;
  1590. if (!files || files.length === 0) {
  1591. return;
  1592. }
  1593. PDFViewerApplication.eventBus.dispatch('fileinputchange', {
  1594. source: this,
  1595. fileInput: evt.target
  1596. });
  1597. });
  1598. appConfig.mainContainer.addEventListener('dragover', function (evt) {
  1599. evt.preventDefault();
  1600. evt.dataTransfer.dropEffect = 'move';
  1601. });
  1602. appConfig.mainContainer.addEventListener('drop', function (evt) {
  1603. evt.preventDefault();
  1604. var files = evt.dataTransfer.files;
  1605. if (!files || files.length === 0) {
  1606. return;
  1607. }
  1608. PDFViewerApplication.eventBus.dispatch('fileinputchange', {
  1609. source: this,
  1610. fileInput: evt.dataTransfer
  1611. });
  1612. });
  1613. if (!PDFViewerApplication.supportsPrinting) {
  1614. appConfig.toolbar.print.classList.add('hidden');
  1615. appConfig.secondaryToolbar.printButton.classList.add('hidden');
  1616. }
  1617. if (!PDFViewerApplication.supportsFullscreen) {
  1618. appConfig.toolbar.presentationModeButton.classList.add('hidden');
  1619. appConfig.secondaryToolbar.presentationModeButton.classList.add('hidden');
  1620. }
  1621. if (PDFViewerApplication.supportsIntegratedFind) {
  1622. appConfig.toolbar.viewFind.classList.add('hidden');
  1623. }
  1624. appConfig.mainContainer.addEventListener('transitionend', function (evt) {
  1625. if (evt.target === this) {
  1626. PDFViewerApplication.eventBus.dispatch('resize', {
  1627. source: this
  1628. });
  1629. }
  1630. }, true);
  1631. try {
  1632. webViewerOpenFileViaURL(file);
  1633. } catch (reason) {
  1634. PDFViewerApplication.l10n.get('loading_error', null, 'An error occurred while loading the PDF.').then(function (msg) {
  1635. PDFViewerApplication.error(msg, reason);
  1636. });
  1637. }
  1638. }
  1639. var webViewerOpenFileViaURL;
  1640. {
  1641. webViewerOpenFileViaURL = function webViewerOpenFileViaURL(file) {
  1642. if (file && file.lastIndexOf('file:', 0) === 0) {
  1643. PDFViewerApplication.setTitleUsingUrl(file);
  1644. var xhr = new XMLHttpRequest();
  1645. xhr.onload = function () {
  1646. PDFViewerApplication.open(new Uint8Array(xhr.response));
  1647. };
  1648. xhr.open('GET', file);
  1649. xhr.responseType = 'arraybuffer';
  1650. xhr.send();
  1651. return;
  1652. }
  1653. if (file) {
  1654. PDFViewerApplication.open(file);
  1655. }
  1656. };
  1657. }
  1658. function webViewerPageRendered(evt) {
  1659. var pageNumber = evt.pageNumber;
  1660. var pageIndex = pageNumber - 1;
  1661. var pageView = PDFViewerApplication.pdfViewer.getPageView(pageIndex);
  1662. if (pageNumber === PDFViewerApplication.page) {
  1663. PDFViewerApplication.toolbar.updateLoadingIndicatorState(false);
  1664. }
  1665. if (!pageView) {
  1666. return;
  1667. }
  1668. if (PDFViewerApplication.pdfSidebar.isThumbnailViewVisible) {
  1669. var thumbnailView = PDFViewerApplication.pdfThumbnailViewer.getThumbnail(pageIndex);
  1670. thumbnailView.setImage(pageView);
  1671. }
  1672. if (typeof Stats !== 'undefined' && Stats.enabled && pageView.stats) {
  1673. Stats.add(pageNumber, pageView.stats);
  1674. }
  1675. if (pageView.error) {
  1676. PDFViewerApplication.l10n.get('rendering_error', null, 'An error occurred while rendering the page.').then(function (msg) {
  1677. PDFViewerApplication.error(msg, pageView.error);
  1678. });
  1679. }
  1680. }
  1681. function webViewerTextLayerRendered(evt) {}
  1682. function webViewerPageMode(evt) {
  1683. var mode = evt.mode,
  1684. view;
  1685. switch (mode) {
  1686. case 'thumbs':
  1687. view = _pdf_sidebar.SidebarView.THUMBS;
  1688. break;
  1689. case 'bookmarks':
  1690. case 'outline':
  1691. view = _pdf_sidebar.SidebarView.OUTLINE;
  1692. break;
  1693. case 'attachments':
  1694. view = _pdf_sidebar.SidebarView.ATTACHMENTS;
  1695. break;
  1696. case 'none':
  1697. view = _pdf_sidebar.SidebarView.NONE;
  1698. break;
  1699. default:
  1700. console.error('Invalid "pagemode" hash parameter: ' + mode);
  1701. return;
  1702. }
  1703. PDFViewerApplication.pdfSidebar.switchView(view, true);
  1704. }
  1705. function webViewerNamedAction(evt) {
  1706. var action = evt.action;
  1707. switch (action) {
  1708. case 'GoToPage':
  1709. PDFViewerApplication.appConfig.toolbar.pageNumber.select();
  1710. break;
  1711. case 'Find':
  1712. if (!PDFViewerApplication.supportsIntegratedFind) {
  1713. PDFViewerApplication.findBar.toggle();
  1714. }
  1715. break;
  1716. }
  1717. }
  1718. function webViewerPresentationModeChanged(evt) {
  1719. var active = evt.active,
  1720. switchInProgress = evt.switchInProgress;
  1721. PDFViewerApplication.pdfViewer.presentationModeState = switchInProgress ? _ui_utils.PresentationModeState.CHANGING : active ? _ui_utils.PresentationModeState.FULLSCREEN : _ui_utils.PresentationModeState.NORMAL;
  1722. }
  1723. function webViewerSidebarViewChanged(evt) {
  1724. PDFViewerApplication.pdfRenderingQueue.isThumbnailViewEnabled = PDFViewerApplication.pdfSidebar.isThumbnailViewVisible;
  1725. var store = PDFViewerApplication.store;
  1726. if (store && PDFViewerApplication.isInitialViewSet) {
  1727. store.set('sidebarView', evt.view)["catch"](function () {});
  1728. }
  1729. }
  1730. function webViewerUpdateViewarea(evt) {
  1731. var location = evt.location,
  1732. store = PDFViewerApplication.store;
  1733. if (store && PDFViewerApplication.isInitialViewSet) {
  1734. store.setMultiple({
  1735. 'page': location.pageNumber,
  1736. 'zoom': location.scale,
  1737. 'scrollLeft': location.left,
  1738. 'scrollTop': location.top,
  1739. 'rotation': location.rotation
  1740. })["catch"](function () {});
  1741. }
  1742. var href = PDFViewerApplication.pdfLinkService.getAnchorUrl(location.pdfOpenParams);
  1743. PDFViewerApplication.appConfig.toolbar.viewBookmark.href = href;
  1744. PDFViewerApplication.appConfig.secondaryToolbar.viewBookmarkButton.href = href;
  1745. var currentPage = PDFViewerApplication.pdfViewer.getPageView(PDFViewerApplication.page - 1);
  1746. var loading = currentPage.renderingState !== _pdf_rendering_queue.RenderingStates.FINISHED;
  1747. PDFViewerApplication.toolbar.updateLoadingIndicatorState(loading);
  1748. }
  1749. function webViewerScrollModeChanged(evt) {
  1750. var store = PDFViewerApplication.store;
  1751. if (store && PDFViewerApplication.isInitialViewSet) {
  1752. store.set('scrollMode', evt.mode)["catch"](function () {});
  1753. }
  1754. }
  1755. function webViewerSpreadModeChanged(evt) {
  1756. var store = PDFViewerApplication.store;
  1757. if (store && PDFViewerApplication.isInitialViewSet) {
  1758. store.set('spreadMode', evt.mode)["catch"](function () {});
  1759. }
  1760. }
  1761. function webViewerResize() {
  1762. var pdfDocument = PDFViewerApplication.pdfDocument,
  1763. pdfViewer = PDFViewerApplication.pdfViewer;
  1764. if (!pdfDocument) {
  1765. return;
  1766. }
  1767. var currentScaleValue = pdfViewer.currentScaleValue;
  1768. if (currentScaleValue === 'auto' || currentScaleValue === 'page-fit' || currentScaleValue === 'page-width') {
  1769. pdfViewer.currentScaleValue = currentScaleValue;
  1770. }
  1771. pdfViewer.update();
  1772. }
  1773. function webViewerHashchange(evt) {
  1774. var hash = evt.hash;
  1775. if (!hash) {
  1776. return;
  1777. }
  1778. if (!PDFViewerApplication.isInitialViewSet) {
  1779. PDFViewerApplication.initialBookmark = hash;
  1780. } else if (!PDFViewerApplication.pdfHistory.popStateInProgress) {
  1781. PDFViewerApplication.pdfLinkService.setHash(hash);
  1782. }
  1783. }
  1784. var webViewerFileInputChange;
  1785. {
  1786. webViewerFileInputChange = function webViewerFileInputChange(evt) {
  1787. if (PDFViewerApplication.pdfViewer && PDFViewerApplication.pdfViewer.isInPresentationMode) {
  1788. return;
  1789. }
  1790. var file = evt.fileInput.files[0];
  1791. if (URL.createObjectURL && !_app_options.AppOptions.get('disableCreateObjectURL')) {
  1792. var url = URL.createObjectURL(file);
  1793. if (file.name) {
  1794. url = {
  1795. url: url,
  1796. originalUrl: file.name
  1797. };
  1798. }
  1799. PDFViewerApplication.open(url);
  1800. } else {
  1801. PDFViewerApplication.setTitleUsingUrl(file.name);
  1802. var fileReader = new FileReader();
  1803. fileReader.onload = function webViewerChangeFileReaderOnload(evt) {
  1804. var buffer = evt.target.result;
  1805. PDFViewerApplication.open(new Uint8Array(buffer));
  1806. };
  1807. fileReader.readAsArrayBuffer(file);
  1808. }
  1809. var appConfig = PDFViewerApplication.appConfig;
  1810. appConfig.toolbar.viewBookmark.setAttribute('hidden', 'true');
  1811. appConfig.secondaryToolbar.viewBookmarkButton.setAttribute('hidden', 'true');
  1812. appConfig.toolbar.download.setAttribute('hidden', 'true');
  1813. appConfig.secondaryToolbar.downloadButton.setAttribute('hidden', 'true');
  1814. };
  1815. }
  1816. function webViewerPresentationMode() {
  1817. PDFViewerApplication.requestPresentationMode();
  1818. }
  1819. function webViewerOpenFile() {
  1820. var openFileInputName = PDFViewerApplication.appConfig.openFileInputName;
  1821. document.getElementById(openFileInputName).click();
  1822. }
  1823. function webViewerPrint() {
  1824. window.print();
  1825. }
  1826. function webViewerDownload() {
  1827. PDFViewerApplication.download();
  1828. }
  1829. function webViewerFirstPage() {
  1830. if (PDFViewerApplication.pdfDocument) {
  1831. PDFViewerApplication.page = 1;
  1832. }
  1833. }
  1834. function webViewerLastPage() {
  1835. if (PDFViewerApplication.pdfDocument) {
  1836. PDFViewerApplication.page = PDFViewerApplication.pagesCount;
  1837. }
  1838. }
  1839. function webViewerNextPage() {
  1840. PDFViewerApplication.page++;
  1841. }
  1842. function webViewerPreviousPage() {
  1843. PDFViewerApplication.page--;
  1844. }
  1845. function webViewerZoomIn() {
  1846. PDFViewerApplication.zoomIn();
  1847. }
  1848. function webViewerZoomOut() {
  1849. PDFViewerApplication.zoomOut();
  1850. }
  1851. function webViewerZoomReset() {
  1852. PDFViewerApplication.zoomReset();
  1853. }
  1854. function webViewerPageNumberChanged(evt) {
  1855. var pdfViewer = PDFViewerApplication.pdfViewer;
  1856. if (evt.value !== '') {
  1857. pdfViewer.currentPageLabel = evt.value;
  1858. }
  1859. if (evt.value !== pdfViewer.currentPageNumber.toString() && evt.value !== pdfViewer.currentPageLabel) {
  1860. PDFViewerApplication.toolbar.setPageNumber(pdfViewer.currentPageNumber, pdfViewer.currentPageLabel);
  1861. }
  1862. }
  1863. function webViewerScaleChanged(evt) {
  1864. PDFViewerApplication.pdfViewer.currentScaleValue = evt.value;
  1865. }
  1866. function webViewerRotateCw() {
  1867. PDFViewerApplication.rotatePages(90);
  1868. }
  1869. function webViewerRotateCcw() {
  1870. PDFViewerApplication.rotatePages(-90);
  1871. }
  1872. function webViewerSwitchScrollMode(evt) {
  1873. PDFViewerApplication.pdfViewer.scrollMode = evt.mode;
  1874. }
  1875. function webViewerSwitchSpreadMode(evt) {
  1876. PDFViewerApplication.pdfViewer.spreadMode = evt.mode;
  1877. }
  1878. function webViewerDocumentProperties() {
  1879. PDFViewerApplication.pdfDocumentProperties.open();
  1880. }
  1881. function webViewerFind(evt) {
  1882. PDFViewerApplication.findController.executeCommand('find' + evt.type, {
  1883. query: evt.query,
  1884. phraseSearch: evt.phraseSearch,
  1885. caseSensitive: evt.caseSensitive,
  1886. entireWord: evt.entireWord,
  1887. highlightAll: evt.highlightAll,
  1888. findPrevious: evt.findPrevious
  1889. });
  1890. }
  1891. function webViewerFindFromUrlHash(evt) {
  1892. PDFViewerApplication.findController.executeCommand('find', {
  1893. query: evt.query,
  1894. phraseSearch: evt.phraseSearch,
  1895. caseSensitive: false,
  1896. entireWord: false,
  1897. highlightAll: true,
  1898. findPrevious: false
  1899. });
  1900. }
  1901. function webViewerUpdateFindMatchesCount(_ref9) {
  1902. var matchesCount = _ref9.matchesCount;
  1903. if (PDFViewerApplication.supportsIntegratedFind) {
  1904. PDFViewerApplication.externalServices.updateFindMatchesCount(matchesCount);
  1905. } else {
  1906. PDFViewerApplication.findBar.updateResultsCount(matchesCount);
  1907. }
  1908. }
  1909. function webViewerUpdateFindControlState(_ref10) {
  1910. var state = _ref10.state,
  1911. previous = _ref10.previous,
  1912. matchesCount = _ref10.matchesCount;
  1913. if (PDFViewerApplication.supportsIntegratedFind) {
  1914. PDFViewerApplication.externalServices.updateFindControlState({
  1915. result: state,
  1916. findPrevious: previous,
  1917. matchesCount: matchesCount
  1918. });
  1919. } else {
  1920. PDFViewerApplication.findBar.updateUIState(state, previous, matchesCount);
  1921. }
  1922. }
  1923. function webViewerScaleChanging(evt) {
  1924. PDFViewerApplication.toolbar.setPageScale(evt.presetValue, evt.scale);
  1925. PDFViewerApplication.pdfViewer.update();
  1926. }
  1927. function webViewerRotationChanging(evt) {
  1928. PDFViewerApplication.pdfThumbnailViewer.pagesRotation = evt.pagesRotation;
  1929. PDFViewerApplication.forceRendering();
  1930. PDFViewerApplication.pdfViewer.currentPageNumber = evt.pageNumber;
  1931. }
  1932. function webViewerPageChanging(evt) {
  1933. var page = evt.pageNumber;
  1934. PDFViewerApplication.toolbar.setPageNumber(page, evt.pageLabel || null);
  1935. PDFViewerApplication.secondaryToolbar.setPageNumber(page);
  1936. if (PDFViewerApplication.pdfSidebar.isThumbnailViewVisible) {
  1937. PDFViewerApplication.pdfThumbnailViewer.scrollThumbnailIntoView(page);
  1938. }
  1939. if (typeof Stats !== 'undefined' && Stats.enabled) {
  1940. var pageView = PDFViewerApplication.pdfViewer.getPageView(page - 1);
  1941. if (pageView && pageView.stats) {
  1942. Stats.add(page, pageView.stats);
  1943. }
  1944. }
  1945. }
  1946. function webViewerVisibilityChange(evt) {
  1947. if (document.visibilityState === 'visible') {
  1948. setZoomDisabledTimeout();
  1949. }
  1950. }
  1951. var zoomDisabledTimeout = null;
  1952. function setZoomDisabledTimeout() {
  1953. if (zoomDisabledTimeout) {
  1954. clearTimeout(zoomDisabledTimeout);
  1955. }
  1956. zoomDisabledTimeout = setTimeout(function () {
  1957. zoomDisabledTimeout = null;
  1958. }, WHEEL_ZOOM_DISABLED_TIMEOUT);
  1959. }
  1960. function webViewerWheel(evt) {
  1961. var pdfViewer = PDFViewerApplication.pdfViewer,
  1962. supportedMouseWheelZoomModifierKeys = PDFViewerApplication.supportedMouseWheelZoomModifierKeys;
  1963. if (pdfViewer.isInPresentationMode) {
  1964. return;
  1965. }
  1966. if (evt.ctrlKey && supportedMouseWheelZoomModifierKeys.ctrlKey || evt.metaKey && supportedMouseWheelZoomModifierKeys.metaKey) {
  1967. evt.preventDefault();
  1968. if (zoomDisabledTimeout || document.visibilityState === 'hidden') {
  1969. return;
  1970. }
  1971. var previousScale = pdfViewer.currentScale;
  1972. var delta = (0, _ui_utils.normalizeWheelEventDelta)(evt);
  1973. var MOUSE_WHEEL_DELTA_PER_PAGE_SCALE = 3.0;
  1974. var ticks = delta * MOUSE_WHEEL_DELTA_PER_PAGE_SCALE;
  1975. if (ticks < 0) {
  1976. PDFViewerApplication.zoomOut(-ticks);
  1977. } else {
  1978. PDFViewerApplication.zoomIn(ticks);
  1979. }
  1980. var currentScale = pdfViewer.currentScale;
  1981. if (previousScale !== currentScale) {
  1982. var scaleCorrectionFactor = currentScale / previousScale - 1;
  1983. var rect = pdfViewer.container.getBoundingClientRect();
  1984. var dx = evt.clientX - rect.left;
  1985. var dy = evt.clientY - rect.top;
  1986. pdfViewer.container.scrollLeft += dx * scaleCorrectionFactor;
  1987. pdfViewer.container.scrollTop += dy * scaleCorrectionFactor;
  1988. }
  1989. } else {
  1990. setZoomDisabledTimeout();
  1991. }
  1992. }
  1993. function webViewerClick(evt) {
  1994. if (!PDFViewerApplication.secondaryToolbar.isOpen) {
  1995. return;
  1996. }
  1997. var appConfig = PDFViewerApplication.appConfig;
  1998. if (PDFViewerApplication.pdfViewer.containsElement(evt.target) || appConfig.toolbar.container.contains(evt.target) && evt.target !== appConfig.secondaryToolbar.toggleButton) {
  1999. PDFViewerApplication.secondaryToolbar.close();
  2000. }
  2001. }
  2002. function webViewerKeyDown(evt) {
  2003. if (PDFViewerApplication.overlayManager.active) {
  2004. return;
  2005. }
  2006. var handled = false,
  2007. ensureViewerFocused = false;
  2008. var cmd = (evt.ctrlKey ? 1 : 0) | (evt.altKey ? 2 : 0) | (evt.shiftKey ? 4 : 0) | (evt.metaKey ? 8 : 0);
  2009. var pdfViewer = PDFViewerApplication.pdfViewer;
  2010. var isViewerInPresentationMode = pdfViewer && pdfViewer.isInPresentationMode;
  2011. if (cmd === 1 || cmd === 8 || cmd === 5 || cmd === 12) {
  2012. switch (evt.keyCode) {
  2013. case 70:
  2014. if (!PDFViewerApplication.supportsIntegratedFind) {
  2015. PDFViewerApplication.findBar.open();
  2016. handled = true;
  2017. }
  2018. break;
  2019. case 71:
  2020. if (!PDFViewerApplication.supportsIntegratedFind) {
  2021. var findState = PDFViewerApplication.findController.state;
  2022. if (findState) {
  2023. PDFViewerApplication.findController.executeCommand('findagain', {
  2024. query: findState.query,
  2025. phraseSearch: findState.phraseSearch,
  2026. caseSensitive: findState.caseSensitive,
  2027. entireWord: findState.entireWord,
  2028. highlightAll: findState.highlightAll,
  2029. findPrevious: cmd === 5 || cmd === 12
  2030. });
  2031. }
  2032. handled = true;
  2033. }
  2034. break;
  2035. case 61:
  2036. case 107:
  2037. case 187:
  2038. case 171:
  2039. if (!isViewerInPresentationMode) {
  2040. PDFViewerApplication.zoomIn();
  2041. }
  2042. handled = true;
  2043. break;
  2044. case 173:
  2045. case 109:
  2046. case 189:
  2047. if (!isViewerInPresentationMode) {
  2048. PDFViewerApplication.zoomOut();
  2049. }
  2050. handled = true;
  2051. break;
  2052. case 48:
  2053. case 96:
  2054. if (!isViewerInPresentationMode) {
  2055. setTimeout(function () {
  2056. PDFViewerApplication.zoomReset();
  2057. });
  2058. handled = false;
  2059. }
  2060. break;
  2061. case 38:
  2062. if (isViewerInPresentationMode || PDFViewerApplication.page > 1) {
  2063. PDFViewerApplication.page = 1;
  2064. handled = true;
  2065. ensureViewerFocused = true;
  2066. }
  2067. break;
  2068. case 40:
  2069. if (isViewerInPresentationMode || PDFViewerApplication.page < PDFViewerApplication.pagesCount) {
  2070. PDFViewerApplication.page = PDFViewerApplication.pagesCount;
  2071. handled = true;
  2072. ensureViewerFocused = true;
  2073. }
  2074. break;
  2075. }
  2076. }
  2077. if (cmd === 1 || cmd === 8) {
  2078. switch (evt.keyCode) {
  2079. case 83:
  2080. PDFViewerApplication.download();
  2081. handled = true;
  2082. break;
  2083. }
  2084. }
  2085. if (cmd === 3 || cmd === 10) {
  2086. switch (evt.keyCode) {
  2087. case 80:
  2088. PDFViewerApplication.requestPresentationMode();
  2089. handled = true;
  2090. break;
  2091. case 71:
  2092. PDFViewerApplication.appConfig.toolbar.pageNumber.select();
  2093. handled = true;
  2094. break;
  2095. }
  2096. }
  2097. if (handled) {
  2098. if (ensureViewerFocused && !isViewerInPresentationMode) {
  2099. pdfViewer.focus();
  2100. }
  2101. evt.preventDefault();
  2102. return;
  2103. }
  2104. var curElement = document.activeElement || document.querySelector(':focus');
  2105. var curElementTagName = curElement && curElement.tagName.toUpperCase();
  2106. if (curElementTagName === 'INPUT' || curElementTagName === 'TEXTAREA' || curElementTagName === 'SELECT') {
  2107. if (evt.keyCode !== 27) {
  2108. return;
  2109. }
  2110. }
  2111. if (cmd === 0) {
  2112. var turnPage = 0,
  2113. turnOnlyIfPageFit = false;
  2114. switch (evt.keyCode) {
  2115. case 38:
  2116. case 33:
  2117. if (pdfViewer.isVerticalScrollbarEnabled) {
  2118. turnOnlyIfPageFit = true;
  2119. }
  2120. turnPage = -1;
  2121. break;
  2122. case 8:
  2123. if (!isViewerInPresentationMode) {
  2124. turnOnlyIfPageFit = true;
  2125. }
  2126. turnPage = -1;
  2127. break;
  2128. case 37:
  2129. if (pdfViewer.isHorizontalScrollbarEnabled) {
  2130. turnOnlyIfPageFit = true;
  2131. }
  2132. case 75:
  2133. case 80:
  2134. turnPage = -1;
  2135. break;
  2136. case 27:
  2137. if (PDFViewerApplication.secondaryToolbar.isOpen) {
  2138. PDFViewerApplication.secondaryToolbar.close();
  2139. handled = true;
  2140. }
  2141. if (!PDFViewerApplication.supportsIntegratedFind && PDFViewerApplication.findBar.opened) {
  2142. PDFViewerApplication.findBar.close();
  2143. handled = true;
  2144. }
  2145. break;
  2146. case 40:
  2147. case 34:
  2148. if (pdfViewer.isVerticalScrollbarEnabled) {
  2149. turnOnlyIfPageFit = true;
  2150. }
  2151. turnPage = 1;
  2152. break;
  2153. case 13:
  2154. case 32:
  2155. if (!isViewerInPresentationMode) {
  2156. turnOnlyIfPageFit = true;
  2157. }
  2158. turnPage = 1;
  2159. break;
  2160. case 39:
  2161. if (pdfViewer.isHorizontalScrollbarEnabled) {
  2162. turnOnlyIfPageFit = true;
  2163. }
  2164. case 74:
  2165. case 78:
  2166. turnPage = 1;
  2167. break;
  2168. case 36:
  2169. if (isViewerInPresentationMode || PDFViewerApplication.page > 1) {
  2170. PDFViewerApplication.page = 1;
  2171. handled = true;
  2172. ensureViewerFocused = true;
  2173. }
  2174. break;
  2175. case 35:
  2176. if (isViewerInPresentationMode || PDFViewerApplication.page < PDFViewerApplication.pagesCount) {
  2177. PDFViewerApplication.page = PDFViewerApplication.pagesCount;
  2178. handled = true;
  2179. ensureViewerFocused = true;
  2180. }
  2181. break;
  2182. case 83:
  2183. PDFViewerApplication.pdfCursorTools.switchTool(_pdf_cursor_tools.CursorTool.SELECT);
  2184. break;
  2185. case 72:
  2186. PDFViewerApplication.pdfCursorTools.switchTool(_pdf_cursor_tools.CursorTool.HAND);
  2187. break;
  2188. case 82:
  2189. PDFViewerApplication.rotatePages(90);
  2190. break;
  2191. case 115:
  2192. PDFViewerApplication.pdfSidebar.toggle();
  2193. break;
  2194. }
  2195. if (turnPage !== 0 && (!turnOnlyIfPageFit || pdfViewer.currentScaleValue === 'page-fit')) {
  2196. if (turnPage > 0) {
  2197. if (PDFViewerApplication.page < PDFViewerApplication.pagesCount) {
  2198. PDFViewerApplication.page++;
  2199. }
  2200. } else {
  2201. if (PDFViewerApplication.page > 1) {
  2202. PDFViewerApplication.page--;
  2203. }
  2204. }
  2205. handled = true;
  2206. }
  2207. }
  2208. if (cmd === 4) {
  2209. switch (evt.keyCode) {
  2210. case 13:
  2211. case 32:
  2212. if (!isViewerInPresentationMode && pdfViewer.currentScaleValue !== 'page-fit') {
  2213. break;
  2214. }
  2215. if (PDFViewerApplication.page > 1) {
  2216. PDFViewerApplication.page--;
  2217. }
  2218. handled = true;
  2219. break;
  2220. case 82:
  2221. PDFViewerApplication.rotatePages(-90);
  2222. break;
  2223. }
  2224. }
  2225. if (!handled && !isViewerInPresentationMode) {
  2226. if (evt.keyCode >= 33 && evt.keyCode <= 40 || evt.keyCode === 32 && curElementTagName !== 'BUTTON') {
  2227. ensureViewerFocused = true;
  2228. }
  2229. }
  2230. if (ensureViewerFocused && !pdfViewer.containsElement(curElement)) {
  2231. pdfViewer.focus();
  2232. }
  2233. if (handled) {
  2234. evt.preventDefault();
  2235. }
  2236. }
  2237. function apiPageLayoutToSpreadMode(layout) {
  2238. switch (layout) {
  2239. case 'SinglePage':
  2240. case 'OneColumn':
  2241. return _ui_utils.SpreadMode.NONE;
  2242. case 'TwoColumnLeft':
  2243. case 'TwoPageLeft':
  2244. return _ui_utils.SpreadMode.ODD;
  2245. case 'TwoColumnRight':
  2246. case 'TwoPageRight':
  2247. return _ui_utils.SpreadMode.EVEN;
  2248. }
  2249. return _ui_utils.SpreadMode.NONE;
  2250. }
  2251. function apiPageModeToSidebarView(mode) {
  2252. switch (mode) {
  2253. case 'UseNone':
  2254. return _pdf_sidebar.SidebarView.NONE;
  2255. case 'UseThumbs':
  2256. return _pdf_sidebar.SidebarView.THUMBS;
  2257. case 'UseOutlines':
  2258. return _pdf_sidebar.SidebarView.OUTLINE;
  2259. case 'UseAttachments':
  2260. return _pdf_sidebar.SidebarView.ATTACHMENTS;
  2261. case 'UseOC':
  2262. }
  2263. return _pdf_sidebar.SidebarView.NONE;
  2264. }
  2265. var PDFPrintServiceFactory = {
  2266. instance: {
  2267. supportsPrinting: false,
  2268. createPrintService: function createPrintService() {
  2269. throw new Error('Not implemented: createPrintService');
  2270. }
  2271. }
  2272. };
  2273. exports.PDFPrintServiceFactory = PDFPrintServiceFactory;
  2274. /***/ }),
  2275. /* 2 */
  2276. /***/ (function(module, exports, __webpack_require__) {
  2277. "use strict";
  2278. module.exports = __webpack_require__(3);
  2279. /***/ }),
  2280. /* 3 */
  2281. /***/ (function(module, exports, __webpack_require__) {
  2282. "use strict";
  2283. /* WEBPACK VAR INJECTION */(function(module) {
  2284. function _typeof(obj) { 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); }
  2285. var runtime = function (exports) {
  2286. "use strict";
  2287. var Op = Object.prototype;
  2288. var hasOwn = Op.hasOwnProperty;
  2289. var undefined;
  2290. var $Symbol = typeof Symbol === "function" ? Symbol : {};
  2291. var iteratorSymbol = $Symbol.iterator || "@@iterator";
  2292. var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator";
  2293. var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
  2294. function wrap(innerFn, outerFn, self, tryLocsList) {
  2295. var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator;
  2296. var generator = Object.create(protoGenerator.prototype);
  2297. var context = new Context(tryLocsList || []);
  2298. generator._invoke = makeInvokeMethod(innerFn, self, context);
  2299. return generator;
  2300. }
  2301. exports.wrap = wrap;
  2302. function tryCatch(fn, obj, arg) {
  2303. try {
  2304. return {
  2305. type: "normal",
  2306. arg: fn.call(obj, arg)
  2307. };
  2308. } catch (err) {
  2309. return {
  2310. type: "throw",
  2311. arg: err
  2312. };
  2313. }
  2314. }
  2315. var GenStateSuspendedStart = "suspendedStart";
  2316. var GenStateSuspendedYield = "suspendedYield";
  2317. var GenStateExecuting = "executing";
  2318. var GenStateCompleted = "completed";
  2319. var ContinueSentinel = {};
  2320. function Generator() {}
  2321. function GeneratorFunction() {}
  2322. function GeneratorFunctionPrototype() {}
  2323. var IteratorPrototype = {};
  2324. IteratorPrototype[iteratorSymbol] = function () {
  2325. return this;
  2326. };
  2327. var getProto = Object.getPrototypeOf;
  2328. var NativeIteratorPrototype = getProto && getProto(getProto(values([])));
  2329. if (NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) {
  2330. IteratorPrototype = NativeIteratorPrototype;
  2331. }
  2332. var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype);
  2333. GeneratorFunction.prototype = Gp.constructor = GeneratorFunctionPrototype;
  2334. GeneratorFunctionPrototype.constructor = GeneratorFunction;
  2335. GeneratorFunctionPrototype[toStringTagSymbol] = GeneratorFunction.displayName = "GeneratorFunction";
  2336. function defineIteratorMethods(prototype) {
  2337. ["next", "throw", "return"].forEach(function (method) {
  2338. prototype[method] = function (arg) {
  2339. return this._invoke(method, arg);
  2340. };
  2341. });
  2342. }
  2343. exports.isGeneratorFunction = function (genFun) {
  2344. var ctor = typeof genFun === "function" && genFun.constructor;
  2345. return ctor ? ctor === GeneratorFunction || (ctor.displayName || ctor.name) === "GeneratorFunction" : false;
  2346. };
  2347. exports.mark = function (genFun) {
  2348. if (Object.setPrototypeOf) {
  2349. Object.setPrototypeOf(genFun, GeneratorFunctionPrototype);
  2350. } else {
  2351. genFun.__proto__ = GeneratorFunctionPrototype;
  2352. if (!(toStringTagSymbol in genFun)) {
  2353. genFun[toStringTagSymbol] = "GeneratorFunction";
  2354. }
  2355. }
  2356. genFun.prototype = Object.create(Gp);
  2357. return genFun;
  2358. };
  2359. exports.awrap = function (arg) {
  2360. return {
  2361. __await: arg
  2362. };
  2363. };
  2364. function AsyncIterator(generator) {
  2365. function invoke(method, arg, resolve, reject) {
  2366. var record = tryCatch(generator[method], generator, arg);
  2367. if (record.type === "throw") {
  2368. reject(record.arg);
  2369. } else {
  2370. var result = record.arg;
  2371. var value = result.value;
  2372. if (value && _typeof(value) === "object" && hasOwn.call(value, "__await")) {
  2373. return Promise.resolve(value.__await).then(function (value) {
  2374. invoke("next", value, resolve, reject);
  2375. }, function (err) {
  2376. invoke("throw", err, resolve, reject);
  2377. });
  2378. }
  2379. return Promise.resolve(value).then(function (unwrapped) {
  2380. result.value = unwrapped;
  2381. resolve(result);
  2382. }, function (error) {
  2383. return invoke("throw", error, resolve, reject);
  2384. });
  2385. }
  2386. }
  2387. var previousPromise;
  2388. function enqueue(method, arg) {
  2389. function callInvokeWithMethodAndArg() {
  2390. return new Promise(function (resolve, reject) {
  2391. invoke(method, arg, resolve, reject);
  2392. });
  2393. }
  2394. return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
  2395. }
  2396. this._invoke = enqueue;
  2397. }
  2398. defineIteratorMethods(AsyncIterator.prototype);
  2399. AsyncIterator.prototype[asyncIteratorSymbol] = function () {
  2400. return this;
  2401. };
  2402. exports.AsyncIterator = AsyncIterator;
  2403. exports.async = function (innerFn, outerFn, self, tryLocsList) {
  2404. var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList));
  2405. return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) {
  2406. return result.done ? result.value : iter.next();
  2407. });
  2408. };
  2409. function makeInvokeMethod(innerFn, self, context) {
  2410. var state = GenStateSuspendedStart;
  2411. return function invoke(method, arg) {
  2412. if (state === GenStateExecuting) {
  2413. throw new Error("Generator is already running");
  2414. }
  2415. if (state === GenStateCompleted) {
  2416. if (method === "throw") {
  2417. throw arg;
  2418. }
  2419. return doneResult();
  2420. }
  2421. context.method = method;
  2422. context.arg = arg;
  2423. while (true) {
  2424. var delegate = context.delegate;
  2425. if (delegate) {
  2426. var delegateResult = maybeInvokeDelegate(delegate, context);
  2427. if (delegateResult) {
  2428. if (delegateResult === ContinueSentinel) continue;
  2429. return delegateResult;
  2430. }
  2431. }
  2432. if (context.method === "next") {
  2433. context.sent = context._sent = context.arg;
  2434. } else if (context.method === "throw") {
  2435. if (state === GenStateSuspendedStart) {
  2436. state = GenStateCompleted;
  2437. throw context.arg;
  2438. }
  2439. context.dispatchException(context.arg);
  2440. } else if (context.method === "return") {
  2441. context.abrupt("return", context.arg);
  2442. }
  2443. state = GenStateExecuting;
  2444. var record = tryCatch(innerFn, self, context);
  2445. if (record.type === "normal") {
  2446. state = context.done ? GenStateCompleted : GenStateSuspendedYield;
  2447. if (record.arg === ContinueSentinel) {
  2448. continue;
  2449. }
  2450. return {
  2451. value: record.arg,
  2452. done: context.done
  2453. };
  2454. } else if (record.type === "throw") {
  2455. state = GenStateCompleted;
  2456. context.method = "throw";
  2457. context.arg = record.arg;
  2458. }
  2459. }
  2460. };
  2461. }
  2462. function maybeInvokeDelegate(delegate, context) {
  2463. var method = delegate.iterator[context.method];
  2464. if (method === undefined) {
  2465. context.delegate = null;
  2466. if (context.method === "throw") {
  2467. if (delegate.iterator["return"]) {
  2468. context.method = "return";
  2469. context.arg = undefined;
  2470. maybeInvokeDelegate(delegate, context);
  2471. if (context.method === "throw") {
  2472. return ContinueSentinel;
  2473. }
  2474. }
  2475. context.method = "throw";
  2476. context.arg = new TypeError("The iterator does not provide a 'throw' method");
  2477. }
  2478. return ContinueSentinel;
  2479. }
  2480. var record = tryCatch(method, delegate.iterator, context.arg);
  2481. if (record.type === "throw") {
  2482. context.method = "throw";
  2483. context.arg = record.arg;
  2484. context.delegate = null;
  2485. return ContinueSentinel;
  2486. }
  2487. var info = record.arg;
  2488. if (!info) {
  2489. context.method = "throw";
  2490. context.arg = new TypeError("iterator result is not an object");
  2491. context.delegate = null;
  2492. return ContinueSentinel;
  2493. }
  2494. if (info.done) {
  2495. context[delegate.resultName] = info.value;
  2496. context.next = delegate.nextLoc;
  2497. if (context.method !== "return") {
  2498. context.method = "next";
  2499. context.arg = undefined;
  2500. }
  2501. } else {
  2502. return info;
  2503. }
  2504. context.delegate = null;
  2505. return ContinueSentinel;
  2506. }
  2507. defineIteratorMethods(Gp);
  2508. Gp[toStringTagSymbol] = "Generator";
  2509. Gp[iteratorSymbol] = function () {
  2510. return this;
  2511. };
  2512. Gp.toString = function () {
  2513. return "[object Generator]";
  2514. };
  2515. function pushTryEntry(locs) {
  2516. var entry = {
  2517. tryLoc: locs[0]
  2518. };
  2519. if (1 in locs) {
  2520. entry.catchLoc = locs[1];
  2521. }
  2522. if (2 in locs) {
  2523. entry.finallyLoc = locs[2];
  2524. entry.afterLoc = locs[3];
  2525. }
  2526. this.tryEntries.push(entry);
  2527. }
  2528. function resetTryEntry(entry) {
  2529. var record = entry.completion || {};
  2530. record.type = "normal";
  2531. delete record.arg;
  2532. entry.completion = record;
  2533. }
  2534. function Context(tryLocsList) {
  2535. this.tryEntries = [{
  2536. tryLoc: "root"
  2537. }];
  2538. tryLocsList.forEach(pushTryEntry, this);
  2539. this.reset(true);
  2540. }
  2541. exports.keys = function (object) {
  2542. var keys = [];
  2543. for (var key in object) {
  2544. keys.push(key);
  2545. }
  2546. keys.reverse();
  2547. return function next() {
  2548. while (keys.length) {
  2549. var key = keys.pop();
  2550. if (key in object) {
  2551. next.value = key;
  2552. next.done = false;
  2553. return next;
  2554. }
  2555. }
  2556. next.done = true;
  2557. return next;
  2558. };
  2559. };
  2560. function values(iterable) {
  2561. if (iterable) {
  2562. var iteratorMethod = iterable[iteratorSymbol];
  2563. if (iteratorMethod) {
  2564. return iteratorMethod.call(iterable);
  2565. }
  2566. if (typeof iterable.next === "function") {
  2567. return iterable;
  2568. }
  2569. if (!isNaN(iterable.length)) {
  2570. var i = -1,
  2571. next = function next() {
  2572. while (++i < iterable.length) {
  2573. if (hasOwn.call(iterable, i)) {
  2574. next.value = iterable[i];
  2575. next.done = false;
  2576. return next;
  2577. }
  2578. }
  2579. next.value = undefined;
  2580. next.done = true;
  2581. return next;
  2582. };
  2583. return next.next = next;
  2584. }
  2585. }
  2586. return {
  2587. next: doneResult
  2588. };
  2589. }
  2590. exports.values = values;
  2591. function doneResult() {
  2592. return {
  2593. value: undefined,
  2594. done: true
  2595. };
  2596. }
  2597. Context.prototype = {
  2598. constructor: Context,
  2599. reset: function reset(skipTempReset) {
  2600. this.prev = 0;
  2601. this.next = 0;
  2602. this.sent = this._sent = undefined;
  2603. this.done = false;
  2604. this.delegate = null;
  2605. this.method = "next";
  2606. this.arg = undefined;
  2607. this.tryEntries.forEach(resetTryEntry);
  2608. if (!skipTempReset) {
  2609. for (var name in this) {
  2610. if (name.charAt(0) === "t" && hasOwn.call(this, name) && !isNaN(+name.slice(1))) {
  2611. this[name] = undefined;
  2612. }
  2613. }
  2614. }
  2615. },
  2616. stop: function stop() {
  2617. this.done = true;
  2618. var rootEntry = this.tryEntries[0];
  2619. var rootRecord = rootEntry.completion;
  2620. if (rootRecord.type === "throw") {
  2621. throw rootRecord.arg;
  2622. }
  2623. return this.rval;
  2624. },
  2625. dispatchException: function dispatchException(exception) {
  2626. if (this.done) {
  2627. throw exception;
  2628. }
  2629. var context = this;
  2630. function handle(loc, caught) {
  2631. record.type = "throw";
  2632. record.arg = exception;
  2633. context.next = loc;
  2634. if (caught) {
  2635. context.method = "next";
  2636. context.arg = undefined;
  2637. }
  2638. return !!caught;
  2639. }
  2640. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  2641. var entry = this.tryEntries[i];
  2642. var record = entry.completion;
  2643. if (entry.tryLoc === "root") {
  2644. return handle("end");
  2645. }
  2646. if (entry.tryLoc <= this.prev) {
  2647. var hasCatch = hasOwn.call(entry, "catchLoc");
  2648. var hasFinally = hasOwn.call(entry, "finallyLoc");
  2649. if (hasCatch && hasFinally) {
  2650. if (this.prev < entry.catchLoc) {
  2651. return handle(entry.catchLoc, true);
  2652. } else if (this.prev < entry.finallyLoc) {
  2653. return handle(entry.finallyLoc);
  2654. }
  2655. } else if (hasCatch) {
  2656. if (this.prev < entry.catchLoc) {
  2657. return handle(entry.catchLoc, true);
  2658. }
  2659. } else if (hasFinally) {
  2660. if (this.prev < entry.finallyLoc) {
  2661. return handle(entry.finallyLoc);
  2662. }
  2663. } else {
  2664. throw new Error("try statement without catch or finally");
  2665. }
  2666. }
  2667. }
  2668. },
  2669. abrupt: function abrupt(type, arg) {
  2670. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  2671. var entry = this.tryEntries[i];
  2672. if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
  2673. var finallyEntry = entry;
  2674. break;
  2675. }
  2676. }
  2677. if (finallyEntry && (type === "break" || type === "continue") && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc) {
  2678. finallyEntry = null;
  2679. }
  2680. var record = finallyEntry ? finallyEntry.completion : {};
  2681. record.type = type;
  2682. record.arg = arg;
  2683. if (finallyEntry) {
  2684. this.method = "next";
  2685. this.next = finallyEntry.finallyLoc;
  2686. return ContinueSentinel;
  2687. }
  2688. return this.complete(record);
  2689. },
  2690. complete: function complete(record, afterLoc) {
  2691. if (record.type === "throw") {
  2692. throw record.arg;
  2693. }
  2694. if (record.type === "break" || record.type === "continue") {
  2695. this.next = record.arg;
  2696. } else if (record.type === "return") {
  2697. this.rval = this.arg = record.arg;
  2698. this.method = "return";
  2699. this.next = "end";
  2700. } else if (record.type === "normal" && afterLoc) {
  2701. this.next = afterLoc;
  2702. }
  2703. return ContinueSentinel;
  2704. },
  2705. finish: function finish(finallyLoc) {
  2706. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  2707. var entry = this.tryEntries[i];
  2708. if (entry.finallyLoc === finallyLoc) {
  2709. this.complete(entry.completion, entry.afterLoc);
  2710. resetTryEntry(entry);
  2711. return ContinueSentinel;
  2712. }
  2713. }
  2714. },
  2715. "catch": function _catch(tryLoc) {
  2716. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  2717. var entry = this.tryEntries[i];
  2718. if (entry.tryLoc === tryLoc) {
  2719. var record = entry.completion;
  2720. if (record.type === "throw") {
  2721. var thrown = record.arg;
  2722. resetTryEntry(entry);
  2723. }
  2724. return thrown;
  2725. }
  2726. }
  2727. throw new Error("illegal catch attempt");
  2728. },
  2729. delegateYield: function delegateYield(iterable, resultName, nextLoc) {
  2730. this.delegate = {
  2731. iterator: values(iterable),
  2732. resultName: resultName,
  2733. nextLoc: nextLoc
  2734. };
  2735. if (this.method === "next") {
  2736. this.arg = undefined;
  2737. }
  2738. return ContinueSentinel;
  2739. }
  2740. };
  2741. return exports;
  2742. }(( false ? undefined : _typeof(module)) === "object" ? module.exports : {});
  2743. try {
  2744. regeneratorRuntime = runtime;
  2745. } catch (accidentalStrictMode) {
  2746. Function("r", "regeneratorRuntime = r")(runtime);
  2747. }
  2748. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(4)(module)))
  2749. /***/ }),
  2750. /* 4 */
  2751. /***/ (function(module, exports, __webpack_require__) {
  2752. "use strict";
  2753. module.exports = function (module) {
  2754. if (!module.webpackPolyfill) {
  2755. module.deprecate = function () {};
  2756. module.paths = [];
  2757. if (!module.children) module.children = [];
  2758. Object.defineProperty(module, "loaded", {
  2759. enumerable: true,
  2760. get: function get() {
  2761. return module.l;
  2762. }
  2763. });
  2764. Object.defineProperty(module, "id", {
  2765. enumerable: true,
  2766. get: function get() {
  2767. return module.i;
  2768. }
  2769. });
  2770. module.webpackPolyfill = 1;
  2771. }
  2772. return module;
  2773. };
  2774. /***/ }),
  2775. /* 5 */
  2776. /***/ (function(module, exports, __webpack_require__) {
  2777. "use strict";
  2778. Object.defineProperty(exports, "__esModule", {
  2779. value: true
  2780. });
  2781. exports.isValidRotation = isValidRotation;
  2782. exports.isValidScrollMode = isValidScrollMode;
  2783. exports.isValidSpreadMode = isValidSpreadMode;
  2784. exports.isPortraitOrientation = isPortraitOrientation;
  2785. exports.getGlobalEventBus = getGlobalEventBus;
  2786. exports.getPDFFileNameFromURL = getPDFFileNameFromURL;
  2787. exports.noContextMenuHandler = noContextMenuHandler;
  2788. exports.parseQueryString = parseQueryString;
  2789. exports.backtrackBeforeAllVisibleElements = backtrackBeforeAllVisibleElements;
  2790. exports.getVisibleElements = getVisibleElements;
  2791. exports.roundToDivide = roundToDivide;
  2792. exports.getPageSizeInches = getPageSizeInches;
  2793. exports.approximateFraction = approximateFraction;
  2794. exports.getOutputScale = getOutputScale;
  2795. exports.scrollIntoView = scrollIntoView;
  2796. exports.watchScroll = watchScroll;
  2797. exports.binarySearchFirstItem = binarySearchFirstItem;
  2798. exports.normalizeWheelEventDelta = normalizeWheelEventDelta;
  2799. exports.waitOnEventOrTimeout = waitOnEventOrTimeout;
  2800. exports.moveToEndOfArray = moveToEndOfArray;
  2801. 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 = void 0;
  2802. var _regenerator = _interopRequireDefault(__webpack_require__(2));
  2803. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  2804. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  2805. 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); } }
  2806. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  2807. function _typeof(obj) { 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); }
  2808. function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); }
  2809. function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance"); }
  2810. function _iterableToArrayLimit(arr, i) { if (!(Symbol.iterator in Object(arr) || Object.prototype.toString.call(arr) === "[object Arguments]")) { 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; }
  2811. function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
  2812. 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); } }
  2813. 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); }); }; }
  2814. var CSS_UNITS = 96.0 / 72.0;
  2815. exports.CSS_UNITS = CSS_UNITS;
  2816. var DEFAULT_SCALE_VALUE = 'auto';
  2817. exports.DEFAULT_SCALE_VALUE = DEFAULT_SCALE_VALUE;
  2818. var DEFAULT_SCALE = 1.0;
  2819. exports.DEFAULT_SCALE = DEFAULT_SCALE;
  2820. var MIN_SCALE = 0.10;
  2821. exports.MIN_SCALE = MIN_SCALE;
  2822. var MAX_SCALE = 10.0;
  2823. exports.MAX_SCALE = MAX_SCALE;
  2824. var UNKNOWN_SCALE = 0;
  2825. exports.UNKNOWN_SCALE = UNKNOWN_SCALE;
  2826. var MAX_AUTO_SCALE = 1.25;
  2827. exports.MAX_AUTO_SCALE = MAX_AUTO_SCALE;
  2828. var SCROLLBAR_PADDING = 40;
  2829. exports.SCROLLBAR_PADDING = SCROLLBAR_PADDING;
  2830. var VERTICAL_PADDING = 5;
  2831. exports.VERTICAL_PADDING = VERTICAL_PADDING;
  2832. var PresentationModeState = {
  2833. UNKNOWN: 0,
  2834. NORMAL: 1,
  2835. CHANGING: 2,
  2836. FULLSCREEN: 3
  2837. };
  2838. exports.PresentationModeState = PresentationModeState;
  2839. var RendererType = {
  2840. CANVAS: 'canvas',
  2841. SVG: 'svg'
  2842. };
  2843. exports.RendererType = RendererType;
  2844. var TextLayerMode = {
  2845. DISABLE: 0,
  2846. ENABLE: 1,
  2847. ENABLE_ENHANCE: 2
  2848. };
  2849. exports.TextLayerMode = TextLayerMode;
  2850. var ScrollMode = {
  2851. UNKNOWN: -1,
  2852. VERTICAL: 0,
  2853. HORIZONTAL: 1,
  2854. WRAPPED: 2
  2855. };
  2856. exports.ScrollMode = ScrollMode;
  2857. var SpreadMode = {
  2858. UNKNOWN: -1,
  2859. NONE: 0,
  2860. ODD: 1,
  2861. EVEN: 2
  2862. };
  2863. exports.SpreadMode = SpreadMode;
  2864. function formatL10nValue(text, args) {
  2865. if (!args) {
  2866. return text;
  2867. }
  2868. return text.replace(/\{\{\s*(\w+)\s*\}\}/g, function (all, name) {
  2869. return name in args ? args[name] : '{{' + name + '}}';
  2870. });
  2871. }
  2872. var NullL10n = {
  2873. getLanguage: function () {
  2874. var _getLanguage = _asyncToGenerator(
  2875. /*#__PURE__*/
  2876. _regenerator["default"].mark(function _callee() {
  2877. return _regenerator["default"].wrap(function _callee$(_context) {
  2878. while (1) {
  2879. switch (_context.prev = _context.next) {
  2880. case 0:
  2881. return _context.abrupt("return", 'en-us');
  2882. case 1:
  2883. case "end":
  2884. return _context.stop();
  2885. }
  2886. }
  2887. }, _callee);
  2888. }));
  2889. function getLanguage() {
  2890. return _getLanguage.apply(this, arguments);
  2891. }
  2892. return getLanguage;
  2893. }(),
  2894. getDirection: function () {
  2895. var _getDirection = _asyncToGenerator(
  2896. /*#__PURE__*/
  2897. _regenerator["default"].mark(function _callee2() {
  2898. return _regenerator["default"].wrap(function _callee2$(_context2) {
  2899. while (1) {
  2900. switch (_context2.prev = _context2.next) {
  2901. case 0:
  2902. return _context2.abrupt("return", 'ltr');
  2903. case 1:
  2904. case "end":
  2905. return _context2.stop();
  2906. }
  2907. }
  2908. }, _callee2);
  2909. }));
  2910. function getDirection() {
  2911. return _getDirection.apply(this, arguments);
  2912. }
  2913. return getDirection;
  2914. }(),
  2915. get: function () {
  2916. var _get = _asyncToGenerator(
  2917. /*#__PURE__*/
  2918. _regenerator["default"].mark(function _callee3(property, args, fallback) {
  2919. return _regenerator["default"].wrap(function _callee3$(_context3) {
  2920. while (1) {
  2921. switch (_context3.prev = _context3.next) {
  2922. case 0:
  2923. return _context3.abrupt("return", formatL10nValue(fallback, args));
  2924. case 1:
  2925. case "end":
  2926. return _context3.stop();
  2927. }
  2928. }
  2929. }, _callee3);
  2930. }));
  2931. function get(_x, _x2, _x3) {
  2932. return _get.apply(this, arguments);
  2933. }
  2934. return get;
  2935. }(),
  2936. translate: function () {
  2937. var _translate = _asyncToGenerator(
  2938. /*#__PURE__*/
  2939. _regenerator["default"].mark(function _callee4(element) {
  2940. return _regenerator["default"].wrap(function _callee4$(_context4) {
  2941. while (1) {
  2942. switch (_context4.prev = _context4.next) {
  2943. case 0:
  2944. case "end":
  2945. return _context4.stop();
  2946. }
  2947. }
  2948. }, _callee4);
  2949. }));
  2950. function translate(_x4) {
  2951. return _translate.apply(this, arguments);
  2952. }
  2953. return translate;
  2954. }()
  2955. };
  2956. exports.NullL10n = NullL10n;
  2957. function getOutputScale(ctx) {
  2958. var devicePixelRatio = window.devicePixelRatio || 1;
  2959. var backingStoreRatio = ctx.webkitBackingStorePixelRatio || ctx.mozBackingStorePixelRatio || ctx.msBackingStorePixelRatio || ctx.oBackingStorePixelRatio || ctx.backingStorePixelRatio || 1;
  2960. var pixelRatio = devicePixelRatio / backingStoreRatio;
  2961. return {
  2962. sx: pixelRatio,
  2963. sy: pixelRatio,
  2964. scaled: pixelRatio !== 1
  2965. };
  2966. }
  2967. function scrollIntoView(element, spot) {
  2968. var skipOverflowHiddenElements = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  2969. var parent = element.offsetParent;
  2970. if (!parent) {
  2971. console.error('offsetParent is not set -- cannot scroll');
  2972. return;
  2973. }
  2974. var offsetY = element.offsetTop + element.clientTop;
  2975. var offsetX = element.offsetLeft + element.clientLeft;
  2976. while (parent.clientHeight === parent.scrollHeight && parent.clientWidth === parent.scrollWidth || skipOverflowHiddenElements && getComputedStyle(parent).overflow === 'hidden') {
  2977. if (parent.dataset._scaleY) {
  2978. offsetY /= parent.dataset._scaleY;
  2979. offsetX /= parent.dataset._scaleX;
  2980. }
  2981. offsetY += parent.offsetTop;
  2982. offsetX += parent.offsetLeft;
  2983. parent = parent.offsetParent;
  2984. if (!parent) {
  2985. return;
  2986. }
  2987. }
  2988. if (spot) {
  2989. if (spot.top !== undefined) {
  2990. offsetY += spot.top;
  2991. }
  2992. if (spot.left !== undefined) {
  2993. offsetX += spot.left;
  2994. parent.scrollLeft = offsetX;
  2995. }
  2996. }
  2997. parent.scrollTop = offsetY;
  2998. }
  2999. function watchScroll(viewAreaElement, callback) {
  3000. var debounceScroll = function debounceScroll(evt) {
  3001. if (rAF) {
  3002. return;
  3003. }
  3004. rAF = window.requestAnimationFrame(function viewAreaElementScrolled() {
  3005. rAF = null;
  3006. var currentX = viewAreaElement.scrollLeft;
  3007. var lastX = state.lastX;
  3008. if (currentX !== lastX) {
  3009. state.right = currentX > lastX;
  3010. }
  3011. state.lastX = currentX;
  3012. var currentY = viewAreaElement.scrollTop;
  3013. var lastY = state.lastY;
  3014. if (currentY !== lastY) {
  3015. state.down = currentY > lastY;
  3016. }
  3017. state.lastY = currentY;
  3018. callback(state);
  3019. });
  3020. };
  3021. var state = {
  3022. right: true,
  3023. down: true,
  3024. lastX: viewAreaElement.scrollLeft,
  3025. lastY: viewAreaElement.scrollTop,
  3026. _eventHandler: debounceScroll
  3027. };
  3028. var rAF = null;
  3029. viewAreaElement.addEventListener('scroll', debounceScroll, true);
  3030. return state;
  3031. }
  3032. function parseQueryString(query) {
  3033. var parts = query.split('&');
  3034. var params = Object.create(null);
  3035. for (var i = 0, ii = parts.length; i < ii; ++i) {
  3036. var param = parts[i].split('=');
  3037. var key = param[0].toLowerCase();
  3038. var value = param.length > 1 ? param[1] : null;
  3039. params[decodeURIComponent(key)] = decodeURIComponent(value);
  3040. }
  3041. return params;
  3042. }
  3043. function binarySearchFirstItem(items, condition) {
  3044. var minIndex = 0;
  3045. var maxIndex = items.length - 1;
  3046. if (items.length === 0 || !condition(items[maxIndex])) {
  3047. return items.length;
  3048. }
  3049. if (condition(items[minIndex])) {
  3050. return minIndex;
  3051. }
  3052. while (minIndex < maxIndex) {
  3053. var currentIndex = minIndex + maxIndex >> 1;
  3054. var currentItem = items[currentIndex];
  3055. if (condition(currentItem)) {
  3056. maxIndex = currentIndex;
  3057. } else {
  3058. minIndex = currentIndex + 1;
  3059. }
  3060. }
  3061. return minIndex;
  3062. }
  3063. function approximateFraction(x) {
  3064. if (Math.floor(x) === x) {
  3065. return [x, 1];
  3066. }
  3067. var xinv = 1 / x;
  3068. var limit = 8;
  3069. if (xinv > limit) {
  3070. return [1, limit];
  3071. } else if (Math.floor(xinv) === xinv) {
  3072. return [1, xinv];
  3073. }
  3074. var x_ = x > 1 ? xinv : x;
  3075. var a = 0,
  3076. b = 1,
  3077. c = 1,
  3078. d = 1;
  3079. while (true) {
  3080. var p = a + c,
  3081. q = b + d;
  3082. if (q > limit) {
  3083. break;
  3084. }
  3085. if (x_ <= p / q) {
  3086. c = p;
  3087. d = q;
  3088. } else {
  3089. a = p;
  3090. b = q;
  3091. }
  3092. }
  3093. var result;
  3094. if (x_ - a / b < c / d - x_) {
  3095. result = x_ === x ? [a, b] : [b, a];
  3096. } else {
  3097. result = x_ === x ? [c, d] : [d, c];
  3098. }
  3099. return result;
  3100. }
  3101. function roundToDivide(x, div) {
  3102. var r = x % div;
  3103. return r === 0 ? x : Math.round(x - r + div);
  3104. }
  3105. function getPageSizeInches(_ref) {
  3106. var view = _ref.view,
  3107. userUnit = _ref.userUnit,
  3108. rotate = _ref.rotate;
  3109. var _view = _slicedToArray(view, 4),
  3110. x1 = _view[0],
  3111. y1 = _view[1],
  3112. x2 = _view[2],
  3113. y2 = _view[3];
  3114. var changeOrientation = rotate % 180 !== 0;
  3115. var width = (x2 - x1) / 72 * userUnit;
  3116. var height = (y2 - y1) / 72 * userUnit;
  3117. return {
  3118. width: changeOrientation ? height : width,
  3119. height: changeOrientation ? width : height
  3120. };
  3121. }
  3122. function backtrackBeforeAllVisibleElements(index, views, top) {
  3123. if (index < 2) {
  3124. return index;
  3125. }
  3126. var elt = views[index].div;
  3127. var pageTop = elt.offsetTop + elt.clientTop;
  3128. if (pageTop >= top) {
  3129. elt = views[index - 1].div;
  3130. pageTop = elt.offsetTop + elt.clientTop;
  3131. }
  3132. for (var i = index - 2; i >= 0; --i) {
  3133. elt = views[i].div;
  3134. if (elt.offsetTop + elt.clientTop + elt.clientHeight <= pageTop) {
  3135. break;
  3136. }
  3137. index = i;
  3138. }
  3139. return index;
  3140. }
  3141. function getVisibleElements(scrollEl, views) {
  3142. var sortByVisibility = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  3143. var horizontal = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
  3144. var top = scrollEl.scrollTop,
  3145. bottom = top + scrollEl.clientHeight;
  3146. var left = scrollEl.scrollLeft,
  3147. right = left + scrollEl.clientWidth;
  3148. function isElementBottomAfterViewTop(view) {
  3149. var element = view.div;
  3150. var elementBottom = element.offsetTop + element.clientTop + element.clientHeight;
  3151. return elementBottom > top;
  3152. }
  3153. function isElementRightAfterViewLeft(view) {
  3154. var element = view.div;
  3155. var elementRight = element.offsetLeft + element.clientLeft + element.clientWidth;
  3156. return elementRight > left;
  3157. }
  3158. var visible = [],
  3159. numViews = views.length;
  3160. var firstVisibleElementInd = numViews === 0 ? 0 : binarySearchFirstItem(views, horizontal ? isElementRightAfterViewLeft : isElementBottomAfterViewTop);
  3161. if (firstVisibleElementInd > 0 && firstVisibleElementInd < numViews && !horizontal) {
  3162. firstVisibleElementInd = backtrackBeforeAllVisibleElements(firstVisibleElementInd, views, top);
  3163. }
  3164. var lastEdge = horizontal ? right : -1;
  3165. for (var i = firstVisibleElementInd; i < numViews; i++) {
  3166. var view = views[i],
  3167. element = view.div;
  3168. var currentWidth = element.offsetLeft + element.clientLeft;
  3169. var currentHeight = element.offsetTop + element.clientTop;
  3170. var viewWidth = element.clientWidth,
  3171. viewHeight = element.clientHeight;
  3172. var viewRight = currentWidth + viewWidth;
  3173. var viewBottom = currentHeight + viewHeight;
  3174. if (lastEdge === -1) {
  3175. if (viewBottom >= bottom) {
  3176. lastEdge = viewBottom;
  3177. }
  3178. } else if ((horizontal ? currentWidth : currentHeight) > lastEdge) {
  3179. break;
  3180. }
  3181. if (viewBottom <= top || currentHeight >= bottom || viewRight <= left || currentWidth >= right) {
  3182. continue;
  3183. }
  3184. var hiddenHeight = Math.max(0, top - currentHeight) + Math.max(0, viewBottom - bottom);
  3185. var hiddenWidth = Math.max(0, left - currentWidth) + Math.max(0, viewRight - right);
  3186. var percent = (viewHeight - hiddenHeight) * (viewWidth - hiddenWidth) * 100 / viewHeight / viewWidth | 0;
  3187. visible.push({
  3188. id: view.id,
  3189. x: currentWidth,
  3190. y: currentHeight,
  3191. view: view,
  3192. percent: percent
  3193. });
  3194. }
  3195. var first = visible[0],
  3196. last = visible[visible.length - 1];
  3197. if (sortByVisibility) {
  3198. visible.sort(function (a, b) {
  3199. var pc = a.percent - b.percent;
  3200. if (Math.abs(pc) > 0.001) {
  3201. return -pc;
  3202. }
  3203. return a.id - b.id;
  3204. });
  3205. }
  3206. return {
  3207. first: first,
  3208. last: last,
  3209. views: visible
  3210. };
  3211. }
  3212. function noContextMenuHandler(evt) {
  3213. evt.preventDefault();
  3214. }
  3215. function isDataSchema(url) {
  3216. var i = 0,
  3217. ii = url.length;
  3218. while (i < ii && url[i].trim() === '') {
  3219. i++;
  3220. }
  3221. return url.substring(i, i + 5).toLowerCase() === 'data:';
  3222. }
  3223. function getPDFFileNameFromURL(url) {
  3224. var defaultFilename = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'document.pdf';
  3225. if (typeof url !== 'string') {
  3226. return defaultFilename;
  3227. }
  3228. if (isDataSchema(url)) {
  3229. console.warn('getPDFFileNameFromURL: ' + 'ignoring "data:" URL for performance reasons.');
  3230. return defaultFilename;
  3231. }
  3232. var reURI = /^(?:(?:[^:]+:)?\/\/[^\/]+)?([^?#]*)(\?[^#]*)?(#.*)?$/;
  3233. var reFilename = /[^\/?#=]+\.pdf\b(?!.*\.pdf\b)/i;
  3234. var splitURI = reURI.exec(url);
  3235. var suggestedFilename = reFilename.exec(splitURI[1]) || reFilename.exec(splitURI[2]) || reFilename.exec(splitURI[3]);
  3236. if (suggestedFilename) {
  3237. suggestedFilename = suggestedFilename[0];
  3238. if (suggestedFilename.includes('%')) {
  3239. try {
  3240. suggestedFilename = reFilename.exec(decodeURIComponent(suggestedFilename))[0];
  3241. } catch (ex) {}
  3242. }
  3243. }
  3244. return suggestedFilename || defaultFilename;
  3245. }
  3246. function normalizeWheelEventDelta(evt) {
  3247. var delta = Math.sqrt(evt.deltaX * evt.deltaX + evt.deltaY * evt.deltaY);
  3248. var angle = Math.atan2(evt.deltaY, evt.deltaX);
  3249. if (-0.25 * Math.PI < angle && angle < 0.75 * Math.PI) {
  3250. delta = -delta;
  3251. }
  3252. var MOUSE_DOM_DELTA_PIXEL_MODE = 0;
  3253. var MOUSE_DOM_DELTA_LINE_MODE = 1;
  3254. var MOUSE_PIXELS_PER_LINE = 30;
  3255. var MOUSE_LINES_PER_PAGE = 30;
  3256. if (evt.deltaMode === MOUSE_DOM_DELTA_PIXEL_MODE) {
  3257. delta /= MOUSE_PIXELS_PER_LINE * MOUSE_LINES_PER_PAGE;
  3258. } else if (evt.deltaMode === MOUSE_DOM_DELTA_LINE_MODE) {
  3259. delta /= MOUSE_LINES_PER_PAGE;
  3260. }
  3261. return delta;
  3262. }
  3263. function isValidRotation(angle) {
  3264. return Number.isInteger(angle) && angle % 90 === 0;
  3265. }
  3266. function isValidScrollMode(mode) {
  3267. return Number.isInteger(mode) && Object.values(ScrollMode).includes(mode) && mode !== ScrollMode.UNKNOWN;
  3268. }
  3269. function isValidSpreadMode(mode) {
  3270. return Number.isInteger(mode) && Object.values(SpreadMode).includes(mode) && mode !== SpreadMode.UNKNOWN;
  3271. }
  3272. function isPortraitOrientation(size) {
  3273. return size.width <= size.height;
  3274. }
  3275. var WaitOnType = {
  3276. EVENT: 'event',
  3277. TIMEOUT: 'timeout'
  3278. };
  3279. exports.WaitOnType = WaitOnType;
  3280. function waitOnEventOrTimeout(_ref2) {
  3281. var target = _ref2.target,
  3282. name = _ref2.name,
  3283. _ref2$delay = _ref2.delay,
  3284. delay = _ref2$delay === void 0 ? 0 : _ref2$delay;
  3285. return new Promise(function (resolve, reject) {
  3286. if (_typeof(target) !== 'object' || !(name && typeof name === 'string') || !(Number.isInteger(delay) && delay >= 0)) {
  3287. throw new Error('waitOnEventOrTimeout - invalid parameters.');
  3288. }
  3289. function handler(type) {
  3290. if (target instanceof EventBus) {
  3291. target.off(name, eventHandler);
  3292. } else {
  3293. target.removeEventListener(name, eventHandler);
  3294. }
  3295. if (timeout) {
  3296. clearTimeout(timeout);
  3297. }
  3298. resolve(type);
  3299. }
  3300. var eventHandler = handler.bind(null, WaitOnType.EVENT);
  3301. if (target instanceof EventBus) {
  3302. target.on(name, eventHandler);
  3303. } else {
  3304. target.addEventListener(name, eventHandler);
  3305. }
  3306. var timeoutHandler = handler.bind(null, WaitOnType.TIMEOUT);
  3307. var timeout = setTimeout(timeoutHandler, delay);
  3308. });
  3309. }
  3310. var animationStarted = new Promise(function (resolve) {
  3311. window.requestAnimationFrame(resolve);
  3312. });
  3313. exports.animationStarted = animationStarted;
  3314. var EventBus =
  3315. /*#__PURE__*/
  3316. function () {
  3317. function EventBus() {
  3318. var _ref3 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
  3319. _ref3$dispatchToDOM = _ref3.dispatchToDOM,
  3320. dispatchToDOM = _ref3$dispatchToDOM === void 0 ? false : _ref3$dispatchToDOM;
  3321. _classCallCheck(this, EventBus);
  3322. this._listeners = Object.create(null);
  3323. this._dispatchToDOM = dispatchToDOM === true;
  3324. }
  3325. _createClass(EventBus, [{
  3326. key: "on",
  3327. value: function on(eventName, listener) {
  3328. var eventListeners = this._listeners[eventName];
  3329. if (!eventListeners) {
  3330. eventListeners = [];
  3331. this._listeners[eventName] = eventListeners;
  3332. }
  3333. eventListeners.push(listener);
  3334. }
  3335. }, {
  3336. key: "off",
  3337. value: function off(eventName, listener) {
  3338. var eventListeners = this._listeners[eventName];
  3339. var i;
  3340. if (!eventListeners || (i = eventListeners.indexOf(listener)) < 0) {
  3341. return;
  3342. }
  3343. eventListeners.splice(i, 1);
  3344. }
  3345. }, {
  3346. key: "dispatch",
  3347. value: function dispatch(eventName) {
  3348. var eventListeners = this._listeners[eventName];
  3349. if (!eventListeners || eventListeners.length === 0) {
  3350. if (this._dispatchToDOM) {
  3351. var _args5 = Array.prototype.slice.call(arguments, 1);
  3352. this._dispatchDOMEvent(eventName, _args5);
  3353. }
  3354. return;
  3355. }
  3356. var args = Array.prototype.slice.call(arguments, 1);
  3357. eventListeners.slice(0).forEach(function (listener) {
  3358. listener.apply(null, args);
  3359. });
  3360. if (this._dispatchToDOM) {
  3361. this._dispatchDOMEvent(eventName, args);
  3362. }
  3363. }
  3364. }, {
  3365. key: "_dispatchDOMEvent",
  3366. value: function _dispatchDOMEvent(eventName) {
  3367. var args = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  3368. var details = Object.create(null);
  3369. if (args && args.length > 0) {
  3370. var obj = args[0];
  3371. for (var key in obj) {
  3372. var value = obj[key];
  3373. if (key === 'source') {
  3374. if (value === window || value === document) {
  3375. return;
  3376. }
  3377. continue;
  3378. }
  3379. details[key] = value;
  3380. }
  3381. }
  3382. var event = document.createEvent('CustomEvent');
  3383. event.initCustomEvent(eventName, true, true, details);
  3384. document.dispatchEvent(event);
  3385. }
  3386. }]);
  3387. return EventBus;
  3388. }();
  3389. exports.EventBus = EventBus;
  3390. var globalEventBus = null;
  3391. function getGlobalEventBus() {
  3392. var dispatchToDOM = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  3393. if (!globalEventBus) {
  3394. globalEventBus = new EventBus({
  3395. dispatchToDOM: dispatchToDOM
  3396. });
  3397. }
  3398. return globalEventBus;
  3399. }
  3400. function clamp(v, min, max) {
  3401. return Math.min(Math.max(v, min), max);
  3402. }
  3403. var ProgressBar =
  3404. /*#__PURE__*/
  3405. function () {
  3406. function ProgressBar(id) {
  3407. var _ref4 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
  3408. height = _ref4.height,
  3409. width = _ref4.width,
  3410. units = _ref4.units;
  3411. _classCallCheck(this, ProgressBar);
  3412. this.visible = true;
  3413. this.div = document.querySelector(id + ' .progress');
  3414. this.bar = this.div.parentNode;
  3415. this.height = height || 100;
  3416. this.width = width || 100;
  3417. this.units = units || '%';
  3418. this.div.style.height = this.height + this.units;
  3419. this.percent = 0;
  3420. }
  3421. _createClass(ProgressBar, [{
  3422. key: "_updateBar",
  3423. value: function _updateBar() {
  3424. if (this._indeterminate) {
  3425. this.div.classList.add('indeterminate');
  3426. this.div.style.width = this.width + this.units;
  3427. return;
  3428. }
  3429. this.div.classList.remove('indeterminate');
  3430. var progressSize = this.width * this._percent / 100;
  3431. this.div.style.width = progressSize + this.units;
  3432. }
  3433. }, {
  3434. key: "setWidth",
  3435. value: function setWidth(viewer) {
  3436. if (!viewer) {
  3437. return;
  3438. }
  3439. var container = viewer.parentNode;
  3440. var scrollbarWidth = container.offsetWidth - viewer.offsetWidth;
  3441. if (scrollbarWidth > 0) {
  3442. this.bar.setAttribute('style', 'width: calc(100% - ' + scrollbarWidth + 'px);');
  3443. }
  3444. }
  3445. }, {
  3446. key: "hide",
  3447. value: function hide() {
  3448. if (!this.visible) {
  3449. return;
  3450. }
  3451. this.visible = false;
  3452. this.bar.classList.add('hidden');
  3453. document.body.classList.remove('loadingInProgress');
  3454. }
  3455. }, {
  3456. key: "show",
  3457. value: function show() {
  3458. if (this.visible) {
  3459. return;
  3460. }
  3461. this.visible = true;
  3462. document.body.classList.add('loadingInProgress');
  3463. this.bar.classList.remove('hidden');
  3464. }
  3465. }, {
  3466. key: "percent",
  3467. get: function get() {
  3468. return this._percent;
  3469. },
  3470. set: function set(val) {
  3471. this._indeterminate = isNaN(val);
  3472. this._percent = clamp(val, 0, 100);
  3473. this._updateBar();
  3474. }
  3475. }]);
  3476. return ProgressBar;
  3477. }();
  3478. exports.ProgressBar = ProgressBar;
  3479. function moveToEndOfArray(arr, condition) {
  3480. var moved = [],
  3481. len = arr.length;
  3482. var write = 0;
  3483. for (var read = 0; read < len; ++read) {
  3484. if (condition(arr[read])) {
  3485. moved.push(arr[read]);
  3486. } else {
  3487. arr[write] = arr[read];
  3488. ++write;
  3489. }
  3490. }
  3491. for (var _read = 0; write < len; ++_read, ++write) {
  3492. arr[write] = moved[_read];
  3493. }
  3494. }
  3495. /***/ }),
  3496. /* 6 */
  3497. /***/ (function(module, exports, __webpack_require__) {
  3498. "use strict";
  3499. Object.defineProperty(exports, "__esModule", {
  3500. value: true
  3501. });
  3502. exports.OptionKind = exports.AppOptions = void 0;
  3503. var _pdfjsLib = __webpack_require__(7);
  3504. var _viewer_compatibility = __webpack_require__(8);
  3505. function _typeof(obj) { 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); }
  3506. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  3507. 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); } }
  3508. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  3509. var OptionKind = {
  3510. VIEWER: 0x02,
  3511. API: 0x04,
  3512. WORKER: 0x08,
  3513. PREFERENCE: 0x80
  3514. };
  3515. exports.OptionKind = OptionKind;
  3516. var defaultOptions = {
  3517. cursorToolOnLoad: {
  3518. value: 0,
  3519. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  3520. },
  3521. defaultUrl: {
  3522. value: 'compressed.tracemonkey-pldi-09.pdf',
  3523. kind: OptionKind.VIEWER
  3524. },
  3525. defaultZoomValue: {
  3526. value: '',
  3527. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  3528. },
  3529. disableHistory: {
  3530. value: false,
  3531. kind: OptionKind.VIEWER
  3532. },
  3533. disablePageLabels: {
  3534. value: false,
  3535. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  3536. },
  3537. enablePrintAutoRotate: {
  3538. value: false,
  3539. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  3540. },
  3541. enableWebGL: {
  3542. value: false,
  3543. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  3544. },
  3545. eventBusDispatchToDOM: {
  3546. value: false,
  3547. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  3548. },
  3549. externalLinkRel: {
  3550. value: 'noopener noreferrer nofollow',
  3551. kind: OptionKind.VIEWER
  3552. },
  3553. externalLinkTarget: {
  3554. value: 0,
  3555. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  3556. },
  3557. historyUpdateUrl: {
  3558. value: false,
  3559. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  3560. },
  3561. imageResourcesPath: {
  3562. value: './images/',
  3563. kind: OptionKind.VIEWER
  3564. },
  3565. maxCanvasPixels: {
  3566. value: 16777216,
  3567. compatibility: _viewer_compatibility.viewerCompatibilityParams.maxCanvasPixels,
  3568. kind: OptionKind.VIEWER
  3569. },
  3570. pdfBugEnabled: {
  3571. value: false,
  3572. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  3573. },
  3574. renderer: {
  3575. value: 'canvas',
  3576. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  3577. },
  3578. renderInteractiveForms: {
  3579. value: false,
  3580. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  3581. },
  3582. sidebarViewOnLoad: {
  3583. value: -1,
  3584. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  3585. },
  3586. scrollModeOnLoad: {
  3587. value: -1,
  3588. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  3589. },
  3590. spreadModeOnLoad: {
  3591. value: -1,
  3592. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  3593. },
  3594. textLayerMode: {
  3595. value: 1,
  3596. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  3597. },
  3598. useOnlyCssZoom: {
  3599. value: false,
  3600. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  3601. },
  3602. viewOnLoad: {
  3603. value: 0,
  3604. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  3605. },
  3606. cMapPacked: {
  3607. value: true,
  3608. kind: OptionKind.API
  3609. },
  3610. cMapUrl: {
  3611. value: '../web/cmaps/',
  3612. kind: OptionKind.API
  3613. },
  3614. disableAutoFetch: {
  3615. value: false,
  3616. kind: OptionKind.API + OptionKind.PREFERENCE
  3617. },
  3618. disableCreateObjectURL: {
  3619. value: false,
  3620. compatibility: _pdfjsLib.apiCompatibilityParams.disableCreateObjectURL,
  3621. kind: OptionKind.API
  3622. },
  3623. disableFontFace: {
  3624. value: false,
  3625. kind: OptionKind.API + OptionKind.PREFERENCE
  3626. },
  3627. disableRange: {
  3628. value: false,
  3629. kind: OptionKind.API + OptionKind.PREFERENCE
  3630. },
  3631. disableStream: {
  3632. value: false,
  3633. kind: OptionKind.API + OptionKind.PREFERENCE
  3634. },
  3635. docBaseUrl: {
  3636. value: '',
  3637. kind: OptionKind.API
  3638. },
  3639. isEvalSupported: {
  3640. value: true,
  3641. kind: OptionKind.API
  3642. },
  3643. maxImageSize: {
  3644. value: -1,
  3645. kind: OptionKind.API
  3646. },
  3647. pdfBug: {
  3648. value: false,
  3649. kind: OptionKind.API
  3650. },
  3651. verbosity: {
  3652. value: 1,
  3653. kind: OptionKind.API
  3654. },
  3655. workerPort: {
  3656. value: null,
  3657. kind: OptionKind.WORKER
  3658. },
  3659. workerSrc: {
  3660. value: '../build/pdf.worker.js',
  3661. kind: OptionKind.WORKER
  3662. }
  3663. };
  3664. {
  3665. defaultOptions.disablePreferences = {
  3666. value: false,
  3667. kind: OptionKind.VIEWER
  3668. };
  3669. defaultOptions.locale = {
  3670. value: typeof navigator !== 'undefined' ? navigator.language : 'en-US',
  3671. kind: OptionKind.VIEWER
  3672. };
  3673. defaultOptions.printResolution = {
  3674. value: 150,
  3675. kind: OptionKind.VIEWER
  3676. };
  3677. }
  3678. var userOptions = Object.create(null);
  3679. var AppOptions =
  3680. /*#__PURE__*/
  3681. function () {
  3682. function AppOptions() {
  3683. _classCallCheck(this, AppOptions);
  3684. throw new Error('Cannot initialize AppOptions.');
  3685. }
  3686. _createClass(AppOptions, null, [{
  3687. key: "get",
  3688. value: function get(name) {
  3689. var userOption = userOptions[name];
  3690. if (userOption !== undefined) {
  3691. return userOption;
  3692. }
  3693. var defaultOption = defaultOptions[name];
  3694. if (defaultOption !== undefined) {
  3695. return defaultOption.compatibility || defaultOption.value;
  3696. }
  3697. return undefined;
  3698. }
  3699. }, {
  3700. key: "getAll",
  3701. value: function getAll() {
  3702. var kind = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
  3703. var options = Object.create(null);
  3704. for (var name in defaultOptions) {
  3705. var defaultOption = defaultOptions[name];
  3706. if (kind) {
  3707. if ((kind & defaultOption.kind) === 0) {
  3708. continue;
  3709. }
  3710. if (kind === OptionKind.PREFERENCE) {
  3711. var value = defaultOption.value,
  3712. valueType = _typeof(value);
  3713. if (valueType === 'boolean' || valueType === 'string' || valueType === 'number' && Number.isInteger(value)) {
  3714. options[name] = value;
  3715. continue;
  3716. }
  3717. throw new Error("Invalid type for preference: ".concat(name));
  3718. }
  3719. }
  3720. var userOption = userOptions[name];
  3721. options[name] = userOption !== undefined ? userOption : defaultOption.compatibility || defaultOption.value;
  3722. }
  3723. return options;
  3724. }
  3725. }, {
  3726. key: "set",
  3727. value: function set(name, value) {
  3728. userOptions[name] = value;
  3729. }
  3730. }, {
  3731. key: "remove",
  3732. value: function remove(name) {
  3733. delete userOptions[name];
  3734. }
  3735. }]);
  3736. return AppOptions;
  3737. }();
  3738. exports.AppOptions = AppOptions;
  3739. /***/ }),
  3740. /* 7 */
  3741. /***/ (function(module, exports, __webpack_require__) {
  3742. "use strict";
  3743. var pdfjsLib;
  3744. if (typeof window !== 'undefined' && window['pdfjs-dist/build/pdf']) {
  3745. pdfjsLib = window['pdfjs-dist/build/pdf'];
  3746. } else {
  3747. pdfjsLib = require('../build/pdf.js');
  3748. }
  3749. module.exports = pdfjsLib;
  3750. /***/ }),
  3751. /* 8 */
  3752. /***/ (function(module, exports, __webpack_require__) {
  3753. "use strict";
  3754. var compatibilityParams = Object.create(null);
  3755. {
  3756. var userAgent = typeof navigator !== 'undefined' && navigator.userAgent || '';
  3757. var isAndroid = /Android/.test(userAgent);
  3758. var isIOS = /\b(iPad|iPhone|iPod)(?=;)/.test(userAgent);
  3759. (function checkCanvasSizeLimitation() {
  3760. if (isIOS || isAndroid) {
  3761. compatibilityParams.maxCanvasPixels = 5242880;
  3762. }
  3763. })();
  3764. }
  3765. exports.viewerCompatibilityParams = Object.freeze(compatibilityParams);
  3766. /***/ }),
  3767. /* 9 */
  3768. /***/ (function(module, exports, __webpack_require__) {
  3769. "use strict";
  3770. Object.defineProperty(exports, "__esModule", {
  3771. value: true
  3772. });
  3773. exports.PDFCursorTools = exports.CursorTool = void 0;
  3774. var _grab_to_pan = __webpack_require__(10);
  3775. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  3776. 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); } }
  3777. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  3778. var CursorTool = {
  3779. SELECT: 0,
  3780. HAND: 1,
  3781. ZOOM: 2
  3782. };
  3783. exports.CursorTool = CursorTool;
  3784. var PDFCursorTools =
  3785. /*#__PURE__*/
  3786. function () {
  3787. function PDFCursorTools(_ref) {
  3788. var _this = this;
  3789. var container = _ref.container,
  3790. eventBus = _ref.eventBus,
  3791. _ref$cursorToolOnLoad = _ref.cursorToolOnLoad,
  3792. cursorToolOnLoad = _ref$cursorToolOnLoad === void 0 ? CursorTool.SELECT : _ref$cursorToolOnLoad;
  3793. _classCallCheck(this, PDFCursorTools);
  3794. this.container = container;
  3795. this.eventBus = eventBus;
  3796. this.active = CursorTool.SELECT;
  3797. this.activeBeforePresentationMode = null;
  3798. this.handTool = new _grab_to_pan.GrabToPan({
  3799. element: this.container
  3800. });
  3801. this._addEventListeners();
  3802. Promise.resolve().then(function () {
  3803. _this.switchTool(cursorToolOnLoad);
  3804. });
  3805. }
  3806. _createClass(PDFCursorTools, [{
  3807. key: "switchTool",
  3808. value: function switchTool(tool) {
  3809. var _this2 = this;
  3810. if (this.activeBeforePresentationMode !== null) {
  3811. return;
  3812. }
  3813. if (tool === this.active) {
  3814. return;
  3815. }
  3816. var disableActiveTool = function disableActiveTool() {
  3817. switch (_this2.active) {
  3818. case CursorTool.SELECT:
  3819. break;
  3820. case CursorTool.HAND:
  3821. _this2.handTool.deactivate();
  3822. break;
  3823. case CursorTool.ZOOM:
  3824. }
  3825. };
  3826. switch (tool) {
  3827. case CursorTool.SELECT:
  3828. disableActiveTool();
  3829. break;
  3830. case CursorTool.HAND:
  3831. disableActiveTool();
  3832. this.handTool.activate();
  3833. break;
  3834. case CursorTool.ZOOM:
  3835. default:
  3836. console.error("switchTool: \"".concat(tool, "\" is an unsupported value."));
  3837. return;
  3838. }
  3839. this.active = tool;
  3840. this._dispatchEvent();
  3841. }
  3842. }, {
  3843. key: "_dispatchEvent",
  3844. value: function _dispatchEvent() {
  3845. this.eventBus.dispatch('cursortoolchanged', {
  3846. source: this,
  3847. tool: this.active
  3848. });
  3849. }
  3850. }, {
  3851. key: "_addEventListeners",
  3852. value: function _addEventListeners() {
  3853. var _this3 = this;
  3854. this.eventBus.on('switchcursortool', function (evt) {
  3855. _this3.switchTool(evt.tool);
  3856. });
  3857. this.eventBus.on('presentationmodechanged', function (evt) {
  3858. if (evt.switchInProgress) {
  3859. return;
  3860. }
  3861. var previouslyActive;
  3862. if (evt.active) {
  3863. previouslyActive = _this3.active;
  3864. _this3.switchTool(CursorTool.SELECT);
  3865. _this3.activeBeforePresentationMode = previouslyActive;
  3866. } else {
  3867. previouslyActive = _this3.activeBeforePresentationMode;
  3868. _this3.activeBeforePresentationMode = null;
  3869. _this3.switchTool(previouslyActive);
  3870. }
  3871. });
  3872. }
  3873. }, {
  3874. key: "activeTool",
  3875. get: function get() {
  3876. return this.active;
  3877. }
  3878. }]);
  3879. return PDFCursorTools;
  3880. }();
  3881. exports.PDFCursorTools = PDFCursorTools;
  3882. /***/ }),
  3883. /* 10 */
  3884. /***/ (function(module, exports, __webpack_require__) {
  3885. "use strict";
  3886. Object.defineProperty(exports, "__esModule", {
  3887. value: true
  3888. });
  3889. exports.GrabToPan = GrabToPan;
  3890. function GrabToPan(options) {
  3891. this.element = options.element;
  3892. this.document = options.element.ownerDocument;
  3893. if (typeof options.ignoreTarget === 'function') {
  3894. this.ignoreTarget = options.ignoreTarget;
  3895. }
  3896. this.onActiveChanged = options.onActiveChanged;
  3897. this.activate = this.activate.bind(this);
  3898. this.deactivate = this.deactivate.bind(this);
  3899. this.toggle = this.toggle.bind(this);
  3900. this._onmousedown = this._onmousedown.bind(this);
  3901. this._onmousemove = this._onmousemove.bind(this);
  3902. this._endPan = this._endPan.bind(this);
  3903. var overlay = this.overlay = document.createElement('div');
  3904. overlay.className = 'grab-to-pan-grabbing';
  3905. }
  3906. GrabToPan.prototype = {
  3907. CSS_CLASS_GRAB: 'grab-to-pan-grab',
  3908. activate: function GrabToPan_activate() {
  3909. if (!this.active) {
  3910. this.active = true;
  3911. this.element.addEventListener('mousedown', this._onmousedown, true);
  3912. this.element.classList.add(this.CSS_CLASS_GRAB);
  3913. if (this.onActiveChanged) {
  3914. this.onActiveChanged(true);
  3915. }
  3916. }
  3917. },
  3918. deactivate: function GrabToPan_deactivate() {
  3919. if (this.active) {
  3920. this.active = false;
  3921. this.element.removeEventListener('mousedown', this._onmousedown, true);
  3922. this._endPan();
  3923. this.element.classList.remove(this.CSS_CLASS_GRAB);
  3924. if (this.onActiveChanged) {
  3925. this.onActiveChanged(false);
  3926. }
  3927. }
  3928. },
  3929. toggle: function GrabToPan_toggle() {
  3930. if (this.active) {
  3931. this.deactivate();
  3932. } else {
  3933. this.activate();
  3934. }
  3935. },
  3936. ignoreTarget: function GrabToPan_ignoreTarget(node) {
  3937. return node[matchesSelector]('a[href], a[href] *, input, textarea, button, button *, select, option');
  3938. },
  3939. _onmousedown: function GrabToPan__onmousedown(event) {
  3940. if (event.button !== 0 || this.ignoreTarget(event.target)) {
  3941. return;
  3942. }
  3943. if (event.originalTarget) {
  3944. try {
  3945. event.originalTarget.tagName;
  3946. } catch (e) {
  3947. return;
  3948. }
  3949. }
  3950. this.scrollLeftStart = this.element.scrollLeft;
  3951. this.scrollTopStart = this.element.scrollTop;
  3952. this.clientXStart = event.clientX;
  3953. this.clientYStart = event.clientY;
  3954. this.document.addEventListener('mousemove', this._onmousemove, true);
  3955. this.document.addEventListener('mouseup', this._endPan, true);
  3956. this.element.addEventListener('scroll', this._endPan, true);
  3957. event.preventDefault();
  3958. event.stopPropagation();
  3959. var focusedElement = document.activeElement;
  3960. if (focusedElement && !focusedElement.contains(event.target)) {
  3961. focusedElement.blur();
  3962. }
  3963. },
  3964. _onmousemove: function GrabToPan__onmousemove(event) {
  3965. this.element.removeEventListener('scroll', this._endPan, true);
  3966. if (isLeftMouseReleased(event)) {
  3967. this._endPan();
  3968. return;
  3969. }
  3970. var xDiff = event.clientX - this.clientXStart;
  3971. var yDiff = event.clientY - this.clientYStart;
  3972. var scrollTop = this.scrollTopStart - yDiff;
  3973. var scrollLeft = this.scrollLeftStart - xDiff;
  3974. if (this.element.scrollTo) {
  3975. this.element.scrollTo({
  3976. top: scrollTop,
  3977. left: scrollLeft,
  3978. behavior: 'instant'
  3979. });
  3980. } else {
  3981. this.element.scrollTop = scrollTop;
  3982. this.element.scrollLeft = scrollLeft;
  3983. }
  3984. if (!this.overlay.parentNode) {
  3985. document.body.appendChild(this.overlay);
  3986. }
  3987. },
  3988. _endPan: function GrabToPan__endPan() {
  3989. this.element.removeEventListener('scroll', this._endPan, true);
  3990. this.document.removeEventListener('mousemove', this._onmousemove, true);
  3991. this.document.removeEventListener('mouseup', this._endPan, true);
  3992. this.overlay.remove();
  3993. }
  3994. };
  3995. var matchesSelector;
  3996. ['webkitM', 'mozM', 'msM', 'oM', 'm'].some(function (prefix) {
  3997. var name = prefix + 'atches';
  3998. if (name in document.documentElement) {
  3999. matchesSelector = name;
  4000. }
  4001. name += 'Selector';
  4002. if (name in document.documentElement) {
  4003. matchesSelector = name;
  4004. }
  4005. return matchesSelector;
  4006. });
  4007. var isNotIEorIsIE10plus = !document.documentMode || document.documentMode > 9;
  4008. var chrome = window.chrome;
  4009. var isChrome15OrOpera15plus = chrome && (chrome.webstore || chrome.app);
  4010. var isSafari6plus = /Apple/.test(navigator.vendor) && /Version\/([6-9]\d*|[1-5]\d+)/.test(navigator.userAgent);
  4011. function isLeftMouseReleased(event) {
  4012. if ('buttons' in event && isNotIEorIsIE10plus) {
  4013. return !(event.buttons & 1);
  4014. }
  4015. if (isChrome15OrOpera15plus || isSafari6plus) {
  4016. return event.which === 0;
  4017. }
  4018. return false;
  4019. }
  4020. /***/ }),
  4021. /* 11 */
  4022. /***/ (function(module, exports, __webpack_require__) {
  4023. "use strict";
  4024. Object.defineProperty(exports, "__esModule", {
  4025. value: true
  4026. });
  4027. exports.PDFRenderingQueue = exports.RenderingStates = void 0;
  4028. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  4029. 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); } }
  4030. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  4031. var CLEANUP_TIMEOUT = 30000;
  4032. var RenderingStates = {
  4033. INITIAL: 0,
  4034. RUNNING: 1,
  4035. PAUSED: 2,
  4036. FINISHED: 3
  4037. };
  4038. exports.RenderingStates = RenderingStates;
  4039. var PDFRenderingQueue =
  4040. /*#__PURE__*/
  4041. function () {
  4042. function PDFRenderingQueue() {
  4043. _classCallCheck(this, PDFRenderingQueue);
  4044. this.pdfViewer = null;
  4045. this.pdfThumbnailViewer = null;
  4046. this.onIdle = null;
  4047. this.highestPriorityPage = null;
  4048. this.idleTimeout = null;
  4049. this.printing = false;
  4050. this.isThumbnailViewEnabled = false;
  4051. }
  4052. _createClass(PDFRenderingQueue, [{
  4053. key: "setViewer",
  4054. value: function setViewer(pdfViewer) {
  4055. this.pdfViewer = pdfViewer;
  4056. }
  4057. }, {
  4058. key: "setThumbnailViewer",
  4059. value: function setThumbnailViewer(pdfThumbnailViewer) {
  4060. this.pdfThumbnailViewer = pdfThumbnailViewer;
  4061. }
  4062. }, {
  4063. key: "isHighestPriority",
  4064. value: function isHighestPriority(view) {
  4065. return this.highestPriorityPage === view.renderingId;
  4066. }
  4067. }, {
  4068. key: "renderHighestPriority",
  4069. value: function renderHighestPriority(currentlyVisiblePages) {
  4070. if (this.idleTimeout) {
  4071. clearTimeout(this.idleTimeout);
  4072. this.idleTimeout = null;
  4073. }
  4074. if (this.pdfViewer.forceRendering(currentlyVisiblePages)) {
  4075. return;
  4076. }
  4077. if (this.pdfThumbnailViewer && this.isThumbnailViewEnabled) {
  4078. if (this.pdfThumbnailViewer.forceRendering()) {
  4079. return;
  4080. }
  4081. }
  4082. if (this.printing) {
  4083. return;
  4084. }
  4085. if (this.onIdle) {
  4086. this.idleTimeout = setTimeout(this.onIdle.bind(this), CLEANUP_TIMEOUT);
  4087. }
  4088. }
  4089. }, {
  4090. key: "getHighestPriority",
  4091. value: function getHighestPriority(visible, views, scrolledDown) {
  4092. var visibleViews = visible.views;
  4093. var numVisible = visibleViews.length;
  4094. if (numVisible === 0) {
  4095. return null;
  4096. }
  4097. for (var i = 0; i < numVisible; ++i) {
  4098. var view = visibleViews[i].view;
  4099. if (!this.isViewFinished(view)) {
  4100. return view;
  4101. }
  4102. }
  4103. if (scrolledDown) {
  4104. var nextPageIndex = visible.last.id;
  4105. if (views[nextPageIndex] && !this.isViewFinished(views[nextPageIndex])) {
  4106. return views[nextPageIndex];
  4107. }
  4108. } else {
  4109. var previousPageIndex = visible.first.id - 2;
  4110. if (views[previousPageIndex] && !this.isViewFinished(views[previousPageIndex])) {
  4111. return views[previousPageIndex];
  4112. }
  4113. }
  4114. return null;
  4115. }
  4116. }, {
  4117. key: "isViewFinished",
  4118. value: function isViewFinished(view) {
  4119. return view.renderingState === RenderingStates.FINISHED;
  4120. }
  4121. }, {
  4122. key: "renderView",
  4123. value: function renderView(view) {
  4124. var _this = this;
  4125. switch (view.renderingState) {
  4126. case RenderingStates.FINISHED:
  4127. return false;
  4128. case RenderingStates.PAUSED:
  4129. this.highestPriorityPage = view.renderingId;
  4130. view.resume();
  4131. break;
  4132. case RenderingStates.RUNNING:
  4133. this.highestPriorityPage = view.renderingId;
  4134. break;
  4135. case RenderingStates.INITIAL:
  4136. this.highestPriorityPage = view.renderingId;
  4137. view.draw()["finally"](function () {
  4138. _this.renderHighestPriority();
  4139. });
  4140. break;
  4141. }
  4142. return true;
  4143. }
  4144. }]);
  4145. return PDFRenderingQueue;
  4146. }();
  4147. exports.PDFRenderingQueue = PDFRenderingQueue;
  4148. /***/ }),
  4149. /* 12 */
  4150. /***/ (function(module, exports, __webpack_require__) {
  4151. "use strict";
  4152. Object.defineProperty(exports, "__esModule", {
  4153. value: true
  4154. });
  4155. exports.PDFSidebar = exports.SidebarView = void 0;
  4156. var _ui_utils = __webpack_require__(5);
  4157. var _pdf_rendering_queue = __webpack_require__(11);
  4158. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  4159. 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); } }
  4160. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  4161. var UI_NOTIFICATION_CLASS = 'pdfSidebarNotification';
  4162. var SidebarView = {
  4163. UNKNOWN: -1,
  4164. NONE: 0,
  4165. THUMBS: 1,
  4166. OUTLINE: 2,
  4167. ATTACHMENTS: 3,
  4168. LAYERS: 4
  4169. };
  4170. exports.SidebarView = SidebarView;
  4171. var PDFSidebar =
  4172. /*#__PURE__*/
  4173. function () {
  4174. function PDFSidebar(_ref) {
  4175. var elements = _ref.elements,
  4176. pdfViewer = _ref.pdfViewer,
  4177. pdfThumbnailViewer = _ref.pdfThumbnailViewer,
  4178. eventBus = _ref.eventBus,
  4179. _ref$l10n = _ref.l10n,
  4180. l10n = _ref$l10n === void 0 ? _ui_utils.NullL10n : _ref$l10n,
  4181. _ref$disableNotificat = _ref.disableNotification,
  4182. disableNotification = _ref$disableNotificat === void 0 ? false : _ref$disableNotificat;
  4183. _classCallCheck(this, PDFSidebar);
  4184. this.isOpen = false;
  4185. this.active = SidebarView.THUMBS;
  4186. this.isInitialViewSet = false;
  4187. this.onToggled = null;
  4188. this.pdfViewer = pdfViewer;
  4189. this.pdfThumbnailViewer = pdfThumbnailViewer;
  4190. this.outerContainer = elements.outerContainer;
  4191. this.viewerContainer = elements.viewerContainer;
  4192. this.toggleButton = elements.toggleButton;
  4193. this.thumbnailButton = elements.thumbnailButton;
  4194. this.outlineButton = elements.outlineButton;
  4195. this.attachmentsButton = elements.attachmentsButton;
  4196. this.thumbnailView = elements.thumbnailView;
  4197. this.outlineView = elements.outlineView;
  4198. this.attachmentsView = elements.attachmentsView;
  4199. this.eventBus = eventBus;
  4200. this.l10n = l10n;
  4201. this._disableNotification = disableNotification;
  4202. this._addEventListeners();
  4203. }
  4204. _createClass(PDFSidebar, [{
  4205. key: "reset",
  4206. value: function reset() {
  4207. this.isInitialViewSet = false;
  4208. this._hideUINotification(null);
  4209. this.switchView(SidebarView.THUMBS);
  4210. this.outlineButton.disabled = false;
  4211. this.attachmentsButton.disabled = false;
  4212. }
  4213. }, {
  4214. key: "setInitialView",
  4215. value: function setInitialView() {
  4216. var view = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : SidebarView.NONE;
  4217. if (this.isInitialViewSet) {
  4218. return;
  4219. }
  4220. this.isInitialViewSet = true;
  4221. if (view === SidebarView.NONE || view === SidebarView.UNKNOWN) {
  4222. this._dispatchEvent();
  4223. return;
  4224. }
  4225. if (!this._switchView(view, true)) {
  4226. this._dispatchEvent();
  4227. }
  4228. }
  4229. }, {
  4230. key: "switchView",
  4231. value: function switchView(view) {
  4232. var forceOpen = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  4233. this._switchView(view, forceOpen);
  4234. }
  4235. }, {
  4236. key: "_switchView",
  4237. value: function _switchView(view) {
  4238. var forceOpen = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  4239. var isViewChanged = view !== this.active;
  4240. var shouldForceRendering = false;
  4241. switch (view) {
  4242. case SidebarView.NONE:
  4243. if (this.isOpen) {
  4244. this.close();
  4245. return true;
  4246. }
  4247. return false;
  4248. case SidebarView.THUMBS:
  4249. if (this.isOpen && isViewChanged) {
  4250. shouldForceRendering = true;
  4251. }
  4252. break;
  4253. case SidebarView.OUTLINE:
  4254. if (this.outlineButton.disabled) {
  4255. return false;
  4256. }
  4257. break;
  4258. case SidebarView.ATTACHMENTS:
  4259. if (this.attachmentsButton.disabled) {
  4260. return false;
  4261. }
  4262. break;
  4263. default:
  4264. console.error("PDFSidebar._switchView: \"".concat(view, "\" is not a valid view."));
  4265. return false;
  4266. }
  4267. this.active = view;
  4268. this.thumbnailButton.classList.toggle('toggled', view === SidebarView.THUMBS);
  4269. this.outlineButton.classList.toggle('toggled', view === SidebarView.OUTLINE);
  4270. this.attachmentsButton.classList.toggle('toggled', view === SidebarView.ATTACHMENTS);
  4271. this.thumbnailView.classList.toggle('hidden', view !== SidebarView.THUMBS);
  4272. this.outlineView.classList.toggle('hidden', view !== SidebarView.OUTLINE);
  4273. this.attachmentsView.classList.toggle('hidden', view !== SidebarView.ATTACHMENTS);
  4274. if (forceOpen && !this.isOpen) {
  4275. this.open();
  4276. return true;
  4277. }
  4278. if (shouldForceRendering) {
  4279. this._updateThumbnailViewer();
  4280. this._forceRendering();
  4281. }
  4282. if (isViewChanged) {
  4283. this._dispatchEvent();
  4284. }
  4285. this._hideUINotification(this.active);
  4286. return isViewChanged;
  4287. }
  4288. }, {
  4289. key: "open",
  4290. value: function open() {
  4291. if (this.isOpen) {
  4292. return;
  4293. }
  4294. this.isOpen = true;
  4295. this.toggleButton.classList.add('toggled');
  4296. this.outerContainer.classList.add('sidebarMoving', 'sidebarOpen');
  4297. if (this.active === SidebarView.THUMBS) {
  4298. this._updateThumbnailViewer();
  4299. }
  4300. this._forceRendering();
  4301. this._dispatchEvent();
  4302. this._hideUINotification(this.active);
  4303. }
  4304. }, {
  4305. key: "close",
  4306. value: function close() {
  4307. if (!this.isOpen) {
  4308. return;
  4309. }
  4310. this.isOpen = false;
  4311. this.toggleButton.classList.remove('toggled');
  4312. this.outerContainer.classList.add('sidebarMoving');
  4313. this.outerContainer.classList.remove('sidebarOpen');
  4314. this._forceRendering();
  4315. this._dispatchEvent();
  4316. }
  4317. }, {
  4318. key: "toggle",
  4319. value: function toggle() {
  4320. if (this.isOpen) {
  4321. this.close();
  4322. } else {
  4323. this.open();
  4324. }
  4325. }
  4326. }, {
  4327. key: "_dispatchEvent",
  4328. value: function _dispatchEvent() {
  4329. this.eventBus.dispatch('sidebarviewchanged', {
  4330. source: this,
  4331. view: this.visibleView
  4332. });
  4333. }
  4334. }, {
  4335. key: "_forceRendering",
  4336. value: function _forceRendering() {
  4337. if (this.onToggled) {
  4338. this.onToggled();
  4339. } else {
  4340. this.pdfViewer.forceRendering();
  4341. this.pdfThumbnailViewer.forceRendering();
  4342. }
  4343. }
  4344. }, {
  4345. key: "_updateThumbnailViewer",
  4346. value: function _updateThumbnailViewer() {
  4347. var pdfViewer = this.pdfViewer,
  4348. pdfThumbnailViewer = this.pdfThumbnailViewer;
  4349. var pagesCount = pdfViewer.pagesCount;
  4350. for (var pageIndex = 0; pageIndex < pagesCount; pageIndex++) {
  4351. var pageView = pdfViewer.getPageView(pageIndex);
  4352. if (pageView && pageView.renderingState === _pdf_rendering_queue.RenderingStates.FINISHED) {
  4353. var thumbnailView = pdfThumbnailViewer.getThumbnail(pageIndex);
  4354. thumbnailView.setImage(pageView);
  4355. }
  4356. }
  4357. pdfThumbnailViewer.scrollThumbnailIntoView(pdfViewer.currentPageNumber);
  4358. }
  4359. }, {
  4360. key: "_showUINotification",
  4361. value: function _showUINotification(view) {
  4362. var _this = this;
  4363. if (this._disableNotification) {
  4364. return;
  4365. }
  4366. this.l10n.get('toggle_sidebar_notification.title', null, 'Toggle Sidebar (document contains outline/attachments)').then(function (msg) {
  4367. _this.toggleButton.title = msg;
  4368. });
  4369. if (!this.isOpen) {
  4370. this.toggleButton.classList.add(UI_NOTIFICATION_CLASS);
  4371. } else if (view === this.active) {
  4372. return;
  4373. }
  4374. switch (view) {
  4375. case SidebarView.OUTLINE:
  4376. this.outlineButton.classList.add(UI_NOTIFICATION_CLASS);
  4377. break;
  4378. case SidebarView.ATTACHMENTS:
  4379. this.attachmentsButton.classList.add(UI_NOTIFICATION_CLASS);
  4380. break;
  4381. }
  4382. }
  4383. }, {
  4384. key: "_hideUINotification",
  4385. value: function _hideUINotification(view) {
  4386. var _this2 = this;
  4387. if (this._disableNotification) {
  4388. return;
  4389. }
  4390. var removeNotification = function removeNotification(view) {
  4391. switch (view) {
  4392. case SidebarView.OUTLINE:
  4393. _this2.outlineButton.classList.remove(UI_NOTIFICATION_CLASS);
  4394. break;
  4395. case SidebarView.ATTACHMENTS:
  4396. _this2.attachmentsButton.classList.remove(UI_NOTIFICATION_CLASS);
  4397. break;
  4398. }
  4399. };
  4400. if (!this.isOpen && view !== null) {
  4401. return;
  4402. }
  4403. this.toggleButton.classList.remove(UI_NOTIFICATION_CLASS);
  4404. if (view !== null) {
  4405. removeNotification(view);
  4406. return;
  4407. }
  4408. for (view in SidebarView) {
  4409. removeNotification(SidebarView[view]);
  4410. }
  4411. this.l10n.get('toggle_sidebar.title', null, 'Toggle Sidebar').then(function (msg) {
  4412. _this2.toggleButton.title = msg;
  4413. });
  4414. }
  4415. }, {
  4416. key: "_addEventListeners",
  4417. value: function _addEventListeners() {
  4418. var _this3 = this;
  4419. this.viewerContainer.addEventListener('transitionend', function (evt) {
  4420. if (evt.target === _this3.viewerContainer) {
  4421. _this3.outerContainer.classList.remove('sidebarMoving');
  4422. }
  4423. });
  4424. this.toggleButton.addEventListener('click', function () {
  4425. _this3.toggle();
  4426. });
  4427. this.thumbnailButton.addEventListener('click', function () {
  4428. _this3.switchView(SidebarView.THUMBS);
  4429. });
  4430. this.outlineButton.addEventListener('click', function () {
  4431. _this3.switchView(SidebarView.OUTLINE);
  4432. });
  4433. this.outlineButton.addEventListener('dblclick', function () {
  4434. _this3.eventBus.dispatch('toggleoutlinetree', {
  4435. source: _this3
  4436. });
  4437. });
  4438. this.attachmentsButton.addEventListener('click', function () {
  4439. _this3.switchView(SidebarView.ATTACHMENTS);
  4440. });
  4441. this.eventBus.on('outlineloaded', function (evt) {
  4442. var outlineCount = evt.outlineCount;
  4443. _this3.outlineButton.disabled = !outlineCount;
  4444. if (outlineCount) {
  4445. _this3._showUINotification(SidebarView.OUTLINE);
  4446. } else if (_this3.active === SidebarView.OUTLINE) {
  4447. _this3.switchView(SidebarView.THUMBS);
  4448. }
  4449. });
  4450. this.eventBus.on('attachmentsloaded', function (evt) {
  4451. if (evt.attachmentsCount) {
  4452. _this3.attachmentsButton.disabled = false;
  4453. _this3._showUINotification(SidebarView.ATTACHMENTS);
  4454. return;
  4455. }
  4456. Promise.resolve().then(function () {
  4457. if (_this3.attachmentsView.hasChildNodes()) {
  4458. return;
  4459. }
  4460. _this3.attachmentsButton.disabled = true;
  4461. if (_this3.active === SidebarView.ATTACHMENTS) {
  4462. _this3.switchView(SidebarView.THUMBS);
  4463. }
  4464. });
  4465. });
  4466. this.eventBus.on('presentationmodechanged', function (evt) {
  4467. if (!evt.active && !evt.switchInProgress && _this3.isThumbnailViewVisible) {
  4468. _this3._updateThumbnailViewer();
  4469. }
  4470. });
  4471. }
  4472. }, {
  4473. key: "visibleView",
  4474. get: function get() {
  4475. return this.isOpen ? this.active : SidebarView.NONE;
  4476. }
  4477. }, {
  4478. key: "isThumbnailViewVisible",
  4479. get: function get() {
  4480. return this.isOpen && this.active === SidebarView.THUMBS;
  4481. }
  4482. }, {
  4483. key: "isOutlineViewVisible",
  4484. get: function get() {
  4485. return this.isOpen && this.active === SidebarView.OUTLINE;
  4486. }
  4487. }, {
  4488. key: "isAttachmentsViewVisible",
  4489. get: function get() {
  4490. return this.isOpen && this.active === SidebarView.ATTACHMENTS;
  4491. }
  4492. }]);
  4493. return PDFSidebar;
  4494. }();
  4495. exports.PDFSidebar = PDFSidebar;
  4496. /***/ }),
  4497. /* 13 */
  4498. /***/ (function(module, exports, __webpack_require__) {
  4499. "use strict";
  4500. Object.defineProperty(exports, "__esModule", {
  4501. value: true
  4502. });
  4503. exports.OverlayManager = void 0;
  4504. var _regenerator = _interopRequireDefault(__webpack_require__(2));
  4505. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  4506. 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); } }
  4507. 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); }); }; }
  4508. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  4509. 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); } }
  4510. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  4511. var OverlayManager =
  4512. /*#__PURE__*/
  4513. function () {
  4514. function OverlayManager() {
  4515. _classCallCheck(this, OverlayManager);
  4516. this._overlays = {};
  4517. this._active = null;
  4518. this._keyDownBound = this._keyDown.bind(this);
  4519. }
  4520. _createClass(OverlayManager, [{
  4521. key: "register",
  4522. value: function () {
  4523. var _register = _asyncToGenerator(
  4524. /*#__PURE__*/
  4525. _regenerator["default"].mark(function _callee(name, element) {
  4526. var callerCloseMethod,
  4527. canForceClose,
  4528. container,
  4529. _args = arguments;
  4530. return _regenerator["default"].wrap(function _callee$(_context) {
  4531. while (1) {
  4532. switch (_context.prev = _context.next) {
  4533. case 0:
  4534. callerCloseMethod = _args.length > 2 && _args[2] !== undefined ? _args[2] : null;
  4535. canForceClose = _args.length > 3 && _args[3] !== undefined ? _args[3] : false;
  4536. if (!(!name || !element || !(container = element.parentNode))) {
  4537. _context.next = 6;
  4538. break;
  4539. }
  4540. throw new Error('Not enough parameters.');
  4541. case 6:
  4542. if (!this._overlays[name]) {
  4543. _context.next = 8;
  4544. break;
  4545. }
  4546. throw new Error('The overlay is already registered.');
  4547. case 8:
  4548. this._overlays[name] = {
  4549. element: element,
  4550. container: container,
  4551. callerCloseMethod: callerCloseMethod,
  4552. canForceClose: canForceClose
  4553. };
  4554. case 9:
  4555. case "end":
  4556. return _context.stop();
  4557. }
  4558. }
  4559. }, _callee, this);
  4560. }));
  4561. function register(_x, _x2) {
  4562. return _register.apply(this, arguments);
  4563. }
  4564. return register;
  4565. }()
  4566. }, {
  4567. key: "unregister",
  4568. value: function () {
  4569. var _unregister = _asyncToGenerator(
  4570. /*#__PURE__*/
  4571. _regenerator["default"].mark(function _callee2(name) {
  4572. return _regenerator["default"].wrap(function _callee2$(_context2) {
  4573. while (1) {
  4574. switch (_context2.prev = _context2.next) {
  4575. case 0:
  4576. if (this._overlays[name]) {
  4577. _context2.next = 4;
  4578. break;
  4579. }
  4580. throw new Error('The overlay does not exist.');
  4581. case 4:
  4582. if (!(this._active === name)) {
  4583. _context2.next = 6;
  4584. break;
  4585. }
  4586. throw new Error('The overlay cannot be removed while it is active.');
  4587. case 6:
  4588. delete this._overlays[name];
  4589. case 7:
  4590. case "end":
  4591. return _context2.stop();
  4592. }
  4593. }
  4594. }, _callee2, this);
  4595. }));
  4596. function unregister(_x3) {
  4597. return _unregister.apply(this, arguments);
  4598. }
  4599. return unregister;
  4600. }()
  4601. }, {
  4602. key: "open",
  4603. value: function () {
  4604. var _open = _asyncToGenerator(
  4605. /*#__PURE__*/
  4606. _regenerator["default"].mark(function _callee3(name) {
  4607. return _regenerator["default"].wrap(function _callee3$(_context3) {
  4608. while (1) {
  4609. switch (_context3.prev = _context3.next) {
  4610. case 0:
  4611. if (this._overlays[name]) {
  4612. _context3.next = 4;
  4613. break;
  4614. }
  4615. throw new Error('The overlay does not exist.');
  4616. case 4:
  4617. if (!this._active) {
  4618. _context3.next = 14;
  4619. break;
  4620. }
  4621. if (!this._overlays[name].canForceClose) {
  4622. _context3.next = 9;
  4623. break;
  4624. }
  4625. this._closeThroughCaller();
  4626. _context3.next = 14;
  4627. break;
  4628. case 9:
  4629. if (!(this._active === name)) {
  4630. _context3.next = 13;
  4631. break;
  4632. }
  4633. throw new Error('The overlay is already active.');
  4634. case 13:
  4635. throw new Error('Another overlay is currently active.');
  4636. case 14:
  4637. this._active = name;
  4638. this._overlays[this._active].element.classList.remove('hidden');
  4639. this._overlays[this._active].container.classList.remove('hidden');
  4640. window.addEventListener('keydown', this._keyDownBound);
  4641. case 18:
  4642. case "end":
  4643. return _context3.stop();
  4644. }
  4645. }
  4646. }, _callee3, this);
  4647. }));
  4648. function open(_x4) {
  4649. return _open.apply(this, arguments);
  4650. }
  4651. return open;
  4652. }()
  4653. }, {
  4654. key: "close",
  4655. value: function () {
  4656. var _close = _asyncToGenerator(
  4657. /*#__PURE__*/
  4658. _regenerator["default"].mark(function _callee4(name) {
  4659. return _regenerator["default"].wrap(function _callee4$(_context4) {
  4660. while (1) {
  4661. switch (_context4.prev = _context4.next) {
  4662. case 0:
  4663. if (this._overlays[name]) {
  4664. _context4.next = 4;
  4665. break;
  4666. }
  4667. throw new Error('The overlay does not exist.');
  4668. case 4:
  4669. if (this._active) {
  4670. _context4.next = 8;
  4671. break;
  4672. }
  4673. throw new Error('The overlay is currently not active.');
  4674. case 8:
  4675. if (!(this._active !== name)) {
  4676. _context4.next = 10;
  4677. break;
  4678. }
  4679. throw new Error('Another overlay is currently active.');
  4680. case 10:
  4681. this._overlays[this._active].container.classList.add('hidden');
  4682. this._overlays[this._active].element.classList.add('hidden');
  4683. this._active = null;
  4684. window.removeEventListener('keydown', this._keyDownBound);
  4685. case 14:
  4686. case "end":
  4687. return _context4.stop();
  4688. }
  4689. }
  4690. }, _callee4, this);
  4691. }));
  4692. function close(_x5) {
  4693. return _close.apply(this, arguments);
  4694. }
  4695. return close;
  4696. }()
  4697. }, {
  4698. key: "_keyDown",
  4699. value: function _keyDown(evt) {
  4700. if (this._active && evt.keyCode === 27) {
  4701. this._closeThroughCaller();
  4702. evt.preventDefault();
  4703. }
  4704. }
  4705. }, {
  4706. key: "_closeThroughCaller",
  4707. value: function _closeThroughCaller() {
  4708. if (this._overlays[this._active].callerCloseMethod) {
  4709. this._overlays[this._active].callerCloseMethod();
  4710. }
  4711. if (this._active) {
  4712. this.close(this._active);
  4713. }
  4714. }
  4715. }, {
  4716. key: "active",
  4717. get: function get() {
  4718. return this._active;
  4719. }
  4720. }]);
  4721. return OverlayManager;
  4722. }();
  4723. exports.OverlayManager = OverlayManager;
  4724. /***/ }),
  4725. /* 14 */
  4726. /***/ (function(module, exports, __webpack_require__) {
  4727. "use strict";
  4728. Object.defineProperty(exports, "__esModule", {
  4729. value: true
  4730. });
  4731. exports.PasswordPrompt = void 0;
  4732. var _ui_utils = __webpack_require__(5);
  4733. var _pdfjsLib = __webpack_require__(7);
  4734. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  4735. 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); } }
  4736. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  4737. var PasswordPrompt =
  4738. /*#__PURE__*/
  4739. function () {
  4740. function PasswordPrompt(options, overlayManager) {
  4741. var _this = this;
  4742. var l10n = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : _ui_utils.NullL10n;
  4743. _classCallCheck(this, PasswordPrompt);
  4744. this.overlayName = options.overlayName;
  4745. this.container = options.container;
  4746. this.label = options.label;
  4747. this.input = options.input;
  4748. this.submitButton = options.submitButton;
  4749. this.cancelButton = options.cancelButton;
  4750. this.overlayManager = overlayManager;
  4751. this.l10n = l10n;
  4752. this.updateCallback = null;
  4753. this.reason = null;
  4754. this.submitButton.addEventListener('click', this.verify.bind(this));
  4755. this.cancelButton.addEventListener('click', this.close.bind(this));
  4756. this.input.addEventListener('keydown', function (e) {
  4757. if (e.keyCode === 13) {
  4758. _this.verify();
  4759. }
  4760. });
  4761. this.overlayManager.register(this.overlayName, this.container, this.close.bind(this), true);
  4762. }
  4763. _createClass(PasswordPrompt, [{
  4764. key: "open",
  4765. value: function open() {
  4766. var _this2 = this;
  4767. this.overlayManager.open(this.overlayName).then(function () {
  4768. _this2.input.focus();
  4769. var promptString;
  4770. if (_this2.reason === _pdfjsLib.PasswordResponses.INCORRECT_PASSWORD) {
  4771. promptString = _this2.l10n.get('password_invalid', null, 'Invalid password. Please try again.');
  4772. } else {
  4773. promptString = _this2.l10n.get('password_label', null, 'Enter the password to open this PDF file.');
  4774. }
  4775. promptString.then(function (msg) {
  4776. _this2.label.textContent = msg;
  4777. });
  4778. });
  4779. }
  4780. }, {
  4781. key: "close",
  4782. value: function close() {
  4783. var _this3 = this;
  4784. this.overlayManager.close(this.overlayName).then(function () {
  4785. _this3.input.value = '';
  4786. });
  4787. }
  4788. }, {
  4789. key: "verify",
  4790. value: function verify() {
  4791. var password = this.input.value;
  4792. if (password && password.length > 0) {
  4793. this.close();
  4794. this.updateCallback(password);
  4795. }
  4796. }
  4797. }, {
  4798. key: "setUpdateCallback",
  4799. value: function setUpdateCallback(updateCallback, reason) {
  4800. this.updateCallback = updateCallback;
  4801. this.reason = reason;
  4802. }
  4803. }]);
  4804. return PasswordPrompt;
  4805. }();
  4806. exports.PasswordPrompt = PasswordPrompt;
  4807. /***/ }),
  4808. /* 15 */
  4809. /***/ (function(module, exports, __webpack_require__) {
  4810. "use strict";
  4811. Object.defineProperty(exports, "__esModule", {
  4812. value: true
  4813. });
  4814. exports.PDFAttachmentViewer = void 0;
  4815. var _pdfjsLib = __webpack_require__(7);
  4816. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  4817. 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); } }
  4818. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  4819. var PDFAttachmentViewer =
  4820. /*#__PURE__*/
  4821. function () {
  4822. function PDFAttachmentViewer(_ref) {
  4823. var container = _ref.container,
  4824. eventBus = _ref.eventBus,
  4825. downloadManager = _ref.downloadManager;
  4826. _classCallCheck(this, PDFAttachmentViewer);
  4827. this.container = container;
  4828. this.eventBus = eventBus;
  4829. this.downloadManager = downloadManager;
  4830. this.reset();
  4831. this.eventBus.on('fileattachmentannotation', this._appendAttachment.bind(this));
  4832. }
  4833. _createClass(PDFAttachmentViewer, [{
  4834. key: "reset",
  4835. value: function reset() {
  4836. var keepRenderedCapability = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  4837. this.attachments = null;
  4838. this.container.textContent = '';
  4839. if (!keepRenderedCapability) {
  4840. this._renderedCapability = (0, _pdfjsLib.createPromiseCapability)();
  4841. }
  4842. }
  4843. }, {
  4844. key: "_dispatchEvent",
  4845. value: function _dispatchEvent(attachmentsCount) {
  4846. this._renderedCapability.resolve();
  4847. this.eventBus.dispatch('attachmentsloaded', {
  4848. source: this,
  4849. attachmentsCount: attachmentsCount
  4850. });
  4851. }
  4852. }, {
  4853. key: "_bindPdfLink",
  4854. value: function _bindPdfLink(button, content, filename) {
  4855. if (this.downloadManager.disableCreateObjectURL) {
  4856. throw new Error('bindPdfLink: Unsupported "disableCreateObjectURL" value.');
  4857. }
  4858. var blobUrl;
  4859. button.onclick = function () {
  4860. if (!blobUrl) {
  4861. blobUrl = (0, _pdfjsLib.createObjectURL)(content, 'application/pdf');
  4862. }
  4863. var viewerUrl;
  4864. viewerUrl = '?file=' + encodeURIComponent(blobUrl + '#' + filename);
  4865. window.open(viewerUrl);
  4866. return false;
  4867. };
  4868. }
  4869. }, {
  4870. key: "_bindLink",
  4871. value: function _bindLink(button, content, filename) {
  4872. var _this = this;
  4873. button.onclick = function () {
  4874. _this.downloadManager.downloadData(content, filename, '');
  4875. return false;
  4876. };
  4877. }
  4878. }, {
  4879. key: "render",
  4880. value: function render(_ref2) {
  4881. var attachments = _ref2.attachments,
  4882. _ref2$keepRenderedCap = _ref2.keepRenderedCapability,
  4883. keepRenderedCapability = _ref2$keepRenderedCap === void 0 ? false : _ref2$keepRenderedCap;
  4884. var attachmentsCount = 0;
  4885. if (this.attachments) {
  4886. this.reset(keepRenderedCapability === true);
  4887. }
  4888. this.attachments = attachments || null;
  4889. if (!attachments) {
  4890. this._dispatchEvent(attachmentsCount);
  4891. return;
  4892. }
  4893. var names = Object.keys(attachments).sort(function (a, b) {
  4894. return a.toLowerCase().localeCompare(b.toLowerCase());
  4895. });
  4896. attachmentsCount = names.length;
  4897. for (var i = 0; i < attachmentsCount; i++) {
  4898. var item = attachments[names[i]];
  4899. var filename = (0, _pdfjsLib.removeNullCharacters)((0, _pdfjsLib.getFilenameFromUrl)(item.filename));
  4900. var div = document.createElement('div');
  4901. div.className = 'attachmentsItem';
  4902. var button = document.createElement('button');
  4903. button.textContent = filename;
  4904. if (/\.pdf$/i.test(filename) && !this.downloadManager.disableCreateObjectURL) {
  4905. this._bindPdfLink(button, item.content, filename);
  4906. } else {
  4907. this._bindLink(button, item.content, filename);
  4908. }
  4909. div.appendChild(button);
  4910. this.container.appendChild(div);
  4911. }
  4912. this._dispatchEvent(attachmentsCount);
  4913. }
  4914. }, {
  4915. key: "_appendAttachment",
  4916. value: function _appendAttachment(_ref3) {
  4917. var _this2 = this;
  4918. var id = _ref3.id,
  4919. filename = _ref3.filename,
  4920. content = _ref3.content;
  4921. this._renderedCapability.promise.then(function () {
  4922. var attachments = _this2.attachments;
  4923. if (!attachments) {
  4924. attachments = Object.create(null);
  4925. } else {
  4926. for (var name in attachments) {
  4927. if (id === name) {
  4928. return;
  4929. }
  4930. }
  4931. }
  4932. attachments[id] = {
  4933. filename: filename,
  4934. content: content
  4935. };
  4936. _this2.render({
  4937. attachments: attachments,
  4938. keepRenderedCapability: true
  4939. });
  4940. });
  4941. }
  4942. }]);
  4943. return PDFAttachmentViewer;
  4944. }();
  4945. exports.PDFAttachmentViewer = PDFAttachmentViewer;
  4946. /***/ }),
  4947. /* 16 */
  4948. /***/ (function(module, exports, __webpack_require__) {
  4949. "use strict";
  4950. Object.defineProperty(exports, "__esModule", {
  4951. value: true
  4952. });
  4953. exports.PDFDocumentProperties = void 0;
  4954. var _regenerator = _interopRequireDefault(__webpack_require__(2));
  4955. var _pdfjsLib = __webpack_require__(7);
  4956. var _ui_utils = __webpack_require__(5);
  4957. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  4958. 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); } }
  4959. 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); }); }; }
  4960. function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); }
  4961. function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance"); }
  4962. function _iterableToArrayLimit(arr, i) { if (!(Symbol.iterator in Object(arr) || Object.prototype.toString.call(arr) === "[object Arguments]")) { 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; }
  4963. function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
  4964. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  4965. 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); } }
  4966. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  4967. var DEFAULT_FIELD_CONTENT = '-';
  4968. var NON_METRIC_LOCALES = ['en-us', 'en-lr', 'my'];
  4969. var US_PAGE_NAMES = {
  4970. '8.5x11': 'Letter',
  4971. '8.5x14': 'Legal'
  4972. };
  4973. var METRIC_PAGE_NAMES = {
  4974. '297x420': 'A3',
  4975. '210x297': 'A4'
  4976. };
  4977. function getPageName(size, isPortrait, pageNames) {
  4978. var width = isPortrait ? size.width : size.height;
  4979. var height = isPortrait ? size.height : size.width;
  4980. return pageNames["".concat(width, "x").concat(height)];
  4981. }
  4982. var PDFDocumentProperties =
  4983. /*#__PURE__*/
  4984. function () {
  4985. function PDFDocumentProperties(_ref, overlayManager, eventBus) {
  4986. var _this = this;
  4987. var overlayName = _ref.overlayName,
  4988. fields = _ref.fields,
  4989. container = _ref.container,
  4990. closeButton = _ref.closeButton;
  4991. var l10n = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : _ui_utils.NullL10n;
  4992. _classCallCheck(this, PDFDocumentProperties);
  4993. this.overlayName = overlayName;
  4994. this.fields = fields;
  4995. this.container = container;
  4996. this.overlayManager = overlayManager;
  4997. this.l10n = l10n;
  4998. this._reset();
  4999. if (closeButton) {
  5000. closeButton.addEventListener('click', this.close.bind(this));
  5001. }
  5002. this.overlayManager.register(this.overlayName, this.container, this.close.bind(this));
  5003. if (eventBus) {
  5004. eventBus.on('pagechanging', function (evt) {
  5005. _this._currentPageNumber = evt.pageNumber;
  5006. });
  5007. eventBus.on('rotationchanging', function (evt) {
  5008. _this._pagesRotation = evt.pagesRotation;
  5009. });
  5010. }
  5011. this._isNonMetricLocale = true;
  5012. l10n.getLanguage().then(function (locale) {
  5013. _this._isNonMetricLocale = NON_METRIC_LOCALES.includes(locale);
  5014. });
  5015. }
  5016. _createClass(PDFDocumentProperties, [{
  5017. key: "open",
  5018. value: function open() {
  5019. var _this2 = this;
  5020. var freezeFieldData = function freezeFieldData(data) {
  5021. Object.defineProperty(_this2, 'fieldData', {
  5022. value: Object.freeze(data),
  5023. writable: false,
  5024. enumerable: true,
  5025. configurable: true
  5026. });
  5027. };
  5028. Promise.all([this.overlayManager.open(this.overlayName), this._dataAvailableCapability.promise]).then(function () {
  5029. var currentPageNumber = _this2._currentPageNumber;
  5030. var pagesRotation = _this2._pagesRotation;
  5031. if (_this2.fieldData && currentPageNumber === _this2.fieldData['_currentPageNumber'] && pagesRotation === _this2.fieldData['_pagesRotation']) {
  5032. _this2._updateUI();
  5033. return;
  5034. }
  5035. _this2.pdfDocument.getMetadata().then(function (_ref2) {
  5036. var info = _ref2.info,
  5037. metadata = _ref2.metadata,
  5038. contentDispositionFilename = _ref2.contentDispositionFilename;
  5039. 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) {
  5040. return _this2._parsePageSize((0, _ui_utils.getPageSizeInches)(pdfPage), pagesRotation);
  5041. }), _this2._parseLinearization(info.IsLinearized)]);
  5042. }).then(function (_ref3) {
  5043. var _ref4 = _slicedToArray(_ref3, 8),
  5044. info = _ref4[0],
  5045. metadata = _ref4[1],
  5046. fileName = _ref4[2],
  5047. fileSize = _ref4[3],
  5048. creationDate = _ref4[4],
  5049. modDate = _ref4[5],
  5050. pageSize = _ref4[6],
  5051. isLinearized = _ref4[7];
  5052. freezeFieldData({
  5053. 'fileName': fileName,
  5054. 'fileSize': fileSize,
  5055. 'title': info.Title,
  5056. 'author': info.Author,
  5057. 'subject': info.Subject,
  5058. 'keywords': info.Keywords,
  5059. 'creationDate': creationDate,
  5060. 'modificationDate': modDate,
  5061. 'creator': info.Creator,
  5062. 'producer': info.Producer,
  5063. 'version': info.PDFFormatVersion,
  5064. 'pageCount': _this2.pdfDocument.numPages,
  5065. 'pageSize': pageSize,
  5066. 'linearized': isLinearized,
  5067. '_currentPageNumber': currentPageNumber,
  5068. '_pagesRotation': pagesRotation
  5069. });
  5070. _this2._updateUI();
  5071. return _this2.pdfDocument.getDownloadInfo();
  5072. }).then(function (_ref5) {
  5073. var length = _ref5.length;
  5074. _this2.maybeFileSize = length;
  5075. return _this2._parseFileSize(length);
  5076. }).then(function (fileSize) {
  5077. if (fileSize === _this2.fieldData['fileSize']) {
  5078. return;
  5079. }
  5080. var data = Object.assign(Object.create(null), _this2.fieldData);
  5081. data['fileSize'] = fileSize;
  5082. freezeFieldData(data);
  5083. _this2._updateUI();
  5084. });
  5085. });
  5086. }
  5087. }, {
  5088. key: "close",
  5089. value: function close() {
  5090. this.overlayManager.close(this.overlayName);
  5091. }
  5092. }, {
  5093. key: "setDocument",
  5094. value: function setDocument(pdfDocument) {
  5095. var url = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  5096. if (this.pdfDocument) {
  5097. this._reset();
  5098. this._updateUI(true);
  5099. }
  5100. if (!pdfDocument) {
  5101. return;
  5102. }
  5103. this.pdfDocument = pdfDocument;
  5104. this.url = url;
  5105. this._dataAvailableCapability.resolve();
  5106. }
  5107. }, {
  5108. key: "setFileSize",
  5109. value: function setFileSize(fileSize) {
  5110. if (Number.isInteger(fileSize) && fileSize > 0) {
  5111. this.maybeFileSize = fileSize;
  5112. }
  5113. }
  5114. }, {
  5115. key: "_reset",
  5116. value: function _reset() {
  5117. this.pdfDocument = null;
  5118. this.url = null;
  5119. this.maybeFileSize = 0;
  5120. delete this.fieldData;
  5121. this._dataAvailableCapability = (0, _pdfjsLib.createPromiseCapability)();
  5122. this._currentPageNumber = 1;
  5123. this._pagesRotation = 0;
  5124. }
  5125. }, {
  5126. key: "_updateUI",
  5127. value: function _updateUI() {
  5128. var reset = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  5129. if (reset || !this.fieldData) {
  5130. for (var id in this.fields) {
  5131. this.fields[id].textContent = DEFAULT_FIELD_CONTENT;
  5132. }
  5133. return;
  5134. }
  5135. if (this.overlayManager.active !== this.overlayName) {
  5136. return;
  5137. }
  5138. for (var _id in this.fields) {
  5139. var content = this.fieldData[_id];
  5140. this.fields[_id].textContent = content || content === 0 ? content : DEFAULT_FIELD_CONTENT;
  5141. }
  5142. }
  5143. }, {
  5144. key: "_parseFileSize",
  5145. value: function () {
  5146. var _parseFileSize2 = _asyncToGenerator(
  5147. /*#__PURE__*/
  5148. _regenerator["default"].mark(function _callee() {
  5149. var fileSize,
  5150. kb,
  5151. _args = arguments;
  5152. return _regenerator["default"].wrap(function _callee$(_context) {
  5153. while (1) {
  5154. switch (_context.prev = _context.next) {
  5155. case 0:
  5156. fileSize = _args.length > 0 && _args[0] !== undefined ? _args[0] : 0;
  5157. kb = fileSize / 1024;
  5158. if (kb) {
  5159. _context.next = 6;
  5160. break;
  5161. }
  5162. return _context.abrupt("return", undefined);
  5163. case 6:
  5164. if (!(kb < 1024)) {
  5165. _context.next = 8;
  5166. break;
  5167. }
  5168. return _context.abrupt("return", this.l10n.get('document_properties_kb', {
  5169. size_kb: (+kb.toPrecision(3)).toLocaleString(),
  5170. size_b: fileSize.toLocaleString()
  5171. }, '{{size_kb}} KB ({{size_b}} bytes)'));
  5172. case 8:
  5173. return _context.abrupt("return", this.l10n.get('document_properties_mb', {
  5174. size_mb: (+(kb / 1024).toPrecision(3)).toLocaleString(),
  5175. size_b: fileSize.toLocaleString()
  5176. }, '{{size_mb}} MB ({{size_b}} bytes)'));
  5177. case 9:
  5178. case "end":
  5179. return _context.stop();
  5180. }
  5181. }
  5182. }, _callee, this);
  5183. }));
  5184. function _parseFileSize() {
  5185. return _parseFileSize2.apply(this, arguments);
  5186. }
  5187. return _parseFileSize;
  5188. }()
  5189. }, {
  5190. key: "_parsePageSize",
  5191. value: function () {
  5192. var _parsePageSize2 = _asyncToGenerator(
  5193. /*#__PURE__*/
  5194. _regenerator["default"].mark(function _callee2(pageSizeInches, pagesRotation) {
  5195. var _this3 = this;
  5196. var isPortrait, sizeInches, sizeMillimeters, pageName, name, exactMillimeters, intMillimeters;
  5197. return _regenerator["default"].wrap(function _callee2$(_context2) {
  5198. while (1) {
  5199. switch (_context2.prev = _context2.next) {
  5200. case 0:
  5201. if (pageSizeInches) {
  5202. _context2.next = 2;
  5203. break;
  5204. }
  5205. return _context2.abrupt("return", undefined);
  5206. case 2:
  5207. if (pagesRotation % 180 !== 0) {
  5208. pageSizeInches = {
  5209. width: pageSizeInches.height,
  5210. height: pageSizeInches.width
  5211. };
  5212. }
  5213. isPortrait = (0, _ui_utils.isPortraitOrientation)(pageSizeInches);
  5214. sizeInches = {
  5215. width: Math.round(pageSizeInches.width * 100) / 100,
  5216. height: Math.round(pageSizeInches.height * 100) / 100
  5217. };
  5218. sizeMillimeters = {
  5219. width: Math.round(pageSizeInches.width * 25.4 * 10) / 10,
  5220. height: Math.round(pageSizeInches.height * 25.4 * 10) / 10
  5221. };
  5222. pageName = null;
  5223. name = getPageName(sizeInches, isPortrait, US_PAGE_NAMES) || getPageName(sizeMillimeters, isPortrait, METRIC_PAGE_NAMES);
  5224. if (!name && !(Number.isInteger(sizeMillimeters.width) && Number.isInteger(sizeMillimeters.height))) {
  5225. exactMillimeters = {
  5226. width: pageSizeInches.width * 25.4,
  5227. height: pageSizeInches.height * 25.4
  5228. };
  5229. intMillimeters = {
  5230. width: Math.round(sizeMillimeters.width),
  5231. height: Math.round(sizeMillimeters.height)
  5232. };
  5233. if (Math.abs(exactMillimeters.width - intMillimeters.width) < 0.1 && Math.abs(exactMillimeters.height - intMillimeters.height) < 0.1) {
  5234. name = getPageName(intMillimeters, isPortrait, METRIC_PAGE_NAMES);
  5235. if (name) {
  5236. sizeInches = {
  5237. width: Math.round(intMillimeters.width / 25.4 * 100) / 100,
  5238. height: Math.round(intMillimeters.height / 25.4 * 100) / 100
  5239. };
  5240. sizeMillimeters = intMillimeters;
  5241. }
  5242. }
  5243. }
  5244. if (name) {
  5245. pageName = this.l10n.get('document_properties_page_size_name_' + name.toLowerCase(), null, name);
  5246. }
  5247. 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) {
  5248. var _ref7 = _slicedToArray(_ref6, 4),
  5249. _ref7$ = _ref7[0],
  5250. width = _ref7$.width,
  5251. height = _ref7$.height,
  5252. unit = _ref7[1],
  5253. name = _ref7[2],
  5254. orientation = _ref7[3];
  5255. return _this3.l10n.get('document_properties_page_size_dimension_' + (name ? 'name_' : '') + 'string', {
  5256. width: width.toLocaleString(),
  5257. height: height.toLocaleString(),
  5258. unit: unit,
  5259. name: name,
  5260. orientation: orientation
  5261. }, '{{width}} × {{height}} {{unit}} (' + (name ? '{{name}}, ' : '') + '{{orientation}})');
  5262. }));
  5263. case 11:
  5264. case "end":
  5265. return _context2.stop();
  5266. }
  5267. }
  5268. }, _callee2, this);
  5269. }));
  5270. function _parsePageSize(_x, _x2) {
  5271. return _parsePageSize2.apply(this, arguments);
  5272. }
  5273. return _parsePageSize;
  5274. }()
  5275. }, {
  5276. key: "_parseDate",
  5277. value: function () {
  5278. var _parseDate2 = _asyncToGenerator(
  5279. /*#__PURE__*/
  5280. _regenerator["default"].mark(function _callee3(inputDate) {
  5281. var dateObject;
  5282. return _regenerator["default"].wrap(function _callee3$(_context3) {
  5283. while (1) {
  5284. switch (_context3.prev = _context3.next) {
  5285. case 0:
  5286. dateObject = _pdfjsLib.PDFDateString.toDateObject(inputDate);
  5287. if (dateObject) {
  5288. _context3.next = 3;
  5289. break;
  5290. }
  5291. return _context3.abrupt("return", undefined);
  5292. case 3:
  5293. return _context3.abrupt("return", this.l10n.get('document_properties_date_string', {
  5294. date: dateObject.toLocaleDateString(),
  5295. time: dateObject.toLocaleTimeString()
  5296. }, '{{date}}, {{time}}'));
  5297. case 4:
  5298. case "end":
  5299. return _context3.stop();
  5300. }
  5301. }
  5302. }, _callee3, this);
  5303. }));
  5304. function _parseDate(_x3) {
  5305. return _parseDate2.apply(this, arguments);
  5306. }
  5307. return _parseDate;
  5308. }()
  5309. }, {
  5310. key: "_parseLinearization",
  5311. value: function _parseLinearization(isLinearized) {
  5312. return this.l10n.get('document_properties_linearized_' + (isLinearized ? 'yes' : 'no'), null, isLinearized ? 'Yes' : 'No');
  5313. }
  5314. }]);
  5315. return PDFDocumentProperties;
  5316. }();
  5317. exports.PDFDocumentProperties = PDFDocumentProperties;
  5318. /***/ }),
  5319. /* 17 */
  5320. /***/ (function(module, exports, __webpack_require__) {
  5321. "use strict";
  5322. Object.defineProperty(exports, "__esModule", {
  5323. value: true
  5324. });
  5325. exports.PDFFindBar = void 0;
  5326. var _ui_utils = __webpack_require__(5);
  5327. var _pdf_find_controller = __webpack_require__(18);
  5328. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  5329. 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); } }
  5330. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  5331. var MATCHES_COUNT_LIMIT = 1000;
  5332. var PDFFindBar =
  5333. /*#__PURE__*/
  5334. function () {
  5335. function PDFFindBar(options) {
  5336. var _this = this;
  5337. var eventBus = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : (0, _ui_utils.getGlobalEventBus)();
  5338. var l10n = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : _ui_utils.NullL10n;
  5339. _classCallCheck(this, PDFFindBar);
  5340. this.opened = false;
  5341. this.bar = options.bar || null;
  5342. this.toggleButton = options.toggleButton || null;
  5343. this.findField = options.findField || null;
  5344. this.highlightAll = options.highlightAllCheckbox || null;
  5345. this.caseSensitive = options.caseSensitiveCheckbox || null;
  5346. this.entireWord = options.entireWordCheckbox || null;
  5347. this.findMsg = options.findMsg || null;
  5348. this.findResultsCount = options.findResultsCount || null;
  5349. this.findPreviousButton = options.findPreviousButton || null;
  5350. this.findNextButton = options.findNextButton || null;
  5351. this.eventBus = eventBus;
  5352. this.l10n = l10n;
  5353. this.toggleButton.addEventListener('click', function () {
  5354. _this.toggle();
  5355. });
  5356. this.findField.addEventListener('input', function () {
  5357. _this.dispatchEvent('');
  5358. });
  5359. this.bar.addEventListener('keydown', function (e) {
  5360. switch (e.keyCode) {
  5361. case 13:
  5362. if (e.target === _this.findField) {
  5363. _this.dispatchEvent('again', e.shiftKey);
  5364. }
  5365. break;
  5366. case 27:
  5367. _this.close();
  5368. break;
  5369. }
  5370. });
  5371. this.findPreviousButton.addEventListener('click', function () {
  5372. _this.dispatchEvent('again', true);
  5373. });
  5374. this.findNextButton.addEventListener('click', function () {
  5375. _this.dispatchEvent('again', false);
  5376. });
  5377. this.highlightAll.addEventListener('click', function () {
  5378. _this.dispatchEvent('highlightallchange');
  5379. });
  5380. this.caseSensitive.addEventListener('click', function () {
  5381. _this.dispatchEvent('casesensitivitychange');
  5382. });
  5383. this.entireWord.addEventListener('click', function () {
  5384. _this.dispatchEvent('entirewordchange');
  5385. });
  5386. this.eventBus.on('resize', this._adjustWidth.bind(this));
  5387. }
  5388. _createClass(PDFFindBar, [{
  5389. key: "reset",
  5390. value: function reset() {
  5391. this.updateUIState();
  5392. }
  5393. }, {
  5394. key: "dispatchEvent",
  5395. value: function dispatchEvent(type, findPrev) {
  5396. this.eventBus.dispatch('find', {
  5397. source: this,
  5398. type: type,
  5399. query: this.findField.value,
  5400. phraseSearch: true,
  5401. caseSensitive: this.caseSensitive.checked,
  5402. entireWord: this.entireWord.checked,
  5403. highlightAll: this.highlightAll.checked,
  5404. findPrevious: findPrev
  5405. });
  5406. }
  5407. }, {
  5408. key: "updateUIState",
  5409. value: function updateUIState(state, previous, matchesCount) {
  5410. var _this2 = this;
  5411. var notFound = false;
  5412. var findMsg = '';
  5413. var status = '';
  5414. switch (state) {
  5415. case _pdf_find_controller.FindState.FOUND:
  5416. break;
  5417. case _pdf_find_controller.FindState.PENDING:
  5418. status = 'pending';
  5419. break;
  5420. case _pdf_find_controller.FindState.NOT_FOUND:
  5421. findMsg = this.l10n.get('find_not_found', null, 'Phrase not found');
  5422. notFound = true;
  5423. break;
  5424. case _pdf_find_controller.FindState.WRAPPED:
  5425. if (previous) {
  5426. findMsg = this.l10n.get('find_reached_top', null, 'Reached top of document, continued from bottom');
  5427. } else {
  5428. findMsg = this.l10n.get('find_reached_bottom', null, 'Reached end of document, continued from top');
  5429. }
  5430. break;
  5431. }
  5432. this.findField.classList.toggle('notFound', notFound);
  5433. this.findField.setAttribute('data-status', status);
  5434. Promise.resolve(findMsg).then(function (msg) {
  5435. _this2.findMsg.textContent = msg;
  5436. _this2._adjustWidth();
  5437. });
  5438. this.updateResultsCount(matchesCount);
  5439. }
  5440. }, {
  5441. key: "updateResultsCount",
  5442. value: function updateResultsCount() {
  5443. var _this3 = this;
  5444. var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
  5445. _ref$current = _ref.current,
  5446. current = _ref$current === void 0 ? 0 : _ref$current,
  5447. _ref$total = _ref.total,
  5448. total = _ref$total === void 0 ? 0 : _ref$total;
  5449. if (!this.findResultsCount) {
  5450. return;
  5451. }
  5452. var matchesCountMsg = '',
  5453. limit = MATCHES_COUNT_LIMIT;
  5454. if (total > 0) {
  5455. if (total > limit) {
  5456. matchesCountMsg = this.l10n.get('find_match_count_limit', {
  5457. limit: limit
  5458. }, 'More than {{limit}} match' + (limit !== 1 ? 'es' : ''));
  5459. } else {
  5460. matchesCountMsg = this.l10n.get('find_match_count', {
  5461. current: current,
  5462. total: total
  5463. }, '{{current}} of {{total}} match' + (total !== 1 ? 'es' : ''));
  5464. }
  5465. }
  5466. Promise.resolve(matchesCountMsg).then(function (msg) {
  5467. _this3.findResultsCount.textContent = msg;
  5468. _this3.findResultsCount.classList.toggle('hidden', !total);
  5469. _this3._adjustWidth();
  5470. });
  5471. }
  5472. }, {
  5473. key: "open",
  5474. value: function open() {
  5475. if (!this.opened) {
  5476. this.opened = true;
  5477. this.toggleButton.classList.add('toggled');
  5478. this.bar.classList.remove('hidden');
  5479. }
  5480. this.findField.select();
  5481. this.findField.focus();
  5482. this._adjustWidth();
  5483. }
  5484. }, {
  5485. key: "close",
  5486. value: function close() {
  5487. if (!this.opened) {
  5488. return;
  5489. }
  5490. this.opened = false;
  5491. this.toggleButton.classList.remove('toggled');
  5492. this.bar.classList.add('hidden');
  5493. this.eventBus.dispatch('findbarclose', {
  5494. source: this
  5495. });
  5496. }
  5497. }, {
  5498. key: "toggle",
  5499. value: function toggle() {
  5500. if (this.opened) {
  5501. this.close();
  5502. } else {
  5503. this.open();
  5504. }
  5505. }
  5506. }, {
  5507. key: "_adjustWidth",
  5508. value: function _adjustWidth() {
  5509. if (!this.opened) {
  5510. return;
  5511. }
  5512. this.bar.classList.remove('wrapContainers');
  5513. var findbarHeight = this.bar.clientHeight;
  5514. var inputContainerHeight = this.bar.firstElementChild.clientHeight;
  5515. if (findbarHeight > inputContainerHeight) {
  5516. this.bar.classList.add('wrapContainers');
  5517. }
  5518. }
  5519. }]);
  5520. return PDFFindBar;
  5521. }();
  5522. exports.PDFFindBar = PDFFindBar;
  5523. /***/ }),
  5524. /* 18 */
  5525. /***/ (function(module, exports, __webpack_require__) {
  5526. "use strict";
  5527. Object.defineProperty(exports, "__esModule", {
  5528. value: true
  5529. });
  5530. exports.PDFFindController = exports.FindState = void 0;
  5531. var _ui_utils = __webpack_require__(5);
  5532. var _pdfjsLib = __webpack_require__(7);
  5533. var _pdf_find_utils = __webpack_require__(19);
  5534. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  5535. 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); } }
  5536. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  5537. var FindState = {
  5538. FOUND: 0,
  5539. NOT_FOUND: 1,
  5540. WRAPPED: 2,
  5541. PENDING: 3
  5542. };
  5543. exports.FindState = FindState;
  5544. var FIND_TIMEOUT = 250;
  5545. var MATCH_SCROLL_OFFSET_TOP = -50;
  5546. var MATCH_SCROLL_OFFSET_LEFT = -400;
  5547. var CHARACTERS_TO_NORMALIZE = {
  5548. "\u2018": '\'',
  5549. "\u2019": '\'',
  5550. "\u201A": '\'',
  5551. "\u201B": '\'',
  5552. "\u201C": '"',
  5553. "\u201D": '"',
  5554. "\u201E": '"',
  5555. "\u201F": '"',
  5556. "\xBC": '1/4',
  5557. "\xBD": '1/2',
  5558. "\xBE": '3/4'
  5559. };
  5560. var normalizationRegex = null;
  5561. function normalize(text) {
  5562. if (!normalizationRegex) {
  5563. var replace = Object.keys(CHARACTERS_TO_NORMALIZE).join('');
  5564. normalizationRegex = new RegExp("[".concat(replace, "]"), 'g');
  5565. }
  5566. return text.replace(normalizationRegex, function (ch) {
  5567. return CHARACTERS_TO_NORMALIZE[ch];
  5568. });
  5569. }
  5570. var PDFFindController =
  5571. /*#__PURE__*/
  5572. function () {
  5573. function PDFFindController(_ref) {
  5574. var linkService = _ref.linkService,
  5575. _ref$eventBus = _ref.eventBus,
  5576. eventBus = _ref$eventBus === void 0 ? (0, _ui_utils.getGlobalEventBus)() : _ref$eventBus;
  5577. _classCallCheck(this, PDFFindController);
  5578. this._linkService = linkService;
  5579. this._eventBus = eventBus;
  5580. this._reset();
  5581. eventBus.on('findbarclose', this._onFindBarClose.bind(this));
  5582. }
  5583. _createClass(PDFFindController, [{
  5584. key: "setDocument",
  5585. value: function setDocument(pdfDocument) {
  5586. if (this._pdfDocument) {
  5587. this._reset();
  5588. }
  5589. if (!pdfDocument) {
  5590. return;
  5591. }
  5592. this._pdfDocument = pdfDocument;
  5593. this._firstPageCapability.resolve();
  5594. }
  5595. }, {
  5596. key: "executeCommand",
  5597. value: function executeCommand(cmd, state) {
  5598. var _this = this;
  5599. if (!state) {
  5600. return;
  5601. }
  5602. var pdfDocument = this._pdfDocument;
  5603. if (this._state === null || this._shouldDirtyMatch(cmd, state)) {
  5604. this._dirtyMatch = true;
  5605. }
  5606. this._state = state;
  5607. if (cmd !== 'findhighlightallchange') {
  5608. this._updateUIState(FindState.PENDING);
  5609. }
  5610. this._firstPageCapability.promise.then(function () {
  5611. if (!_this._pdfDocument || pdfDocument && _this._pdfDocument !== pdfDocument) {
  5612. return;
  5613. }
  5614. _this._extractText();
  5615. var findbarClosed = !_this._highlightMatches;
  5616. var pendingTimeout = !!_this._findTimeout;
  5617. if (_this._findTimeout) {
  5618. clearTimeout(_this._findTimeout);
  5619. _this._findTimeout = null;
  5620. }
  5621. if (cmd === 'find') {
  5622. _this._findTimeout = setTimeout(function () {
  5623. _this._nextMatch();
  5624. _this._findTimeout = null;
  5625. }, FIND_TIMEOUT);
  5626. } else if (_this._dirtyMatch) {
  5627. _this._nextMatch();
  5628. } else if (cmd === 'findagain') {
  5629. _this._nextMatch();
  5630. if (findbarClosed && _this._state.highlightAll) {
  5631. _this._updateAllPages();
  5632. }
  5633. } else if (cmd === 'findhighlightallchange') {
  5634. if (pendingTimeout) {
  5635. _this._nextMatch();
  5636. } else {
  5637. _this._highlightMatches = true;
  5638. }
  5639. _this._updateAllPages();
  5640. } else {
  5641. _this._nextMatch();
  5642. }
  5643. });
  5644. }
  5645. }, {
  5646. key: "scrollMatchIntoView",
  5647. value: function scrollMatchIntoView(_ref2) {
  5648. var _ref2$element = _ref2.element,
  5649. element = _ref2$element === void 0 ? null : _ref2$element,
  5650. _ref2$pageIndex = _ref2.pageIndex,
  5651. pageIndex = _ref2$pageIndex === void 0 ? -1 : _ref2$pageIndex,
  5652. _ref2$matchIndex = _ref2.matchIndex,
  5653. matchIndex = _ref2$matchIndex === void 0 ? -1 : _ref2$matchIndex;
  5654. if (!this._scrollMatches || !element) {
  5655. return;
  5656. } else if (matchIndex === -1 || matchIndex !== this._selected.matchIdx) {
  5657. return;
  5658. } else if (pageIndex === -1 || pageIndex !== this._selected.pageIdx) {
  5659. return;
  5660. }
  5661. this._scrollMatches = false;
  5662. var spot = {
  5663. top: MATCH_SCROLL_OFFSET_TOP,
  5664. left: MATCH_SCROLL_OFFSET_LEFT
  5665. };
  5666. (0, _ui_utils.scrollIntoView)(element, spot, true);
  5667. }
  5668. }, {
  5669. key: "_reset",
  5670. value: function _reset() {
  5671. this._highlightMatches = false;
  5672. this._scrollMatches = false;
  5673. this._pdfDocument = null;
  5674. this._pageMatches = [];
  5675. this._pageMatchesLength = [];
  5676. this._state = null;
  5677. this._selected = {
  5678. pageIdx: -1,
  5679. matchIdx: -1
  5680. };
  5681. this._offset = {
  5682. pageIdx: null,
  5683. matchIdx: null,
  5684. wrapped: false
  5685. };
  5686. this._extractTextPromises = [];
  5687. this._pageContents = [];
  5688. this._matchesCountTotal = 0;
  5689. this._pagesToSearch = null;
  5690. this._pendingFindMatches = Object.create(null);
  5691. this._resumePageIdx = null;
  5692. this._dirtyMatch = false;
  5693. clearTimeout(this._findTimeout);
  5694. this._findTimeout = null;
  5695. this._firstPageCapability = (0, _pdfjsLib.createPromiseCapability)();
  5696. }
  5697. }, {
  5698. key: "_shouldDirtyMatch",
  5699. value: function _shouldDirtyMatch(cmd, state) {
  5700. if (state.query !== this._state.query) {
  5701. return true;
  5702. }
  5703. switch (cmd) {
  5704. case 'findagain':
  5705. var pageNumber = this._selected.pageIdx + 1;
  5706. var linkService = this._linkService;
  5707. if (pageNumber >= 1 && pageNumber <= linkService.pagesCount && pageNumber !== linkService.page && !linkService.isPageVisible(pageNumber)) {
  5708. return true;
  5709. }
  5710. return false;
  5711. case 'findhighlightallchange':
  5712. return false;
  5713. }
  5714. return true;
  5715. }
  5716. }, {
  5717. key: "_prepareMatches",
  5718. value: function _prepareMatches(matchesWithLength, matches, matchesLength) {
  5719. function isSubTerm(matchesWithLength, currentIndex) {
  5720. var currentElem = matchesWithLength[currentIndex];
  5721. var nextElem = matchesWithLength[currentIndex + 1];
  5722. if (currentIndex < matchesWithLength.length - 1 && currentElem.match === nextElem.match) {
  5723. currentElem.skipped = true;
  5724. return true;
  5725. }
  5726. for (var i = currentIndex - 1; i >= 0; i--) {
  5727. var prevElem = matchesWithLength[i];
  5728. if (prevElem.skipped) {
  5729. continue;
  5730. }
  5731. if (prevElem.match + prevElem.matchLength < currentElem.match) {
  5732. break;
  5733. }
  5734. if (prevElem.match + prevElem.matchLength >= currentElem.match + currentElem.matchLength) {
  5735. currentElem.skipped = true;
  5736. return true;
  5737. }
  5738. }
  5739. return false;
  5740. }
  5741. matchesWithLength.sort(function (a, b) {
  5742. return a.match === b.match ? a.matchLength - b.matchLength : a.match - b.match;
  5743. });
  5744. for (var i = 0, len = matchesWithLength.length; i < len; i++) {
  5745. if (isSubTerm(matchesWithLength, i)) {
  5746. continue;
  5747. }
  5748. matches.push(matchesWithLength[i].match);
  5749. matchesLength.push(matchesWithLength[i].matchLength);
  5750. }
  5751. }
  5752. }, {
  5753. key: "_isEntireWord",
  5754. value: function _isEntireWord(content, startIdx, length) {
  5755. if (startIdx > 0) {
  5756. var first = content.charCodeAt(startIdx);
  5757. var limit = content.charCodeAt(startIdx - 1);
  5758. if ((0, _pdf_find_utils.getCharacterType)(first) === (0, _pdf_find_utils.getCharacterType)(limit)) {
  5759. return false;
  5760. }
  5761. }
  5762. var endIdx = startIdx + length - 1;
  5763. if (endIdx < content.length - 1) {
  5764. var last = content.charCodeAt(endIdx);
  5765. var _limit = content.charCodeAt(endIdx + 1);
  5766. if ((0, _pdf_find_utils.getCharacterType)(last) === (0, _pdf_find_utils.getCharacterType)(_limit)) {
  5767. return false;
  5768. }
  5769. }
  5770. return true;
  5771. }
  5772. }, {
  5773. key: "_calculatePhraseMatch",
  5774. value: function _calculatePhraseMatch(query, pageIndex, pageContent, entireWord) {
  5775. var matches = [];
  5776. var queryLen = query.length;
  5777. var matchIdx = -queryLen;
  5778. while (true) {
  5779. matchIdx = pageContent.indexOf(query, matchIdx + queryLen);
  5780. if (matchIdx === -1) {
  5781. break;
  5782. }
  5783. if (entireWord && !this._isEntireWord(pageContent, matchIdx, queryLen)) {
  5784. continue;
  5785. }
  5786. matches.push(matchIdx);
  5787. }
  5788. this._pageMatches[pageIndex] = matches;
  5789. }
  5790. }, {
  5791. key: "_calculateWordMatch",
  5792. value: function _calculateWordMatch(query, pageIndex, pageContent, entireWord) {
  5793. var matchesWithLength = [];
  5794. var queryArray = query.match(/\S+/g);
  5795. for (var i = 0, len = queryArray.length; i < len; i++) {
  5796. var subquery = queryArray[i];
  5797. var subqueryLen = subquery.length;
  5798. var matchIdx = -subqueryLen;
  5799. while (true) {
  5800. matchIdx = pageContent.indexOf(subquery, matchIdx + subqueryLen);
  5801. if (matchIdx === -1) {
  5802. break;
  5803. }
  5804. if (entireWord && !this._isEntireWord(pageContent, matchIdx, subqueryLen)) {
  5805. continue;
  5806. }
  5807. matchesWithLength.push({
  5808. match: matchIdx,
  5809. matchLength: subqueryLen,
  5810. skipped: false
  5811. });
  5812. }
  5813. }
  5814. this._pageMatchesLength[pageIndex] = [];
  5815. this._pageMatches[pageIndex] = [];
  5816. this._prepareMatches(matchesWithLength, this._pageMatches[pageIndex], this._pageMatchesLength[pageIndex]);
  5817. }
  5818. }, {
  5819. key: "_calculateMatch",
  5820. value: function _calculateMatch(pageIndex) {
  5821. var pageContent = this._pageContents[pageIndex];
  5822. var query = this._query;
  5823. var _this$_state = this._state,
  5824. caseSensitive = _this$_state.caseSensitive,
  5825. entireWord = _this$_state.entireWord,
  5826. phraseSearch = _this$_state.phraseSearch;
  5827. if (query.length === 0) {
  5828. return;
  5829. }
  5830. if (!caseSensitive) {
  5831. pageContent = pageContent.toLowerCase();
  5832. query = query.toLowerCase();
  5833. }
  5834. if (phraseSearch) {
  5835. this._calculatePhraseMatch(query, pageIndex, pageContent, entireWord);
  5836. } else {
  5837. this._calculateWordMatch(query, pageIndex, pageContent, entireWord);
  5838. }
  5839. if (this._state.highlightAll) {
  5840. this._updatePage(pageIndex);
  5841. }
  5842. if (this._resumePageIdx === pageIndex) {
  5843. this._resumePageIdx = null;
  5844. this._nextPageMatch();
  5845. }
  5846. var pageMatchesCount = this._pageMatches[pageIndex].length;
  5847. if (pageMatchesCount > 0) {
  5848. this._matchesCountTotal += pageMatchesCount;
  5849. this._updateUIResultsCount();
  5850. }
  5851. }
  5852. }, {
  5853. key: "_extractText",
  5854. value: function _extractText() {
  5855. var _this2 = this;
  5856. if (this._extractTextPromises.length > 0) {
  5857. return;
  5858. }
  5859. var promise = Promise.resolve();
  5860. var _loop = function _loop(i, ii) {
  5861. var extractTextCapability = (0, _pdfjsLib.createPromiseCapability)();
  5862. _this2._extractTextPromises[i] = extractTextCapability.promise;
  5863. promise = promise.then(function () {
  5864. return _this2._pdfDocument.getPage(i + 1).then(function (pdfPage) {
  5865. return pdfPage.getTextContent({
  5866. normalizeWhitespace: true
  5867. });
  5868. }).then(function (textContent) {
  5869. var textItems = textContent.items;
  5870. var strBuf = [];
  5871. for (var j = 0, jj = textItems.length; j < jj; j++) {
  5872. strBuf.push(textItems[j].str);
  5873. }
  5874. _this2._pageContents[i] = normalize(strBuf.join(''));
  5875. extractTextCapability.resolve(i);
  5876. }, function (reason) {
  5877. console.error("Unable to get text content for page ".concat(i + 1), reason);
  5878. _this2._pageContents[i] = '';
  5879. extractTextCapability.resolve(i);
  5880. });
  5881. });
  5882. };
  5883. for (var i = 0, ii = this._linkService.pagesCount; i < ii; i++) {
  5884. _loop(i, ii);
  5885. }
  5886. }
  5887. }, {
  5888. key: "_updatePage",
  5889. value: function _updatePage(index) {
  5890. if (this._scrollMatches && this._selected.pageIdx === index) {
  5891. this._linkService.page = index + 1;
  5892. }
  5893. this._eventBus.dispatch('updatetextlayermatches', {
  5894. source: this,
  5895. pageIndex: index
  5896. });
  5897. }
  5898. }, {
  5899. key: "_updateAllPages",
  5900. value: function _updateAllPages() {
  5901. this._eventBus.dispatch('updatetextlayermatches', {
  5902. source: this,
  5903. pageIndex: -1
  5904. });
  5905. }
  5906. }, {
  5907. key: "_nextMatch",
  5908. value: function _nextMatch() {
  5909. var _this3 = this;
  5910. var previous = this._state.findPrevious;
  5911. var currentPageIndex = this._linkService.page - 1;
  5912. var numPages = this._linkService.pagesCount;
  5913. this._highlightMatches = true;
  5914. if (this._dirtyMatch) {
  5915. this._dirtyMatch = false;
  5916. this._selected.pageIdx = this._selected.matchIdx = -1;
  5917. this._offset.pageIdx = currentPageIndex;
  5918. this._offset.matchIdx = null;
  5919. this._offset.wrapped = false;
  5920. this._resumePageIdx = null;
  5921. this._pageMatches.length = 0;
  5922. this._pageMatchesLength.length = 0;
  5923. this._matchesCountTotal = 0;
  5924. this._updateAllPages();
  5925. for (var i = 0; i < numPages; i++) {
  5926. if (this._pendingFindMatches[i] === true) {
  5927. continue;
  5928. }
  5929. this._pendingFindMatches[i] = true;
  5930. this._extractTextPromises[i].then(function (pageIdx) {
  5931. delete _this3._pendingFindMatches[pageIdx];
  5932. _this3._calculateMatch(pageIdx);
  5933. });
  5934. }
  5935. }
  5936. if (this._query === '') {
  5937. this._updateUIState(FindState.FOUND);
  5938. return;
  5939. }
  5940. if (this._resumePageIdx) {
  5941. return;
  5942. }
  5943. var offset = this._offset;
  5944. this._pagesToSearch = numPages;
  5945. if (offset.matchIdx !== null) {
  5946. var numPageMatches = this._pageMatches[offset.pageIdx].length;
  5947. if (!previous && offset.matchIdx + 1 < numPageMatches || previous && offset.matchIdx > 0) {
  5948. offset.matchIdx = previous ? offset.matchIdx - 1 : offset.matchIdx + 1;
  5949. this._updateMatch(true);
  5950. return;
  5951. }
  5952. this._advanceOffsetPage(previous);
  5953. }
  5954. this._nextPageMatch();
  5955. }
  5956. }, {
  5957. key: "_matchesReady",
  5958. value: function _matchesReady(matches) {
  5959. var offset = this._offset;
  5960. var numMatches = matches.length;
  5961. var previous = this._state.findPrevious;
  5962. if (numMatches) {
  5963. offset.matchIdx = previous ? numMatches - 1 : 0;
  5964. this._updateMatch(true);
  5965. return true;
  5966. }
  5967. this._advanceOffsetPage(previous);
  5968. if (offset.wrapped) {
  5969. offset.matchIdx = null;
  5970. if (this._pagesToSearch < 0) {
  5971. this._updateMatch(false);
  5972. return true;
  5973. }
  5974. }
  5975. return false;
  5976. }
  5977. }, {
  5978. key: "_nextPageMatch",
  5979. value: function _nextPageMatch() {
  5980. if (this._resumePageIdx !== null) {
  5981. console.error('There can only be one pending page.');
  5982. }
  5983. var matches = null;
  5984. do {
  5985. var pageIdx = this._offset.pageIdx;
  5986. matches = this._pageMatches[pageIdx];
  5987. if (!matches) {
  5988. this._resumePageIdx = pageIdx;
  5989. break;
  5990. }
  5991. } while (!this._matchesReady(matches));
  5992. }
  5993. }, {
  5994. key: "_advanceOffsetPage",
  5995. value: function _advanceOffsetPage(previous) {
  5996. var offset = this._offset;
  5997. var numPages = this._linkService.pagesCount;
  5998. offset.pageIdx = previous ? offset.pageIdx - 1 : offset.pageIdx + 1;
  5999. offset.matchIdx = null;
  6000. this._pagesToSearch--;
  6001. if (offset.pageIdx >= numPages || offset.pageIdx < 0) {
  6002. offset.pageIdx = previous ? numPages - 1 : 0;
  6003. offset.wrapped = true;
  6004. }
  6005. }
  6006. }, {
  6007. key: "_updateMatch",
  6008. value: function _updateMatch() {
  6009. var found = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  6010. var state = FindState.NOT_FOUND;
  6011. var wrapped = this._offset.wrapped;
  6012. this._offset.wrapped = false;
  6013. if (found) {
  6014. var previousPage = this._selected.pageIdx;
  6015. this._selected.pageIdx = this._offset.pageIdx;
  6016. this._selected.matchIdx = this._offset.matchIdx;
  6017. state = wrapped ? FindState.WRAPPED : FindState.FOUND;
  6018. if (previousPage !== -1 && previousPage !== this._selected.pageIdx) {
  6019. this._updatePage(previousPage);
  6020. }
  6021. }
  6022. this._updateUIState(state, this._state.findPrevious);
  6023. if (this._selected.pageIdx !== -1) {
  6024. this._scrollMatches = true;
  6025. this._updatePage(this._selected.pageIdx);
  6026. }
  6027. }
  6028. }, {
  6029. key: "_onFindBarClose",
  6030. value: function _onFindBarClose(evt) {
  6031. var _this4 = this;
  6032. var pdfDocument = this._pdfDocument;
  6033. this._firstPageCapability.promise.then(function () {
  6034. if (!_this4._pdfDocument || pdfDocument && _this4._pdfDocument !== pdfDocument) {
  6035. return;
  6036. }
  6037. if (_this4._findTimeout) {
  6038. clearTimeout(_this4._findTimeout);
  6039. _this4._findTimeout = null;
  6040. }
  6041. if (_this4._resumePageIdx) {
  6042. _this4._resumePageIdx = null;
  6043. _this4._dirtyMatch = true;
  6044. }
  6045. _this4._updateUIState(FindState.FOUND);
  6046. _this4._highlightMatches = false;
  6047. _this4._updateAllPages();
  6048. });
  6049. }
  6050. }, {
  6051. key: "_requestMatchesCount",
  6052. value: function _requestMatchesCount() {
  6053. var _this$_selected = this._selected,
  6054. pageIdx = _this$_selected.pageIdx,
  6055. matchIdx = _this$_selected.matchIdx;
  6056. var current = 0,
  6057. total = this._matchesCountTotal;
  6058. if (matchIdx !== -1) {
  6059. for (var i = 0; i < pageIdx; i++) {
  6060. current += this._pageMatches[i] && this._pageMatches[i].length || 0;
  6061. }
  6062. current += matchIdx + 1;
  6063. }
  6064. if (current < 1 || current > total) {
  6065. current = total = 0;
  6066. }
  6067. return {
  6068. current: current,
  6069. total: total
  6070. };
  6071. }
  6072. }, {
  6073. key: "_updateUIResultsCount",
  6074. value: function _updateUIResultsCount() {
  6075. this._eventBus.dispatch('updatefindmatchescount', {
  6076. source: this,
  6077. matchesCount: this._requestMatchesCount()
  6078. });
  6079. }
  6080. }, {
  6081. key: "_updateUIState",
  6082. value: function _updateUIState(state, previous) {
  6083. this._eventBus.dispatch('updatefindcontrolstate', {
  6084. source: this,
  6085. state: state,
  6086. previous: previous,
  6087. matchesCount: this._requestMatchesCount()
  6088. });
  6089. }
  6090. }, {
  6091. key: "highlightMatches",
  6092. get: function get() {
  6093. return this._highlightMatches;
  6094. }
  6095. }, {
  6096. key: "pageMatches",
  6097. get: function get() {
  6098. return this._pageMatches;
  6099. }
  6100. }, {
  6101. key: "pageMatchesLength",
  6102. get: function get() {
  6103. return this._pageMatchesLength;
  6104. }
  6105. }, {
  6106. key: "selected",
  6107. get: function get() {
  6108. return this._selected;
  6109. }
  6110. }, {
  6111. key: "state",
  6112. get: function get() {
  6113. return this._state;
  6114. }
  6115. }, {
  6116. key: "_query",
  6117. get: function get() {
  6118. if (this._state.query !== this._rawQuery) {
  6119. this._rawQuery = this._state.query;
  6120. this._normalizedQuery = normalize(this._state.query);
  6121. }
  6122. return this._normalizedQuery;
  6123. }
  6124. }]);
  6125. return PDFFindController;
  6126. }();
  6127. exports.PDFFindController = PDFFindController;
  6128. /***/ }),
  6129. /* 19 */
  6130. /***/ (function(module, exports, __webpack_require__) {
  6131. "use strict";
  6132. Object.defineProperty(exports, "__esModule", {
  6133. value: true
  6134. });
  6135. exports.getCharacterType = getCharacterType;
  6136. exports.CharacterType = void 0;
  6137. var CharacterType = {
  6138. SPACE: 0,
  6139. ALPHA_LETTER: 1,
  6140. PUNCT: 2,
  6141. HAN_LETTER: 3,
  6142. KATAKANA_LETTER: 4,
  6143. HIRAGANA_LETTER: 5,
  6144. HALFWIDTH_KATAKANA_LETTER: 6,
  6145. THAI_LETTER: 7
  6146. };
  6147. exports.CharacterType = CharacterType;
  6148. function isAlphabeticalScript(charCode) {
  6149. return charCode < 0x2E80;
  6150. }
  6151. function isAscii(charCode) {
  6152. return (charCode & 0xFF80) === 0;
  6153. }
  6154. function isAsciiAlpha(charCode) {
  6155. return charCode >= 0x61 && charCode <= 0x7A || charCode >= 0x41 && charCode <= 0x5A;
  6156. }
  6157. function isAsciiDigit(charCode) {
  6158. return charCode >= 0x30 && charCode <= 0x39;
  6159. }
  6160. function isAsciiSpace(charCode) {
  6161. return charCode === 0x20 || charCode === 0x09 || charCode === 0x0D || charCode === 0x0A;
  6162. }
  6163. function isHan(charCode) {
  6164. return charCode >= 0x3400 && charCode <= 0x9FFF || charCode >= 0xF900 && charCode <= 0xFAFF;
  6165. }
  6166. function isKatakana(charCode) {
  6167. return charCode >= 0x30A0 && charCode <= 0x30FF;
  6168. }
  6169. function isHiragana(charCode) {
  6170. return charCode >= 0x3040 && charCode <= 0x309F;
  6171. }
  6172. function isHalfwidthKatakana(charCode) {
  6173. return charCode >= 0xFF60 && charCode <= 0xFF9F;
  6174. }
  6175. function isThai(charCode) {
  6176. return (charCode & 0xFF80) === 0x0E00;
  6177. }
  6178. function getCharacterType(charCode) {
  6179. if (isAlphabeticalScript(charCode)) {
  6180. if (isAscii(charCode)) {
  6181. if (isAsciiSpace(charCode)) {
  6182. return CharacterType.SPACE;
  6183. } else if (isAsciiAlpha(charCode) || isAsciiDigit(charCode) || charCode === 0x5F) {
  6184. return CharacterType.ALPHA_LETTER;
  6185. }
  6186. return CharacterType.PUNCT;
  6187. } else if (isThai(charCode)) {
  6188. return CharacterType.THAI_LETTER;
  6189. } else if (charCode === 0xA0) {
  6190. return CharacterType.SPACE;
  6191. }
  6192. return CharacterType.ALPHA_LETTER;
  6193. }
  6194. if (isHan(charCode)) {
  6195. return CharacterType.HAN_LETTER;
  6196. } else if (isKatakana(charCode)) {
  6197. return CharacterType.KATAKANA_LETTER;
  6198. } else if (isHiragana(charCode)) {
  6199. return CharacterType.HIRAGANA_LETTER;
  6200. } else if (isHalfwidthKatakana(charCode)) {
  6201. return CharacterType.HALFWIDTH_KATAKANA_LETTER;
  6202. }
  6203. return CharacterType.ALPHA_LETTER;
  6204. }
  6205. /***/ }),
  6206. /* 20 */
  6207. /***/ (function(module, exports, __webpack_require__) {
  6208. "use strict";
  6209. Object.defineProperty(exports, "__esModule", {
  6210. value: true
  6211. });
  6212. exports.isDestHashesEqual = isDestHashesEqual;
  6213. exports.isDestArraysEqual = isDestArraysEqual;
  6214. exports.PDFHistory = void 0;
  6215. var _ui_utils = __webpack_require__(5);
  6216. function _typeof(obj) { 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); }
  6217. function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); }
  6218. function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance"); }
  6219. function _iterableToArrayLimit(arr, i) { if (!(Symbol.iterator in Object(arr) || Object.prototype.toString.call(arr) === "[object Arguments]")) { 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; }
  6220. function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
  6221. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  6222. 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); } }
  6223. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  6224. var HASH_CHANGE_TIMEOUT = 1000;
  6225. var POSITION_UPDATED_THRESHOLD = 50;
  6226. var UPDATE_VIEWAREA_TIMEOUT = 1000;
  6227. function getCurrentHash() {
  6228. return document.location.hash;
  6229. }
  6230. function parseCurrentHash(linkService) {
  6231. var hash = unescape(getCurrentHash()).substring(1);
  6232. var params = (0, _ui_utils.parseQueryString)(hash);
  6233. var page = params.page | 0;
  6234. if (!(Number.isInteger(page) && page > 0 && page <= linkService.pagesCount)) {
  6235. page = null;
  6236. }
  6237. return {
  6238. hash: hash,
  6239. page: page,
  6240. rotation: linkService.rotation
  6241. };
  6242. }
  6243. var PDFHistory =
  6244. /*#__PURE__*/
  6245. function () {
  6246. function PDFHistory(_ref) {
  6247. var _this = this;
  6248. var linkService = _ref.linkService,
  6249. eventBus = _ref.eventBus;
  6250. _classCallCheck(this, PDFHistory);
  6251. this.linkService = linkService;
  6252. this.eventBus = eventBus || (0, _ui_utils.getGlobalEventBus)();
  6253. this.initialized = false;
  6254. this.initialBookmark = null;
  6255. this.initialRotation = null;
  6256. this._boundEvents = Object.create(null);
  6257. this._isViewerInPresentationMode = false;
  6258. this._isPagesLoaded = false;
  6259. this.eventBus.on('presentationmodechanged', function (evt) {
  6260. _this._isViewerInPresentationMode = evt.active || evt.switchInProgress;
  6261. });
  6262. this.eventBus.on('pagesloaded', function (evt) {
  6263. _this._isPagesLoaded = !!evt.pagesCount;
  6264. });
  6265. }
  6266. _createClass(PDFHistory, [{
  6267. key: "initialize",
  6268. value: function initialize(_ref2) {
  6269. var fingerprint = _ref2.fingerprint,
  6270. _ref2$resetHistory = _ref2.resetHistory,
  6271. resetHistory = _ref2$resetHistory === void 0 ? false : _ref2$resetHistory,
  6272. _ref2$updateUrl = _ref2.updateUrl,
  6273. updateUrl = _ref2$updateUrl === void 0 ? false : _ref2$updateUrl;
  6274. if (!fingerprint || typeof fingerprint !== 'string') {
  6275. console.error('PDFHistory.initialize: The "fingerprint" must be a non-empty string.');
  6276. return;
  6277. }
  6278. var reInitialized = this.initialized && this.fingerprint !== fingerprint;
  6279. this.fingerprint = fingerprint;
  6280. this._updateUrl = updateUrl === true;
  6281. if (!this.initialized) {
  6282. this._bindEvents();
  6283. }
  6284. var state = window.history.state;
  6285. this.initialized = true;
  6286. this.initialBookmark = null;
  6287. this.initialRotation = null;
  6288. this._popStateInProgress = false;
  6289. this._blockHashChange = 0;
  6290. this._currentHash = getCurrentHash();
  6291. this._numPositionUpdates = 0;
  6292. this._uid = this._maxUid = 0;
  6293. this._destination = null;
  6294. this._position = null;
  6295. if (!this._isValidState(state, true) || resetHistory) {
  6296. var _parseCurrentHash = parseCurrentHash(this.linkService),
  6297. hash = _parseCurrentHash.hash,
  6298. page = _parseCurrentHash.page,
  6299. rotation = _parseCurrentHash.rotation;
  6300. if (!hash || reInitialized || resetHistory) {
  6301. this._pushOrReplaceState(null, true);
  6302. return;
  6303. }
  6304. this._pushOrReplaceState({
  6305. hash: hash,
  6306. page: page,
  6307. rotation: rotation
  6308. }, true);
  6309. return;
  6310. }
  6311. var destination = state.destination;
  6312. this._updateInternalState(destination, state.uid, true);
  6313. if (this._uid > this._maxUid) {
  6314. this._maxUid = this._uid;
  6315. }
  6316. if (destination.rotation !== undefined) {
  6317. this.initialRotation = destination.rotation;
  6318. }
  6319. if (destination.dest) {
  6320. this.initialBookmark = JSON.stringify(destination.dest);
  6321. this._destination.page = null;
  6322. } else if (destination.hash) {
  6323. this.initialBookmark = destination.hash;
  6324. } else if (destination.page) {
  6325. this.initialBookmark = "page=".concat(destination.page);
  6326. }
  6327. }
  6328. }, {
  6329. key: "push",
  6330. value: function push(_ref3) {
  6331. var _this2 = this;
  6332. var _ref3$namedDest = _ref3.namedDest,
  6333. namedDest = _ref3$namedDest === void 0 ? null : _ref3$namedDest,
  6334. explicitDest = _ref3.explicitDest,
  6335. pageNumber = _ref3.pageNumber;
  6336. if (!this.initialized) {
  6337. return;
  6338. }
  6339. if (namedDest && typeof namedDest !== 'string') {
  6340. console.error('PDFHistory.push: ' + "\"".concat(namedDest, "\" is not a valid namedDest parameter."));
  6341. return;
  6342. } else if (!Array.isArray(explicitDest)) {
  6343. console.error('PDFHistory.push: ' + "\"".concat(explicitDest, "\" is not a valid explicitDest parameter."));
  6344. return;
  6345. } else if (!(Number.isInteger(pageNumber) && pageNumber > 0 && pageNumber <= this.linkService.pagesCount)) {
  6346. if (pageNumber !== null || this._destination) {
  6347. console.error('PDFHistory.push: ' + "\"".concat(pageNumber, "\" is not a valid pageNumber parameter."));
  6348. return;
  6349. }
  6350. }
  6351. var hash = namedDest || JSON.stringify(explicitDest);
  6352. if (!hash) {
  6353. return;
  6354. }
  6355. var forceReplace = false;
  6356. if (this._destination && (isDestHashesEqual(this._destination.hash, hash) || isDestArraysEqual(this._destination.dest, explicitDest))) {
  6357. if (this._destination.page) {
  6358. return;
  6359. }
  6360. forceReplace = true;
  6361. }
  6362. if (this._popStateInProgress && !forceReplace) {
  6363. return;
  6364. }
  6365. this._pushOrReplaceState({
  6366. dest: explicitDest,
  6367. hash: hash,
  6368. page: pageNumber,
  6369. rotation: this.linkService.rotation
  6370. }, forceReplace);
  6371. if (!this._popStateInProgress) {
  6372. this._popStateInProgress = true;
  6373. Promise.resolve().then(function () {
  6374. _this2._popStateInProgress = false;
  6375. });
  6376. }
  6377. }
  6378. }, {
  6379. key: "pushCurrentPosition",
  6380. value: function pushCurrentPosition() {
  6381. if (!this.initialized || this._popStateInProgress) {
  6382. return;
  6383. }
  6384. this._tryPushCurrentPosition();
  6385. }
  6386. }, {
  6387. key: "back",
  6388. value: function back() {
  6389. if (!this.initialized || this._popStateInProgress) {
  6390. return;
  6391. }
  6392. var state = window.history.state;
  6393. if (this._isValidState(state) && state.uid > 0) {
  6394. window.history.back();
  6395. }
  6396. }
  6397. }, {
  6398. key: "forward",
  6399. value: function forward() {
  6400. if (!this.initialized || this._popStateInProgress) {
  6401. return;
  6402. }
  6403. var state = window.history.state;
  6404. if (this._isValidState(state) && state.uid < this._maxUid) {
  6405. window.history.forward();
  6406. }
  6407. }
  6408. }, {
  6409. key: "_pushOrReplaceState",
  6410. value: function _pushOrReplaceState(destination) {
  6411. var forceReplace = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  6412. var shouldReplace = forceReplace || !this._destination;
  6413. var newState = {
  6414. fingerprint: this.fingerprint,
  6415. uid: shouldReplace ? this._uid : this._uid + 1,
  6416. destination: destination
  6417. };
  6418. this._updateInternalState(destination, newState.uid);
  6419. var newUrl;
  6420. if (this._updateUrl && destination && destination.hash) {
  6421. var baseUrl = document.location.href.split('#')[0];
  6422. if (!baseUrl.startsWith('file://')) {
  6423. newUrl = "".concat(baseUrl, "#").concat(destination.hash);
  6424. }
  6425. }
  6426. if (shouldReplace) {
  6427. if (newUrl) {
  6428. window.history.replaceState(newState, '', newUrl);
  6429. } else {
  6430. window.history.replaceState(newState, '');
  6431. }
  6432. } else {
  6433. this._maxUid = this._uid;
  6434. if (newUrl) {
  6435. window.history.pushState(newState, '', newUrl);
  6436. } else {
  6437. window.history.pushState(newState, '');
  6438. }
  6439. }
  6440. }
  6441. }, {
  6442. key: "_tryPushCurrentPosition",
  6443. value: function _tryPushCurrentPosition() {
  6444. var temporary = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  6445. if (!this._position) {
  6446. return;
  6447. }
  6448. var position = this._position;
  6449. if (temporary) {
  6450. position = Object.assign(Object.create(null), this._position);
  6451. position.temporary = true;
  6452. }
  6453. if (!this._destination) {
  6454. this._pushOrReplaceState(position);
  6455. return;
  6456. }
  6457. if (this._destination.temporary) {
  6458. this._pushOrReplaceState(position, true);
  6459. return;
  6460. }
  6461. if (this._destination.hash === position.hash) {
  6462. return;
  6463. }
  6464. if (!this._destination.page && (POSITION_UPDATED_THRESHOLD <= 0 || this._numPositionUpdates <= POSITION_UPDATED_THRESHOLD)) {
  6465. return;
  6466. }
  6467. var forceReplace = false;
  6468. if (this._destination.page >= position.first && this._destination.page <= position.page) {
  6469. if (this._destination.dest || !this._destination.first) {
  6470. return;
  6471. }
  6472. forceReplace = true;
  6473. }
  6474. this._pushOrReplaceState(position, forceReplace);
  6475. }
  6476. }, {
  6477. key: "_isValidState",
  6478. value: function _isValidState(state) {
  6479. var checkReload = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  6480. if (!state) {
  6481. return false;
  6482. }
  6483. if (state.fingerprint !== this.fingerprint) {
  6484. if (checkReload) {
  6485. if (typeof state.fingerprint !== 'string' || state.fingerprint.length !== this.fingerprint.length) {
  6486. return false;
  6487. }
  6488. var _performance$getEntri = performance.getEntriesByType('navigation'),
  6489. _performance$getEntri2 = _slicedToArray(_performance$getEntri, 1),
  6490. perfEntry = _performance$getEntri2[0];
  6491. if (!perfEntry || perfEntry.type !== 'reload') {
  6492. return false;
  6493. }
  6494. } else {
  6495. return false;
  6496. }
  6497. }
  6498. if (!Number.isInteger(state.uid) || state.uid < 0) {
  6499. return false;
  6500. }
  6501. if (state.destination === null || _typeof(state.destination) !== 'object') {
  6502. return false;
  6503. }
  6504. return true;
  6505. }
  6506. }, {
  6507. key: "_updateInternalState",
  6508. value: function _updateInternalState(destination, uid) {
  6509. var removeTemporary = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  6510. if (this._updateViewareaTimeout) {
  6511. clearTimeout(this._updateViewareaTimeout);
  6512. this._updateViewareaTimeout = null;
  6513. }
  6514. if (removeTemporary && destination && destination.temporary) {
  6515. delete destination.temporary;
  6516. }
  6517. this._destination = destination;
  6518. this._uid = uid;
  6519. this._numPositionUpdates = 0;
  6520. }
  6521. }, {
  6522. key: "_updateViewarea",
  6523. value: function _updateViewarea(_ref4) {
  6524. var _this3 = this;
  6525. var location = _ref4.location;
  6526. if (this._updateViewareaTimeout) {
  6527. clearTimeout(this._updateViewareaTimeout);
  6528. this._updateViewareaTimeout = null;
  6529. }
  6530. this._position = {
  6531. hash: this._isViewerInPresentationMode ? "page=".concat(location.pageNumber) : location.pdfOpenParams.substring(1),
  6532. page: this.linkService.page,
  6533. first: location.pageNumber,
  6534. rotation: location.rotation
  6535. };
  6536. if (this._popStateInProgress) {
  6537. return;
  6538. }
  6539. if (POSITION_UPDATED_THRESHOLD > 0 && this._isPagesLoaded && this._destination && !this._destination.page) {
  6540. this._numPositionUpdates++;
  6541. }
  6542. if (UPDATE_VIEWAREA_TIMEOUT > 0) {
  6543. this._updateViewareaTimeout = setTimeout(function () {
  6544. if (!_this3._popStateInProgress) {
  6545. _this3._tryPushCurrentPosition(true);
  6546. }
  6547. _this3._updateViewareaTimeout = null;
  6548. }, UPDATE_VIEWAREA_TIMEOUT);
  6549. }
  6550. }
  6551. }, {
  6552. key: "_popState",
  6553. value: function _popState(_ref5) {
  6554. var _this4 = this;
  6555. var state = _ref5.state;
  6556. var newHash = getCurrentHash(),
  6557. hashChanged = this._currentHash !== newHash;
  6558. this._currentHash = newHash;
  6559. if (!state || false) {
  6560. this._uid++;
  6561. var _parseCurrentHash2 = parseCurrentHash(this.linkService),
  6562. hash = _parseCurrentHash2.hash,
  6563. page = _parseCurrentHash2.page,
  6564. rotation = _parseCurrentHash2.rotation;
  6565. this._pushOrReplaceState({
  6566. hash: hash,
  6567. page: page,
  6568. rotation: rotation
  6569. }, true);
  6570. return;
  6571. }
  6572. if (!this._isValidState(state)) {
  6573. return;
  6574. }
  6575. this._popStateInProgress = true;
  6576. if (hashChanged) {
  6577. this._blockHashChange++;
  6578. (0, _ui_utils.waitOnEventOrTimeout)({
  6579. target: window,
  6580. name: 'hashchange',
  6581. delay: HASH_CHANGE_TIMEOUT
  6582. }).then(function () {
  6583. _this4._blockHashChange--;
  6584. });
  6585. }
  6586. var destination = state.destination;
  6587. this._updateInternalState(destination, state.uid, true);
  6588. if (this._uid > this._maxUid) {
  6589. this._maxUid = this._uid;
  6590. }
  6591. if ((0, _ui_utils.isValidRotation)(destination.rotation)) {
  6592. this.linkService.rotation = destination.rotation;
  6593. }
  6594. if (destination.dest) {
  6595. this.linkService.navigateTo(destination.dest);
  6596. } else if (destination.hash) {
  6597. this.linkService.setHash(destination.hash);
  6598. } else if (destination.page) {
  6599. this.linkService.page = destination.page;
  6600. }
  6601. Promise.resolve().then(function () {
  6602. _this4._popStateInProgress = false;
  6603. });
  6604. }
  6605. }, {
  6606. key: "_bindEvents",
  6607. value: function _bindEvents() {
  6608. var _this5 = this;
  6609. var _boundEvents = this._boundEvents,
  6610. eventBus = this.eventBus;
  6611. _boundEvents.updateViewarea = this._updateViewarea.bind(this);
  6612. _boundEvents.popState = this._popState.bind(this);
  6613. _boundEvents.pageHide = function (evt) {
  6614. if (!_this5._destination || _this5._destination.temporary) {
  6615. _this5._tryPushCurrentPosition();
  6616. }
  6617. };
  6618. eventBus.on('updateviewarea', _boundEvents.updateViewarea);
  6619. window.addEventListener('popstate', _boundEvents.popState);
  6620. window.addEventListener('pagehide', _boundEvents.pageHide);
  6621. }
  6622. }, {
  6623. key: "popStateInProgress",
  6624. get: function get() {
  6625. return this.initialized && (this._popStateInProgress || this._blockHashChange > 0);
  6626. }
  6627. }]);
  6628. return PDFHistory;
  6629. }();
  6630. exports.PDFHistory = PDFHistory;
  6631. function isDestHashesEqual(destHash, pushHash) {
  6632. if (typeof destHash !== 'string' || typeof pushHash !== 'string') {
  6633. return false;
  6634. }
  6635. if (destHash === pushHash) {
  6636. return true;
  6637. }
  6638. var _parseQueryString = (0, _ui_utils.parseQueryString)(destHash),
  6639. nameddest = _parseQueryString.nameddest;
  6640. if (nameddest === pushHash) {
  6641. return true;
  6642. }
  6643. return false;
  6644. }
  6645. function isDestArraysEqual(firstDest, secondDest) {
  6646. function isEntryEqual(first, second) {
  6647. if (_typeof(first) !== _typeof(second)) {
  6648. return false;
  6649. }
  6650. if (Array.isArray(first) || Array.isArray(second)) {
  6651. return false;
  6652. }
  6653. if (first !== null && _typeof(first) === 'object' && second !== null) {
  6654. if (Object.keys(first).length !== Object.keys(second).length) {
  6655. return false;
  6656. }
  6657. for (var key in first) {
  6658. if (!isEntryEqual(first[key], second[key])) {
  6659. return false;
  6660. }
  6661. }
  6662. return true;
  6663. }
  6664. return first === second || Number.isNaN(first) && Number.isNaN(second);
  6665. }
  6666. if (!(Array.isArray(firstDest) && Array.isArray(secondDest))) {
  6667. return false;
  6668. }
  6669. if (firstDest.length !== secondDest.length) {
  6670. return false;
  6671. }
  6672. for (var i = 0, ii = firstDest.length; i < ii; i++) {
  6673. if (!isEntryEqual(firstDest[i], secondDest[i])) {
  6674. return false;
  6675. }
  6676. }
  6677. return true;
  6678. }
  6679. /***/ }),
  6680. /* 21 */
  6681. /***/ (function(module, exports, __webpack_require__) {
  6682. "use strict";
  6683. Object.defineProperty(exports, "__esModule", {
  6684. value: true
  6685. });
  6686. exports.SimpleLinkService = exports.PDFLinkService = void 0;
  6687. var _ui_utils = __webpack_require__(5);
  6688. function _typeof(obj) { 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); }
  6689. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  6690. 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); } }
  6691. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  6692. var PDFLinkService =
  6693. /*#__PURE__*/
  6694. function () {
  6695. function PDFLinkService() {
  6696. var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
  6697. eventBus = _ref.eventBus,
  6698. _ref$externalLinkTarg = _ref.externalLinkTarget,
  6699. externalLinkTarget = _ref$externalLinkTarg === void 0 ? null : _ref$externalLinkTarg,
  6700. _ref$externalLinkRel = _ref.externalLinkRel,
  6701. externalLinkRel = _ref$externalLinkRel === void 0 ? null : _ref$externalLinkRel,
  6702. _ref$externalLinkEnab = _ref.externalLinkEnabled,
  6703. externalLinkEnabled = _ref$externalLinkEnab === void 0 ? true : _ref$externalLinkEnab;
  6704. _classCallCheck(this, PDFLinkService);
  6705. this.eventBus = eventBus || (0, _ui_utils.getGlobalEventBus)();
  6706. this.externalLinkTarget = externalLinkTarget;
  6707. this.externalLinkRel = externalLinkRel;
  6708. this.externalLinkEnabled = externalLinkEnabled;
  6709. this.baseUrl = null;
  6710. this.pdfDocument = null;
  6711. this.pdfViewer = null;
  6712. this.pdfHistory = null;
  6713. this._pagesRefCache = null;
  6714. }
  6715. _createClass(PDFLinkService, [{
  6716. key: "setDocument",
  6717. value: function setDocument(pdfDocument) {
  6718. var baseUrl = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  6719. this.baseUrl = baseUrl;
  6720. this.pdfDocument = pdfDocument;
  6721. this._pagesRefCache = Object.create(null);
  6722. }
  6723. }, {
  6724. key: "setViewer",
  6725. value: function setViewer(pdfViewer) {
  6726. this.pdfViewer = pdfViewer;
  6727. }
  6728. }, {
  6729. key: "setHistory",
  6730. value: function setHistory(pdfHistory) {
  6731. this.pdfHistory = pdfHistory;
  6732. }
  6733. }, {
  6734. key: "navigateTo",
  6735. value: function navigateTo(dest) {
  6736. var _this = this;
  6737. var goToDestination = function goToDestination(_ref2) {
  6738. var namedDest = _ref2.namedDest,
  6739. explicitDest = _ref2.explicitDest;
  6740. var destRef = explicitDest[0],
  6741. pageNumber;
  6742. if (destRef instanceof Object) {
  6743. pageNumber = _this._cachedPageNumber(destRef);
  6744. if (pageNumber === null) {
  6745. _this.pdfDocument.getPageIndex(destRef).then(function (pageIndex) {
  6746. _this.cachePageRef(pageIndex + 1, destRef);
  6747. goToDestination({
  6748. namedDest: namedDest,
  6749. explicitDest: explicitDest
  6750. });
  6751. })["catch"](function () {
  6752. console.error("PDFLinkService.navigateTo: \"".concat(destRef, "\" is not ") + "a valid page reference, for dest=\"".concat(dest, "\"."));
  6753. });
  6754. return;
  6755. }
  6756. } else if (Number.isInteger(destRef)) {
  6757. pageNumber = destRef + 1;
  6758. } else {
  6759. console.error("PDFLinkService.navigateTo: \"".concat(destRef, "\" is not ") + "a valid destination reference, for dest=\"".concat(dest, "\"."));
  6760. return;
  6761. }
  6762. if (!pageNumber || pageNumber < 1 || pageNumber > _this.pagesCount) {
  6763. console.error("PDFLinkService.navigateTo: \"".concat(pageNumber, "\" is not ") + "a valid page number, for dest=\"".concat(dest, "\"."));
  6764. return;
  6765. }
  6766. if (_this.pdfHistory) {
  6767. _this.pdfHistory.pushCurrentPosition();
  6768. _this.pdfHistory.push({
  6769. namedDest: namedDest,
  6770. explicitDest: explicitDest,
  6771. pageNumber: pageNumber
  6772. });
  6773. }
  6774. _this.pdfViewer.scrollPageIntoView({
  6775. pageNumber: pageNumber,
  6776. destArray: explicitDest
  6777. });
  6778. };
  6779. new Promise(function (resolve, reject) {
  6780. if (typeof dest === 'string') {
  6781. _this.pdfDocument.getDestination(dest).then(function (destArray) {
  6782. resolve({
  6783. namedDest: dest,
  6784. explicitDest: destArray
  6785. });
  6786. });
  6787. return;
  6788. }
  6789. resolve({
  6790. namedDest: '',
  6791. explicitDest: dest
  6792. });
  6793. }).then(function (data) {
  6794. if (!Array.isArray(data.explicitDest)) {
  6795. console.error("PDFLinkService.navigateTo: \"".concat(data.explicitDest, "\" is") + " not a valid destination array, for dest=\"".concat(dest, "\"."));
  6796. return;
  6797. }
  6798. goToDestination(data);
  6799. });
  6800. }
  6801. }, {
  6802. key: "getDestinationHash",
  6803. value: function getDestinationHash(dest) {
  6804. if (typeof dest === 'string') {
  6805. return this.getAnchorUrl('#' + escape(dest));
  6806. }
  6807. if (Array.isArray(dest)) {
  6808. var str = JSON.stringify(dest);
  6809. return this.getAnchorUrl('#' + escape(str));
  6810. }
  6811. return this.getAnchorUrl('');
  6812. }
  6813. }, {
  6814. key: "getAnchorUrl",
  6815. value: function getAnchorUrl(anchor) {
  6816. return (this.baseUrl || '') + anchor;
  6817. }
  6818. }, {
  6819. key: "setHash",
  6820. value: function setHash(hash) {
  6821. var pageNumber, dest;
  6822. if (hash.includes('=')) {
  6823. var params = (0, _ui_utils.parseQueryString)(hash);
  6824. if ('search' in params) {
  6825. this.eventBus.dispatch('findfromurlhash', {
  6826. source: this,
  6827. query: params['search'].replace(/"/g, ''),
  6828. phraseSearch: params['phrase'] === 'true'
  6829. });
  6830. }
  6831. if ('nameddest' in params) {
  6832. this.navigateTo(params.nameddest);
  6833. return;
  6834. }
  6835. if ('page' in params) {
  6836. pageNumber = params.page | 0 || 1;
  6837. }
  6838. if ('zoom' in params) {
  6839. var zoomArgs = params.zoom.split(',');
  6840. var zoomArg = zoomArgs[0];
  6841. var zoomArgNumber = parseFloat(zoomArg);
  6842. if (!zoomArg.includes('Fit')) {
  6843. dest = [null, {
  6844. name: 'XYZ'
  6845. }, zoomArgs.length > 1 ? zoomArgs[1] | 0 : null, zoomArgs.length > 2 ? zoomArgs[2] | 0 : null, zoomArgNumber ? zoomArgNumber / 100 : zoomArg];
  6846. } else {
  6847. if (zoomArg === 'Fit' || zoomArg === 'FitB') {
  6848. dest = [null, {
  6849. name: zoomArg
  6850. }];
  6851. } else if (zoomArg === 'FitH' || zoomArg === 'FitBH' || zoomArg === 'FitV' || zoomArg === 'FitBV') {
  6852. dest = [null, {
  6853. name: zoomArg
  6854. }, zoomArgs.length > 1 ? zoomArgs[1] | 0 : null];
  6855. } else if (zoomArg === 'FitR') {
  6856. if (zoomArgs.length !== 5) {
  6857. console.error('PDFLinkService.setHash: Not enough parameters for "FitR".');
  6858. } else {
  6859. dest = [null, {
  6860. name: zoomArg
  6861. }, zoomArgs[1] | 0, zoomArgs[2] | 0, zoomArgs[3] | 0, zoomArgs[4] | 0];
  6862. }
  6863. } else {
  6864. console.error("PDFLinkService.setHash: \"".concat(zoomArg, "\" is not ") + 'a valid zoom value.');
  6865. }
  6866. }
  6867. }
  6868. if (dest) {
  6869. this.pdfViewer.scrollPageIntoView({
  6870. pageNumber: pageNumber || this.page,
  6871. destArray: dest,
  6872. allowNegativeOffset: true
  6873. });
  6874. } else if (pageNumber) {
  6875. this.page = pageNumber;
  6876. }
  6877. if ('pagemode' in params) {
  6878. this.eventBus.dispatch('pagemode', {
  6879. source: this,
  6880. mode: params.pagemode
  6881. });
  6882. }
  6883. } else {
  6884. dest = unescape(hash);
  6885. try {
  6886. dest = JSON.parse(dest);
  6887. if (!Array.isArray(dest)) {
  6888. dest = dest.toString();
  6889. }
  6890. } catch (ex) {}
  6891. if (typeof dest === 'string' || isValidExplicitDestination(dest)) {
  6892. this.navigateTo(dest);
  6893. return;
  6894. }
  6895. console.error("PDFLinkService.setHash: \"".concat(unescape(hash), "\" is not ") + 'a valid destination.');
  6896. }
  6897. }
  6898. }, {
  6899. key: "executeNamedAction",
  6900. value: function executeNamedAction(action) {
  6901. switch (action) {
  6902. case 'GoBack':
  6903. if (this.pdfHistory) {
  6904. this.pdfHistory.back();
  6905. }
  6906. break;
  6907. case 'GoForward':
  6908. if (this.pdfHistory) {
  6909. this.pdfHistory.forward();
  6910. }
  6911. break;
  6912. case 'NextPage':
  6913. if (this.page < this.pagesCount) {
  6914. this.page++;
  6915. }
  6916. break;
  6917. case 'PrevPage':
  6918. if (this.page > 1) {
  6919. this.page--;
  6920. }
  6921. break;
  6922. case 'LastPage':
  6923. this.page = this.pagesCount;
  6924. break;
  6925. case 'FirstPage':
  6926. this.page = 1;
  6927. break;
  6928. default:
  6929. break;
  6930. }
  6931. this.eventBus.dispatch('namedaction', {
  6932. source: this,
  6933. action: action
  6934. });
  6935. }
  6936. }, {
  6937. key: "cachePageRef",
  6938. value: function cachePageRef(pageNum, pageRef) {
  6939. if (!pageRef) {
  6940. return;
  6941. }
  6942. var refStr = pageRef.gen === 0 ? "".concat(pageRef.num, "R") : "".concat(pageRef.num, "R").concat(pageRef.gen);
  6943. this._pagesRefCache[refStr] = pageNum;
  6944. }
  6945. }, {
  6946. key: "_cachedPageNumber",
  6947. value: function _cachedPageNumber(pageRef) {
  6948. var refStr = pageRef.gen === 0 ? "".concat(pageRef.num, "R") : "".concat(pageRef.num, "R").concat(pageRef.gen);
  6949. return this._pagesRefCache && this._pagesRefCache[refStr] || null;
  6950. }
  6951. }, {
  6952. key: "isPageVisible",
  6953. value: function isPageVisible(pageNumber) {
  6954. return this.pdfViewer.isPageVisible(pageNumber);
  6955. }
  6956. }, {
  6957. key: "pagesCount",
  6958. get: function get() {
  6959. return this.pdfDocument ? this.pdfDocument.numPages : 0;
  6960. }
  6961. }, {
  6962. key: "page",
  6963. get: function get() {
  6964. return this.pdfViewer.currentPageNumber;
  6965. },
  6966. set: function set(value) {
  6967. this.pdfViewer.currentPageNumber = value;
  6968. }
  6969. }, {
  6970. key: "rotation",
  6971. get: function get() {
  6972. return this.pdfViewer.pagesRotation;
  6973. },
  6974. set: function set(value) {
  6975. this.pdfViewer.pagesRotation = value;
  6976. }
  6977. }]);
  6978. return PDFLinkService;
  6979. }();
  6980. exports.PDFLinkService = PDFLinkService;
  6981. function isValidExplicitDestination(dest) {
  6982. if (!Array.isArray(dest)) {
  6983. return false;
  6984. }
  6985. var destLength = dest.length,
  6986. allowNull = true;
  6987. if (destLength < 2) {
  6988. return false;
  6989. }
  6990. var page = dest[0];
  6991. if (!(_typeof(page) === 'object' && Number.isInteger(page.num) && Number.isInteger(page.gen)) && !(Number.isInteger(page) && page >= 0)) {
  6992. return false;
  6993. }
  6994. var zoom = dest[1];
  6995. if (!(_typeof(zoom) === 'object' && typeof zoom.name === 'string')) {
  6996. return false;
  6997. }
  6998. switch (zoom.name) {
  6999. case 'XYZ':
  7000. if (destLength !== 5) {
  7001. return false;
  7002. }
  7003. break;
  7004. case 'Fit':
  7005. case 'FitB':
  7006. return destLength === 2;
  7007. case 'FitH':
  7008. case 'FitBH':
  7009. case 'FitV':
  7010. case 'FitBV':
  7011. if (destLength !== 3) {
  7012. return false;
  7013. }
  7014. break;
  7015. case 'FitR':
  7016. if (destLength !== 6) {
  7017. return false;
  7018. }
  7019. allowNull = false;
  7020. break;
  7021. default:
  7022. return false;
  7023. }
  7024. for (var i = 2; i < destLength; i++) {
  7025. var param = dest[i];
  7026. if (!(typeof param === 'number' || allowNull && param === null)) {
  7027. return false;
  7028. }
  7029. }
  7030. return true;
  7031. }
  7032. var SimpleLinkService =
  7033. /*#__PURE__*/
  7034. function () {
  7035. function SimpleLinkService() {
  7036. _classCallCheck(this, SimpleLinkService);
  7037. this.externalLinkTarget = null;
  7038. this.externalLinkRel = null;
  7039. this.externalLinkEnabled = true;
  7040. }
  7041. _createClass(SimpleLinkService, [{
  7042. key: "navigateTo",
  7043. value: function navigateTo(dest) {}
  7044. }, {
  7045. key: "getDestinationHash",
  7046. value: function getDestinationHash(dest) {
  7047. return '#';
  7048. }
  7049. }, {
  7050. key: "getAnchorUrl",
  7051. value: function getAnchorUrl(hash) {
  7052. return '#';
  7053. }
  7054. }, {
  7055. key: "setHash",
  7056. value: function setHash(hash) {}
  7057. }, {
  7058. key: "executeNamedAction",
  7059. value: function executeNamedAction(action) {}
  7060. }, {
  7061. key: "cachePageRef",
  7062. value: function cachePageRef(pageNum, pageRef) {}
  7063. }, {
  7064. key: "isPageVisible",
  7065. value: function isPageVisible(pageNumber) {
  7066. return true;
  7067. }
  7068. }, {
  7069. key: "pagesCount",
  7070. get: function get() {
  7071. return 0;
  7072. }
  7073. }, {
  7074. key: "page",
  7075. get: function get() {
  7076. return 0;
  7077. },
  7078. set: function set(value) {}
  7079. }, {
  7080. key: "rotation",
  7081. get: function get() {
  7082. return 0;
  7083. },
  7084. set: function set(value) {}
  7085. }]);
  7086. return SimpleLinkService;
  7087. }();
  7088. exports.SimpleLinkService = SimpleLinkService;
  7089. /***/ }),
  7090. /* 22 */
  7091. /***/ (function(module, exports, __webpack_require__) {
  7092. "use strict";
  7093. Object.defineProperty(exports, "__esModule", {
  7094. value: true
  7095. });
  7096. exports.PDFOutlineViewer = void 0;
  7097. var _pdfjsLib = __webpack_require__(7);
  7098. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  7099. 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); } }
  7100. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  7101. var DEFAULT_TITLE = "\u2013";
  7102. var PDFOutlineViewer =
  7103. /*#__PURE__*/
  7104. function () {
  7105. function PDFOutlineViewer(_ref) {
  7106. var container = _ref.container,
  7107. linkService = _ref.linkService,
  7108. eventBus = _ref.eventBus;
  7109. _classCallCheck(this, PDFOutlineViewer);
  7110. this.container = container;
  7111. this.linkService = linkService;
  7112. this.eventBus = eventBus;
  7113. this.reset();
  7114. eventBus.on('toggleoutlinetree', this.toggleOutlineTree.bind(this));
  7115. }
  7116. _createClass(PDFOutlineViewer, [{
  7117. key: "reset",
  7118. value: function reset() {
  7119. this.outline = null;
  7120. this.lastToggleIsShow = true;
  7121. this.container.textContent = '';
  7122. this.container.classList.remove('outlineWithDeepNesting');
  7123. }
  7124. }, {
  7125. key: "_dispatchEvent",
  7126. value: function _dispatchEvent(outlineCount) {
  7127. this.eventBus.dispatch('outlineloaded', {
  7128. source: this,
  7129. outlineCount: outlineCount
  7130. });
  7131. }
  7132. }, {
  7133. key: "_bindLink",
  7134. value: function _bindLink(element, _ref2) {
  7135. var url = _ref2.url,
  7136. newWindow = _ref2.newWindow,
  7137. dest = _ref2.dest;
  7138. var linkService = this.linkService;
  7139. if (url) {
  7140. (0, _pdfjsLib.addLinkAttributes)(element, {
  7141. url: url,
  7142. target: newWindow ? _pdfjsLib.LinkTarget.BLANK : linkService.externalLinkTarget,
  7143. rel: linkService.externalLinkRel,
  7144. enabled: linkService.externalLinkEnabled
  7145. });
  7146. return;
  7147. }
  7148. element.href = linkService.getDestinationHash(dest);
  7149. element.onclick = function () {
  7150. if (dest) {
  7151. linkService.navigateTo(dest);
  7152. }
  7153. return false;
  7154. };
  7155. }
  7156. }, {
  7157. key: "_setStyles",
  7158. value: function _setStyles(element, _ref3) {
  7159. var bold = _ref3.bold,
  7160. italic = _ref3.italic;
  7161. var styleStr = '';
  7162. if (bold) {
  7163. styleStr += 'font-weight: bold;';
  7164. }
  7165. if (italic) {
  7166. styleStr += 'font-style: italic;';
  7167. }
  7168. if (styleStr) {
  7169. element.setAttribute('style', styleStr);
  7170. }
  7171. }
  7172. }, {
  7173. key: "_addToggleButton",
  7174. value: function _addToggleButton(div, _ref4) {
  7175. var _this = this;
  7176. var count = _ref4.count,
  7177. items = _ref4.items;
  7178. var toggler = document.createElement('div');
  7179. toggler.className = 'outlineItemToggler';
  7180. if (count < 0 && Math.abs(count) === items.length) {
  7181. toggler.classList.add('outlineItemsHidden');
  7182. }
  7183. toggler.onclick = function (evt) {
  7184. evt.stopPropagation();
  7185. toggler.classList.toggle('outlineItemsHidden');
  7186. if (evt.shiftKey) {
  7187. var shouldShowAll = !toggler.classList.contains('outlineItemsHidden');
  7188. _this._toggleOutlineItem(div, shouldShowAll);
  7189. }
  7190. };
  7191. div.insertBefore(toggler, div.firstChild);
  7192. }
  7193. }, {
  7194. key: "_toggleOutlineItem",
  7195. value: function _toggleOutlineItem(root) {
  7196. var show = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  7197. this.lastToggleIsShow = show;
  7198. var _iteratorNormalCompletion = true;
  7199. var _didIteratorError = false;
  7200. var _iteratorError = undefined;
  7201. try {
  7202. for (var _iterator = root.querySelectorAll('.outlineItemToggler')[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
  7203. var toggler = _step.value;
  7204. toggler.classList.toggle('outlineItemsHidden', !show);
  7205. }
  7206. } catch (err) {
  7207. _didIteratorError = true;
  7208. _iteratorError = err;
  7209. } finally {
  7210. try {
  7211. if (!_iteratorNormalCompletion && _iterator["return"] != null) {
  7212. _iterator["return"]();
  7213. }
  7214. } finally {
  7215. if (_didIteratorError) {
  7216. throw _iteratorError;
  7217. }
  7218. }
  7219. }
  7220. }
  7221. }, {
  7222. key: "toggleOutlineTree",
  7223. value: function toggleOutlineTree() {
  7224. if (!this.outline) {
  7225. return;
  7226. }
  7227. this._toggleOutlineItem(this.container, !this.lastToggleIsShow);
  7228. }
  7229. }, {
  7230. key: "render",
  7231. value: function render(_ref5) {
  7232. var outline = _ref5.outline;
  7233. var outlineCount = 0;
  7234. if (this.outline) {
  7235. this.reset();
  7236. }
  7237. this.outline = outline || null;
  7238. if (!outline) {
  7239. this._dispatchEvent(outlineCount);
  7240. return;
  7241. }
  7242. var fragment = document.createDocumentFragment();
  7243. var queue = [{
  7244. parent: fragment,
  7245. items: this.outline
  7246. }];
  7247. var hasAnyNesting = false;
  7248. while (queue.length > 0) {
  7249. var levelData = queue.shift();
  7250. var _iteratorNormalCompletion2 = true;
  7251. var _didIteratorError2 = false;
  7252. var _iteratorError2 = undefined;
  7253. try {
  7254. for (var _iterator2 = levelData.items[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
  7255. var item = _step2.value;
  7256. var div = document.createElement('div');
  7257. div.className = 'outlineItem';
  7258. var element = document.createElement('a');
  7259. this._bindLink(element, item);
  7260. this._setStyles(element, item);
  7261. element.textContent = (0, _pdfjsLib.removeNullCharacters)(item.title) || DEFAULT_TITLE;
  7262. div.appendChild(element);
  7263. if (item.items.length > 0) {
  7264. hasAnyNesting = true;
  7265. this._addToggleButton(div, item);
  7266. var itemsDiv = document.createElement('div');
  7267. itemsDiv.className = 'outlineItems';
  7268. div.appendChild(itemsDiv);
  7269. queue.push({
  7270. parent: itemsDiv,
  7271. items: item.items
  7272. });
  7273. }
  7274. levelData.parent.appendChild(div);
  7275. outlineCount++;
  7276. }
  7277. } catch (err) {
  7278. _didIteratorError2 = true;
  7279. _iteratorError2 = err;
  7280. } finally {
  7281. try {
  7282. if (!_iteratorNormalCompletion2 && _iterator2["return"] != null) {
  7283. _iterator2["return"]();
  7284. }
  7285. } finally {
  7286. if (_didIteratorError2) {
  7287. throw _iteratorError2;
  7288. }
  7289. }
  7290. }
  7291. }
  7292. if (hasAnyNesting) {
  7293. this.container.classList.add('outlineWithDeepNesting');
  7294. this.lastToggleIsShow = fragment.querySelectorAll('.outlineItemsHidden').length === 0;
  7295. }
  7296. this.container.appendChild(fragment);
  7297. this._dispatchEvent(outlineCount);
  7298. }
  7299. }]);
  7300. return PDFOutlineViewer;
  7301. }();
  7302. exports.PDFOutlineViewer = PDFOutlineViewer;
  7303. /***/ }),
  7304. /* 23 */
  7305. /***/ (function(module, exports, __webpack_require__) {
  7306. "use strict";
  7307. Object.defineProperty(exports, "__esModule", {
  7308. value: true
  7309. });
  7310. exports.PDFPresentationMode = void 0;
  7311. var _ui_utils = __webpack_require__(5);
  7312. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  7313. 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); } }
  7314. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  7315. var DELAY_BEFORE_RESETTING_SWITCH_IN_PROGRESS = 1500;
  7316. var DELAY_BEFORE_HIDING_CONTROLS = 3000;
  7317. var ACTIVE_SELECTOR = 'pdfPresentationMode';
  7318. var CONTROLS_SELECTOR = 'pdfPresentationModeControls';
  7319. var MOUSE_SCROLL_COOLDOWN_TIME = 50;
  7320. var PAGE_SWITCH_THRESHOLD = 0.1;
  7321. var SWIPE_MIN_DISTANCE_THRESHOLD = 50;
  7322. var SWIPE_ANGLE_THRESHOLD = Math.PI / 6;
  7323. var PDFPresentationMode =
  7324. /*#__PURE__*/
  7325. function () {
  7326. function PDFPresentationMode(_ref) {
  7327. var _this = this;
  7328. var container = _ref.container,
  7329. _ref$viewer = _ref.viewer,
  7330. viewer = _ref$viewer === void 0 ? null : _ref$viewer,
  7331. pdfViewer = _ref.pdfViewer,
  7332. eventBus = _ref.eventBus,
  7333. _ref$contextMenuItems = _ref.contextMenuItems,
  7334. contextMenuItems = _ref$contextMenuItems === void 0 ? null : _ref$contextMenuItems;
  7335. _classCallCheck(this, PDFPresentationMode);
  7336. this.container = container;
  7337. this.viewer = viewer || container.firstElementChild;
  7338. this.pdfViewer = pdfViewer;
  7339. this.eventBus = eventBus;
  7340. this.active = false;
  7341. this.args = null;
  7342. this.contextMenuOpen = false;
  7343. this.mouseScrollTimeStamp = 0;
  7344. this.mouseScrollDelta = 0;
  7345. this.touchSwipeState = null;
  7346. if (contextMenuItems) {
  7347. contextMenuItems.contextFirstPage.addEventListener('click', function () {
  7348. _this.contextMenuOpen = false;
  7349. _this.eventBus.dispatch('firstpage', {
  7350. source: _this
  7351. });
  7352. });
  7353. contextMenuItems.contextLastPage.addEventListener('click', function () {
  7354. _this.contextMenuOpen = false;
  7355. _this.eventBus.dispatch('lastpage', {
  7356. source: _this
  7357. });
  7358. });
  7359. contextMenuItems.contextPageRotateCw.addEventListener('click', function () {
  7360. _this.contextMenuOpen = false;
  7361. _this.eventBus.dispatch('rotatecw', {
  7362. source: _this
  7363. });
  7364. });
  7365. contextMenuItems.contextPageRotateCcw.addEventListener('click', function () {
  7366. _this.contextMenuOpen = false;
  7367. _this.eventBus.dispatch('rotateccw', {
  7368. source: _this
  7369. });
  7370. });
  7371. }
  7372. }
  7373. _createClass(PDFPresentationMode, [{
  7374. key: "request",
  7375. value: function request() {
  7376. if (this.switchInProgress || this.active || !this.viewer.hasChildNodes()) {
  7377. return false;
  7378. }
  7379. this._addFullscreenChangeListeners();
  7380. this._setSwitchInProgress();
  7381. this._notifyStateChange();
  7382. if (this.container.requestFullscreen) {
  7383. this.container.requestFullscreen();
  7384. } else if (this.container.mozRequestFullScreen) {
  7385. this.container.mozRequestFullScreen();
  7386. } else if (this.container.webkitRequestFullscreen) {
  7387. this.container.webkitRequestFullscreen(Element.ALLOW_KEYBOARD_INPUT);
  7388. } else if (this.container.msRequestFullscreen) {
  7389. this.container.msRequestFullscreen();
  7390. } else {
  7391. return false;
  7392. }
  7393. this.args = {
  7394. page: this.pdfViewer.currentPageNumber,
  7395. previousScale: this.pdfViewer.currentScaleValue
  7396. };
  7397. return true;
  7398. }
  7399. }, {
  7400. key: "_mouseWheel",
  7401. value: function _mouseWheel(evt) {
  7402. if (!this.active) {
  7403. return;
  7404. }
  7405. evt.preventDefault();
  7406. var delta = (0, _ui_utils.normalizeWheelEventDelta)(evt);
  7407. var currentTime = new Date().getTime();
  7408. var storedTime = this.mouseScrollTimeStamp;
  7409. if (currentTime > storedTime && currentTime - storedTime < MOUSE_SCROLL_COOLDOWN_TIME) {
  7410. return;
  7411. }
  7412. if (this.mouseScrollDelta > 0 && delta < 0 || this.mouseScrollDelta < 0 && delta > 0) {
  7413. this._resetMouseScrollState();
  7414. }
  7415. this.mouseScrollDelta += delta;
  7416. if (Math.abs(this.mouseScrollDelta) >= PAGE_SWITCH_THRESHOLD) {
  7417. var totalDelta = this.mouseScrollDelta;
  7418. this._resetMouseScrollState();
  7419. var success = totalDelta > 0 ? this._goToPreviousPage() : this._goToNextPage();
  7420. if (success) {
  7421. this.mouseScrollTimeStamp = currentTime;
  7422. }
  7423. }
  7424. }
  7425. }, {
  7426. key: "_goToPreviousPage",
  7427. value: function _goToPreviousPage() {
  7428. var page = this.pdfViewer.currentPageNumber;
  7429. if (page <= 1) {
  7430. return false;
  7431. }
  7432. this.pdfViewer.currentPageNumber = page - 1;
  7433. return true;
  7434. }
  7435. }, {
  7436. key: "_goToNextPage",
  7437. value: function _goToNextPage() {
  7438. var page = this.pdfViewer.currentPageNumber;
  7439. if (page >= this.pdfViewer.pagesCount) {
  7440. return false;
  7441. }
  7442. this.pdfViewer.currentPageNumber = page + 1;
  7443. return true;
  7444. }
  7445. }, {
  7446. key: "_notifyStateChange",
  7447. value: function _notifyStateChange() {
  7448. this.eventBus.dispatch('presentationmodechanged', {
  7449. source: this,
  7450. active: this.active,
  7451. switchInProgress: !!this.switchInProgress
  7452. });
  7453. }
  7454. }, {
  7455. key: "_setSwitchInProgress",
  7456. value: function _setSwitchInProgress() {
  7457. var _this2 = this;
  7458. if (this.switchInProgress) {
  7459. clearTimeout(this.switchInProgress);
  7460. }
  7461. this.switchInProgress = setTimeout(function () {
  7462. _this2._removeFullscreenChangeListeners();
  7463. delete _this2.switchInProgress;
  7464. _this2._notifyStateChange();
  7465. }, DELAY_BEFORE_RESETTING_SWITCH_IN_PROGRESS);
  7466. }
  7467. }, {
  7468. key: "_resetSwitchInProgress",
  7469. value: function _resetSwitchInProgress() {
  7470. if (this.switchInProgress) {
  7471. clearTimeout(this.switchInProgress);
  7472. delete this.switchInProgress;
  7473. }
  7474. }
  7475. }, {
  7476. key: "_enter",
  7477. value: function _enter() {
  7478. var _this3 = this;
  7479. this.active = true;
  7480. this._resetSwitchInProgress();
  7481. this._notifyStateChange();
  7482. this.container.classList.add(ACTIVE_SELECTOR);
  7483. setTimeout(function () {
  7484. _this3.pdfViewer.currentPageNumber = _this3.args.page;
  7485. _this3.pdfViewer.currentScaleValue = 'page-fit';
  7486. }, 0);
  7487. this._addWindowListeners();
  7488. this._showControls();
  7489. this.contextMenuOpen = false;
  7490. this.container.setAttribute('contextmenu', 'viewerContextMenu');
  7491. window.getSelection().removeAllRanges();
  7492. }
  7493. }, {
  7494. key: "_exit",
  7495. value: function _exit() {
  7496. var _this4 = this;
  7497. var page = this.pdfViewer.currentPageNumber;
  7498. this.container.classList.remove(ACTIVE_SELECTOR);
  7499. setTimeout(function () {
  7500. _this4.active = false;
  7501. _this4._removeFullscreenChangeListeners();
  7502. _this4._notifyStateChange();
  7503. _this4.pdfViewer.currentScaleValue = _this4.args.previousScale;
  7504. _this4.pdfViewer.currentPageNumber = page;
  7505. _this4.args = null;
  7506. }, 0);
  7507. this._removeWindowListeners();
  7508. this._hideControls();
  7509. this._resetMouseScrollState();
  7510. this.container.removeAttribute('contextmenu');
  7511. this.contextMenuOpen = false;
  7512. }
  7513. }, {
  7514. key: "_mouseDown",
  7515. value: function _mouseDown(evt) {
  7516. if (this.contextMenuOpen) {
  7517. this.contextMenuOpen = false;
  7518. evt.preventDefault();
  7519. return;
  7520. }
  7521. if (evt.button === 0) {
  7522. var isInternalLink = evt.target.href && evt.target.classList.contains('internalLink');
  7523. if (!isInternalLink) {
  7524. evt.preventDefault();
  7525. if (evt.shiftKey) {
  7526. this._goToPreviousPage();
  7527. } else {
  7528. this._goToNextPage();
  7529. }
  7530. }
  7531. }
  7532. }
  7533. }, {
  7534. key: "_contextMenu",
  7535. value: function _contextMenu() {
  7536. this.contextMenuOpen = true;
  7537. }
  7538. }, {
  7539. key: "_showControls",
  7540. value: function _showControls() {
  7541. var _this5 = this;
  7542. if (this.controlsTimeout) {
  7543. clearTimeout(this.controlsTimeout);
  7544. } else {
  7545. this.container.classList.add(CONTROLS_SELECTOR);
  7546. }
  7547. this.controlsTimeout = setTimeout(function () {
  7548. _this5.container.classList.remove(CONTROLS_SELECTOR);
  7549. delete _this5.controlsTimeout;
  7550. }, DELAY_BEFORE_HIDING_CONTROLS);
  7551. }
  7552. }, {
  7553. key: "_hideControls",
  7554. value: function _hideControls() {
  7555. if (!this.controlsTimeout) {
  7556. return;
  7557. }
  7558. clearTimeout(this.controlsTimeout);
  7559. this.container.classList.remove(CONTROLS_SELECTOR);
  7560. delete this.controlsTimeout;
  7561. }
  7562. }, {
  7563. key: "_resetMouseScrollState",
  7564. value: function _resetMouseScrollState() {
  7565. this.mouseScrollTimeStamp = 0;
  7566. this.mouseScrollDelta = 0;
  7567. }
  7568. }, {
  7569. key: "_touchSwipe",
  7570. value: function _touchSwipe(evt) {
  7571. if (!this.active) {
  7572. return;
  7573. }
  7574. if (evt.touches.length > 1) {
  7575. this.touchSwipeState = null;
  7576. return;
  7577. }
  7578. switch (evt.type) {
  7579. case 'touchstart':
  7580. this.touchSwipeState = {
  7581. startX: evt.touches[0].pageX,
  7582. startY: evt.touches[0].pageY,
  7583. endX: evt.touches[0].pageX,
  7584. endY: evt.touches[0].pageY
  7585. };
  7586. break;
  7587. case 'touchmove':
  7588. if (this.touchSwipeState === null) {
  7589. return;
  7590. }
  7591. this.touchSwipeState.endX = evt.touches[0].pageX;
  7592. this.touchSwipeState.endY = evt.touches[0].pageY;
  7593. evt.preventDefault();
  7594. break;
  7595. case 'touchend':
  7596. if (this.touchSwipeState === null) {
  7597. return;
  7598. }
  7599. var delta = 0;
  7600. var dx = this.touchSwipeState.endX - this.touchSwipeState.startX;
  7601. var dy = this.touchSwipeState.endY - this.touchSwipeState.startY;
  7602. var absAngle = Math.abs(Math.atan2(dy, dx));
  7603. if (Math.abs(dx) > SWIPE_MIN_DISTANCE_THRESHOLD && (absAngle <= SWIPE_ANGLE_THRESHOLD || absAngle >= Math.PI - SWIPE_ANGLE_THRESHOLD)) {
  7604. delta = dx;
  7605. } else if (Math.abs(dy) > SWIPE_MIN_DISTANCE_THRESHOLD && Math.abs(absAngle - Math.PI / 2) <= SWIPE_ANGLE_THRESHOLD) {
  7606. delta = dy;
  7607. }
  7608. if (delta > 0) {
  7609. this._goToPreviousPage();
  7610. } else if (delta < 0) {
  7611. this._goToNextPage();
  7612. }
  7613. break;
  7614. }
  7615. }
  7616. }, {
  7617. key: "_addWindowListeners",
  7618. value: function _addWindowListeners() {
  7619. this.showControlsBind = this._showControls.bind(this);
  7620. this.mouseDownBind = this._mouseDown.bind(this);
  7621. this.mouseWheelBind = this._mouseWheel.bind(this);
  7622. this.resetMouseScrollStateBind = this._resetMouseScrollState.bind(this);
  7623. this.contextMenuBind = this._contextMenu.bind(this);
  7624. this.touchSwipeBind = this._touchSwipe.bind(this);
  7625. window.addEventListener('mousemove', this.showControlsBind);
  7626. window.addEventListener('mousedown', this.mouseDownBind);
  7627. window.addEventListener('wheel', this.mouseWheelBind);
  7628. window.addEventListener('keydown', this.resetMouseScrollStateBind);
  7629. window.addEventListener('contextmenu', this.contextMenuBind);
  7630. window.addEventListener('touchstart', this.touchSwipeBind);
  7631. window.addEventListener('touchmove', this.touchSwipeBind);
  7632. window.addEventListener('touchend', this.touchSwipeBind);
  7633. }
  7634. }, {
  7635. key: "_removeWindowListeners",
  7636. value: function _removeWindowListeners() {
  7637. window.removeEventListener('mousemove', this.showControlsBind);
  7638. window.removeEventListener('mousedown', this.mouseDownBind);
  7639. window.removeEventListener('wheel', this.mouseWheelBind);
  7640. window.removeEventListener('keydown', this.resetMouseScrollStateBind);
  7641. window.removeEventListener('contextmenu', this.contextMenuBind);
  7642. window.removeEventListener('touchstart', this.touchSwipeBind);
  7643. window.removeEventListener('touchmove', this.touchSwipeBind);
  7644. window.removeEventListener('touchend', this.touchSwipeBind);
  7645. delete this.showControlsBind;
  7646. delete this.mouseDownBind;
  7647. delete this.mouseWheelBind;
  7648. delete this.resetMouseScrollStateBind;
  7649. delete this.contextMenuBind;
  7650. delete this.touchSwipeBind;
  7651. }
  7652. }, {
  7653. key: "_fullscreenChange",
  7654. value: function _fullscreenChange() {
  7655. if (this.isFullscreen) {
  7656. this._enter();
  7657. } else {
  7658. this._exit();
  7659. }
  7660. }
  7661. }, {
  7662. key: "_addFullscreenChangeListeners",
  7663. value: function _addFullscreenChangeListeners() {
  7664. this.fullscreenChangeBind = this._fullscreenChange.bind(this);
  7665. window.addEventListener('fullscreenchange', this.fullscreenChangeBind);
  7666. window.addEventListener('mozfullscreenchange', this.fullscreenChangeBind);
  7667. window.addEventListener('webkitfullscreenchange', this.fullscreenChangeBind);
  7668. window.addEventListener('MSFullscreenChange', this.fullscreenChangeBind);
  7669. }
  7670. }, {
  7671. key: "_removeFullscreenChangeListeners",
  7672. value: function _removeFullscreenChangeListeners() {
  7673. window.removeEventListener('fullscreenchange', this.fullscreenChangeBind);
  7674. window.removeEventListener('mozfullscreenchange', this.fullscreenChangeBind);
  7675. window.removeEventListener('webkitfullscreenchange', this.fullscreenChangeBind);
  7676. window.removeEventListener('MSFullscreenChange', this.fullscreenChangeBind);
  7677. delete this.fullscreenChangeBind;
  7678. }
  7679. }, {
  7680. key: "isFullscreen",
  7681. get: function get() {
  7682. return !!(document.fullscreenElement || document.mozFullScreen || document.webkitIsFullScreen || document.msFullscreenElement);
  7683. }
  7684. }]);
  7685. return PDFPresentationMode;
  7686. }();
  7687. exports.PDFPresentationMode = PDFPresentationMode;
  7688. /***/ }),
  7689. /* 24 */
  7690. /***/ (function(module, exports, __webpack_require__) {
  7691. "use strict";
  7692. Object.defineProperty(exports, "__esModule", {
  7693. value: true
  7694. });
  7695. exports.PDFSidebarResizer = void 0;
  7696. var _ui_utils = __webpack_require__(5);
  7697. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  7698. 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); } }
  7699. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  7700. var SIDEBAR_WIDTH_VAR = '--sidebar-width';
  7701. var SIDEBAR_MIN_WIDTH = 200;
  7702. var SIDEBAR_RESIZING_CLASS = 'sidebarResizing';
  7703. var PDFSidebarResizer =
  7704. /*#__PURE__*/
  7705. function () {
  7706. function PDFSidebarResizer(options, eventBus) {
  7707. var _this = this;
  7708. var l10n = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : _ui_utils.NullL10n;
  7709. _classCallCheck(this, PDFSidebarResizer);
  7710. this.enabled = false;
  7711. this.isRTL = false;
  7712. this.sidebarOpen = false;
  7713. this.doc = document.documentElement;
  7714. this._width = null;
  7715. this._outerContainerWidth = null;
  7716. this._boundEvents = Object.create(null);
  7717. this.outerContainer = options.outerContainer;
  7718. this.resizer = options.resizer;
  7719. this.eventBus = eventBus;
  7720. this.l10n = l10n;
  7721. if (typeof CSS === 'undefined' || typeof CSS.supports !== 'function' || !CSS.supports(SIDEBAR_WIDTH_VAR, "calc(-1 * ".concat(SIDEBAR_MIN_WIDTH, "px)"))) {
  7722. console.warn('PDFSidebarResizer: ' + 'The browser does not support resizing of the sidebar.');
  7723. return;
  7724. }
  7725. this.enabled = true;
  7726. this.resizer.classList.remove('hidden');
  7727. this.l10n.getDirection().then(function (dir) {
  7728. _this.isRTL = dir === 'rtl';
  7729. });
  7730. this._addEventListeners();
  7731. }
  7732. _createClass(PDFSidebarResizer, [{
  7733. key: "_updateWidth",
  7734. value: function _updateWidth() {
  7735. var width = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
  7736. if (!this.enabled) {
  7737. return false;
  7738. }
  7739. var maxWidth = Math.floor(this.outerContainerWidth / 2);
  7740. if (width > maxWidth) {
  7741. width = maxWidth;
  7742. }
  7743. if (width < SIDEBAR_MIN_WIDTH) {
  7744. width = SIDEBAR_MIN_WIDTH;
  7745. }
  7746. if (width === this._width) {
  7747. return false;
  7748. }
  7749. this._width = width;
  7750. this.doc.style.setProperty(SIDEBAR_WIDTH_VAR, "".concat(width, "px"));
  7751. return true;
  7752. }
  7753. }, {
  7754. key: "_mouseMove",
  7755. value: function _mouseMove(evt) {
  7756. var width = evt.clientX;
  7757. if (this.isRTL) {
  7758. width = this.outerContainerWidth - width;
  7759. }
  7760. this._updateWidth(width);
  7761. }
  7762. }, {
  7763. key: "_mouseUp",
  7764. value: function _mouseUp(evt) {
  7765. this.outerContainer.classList.remove(SIDEBAR_RESIZING_CLASS);
  7766. this.eventBus.dispatch('resize', {
  7767. source: this
  7768. });
  7769. var _boundEvents = this._boundEvents;
  7770. window.removeEventListener('mousemove', _boundEvents.mouseMove);
  7771. window.removeEventListener('mouseup', _boundEvents.mouseUp);
  7772. }
  7773. }, {
  7774. key: "_addEventListeners",
  7775. value: function _addEventListeners() {
  7776. var _this2 = this;
  7777. if (!this.enabled) {
  7778. return;
  7779. }
  7780. var _boundEvents = this._boundEvents;
  7781. _boundEvents.mouseMove = this._mouseMove.bind(this);
  7782. _boundEvents.mouseUp = this._mouseUp.bind(this);
  7783. this.resizer.addEventListener('mousedown', function (evt) {
  7784. if (evt.button !== 0) {
  7785. return;
  7786. }
  7787. _this2.outerContainer.classList.add(SIDEBAR_RESIZING_CLASS);
  7788. window.addEventListener('mousemove', _boundEvents.mouseMove);
  7789. window.addEventListener('mouseup', _boundEvents.mouseUp);
  7790. });
  7791. this.eventBus.on('sidebarviewchanged', function (evt) {
  7792. _this2.sidebarOpen = !!(evt && evt.view);
  7793. });
  7794. this.eventBus.on('resize', function (evt) {
  7795. if (evt && evt.source === window) {
  7796. _this2._outerContainerWidth = null;
  7797. if (_this2._width) {
  7798. if (_this2.sidebarOpen) {
  7799. _this2.outerContainer.classList.add(SIDEBAR_RESIZING_CLASS);
  7800. var updated = _this2._updateWidth(_this2._width);
  7801. Promise.resolve().then(function () {
  7802. _this2.outerContainer.classList.remove(SIDEBAR_RESIZING_CLASS);
  7803. if (updated) {
  7804. _this2.eventBus.dispatch('resize', {
  7805. source: _this2
  7806. });
  7807. }
  7808. });
  7809. } else {
  7810. _this2._updateWidth(_this2._width);
  7811. }
  7812. }
  7813. }
  7814. });
  7815. }
  7816. }, {
  7817. key: "outerContainerWidth",
  7818. get: function get() {
  7819. if (!this._outerContainerWidth) {
  7820. this._outerContainerWidth = this.outerContainer.clientWidth;
  7821. }
  7822. return this._outerContainerWidth;
  7823. }
  7824. }]);
  7825. return PDFSidebarResizer;
  7826. }();
  7827. exports.PDFSidebarResizer = PDFSidebarResizer;
  7828. /***/ }),
  7829. /* 25 */
  7830. /***/ (function(module, exports, __webpack_require__) {
  7831. "use strict";
  7832. Object.defineProperty(exports, "__esModule", {
  7833. value: true
  7834. });
  7835. exports.PDFThumbnailViewer = void 0;
  7836. var _ui_utils = __webpack_require__(5);
  7837. var _pdf_thumbnail_view = __webpack_require__(26);
  7838. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  7839. 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); } }
  7840. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  7841. var THUMBNAIL_SCROLL_MARGIN = -19;
  7842. var THUMBNAIL_SELECTED_CLASS = 'selected';
  7843. var PDFThumbnailViewer =
  7844. /*#__PURE__*/
  7845. function () {
  7846. function PDFThumbnailViewer(_ref) {
  7847. var container = _ref.container,
  7848. linkService = _ref.linkService,
  7849. renderingQueue = _ref.renderingQueue,
  7850. _ref$l10n = _ref.l10n,
  7851. l10n = _ref$l10n === void 0 ? _ui_utils.NullL10n : _ref$l10n;
  7852. _classCallCheck(this, PDFThumbnailViewer);
  7853. this.container = container;
  7854. this.linkService = linkService;
  7855. this.renderingQueue = renderingQueue;
  7856. this.l10n = l10n;
  7857. this.scroll = (0, _ui_utils.watchScroll)(this.container, this._scrollUpdated.bind(this));
  7858. this._resetView();
  7859. }
  7860. _createClass(PDFThumbnailViewer, [{
  7861. key: "_scrollUpdated",
  7862. value: function _scrollUpdated() {
  7863. this.renderingQueue.renderHighestPriority();
  7864. }
  7865. }, {
  7866. key: "getThumbnail",
  7867. value: function getThumbnail(index) {
  7868. return this._thumbnails[index];
  7869. }
  7870. }, {
  7871. key: "_getVisibleThumbs",
  7872. value: function _getVisibleThumbs() {
  7873. return (0, _ui_utils.getVisibleElements)(this.container, this._thumbnails);
  7874. }
  7875. }, {
  7876. key: "scrollThumbnailIntoView",
  7877. value: function scrollThumbnailIntoView(pageNumber) {
  7878. if (!this.pdfDocument) {
  7879. return;
  7880. }
  7881. var thumbnailView = this._thumbnails[pageNumber - 1];
  7882. if (!thumbnailView) {
  7883. console.error('scrollThumbnailIntoView: Invalid "pageNumber" parameter.');
  7884. return;
  7885. }
  7886. if (pageNumber !== this._currentPageNumber) {
  7887. var prevThumbnailView = this._thumbnails[this._currentPageNumber - 1];
  7888. prevThumbnailView.div.classList.remove(THUMBNAIL_SELECTED_CLASS);
  7889. thumbnailView.div.classList.add(THUMBNAIL_SELECTED_CLASS);
  7890. }
  7891. var visibleThumbs = this._getVisibleThumbs();
  7892. var numVisibleThumbs = visibleThumbs.views.length;
  7893. if (numVisibleThumbs > 0) {
  7894. var first = visibleThumbs.first.id;
  7895. var last = numVisibleThumbs > 1 ? visibleThumbs.last.id : first;
  7896. var shouldScroll = false;
  7897. if (pageNumber <= first || pageNumber >= last) {
  7898. shouldScroll = true;
  7899. } else {
  7900. visibleThumbs.views.some(function (view) {
  7901. if (view.id !== pageNumber) {
  7902. return false;
  7903. }
  7904. shouldScroll = view.percent < 100;
  7905. return true;
  7906. });
  7907. }
  7908. if (shouldScroll) {
  7909. (0, _ui_utils.scrollIntoView)(thumbnailView.div, {
  7910. top: THUMBNAIL_SCROLL_MARGIN
  7911. });
  7912. }
  7913. }
  7914. this._currentPageNumber = pageNumber;
  7915. }
  7916. }, {
  7917. key: "cleanup",
  7918. value: function cleanup() {
  7919. _pdf_thumbnail_view.PDFThumbnailView.cleanup();
  7920. }
  7921. }, {
  7922. key: "_resetView",
  7923. value: function _resetView() {
  7924. this._thumbnails = [];
  7925. this._currentPageNumber = 1;
  7926. this._pageLabels = null;
  7927. this._pagesRotation = 0;
  7928. this._pagesRequests = [];
  7929. this.container.textContent = '';
  7930. }
  7931. }, {
  7932. key: "setDocument",
  7933. value: function setDocument(pdfDocument) {
  7934. var _this = this;
  7935. if (this.pdfDocument) {
  7936. this._cancelRendering();
  7937. this._resetView();
  7938. }
  7939. this.pdfDocument = pdfDocument;
  7940. if (!pdfDocument) {
  7941. return;
  7942. }
  7943. pdfDocument.getPage(1).then(function (firstPage) {
  7944. var pagesCount = pdfDocument.numPages;
  7945. var viewport = firstPage.getViewport({
  7946. scale: 1
  7947. });
  7948. for (var pageNum = 1; pageNum <= pagesCount; ++pageNum) {
  7949. var thumbnail = new _pdf_thumbnail_view.PDFThumbnailView({
  7950. container: _this.container,
  7951. id: pageNum,
  7952. defaultViewport: viewport.clone(),
  7953. linkService: _this.linkService,
  7954. renderingQueue: _this.renderingQueue,
  7955. disableCanvasToImageConversion: false,
  7956. l10n: _this.l10n
  7957. });
  7958. _this._thumbnails.push(thumbnail);
  7959. }
  7960. var thumbnailView = _this._thumbnails[_this._currentPageNumber - 1];
  7961. thumbnailView.div.classList.add(THUMBNAIL_SELECTED_CLASS);
  7962. })["catch"](function (reason) {
  7963. console.error('Unable to initialize thumbnail viewer', reason);
  7964. });
  7965. }
  7966. }, {
  7967. key: "_cancelRendering",
  7968. value: function _cancelRendering() {
  7969. for (var i = 0, ii = this._thumbnails.length; i < ii; i++) {
  7970. if (this._thumbnails[i]) {
  7971. this._thumbnails[i].cancelRendering();
  7972. }
  7973. }
  7974. }
  7975. }, {
  7976. key: "setPageLabels",
  7977. value: function setPageLabels(labels) {
  7978. if (!this.pdfDocument) {
  7979. return;
  7980. }
  7981. if (!labels) {
  7982. this._pageLabels = null;
  7983. } else if (!(Array.isArray(labels) && this.pdfDocument.numPages === labels.length)) {
  7984. this._pageLabels = null;
  7985. console.error('PDFThumbnailViewer_setPageLabels: Invalid page labels.');
  7986. } else {
  7987. this._pageLabels = labels;
  7988. }
  7989. for (var i = 0, ii = this._thumbnails.length; i < ii; i++) {
  7990. var label = this._pageLabels && this._pageLabels[i];
  7991. this._thumbnails[i].setPageLabel(label);
  7992. }
  7993. }
  7994. }, {
  7995. key: "_ensurePdfPageLoaded",
  7996. value: function _ensurePdfPageLoaded(thumbView) {
  7997. var _this2 = this;
  7998. if (thumbView.pdfPage) {
  7999. return Promise.resolve(thumbView.pdfPage);
  8000. }
  8001. var pageNumber = thumbView.id;
  8002. if (this._pagesRequests[pageNumber]) {
  8003. return this._pagesRequests[pageNumber];
  8004. }
  8005. var promise = this.pdfDocument.getPage(pageNumber).then(function (pdfPage) {
  8006. thumbView.setPdfPage(pdfPage);
  8007. _this2._pagesRequests[pageNumber] = null;
  8008. return pdfPage;
  8009. })["catch"](function (reason) {
  8010. console.error('Unable to get page for thumb view', reason);
  8011. _this2._pagesRequests[pageNumber] = null;
  8012. });
  8013. this._pagesRequests[pageNumber] = promise;
  8014. return promise;
  8015. }
  8016. }, {
  8017. key: "forceRendering",
  8018. value: function forceRendering() {
  8019. var _this3 = this;
  8020. var visibleThumbs = this._getVisibleThumbs();
  8021. var thumbView = this.renderingQueue.getHighestPriority(visibleThumbs, this._thumbnails, this.scroll.down);
  8022. if (thumbView) {
  8023. this._ensurePdfPageLoaded(thumbView).then(function () {
  8024. _this3.renderingQueue.renderView(thumbView);
  8025. });
  8026. return true;
  8027. }
  8028. return false;
  8029. }
  8030. }, {
  8031. key: "pagesRotation",
  8032. get: function get() {
  8033. return this._pagesRotation;
  8034. },
  8035. set: function set(rotation) {
  8036. if (!(0, _ui_utils.isValidRotation)(rotation)) {
  8037. throw new Error('Invalid thumbnails rotation angle.');
  8038. }
  8039. if (!this.pdfDocument) {
  8040. return;
  8041. }
  8042. if (this._pagesRotation === rotation) {
  8043. return;
  8044. }
  8045. this._pagesRotation = rotation;
  8046. for (var i = 0, ii = this._thumbnails.length; i < ii; i++) {
  8047. this._thumbnails[i].update(rotation);
  8048. }
  8049. }
  8050. }]);
  8051. return PDFThumbnailViewer;
  8052. }();
  8053. exports.PDFThumbnailViewer = PDFThumbnailViewer;
  8054. /***/ }),
  8055. /* 26 */
  8056. /***/ (function(module, exports, __webpack_require__) {
  8057. "use strict";
  8058. Object.defineProperty(exports, "__esModule", {
  8059. value: true
  8060. });
  8061. exports.PDFThumbnailView = void 0;
  8062. var _pdfjsLib = __webpack_require__(7);
  8063. var _ui_utils = __webpack_require__(5);
  8064. var _pdf_rendering_queue = __webpack_require__(11);
  8065. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  8066. 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); } }
  8067. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  8068. var MAX_NUM_SCALING_STEPS = 3;
  8069. var THUMBNAIL_CANVAS_BORDER_WIDTH = 1;
  8070. var THUMBNAIL_WIDTH = 98;
  8071. var TempImageFactory = function TempImageFactoryClosure() {
  8072. var tempCanvasCache = null;
  8073. return {
  8074. getCanvas: function getCanvas(width, height) {
  8075. var tempCanvas = tempCanvasCache;
  8076. if (!tempCanvas) {
  8077. tempCanvas = document.createElement('canvas');
  8078. tempCanvasCache = tempCanvas;
  8079. }
  8080. tempCanvas.width = width;
  8081. tempCanvas.height = height;
  8082. tempCanvas.mozOpaque = true;
  8083. var ctx = tempCanvas.getContext('2d', {
  8084. alpha: false
  8085. });
  8086. ctx.save();
  8087. ctx.fillStyle = 'rgb(255, 255, 255)';
  8088. ctx.fillRect(0, 0, width, height);
  8089. ctx.restore();
  8090. return tempCanvas;
  8091. },
  8092. destroyCanvas: function destroyCanvas() {
  8093. var tempCanvas = tempCanvasCache;
  8094. if (tempCanvas) {
  8095. tempCanvas.width = 0;
  8096. tempCanvas.height = 0;
  8097. }
  8098. tempCanvasCache = null;
  8099. }
  8100. };
  8101. }();
  8102. var PDFThumbnailView =
  8103. /*#__PURE__*/
  8104. function () {
  8105. function PDFThumbnailView(_ref) {
  8106. var container = _ref.container,
  8107. id = _ref.id,
  8108. defaultViewport = _ref.defaultViewport,
  8109. linkService = _ref.linkService,
  8110. renderingQueue = _ref.renderingQueue,
  8111. _ref$disableCanvasToI = _ref.disableCanvasToImageConversion,
  8112. disableCanvasToImageConversion = _ref$disableCanvasToI === void 0 ? false : _ref$disableCanvasToI,
  8113. _ref$l10n = _ref.l10n,
  8114. l10n = _ref$l10n === void 0 ? _ui_utils.NullL10n : _ref$l10n;
  8115. _classCallCheck(this, PDFThumbnailView);
  8116. this.id = id;
  8117. this.renderingId = 'thumbnail' + id;
  8118. this.pageLabel = null;
  8119. this.pdfPage = null;
  8120. this.rotation = 0;
  8121. this.viewport = defaultViewport;
  8122. this.pdfPageRotate = defaultViewport.rotation;
  8123. this.linkService = linkService;
  8124. this.renderingQueue = renderingQueue;
  8125. this.renderTask = null;
  8126. this.renderingState = _pdf_rendering_queue.RenderingStates.INITIAL;
  8127. this.resume = null;
  8128. this.disableCanvasToImageConversion = disableCanvasToImageConversion;
  8129. this.pageWidth = this.viewport.width;
  8130. this.pageHeight = this.viewport.height;
  8131. this.pageRatio = this.pageWidth / this.pageHeight;
  8132. this.canvasWidth = THUMBNAIL_WIDTH;
  8133. this.canvasHeight = this.canvasWidth / this.pageRatio | 0;
  8134. this.scale = this.canvasWidth / this.pageWidth;
  8135. this.l10n = l10n;
  8136. var anchor = document.createElement('a');
  8137. anchor.href = linkService.getAnchorUrl('#page=' + id);
  8138. this.l10n.get('thumb_page_title', {
  8139. page: id
  8140. }, 'Page {{page}}').then(function (msg) {
  8141. anchor.title = msg;
  8142. });
  8143. anchor.onclick = function () {
  8144. linkService.page = id;
  8145. return false;
  8146. };
  8147. this.anchor = anchor;
  8148. var div = document.createElement('div');
  8149. div.className = 'thumbnail';
  8150. div.setAttribute('data-page-number', this.id);
  8151. this.div = div;
  8152. var ring = document.createElement('div');
  8153. ring.className = 'thumbnailSelectionRing';
  8154. var borderAdjustment = 2 * THUMBNAIL_CANVAS_BORDER_WIDTH;
  8155. ring.style.width = this.canvasWidth + borderAdjustment + 'px';
  8156. ring.style.height = this.canvasHeight + borderAdjustment + 'px';
  8157. this.ring = ring;
  8158. div.appendChild(ring);
  8159. anchor.appendChild(div);
  8160. container.appendChild(anchor);
  8161. }
  8162. _createClass(PDFThumbnailView, [{
  8163. key: "setPdfPage",
  8164. value: function setPdfPage(pdfPage) {
  8165. this.pdfPage = pdfPage;
  8166. this.pdfPageRotate = pdfPage.rotate;
  8167. var totalRotation = (this.rotation + this.pdfPageRotate) % 360;
  8168. this.viewport = pdfPage.getViewport({
  8169. scale: 1,
  8170. rotation: totalRotation
  8171. });
  8172. this.reset();
  8173. }
  8174. }, {
  8175. key: "reset",
  8176. value: function reset() {
  8177. this.cancelRendering();
  8178. this.renderingState = _pdf_rendering_queue.RenderingStates.INITIAL;
  8179. this.pageWidth = this.viewport.width;
  8180. this.pageHeight = this.viewport.height;
  8181. this.pageRatio = this.pageWidth / this.pageHeight;
  8182. this.canvasHeight = this.canvasWidth / this.pageRatio | 0;
  8183. this.scale = this.canvasWidth / this.pageWidth;
  8184. this.div.removeAttribute('data-loaded');
  8185. var ring = this.ring;
  8186. var childNodes = ring.childNodes;
  8187. for (var i = childNodes.length - 1; i >= 0; i--) {
  8188. ring.removeChild(childNodes[i]);
  8189. }
  8190. var borderAdjustment = 2 * THUMBNAIL_CANVAS_BORDER_WIDTH;
  8191. ring.style.width = this.canvasWidth + borderAdjustment + 'px';
  8192. ring.style.height = this.canvasHeight + borderAdjustment + 'px';
  8193. if (this.canvas) {
  8194. this.canvas.width = 0;
  8195. this.canvas.height = 0;
  8196. delete this.canvas;
  8197. }
  8198. if (this.image) {
  8199. this.image.removeAttribute('src');
  8200. delete this.image;
  8201. }
  8202. }
  8203. }, {
  8204. key: "update",
  8205. value: function update(rotation) {
  8206. if (typeof rotation !== 'undefined') {
  8207. this.rotation = rotation;
  8208. }
  8209. var totalRotation = (this.rotation + this.pdfPageRotate) % 360;
  8210. this.viewport = this.viewport.clone({
  8211. scale: 1,
  8212. rotation: totalRotation
  8213. });
  8214. this.reset();
  8215. }
  8216. }, {
  8217. key: "cancelRendering",
  8218. value: function cancelRendering() {
  8219. if (this.renderTask) {
  8220. this.renderTask.cancel();
  8221. this.renderTask = null;
  8222. }
  8223. this.resume = null;
  8224. }
  8225. }, {
  8226. key: "_getPageDrawContext",
  8227. value: function _getPageDrawContext() {
  8228. var noCtxScale = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  8229. var canvas = document.createElement('canvas');
  8230. this.canvas = canvas;
  8231. canvas.mozOpaque = true;
  8232. var ctx = canvas.getContext('2d', {
  8233. alpha: false
  8234. });
  8235. var outputScale = (0, _ui_utils.getOutputScale)(ctx);
  8236. canvas.width = this.canvasWidth * outputScale.sx | 0;
  8237. canvas.height = this.canvasHeight * outputScale.sy | 0;
  8238. canvas.style.width = this.canvasWidth + 'px';
  8239. canvas.style.height = this.canvasHeight + 'px';
  8240. if (!noCtxScale && outputScale.scaled) {
  8241. ctx.scale(outputScale.sx, outputScale.sy);
  8242. }
  8243. return ctx;
  8244. }
  8245. }, {
  8246. key: "_convertCanvasToImage",
  8247. value: function _convertCanvasToImage() {
  8248. var _this = this;
  8249. if (!this.canvas) {
  8250. return;
  8251. }
  8252. if (this.renderingState !== _pdf_rendering_queue.RenderingStates.FINISHED) {
  8253. return;
  8254. }
  8255. var id = this.renderingId;
  8256. var className = 'thumbnailImage';
  8257. if (this.disableCanvasToImageConversion) {
  8258. this.canvas.id = id;
  8259. this.canvas.className = className;
  8260. this.l10n.get('thumb_page_canvas', {
  8261. page: this.pageId
  8262. }, 'Thumbnail of Page {{page}}').then(function (msg) {
  8263. _this.canvas.setAttribute('aria-label', msg);
  8264. });
  8265. this.div.setAttribute('data-loaded', true);
  8266. this.ring.appendChild(this.canvas);
  8267. return;
  8268. }
  8269. var image = document.createElement('img');
  8270. image.id = id;
  8271. image.className = className;
  8272. this.l10n.get('thumb_page_canvas', {
  8273. page: this.pageId
  8274. }, 'Thumbnail of Page {{page}}').then(function (msg) {
  8275. image.setAttribute('aria-label', msg);
  8276. });
  8277. image.style.width = this.canvasWidth + 'px';
  8278. image.style.height = this.canvasHeight + 'px';
  8279. image.src = this.canvas.toDataURL();
  8280. this.image = image;
  8281. this.div.setAttribute('data-loaded', true);
  8282. this.ring.appendChild(image);
  8283. this.canvas.width = 0;
  8284. this.canvas.height = 0;
  8285. delete this.canvas;
  8286. }
  8287. }, {
  8288. key: "draw",
  8289. value: function draw() {
  8290. var _this2 = this;
  8291. if (this.renderingState !== _pdf_rendering_queue.RenderingStates.INITIAL) {
  8292. console.error('Must be in new state before drawing');
  8293. return Promise.resolve(undefined);
  8294. }
  8295. this.renderingState = _pdf_rendering_queue.RenderingStates.RUNNING;
  8296. var renderCapability = (0, _pdfjsLib.createPromiseCapability)();
  8297. var finishRenderTask = function finishRenderTask(error) {
  8298. if (renderTask === _this2.renderTask) {
  8299. _this2.renderTask = null;
  8300. }
  8301. if (error instanceof _pdfjsLib.RenderingCancelledException) {
  8302. renderCapability.resolve(undefined);
  8303. return;
  8304. }
  8305. _this2.renderingState = _pdf_rendering_queue.RenderingStates.FINISHED;
  8306. _this2._convertCanvasToImage();
  8307. if (!error) {
  8308. renderCapability.resolve(undefined);
  8309. } else {
  8310. renderCapability.reject(error);
  8311. }
  8312. };
  8313. var ctx = this._getPageDrawContext();
  8314. var drawViewport = this.viewport.clone({
  8315. scale: this.scale
  8316. });
  8317. var renderContinueCallback = function renderContinueCallback(cont) {
  8318. if (!_this2.renderingQueue.isHighestPriority(_this2)) {
  8319. _this2.renderingState = _pdf_rendering_queue.RenderingStates.PAUSED;
  8320. _this2.resume = function () {
  8321. _this2.renderingState = _pdf_rendering_queue.RenderingStates.RUNNING;
  8322. cont();
  8323. };
  8324. return;
  8325. }
  8326. cont();
  8327. };
  8328. var renderContext = {
  8329. canvasContext: ctx,
  8330. viewport: drawViewport
  8331. };
  8332. var renderTask = this.renderTask = this.pdfPage.render(renderContext);
  8333. renderTask.onContinue = renderContinueCallback;
  8334. renderTask.promise.then(function () {
  8335. finishRenderTask(null);
  8336. }, function (error) {
  8337. finishRenderTask(error);
  8338. });
  8339. return renderCapability.promise;
  8340. }
  8341. }, {
  8342. key: "setImage",
  8343. value: function setImage(pageView) {
  8344. if (this.renderingState !== _pdf_rendering_queue.RenderingStates.INITIAL) {
  8345. return;
  8346. }
  8347. var img = pageView.canvas;
  8348. if (!img) {
  8349. return;
  8350. }
  8351. if (!this.pdfPage) {
  8352. this.setPdfPage(pageView.pdfPage);
  8353. }
  8354. this.renderingState = _pdf_rendering_queue.RenderingStates.FINISHED;
  8355. var ctx = this._getPageDrawContext(true);
  8356. var canvas = ctx.canvas;
  8357. if (img.width <= 2 * canvas.width) {
  8358. ctx.drawImage(img, 0, 0, img.width, img.height, 0, 0, canvas.width, canvas.height);
  8359. this._convertCanvasToImage();
  8360. return;
  8361. }
  8362. var reducedWidth = canvas.width << MAX_NUM_SCALING_STEPS;
  8363. var reducedHeight = canvas.height << MAX_NUM_SCALING_STEPS;
  8364. var reducedImage = TempImageFactory.getCanvas(reducedWidth, reducedHeight);
  8365. var reducedImageCtx = reducedImage.getContext('2d');
  8366. while (reducedWidth > img.width || reducedHeight > img.height) {
  8367. reducedWidth >>= 1;
  8368. reducedHeight >>= 1;
  8369. }
  8370. reducedImageCtx.drawImage(img, 0, 0, img.width, img.height, 0, 0, reducedWidth, reducedHeight);
  8371. while (reducedWidth > 2 * canvas.width) {
  8372. reducedImageCtx.drawImage(reducedImage, 0, 0, reducedWidth, reducedHeight, 0, 0, reducedWidth >> 1, reducedHeight >> 1);
  8373. reducedWidth >>= 1;
  8374. reducedHeight >>= 1;
  8375. }
  8376. ctx.drawImage(reducedImage, 0, 0, reducedWidth, reducedHeight, 0, 0, canvas.width, canvas.height);
  8377. this._convertCanvasToImage();
  8378. }
  8379. }, {
  8380. key: "setPageLabel",
  8381. value: function setPageLabel(label) {
  8382. var _this3 = this;
  8383. this.pageLabel = typeof label === 'string' ? label : null;
  8384. this.l10n.get('thumb_page_title', {
  8385. page: this.pageId
  8386. }, 'Page {{page}}').then(function (msg) {
  8387. _this3.anchor.title = msg;
  8388. });
  8389. if (this.renderingState !== _pdf_rendering_queue.RenderingStates.FINISHED) {
  8390. return;
  8391. }
  8392. this.l10n.get('thumb_page_canvas', {
  8393. page: this.pageId
  8394. }, 'Thumbnail of Page {{page}}').then(function (ariaLabel) {
  8395. if (_this3.image) {
  8396. _this3.image.setAttribute('aria-label', ariaLabel);
  8397. } else if (_this3.disableCanvasToImageConversion && _this3.canvas) {
  8398. _this3.canvas.setAttribute('aria-label', ariaLabel);
  8399. }
  8400. });
  8401. }
  8402. }, {
  8403. key: "pageId",
  8404. get: function get() {
  8405. return this.pageLabel !== null ? this.pageLabel : this.id;
  8406. }
  8407. }], [{
  8408. key: "cleanup",
  8409. value: function cleanup() {
  8410. TempImageFactory.destroyCanvas();
  8411. }
  8412. }]);
  8413. return PDFThumbnailView;
  8414. }();
  8415. exports.PDFThumbnailView = PDFThumbnailView;
  8416. /***/ }),
  8417. /* 27 */
  8418. /***/ (function(module, exports, __webpack_require__) {
  8419. "use strict";
  8420. Object.defineProperty(exports, "__esModule", {
  8421. value: true
  8422. });
  8423. exports.PDFViewer = void 0;
  8424. var _base_viewer = __webpack_require__(28);
  8425. var _pdfjsLib = __webpack_require__(7);
  8426. function _typeof(obj) { 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); }
  8427. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  8428. 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); } }
  8429. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  8430. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  8431. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  8432. 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); }
  8433. function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
  8434. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  8435. 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); }
  8436. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  8437. var PDFViewer =
  8438. /*#__PURE__*/
  8439. function (_BaseViewer) {
  8440. _inherits(PDFViewer, _BaseViewer);
  8441. function PDFViewer() {
  8442. _classCallCheck(this, PDFViewer);
  8443. return _possibleConstructorReturn(this, _getPrototypeOf(PDFViewer).apply(this, arguments));
  8444. }
  8445. _createClass(PDFViewer, [{
  8446. key: "_scrollIntoView",
  8447. value: function _scrollIntoView(_ref) {
  8448. var pageDiv = _ref.pageDiv,
  8449. _ref$pageSpot = _ref.pageSpot,
  8450. pageSpot = _ref$pageSpot === void 0 ? null : _ref$pageSpot,
  8451. _ref$pageNumber = _ref.pageNumber,
  8452. pageNumber = _ref$pageNumber === void 0 ? null : _ref$pageNumber;
  8453. if (!pageSpot && !this.isInPresentationMode) {
  8454. var left = pageDiv.offsetLeft + pageDiv.clientLeft;
  8455. var right = left + pageDiv.clientWidth;
  8456. var _this$container = this.container,
  8457. scrollLeft = _this$container.scrollLeft,
  8458. clientWidth = _this$container.clientWidth;
  8459. if (this._isScrollModeHorizontal || left < scrollLeft || right > scrollLeft + clientWidth) {
  8460. pageSpot = {
  8461. left: 0,
  8462. top: 0
  8463. };
  8464. }
  8465. }
  8466. _get(_getPrototypeOf(PDFViewer.prototype), "_scrollIntoView", this).call(this, {
  8467. pageDiv: pageDiv,
  8468. pageSpot: pageSpot,
  8469. pageNumber: pageNumber
  8470. });
  8471. }
  8472. }, {
  8473. key: "_getVisiblePages",
  8474. value: function _getVisiblePages() {
  8475. if (this.isInPresentationMode) {
  8476. return this._getCurrentVisiblePage();
  8477. }
  8478. return _get(_getPrototypeOf(PDFViewer.prototype), "_getVisiblePages", this).call(this);
  8479. }
  8480. }, {
  8481. key: "_updateHelper",
  8482. value: function _updateHelper(visiblePages) {
  8483. if (this.isInPresentationMode) {
  8484. return;
  8485. }
  8486. var currentId = this._currentPageNumber;
  8487. var stillFullyVisible = false;
  8488. var _iteratorNormalCompletion = true;
  8489. var _didIteratorError = false;
  8490. var _iteratorError = undefined;
  8491. try {
  8492. for (var _iterator = visiblePages[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
  8493. var page = _step.value;
  8494. if (page.percent < 100) {
  8495. break;
  8496. }
  8497. if (page.id === currentId) {
  8498. stillFullyVisible = true;
  8499. break;
  8500. }
  8501. }
  8502. } catch (err) {
  8503. _didIteratorError = true;
  8504. _iteratorError = err;
  8505. } finally {
  8506. try {
  8507. if (!_iteratorNormalCompletion && _iterator["return"] != null) {
  8508. _iterator["return"]();
  8509. }
  8510. } finally {
  8511. if (_didIteratorError) {
  8512. throw _iteratorError;
  8513. }
  8514. }
  8515. }
  8516. if (!stillFullyVisible) {
  8517. currentId = visiblePages[0].id;
  8518. }
  8519. this._setCurrentPageNumber(currentId);
  8520. }
  8521. }, {
  8522. key: "_setDocumentViewerElement",
  8523. get: function get() {
  8524. return (0, _pdfjsLib.shadow)(this, '_setDocumentViewerElement', this.viewer);
  8525. }
  8526. }]);
  8527. return PDFViewer;
  8528. }(_base_viewer.BaseViewer);
  8529. exports.PDFViewer = PDFViewer;
  8530. /***/ }),
  8531. /* 28 */
  8532. /***/ (function(module, exports, __webpack_require__) {
  8533. "use strict";
  8534. Object.defineProperty(exports, "__esModule", {
  8535. value: true
  8536. });
  8537. exports.BaseViewer = void 0;
  8538. var _ui_utils = __webpack_require__(5);
  8539. var _pdf_rendering_queue = __webpack_require__(11);
  8540. var _annotation_layer_builder = __webpack_require__(29);
  8541. var _pdfjsLib = __webpack_require__(7);
  8542. var _pdf_page_view = __webpack_require__(30);
  8543. var _pdf_link_service = __webpack_require__(21);
  8544. var _text_layer_builder = __webpack_require__(31);
  8545. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  8546. 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); } }
  8547. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  8548. var DEFAULT_CACHE_SIZE = 10;
  8549. function PDFPageViewBuffer(size) {
  8550. var data = [];
  8551. this.push = function (view) {
  8552. var i = data.indexOf(view);
  8553. if (i >= 0) {
  8554. data.splice(i, 1);
  8555. }
  8556. data.push(view);
  8557. if (data.length > size) {
  8558. data.shift().destroy();
  8559. }
  8560. };
  8561. this.resize = function (newSize, pagesToKeep) {
  8562. size = newSize;
  8563. if (pagesToKeep) {
  8564. var pageIdsToKeep = new Set();
  8565. for (var i = 0, iMax = pagesToKeep.length; i < iMax; ++i) {
  8566. pageIdsToKeep.add(pagesToKeep[i].id);
  8567. }
  8568. (0, _ui_utils.moveToEndOfArray)(data, function (page) {
  8569. return pageIdsToKeep.has(page.id);
  8570. });
  8571. }
  8572. while (data.length > size) {
  8573. data.shift().destroy();
  8574. }
  8575. };
  8576. }
  8577. function isSameScale(oldScale, newScale) {
  8578. if (newScale === oldScale) {
  8579. return true;
  8580. }
  8581. if (Math.abs(newScale - oldScale) < 1e-15) {
  8582. return true;
  8583. }
  8584. return false;
  8585. }
  8586. var BaseViewer =
  8587. /*#__PURE__*/
  8588. function () {
  8589. function BaseViewer(options) {
  8590. var _this = this;
  8591. _classCallCheck(this, BaseViewer);
  8592. if (this.constructor === BaseViewer) {
  8593. throw new Error('Cannot initialize BaseViewer.');
  8594. }
  8595. this._name = this.constructor.name;
  8596. this.container = options.container;
  8597. this.viewer = options.viewer || options.container.firstElementChild;
  8598. this.eventBus = options.eventBus || (0, _ui_utils.getGlobalEventBus)();
  8599. this.linkService = options.linkService || new _pdf_link_service.SimpleLinkService();
  8600. this.downloadManager = options.downloadManager || null;
  8601. this.findController = options.findController || null;
  8602. this.removePageBorders = options.removePageBorders || false;
  8603. this.textLayerMode = Number.isInteger(options.textLayerMode) ? options.textLayerMode : _ui_utils.TextLayerMode.ENABLE;
  8604. this.imageResourcesPath = options.imageResourcesPath || '';
  8605. this.renderInteractiveForms = options.renderInteractiveForms || false;
  8606. this.enablePrintAutoRotate = options.enablePrintAutoRotate || false;
  8607. this.renderer = options.renderer || _ui_utils.RendererType.CANVAS;
  8608. this.enableWebGL = options.enableWebGL || false;
  8609. this.useOnlyCssZoom = options.useOnlyCssZoom || false;
  8610. this.maxCanvasPixels = options.maxCanvasPixels;
  8611. this.l10n = options.l10n || _ui_utils.NullL10n;
  8612. this.defaultRenderingQueue = !options.renderingQueue;
  8613. if (this.defaultRenderingQueue) {
  8614. this.renderingQueue = new _pdf_rendering_queue.PDFRenderingQueue();
  8615. this.renderingQueue.setViewer(this);
  8616. } else {
  8617. this.renderingQueue = options.renderingQueue;
  8618. }
  8619. this.scroll = (0, _ui_utils.watchScroll)(this.container, this._scrollUpdate.bind(this));
  8620. this.presentationModeState = _ui_utils.PresentationModeState.UNKNOWN;
  8621. this._onBeforeDraw = this._onAfterDraw = null;
  8622. this._resetView();
  8623. if (this.removePageBorders) {
  8624. this.viewer.classList.add('removePageBorders');
  8625. }
  8626. Promise.resolve().then(function () {
  8627. _this.eventBus.dispatch('baseviewerinit', {
  8628. source: _this
  8629. });
  8630. });
  8631. }
  8632. _createClass(BaseViewer, [{
  8633. key: "getPageView",
  8634. value: function getPageView(index) {
  8635. return this._pages[index];
  8636. }
  8637. }, {
  8638. key: "_setCurrentPageNumber",
  8639. value: function _setCurrentPageNumber(val) {
  8640. var resetCurrentPageView = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  8641. if (this._currentPageNumber === val) {
  8642. if (resetCurrentPageView) {
  8643. this._resetCurrentPageView();
  8644. }
  8645. return true;
  8646. }
  8647. if (!(0 < val && val <= this.pagesCount)) {
  8648. return false;
  8649. }
  8650. this._currentPageNumber = val;
  8651. this.eventBus.dispatch('pagechanging', {
  8652. source: this,
  8653. pageNumber: val,
  8654. pageLabel: this._pageLabels && this._pageLabels[val - 1]
  8655. });
  8656. if (resetCurrentPageView) {
  8657. this._resetCurrentPageView();
  8658. }
  8659. return true;
  8660. }
  8661. }, {
  8662. key: "setDocument",
  8663. value: function setDocument(pdfDocument) {
  8664. var _this2 = this;
  8665. if (this.pdfDocument) {
  8666. this._cancelRendering();
  8667. this._resetView();
  8668. if (this.findController) {
  8669. this.findController.setDocument(null);
  8670. }
  8671. }
  8672. this.pdfDocument = pdfDocument;
  8673. if (!pdfDocument) {
  8674. return;
  8675. }
  8676. var pagesCount = pdfDocument.numPages;
  8677. var pagesCapability = (0, _pdfjsLib.createPromiseCapability)();
  8678. this.pagesPromise = pagesCapability.promise;
  8679. pagesCapability.promise.then(function () {
  8680. _this2._pageViewsReady = true;
  8681. _this2.eventBus.dispatch('pagesloaded', {
  8682. source: _this2,
  8683. pagesCount: pagesCount
  8684. });
  8685. });
  8686. var onePageRenderedCapability = (0, _pdfjsLib.createPromiseCapability)();
  8687. this.onePageRendered = onePageRenderedCapability.promise;
  8688. var firstPagePromise = pdfDocument.getPage(1);
  8689. this.firstPagePromise = firstPagePromise;
  8690. this._onBeforeDraw = function (evt) {
  8691. var pageView = _this2._pages[evt.pageNumber - 1];
  8692. if (!pageView) {
  8693. return;
  8694. }
  8695. _this2._buffer.push(pageView);
  8696. };
  8697. this.eventBus.on('pagerender', this._onBeforeDraw);
  8698. this._onAfterDraw = function (evt) {
  8699. if (evt.cssTransform || onePageRenderedCapability.settled) {
  8700. return;
  8701. }
  8702. onePageRenderedCapability.resolve();
  8703. _this2.eventBus.off('pagerendered', _this2._onAfterDraw);
  8704. _this2._onAfterDraw = null;
  8705. };
  8706. this.eventBus.on('pagerendered', this._onAfterDraw);
  8707. firstPagePromise.then(function (pdfPage) {
  8708. var scale = _this2.currentScale;
  8709. var viewport = pdfPage.getViewport({
  8710. scale: scale * _ui_utils.CSS_UNITS
  8711. });
  8712. for (var pageNum = 1; pageNum <= pagesCount; ++pageNum) {
  8713. var textLayerFactory = null;
  8714. if (_this2.textLayerMode !== _ui_utils.TextLayerMode.DISABLE) {
  8715. textLayerFactory = _this2;
  8716. }
  8717. var pageView = new _pdf_page_view.PDFPageView({
  8718. container: _this2._setDocumentViewerElement,
  8719. eventBus: _this2.eventBus,
  8720. id: pageNum,
  8721. scale: scale,
  8722. defaultViewport: viewport.clone(),
  8723. renderingQueue: _this2.renderingQueue,
  8724. textLayerFactory: textLayerFactory,
  8725. textLayerMode: _this2.textLayerMode,
  8726. annotationLayerFactory: _this2,
  8727. imageResourcesPath: _this2.imageResourcesPath,
  8728. renderInteractiveForms: _this2.renderInteractiveForms,
  8729. renderer: _this2.renderer,
  8730. enableWebGL: _this2.enableWebGL,
  8731. useOnlyCssZoom: _this2.useOnlyCssZoom,
  8732. maxCanvasPixels: _this2.maxCanvasPixels,
  8733. l10n: _this2.l10n
  8734. });
  8735. _this2._pages.push(pageView);
  8736. }
  8737. if (_this2._spreadMode !== _ui_utils.SpreadMode.NONE) {
  8738. _this2._updateSpreadMode();
  8739. }
  8740. onePageRenderedCapability.promise.then(function () {
  8741. if (_this2.findController) {
  8742. _this2.findController.setDocument(pdfDocument);
  8743. }
  8744. if (pdfDocument.loadingParams['disableAutoFetch']) {
  8745. pagesCapability.resolve();
  8746. return;
  8747. }
  8748. var getPagesLeft = pagesCount;
  8749. var _loop = function _loop(_pageNum) {
  8750. pdfDocument.getPage(_pageNum).then(function (pdfPage) {
  8751. var pageView = _this2._pages[_pageNum - 1];
  8752. if (!pageView.pdfPage) {
  8753. pageView.setPdfPage(pdfPage);
  8754. }
  8755. _this2.linkService.cachePageRef(_pageNum, pdfPage.ref);
  8756. if (--getPagesLeft === 0) {
  8757. pagesCapability.resolve();
  8758. }
  8759. }, function (reason) {
  8760. console.error("Unable to get page ".concat(_pageNum, " to initialize viewer"), reason);
  8761. if (--getPagesLeft === 0) {
  8762. pagesCapability.resolve();
  8763. }
  8764. });
  8765. };
  8766. for (var _pageNum = 1; _pageNum <= pagesCount; ++_pageNum) {
  8767. _loop(_pageNum);
  8768. }
  8769. });
  8770. _this2.eventBus.dispatch('pagesinit', {
  8771. source: _this2
  8772. });
  8773. if (_this2.defaultRenderingQueue) {
  8774. _this2.update();
  8775. }
  8776. })["catch"](function (reason) {
  8777. console.error('Unable to initialize viewer', reason);
  8778. });
  8779. }
  8780. }, {
  8781. key: "setPageLabels",
  8782. value: function setPageLabels(labels) {
  8783. if (!this.pdfDocument) {
  8784. return;
  8785. }
  8786. if (!labels) {
  8787. this._pageLabels = null;
  8788. } else if (!(Array.isArray(labels) && this.pdfDocument.numPages === labels.length)) {
  8789. this._pageLabels = null;
  8790. console.error("".concat(this._name, ".setPageLabels: Invalid page labels."));
  8791. } else {
  8792. this._pageLabels = labels;
  8793. }
  8794. for (var i = 0, ii = this._pages.length; i < ii; i++) {
  8795. var pageView = this._pages[i];
  8796. var label = this._pageLabels && this._pageLabels[i];
  8797. pageView.setPageLabel(label);
  8798. }
  8799. }
  8800. }, {
  8801. key: "_resetView",
  8802. value: function _resetView() {
  8803. this._pages = [];
  8804. this._currentPageNumber = 1;
  8805. this._currentScale = _ui_utils.UNKNOWN_SCALE;
  8806. this._currentScaleValue = null;
  8807. this._pageLabels = null;
  8808. this._buffer = new PDFPageViewBuffer(DEFAULT_CACHE_SIZE);
  8809. this._location = null;
  8810. this._pagesRotation = 0;
  8811. this._pagesRequests = [];
  8812. this._pageViewsReady = false;
  8813. this._scrollMode = _ui_utils.ScrollMode.VERTICAL;
  8814. this._spreadMode = _ui_utils.SpreadMode.NONE;
  8815. if (this._onBeforeDraw) {
  8816. this.eventBus.off('pagerender', this._onBeforeDraw);
  8817. this._onBeforeDraw = null;
  8818. }
  8819. if (this._onAfterDraw) {
  8820. this.eventBus.off('pagerendered', this._onAfterDraw);
  8821. this._onAfterDraw = null;
  8822. }
  8823. this.viewer.textContent = '';
  8824. this._updateScrollMode();
  8825. }
  8826. }, {
  8827. key: "_scrollUpdate",
  8828. value: function _scrollUpdate() {
  8829. if (this.pagesCount === 0) {
  8830. return;
  8831. }
  8832. this.update();
  8833. }
  8834. }, {
  8835. key: "_scrollIntoView",
  8836. value: function _scrollIntoView(_ref) {
  8837. var pageDiv = _ref.pageDiv,
  8838. _ref$pageSpot = _ref.pageSpot,
  8839. pageSpot = _ref$pageSpot === void 0 ? null : _ref$pageSpot,
  8840. _ref$pageNumber = _ref.pageNumber,
  8841. pageNumber = _ref$pageNumber === void 0 ? null : _ref$pageNumber;
  8842. (0, _ui_utils.scrollIntoView)(pageDiv, pageSpot);
  8843. }
  8844. }, {
  8845. key: "_setScaleUpdatePages",
  8846. value: function _setScaleUpdatePages(newScale, newValue) {
  8847. var noScroll = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  8848. var preset = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
  8849. this._currentScaleValue = newValue.toString();
  8850. if (isSameScale(this._currentScale, newScale)) {
  8851. if (preset) {
  8852. this.eventBus.dispatch('scalechanging', {
  8853. source: this,
  8854. scale: newScale,
  8855. presetValue: newValue
  8856. });
  8857. }
  8858. return;
  8859. }
  8860. for (var i = 0, ii = this._pages.length; i < ii; i++) {
  8861. this._pages[i].update(newScale);
  8862. }
  8863. this._currentScale = newScale;
  8864. if (!noScroll) {
  8865. var page = this._currentPageNumber,
  8866. dest;
  8867. if (this._location && !(this.isInPresentationMode || this.isChangingPresentationMode)) {
  8868. page = this._location.pageNumber;
  8869. dest = [null, {
  8870. name: 'XYZ'
  8871. }, this._location.left, this._location.top, null];
  8872. }
  8873. this.scrollPageIntoView({
  8874. pageNumber: page,
  8875. destArray: dest,
  8876. allowNegativeOffset: true
  8877. });
  8878. }
  8879. this.eventBus.dispatch('scalechanging', {
  8880. source: this,
  8881. scale: newScale,
  8882. presetValue: preset ? newValue : undefined
  8883. });
  8884. if (this.defaultRenderingQueue) {
  8885. this.update();
  8886. }
  8887. }
  8888. }, {
  8889. key: "_setScale",
  8890. value: function _setScale(value) {
  8891. var noScroll = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  8892. var scale = parseFloat(value);
  8893. if (scale > 0) {
  8894. this._setScaleUpdatePages(scale, value, noScroll, false);
  8895. } else {
  8896. var currentPage = this._pages[this._currentPageNumber - 1];
  8897. if (!currentPage) {
  8898. return;
  8899. }
  8900. var noPadding = this.isInPresentationMode || this.removePageBorders;
  8901. var hPadding = noPadding ? 0 : _ui_utils.SCROLLBAR_PADDING;
  8902. var vPadding = noPadding ? 0 : _ui_utils.VERTICAL_PADDING;
  8903. if (!noPadding && this._isScrollModeHorizontal) {
  8904. var _ref2 = [vPadding, hPadding];
  8905. hPadding = _ref2[0];
  8906. vPadding = _ref2[1];
  8907. }
  8908. var pageWidthScale = (this.container.clientWidth - hPadding) / currentPage.width * currentPage.scale;
  8909. var pageHeightScale = (this.container.clientHeight - vPadding) / currentPage.height * currentPage.scale;
  8910. switch (value) {
  8911. case 'page-actual':
  8912. scale = 1;
  8913. break;
  8914. case 'page-width':
  8915. scale = pageWidthScale;
  8916. break;
  8917. case 'page-height':
  8918. scale = pageHeightScale;
  8919. break;
  8920. case 'page-fit':
  8921. scale = Math.min(pageWidthScale, pageHeightScale);
  8922. break;
  8923. case 'auto':
  8924. var horizontalScale = (0, _ui_utils.isPortraitOrientation)(currentPage) ? pageWidthScale : Math.min(pageHeightScale, pageWidthScale);
  8925. scale = Math.min(_ui_utils.MAX_AUTO_SCALE, horizontalScale);
  8926. break;
  8927. default:
  8928. console.error("".concat(this._name, "._setScale: \"").concat(value, "\" is an unknown zoom value."));
  8929. return;
  8930. }
  8931. this._setScaleUpdatePages(scale, value, noScroll, true);
  8932. }
  8933. }
  8934. }, {
  8935. key: "_resetCurrentPageView",
  8936. value: function _resetCurrentPageView() {
  8937. if (this.isInPresentationMode) {
  8938. this._setScale(this._currentScaleValue, true);
  8939. }
  8940. var pageView = this._pages[this._currentPageNumber - 1];
  8941. this._scrollIntoView({
  8942. pageDiv: pageView.div
  8943. });
  8944. }
  8945. }, {
  8946. key: "scrollPageIntoView",
  8947. value: function scrollPageIntoView(_ref3) {
  8948. var pageNumber = _ref3.pageNumber,
  8949. _ref3$destArray = _ref3.destArray,
  8950. destArray = _ref3$destArray === void 0 ? null : _ref3$destArray,
  8951. _ref3$allowNegativeOf = _ref3.allowNegativeOffset,
  8952. allowNegativeOffset = _ref3$allowNegativeOf === void 0 ? false : _ref3$allowNegativeOf;
  8953. if (!this.pdfDocument) {
  8954. return;
  8955. }
  8956. var pageView = Number.isInteger(pageNumber) && this._pages[pageNumber - 1];
  8957. if (!pageView) {
  8958. console.error("".concat(this._name, ".scrollPageIntoView: ") + "\"".concat(pageNumber, "\" is not a valid pageNumber parameter."));
  8959. return;
  8960. }
  8961. if (this.isInPresentationMode || !destArray) {
  8962. this._setCurrentPageNumber(pageNumber, true);
  8963. return;
  8964. }
  8965. var x = 0,
  8966. y = 0;
  8967. var width = 0,
  8968. height = 0,
  8969. widthScale,
  8970. heightScale;
  8971. var changeOrientation = pageView.rotation % 180 === 0 ? false : true;
  8972. var pageWidth = (changeOrientation ? pageView.height : pageView.width) / pageView.scale / _ui_utils.CSS_UNITS;
  8973. var pageHeight = (changeOrientation ? pageView.width : pageView.height) / pageView.scale / _ui_utils.CSS_UNITS;
  8974. var scale = 0;
  8975. switch (destArray[1].name) {
  8976. case 'XYZ':
  8977. x = destArray[2];
  8978. y = destArray[3];
  8979. scale = destArray[4];
  8980. x = x !== null ? x : 0;
  8981. y = y !== null ? y : pageHeight;
  8982. break;
  8983. case 'Fit':
  8984. case 'FitB':
  8985. scale = 'page-fit';
  8986. break;
  8987. case 'FitH':
  8988. case 'FitBH':
  8989. y = destArray[2];
  8990. scale = 'page-width';
  8991. if (y === null && this._location) {
  8992. x = this._location.left;
  8993. y = this._location.top;
  8994. }
  8995. break;
  8996. case 'FitV':
  8997. case 'FitBV':
  8998. x = destArray[2];
  8999. width = pageWidth;
  9000. height = pageHeight;
  9001. scale = 'page-height';
  9002. break;
  9003. case 'FitR':
  9004. x = destArray[2];
  9005. y = destArray[3];
  9006. width = destArray[4] - x;
  9007. height = destArray[5] - y;
  9008. var hPadding = this.removePageBorders ? 0 : _ui_utils.SCROLLBAR_PADDING;
  9009. var vPadding = this.removePageBorders ? 0 : _ui_utils.VERTICAL_PADDING;
  9010. widthScale = (this.container.clientWidth - hPadding) / width / _ui_utils.CSS_UNITS;
  9011. heightScale = (this.container.clientHeight - vPadding) / height / _ui_utils.CSS_UNITS;
  9012. scale = Math.min(Math.abs(widthScale), Math.abs(heightScale));
  9013. break;
  9014. default:
  9015. console.error("".concat(this._name, ".scrollPageIntoView: ") + "\"".concat(destArray[1].name, "\" is not a valid destination type."));
  9016. return;
  9017. }
  9018. if (scale && scale !== this._currentScale) {
  9019. this.currentScaleValue = scale;
  9020. } else if (this._currentScale === _ui_utils.UNKNOWN_SCALE) {
  9021. this.currentScaleValue = _ui_utils.DEFAULT_SCALE_VALUE;
  9022. }
  9023. if (scale === 'page-fit' && !destArray[4]) {
  9024. this._scrollIntoView({
  9025. pageDiv: pageView.div,
  9026. pageNumber: pageNumber
  9027. });
  9028. return;
  9029. }
  9030. var boundingRect = [pageView.viewport.convertToViewportPoint(x, y), pageView.viewport.convertToViewportPoint(x + width, y + height)];
  9031. var left = Math.min(boundingRect[0][0], boundingRect[1][0]);
  9032. var top = Math.min(boundingRect[0][1], boundingRect[1][1]);
  9033. if (!allowNegativeOffset) {
  9034. left = Math.max(left, 0);
  9035. top = Math.max(top, 0);
  9036. }
  9037. this._scrollIntoView({
  9038. pageDiv: pageView.div,
  9039. pageSpot: {
  9040. left: left,
  9041. top: top
  9042. },
  9043. pageNumber: pageNumber
  9044. });
  9045. }
  9046. }, {
  9047. key: "_updateLocation",
  9048. value: function _updateLocation(firstPage) {
  9049. var currentScale = this._currentScale;
  9050. var currentScaleValue = this._currentScaleValue;
  9051. var normalizedScaleValue = parseFloat(currentScaleValue) === currentScale ? Math.round(currentScale * 10000) / 100 : currentScaleValue;
  9052. var pageNumber = firstPage.id;
  9053. var pdfOpenParams = '#page=' + pageNumber;
  9054. pdfOpenParams += '&zoom=' + normalizedScaleValue;
  9055. var currentPageView = this._pages[pageNumber - 1];
  9056. var container = this.container;
  9057. var topLeft = currentPageView.getPagePoint(container.scrollLeft - firstPage.x, container.scrollTop - firstPage.y);
  9058. var intLeft = Math.round(topLeft[0]);
  9059. var intTop = Math.round(topLeft[1]);
  9060. pdfOpenParams += ',' + intLeft + ',' + intTop;
  9061. this._location = {
  9062. pageNumber: pageNumber,
  9063. scale: normalizedScaleValue,
  9064. top: intTop,
  9065. left: intLeft,
  9066. rotation: this._pagesRotation,
  9067. pdfOpenParams: pdfOpenParams
  9068. };
  9069. }
  9070. }, {
  9071. key: "_updateHelper",
  9072. value: function _updateHelper(visiblePages) {
  9073. throw new Error('Not implemented: _updateHelper');
  9074. }
  9075. }, {
  9076. key: "update",
  9077. value: function update() {
  9078. var visible = this._getVisiblePages();
  9079. var visiblePages = visible.views,
  9080. numVisiblePages = visiblePages.length;
  9081. if (numVisiblePages === 0) {
  9082. return;
  9083. }
  9084. var newCacheSize = Math.max(DEFAULT_CACHE_SIZE, 2 * numVisiblePages + 1);
  9085. this._buffer.resize(newCacheSize, visiblePages);
  9086. this.renderingQueue.renderHighestPriority(visible);
  9087. this._updateHelper(visiblePages);
  9088. this._updateLocation(visible.first);
  9089. this.eventBus.dispatch('updateviewarea', {
  9090. source: this,
  9091. location: this._location
  9092. });
  9093. }
  9094. }, {
  9095. key: "containsElement",
  9096. value: function containsElement(element) {
  9097. return this.container.contains(element);
  9098. }
  9099. }, {
  9100. key: "focus",
  9101. value: function focus() {
  9102. this.container.focus();
  9103. }
  9104. }, {
  9105. key: "_getCurrentVisiblePage",
  9106. value: function _getCurrentVisiblePage() {
  9107. if (!this.pagesCount) {
  9108. return {
  9109. views: []
  9110. };
  9111. }
  9112. var pageView = this._pages[this._currentPageNumber - 1];
  9113. var element = pageView.div;
  9114. var view = {
  9115. id: pageView.id,
  9116. x: element.offsetLeft + element.clientLeft,
  9117. y: element.offsetTop + element.clientTop,
  9118. view: pageView
  9119. };
  9120. return {
  9121. first: view,
  9122. last: view,
  9123. views: [view]
  9124. };
  9125. }
  9126. }, {
  9127. key: "_getVisiblePages",
  9128. value: function _getVisiblePages() {
  9129. return (0, _ui_utils.getVisibleElements)(this.container, this._pages, true, this._isScrollModeHorizontal);
  9130. }
  9131. }, {
  9132. key: "isPageVisible",
  9133. value: function isPageVisible(pageNumber) {
  9134. if (!this.pdfDocument) {
  9135. return false;
  9136. }
  9137. if (this.pageNumber < 1 || pageNumber > this.pagesCount) {
  9138. console.error("".concat(this._name, ".isPageVisible: \"").concat(pageNumber, "\" is out of bounds."));
  9139. return false;
  9140. }
  9141. return this._getVisiblePages().views.some(function (view) {
  9142. return view.id === pageNumber;
  9143. });
  9144. }
  9145. }, {
  9146. key: "cleanup",
  9147. value: function cleanup() {
  9148. for (var i = 0, ii = this._pages.length; i < ii; i++) {
  9149. if (this._pages[i] && this._pages[i].renderingState !== _pdf_rendering_queue.RenderingStates.FINISHED) {
  9150. this._pages[i].reset();
  9151. }
  9152. }
  9153. }
  9154. }, {
  9155. key: "_cancelRendering",
  9156. value: function _cancelRendering() {
  9157. for (var i = 0, ii = this._pages.length; i < ii; i++) {
  9158. if (this._pages[i]) {
  9159. this._pages[i].cancelRendering();
  9160. }
  9161. }
  9162. }
  9163. }, {
  9164. key: "_ensurePdfPageLoaded",
  9165. value: function _ensurePdfPageLoaded(pageView) {
  9166. var _this3 = this;
  9167. if (pageView.pdfPage) {
  9168. return Promise.resolve(pageView.pdfPage);
  9169. }
  9170. var pageNumber = pageView.id;
  9171. if (this._pagesRequests[pageNumber]) {
  9172. return this._pagesRequests[pageNumber];
  9173. }
  9174. var promise = this.pdfDocument.getPage(pageNumber).then(function (pdfPage) {
  9175. if (!pageView.pdfPage) {
  9176. pageView.setPdfPage(pdfPage);
  9177. }
  9178. _this3._pagesRequests[pageNumber] = null;
  9179. return pdfPage;
  9180. })["catch"](function (reason) {
  9181. console.error('Unable to get page for page view', reason);
  9182. _this3._pagesRequests[pageNumber] = null;
  9183. });
  9184. this._pagesRequests[pageNumber] = promise;
  9185. return promise;
  9186. }
  9187. }, {
  9188. key: "forceRendering",
  9189. value: function forceRendering(currentlyVisiblePages) {
  9190. var _this4 = this;
  9191. var visiblePages = currentlyVisiblePages || this._getVisiblePages();
  9192. var scrollAhead = this._isScrollModeHorizontal ? this.scroll.right : this.scroll.down;
  9193. var pageView = this.renderingQueue.getHighestPriority(visiblePages, this._pages, scrollAhead);
  9194. if (pageView) {
  9195. this._ensurePdfPageLoaded(pageView).then(function () {
  9196. _this4.renderingQueue.renderView(pageView);
  9197. });
  9198. return true;
  9199. }
  9200. return false;
  9201. }
  9202. }, {
  9203. key: "createTextLayerBuilder",
  9204. value: function createTextLayerBuilder(textLayerDiv, pageIndex, viewport) {
  9205. var enhanceTextSelection = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
  9206. return new _text_layer_builder.TextLayerBuilder({
  9207. textLayerDiv: textLayerDiv,
  9208. eventBus: this.eventBus,
  9209. pageIndex: pageIndex,
  9210. viewport: viewport,
  9211. findController: this.isInPresentationMode ? null : this.findController,
  9212. enhanceTextSelection: this.isInPresentationMode ? false : enhanceTextSelection
  9213. });
  9214. }
  9215. }, {
  9216. key: "createAnnotationLayerBuilder",
  9217. value: function createAnnotationLayerBuilder(pageDiv, pdfPage) {
  9218. var imageResourcesPath = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
  9219. var renderInteractiveForms = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
  9220. var l10n = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : _ui_utils.NullL10n;
  9221. return new _annotation_layer_builder.AnnotationLayerBuilder({
  9222. pageDiv: pageDiv,
  9223. pdfPage: pdfPage,
  9224. imageResourcesPath: imageResourcesPath,
  9225. renderInteractiveForms: renderInteractiveForms,
  9226. linkService: this.linkService,
  9227. downloadManager: this.downloadManager,
  9228. l10n: l10n
  9229. });
  9230. }
  9231. }, {
  9232. key: "getPagesOverview",
  9233. value: function getPagesOverview() {
  9234. var pagesOverview = this._pages.map(function (pageView) {
  9235. var viewport = pageView.pdfPage.getViewport({
  9236. scale: 1
  9237. });
  9238. return {
  9239. width: viewport.width,
  9240. height: viewport.height,
  9241. rotation: viewport.rotation
  9242. };
  9243. });
  9244. if (!this.enablePrintAutoRotate) {
  9245. return pagesOverview;
  9246. }
  9247. var isFirstPagePortrait = (0, _ui_utils.isPortraitOrientation)(pagesOverview[0]);
  9248. return pagesOverview.map(function (size) {
  9249. if (isFirstPagePortrait === (0, _ui_utils.isPortraitOrientation)(size)) {
  9250. return size;
  9251. }
  9252. return {
  9253. width: size.height,
  9254. height: size.width,
  9255. rotation: (size.rotation + 90) % 360
  9256. };
  9257. });
  9258. }
  9259. }, {
  9260. key: "_updateScrollMode",
  9261. value: function _updateScrollMode() {
  9262. var pageNumber = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
  9263. var scrollMode = this._scrollMode,
  9264. viewer = this.viewer;
  9265. viewer.classList.toggle('scrollHorizontal', scrollMode === _ui_utils.ScrollMode.HORIZONTAL);
  9266. viewer.classList.toggle('scrollWrapped', scrollMode === _ui_utils.ScrollMode.WRAPPED);
  9267. if (!this.pdfDocument || !pageNumber) {
  9268. return;
  9269. }
  9270. if (this._currentScaleValue && isNaN(this._currentScaleValue)) {
  9271. this._setScale(this._currentScaleValue, true);
  9272. }
  9273. this._setCurrentPageNumber(pageNumber, true);
  9274. this.update();
  9275. }
  9276. }, {
  9277. key: "_updateSpreadMode",
  9278. value: function _updateSpreadMode() {
  9279. var pageNumber = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
  9280. if (!this.pdfDocument) {
  9281. return;
  9282. }
  9283. var viewer = this.viewer,
  9284. pages = this._pages;
  9285. viewer.textContent = '';
  9286. if (this._spreadMode === _ui_utils.SpreadMode.NONE) {
  9287. for (var i = 0, iMax = pages.length; i < iMax; ++i) {
  9288. viewer.appendChild(pages[i].div);
  9289. }
  9290. } else {
  9291. var parity = this._spreadMode - 1;
  9292. var spread = null;
  9293. for (var _i = 0, _iMax = pages.length; _i < _iMax; ++_i) {
  9294. if (spread === null) {
  9295. spread = document.createElement('div');
  9296. spread.className = 'spread';
  9297. viewer.appendChild(spread);
  9298. } else if (_i % 2 === parity) {
  9299. spread = spread.cloneNode(false);
  9300. viewer.appendChild(spread);
  9301. }
  9302. spread.appendChild(pages[_i].div);
  9303. }
  9304. }
  9305. if (!pageNumber) {
  9306. return;
  9307. }
  9308. this._setCurrentPageNumber(pageNumber, true);
  9309. this.update();
  9310. }
  9311. }, {
  9312. key: "pagesCount",
  9313. get: function get() {
  9314. return this._pages.length;
  9315. }
  9316. }, {
  9317. key: "pageViewsReady",
  9318. get: function get() {
  9319. return this._pageViewsReady;
  9320. }
  9321. }, {
  9322. key: "currentPageNumber",
  9323. get: function get() {
  9324. return this._currentPageNumber;
  9325. },
  9326. set: function set(val) {
  9327. if (!Number.isInteger(val)) {
  9328. throw new Error('Invalid page number.');
  9329. }
  9330. if (!this.pdfDocument) {
  9331. return;
  9332. }
  9333. if (!this._setCurrentPageNumber(val, true)) {
  9334. console.error("".concat(this._name, ".currentPageNumber: \"").concat(val, "\" is not a valid page."));
  9335. }
  9336. }
  9337. }, {
  9338. key: "currentPageLabel",
  9339. get: function get() {
  9340. return this._pageLabels && this._pageLabels[this._currentPageNumber - 1];
  9341. },
  9342. set: function set(val) {
  9343. if (!this.pdfDocument) {
  9344. return;
  9345. }
  9346. var page = val | 0;
  9347. if (this._pageLabels) {
  9348. var i = this._pageLabels.indexOf(val);
  9349. if (i >= 0) {
  9350. page = i + 1;
  9351. }
  9352. }
  9353. if (!this._setCurrentPageNumber(page, true)) {
  9354. console.error("".concat(this._name, ".currentPageLabel: \"").concat(val, "\" is not a valid page."));
  9355. }
  9356. }
  9357. }, {
  9358. key: "currentScale",
  9359. get: function get() {
  9360. return this._currentScale !== _ui_utils.UNKNOWN_SCALE ? this._currentScale : _ui_utils.DEFAULT_SCALE;
  9361. },
  9362. set: function set(val) {
  9363. if (isNaN(val)) {
  9364. throw new Error('Invalid numeric scale.');
  9365. }
  9366. if (!this.pdfDocument) {
  9367. return;
  9368. }
  9369. this._setScale(val, false);
  9370. }
  9371. }, {
  9372. key: "currentScaleValue",
  9373. get: function get() {
  9374. return this._currentScaleValue;
  9375. },
  9376. set: function set(val) {
  9377. if (!this.pdfDocument) {
  9378. return;
  9379. }
  9380. this._setScale(val, false);
  9381. }
  9382. }, {
  9383. key: "pagesRotation",
  9384. get: function get() {
  9385. return this._pagesRotation;
  9386. },
  9387. set: function set(rotation) {
  9388. if (!(0, _ui_utils.isValidRotation)(rotation)) {
  9389. throw new Error('Invalid pages rotation angle.');
  9390. }
  9391. if (!this.pdfDocument) {
  9392. return;
  9393. }
  9394. if (this._pagesRotation === rotation) {
  9395. return;
  9396. }
  9397. this._pagesRotation = rotation;
  9398. var pageNumber = this._currentPageNumber;
  9399. for (var i = 0, ii = this._pages.length; i < ii; i++) {
  9400. var pageView = this._pages[i];
  9401. pageView.update(pageView.scale, rotation);
  9402. }
  9403. if (this._currentScaleValue) {
  9404. this._setScale(this._currentScaleValue, true);
  9405. }
  9406. this.eventBus.dispatch('rotationchanging', {
  9407. source: this,
  9408. pagesRotation: rotation,
  9409. pageNumber: pageNumber
  9410. });
  9411. if (this.defaultRenderingQueue) {
  9412. this.update();
  9413. }
  9414. }
  9415. }, {
  9416. key: "_setDocumentViewerElement",
  9417. get: function get() {
  9418. throw new Error('Not implemented: _setDocumentViewerElement');
  9419. }
  9420. }, {
  9421. key: "_isScrollModeHorizontal",
  9422. get: function get() {
  9423. return this.isInPresentationMode ? false : this._scrollMode === _ui_utils.ScrollMode.HORIZONTAL;
  9424. }
  9425. }, {
  9426. key: "isInPresentationMode",
  9427. get: function get() {
  9428. return this.presentationModeState === _ui_utils.PresentationModeState.FULLSCREEN;
  9429. }
  9430. }, {
  9431. key: "isChangingPresentationMode",
  9432. get: function get() {
  9433. return this.presentationModeState === _ui_utils.PresentationModeState.CHANGING;
  9434. }
  9435. }, {
  9436. key: "isHorizontalScrollbarEnabled",
  9437. get: function get() {
  9438. return this.isInPresentationMode ? false : this.container.scrollWidth > this.container.clientWidth;
  9439. }
  9440. }, {
  9441. key: "isVerticalScrollbarEnabled",
  9442. get: function get() {
  9443. return this.isInPresentationMode ? false : this.container.scrollHeight > this.container.clientHeight;
  9444. }
  9445. }, {
  9446. key: "hasEqualPageSizes",
  9447. get: function get() {
  9448. var firstPageView = this._pages[0];
  9449. for (var i = 1, ii = this._pages.length; i < ii; ++i) {
  9450. var pageView = this._pages[i];
  9451. if (pageView.width !== firstPageView.width || pageView.height !== firstPageView.height) {
  9452. return false;
  9453. }
  9454. }
  9455. return true;
  9456. }
  9457. }, {
  9458. key: "scrollMode",
  9459. get: function get() {
  9460. return this._scrollMode;
  9461. },
  9462. set: function set(mode) {
  9463. if (this._scrollMode === mode) {
  9464. return;
  9465. }
  9466. if (!(0, _ui_utils.isValidScrollMode)(mode)) {
  9467. throw new Error("Invalid scroll mode: ".concat(mode));
  9468. }
  9469. this._scrollMode = mode;
  9470. this.eventBus.dispatch('scrollmodechanged', {
  9471. source: this,
  9472. mode: mode
  9473. });
  9474. this._updateScrollMode(this._currentPageNumber);
  9475. }
  9476. }, {
  9477. key: "spreadMode",
  9478. get: function get() {
  9479. return this._spreadMode;
  9480. },
  9481. set: function set(mode) {
  9482. if (this._spreadMode === mode) {
  9483. return;
  9484. }
  9485. if (!(0, _ui_utils.isValidSpreadMode)(mode)) {
  9486. throw new Error("Invalid spread mode: ".concat(mode));
  9487. }
  9488. this._spreadMode = mode;
  9489. this.eventBus.dispatch('spreadmodechanged', {
  9490. source: this,
  9491. mode: mode
  9492. });
  9493. this._updateSpreadMode(this._currentPageNumber);
  9494. }
  9495. }]);
  9496. return BaseViewer;
  9497. }();
  9498. exports.BaseViewer = BaseViewer;
  9499. /***/ }),
  9500. /* 29 */
  9501. /***/ (function(module, exports, __webpack_require__) {
  9502. "use strict";
  9503. Object.defineProperty(exports, "__esModule", {
  9504. value: true
  9505. });
  9506. exports.DefaultAnnotationLayerFactory = exports.AnnotationLayerBuilder = void 0;
  9507. var _pdfjsLib = __webpack_require__(7);
  9508. var _ui_utils = __webpack_require__(5);
  9509. var _pdf_link_service = __webpack_require__(21);
  9510. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  9511. 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); } }
  9512. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  9513. var AnnotationLayerBuilder =
  9514. /*#__PURE__*/
  9515. function () {
  9516. function AnnotationLayerBuilder(_ref) {
  9517. var pageDiv = _ref.pageDiv,
  9518. pdfPage = _ref.pdfPage,
  9519. linkService = _ref.linkService,
  9520. downloadManager = _ref.downloadManager,
  9521. _ref$imageResourcesPa = _ref.imageResourcesPath,
  9522. imageResourcesPath = _ref$imageResourcesPa === void 0 ? '' : _ref$imageResourcesPa,
  9523. _ref$renderInteractiv = _ref.renderInteractiveForms,
  9524. renderInteractiveForms = _ref$renderInteractiv === void 0 ? false : _ref$renderInteractiv,
  9525. _ref$l10n = _ref.l10n,
  9526. l10n = _ref$l10n === void 0 ? _ui_utils.NullL10n : _ref$l10n;
  9527. _classCallCheck(this, AnnotationLayerBuilder);
  9528. this.pageDiv = pageDiv;
  9529. this.pdfPage = pdfPage;
  9530. this.linkService = linkService;
  9531. this.downloadManager = downloadManager;
  9532. this.imageResourcesPath = imageResourcesPath;
  9533. this.renderInteractiveForms = renderInteractiveForms;
  9534. this.l10n = l10n;
  9535. this.div = null;
  9536. this._cancelled = false;
  9537. }
  9538. _createClass(AnnotationLayerBuilder, [{
  9539. key: "render",
  9540. value: function render(viewport) {
  9541. var _this = this;
  9542. var intent = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'display';
  9543. this.pdfPage.getAnnotations({
  9544. intent: intent
  9545. }).then(function (annotations) {
  9546. if (_this._cancelled) {
  9547. return;
  9548. }
  9549. var parameters = {
  9550. viewport: viewport.clone({
  9551. dontFlip: true
  9552. }),
  9553. div: _this.div,
  9554. annotations: annotations,
  9555. page: _this.pdfPage,
  9556. imageResourcesPath: _this.imageResourcesPath,
  9557. renderInteractiveForms: _this.renderInteractiveForms,
  9558. linkService: _this.linkService,
  9559. downloadManager: _this.downloadManager
  9560. };
  9561. if (_this.div) {
  9562. _pdfjsLib.AnnotationLayer.update(parameters);
  9563. } else {
  9564. if (annotations.length === 0) {
  9565. return;
  9566. }
  9567. _this.div = document.createElement('div');
  9568. _this.div.className = 'annotationLayer';
  9569. _this.pageDiv.appendChild(_this.div);
  9570. parameters.div = _this.div;
  9571. _pdfjsLib.AnnotationLayer.render(parameters);
  9572. _this.l10n.translate(_this.div);
  9573. }
  9574. });
  9575. }
  9576. }, {
  9577. key: "cancel",
  9578. value: function cancel() {
  9579. this._cancelled = true;
  9580. }
  9581. }, {
  9582. key: "hide",
  9583. value: function hide() {
  9584. if (!this.div) {
  9585. return;
  9586. }
  9587. this.div.setAttribute('hidden', 'true');
  9588. }
  9589. }]);
  9590. return AnnotationLayerBuilder;
  9591. }();
  9592. exports.AnnotationLayerBuilder = AnnotationLayerBuilder;
  9593. var DefaultAnnotationLayerFactory =
  9594. /*#__PURE__*/
  9595. function () {
  9596. function DefaultAnnotationLayerFactory() {
  9597. _classCallCheck(this, DefaultAnnotationLayerFactory);
  9598. }
  9599. _createClass(DefaultAnnotationLayerFactory, [{
  9600. key: "createAnnotationLayerBuilder",
  9601. value: function createAnnotationLayerBuilder(pageDiv, pdfPage) {
  9602. var imageResourcesPath = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
  9603. var renderInteractiveForms = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
  9604. var l10n = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : _ui_utils.NullL10n;
  9605. return new AnnotationLayerBuilder({
  9606. pageDiv: pageDiv,
  9607. pdfPage: pdfPage,
  9608. imageResourcesPath: imageResourcesPath,
  9609. renderInteractiveForms: renderInteractiveForms,
  9610. linkService: new _pdf_link_service.SimpleLinkService(),
  9611. l10n: l10n
  9612. });
  9613. }
  9614. }]);
  9615. return DefaultAnnotationLayerFactory;
  9616. }();
  9617. exports.DefaultAnnotationLayerFactory = DefaultAnnotationLayerFactory;
  9618. /***/ }),
  9619. /* 30 */
  9620. /***/ (function(module, exports, __webpack_require__) {
  9621. "use strict";
  9622. Object.defineProperty(exports, "__esModule", {
  9623. value: true
  9624. });
  9625. exports.PDFPageView = void 0;
  9626. var _regenerator = _interopRequireDefault(__webpack_require__(2));
  9627. var _ui_utils = __webpack_require__(5);
  9628. var _pdfjsLib = __webpack_require__(7);
  9629. var _pdf_rendering_queue = __webpack_require__(11);
  9630. var _viewer_compatibility = __webpack_require__(8);
  9631. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  9632. 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); } }
  9633. 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); }); }; }
  9634. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  9635. 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); } }
  9636. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  9637. var MAX_CANVAS_PIXELS = _viewer_compatibility.viewerCompatibilityParams.maxCanvasPixels || 16777216;
  9638. var PDFPageView =
  9639. /*#__PURE__*/
  9640. function () {
  9641. function PDFPageView(options) {
  9642. _classCallCheck(this, PDFPageView);
  9643. var container = options.container;
  9644. var defaultViewport = options.defaultViewport;
  9645. this.id = options.id;
  9646. this.renderingId = 'page' + this.id;
  9647. this.pdfPage = null;
  9648. this.pageLabel = null;
  9649. this.rotation = 0;
  9650. this.scale = options.scale || _ui_utils.DEFAULT_SCALE;
  9651. this.viewport = defaultViewport;
  9652. this.pdfPageRotate = defaultViewport.rotation;
  9653. this.hasRestrictedScaling = false;
  9654. this.textLayerMode = Number.isInteger(options.textLayerMode) ? options.textLayerMode : _ui_utils.TextLayerMode.ENABLE;
  9655. this.imageResourcesPath = options.imageResourcesPath || '';
  9656. this.renderInteractiveForms = options.renderInteractiveForms || false;
  9657. this.useOnlyCssZoom = options.useOnlyCssZoom || false;
  9658. this.maxCanvasPixels = options.maxCanvasPixels || MAX_CANVAS_PIXELS;
  9659. this.eventBus = options.eventBus || (0, _ui_utils.getGlobalEventBus)();
  9660. this.renderingQueue = options.renderingQueue;
  9661. this.textLayerFactory = options.textLayerFactory;
  9662. this.annotationLayerFactory = options.annotationLayerFactory;
  9663. this.renderer = options.renderer || _ui_utils.RendererType.CANVAS;
  9664. this.enableWebGL = options.enableWebGL || false;
  9665. this.l10n = options.l10n || _ui_utils.NullL10n;
  9666. this.paintTask = null;
  9667. this.paintedViewportMap = new WeakMap();
  9668. this.renderingState = _pdf_rendering_queue.RenderingStates.INITIAL;
  9669. this.resume = null;
  9670. this.error = null;
  9671. this.annotationLayer = null;
  9672. this.textLayer = null;
  9673. this.zoomLayer = null;
  9674. var div = document.createElement('div');
  9675. div.className = 'page';
  9676. div.style.width = Math.floor(this.viewport.width) + 'px';
  9677. div.style.height = Math.floor(this.viewport.height) + 'px';
  9678. div.setAttribute('data-page-number', this.id);
  9679. this.div = div;
  9680. container.appendChild(div);
  9681. }
  9682. _createClass(PDFPageView, [{
  9683. key: "setPdfPage",
  9684. value: function setPdfPage(pdfPage) {
  9685. this.pdfPage = pdfPage;
  9686. this.pdfPageRotate = pdfPage.rotate;
  9687. var totalRotation = (this.rotation + this.pdfPageRotate) % 360;
  9688. this.viewport = pdfPage.getViewport({
  9689. scale: this.scale * _ui_utils.CSS_UNITS,
  9690. rotation: totalRotation
  9691. });
  9692. this.stats = pdfPage.stats;
  9693. this.reset();
  9694. }
  9695. }, {
  9696. key: "destroy",
  9697. value: function destroy() {
  9698. this.reset();
  9699. if (this.pdfPage) {
  9700. this.pdfPage.cleanup();
  9701. }
  9702. }
  9703. }, {
  9704. key: "_resetZoomLayer",
  9705. value: function _resetZoomLayer() {
  9706. var removeFromDOM = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  9707. if (!this.zoomLayer) {
  9708. return;
  9709. }
  9710. var zoomLayerCanvas = this.zoomLayer.firstChild;
  9711. this.paintedViewportMap["delete"](zoomLayerCanvas);
  9712. zoomLayerCanvas.width = 0;
  9713. zoomLayerCanvas.height = 0;
  9714. if (removeFromDOM) {
  9715. this.zoomLayer.remove();
  9716. }
  9717. this.zoomLayer = null;
  9718. }
  9719. }, {
  9720. key: "reset",
  9721. value: function reset() {
  9722. var keepZoomLayer = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  9723. var keepAnnotations = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  9724. this.cancelRendering(keepAnnotations);
  9725. this.renderingState = _pdf_rendering_queue.RenderingStates.INITIAL;
  9726. var div = this.div;
  9727. div.style.width = Math.floor(this.viewport.width) + 'px';
  9728. div.style.height = Math.floor(this.viewport.height) + 'px';
  9729. var childNodes = div.childNodes;
  9730. var currentZoomLayerNode = keepZoomLayer && this.zoomLayer || null;
  9731. var currentAnnotationNode = keepAnnotations && this.annotationLayer && this.annotationLayer.div || null;
  9732. for (var i = childNodes.length - 1; i >= 0; i--) {
  9733. var node = childNodes[i];
  9734. if (currentZoomLayerNode === node || currentAnnotationNode === node) {
  9735. continue;
  9736. }
  9737. div.removeChild(node);
  9738. }
  9739. div.removeAttribute('data-loaded');
  9740. if (currentAnnotationNode) {
  9741. this.annotationLayer.hide();
  9742. } else if (this.annotationLayer) {
  9743. this.annotationLayer.cancel();
  9744. this.annotationLayer = null;
  9745. }
  9746. if (!currentZoomLayerNode) {
  9747. if (this.canvas) {
  9748. this.paintedViewportMap["delete"](this.canvas);
  9749. this.canvas.width = 0;
  9750. this.canvas.height = 0;
  9751. delete this.canvas;
  9752. }
  9753. this._resetZoomLayer();
  9754. }
  9755. if (this.svg) {
  9756. this.paintedViewportMap["delete"](this.svg);
  9757. delete this.svg;
  9758. }
  9759. this.loadingIconDiv = document.createElement('div');
  9760. this.loadingIconDiv.className = 'loadingIcon';
  9761. div.appendChild(this.loadingIconDiv);
  9762. }
  9763. }, {
  9764. key: "update",
  9765. value: function update(scale, rotation) {
  9766. this.scale = scale || this.scale;
  9767. if (typeof rotation !== 'undefined') {
  9768. this.rotation = rotation;
  9769. }
  9770. var totalRotation = (this.rotation + this.pdfPageRotate) % 360;
  9771. this.viewport = this.viewport.clone({
  9772. scale: this.scale * _ui_utils.CSS_UNITS,
  9773. rotation: totalRotation
  9774. });
  9775. if (this.svg) {
  9776. this.cssTransform(this.svg, true);
  9777. this.eventBus.dispatch('pagerendered', {
  9778. source: this,
  9779. pageNumber: this.id,
  9780. cssTransform: true,
  9781. timestamp: performance.now()
  9782. });
  9783. return;
  9784. }
  9785. var isScalingRestricted = false;
  9786. if (this.canvas && this.maxCanvasPixels > 0) {
  9787. var outputScale = this.outputScale;
  9788. if ((Math.floor(this.viewport.width) * outputScale.sx | 0) * (Math.floor(this.viewport.height) * outputScale.sy | 0) > this.maxCanvasPixels) {
  9789. isScalingRestricted = true;
  9790. }
  9791. }
  9792. if (this.canvas) {
  9793. if (this.useOnlyCssZoom || this.hasRestrictedScaling && isScalingRestricted) {
  9794. this.cssTransform(this.canvas, true);
  9795. this.eventBus.dispatch('pagerendered', {
  9796. source: this,
  9797. pageNumber: this.id,
  9798. cssTransform: true,
  9799. timestamp: performance.now()
  9800. });
  9801. return;
  9802. }
  9803. if (!this.zoomLayer && !this.canvas.hasAttribute('hidden')) {
  9804. this.zoomLayer = this.canvas.parentNode;
  9805. this.zoomLayer.style.position = 'absolute';
  9806. }
  9807. }
  9808. if (this.zoomLayer) {
  9809. this.cssTransform(this.zoomLayer.firstChild);
  9810. }
  9811. this.reset(true, true);
  9812. }
  9813. }, {
  9814. key: "cancelRendering",
  9815. value: function cancelRendering() {
  9816. var keepAnnotations = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  9817. if (this.paintTask) {
  9818. this.paintTask.cancel();
  9819. this.paintTask = null;
  9820. }
  9821. this.resume = null;
  9822. if (this.textLayer) {
  9823. this.textLayer.cancel();
  9824. this.textLayer = null;
  9825. }
  9826. if (!keepAnnotations && this.annotationLayer) {
  9827. this.annotationLayer.cancel();
  9828. this.annotationLayer = null;
  9829. }
  9830. }
  9831. }, {
  9832. key: "cssTransform",
  9833. value: function cssTransform(target) {
  9834. var redrawAnnotations = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  9835. var width = this.viewport.width;
  9836. var height = this.viewport.height;
  9837. var div = this.div;
  9838. target.style.width = target.parentNode.style.width = div.style.width = Math.floor(width) + 'px';
  9839. target.style.height = target.parentNode.style.height = div.style.height = Math.floor(height) + 'px';
  9840. var relativeRotation = this.viewport.rotation - this.paintedViewportMap.get(target).rotation;
  9841. var absRotation = Math.abs(relativeRotation);
  9842. var scaleX = 1,
  9843. scaleY = 1;
  9844. if (absRotation === 90 || absRotation === 270) {
  9845. scaleX = height / width;
  9846. scaleY = width / height;
  9847. }
  9848. var cssTransform = 'rotate(' + relativeRotation + 'deg) ' + 'scale(' + scaleX + ',' + scaleY + ')';
  9849. target.style.transform = cssTransform;
  9850. if (this.textLayer) {
  9851. var textLayerViewport = this.textLayer.viewport;
  9852. var textRelativeRotation = this.viewport.rotation - textLayerViewport.rotation;
  9853. var textAbsRotation = Math.abs(textRelativeRotation);
  9854. var scale = width / textLayerViewport.width;
  9855. if (textAbsRotation === 90 || textAbsRotation === 270) {
  9856. scale = width / textLayerViewport.height;
  9857. }
  9858. var textLayerDiv = this.textLayer.textLayerDiv;
  9859. var transX, transY;
  9860. switch (textAbsRotation) {
  9861. case 0:
  9862. transX = transY = 0;
  9863. break;
  9864. case 90:
  9865. transX = 0;
  9866. transY = '-' + textLayerDiv.style.height;
  9867. break;
  9868. case 180:
  9869. transX = '-' + textLayerDiv.style.width;
  9870. transY = '-' + textLayerDiv.style.height;
  9871. break;
  9872. case 270:
  9873. transX = '-' + textLayerDiv.style.width;
  9874. transY = 0;
  9875. break;
  9876. default:
  9877. console.error('Bad rotation value.');
  9878. break;
  9879. }
  9880. textLayerDiv.style.transform = 'rotate(' + textAbsRotation + 'deg) ' + 'scale(' + scale + ', ' + scale + ') ' + 'translate(' + transX + ', ' + transY + ')';
  9881. textLayerDiv.style.transformOrigin = '0% 0%';
  9882. }
  9883. if (redrawAnnotations && this.annotationLayer) {
  9884. this.annotationLayer.render(this.viewport, 'display');
  9885. }
  9886. }
  9887. }, {
  9888. key: "getPagePoint",
  9889. value: function getPagePoint(x, y) {
  9890. return this.viewport.convertToPdfPoint(x, y);
  9891. }
  9892. }, {
  9893. key: "draw",
  9894. value: function draw() {
  9895. var _this = this;
  9896. if (this.renderingState !== _pdf_rendering_queue.RenderingStates.INITIAL) {
  9897. console.error('Must be in new state before drawing');
  9898. this.reset();
  9899. }
  9900. if (!this.pdfPage) {
  9901. this.renderingState = _pdf_rendering_queue.RenderingStates.FINISHED;
  9902. return Promise.reject(new Error('Page is not loaded'));
  9903. }
  9904. this.renderingState = _pdf_rendering_queue.RenderingStates.RUNNING;
  9905. var pdfPage = this.pdfPage;
  9906. var div = this.div;
  9907. var canvasWrapper = document.createElement('div');
  9908. canvasWrapper.style.width = div.style.width;
  9909. canvasWrapper.style.height = div.style.height;
  9910. canvasWrapper.classList.add('canvasWrapper');
  9911. if (this.annotationLayer && this.annotationLayer.div) {
  9912. div.insertBefore(canvasWrapper, this.annotationLayer.div);
  9913. } else {
  9914. div.appendChild(canvasWrapper);
  9915. }
  9916. var textLayer = null;
  9917. if (this.textLayerMode !== _ui_utils.TextLayerMode.DISABLE && this.textLayerFactory) {
  9918. var textLayerDiv = document.createElement('div');
  9919. textLayerDiv.className = 'textLayer';
  9920. textLayerDiv.style.width = canvasWrapper.style.width;
  9921. textLayerDiv.style.height = canvasWrapper.style.height;
  9922. if (this.annotationLayer && this.annotationLayer.div) {
  9923. div.insertBefore(textLayerDiv, this.annotationLayer.div);
  9924. } else {
  9925. div.appendChild(textLayerDiv);
  9926. }
  9927. textLayer = this.textLayerFactory.createTextLayerBuilder(textLayerDiv, this.id - 1, this.viewport, this.textLayerMode === _ui_utils.TextLayerMode.ENABLE_ENHANCE);
  9928. }
  9929. this.textLayer = textLayer;
  9930. var renderContinueCallback = null;
  9931. if (this.renderingQueue) {
  9932. renderContinueCallback = function renderContinueCallback(cont) {
  9933. if (!_this.renderingQueue.isHighestPriority(_this)) {
  9934. _this.renderingState = _pdf_rendering_queue.RenderingStates.PAUSED;
  9935. _this.resume = function () {
  9936. _this.renderingState = _pdf_rendering_queue.RenderingStates.RUNNING;
  9937. cont();
  9938. };
  9939. return;
  9940. }
  9941. cont();
  9942. };
  9943. }
  9944. var finishPaintTask =
  9945. /*#__PURE__*/
  9946. function () {
  9947. var _ref = _asyncToGenerator(
  9948. /*#__PURE__*/
  9949. _regenerator["default"].mark(function _callee(error) {
  9950. return _regenerator["default"].wrap(function _callee$(_context) {
  9951. while (1) {
  9952. switch (_context.prev = _context.next) {
  9953. case 0:
  9954. if (paintTask === _this.paintTask) {
  9955. _this.paintTask = null;
  9956. }
  9957. if (!(error instanceof _pdfjsLib.RenderingCancelledException)) {
  9958. _context.next = 4;
  9959. break;
  9960. }
  9961. _this.error = null;
  9962. return _context.abrupt("return");
  9963. case 4:
  9964. _this.renderingState = _pdf_rendering_queue.RenderingStates.FINISHED;
  9965. if (_this.loadingIconDiv) {
  9966. div.removeChild(_this.loadingIconDiv);
  9967. delete _this.loadingIconDiv;
  9968. }
  9969. _this._resetZoomLayer(true);
  9970. _this.error = error;
  9971. _this.stats = pdfPage.stats;
  9972. _this.eventBus.dispatch('pagerendered', {
  9973. source: _this,
  9974. pageNumber: _this.id,
  9975. cssTransform: false,
  9976. timestamp: performance.now()
  9977. });
  9978. if (!error) {
  9979. _context.next = 12;
  9980. break;
  9981. }
  9982. throw error;
  9983. case 12:
  9984. case "end":
  9985. return _context.stop();
  9986. }
  9987. }
  9988. }, _callee);
  9989. }));
  9990. return function finishPaintTask(_x) {
  9991. return _ref.apply(this, arguments);
  9992. };
  9993. }();
  9994. var paintTask = this.renderer === _ui_utils.RendererType.SVG ? this.paintOnSvg(canvasWrapper) : this.paintOnCanvas(canvasWrapper);
  9995. paintTask.onRenderContinue = renderContinueCallback;
  9996. this.paintTask = paintTask;
  9997. var resultPromise = paintTask.promise.then(function () {
  9998. return finishPaintTask(null).then(function () {
  9999. if (textLayer) {
  10000. var readableStream = pdfPage.streamTextContent({
  10001. normalizeWhitespace: true
  10002. });
  10003. textLayer.setTextContentStream(readableStream);
  10004. textLayer.render();
  10005. }
  10006. });
  10007. }, function (reason) {
  10008. return finishPaintTask(reason);
  10009. });
  10010. if (this.annotationLayerFactory) {
  10011. if (!this.annotationLayer) {
  10012. this.annotationLayer = this.annotationLayerFactory.createAnnotationLayerBuilder(div, pdfPage, this.imageResourcesPath, this.renderInteractiveForms, this.l10n);
  10013. }
  10014. this.annotationLayer.render(this.viewport, 'display');
  10015. }
  10016. div.setAttribute('data-loaded', true);
  10017. this.eventBus.dispatch('pagerender', {
  10018. source: this,
  10019. pageNumber: this.id
  10020. });
  10021. return resultPromise;
  10022. }
  10023. }, {
  10024. key: "paintOnCanvas",
  10025. value: function paintOnCanvas(canvasWrapper) {
  10026. var renderCapability = (0, _pdfjsLib.createPromiseCapability)();
  10027. var result = {
  10028. promise: renderCapability.promise,
  10029. onRenderContinue: function onRenderContinue(cont) {
  10030. cont();
  10031. },
  10032. cancel: function cancel() {
  10033. renderTask.cancel();
  10034. }
  10035. };
  10036. var viewport = this.viewport;
  10037. var canvas = document.createElement('canvas');
  10038. canvas.id = this.renderingId;
  10039. canvas.setAttribute('hidden', 'hidden');
  10040. var isCanvasHidden = true;
  10041. var showCanvas = function showCanvas() {
  10042. if (isCanvasHidden) {
  10043. canvas.removeAttribute('hidden');
  10044. isCanvasHidden = false;
  10045. }
  10046. };
  10047. canvasWrapper.appendChild(canvas);
  10048. this.canvas = canvas;
  10049. canvas.mozOpaque = true;
  10050. var ctx = canvas.getContext('2d', {
  10051. alpha: false
  10052. });
  10053. var outputScale = (0, _ui_utils.getOutputScale)(ctx);
  10054. this.outputScale = outputScale;
  10055. if (this.useOnlyCssZoom) {
  10056. var actualSizeViewport = viewport.clone({
  10057. scale: _ui_utils.CSS_UNITS
  10058. });
  10059. outputScale.sx *= actualSizeViewport.width / viewport.width;
  10060. outputScale.sy *= actualSizeViewport.height / viewport.height;
  10061. outputScale.scaled = true;
  10062. }
  10063. if (this.maxCanvasPixels > 0) {
  10064. var pixelsInViewport = viewport.width * viewport.height;
  10065. var maxScale = Math.sqrt(this.maxCanvasPixels / pixelsInViewport);
  10066. if (outputScale.sx > maxScale || outputScale.sy > maxScale) {
  10067. outputScale.sx = maxScale;
  10068. outputScale.sy = maxScale;
  10069. outputScale.scaled = true;
  10070. this.hasRestrictedScaling = true;
  10071. } else {
  10072. this.hasRestrictedScaling = false;
  10073. }
  10074. }
  10075. var sfx = (0, _ui_utils.approximateFraction)(outputScale.sx);
  10076. var sfy = (0, _ui_utils.approximateFraction)(outputScale.sy);
  10077. canvas.width = (0, _ui_utils.roundToDivide)(viewport.width * outputScale.sx, sfx[0]);
  10078. canvas.height = (0, _ui_utils.roundToDivide)(viewport.height * outputScale.sy, sfy[0]);
  10079. canvas.style.width = (0, _ui_utils.roundToDivide)(viewport.width, sfx[1]) + 'px';
  10080. canvas.style.height = (0, _ui_utils.roundToDivide)(viewport.height, sfy[1]) + 'px';
  10081. this.paintedViewportMap.set(canvas, viewport);
  10082. var transform = !outputScale.scaled ? null : [outputScale.sx, 0, 0, outputScale.sy, 0, 0];
  10083. var renderContext = {
  10084. canvasContext: ctx,
  10085. transform: transform,
  10086. viewport: this.viewport,
  10087. enableWebGL: this.enableWebGL,
  10088. renderInteractiveForms: this.renderInteractiveForms
  10089. };
  10090. var renderTask = this.pdfPage.render(renderContext);
  10091. renderTask.onContinue = function (cont) {
  10092. showCanvas();
  10093. if (result.onRenderContinue) {
  10094. result.onRenderContinue(cont);
  10095. } else {
  10096. cont();
  10097. }
  10098. };
  10099. renderTask.promise.then(function () {
  10100. showCanvas();
  10101. renderCapability.resolve(undefined);
  10102. }, function (error) {
  10103. showCanvas();
  10104. renderCapability.reject(error);
  10105. });
  10106. return result;
  10107. }
  10108. }, {
  10109. key: "paintOnSvg",
  10110. value: function paintOnSvg(wrapper) {
  10111. var _this2 = this;
  10112. var cancelled = false;
  10113. var ensureNotCancelled = function ensureNotCancelled() {
  10114. if (cancelled) {
  10115. throw new _pdfjsLib.RenderingCancelledException('Rendering cancelled, page ' + _this2.id, 'svg');
  10116. }
  10117. };
  10118. var pdfPage = this.pdfPage;
  10119. var actualSizeViewport = this.viewport.clone({
  10120. scale: _ui_utils.CSS_UNITS
  10121. });
  10122. var promise = pdfPage.getOperatorList().then(function (opList) {
  10123. ensureNotCancelled();
  10124. var svgGfx = new _pdfjsLib.SVGGraphics(pdfPage.commonObjs, pdfPage.objs);
  10125. return svgGfx.getSVG(opList, actualSizeViewport).then(function (svg) {
  10126. ensureNotCancelled();
  10127. _this2.svg = svg;
  10128. _this2.paintedViewportMap.set(svg, actualSizeViewport);
  10129. svg.style.width = wrapper.style.width;
  10130. svg.style.height = wrapper.style.height;
  10131. _this2.renderingState = _pdf_rendering_queue.RenderingStates.FINISHED;
  10132. wrapper.appendChild(svg);
  10133. });
  10134. });
  10135. return {
  10136. promise: promise,
  10137. onRenderContinue: function onRenderContinue(cont) {
  10138. cont();
  10139. },
  10140. cancel: function cancel() {
  10141. cancelled = true;
  10142. }
  10143. };
  10144. }
  10145. }, {
  10146. key: "setPageLabel",
  10147. value: function setPageLabel(label) {
  10148. this.pageLabel = typeof label === 'string' ? label : null;
  10149. if (this.pageLabel !== null) {
  10150. this.div.setAttribute('data-page-label', this.pageLabel);
  10151. } else {
  10152. this.div.removeAttribute('data-page-label');
  10153. }
  10154. }
  10155. }, {
  10156. key: "width",
  10157. get: function get() {
  10158. return this.viewport.width;
  10159. }
  10160. }, {
  10161. key: "height",
  10162. get: function get() {
  10163. return this.viewport.height;
  10164. }
  10165. }]);
  10166. return PDFPageView;
  10167. }();
  10168. exports.PDFPageView = PDFPageView;
  10169. /***/ }),
  10170. /* 31 */
  10171. /***/ (function(module, exports, __webpack_require__) {
  10172. "use strict";
  10173. Object.defineProperty(exports, "__esModule", {
  10174. value: true
  10175. });
  10176. exports.DefaultTextLayerFactory = exports.TextLayerBuilder = void 0;
  10177. var _ui_utils = __webpack_require__(5);
  10178. var _pdfjsLib = __webpack_require__(7);
  10179. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  10180. 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); } }
  10181. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  10182. var EXPAND_DIVS_TIMEOUT = 300;
  10183. var TextLayerBuilder =
  10184. /*#__PURE__*/
  10185. function () {
  10186. function TextLayerBuilder(_ref) {
  10187. var textLayerDiv = _ref.textLayerDiv,
  10188. eventBus = _ref.eventBus,
  10189. pageIndex = _ref.pageIndex,
  10190. viewport = _ref.viewport,
  10191. _ref$findController = _ref.findController,
  10192. findController = _ref$findController === void 0 ? null : _ref$findController,
  10193. _ref$enhanceTextSelec = _ref.enhanceTextSelection,
  10194. enhanceTextSelection = _ref$enhanceTextSelec === void 0 ? false : _ref$enhanceTextSelec;
  10195. _classCallCheck(this, TextLayerBuilder);
  10196. this.textLayerDiv = textLayerDiv;
  10197. this.eventBus = eventBus || (0, _ui_utils.getGlobalEventBus)();
  10198. this.textContent = null;
  10199. this.textContentItemsStr = [];
  10200. this.textContentStream = null;
  10201. this.renderingDone = false;
  10202. this.pageIdx = pageIndex;
  10203. this.pageNumber = this.pageIdx + 1;
  10204. this.matches = [];
  10205. this.viewport = viewport;
  10206. this.textDivs = [];
  10207. this.findController = findController;
  10208. this.textLayerRenderTask = null;
  10209. this.enhanceTextSelection = enhanceTextSelection;
  10210. this._onUpdateTextLayerMatches = null;
  10211. this._bindMouse();
  10212. }
  10213. _createClass(TextLayerBuilder, [{
  10214. key: "_finishRendering",
  10215. value: function _finishRendering() {
  10216. this.renderingDone = true;
  10217. if (!this.enhanceTextSelection) {
  10218. var endOfContent = document.createElement('div');
  10219. endOfContent.className = 'endOfContent';
  10220. this.textLayerDiv.appendChild(endOfContent);
  10221. }
  10222. this.eventBus.dispatch('textlayerrendered', {
  10223. source: this,
  10224. pageNumber: this.pageNumber,
  10225. numTextDivs: this.textDivs.length
  10226. });
  10227. }
  10228. }, {
  10229. key: "render",
  10230. value: function render() {
  10231. var _this = this;
  10232. var timeout = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
  10233. if (!(this.textContent || this.textContentStream) || this.renderingDone) {
  10234. return;
  10235. }
  10236. this.cancel();
  10237. this.textDivs = [];
  10238. var textLayerFrag = document.createDocumentFragment();
  10239. this.textLayerRenderTask = (0, _pdfjsLib.renderTextLayer)({
  10240. textContent: this.textContent,
  10241. textContentStream: this.textContentStream,
  10242. container: textLayerFrag,
  10243. viewport: this.viewport,
  10244. textDivs: this.textDivs,
  10245. textContentItemsStr: this.textContentItemsStr,
  10246. timeout: timeout,
  10247. enhanceTextSelection: this.enhanceTextSelection
  10248. });
  10249. this.textLayerRenderTask.promise.then(function () {
  10250. _this.textLayerDiv.appendChild(textLayerFrag);
  10251. _this._finishRendering();
  10252. _this._updateMatches();
  10253. }, function (reason) {});
  10254. if (!this._onUpdateTextLayerMatches) {
  10255. this._onUpdateTextLayerMatches = function (evt) {
  10256. if (evt.pageIndex === _this.pageIdx || evt.pageIndex === -1) {
  10257. _this._updateMatches();
  10258. }
  10259. };
  10260. this.eventBus.on('updatetextlayermatches', this._onUpdateTextLayerMatches);
  10261. }
  10262. }
  10263. }, {
  10264. key: "cancel",
  10265. value: function cancel() {
  10266. if (this.textLayerRenderTask) {
  10267. this.textLayerRenderTask.cancel();
  10268. this.textLayerRenderTask = null;
  10269. }
  10270. if (this._onUpdateTextLayerMatches) {
  10271. this.eventBus.off('updatetextlayermatches', this._onUpdateTextLayerMatches);
  10272. this._onUpdateTextLayerMatches = null;
  10273. }
  10274. }
  10275. }, {
  10276. key: "setTextContentStream",
  10277. value: function setTextContentStream(readableStream) {
  10278. this.cancel();
  10279. this.textContentStream = readableStream;
  10280. }
  10281. }, {
  10282. key: "setTextContent",
  10283. value: function setTextContent(textContent) {
  10284. this.cancel();
  10285. this.textContent = textContent;
  10286. }
  10287. }, {
  10288. key: "_convertMatches",
  10289. value: function _convertMatches(matches, matchesLength) {
  10290. if (!matches) {
  10291. return [];
  10292. }
  10293. var findController = this.findController,
  10294. textContentItemsStr = this.textContentItemsStr;
  10295. var i = 0,
  10296. iIndex = 0;
  10297. var end = textContentItemsStr.length - 1;
  10298. var queryLen = findController.state.query.length;
  10299. var result = [];
  10300. for (var m = 0, mm = matches.length; m < mm; m++) {
  10301. var matchIdx = matches[m];
  10302. while (i !== end && matchIdx >= iIndex + textContentItemsStr[i].length) {
  10303. iIndex += textContentItemsStr[i].length;
  10304. i++;
  10305. }
  10306. if (i === textContentItemsStr.length) {
  10307. console.error('Could not find a matching mapping');
  10308. }
  10309. var match = {
  10310. begin: {
  10311. divIdx: i,
  10312. offset: matchIdx - iIndex
  10313. }
  10314. };
  10315. if (matchesLength) {
  10316. matchIdx += matchesLength[m];
  10317. } else {
  10318. matchIdx += queryLen;
  10319. }
  10320. while (i !== end && matchIdx > iIndex + textContentItemsStr[i].length) {
  10321. iIndex += textContentItemsStr[i].length;
  10322. i++;
  10323. }
  10324. match.end = {
  10325. divIdx: i,
  10326. offset: matchIdx - iIndex
  10327. };
  10328. result.push(match);
  10329. }
  10330. return result;
  10331. }
  10332. }, {
  10333. key: "_renderMatches",
  10334. value: function _renderMatches(matches) {
  10335. if (matches.length === 0) {
  10336. return;
  10337. }
  10338. var findController = this.findController,
  10339. pageIdx = this.pageIdx,
  10340. textContentItemsStr = this.textContentItemsStr,
  10341. textDivs = this.textDivs;
  10342. var isSelectedPage = pageIdx === findController.selected.pageIdx;
  10343. var selectedMatchIdx = findController.selected.matchIdx;
  10344. var highlightAll = findController.state.highlightAll;
  10345. var prevEnd = null;
  10346. var infinity = {
  10347. divIdx: -1,
  10348. offset: undefined
  10349. };
  10350. function beginText(begin, className) {
  10351. var divIdx = begin.divIdx;
  10352. textDivs[divIdx].textContent = '';
  10353. appendTextToDiv(divIdx, 0, begin.offset, className);
  10354. }
  10355. function appendTextToDiv(divIdx, fromOffset, toOffset, className) {
  10356. var div = textDivs[divIdx];
  10357. var content = textContentItemsStr[divIdx].substring(fromOffset, toOffset);
  10358. var node = document.createTextNode(content);
  10359. if (className) {
  10360. var span = document.createElement('span');
  10361. span.className = className;
  10362. span.appendChild(node);
  10363. div.appendChild(span);
  10364. return;
  10365. }
  10366. div.appendChild(node);
  10367. }
  10368. var i0 = selectedMatchIdx,
  10369. i1 = i0 + 1;
  10370. if (highlightAll) {
  10371. i0 = 0;
  10372. i1 = matches.length;
  10373. } else if (!isSelectedPage) {
  10374. return;
  10375. }
  10376. for (var i = i0; i < i1; i++) {
  10377. var match = matches[i];
  10378. var begin = match.begin;
  10379. var end = match.end;
  10380. var isSelected = isSelectedPage && i === selectedMatchIdx;
  10381. var highlightSuffix = isSelected ? ' selected' : '';
  10382. if (isSelected) {
  10383. findController.scrollMatchIntoView({
  10384. element: textDivs[begin.divIdx],
  10385. pageIndex: pageIdx,
  10386. matchIndex: selectedMatchIdx
  10387. });
  10388. }
  10389. if (!prevEnd || begin.divIdx !== prevEnd.divIdx) {
  10390. if (prevEnd !== null) {
  10391. appendTextToDiv(prevEnd.divIdx, prevEnd.offset, infinity.offset);
  10392. }
  10393. beginText(begin);
  10394. } else {
  10395. appendTextToDiv(prevEnd.divIdx, prevEnd.offset, begin.offset);
  10396. }
  10397. if (begin.divIdx === end.divIdx) {
  10398. appendTextToDiv(begin.divIdx, begin.offset, end.offset, 'highlight' + highlightSuffix);
  10399. } else {
  10400. appendTextToDiv(begin.divIdx, begin.offset, infinity.offset, 'highlight begin' + highlightSuffix);
  10401. for (var n0 = begin.divIdx + 1, n1 = end.divIdx; n0 < n1; n0++) {
  10402. textDivs[n0].className = 'highlight middle' + highlightSuffix;
  10403. }
  10404. beginText(end, 'highlight end' + highlightSuffix);
  10405. }
  10406. prevEnd = end;
  10407. }
  10408. if (prevEnd) {
  10409. appendTextToDiv(prevEnd.divIdx, prevEnd.offset, infinity.offset);
  10410. }
  10411. }
  10412. }, {
  10413. key: "_updateMatches",
  10414. value: function _updateMatches() {
  10415. if (!this.renderingDone) {
  10416. return;
  10417. }
  10418. var findController = this.findController,
  10419. matches = this.matches,
  10420. pageIdx = this.pageIdx,
  10421. textContentItemsStr = this.textContentItemsStr,
  10422. textDivs = this.textDivs;
  10423. var clearedUntilDivIdx = -1;
  10424. for (var i = 0, ii = matches.length; i < ii; i++) {
  10425. var match = matches[i];
  10426. var begin = Math.max(clearedUntilDivIdx, match.begin.divIdx);
  10427. for (var n = begin, end = match.end.divIdx; n <= end; n++) {
  10428. var div = textDivs[n];
  10429. div.textContent = textContentItemsStr[n];
  10430. div.className = '';
  10431. }
  10432. clearedUntilDivIdx = match.end.divIdx + 1;
  10433. }
  10434. if (!findController || !findController.highlightMatches) {
  10435. return;
  10436. }
  10437. var pageMatches = findController.pageMatches[pageIdx] || null;
  10438. var pageMatchesLength = findController.pageMatchesLength[pageIdx] || null;
  10439. this.matches = this._convertMatches(pageMatches, pageMatchesLength);
  10440. this._renderMatches(this.matches);
  10441. }
  10442. }, {
  10443. key: "_bindMouse",
  10444. value: function _bindMouse() {
  10445. var _this2 = this;
  10446. var div = this.textLayerDiv;
  10447. var expandDivsTimer = null;
  10448. div.addEventListener('mousedown', function (evt) {
  10449. if (_this2.enhanceTextSelection && _this2.textLayerRenderTask) {
  10450. _this2.textLayerRenderTask.expandTextDivs(true);
  10451. if (expandDivsTimer) {
  10452. clearTimeout(expandDivsTimer);
  10453. expandDivsTimer = null;
  10454. }
  10455. return;
  10456. }
  10457. var end = div.querySelector('.endOfContent');
  10458. if (!end) {
  10459. return;
  10460. }
  10461. var adjustTop = evt.target !== div;
  10462. adjustTop = adjustTop && window.getComputedStyle(end).getPropertyValue('-moz-user-select') !== 'none';
  10463. if (adjustTop) {
  10464. var divBounds = div.getBoundingClientRect();
  10465. var r = Math.max(0, (evt.pageY - divBounds.top) / divBounds.height);
  10466. end.style.top = (r * 100).toFixed(2) + '%';
  10467. }
  10468. end.classList.add('active');
  10469. });
  10470. div.addEventListener('mouseup', function () {
  10471. if (_this2.enhanceTextSelection && _this2.textLayerRenderTask) {
  10472. expandDivsTimer = setTimeout(function () {
  10473. if (_this2.textLayerRenderTask) {
  10474. _this2.textLayerRenderTask.expandTextDivs(false);
  10475. }
  10476. expandDivsTimer = null;
  10477. }, EXPAND_DIVS_TIMEOUT);
  10478. return;
  10479. }
  10480. var end = div.querySelector('.endOfContent');
  10481. if (!end) {
  10482. return;
  10483. }
  10484. end.style.top = '';
  10485. end.classList.remove('active');
  10486. });
  10487. }
  10488. }]);
  10489. return TextLayerBuilder;
  10490. }();
  10491. exports.TextLayerBuilder = TextLayerBuilder;
  10492. var DefaultTextLayerFactory =
  10493. /*#__PURE__*/
  10494. function () {
  10495. function DefaultTextLayerFactory() {
  10496. _classCallCheck(this, DefaultTextLayerFactory);
  10497. }
  10498. _createClass(DefaultTextLayerFactory, [{
  10499. key: "createTextLayerBuilder",
  10500. value: function createTextLayerBuilder(textLayerDiv, pageIndex, viewport) {
  10501. var enhanceTextSelection = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
  10502. return new TextLayerBuilder({
  10503. textLayerDiv: textLayerDiv,
  10504. pageIndex: pageIndex,
  10505. viewport: viewport,
  10506. enhanceTextSelection: enhanceTextSelection
  10507. });
  10508. }
  10509. }]);
  10510. return DefaultTextLayerFactory;
  10511. }();
  10512. exports.DefaultTextLayerFactory = DefaultTextLayerFactory;
  10513. /***/ }),
  10514. /* 32 */
  10515. /***/ (function(module, exports, __webpack_require__) {
  10516. "use strict";
  10517. Object.defineProperty(exports, "__esModule", {
  10518. value: true
  10519. });
  10520. exports.SecondaryToolbar = void 0;
  10521. var _ui_utils = __webpack_require__(5);
  10522. var _pdf_cursor_tools = __webpack_require__(9);
  10523. var _pdf_single_page_viewer = __webpack_require__(33);
  10524. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  10525. 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); } }
  10526. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  10527. var SecondaryToolbar =
  10528. /*#__PURE__*/
  10529. function () {
  10530. function SecondaryToolbar(options, mainContainer, eventBus) {
  10531. var _this = this;
  10532. _classCallCheck(this, SecondaryToolbar);
  10533. this.toolbar = options.toolbar;
  10534. this.toggleButton = options.toggleButton;
  10535. this.toolbarButtonContainer = options.toolbarButtonContainer;
  10536. this.buttons = [{
  10537. element: options.presentationModeButton,
  10538. eventName: 'presentationmode',
  10539. close: true
  10540. }, {
  10541. element: options.openFileButton,
  10542. eventName: 'openfile',
  10543. close: true
  10544. }, {
  10545. element: options.printButton,
  10546. eventName: 'print',
  10547. close: true
  10548. }, {
  10549. element: options.downloadButton,
  10550. eventName: 'download',
  10551. close: true
  10552. }, {
  10553. element: options.viewBookmarkButton,
  10554. eventName: null,
  10555. close: true
  10556. }, {
  10557. element: options.firstPageButton,
  10558. eventName: 'firstpage',
  10559. close: true
  10560. }, {
  10561. element: options.lastPageButton,
  10562. eventName: 'lastpage',
  10563. close: true
  10564. }, {
  10565. element: options.pageRotateCwButton,
  10566. eventName: 'rotatecw',
  10567. close: false
  10568. }, {
  10569. element: options.pageRotateCcwButton,
  10570. eventName: 'rotateccw',
  10571. close: false
  10572. }, {
  10573. element: options.cursorSelectToolButton,
  10574. eventName: 'switchcursortool',
  10575. eventDetails: {
  10576. tool: _pdf_cursor_tools.CursorTool.SELECT
  10577. },
  10578. close: true
  10579. }, {
  10580. element: options.cursorHandToolButton,
  10581. eventName: 'switchcursortool',
  10582. eventDetails: {
  10583. tool: _pdf_cursor_tools.CursorTool.HAND
  10584. },
  10585. close: true
  10586. }, {
  10587. element: options.scrollVerticalButton,
  10588. eventName: 'switchscrollmode',
  10589. eventDetails: {
  10590. mode: _ui_utils.ScrollMode.VERTICAL
  10591. },
  10592. close: true
  10593. }, {
  10594. element: options.scrollHorizontalButton,
  10595. eventName: 'switchscrollmode',
  10596. eventDetails: {
  10597. mode: _ui_utils.ScrollMode.HORIZONTAL
  10598. },
  10599. close: true
  10600. }, {
  10601. element: options.scrollWrappedButton,
  10602. eventName: 'switchscrollmode',
  10603. eventDetails: {
  10604. mode: _ui_utils.ScrollMode.WRAPPED
  10605. },
  10606. close: true
  10607. }, {
  10608. element: options.spreadNoneButton,
  10609. eventName: 'switchspreadmode',
  10610. eventDetails: {
  10611. mode: _ui_utils.SpreadMode.NONE
  10612. },
  10613. close: true
  10614. }, {
  10615. element: options.spreadOddButton,
  10616. eventName: 'switchspreadmode',
  10617. eventDetails: {
  10618. mode: _ui_utils.SpreadMode.ODD
  10619. },
  10620. close: true
  10621. }, {
  10622. element: options.spreadEvenButton,
  10623. eventName: 'switchspreadmode',
  10624. eventDetails: {
  10625. mode: _ui_utils.SpreadMode.EVEN
  10626. },
  10627. close: true
  10628. }, {
  10629. element: options.documentPropertiesButton,
  10630. eventName: 'documentproperties',
  10631. close: true
  10632. }];
  10633. this.items = {
  10634. firstPage: options.firstPageButton,
  10635. lastPage: options.lastPageButton,
  10636. pageRotateCw: options.pageRotateCwButton,
  10637. pageRotateCcw: options.pageRotateCcwButton
  10638. };
  10639. this.mainContainer = mainContainer;
  10640. this.eventBus = eventBus;
  10641. this.opened = false;
  10642. this.containerHeight = null;
  10643. this.previousContainerHeight = null;
  10644. this.reset();
  10645. this._bindClickListeners();
  10646. this._bindCursorToolsListener(options);
  10647. this._bindScrollModeListener(options);
  10648. this._bindSpreadModeListener(options);
  10649. this.eventBus.on('resize', this._setMaxHeight.bind(this));
  10650. this.eventBus.on('baseviewerinit', function (evt) {
  10651. if (evt.source instanceof _pdf_single_page_viewer.PDFSinglePageViewer) {
  10652. _this.toolbarButtonContainer.classList.add('hiddenScrollModeButtons', 'hiddenSpreadModeButtons');
  10653. } else {
  10654. _this.toolbarButtonContainer.classList.remove('hiddenScrollModeButtons', 'hiddenSpreadModeButtons');
  10655. }
  10656. });
  10657. }
  10658. _createClass(SecondaryToolbar, [{
  10659. key: "setPageNumber",
  10660. value: function setPageNumber(pageNumber) {
  10661. this.pageNumber = pageNumber;
  10662. this._updateUIState();
  10663. }
  10664. }, {
  10665. key: "setPagesCount",
  10666. value: function setPagesCount(pagesCount) {
  10667. this.pagesCount = pagesCount;
  10668. this._updateUIState();
  10669. }
  10670. }, {
  10671. key: "reset",
  10672. value: function reset() {
  10673. this.pageNumber = 0;
  10674. this.pagesCount = 0;
  10675. this._updateUIState();
  10676. this.eventBus.dispatch('secondarytoolbarreset', {
  10677. source: this
  10678. });
  10679. }
  10680. }, {
  10681. key: "_updateUIState",
  10682. value: function _updateUIState() {
  10683. this.items.firstPage.disabled = this.pageNumber <= 1;
  10684. this.items.lastPage.disabled = this.pageNumber >= this.pagesCount;
  10685. this.items.pageRotateCw.disabled = this.pagesCount === 0;
  10686. this.items.pageRotateCcw.disabled = this.pagesCount === 0;
  10687. }
  10688. }, {
  10689. key: "_bindClickListeners",
  10690. value: function _bindClickListeners() {
  10691. var _this2 = this;
  10692. this.toggleButton.addEventListener('click', this.toggle.bind(this));
  10693. var _loop = function _loop(button) {
  10694. var _this2$buttons$button = _this2.buttons[button],
  10695. element = _this2$buttons$button.element,
  10696. eventName = _this2$buttons$button.eventName,
  10697. close = _this2$buttons$button.close,
  10698. eventDetails = _this2$buttons$button.eventDetails;
  10699. element.addEventListener('click', function (evt) {
  10700. if (eventName !== null) {
  10701. var details = {
  10702. source: _this2
  10703. };
  10704. for (var property in eventDetails) {
  10705. details[property] = eventDetails[property];
  10706. }
  10707. _this2.eventBus.dispatch(eventName, details);
  10708. }
  10709. if (close) {
  10710. _this2.close();
  10711. }
  10712. });
  10713. };
  10714. for (var button in this.buttons) {
  10715. _loop(button);
  10716. }
  10717. }
  10718. }, {
  10719. key: "_bindCursorToolsListener",
  10720. value: function _bindCursorToolsListener(buttons) {
  10721. this.eventBus.on('cursortoolchanged', function (_ref) {
  10722. var tool = _ref.tool;
  10723. buttons.cursorSelectToolButton.classList.toggle('toggled', tool === _pdf_cursor_tools.CursorTool.SELECT);
  10724. buttons.cursorHandToolButton.classList.toggle('toggled', tool === _pdf_cursor_tools.CursorTool.HAND);
  10725. });
  10726. }
  10727. }, {
  10728. key: "_bindScrollModeListener",
  10729. value: function _bindScrollModeListener(buttons) {
  10730. var _this3 = this;
  10731. function scrollModeChanged(_ref2) {
  10732. var mode = _ref2.mode;
  10733. buttons.scrollVerticalButton.classList.toggle('toggled', mode === _ui_utils.ScrollMode.VERTICAL);
  10734. buttons.scrollHorizontalButton.classList.toggle('toggled', mode === _ui_utils.ScrollMode.HORIZONTAL);
  10735. buttons.scrollWrappedButton.classList.toggle('toggled', mode === _ui_utils.ScrollMode.WRAPPED);
  10736. var isScrollModeHorizontal = mode === _ui_utils.ScrollMode.HORIZONTAL;
  10737. buttons.spreadNoneButton.disabled = isScrollModeHorizontal;
  10738. buttons.spreadOddButton.disabled = isScrollModeHorizontal;
  10739. buttons.spreadEvenButton.disabled = isScrollModeHorizontal;
  10740. }
  10741. this.eventBus.on('scrollmodechanged', scrollModeChanged);
  10742. this.eventBus.on('secondarytoolbarreset', function (evt) {
  10743. if (evt.source === _this3) {
  10744. scrollModeChanged({
  10745. mode: _ui_utils.ScrollMode.VERTICAL
  10746. });
  10747. }
  10748. });
  10749. }
  10750. }, {
  10751. key: "_bindSpreadModeListener",
  10752. value: function _bindSpreadModeListener(buttons) {
  10753. var _this4 = this;
  10754. function spreadModeChanged(_ref3) {
  10755. var mode = _ref3.mode;
  10756. buttons.spreadNoneButton.classList.toggle('toggled', mode === _ui_utils.SpreadMode.NONE);
  10757. buttons.spreadOddButton.classList.toggle('toggled', mode === _ui_utils.SpreadMode.ODD);
  10758. buttons.spreadEvenButton.classList.toggle('toggled', mode === _ui_utils.SpreadMode.EVEN);
  10759. }
  10760. this.eventBus.on('spreadmodechanged', spreadModeChanged);
  10761. this.eventBus.on('secondarytoolbarreset', function (evt) {
  10762. if (evt.source === _this4) {
  10763. spreadModeChanged({
  10764. mode: _ui_utils.SpreadMode.NONE
  10765. });
  10766. }
  10767. });
  10768. }
  10769. }, {
  10770. key: "open",
  10771. value: function open() {
  10772. if (this.opened) {
  10773. return;
  10774. }
  10775. this.opened = true;
  10776. this._setMaxHeight();
  10777. this.toggleButton.classList.add('toggled');
  10778. this.toolbar.classList.remove('hidden');
  10779. }
  10780. }, {
  10781. key: "close",
  10782. value: function close() {
  10783. if (!this.opened) {
  10784. return;
  10785. }
  10786. this.opened = false;
  10787. this.toolbar.classList.add('hidden');
  10788. this.toggleButton.classList.remove('toggled');
  10789. }
  10790. }, {
  10791. key: "toggle",
  10792. value: function toggle() {
  10793. if (this.opened) {
  10794. this.close();
  10795. } else {
  10796. this.open();
  10797. }
  10798. }
  10799. }, {
  10800. key: "_setMaxHeight",
  10801. value: function _setMaxHeight() {
  10802. if (!this.opened) {
  10803. return;
  10804. }
  10805. this.containerHeight = this.mainContainer.clientHeight;
  10806. if (this.containerHeight === this.previousContainerHeight) {
  10807. return;
  10808. }
  10809. this.toolbarButtonContainer.setAttribute('style', 'max-height: ' + (this.containerHeight - _ui_utils.SCROLLBAR_PADDING) + 'px;');
  10810. this.previousContainerHeight = this.containerHeight;
  10811. }
  10812. }, {
  10813. key: "isOpen",
  10814. get: function get() {
  10815. return this.opened;
  10816. }
  10817. }]);
  10818. return SecondaryToolbar;
  10819. }();
  10820. exports.SecondaryToolbar = SecondaryToolbar;
  10821. /***/ }),
  10822. /* 33 */
  10823. /***/ (function(module, exports, __webpack_require__) {
  10824. "use strict";
  10825. Object.defineProperty(exports, "__esModule", {
  10826. value: true
  10827. });
  10828. exports.PDFSinglePageViewer = void 0;
  10829. var _base_viewer = __webpack_require__(28);
  10830. var _pdfjsLib = __webpack_require__(7);
  10831. function _typeof(obj) { 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); }
  10832. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  10833. 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); } }
  10834. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  10835. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  10836. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  10837. 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); }
  10838. function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
  10839. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  10840. 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); }
  10841. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  10842. var PDFSinglePageViewer =
  10843. /*#__PURE__*/
  10844. function (_BaseViewer) {
  10845. _inherits(PDFSinglePageViewer, _BaseViewer);
  10846. function PDFSinglePageViewer(options) {
  10847. var _this;
  10848. _classCallCheck(this, PDFSinglePageViewer);
  10849. _this = _possibleConstructorReturn(this, _getPrototypeOf(PDFSinglePageViewer).call(this, options));
  10850. _this.eventBus.on('pagesinit', function (evt) {
  10851. _this._ensurePageViewVisible();
  10852. });
  10853. return _this;
  10854. }
  10855. _createClass(PDFSinglePageViewer, [{
  10856. key: "_resetView",
  10857. value: function _resetView() {
  10858. _get(_getPrototypeOf(PDFSinglePageViewer.prototype), "_resetView", this).call(this);
  10859. this._previousPageNumber = 1;
  10860. this._shadowViewer = document.createDocumentFragment();
  10861. this._updateScrollDown = null;
  10862. }
  10863. }, {
  10864. key: "_ensurePageViewVisible",
  10865. value: function _ensurePageViewVisible() {
  10866. var pageView = this._pages[this._currentPageNumber - 1];
  10867. var previousPageView = this._pages[this._previousPageNumber - 1];
  10868. var viewerNodes = this.viewer.childNodes;
  10869. switch (viewerNodes.length) {
  10870. case 0:
  10871. this.viewer.appendChild(pageView.div);
  10872. break;
  10873. case 1:
  10874. if (viewerNodes[0] !== previousPageView.div) {
  10875. throw new Error('_ensurePageViewVisible: Unexpected previously visible page.');
  10876. }
  10877. if (pageView === previousPageView) {
  10878. break;
  10879. }
  10880. this._shadowViewer.appendChild(previousPageView.div);
  10881. this.viewer.appendChild(pageView.div);
  10882. this.container.scrollTop = 0;
  10883. break;
  10884. default:
  10885. throw new Error('_ensurePageViewVisible: Only one page should be visible at a time.');
  10886. }
  10887. this._previousPageNumber = this._currentPageNumber;
  10888. }
  10889. }, {
  10890. key: "_scrollUpdate",
  10891. value: function _scrollUpdate() {
  10892. if (this._updateScrollDown) {
  10893. this._updateScrollDown();
  10894. }
  10895. _get(_getPrototypeOf(PDFSinglePageViewer.prototype), "_scrollUpdate", this).call(this);
  10896. }
  10897. }, {
  10898. key: "_scrollIntoView",
  10899. value: function _scrollIntoView(_ref) {
  10900. var _this2 = this;
  10901. var pageDiv = _ref.pageDiv,
  10902. _ref$pageSpot = _ref.pageSpot,
  10903. pageSpot = _ref$pageSpot === void 0 ? null : _ref$pageSpot,
  10904. _ref$pageNumber = _ref.pageNumber,
  10905. pageNumber = _ref$pageNumber === void 0 ? null : _ref$pageNumber;
  10906. if (pageNumber) {
  10907. this._setCurrentPageNumber(pageNumber);
  10908. }
  10909. var scrolledDown = this._currentPageNumber >= this._previousPageNumber;
  10910. this._ensurePageViewVisible();
  10911. this.update();
  10912. _get(_getPrototypeOf(PDFSinglePageViewer.prototype), "_scrollIntoView", this).call(this, {
  10913. pageDiv: pageDiv,
  10914. pageSpot: pageSpot,
  10915. pageNumber: pageNumber
  10916. });
  10917. this._updateScrollDown = function () {
  10918. _this2.scroll.down = scrolledDown;
  10919. _this2._updateScrollDown = null;
  10920. };
  10921. }
  10922. }, {
  10923. key: "_getVisiblePages",
  10924. value: function _getVisiblePages() {
  10925. return this._getCurrentVisiblePage();
  10926. }
  10927. }, {
  10928. key: "_updateHelper",
  10929. value: function _updateHelper(visiblePages) {}
  10930. }, {
  10931. key: "_updateScrollMode",
  10932. value: function _updateScrollMode() {}
  10933. }, {
  10934. key: "_updateSpreadMode",
  10935. value: function _updateSpreadMode() {}
  10936. }, {
  10937. key: "_setDocumentViewerElement",
  10938. get: function get() {
  10939. return (0, _pdfjsLib.shadow)(this, '_setDocumentViewerElement', this._shadowViewer);
  10940. }
  10941. }, {
  10942. key: "_isScrollModeHorizontal",
  10943. get: function get() {
  10944. return (0, _pdfjsLib.shadow)(this, '_isScrollModeHorizontal', false);
  10945. }
  10946. }]);
  10947. return PDFSinglePageViewer;
  10948. }(_base_viewer.BaseViewer);
  10949. exports.PDFSinglePageViewer = PDFSinglePageViewer;
  10950. /***/ }),
  10951. /* 34 */
  10952. /***/ (function(module, exports, __webpack_require__) {
  10953. "use strict";
  10954. Object.defineProperty(exports, "__esModule", {
  10955. value: true
  10956. });
  10957. exports.Toolbar = void 0;
  10958. var _ui_utils = __webpack_require__(5);
  10959. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  10960. 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); } }
  10961. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  10962. var PAGE_NUMBER_LOADING_INDICATOR = 'visiblePageIsLoading';
  10963. var SCALE_SELECT_CONTAINER_PADDING = 8;
  10964. var SCALE_SELECT_PADDING = 22;
  10965. var Toolbar =
  10966. /*#__PURE__*/
  10967. function () {
  10968. function Toolbar(options, eventBus) {
  10969. var l10n = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : _ui_utils.NullL10n;
  10970. _classCallCheck(this, Toolbar);
  10971. this.toolbar = options.container;
  10972. this.eventBus = eventBus;
  10973. this.l10n = l10n;
  10974. this.items = options;
  10975. this._wasLocalized = false;
  10976. this.reset();
  10977. this._bindListeners();
  10978. }
  10979. _createClass(Toolbar, [{
  10980. key: "setPageNumber",
  10981. value: function setPageNumber(pageNumber, pageLabel) {
  10982. this.pageNumber = pageNumber;
  10983. this.pageLabel = pageLabel;
  10984. this._updateUIState(false);
  10985. }
  10986. }, {
  10987. key: "setPagesCount",
  10988. value: function setPagesCount(pagesCount, hasPageLabels) {
  10989. this.pagesCount = pagesCount;
  10990. this.hasPageLabels = hasPageLabels;
  10991. this._updateUIState(true);
  10992. }
  10993. }, {
  10994. key: "setPageScale",
  10995. value: function setPageScale(pageScaleValue, pageScale) {
  10996. this.pageScaleValue = (pageScaleValue || pageScale).toString();
  10997. this.pageScale = pageScale;
  10998. this._updateUIState(false);
  10999. }
  11000. }, {
  11001. key: "reset",
  11002. value: function reset() {
  11003. this.pageNumber = 0;
  11004. this.pageLabel = null;
  11005. this.hasPageLabels = false;
  11006. this.pagesCount = 0;
  11007. this.pageScaleValue = _ui_utils.DEFAULT_SCALE_VALUE;
  11008. this.pageScale = _ui_utils.DEFAULT_SCALE;
  11009. this._updateUIState(true);
  11010. this.updateLoadingIndicatorState();
  11011. }
  11012. }, {
  11013. key: "_bindListeners",
  11014. value: function _bindListeners() {
  11015. var _this = this;
  11016. var eventBus = this.eventBus,
  11017. items = this.items;
  11018. var self = this;
  11019. items.previous.addEventListener('click', function () {
  11020. eventBus.dispatch('previouspage', {
  11021. source: self
  11022. });
  11023. });
  11024. items.next.addEventListener('click', function () {
  11025. eventBus.dispatch('nextpage', {
  11026. source: self
  11027. });
  11028. });
  11029. items.zoomIn.addEventListener('click', function () {
  11030. eventBus.dispatch('zoomin', {
  11031. source: self
  11032. });
  11033. });
  11034. items.zoomOut.addEventListener('click', function () {
  11035. eventBus.dispatch('zoomout', {
  11036. source: self
  11037. });
  11038. });
  11039. items.pageNumber.addEventListener('click', function () {
  11040. this.select();
  11041. });
  11042. items.pageNumber.addEventListener('change', function () {
  11043. eventBus.dispatch('pagenumberchanged', {
  11044. source: self,
  11045. value: this.value
  11046. });
  11047. });
  11048. items.scaleSelect.addEventListener('change', function () {
  11049. if (this.value === 'custom') {
  11050. return;
  11051. }
  11052. eventBus.dispatch('scalechanged', {
  11053. source: self,
  11054. value: this.value
  11055. });
  11056. });
  11057. items.presentationModeButton.addEventListener('click', function () {
  11058. eventBus.dispatch('presentationmode', {
  11059. source: self
  11060. });
  11061. });
  11062. items.openFile.addEventListener('click', function () {
  11063. eventBus.dispatch('openfile', {
  11064. source: self
  11065. });
  11066. });
  11067. items.print.addEventListener('click', function () {
  11068. eventBus.dispatch('print', {
  11069. source: self
  11070. });
  11071. });
  11072. items.download.addEventListener('click', function () {
  11073. eventBus.dispatch('download', {
  11074. source: self
  11075. });
  11076. });
  11077. items.scaleSelect.oncontextmenu = _ui_utils.noContextMenuHandler;
  11078. eventBus.on('localized', function () {
  11079. _this._localized();
  11080. });
  11081. }
  11082. }, {
  11083. key: "_localized",
  11084. value: function _localized() {
  11085. this._wasLocalized = true;
  11086. this._adjustScaleWidth();
  11087. this._updateUIState(true);
  11088. }
  11089. }, {
  11090. key: "_updateUIState",
  11091. value: function _updateUIState() {
  11092. var resetNumPages = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  11093. if (!this._wasLocalized) {
  11094. return;
  11095. }
  11096. var pageNumber = this.pageNumber,
  11097. pagesCount = this.pagesCount,
  11098. pageScaleValue = this.pageScaleValue,
  11099. pageScale = this.pageScale,
  11100. items = this.items;
  11101. if (resetNumPages) {
  11102. if (this.hasPageLabels) {
  11103. items.pageNumber.type = 'text';
  11104. } else {
  11105. items.pageNumber.type = 'number';
  11106. this.l10n.get('of_pages', {
  11107. pagesCount: pagesCount
  11108. }, 'of {{pagesCount}}').then(function (msg) {
  11109. items.numPages.textContent = msg;
  11110. });
  11111. }
  11112. items.pageNumber.max = pagesCount;
  11113. }
  11114. if (this.hasPageLabels) {
  11115. items.pageNumber.value = this.pageLabel;
  11116. this.l10n.get('page_of_pages', {
  11117. pageNumber: pageNumber,
  11118. pagesCount: pagesCount
  11119. }, '({{pageNumber}} of {{pagesCount}})').then(function (msg) {
  11120. items.numPages.textContent = msg;
  11121. });
  11122. } else {
  11123. items.pageNumber.value = pageNumber;
  11124. }
  11125. items.previous.disabled = pageNumber <= 1;
  11126. items.next.disabled = pageNumber >= pagesCount;
  11127. items.zoomOut.disabled = pageScale <= _ui_utils.MIN_SCALE;
  11128. items.zoomIn.disabled = pageScale >= _ui_utils.MAX_SCALE;
  11129. var customScale = Math.round(pageScale * 10000) / 100;
  11130. this.l10n.get('page_scale_percent', {
  11131. scale: customScale
  11132. }, '{{scale}}%').then(function (msg) {
  11133. var options = items.scaleSelect.options;
  11134. var predefinedValueFound = false;
  11135. for (var i = 0, ii = options.length; i < ii; i++) {
  11136. var option = options[i];
  11137. if (option.value !== pageScaleValue) {
  11138. option.selected = false;
  11139. continue;
  11140. }
  11141. option.selected = true;
  11142. predefinedValueFound = true;
  11143. }
  11144. if (!predefinedValueFound) {
  11145. items.customScaleOption.textContent = msg;
  11146. items.customScaleOption.selected = true;
  11147. }
  11148. });
  11149. }
  11150. }, {
  11151. key: "updateLoadingIndicatorState",
  11152. value: function updateLoadingIndicatorState() {
  11153. var loading = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  11154. var pageNumberInput = this.items.pageNumber;
  11155. pageNumberInput.classList.toggle(PAGE_NUMBER_LOADING_INDICATOR, loading);
  11156. }
  11157. }, {
  11158. key: "_adjustScaleWidth",
  11159. value: function _adjustScaleWidth() {
  11160. var container = this.items.scaleSelectContainer;
  11161. var select = this.items.scaleSelect;
  11162. _ui_utils.animationStarted.then(function () {
  11163. if (container.clientWidth === 0) {
  11164. container.setAttribute('style', 'display: inherit;');
  11165. }
  11166. if (container.clientWidth > 0) {
  11167. select.setAttribute('style', 'min-width: inherit;');
  11168. var width = select.clientWidth + SCALE_SELECT_CONTAINER_PADDING;
  11169. select.setAttribute('style', 'min-width: ' + (width + SCALE_SELECT_PADDING) + 'px;');
  11170. container.setAttribute('style', 'min-width: ' + width + 'px; ' + 'max-width: ' + width + 'px;');
  11171. }
  11172. });
  11173. }
  11174. }]);
  11175. return Toolbar;
  11176. }();
  11177. exports.Toolbar = Toolbar;
  11178. /***/ }),
  11179. /* 35 */
  11180. /***/ (function(module, exports, __webpack_require__) {
  11181. "use strict";
  11182. Object.defineProperty(exports, "__esModule", {
  11183. value: true
  11184. });
  11185. exports.ViewHistory = void 0;
  11186. var _regenerator = _interopRequireDefault(__webpack_require__(2));
  11187. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  11188. 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); } }
  11189. 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); }); }; }
  11190. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  11191. 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); } }
  11192. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  11193. var DEFAULT_VIEW_HISTORY_CACHE_SIZE = 20;
  11194. var ViewHistory =
  11195. /*#__PURE__*/
  11196. function () {
  11197. function ViewHistory(fingerprint) {
  11198. var _this = this;
  11199. var cacheSize = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : DEFAULT_VIEW_HISTORY_CACHE_SIZE;
  11200. _classCallCheck(this, ViewHistory);
  11201. this.fingerprint = fingerprint;
  11202. this.cacheSize = cacheSize;
  11203. this._initializedPromise = this._readFromStorage().then(function (databaseStr) {
  11204. var database = JSON.parse(databaseStr || '{}');
  11205. if (!('files' in database)) {
  11206. database.files = [];
  11207. } else {
  11208. while (database.files.length >= _this.cacheSize) {
  11209. database.files.shift();
  11210. }
  11211. }
  11212. var index = -1;
  11213. for (var i = 0, length = database.files.length; i < length; i++) {
  11214. var branch = database.files[i];
  11215. if (branch.fingerprint === _this.fingerprint) {
  11216. index = i;
  11217. break;
  11218. }
  11219. }
  11220. if (index === -1) {
  11221. index = database.files.push({
  11222. fingerprint: _this.fingerprint
  11223. }) - 1;
  11224. }
  11225. _this.file = database.files[index];
  11226. _this.database = database;
  11227. });
  11228. }
  11229. _createClass(ViewHistory, [{
  11230. key: "_writeToStorage",
  11231. value: function () {
  11232. var _writeToStorage2 = _asyncToGenerator(
  11233. /*#__PURE__*/
  11234. _regenerator["default"].mark(function _callee() {
  11235. var databaseStr;
  11236. return _regenerator["default"].wrap(function _callee$(_context) {
  11237. while (1) {
  11238. switch (_context.prev = _context.next) {
  11239. case 0:
  11240. databaseStr = JSON.stringify(this.database);
  11241. localStorage.setItem('pdfjs.history', databaseStr);
  11242. case 2:
  11243. case "end":
  11244. return _context.stop();
  11245. }
  11246. }
  11247. }, _callee, this);
  11248. }));
  11249. function _writeToStorage() {
  11250. return _writeToStorage2.apply(this, arguments);
  11251. }
  11252. return _writeToStorage;
  11253. }()
  11254. }, {
  11255. key: "_readFromStorage",
  11256. value: function () {
  11257. var _readFromStorage2 = _asyncToGenerator(
  11258. /*#__PURE__*/
  11259. _regenerator["default"].mark(function _callee2() {
  11260. return _regenerator["default"].wrap(function _callee2$(_context2) {
  11261. while (1) {
  11262. switch (_context2.prev = _context2.next) {
  11263. case 0:
  11264. return _context2.abrupt("return", localStorage.getItem('pdfjs.history'));
  11265. case 1:
  11266. case "end":
  11267. return _context2.stop();
  11268. }
  11269. }
  11270. }, _callee2);
  11271. }));
  11272. function _readFromStorage() {
  11273. return _readFromStorage2.apply(this, arguments);
  11274. }
  11275. return _readFromStorage;
  11276. }()
  11277. }, {
  11278. key: "set",
  11279. value: function () {
  11280. var _set = _asyncToGenerator(
  11281. /*#__PURE__*/
  11282. _regenerator["default"].mark(function _callee3(name, val) {
  11283. return _regenerator["default"].wrap(function _callee3$(_context3) {
  11284. while (1) {
  11285. switch (_context3.prev = _context3.next) {
  11286. case 0:
  11287. _context3.next = 2;
  11288. return this._initializedPromise;
  11289. case 2:
  11290. this.file[name] = val;
  11291. return _context3.abrupt("return", this._writeToStorage());
  11292. case 4:
  11293. case "end":
  11294. return _context3.stop();
  11295. }
  11296. }
  11297. }, _callee3, this);
  11298. }));
  11299. function set(_x, _x2) {
  11300. return _set.apply(this, arguments);
  11301. }
  11302. return set;
  11303. }()
  11304. }, {
  11305. key: "setMultiple",
  11306. value: function () {
  11307. var _setMultiple = _asyncToGenerator(
  11308. /*#__PURE__*/
  11309. _regenerator["default"].mark(function _callee4(properties) {
  11310. var name;
  11311. return _regenerator["default"].wrap(function _callee4$(_context4) {
  11312. while (1) {
  11313. switch (_context4.prev = _context4.next) {
  11314. case 0:
  11315. _context4.next = 2;
  11316. return this._initializedPromise;
  11317. case 2:
  11318. for (name in properties) {
  11319. this.file[name] = properties[name];
  11320. }
  11321. return _context4.abrupt("return", this._writeToStorage());
  11322. case 4:
  11323. case "end":
  11324. return _context4.stop();
  11325. }
  11326. }
  11327. }, _callee4, this);
  11328. }));
  11329. function setMultiple(_x3) {
  11330. return _setMultiple.apply(this, arguments);
  11331. }
  11332. return setMultiple;
  11333. }()
  11334. }, {
  11335. key: "get",
  11336. value: function () {
  11337. var _get = _asyncToGenerator(
  11338. /*#__PURE__*/
  11339. _regenerator["default"].mark(function _callee5(name, defaultValue) {
  11340. var val;
  11341. return _regenerator["default"].wrap(function _callee5$(_context5) {
  11342. while (1) {
  11343. switch (_context5.prev = _context5.next) {
  11344. case 0:
  11345. _context5.next = 2;
  11346. return this._initializedPromise;
  11347. case 2:
  11348. val = this.file[name];
  11349. return _context5.abrupt("return", val !== undefined ? val : defaultValue);
  11350. case 4:
  11351. case "end":
  11352. return _context5.stop();
  11353. }
  11354. }
  11355. }, _callee5, this);
  11356. }));
  11357. function get(_x4, _x5) {
  11358. return _get.apply(this, arguments);
  11359. }
  11360. return get;
  11361. }()
  11362. }, {
  11363. key: "getMultiple",
  11364. value: function () {
  11365. var _getMultiple = _asyncToGenerator(
  11366. /*#__PURE__*/
  11367. _regenerator["default"].mark(function _callee6(properties) {
  11368. var values, name, val;
  11369. return _regenerator["default"].wrap(function _callee6$(_context6) {
  11370. while (1) {
  11371. switch (_context6.prev = _context6.next) {
  11372. case 0:
  11373. _context6.next = 2;
  11374. return this._initializedPromise;
  11375. case 2:
  11376. values = Object.create(null);
  11377. for (name in properties) {
  11378. val = this.file[name];
  11379. values[name] = val !== undefined ? val : properties[name];
  11380. }
  11381. return _context6.abrupt("return", values);
  11382. case 5:
  11383. case "end":
  11384. return _context6.stop();
  11385. }
  11386. }
  11387. }, _callee6, this);
  11388. }));
  11389. function getMultiple(_x6) {
  11390. return _getMultiple.apply(this, arguments);
  11391. }
  11392. return getMultiple;
  11393. }()
  11394. }]);
  11395. return ViewHistory;
  11396. }();
  11397. exports.ViewHistory = ViewHistory;
  11398. /***/ }),
  11399. /* 36 */
  11400. /***/ (function(module, exports, __webpack_require__) {
  11401. "use strict";
  11402. Object.defineProperty(exports, "__esModule", {
  11403. value: true
  11404. });
  11405. exports.GenericCom = void 0;
  11406. var _regenerator = _interopRequireDefault(__webpack_require__(2));
  11407. var _app = __webpack_require__(1);
  11408. var _preferences = __webpack_require__(37);
  11409. var _download_manager = __webpack_require__(38);
  11410. var _genericl10n = __webpack_require__(39);
  11411. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  11412. function _typeof(obj) { 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); }
  11413. 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); } }
  11414. 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); }); }; }
  11415. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  11416. 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); } }
  11417. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  11418. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  11419. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  11420. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  11421. 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); }
  11422. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  11423. ;
  11424. var GenericCom = {};
  11425. exports.GenericCom = GenericCom;
  11426. var GenericPreferences =
  11427. /*#__PURE__*/
  11428. function (_BasePreferences) {
  11429. _inherits(GenericPreferences, _BasePreferences);
  11430. function GenericPreferences() {
  11431. _classCallCheck(this, GenericPreferences);
  11432. return _possibleConstructorReturn(this, _getPrototypeOf(GenericPreferences).apply(this, arguments));
  11433. }
  11434. _createClass(GenericPreferences, [{
  11435. key: "_writeToStorage",
  11436. value: function () {
  11437. var _writeToStorage2 = _asyncToGenerator(
  11438. /*#__PURE__*/
  11439. _regenerator["default"].mark(function _callee(prefObj) {
  11440. return _regenerator["default"].wrap(function _callee$(_context) {
  11441. while (1) {
  11442. switch (_context.prev = _context.next) {
  11443. case 0:
  11444. localStorage.setItem('pdfjs.preferences', JSON.stringify(prefObj));
  11445. case 1:
  11446. case "end":
  11447. return _context.stop();
  11448. }
  11449. }
  11450. }, _callee);
  11451. }));
  11452. function _writeToStorage(_x) {
  11453. return _writeToStorage2.apply(this, arguments);
  11454. }
  11455. return _writeToStorage;
  11456. }()
  11457. }, {
  11458. key: "_readFromStorage",
  11459. value: function () {
  11460. var _readFromStorage2 = _asyncToGenerator(
  11461. /*#__PURE__*/
  11462. _regenerator["default"].mark(function _callee2(prefObj) {
  11463. return _regenerator["default"].wrap(function _callee2$(_context2) {
  11464. while (1) {
  11465. switch (_context2.prev = _context2.next) {
  11466. case 0:
  11467. return _context2.abrupt("return", JSON.parse(localStorage.getItem('pdfjs.preferences')));
  11468. case 1:
  11469. case "end":
  11470. return _context2.stop();
  11471. }
  11472. }
  11473. }, _callee2);
  11474. }));
  11475. function _readFromStorage(_x2) {
  11476. return _readFromStorage2.apply(this, arguments);
  11477. }
  11478. return _readFromStorage;
  11479. }()
  11480. }]);
  11481. return GenericPreferences;
  11482. }(_preferences.BasePreferences);
  11483. var GenericExternalServices = Object.create(_app.DefaultExternalServices);
  11484. GenericExternalServices.createDownloadManager = function (options) {
  11485. return new _download_manager.DownloadManager(options);
  11486. };
  11487. GenericExternalServices.createPreferences = function () {
  11488. return new GenericPreferences();
  11489. };
  11490. GenericExternalServices.createL10n = function (_ref) {
  11491. var _ref$locale = _ref.locale,
  11492. locale = _ref$locale === void 0 ? 'en-US' : _ref$locale;
  11493. return new _genericl10n.GenericL10n(locale);
  11494. };
  11495. _app.PDFViewerApplication.externalServices = GenericExternalServices;
  11496. /***/ }),
  11497. /* 37 */
  11498. /***/ (function(module, exports, __webpack_require__) {
  11499. "use strict";
  11500. Object.defineProperty(exports, "__esModule", {
  11501. value: true
  11502. });
  11503. exports.BasePreferences = void 0;
  11504. var _regenerator = _interopRequireDefault(__webpack_require__(2));
  11505. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  11506. 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); } }
  11507. 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); }); }; }
  11508. function _typeof(obj) { 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); }
  11509. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  11510. 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); } }
  11511. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  11512. var defaultPreferences = null;
  11513. function getDefaultPreferences() {
  11514. if (!defaultPreferences) {
  11515. defaultPreferences = Promise.resolve({
  11516. "cursorToolOnLoad": 0,
  11517. "defaultZoomValue": "",
  11518. "disablePageLabels": false,
  11519. "enablePrintAutoRotate": false,
  11520. "enableWebGL": false,
  11521. "eventBusDispatchToDOM": false,
  11522. "externalLinkTarget": 0,
  11523. "historyUpdateUrl": false,
  11524. "pdfBugEnabled": false,
  11525. "renderer": "canvas",
  11526. "renderInteractiveForms": false,
  11527. "sidebarViewOnLoad": -1,
  11528. "scrollModeOnLoad": -1,
  11529. "spreadModeOnLoad": -1,
  11530. "textLayerMode": 1,
  11531. "useOnlyCssZoom": false,
  11532. "viewOnLoad": 0,
  11533. "disableAutoFetch": false,
  11534. "disableFontFace": false,
  11535. "disableRange": false,
  11536. "disableStream": false
  11537. });
  11538. }
  11539. return defaultPreferences;
  11540. }
  11541. var BasePreferences =
  11542. /*#__PURE__*/
  11543. function () {
  11544. function BasePreferences() {
  11545. var _this = this;
  11546. _classCallCheck(this, BasePreferences);
  11547. if (this.constructor === BasePreferences) {
  11548. throw new Error('Cannot initialize BasePreferences.');
  11549. }
  11550. this.prefs = null;
  11551. this._initializedPromise = getDefaultPreferences().then(function (defaults) {
  11552. Object.defineProperty(_this, 'defaults', {
  11553. value: Object.freeze(defaults),
  11554. writable: false,
  11555. enumerable: true,
  11556. configurable: false
  11557. });
  11558. _this.prefs = Object.assign(Object.create(null), defaults);
  11559. return _this._readFromStorage(defaults);
  11560. }).then(function (prefs) {
  11561. if (!prefs) {
  11562. return;
  11563. }
  11564. for (var name in prefs) {
  11565. var defaultValue = _this.defaults[name],
  11566. prefValue = prefs[name];
  11567. if (defaultValue === undefined || _typeof(prefValue) !== _typeof(defaultValue)) {
  11568. continue;
  11569. }
  11570. _this.prefs[name] = prefValue;
  11571. }
  11572. });
  11573. }
  11574. _createClass(BasePreferences, [{
  11575. key: "_writeToStorage",
  11576. value: function () {
  11577. var _writeToStorage2 = _asyncToGenerator(
  11578. /*#__PURE__*/
  11579. _regenerator["default"].mark(function _callee(prefObj) {
  11580. return _regenerator["default"].wrap(function _callee$(_context) {
  11581. while (1) {
  11582. switch (_context.prev = _context.next) {
  11583. case 0:
  11584. throw new Error('Not implemented: _writeToStorage');
  11585. case 1:
  11586. case "end":
  11587. return _context.stop();
  11588. }
  11589. }
  11590. }, _callee);
  11591. }));
  11592. function _writeToStorage(_x) {
  11593. return _writeToStorage2.apply(this, arguments);
  11594. }
  11595. return _writeToStorage;
  11596. }()
  11597. }, {
  11598. key: "_readFromStorage",
  11599. value: function () {
  11600. var _readFromStorage2 = _asyncToGenerator(
  11601. /*#__PURE__*/
  11602. _regenerator["default"].mark(function _callee2(prefObj) {
  11603. return _regenerator["default"].wrap(function _callee2$(_context2) {
  11604. while (1) {
  11605. switch (_context2.prev = _context2.next) {
  11606. case 0:
  11607. throw new Error('Not implemented: _readFromStorage');
  11608. case 1:
  11609. case "end":
  11610. return _context2.stop();
  11611. }
  11612. }
  11613. }, _callee2);
  11614. }));
  11615. function _readFromStorage(_x2) {
  11616. return _readFromStorage2.apply(this, arguments);
  11617. }
  11618. return _readFromStorage;
  11619. }()
  11620. }, {
  11621. key: "reset",
  11622. value: function () {
  11623. var _reset = _asyncToGenerator(
  11624. /*#__PURE__*/
  11625. _regenerator["default"].mark(function _callee3() {
  11626. return _regenerator["default"].wrap(function _callee3$(_context3) {
  11627. while (1) {
  11628. switch (_context3.prev = _context3.next) {
  11629. case 0:
  11630. _context3.next = 2;
  11631. return this._initializedPromise;
  11632. case 2:
  11633. this.prefs = Object.assign(Object.create(null), this.defaults);
  11634. return _context3.abrupt("return", this._writeToStorage(this.defaults));
  11635. case 4:
  11636. case "end":
  11637. return _context3.stop();
  11638. }
  11639. }
  11640. }, _callee3, this);
  11641. }));
  11642. function reset() {
  11643. return _reset.apply(this, arguments);
  11644. }
  11645. return reset;
  11646. }()
  11647. }, {
  11648. key: "set",
  11649. value: function () {
  11650. var _set = _asyncToGenerator(
  11651. /*#__PURE__*/
  11652. _regenerator["default"].mark(function _callee4(name, value) {
  11653. var defaultValue, valueType, defaultType;
  11654. return _regenerator["default"].wrap(function _callee4$(_context4) {
  11655. while (1) {
  11656. switch (_context4.prev = _context4.next) {
  11657. case 0:
  11658. _context4.next = 2;
  11659. return this._initializedPromise;
  11660. case 2:
  11661. defaultValue = this.defaults[name];
  11662. if (!(defaultValue === undefined)) {
  11663. _context4.next = 7;
  11664. break;
  11665. }
  11666. throw new Error("Set preference: \"".concat(name, "\" is undefined."));
  11667. case 7:
  11668. if (!(value === undefined)) {
  11669. _context4.next = 9;
  11670. break;
  11671. }
  11672. throw new Error('Set preference: no value is specified.');
  11673. case 9:
  11674. valueType = _typeof(value);
  11675. defaultType = _typeof(defaultValue);
  11676. if (!(valueType !== defaultType)) {
  11677. _context4.next = 19;
  11678. break;
  11679. }
  11680. if (!(valueType === 'number' && defaultType === 'string')) {
  11681. _context4.next = 16;
  11682. break;
  11683. }
  11684. value = value.toString();
  11685. _context4.next = 17;
  11686. break;
  11687. case 16:
  11688. throw new Error("Set preference: \"".concat(value, "\" is a ").concat(valueType, ", ") + "expected a ".concat(defaultType, "."));
  11689. case 17:
  11690. _context4.next = 21;
  11691. break;
  11692. case 19:
  11693. if (!(valueType === 'number' && !Number.isInteger(value))) {
  11694. _context4.next = 21;
  11695. break;
  11696. }
  11697. throw new Error("Set preference: \"".concat(value, "\" must be an integer."));
  11698. case 21:
  11699. this.prefs[name] = value;
  11700. return _context4.abrupt("return", this._writeToStorage(this.prefs));
  11701. case 23:
  11702. case "end":
  11703. return _context4.stop();
  11704. }
  11705. }
  11706. }, _callee4, this);
  11707. }));
  11708. function set(_x3, _x4) {
  11709. return _set.apply(this, arguments);
  11710. }
  11711. return set;
  11712. }()
  11713. }, {
  11714. key: "get",
  11715. value: function () {
  11716. var _get = _asyncToGenerator(
  11717. /*#__PURE__*/
  11718. _regenerator["default"].mark(function _callee5(name) {
  11719. var defaultValue, prefValue;
  11720. return _regenerator["default"].wrap(function _callee5$(_context5) {
  11721. while (1) {
  11722. switch (_context5.prev = _context5.next) {
  11723. case 0:
  11724. _context5.next = 2;
  11725. return this._initializedPromise;
  11726. case 2:
  11727. defaultValue = this.defaults[name];
  11728. if (!(defaultValue === undefined)) {
  11729. _context5.next = 7;
  11730. break;
  11731. }
  11732. throw new Error("Get preference: \"".concat(name, "\" is undefined."));
  11733. case 7:
  11734. prefValue = this.prefs[name];
  11735. if (!(prefValue !== undefined)) {
  11736. _context5.next = 10;
  11737. break;
  11738. }
  11739. return _context5.abrupt("return", prefValue);
  11740. case 10:
  11741. return _context5.abrupt("return", defaultValue);
  11742. case 11:
  11743. case "end":
  11744. return _context5.stop();
  11745. }
  11746. }
  11747. }, _callee5, this);
  11748. }));
  11749. function get(_x5) {
  11750. return _get.apply(this, arguments);
  11751. }
  11752. return get;
  11753. }()
  11754. }, {
  11755. key: "getAll",
  11756. value: function () {
  11757. var _getAll = _asyncToGenerator(
  11758. /*#__PURE__*/
  11759. _regenerator["default"].mark(function _callee6() {
  11760. return _regenerator["default"].wrap(function _callee6$(_context6) {
  11761. while (1) {
  11762. switch (_context6.prev = _context6.next) {
  11763. case 0:
  11764. _context6.next = 2;
  11765. return this._initializedPromise;
  11766. case 2:
  11767. return _context6.abrupt("return", Object.assign(Object.create(null), this.defaults, this.prefs));
  11768. case 3:
  11769. case "end":
  11770. return _context6.stop();
  11771. }
  11772. }
  11773. }, _callee6, this);
  11774. }));
  11775. function getAll() {
  11776. return _getAll.apply(this, arguments);
  11777. }
  11778. return getAll;
  11779. }()
  11780. }]);
  11781. return BasePreferences;
  11782. }();
  11783. exports.BasePreferences = BasePreferences;
  11784. /***/ }),
  11785. /* 38 */
  11786. /***/ (function(module, exports, __webpack_require__) {
  11787. "use strict";
  11788. Object.defineProperty(exports, "__esModule", {
  11789. value: true
  11790. });
  11791. exports.DownloadManager = void 0;
  11792. var _pdfjsLib = __webpack_require__(7);
  11793. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  11794. 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); } }
  11795. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  11796. ;
  11797. var DISABLE_CREATE_OBJECT_URL = _pdfjsLib.apiCompatibilityParams.disableCreateObjectURL || false;
  11798. function _download(blobUrl, filename) {
  11799. var a = document.createElement('a');
  11800. if (!a.click) {
  11801. throw new Error('DownloadManager: "a.click()" is not supported.');
  11802. }
  11803. a.href = blobUrl;
  11804. a.target = '_parent';
  11805. if ('download' in a) {
  11806. a.download = filename;
  11807. }
  11808. (document.body || document.documentElement).appendChild(a);
  11809. a.click();
  11810. a.remove();
  11811. }
  11812. var DownloadManager =
  11813. /*#__PURE__*/
  11814. function () {
  11815. function DownloadManager(_ref) {
  11816. var _ref$disableCreateObj = _ref.disableCreateObjectURL,
  11817. disableCreateObjectURL = _ref$disableCreateObj === void 0 ? DISABLE_CREATE_OBJECT_URL : _ref$disableCreateObj;
  11818. _classCallCheck(this, DownloadManager);
  11819. this.disableCreateObjectURL = disableCreateObjectURL;
  11820. }
  11821. _createClass(DownloadManager, [{
  11822. key: "downloadUrl",
  11823. value: function downloadUrl(url, filename) {
  11824. if (!(0, _pdfjsLib.createValidAbsoluteUrl)(url, 'http://example.com')) {
  11825. return;
  11826. }
  11827. _download(url + '#pdfjs.action=download', filename);
  11828. }
  11829. }, {
  11830. key: "downloadData",
  11831. value: function downloadData(data, filename, contentType) {
  11832. if (navigator.msSaveBlob) {
  11833. navigator.msSaveBlob(new Blob([data], {
  11834. type: contentType
  11835. }), filename);
  11836. return;
  11837. }
  11838. var blobUrl = (0, _pdfjsLib.createObjectURL)(data, contentType, this.disableCreateObjectURL);
  11839. _download(blobUrl, filename);
  11840. }
  11841. }, {
  11842. key: "download",
  11843. value: function download(blob, url, filename) {
  11844. if (navigator.msSaveBlob) {
  11845. if (!navigator.msSaveBlob(blob, filename)) {
  11846. this.downloadUrl(url, filename);
  11847. }
  11848. return;
  11849. }
  11850. if (this.disableCreateObjectURL) {
  11851. this.downloadUrl(url, filename);
  11852. return;
  11853. }
  11854. var blobUrl = URL.createObjectURL(blob);
  11855. _download(blobUrl, filename);
  11856. }
  11857. }]);
  11858. return DownloadManager;
  11859. }();
  11860. exports.DownloadManager = DownloadManager;
  11861. /***/ }),
  11862. /* 39 */
  11863. /***/ (function(module, exports, __webpack_require__) {
  11864. "use strict";
  11865. Object.defineProperty(exports, "__esModule", {
  11866. value: true
  11867. });
  11868. exports.GenericL10n = void 0;
  11869. var _regenerator = _interopRequireDefault(__webpack_require__(2));
  11870. __webpack_require__(40);
  11871. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  11872. 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); } }
  11873. 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); }); }; }
  11874. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  11875. 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); } }
  11876. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  11877. var webL10n = document.webL10n;
  11878. var GenericL10n =
  11879. /*#__PURE__*/
  11880. function () {
  11881. function GenericL10n(lang) {
  11882. _classCallCheck(this, GenericL10n);
  11883. this._lang = lang;
  11884. this._ready = new Promise(function (resolve, reject) {
  11885. webL10n.setLanguage(lang, function () {
  11886. resolve(webL10n);
  11887. });
  11888. });
  11889. }
  11890. _createClass(GenericL10n, [{
  11891. key: "getLanguage",
  11892. value: function () {
  11893. var _getLanguage = _asyncToGenerator(
  11894. /*#__PURE__*/
  11895. _regenerator["default"].mark(function _callee() {
  11896. var l10n;
  11897. return _regenerator["default"].wrap(function _callee$(_context) {
  11898. while (1) {
  11899. switch (_context.prev = _context.next) {
  11900. case 0:
  11901. _context.next = 2;
  11902. return this._ready;
  11903. case 2:
  11904. l10n = _context.sent;
  11905. return _context.abrupt("return", l10n.getLanguage());
  11906. case 4:
  11907. case "end":
  11908. return _context.stop();
  11909. }
  11910. }
  11911. }, _callee, this);
  11912. }));
  11913. function getLanguage() {
  11914. return _getLanguage.apply(this, arguments);
  11915. }
  11916. return getLanguage;
  11917. }()
  11918. }, {
  11919. key: "getDirection",
  11920. value: function () {
  11921. var _getDirection = _asyncToGenerator(
  11922. /*#__PURE__*/
  11923. _regenerator["default"].mark(function _callee2() {
  11924. var l10n;
  11925. return _regenerator["default"].wrap(function _callee2$(_context2) {
  11926. while (1) {
  11927. switch (_context2.prev = _context2.next) {
  11928. case 0:
  11929. _context2.next = 2;
  11930. return this._ready;
  11931. case 2:
  11932. l10n = _context2.sent;
  11933. return _context2.abrupt("return", l10n.getDirection());
  11934. case 4:
  11935. case "end":
  11936. return _context2.stop();
  11937. }
  11938. }
  11939. }, _callee2, this);
  11940. }));
  11941. function getDirection() {
  11942. return _getDirection.apply(this, arguments);
  11943. }
  11944. return getDirection;
  11945. }()
  11946. }, {
  11947. key: "get",
  11948. value: function () {
  11949. var _get = _asyncToGenerator(
  11950. /*#__PURE__*/
  11951. _regenerator["default"].mark(function _callee3(property, args, fallback) {
  11952. var l10n;
  11953. return _regenerator["default"].wrap(function _callee3$(_context3) {
  11954. while (1) {
  11955. switch (_context3.prev = _context3.next) {
  11956. case 0:
  11957. _context3.next = 2;
  11958. return this._ready;
  11959. case 2:
  11960. l10n = _context3.sent;
  11961. return _context3.abrupt("return", l10n.get(property, args, fallback));
  11962. case 4:
  11963. case "end":
  11964. return _context3.stop();
  11965. }
  11966. }
  11967. }, _callee3, this);
  11968. }));
  11969. function get(_x, _x2, _x3) {
  11970. return _get.apply(this, arguments);
  11971. }
  11972. return get;
  11973. }()
  11974. }, {
  11975. key: "translate",
  11976. value: function () {
  11977. var _translate = _asyncToGenerator(
  11978. /*#__PURE__*/
  11979. _regenerator["default"].mark(function _callee4(element) {
  11980. var l10n;
  11981. return _regenerator["default"].wrap(function _callee4$(_context4) {
  11982. while (1) {
  11983. switch (_context4.prev = _context4.next) {
  11984. case 0:
  11985. _context4.next = 2;
  11986. return this._ready;
  11987. case 2:
  11988. l10n = _context4.sent;
  11989. return _context4.abrupt("return", l10n.translate(element));
  11990. case 4:
  11991. case "end":
  11992. return _context4.stop();
  11993. }
  11994. }
  11995. }, _callee4, this);
  11996. }));
  11997. function translate(_x4) {
  11998. return _translate.apply(this, arguments);
  11999. }
  12000. return translate;
  12001. }()
  12002. }]);
  12003. return GenericL10n;
  12004. }();
  12005. exports.GenericL10n = GenericL10n;
  12006. /***/ }),
  12007. /* 40 */
  12008. /***/ (function(module, exports, __webpack_require__) {
  12009. "use strict";
  12010. document.webL10n = function (window, document, undefined) {
  12011. var gL10nData = {};
  12012. var gTextData = '';
  12013. var gTextProp = 'textContent';
  12014. var gLanguage = '';
  12015. var gMacros = {};
  12016. var gReadyState = 'loading';
  12017. var gAsyncResourceLoading = true;
  12018. function getL10nResourceLinks() {
  12019. return document.querySelectorAll('link[type="application/l10n"]');
  12020. }
  12021. function getL10nDictionary() {
  12022. var script = document.querySelector('script[type="application/l10n"]');
  12023. return script ? JSON.parse(script.innerHTML) : null;
  12024. }
  12025. function getTranslatableChildren(element) {
  12026. return element ? element.querySelectorAll('*[data-l10n-id]') : [];
  12027. }
  12028. function getL10nAttributes(element) {
  12029. if (!element) return {};
  12030. var l10nId = element.getAttribute('data-l10n-id');
  12031. var l10nArgs = element.getAttribute('data-l10n-args');
  12032. var args = {};
  12033. if (l10nArgs) {
  12034. try {
  12035. args = JSON.parse(l10nArgs);
  12036. } catch (e) {
  12037. console.warn('could not parse arguments for #' + l10nId);
  12038. }
  12039. }
  12040. return {
  12041. id: l10nId,
  12042. args: args
  12043. };
  12044. }
  12045. function xhrLoadText(url, onSuccess, onFailure) {
  12046. onSuccess = onSuccess || function _onSuccess(data) {};
  12047. onFailure = onFailure || function _onFailure() {};
  12048. var xhr = new XMLHttpRequest();
  12049. xhr.open('GET', url, gAsyncResourceLoading);
  12050. if (xhr.overrideMimeType) {
  12051. xhr.overrideMimeType('text/plain; charset=utf-8');
  12052. }
  12053. xhr.onreadystatechange = function () {
  12054. if (xhr.readyState == 4) {
  12055. if (xhr.status == 200 || xhr.status === 0) {
  12056. onSuccess(xhr.responseText);
  12057. } else {
  12058. onFailure();
  12059. }
  12060. }
  12061. };
  12062. xhr.onerror = onFailure;
  12063. xhr.ontimeout = onFailure;
  12064. try {
  12065. xhr.send(null);
  12066. } catch (e) {
  12067. onFailure();
  12068. }
  12069. }
  12070. function parseResource(href, lang, successCallback, failureCallback) {
  12071. var baseURL = href.replace(/[^\/]*$/, '') || './';
  12072. function evalString(text) {
  12073. if (text.lastIndexOf('\\') < 0) return text;
  12074. 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, "'");
  12075. }
  12076. function parseProperties(text, parsedPropertiesCallback) {
  12077. var dictionary = {};
  12078. var reBlank = /^\s*|\s*$/;
  12079. var reComment = /^\s*#|^\s*$/;
  12080. var reSection = /^\s*\[(.*)\]\s*$/;
  12081. var reImport = /^\s*@import\s+url\((.*)\)\s*$/i;
  12082. var reSplit = /^([^=\s]*)\s*=\s*(.+)$/;
  12083. function parseRawLines(rawText, extendedSyntax, parsedRawLinesCallback) {
  12084. var entries = rawText.replace(reBlank, '').split(/[\r\n]+/);
  12085. var currentLang = '*';
  12086. var genericLang = lang.split('-', 1)[0];
  12087. var skipLang = false;
  12088. var match = '';
  12089. function nextEntry() {
  12090. while (true) {
  12091. if (!entries.length) {
  12092. parsedRawLinesCallback();
  12093. return;
  12094. }
  12095. var line = entries.shift();
  12096. if (reComment.test(line)) continue;
  12097. if (extendedSyntax) {
  12098. match = reSection.exec(line);
  12099. if (match) {
  12100. currentLang = match[1].toLowerCase();
  12101. skipLang = currentLang !== '*' && currentLang !== lang && currentLang !== genericLang;
  12102. continue;
  12103. } else if (skipLang) {
  12104. continue;
  12105. }
  12106. match = reImport.exec(line);
  12107. if (match) {
  12108. loadImport(baseURL + match[1], nextEntry);
  12109. return;
  12110. }
  12111. }
  12112. var tmp = line.match(reSplit);
  12113. if (tmp && tmp.length == 3) {
  12114. dictionary[tmp[1]] = evalString(tmp[2]);
  12115. }
  12116. }
  12117. }
  12118. nextEntry();
  12119. }
  12120. function loadImport(url, callback) {
  12121. xhrLoadText(url, function (content) {
  12122. parseRawLines(content, false, callback);
  12123. }, function () {
  12124. console.warn(url + ' not found.');
  12125. callback();
  12126. });
  12127. }
  12128. parseRawLines(text, true, function () {
  12129. parsedPropertiesCallback(dictionary);
  12130. });
  12131. }
  12132. xhrLoadText(href, function (response) {
  12133. gTextData += response;
  12134. parseProperties(response, function (data) {
  12135. for (var key in data) {
  12136. var id,
  12137. prop,
  12138. index = key.lastIndexOf('.');
  12139. if (index > 0) {
  12140. id = key.substring(0, index);
  12141. prop = key.substring(index + 1);
  12142. } else {
  12143. id = key;
  12144. prop = gTextProp;
  12145. }
  12146. if (!gL10nData[id]) {
  12147. gL10nData[id] = {};
  12148. }
  12149. gL10nData[id][prop] = data[key];
  12150. }
  12151. if (successCallback) {
  12152. successCallback();
  12153. }
  12154. });
  12155. }, failureCallback);
  12156. }
  12157. function loadLocale(lang, callback) {
  12158. if (lang) {
  12159. lang = lang.toLowerCase();
  12160. }
  12161. callback = callback || function _callback() {};
  12162. clear();
  12163. gLanguage = lang;
  12164. var langLinks = getL10nResourceLinks();
  12165. var langCount = langLinks.length;
  12166. if (langCount === 0) {
  12167. var dict = getL10nDictionary();
  12168. if (dict && dict.locales && dict.default_locale) {
  12169. console.log('using the embedded JSON directory, early way out');
  12170. gL10nData = dict.locales[lang];
  12171. if (!gL10nData) {
  12172. var defaultLocale = dict.default_locale.toLowerCase();
  12173. for (var anyCaseLang in dict.locales) {
  12174. anyCaseLang = anyCaseLang.toLowerCase();
  12175. if (anyCaseLang === lang) {
  12176. gL10nData = dict.locales[lang];
  12177. break;
  12178. } else if (anyCaseLang === defaultLocale) {
  12179. gL10nData = dict.locales[defaultLocale];
  12180. }
  12181. }
  12182. }
  12183. callback();
  12184. } else {
  12185. console.log('no resource to load, early way out');
  12186. }
  12187. gReadyState = 'complete';
  12188. return;
  12189. }
  12190. var onResourceLoaded = null;
  12191. var gResourceCount = 0;
  12192. onResourceLoaded = function onResourceLoaded() {
  12193. gResourceCount++;
  12194. if (gResourceCount >= langCount) {
  12195. callback();
  12196. gReadyState = 'complete';
  12197. }
  12198. };
  12199. function L10nResourceLink(link) {
  12200. var href = link.href;
  12201. this.load = function (lang, callback) {
  12202. parseResource(href, lang, callback, function () {
  12203. console.warn(href + ' not found.');
  12204. console.warn('"' + lang + '" resource not found');
  12205. gLanguage = '';
  12206. callback();
  12207. });
  12208. };
  12209. }
  12210. for (var i = 0; i < langCount; i++) {
  12211. var resource = new L10nResourceLink(langLinks[i]);
  12212. resource.load(lang, onResourceLoaded);
  12213. }
  12214. }
  12215. function clear() {
  12216. gL10nData = {};
  12217. gTextData = '';
  12218. gLanguage = '';
  12219. }
  12220. function getPluralRules(lang) {
  12221. var locales2rules = {
  12222. 'af': 3,
  12223. 'ak': 4,
  12224. 'am': 4,
  12225. 'ar': 1,
  12226. 'asa': 3,
  12227. 'az': 0,
  12228. 'be': 11,
  12229. 'bem': 3,
  12230. 'bez': 3,
  12231. 'bg': 3,
  12232. 'bh': 4,
  12233. 'bm': 0,
  12234. 'bn': 3,
  12235. 'bo': 0,
  12236. 'br': 20,
  12237. 'brx': 3,
  12238. 'bs': 11,
  12239. 'ca': 3,
  12240. 'cgg': 3,
  12241. 'chr': 3,
  12242. 'cs': 12,
  12243. 'cy': 17,
  12244. 'da': 3,
  12245. 'de': 3,
  12246. 'dv': 3,
  12247. 'dz': 0,
  12248. 'ee': 3,
  12249. 'el': 3,
  12250. 'en': 3,
  12251. 'eo': 3,
  12252. 'es': 3,
  12253. 'et': 3,
  12254. 'eu': 3,
  12255. 'fa': 0,
  12256. 'ff': 5,
  12257. 'fi': 3,
  12258. 'fil': 4,
  12259. 'fo': 3,
  12260. 'fr': 5,
  12261. 'fur': 3,
  12262. 'fy': 3,
  12263. 'ga': 8,
  12264. 'gd': 24,
  12265. 'gl': 3,
  12266. 'gsw': 3,
  12267. 'gu': 3,
  12268. 'guw': 4,
  12269. 'gv': 23,
  12270. 'ha': 3,
  12271. 'haw': 3,
  12272. 'he': 2,
  12273. 'hi': 4,
  12274. 'hr': 11,
  12275. 'hu': 0,
  12276. 'id': 0,
  12277. 'ig': 0,
  12278. 'ii': 0,
  12279. 'is': 3,
  12280. 'it': 3,
  12281. 'iu': 7,
  12282. 'ja': 0,
  12283. 'jmc': 3,
  12284. 'jv': 0,
  12285. 'ka': 0,
  12286. 'kab': 5,
  12287. 'kaj': 3,
  12288. 'kcg': 3,
  12289. 'kde': 0,
  12290. 'kea': 0,
  12291. 'kk': 3,
  12292. 'kl': 3,
  12293. 'km': 0,
  12294. 'kn': 0,
  12295. 'ko': 0,
  12296. 'ksb': 3,
  12297. 'ksh': 21,
  12298. 'ku': 3,
  12299. 'kw': 7,
  12300. 'lag': 18,
  12301. 'lb': 3,
  12302. 'lg': 3,
  12303. 'ln': 4,
  12304. 'lo': 0,
  12305. 'lt': 10,
  12306. 'lv': 6,
  12307. 'mas': 3,
  12308. 'mg': 4,
  12309. 'mk': 16,
  12310. 'ml': 3,
  12311. 'mn': 3,
  12312. 'mo': 9,
  12313. 'mr': 3,
  12314. 'ms': 0,
  12315. 'mt': 15,
  12316. 'my': 0,
  12317. 'nah': 3,
  12318. 'naq': 7,
  12319. 'nb': 3,
  12320. 'nd': 3,
  12321. 'ne': 3,
  12322. 'nl': 3,
  12323. 'nn': 3,
  12324. 'no': 3,
  12325. 'nr': 3,
  12326. 'nso': 4,
  12327. 'ny': 3,
  12328. 'nyn': 3,
  12329. 'om': 3,
  12330. 'or': 3,
  12331. 'pa': 3,
  12332. 'pap': 3,
  12333. 'pl': 13,
  12334. 'ps': 3,
  12335. 'pt': 3,
  12336. 'rm': 3,
  12337. 'ro': 9,
  12338. 'rof': 3,
  12339. 'ru': 11,
  12340. 'rwk': 3,
  12341. 'sah': 0,
  12342. 'saq': 3,
  12343. 'se': 7,
  12344. 'seh': 3,
  12345. 'ses': 0,
  12346. 'sg': 0,
  12347. 'sh': 11,
  12348. 'shi': 19,
  12349. 'sk': 12,
  12350. 'sl': 14,
  12351. 'sma': 7,
  12352. 'smi': 7,
  12353. 'smj': 7,
  12354. 'smn': 7,
  12355. 'sms': 7,
  12356. 'sn': 3,
  12357. 'so': 3,
  12358. 'sq': 3,
  12359. 'sr': 11,
  12360. 'ss': 3,
  12361. 'ssy': 3,
  12362. 'st': 3,
  12363. 'sv': 3,
  12364. 'sw': 3,
  12365. 'syr': 3,
  12366. 'ta': 3,
  12367. 'te': 3,
  12368. 'teo': 3,
  12369. 'th': 0,
  12370. 'ti': 4,
  12371. 'tig': 3,
  12372. 'tk': 3,
  12373. 'tl': 4,
  12374. 'tn': 3,
  12375. 'to': 0,
  12376. 'tr': 0,
  12377. 'ts': 3,
  12378. 'tzm': 22,
  12379. 'uk': 11,
  12380. 'ur': 3,
  12381. 've': 3,
  12382. 'vi': 0,
  12383. 'vun': 3,
  12384. 'wa': 4,
  12385. 'wae': 3,
  12386. 'wo': 0,
  12387. 'xh': 3,
  12388. 'xog': 3,
  12389. 'yo': 0,
  12390. 'zh': 0,
  12391. 'zu': 3
  12392. };
  12393. function isIn(n, list) {
  12394. return list.indexOf(n) !== -1;
  12395. }
  12396. function isBetween(n, start, end) {
  12397. return start <= n && n <= end;
  12398. }
  12399. var pluralRules = {
  12400. '0': function _(n) {
  12401. return 'other';
  12402. },
  12403. '1': function _(n) {
  12404. if (isBetween(n % 100, 3, 10)) return 'few';
  12405. if (n === 0) return 'zero';
  12406. if (isBetween(n % 100, 11, 99)) return 'many';
  12407. if (n == 2) return 'two';
  12408. if (n == 1) return 'one';
  12409. return 'other';
  12410. },
  12411. '2': function _(n) {
  12412. if (n !== 0 && n % 10 === 0) return 'many';
  12413. if (n == 2) return 'two';
  12414. if (n == 1) return 'one';
  12415. return 'other';
  12416. },
  12417. '3': function _(n) {
  12418. if (n == 1) return 'one';
  12419. return 'other';
  12420. },
  12421. '4': function _(n) {
  12422. if (isBetween(n, 0, 1)) return 'one';
  12423. return 'other';
  12424. },
  12425. '5': function _(n) {
  12426. if (isBetween(n, 0, 2) && n != 2) return 'one';
  12427. return 'other';
  12428. },
  12429. '6': function _(n) {
  12430. if (n === 0) return 'zero';
  12431. if (n % 10 == 1 && n % 100 != 11) return 'one';
  12432. return 'other';
  12433. },
  12434. '7': function _(n) {
  12435. if (n == 2) return 'two';
  12436. if (n == 1) return 'one';
  12437. return 'other';
  12438. },
  12439. '8': function _(n) {
  12440. if (isBetween(n, 3, 6)) return 'few';
  12441. if (isBetween(n, 7, 10)) return 'many';
  12442. if (n == 2) return 'two';
  12443. if (n == 1) return 'one';
  12444. return 'other';
  12445. },
  12446. '9': function _(n) {
  12447. if (n === 0 || n != 1 && isBetween(n % 100, 1, 19)) return 'few';
  12448. if (n == 1) return 'one';
  12449. return 'other';
  12450. },
  12451. '10': function _(n) {
  12452. if (isBetween(n % 10, 2, 9) && !isBetween(n % 100, 11, 19)) return 'few';
  12453. if (n % 10 == 1 && !isBetween(n % 100, 11, 19)) return 'one';
  12454. return 'other';
  12455. },
  12456. '11': function _(n) {
  12457. if (isBetween(n % 10, 2, 4) && !isBetween(n % 100, 12, 14)) return 'few';
  12458. if (n % 10 === 0 || isBetween(n % 10, 5, 9) || isBetween(n % 100, 11, 14)) return 'many';
  12459. if (n % 10 == 1 && n % 100 != 11) return 'one';
  12460. return 'other';
  12461. },
  12462. '12': function _(n) {
  12463. if (isBetween(n, 2, 4)) return 'few';
  12464. if (n == 1) return 'one';
  12465. return 'other';
  12466. },
  12467. '13': function _(n) {
  12468. if (isBetween(n % 10, 2, 4) && !isBetween(n % 100, 12, 14)) return 'few';
  12469. if (n != 1 && isBetween(n % 10, 0, 1) || isBetween(n % 10, 5, 9) || isBetween(n % 100, 12, 14)) return 'many';
  12470. if (n == 1) return 'one';
  12471. return 'other';
  12472. },
  12473. '14': function _(n) {
  12474. if (isBetween(n % 100, 3, 4)) return 'few';
  12475. if (n % 100 == 2) return 'two';
  12476. if (n % 100 == 1) return 'one';
  12477. return 'other';
  12478. },
  12479. '15': function _(n) {
  12480. if (n === 0 || isBetween(n % 100, 2, 10)) return 'few';
  12481. if (isBetween(n % 100, 11, 19)) return 'many';
  12482. if (n == 1) return 'one';
  12483. return 'other';
  12484. },
  12485. '16': function _(n) {
  12486. if (n % 10 == 1 && n != 11) return 'one';
  12487. return 'other';
  12488. },
  12489. '17': function _(n) {
  12490. if (n == 3) return 'few';
  12491. if (n === 0) return 'zero';
  12492. if (n == 6) return 'many';
  12493. if (n == 2) return 'two';
  12494. if (n == 1) return 'one';
  12495. return 'other';
  12496. },
  12497. '18': function _(n) {
  12498. if (n === 0) return 'zero';
  12499. if (isBetween(n, 0, 2) && n !== 0 && n != 2) return 'one';
  12500. return 'other';
  12501. },
  12502. '19': function _(n) {
  12503. if (isBetween(n, 2, 10)) return 'few';
  12504. if (isBetween(n, 0, 1)) return 'one';
  12505. return 'other';
  12506. },
  12507. '20': function _(n) {
  12508. 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';
  12509. if (n % 1000000 === 0 && n !== 0) return 'many';
  12510. if (n % 10 == 2 && !isIn(n % 100, [12, 72, 92])) return 'two';
  12511. if (n % 10 == 1 && !isIn(n % 100, [11, 71, 91])) return 'one';
  12512. return 'other';
  12513. },
  12514. '21': function _(n) {
  12515. if (n === 0) return 'zero';
  12516. if (n == 1) return 'one';
  12517. return 'other';
  12518. },
  12519. '22': function _(n) {
  12520. if (isBetween(n, 0, 1) || isBetween(n, 11, 99)) return 'one';
  12521. return 'other';
  12522. },
  12523. '23': function _(n) {
  12524. if (isBetween(n % 10, 1, 2) || n % 20 === 0) return 'one';
  12525. return 'other';
  12526. },
  12527. '24': function _(n) {
  12528. if (isBetween(n, 3, 10) || isBetween(n, 13, 19)) return 'few';
  12529. if (isIn(n, [2, 12])) return 'two';
  12530. if (isIn(n, [1, 11])) return 'one';
  12531. return 'other';
  12532. }
  12533. };
  12534. var index = locales2rules[lang.replace(/-.*$/, '')];
  12535. if (!(index in pluralRules)) {
  12536. console.warn('plural form unknown for [' + lang + ']');
  12537. return function () {
  12538. return 'other';
  12539. };
  12540. }
  12541. return pluralRules[index];
  12542. }
  12543. gMacros.plural = function (str, param, key, prop) {
  12544. var n = parseFloat(param);
  12545. if (isNaN(n)) return str;
  12546. if (prop != gTextProp) return str;
  12547. if (!gMacros._pluralRules) {
  12548. gMacros._pluralRules = getPluralRules(gLanguage);
  12549. }
  12550. var index = '[' + gMacros._pluralRules(n) + ']';
  12551. if (n === 0 && key + '[zero]' in gL10nData) {
  12552. str = gL10nData[key + '[zero]'][prop];
  12553. } else if (n == 1 && key + '[one]' in gL10nData) {
  12554. str = gL10nData[key + '[one]'][prop];
  12555. } else if (n == 2 && key + '[two]' in gL10nData) {
  12556. str = gL10nData[key + '[two]'][prop];
  12557. } else if (key + index in gL10nData) {
  12558. str = gL10nData[key + index][prop];
  12559. } else if (key + '[other]' in gL10nData) {
  12560. str = gL10nData[key + '[other]'][prop];
  12561. }
  12562. return str;
  12563. };
  12564. function getL10nData(key, args, fallback) {
  12565. var data = gL10nData[key];
  12566. if (!data) {
  12567. console.warn('#' + key + ' is undefined.');
  12568. if (!fallback) {
  12569. return null;
  12570. }
  12571. data = fallback;
  12572. }
  12573. var rv = {};
  12574. for (var prop in data) {
  12575. var str = data[prop];
  12576. str = substIndexes(str, args, key, prop);
  12577. str = substArguments(str, args, key);
  12578. rv[prop] = str;
  12579. }
  12580. return rv;
  12581. }
  12582. function substIndexes(str, args, key, prop) {
  12583. var reIndex = /\{\[\s*([a-zA-Z]+)\(([a-zA-Z]+)\)\s*\]\}/;
  12584. var reMatch = reIndex.exec(str);
  12585. if (!reMatch || !reMatch.length) return str;
  12586. var macroName = reMatch[1];
  12587. var paramName = reMatch[2];
  12588. var param;
  12589. if (args && paramName in args) {
  12590. param = args[paramName];
  12591. } else if (paramName in gL10nData) {
  12592. param = gL10nData[paramName];
  12593. }
  12594. if (macroName in gMacros) {
  12595. var macro = gMacros[macroName];
  12596. str = macro(str, param, key, prop);
  12597. }
  12598. return str;
  12599. }
  12600. function substArguments(str, args, key) {
  12601. var reArgs = /\{\{\s*(.+?)\s*\}\}/g;
  12602. return str.replace(reArgs, function (matched_text, arg) {
  12603. if (args && arg in args) {
  12604. return args[arg];
  12605. }
  12606. if (arg in gL10nData) {
  12607. return gL10nData[arg];
  12608. }
  12609. console.log('argument {{' + arg + '}} for #' + key + ' is undefined.');
  12610. return matched_text;
  12611. });
  12612. }
  12613. function translateElement(element) {
  12614. var l10n = getL10nAttributes(element);
  12615. if (!l10n.id) return;
  12616. var data = getL10nData(l10n.id, l10n.args);
  12617. if (!data) {
  12618. console.warn('#' + l10n.id + ' is undefined.');
  12619. return;
  12620. }
  12621. if (data[gTextProp]) {
  12622. if (getChildElementCount(element) === 0) {
  12623. element[gTextProp] = data[gTextProp];
  12624. } else {
  12625. var children = element.childNodes;
  12626. var found = false;
  12627. for (var i = 0, l = children.length; i < l; i++) {
  12628. if (children[i].nodeType === 3 && /\S/.test(children[i].nodeValue)) {
  12629. if (found) {
  12630. children[i].nodeValue = '';
  12631. } else {
  12632. children[i].nodeValue = data[gTextProp];
  12633. found = true;
  12634. }
  12635. }
  12636. }
  12637. if (!found) {
  12638. var textNode = document.createTextNode(data[gTextProp]);
  12639. element.insertBefore(textNode, element.firstChild);
  12640. }
  12641. }
  12642. delete data[gTextProp];
  12643. }
  12644. for (var k in data) {
  12645. element[k] = data[k];
  12646. }
  12647. }
  12648. function getChildElementCount(element) {
  12649. if (element.children) {
  12650. return element.children.length;
  12651. }
  12652. if (typeof element.childElementCount !== 'undefined') {
  12653. return element.childElementCount;
  12654. }
  12655. var count = 0;
  12656. for (var i = 0; i < element.childNodes.length; i++) {
  12657. count += element.nodeType === 1 ? 1 : 0;
  12658. }
  12659. return count;
  12660. }
  12661. function translateFragment(element) {
  12662. element = element || document.documentElement;
  12663. var children = getTranslatableChildren(element);
  12664. var elementCount = children.length;
  12665. for (var i = 0; i < elementCount; i++) {
  12666. translateElement(children[i]);
  12667. }
  12668. translateElement(element);
  12669. }
  12670. return {
  12671. get: function get(key, args, fallbackString) {
  12672. var index = key.lastIndexOf('.');
  12673. var prop = gTextProp;
  12674. if (index > 0) {
  12675. prop = key.substring(index + 1);
  12676. key = key.substring(0, index);
  12677. }
  12678. var fallback;
  12679. if (fallbackString) {
  12680. fallback = {};
  12681. fallback[prop] = fallbackString;
  12682. }
  12683. var data = getL10nData(key, args, fallback);
  12684. if (data && prop in data) {
  12685. return data[prop];
  12686. }
  12687. return '{{' + key + '}}';
  12688. },
  12689. getData: function getData() {
  12690. return gL10nData;
  12691. },
  12692. getText: function getText() {
  12693. return gTextData;
  12694. },
  12695. getLanguage: function getLanguage() {
  12696. return gLanguage;
  12697. },
  12698. setLanguage: function setLanguage(lang, callback) {
  12699. loadLocale(lang, function () {
  12700. if (callback) callback();
  12701. });
  12702. },
  12703. getDirection: function getDirection() {
  12704. var rtlList = ['ar', 'he', 'fa', 'ps', 'ur'];
  12705. var shortCode = gLanguage.split('-', 1)[0];
  12706. return rtlList.indexOf(shortCode) >= 0 ? 'rtl' : 'ltr';
  12707. },
  12708. translate: translateFragment,
  12709. getReadyState: function getReadyState() {
  12710. return gReadyState;
  12711. },
  12712. ready: function ready(callback) {
  12713. if (!callback) {
  12714. return;
  12715. } else if (gReadyState == 'complete' || gReadyState == 'interactive') {
  12716. window.setTimeout(function () {
  12717. callback();
  12718. });
  12719. } else if (document.addEventListener) {
  12720. document.addEventListener('localized', function once() {
  12721. document.removeEventListener('localized', once);
  12722. callback();
  12723. });
  12724. }
  12725. }
  12726. };
  12727. }(window, document);
  12728. /***/ }),
  12729. /* 41 */
  12730. /***/ (function(module, exports, __webpack_require__) {
  12731. "use strict";
  12732. Object.defineProperty(exports, "__esModule", {
  12733. value: true
  12734. });
  12735. exports.PDFPrintService = PDFPrintService;
  12736. var _ui_utils = __webpack_require__(5);
  12737. var _app = __webpack_require__(1);
  12738. var _app_options = __webpack_require__(6);
  12739. var activeService = null;
  12740. var overlayManager = null;
  12741. function renderPage(activeServiceOnEntry, pdfDocument, pageNumber, size) {
  12742. var scratchCanvas = activeService.scratchCanvas;
  12743. var PRINT_RESOLUTION = _app_options.AppOptions.get('printResolution') || 150;
  12744. var PRINT_UNITS = PRINT_RESOLUTION / 72.0;
  12745. scratchCanvas.width = Math.floor(size.width * PRINT_UNITS);
  12746. scratchCanvas.height = Math.floor(size.height * PRINT_UNITS);
  12747. var width = Math.floor(size.width * _ui_utils.CSS_UNITS) + 'px';
  12748. var height = Math.floor(size.height * _ui_utils.CSS_UNITS) + 'px';
  12749. var ctx = scratchCanvas.getContext('2d');
  12750. ctx.save();
  12751. ctx.fillStyle = 'rgb(255, 255, 255)';
  12752. ctx.fillRect(0, 0, scratchCanvas.width, scratchCanvas.height);
  12753. ctx.restore();
  12754. return pdfDocument.getPage(pageNumber).then(function (pdfPage) {
  12755. var renderContext = {
  12756. canvasContext: ctx,
  12757. transform: [PRINT_UNITS, 0, 0, PRINT_UNITS, 0, 0],
  12758. viewport: pdfPage.getViewport({
  12759. scale: 1,
  12760. rotation: size.rotation
  12761. }),
  12762. intent: 'print'
  12763. };
  12764. return pdfPage.render(renderContext).promise;
  12765. }).then(function () {
  12766. return {
  12767. width: width,
  12768. height: height
  12769. };
  12770. });
  12771. }
  12772. function PDFPrintService(pdfDocument, pagesOverview, printContainer, l10n) {
  12773. this.pdfDocument = pdfDocument;
  12774. this.pagesOverview = pagesOverview;
  12775. this.printContainer = printContainer;
  12776. this.l10n = l10n || _ui_utils.NullL10n;
  12777. this.disableCreateObjectURL = pdfDocument.loadingParams['disableCreateObjectURL'];
  12778. this.currentPage = -1;
  12779. this.scratchCanvas = document.createElement('canvas');
  12780. }
  12781. PDFPrintService.prototype = {
  12782. layout: function layout() {
  12783. this.throwIfInactive();
  12784. var body = document.querySelector('body');
  12785. body.setAttribute('data-pdfjsprinting', true);
  12786. var hasEqualPageSizes = this.pagesOverview.every(function (size) {
  12787. return size.width === this.pagesOverview[0].width && size.height === this.pagesOverview[0].height;
  12788. }, this);
  12789. if (!hasEqualPageSizes) {
  12790. console.warn('Not all pages have the same size. The printed ' + 'result may be incorrect!');
  12791. }
  12792. this.pageStyleSheet = document.createElement('style');
  12793. var pageSize = this.pagesOverview[0];
  12794. this.pageStyleSheet.textContent = '@supports ((size:A4) and (size:1pt 1pt)) {' + '@page { size: ' + pageSize.width + 'pt ' + pageSize.height + 'pt;}' + '}';
  12795. body.appendChild(this.pageStyleSheet);
  12796. },
  12797. destroy: function destroy() {
  12798. if (activeService !== this) {
  12799. return;
  12800. }
  12801. this.printContainer.textContent = '';
  12802. var body = document.querySelector('body');
  12803. body.removeAttribute('data-pdfjsprinting');
  12804. if (this.pageStyleSheet) {
  12805. this.pageStyleSheet.remove();
  12806. this.pageStyleSheet = null;
  12807. }
  12808. this.scratchCanvas.width = this.scratchCanvas.height = 0;
  12809. this.scratchCanvas = null;
  12810. activeService = null;
  12811. ensureOverlay().then(function () {
  12812. if (overlayManager.active !== 'printServiceOverlay') {
  12813. return;
  12814. }
  12815. overlayManager.close('printServiceOverlay');
  12816. });
  12817. },
  12818. renderPages: function renderPages() {
  12819. var _this = this;
  12820. var pageCount = this.pagesOverview.length;
  12821. var renderNextPage = function renderNextPage(resolve, reject) {
  12822. _this.throwIfInactive();
  12823. if (++_this.currentPage >= pageCount) {
  12824. renderProgress(pageCount, pageCount, _this.l10n);
  12825. resolve();
  12826. return;
  12827. }
  12828. var index = _this.currentPage;
  12829. renderProgress(index, pageCount, _this.l10n);
  12830. renderPage(_this, _this.pdfDocument, index + 1, _this.pagesOverview[index]).then(_this.useRenderedPage.bind(_this)).then(function () {
  12831. renderNextPage(resolve, reject);
  12832. }, reject);
  12833. };
  12834. return new Promise(renderNextPage);
  12835. },
  12836. useRenderedPage: function useRenderedPage(printItem) {
  12837. this.throwIfInactive();
  12838. var img = document.createElement('img');
  12839. img.style.width = printItem.width;
  12840. img.style.height = printItem.height;
  12841. var scratchCanvas = this.scratchCanvas;
  12842. if ('toBlob' in scratchCanvas && !this.disableCreateObjectURL) {
  12843. scratchCanvas.toBlob(function (blob) {
  12844. img.src = URL.createObjectURL(blob);
  12845. });
  12846. } else {
  12847. img.src = scratchCanvas.toDataURL();
  12848. }
  12849. var wrapper = document.createElement('div');
  12850. wrapper.appendChild(img);
  12851. this.printContainer.appendChild(wrapper);
  12852. return new Promise(function (resolve, reject) {
  12853. img.onload = resolve;
  12854. img.onerror = reject;
  12855. });
  12856. },
  12857. performPrint: function performPrint() {
  12858. var _this2 = this;
  12859. this.throwIfInactive();
  12860. return new Promise(function (resolve) {
  12861. setTimeout(function () {
  12862. if (!_this2.active) {
  12863. resolve();
  12864. return;
  12865. }
  12866. print.call(window);
  12867. setTimeout(resolve, 20);
  12868. }, 0);
  12869. });
  12870. },
  12871. get active() {
  12872. return this === activeService;
  12873. },
  12874. throwIfInactive: function throwIfInactive() {
  12875. if (!this.active) {
  12876. throw new Error('This print request was cancelled or completed.');
  12877. }
  12878. }
  12879. };
  12880. var print = window.print;
  12881. window.print = function print() {
  12882. if (activeService) {
  12883. console.warn('Ignored window.print() because of a pending print job.');
  12884. return;
  12885. }
  12886. ensureOverlay().then(function () {
  12887. if (activeService) {
  12888. overlayManager.open('printServiceOverlay');
  12889. }
  12890. });
  12891. try {
  12892. dispatchEvent('beforeprint');
  12893. } finally {
  12894. if (!activeService) {
  12895. console.error('Expected print service to be initialized.');
  12896. ensureOverlay().then(function () {
  12897. if (overlayManager.active === 'printServiceOverlay') {
  12898. overlayManager.close('printServiceOverlay');
  12899. }
  12900. });
  12901. return;
  12902. }
  12903. var activeServiceOnEntry = activeService;
  12904. activeService.renderPages().then(function () {
  12905. return activeServiceOnEntry.performPrint();
  12906. })["catch"](function () {}).then(function () {
  12907. if (activeServiceOnEntry.active) {
  12908. abort();
  12909. }
  12910. });
  12911. }
  12912. };
  12913. function dispatchEvent(eventType) {
  12914. var event = document.createEvent('CustomEvent');
  12915. event.initCustomEvent(eventType, false, false, 'custom');
  12916. window.dispatchEvent(event);
  12917. }
  12918. function abort() {
  12919. if (activeService) {
  12920. activeService.destroy();
  12921. dispatchEvent('afterprint');
  12922. }
  12923. }
  12924. function renderProgress(index, total, l10n) {
  12925. var progressContainer = document.getElementById('printServiceOverlay');
  12926. var progress = Math.round(100 * index / total);
  12927. var progressBar = progressContainer.querySelector('progress');
  12928. var progressPerc = progressContainer.querySelector('.relative-progress');
  12929. progressBar.value = progress;
  12930. l10n.get('print_progress_percent', {
  12931. progress: progress
  12932. }, progress + '%').then(function (msg) {
  12933. progressPerc.textContent = msg;
  12934. });
  12935. }
  12936. var hasAttachEvent = !!document.attachEvent;
  12937. window.addEventListener('keydown', function (event) {
  12938. if (event.keyCode === 80 && (event.ctrlKey || event.metaKey) && !event.altKey && (!event.shiftKey || window.chrome || window.opera)) {
  12939. window.print();
  12940. if (hasAttachEvent) {
  12941. return;
  12942. }
  12943. event.preventDefault();
  12944. if (event.stopImmediatePropagation) {
  12945. event.stopImmediatePropagation();
  12946. } else {
  12947. event.stopPropagation();
  12948. }
  12949. }
  12950. }, true);
  12951. if (hasAttachEvent) {
  12952. document.attachEvent('onkeydown', function (event) {
  12953. event = event || window.event;
  12954. if (event.keyCode === 80 && event.ctrlKey) {
  12955. event.keyCode = 0;
  12956. return false;
  12957. }
  12958. });
  12959. }
  12960. if ('onbeforeprint' in window) {
  12961. var stopPropagationIfNeeded = function stopPropagationIfNeeded(event) {
  12962. if (event.detail !== 'custom' && event.stopImmediatePropagation) {
  12963. event.stopImmediatePropagation();
  12964. }
  12965. };
  12966. window.addEventListener('beforeprint', stopPropagationIfNeeded);
  12967. window.addEventListener('afterprint', stopPropagationIfNeeded);
  12968. }
  12969. var overlayPromise;
  12970. function ensureOverlay() {
  12971. if (!overlayPromise) {
  12972. overlayManager = _app.PDFViewerApplication.overlayManager;
  12973. if (!overlayManager) {
  12974. throw new Error('The overlay manager has not yet been initialized.');
  12975. }
  12976. overlayPromise = overlayManager.register('printServiceOverlay', document.getElementById('printServiceOverlay'), abort, true);
  12977. document.getElementById('printCancel').onclick = abort;
  12978. }
  12979. return overlayPromise;
  12980. }
  12981. _app.PDFPrintServiceFactory.instance = {
  12982. supportsPrinting: true,
  12983. createPrintService: function createPrintService(pdfDocument, pagesOverview, printContainer, l10n) {
  12984. if (activeService) {
  12985. throw new Error('The print service is created and active.');
  12986. }
  12987. activeService = new PDFPrintService(pdfDocument, pagesOverview, printContainer, l10n);
  12988. return activeService;
  12989. }
  12990. };
  12991. /***/ })
  12992. /******/ ]);
  12993. //# sourceMappingURL=viewer.js.map