viewer.js 479 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132
  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. /******/
  23. (function(modules) { // webpackBootstrap
  24. /******/ // The module cache
  25. /******/
  26. var installedModules = {};
  27. /******/
  28. /******/ // The require function
  29. /******/
  30. function __webpack_require__(moduleId) {
  31. /******/
  32. /******/ // Check if module is in cache
  33. /******/
  34. if (installedModules[moduleId]) {
  35. /******/
  36. return installedModules[moduleId].exports;
  37. /******/
  38. }
  39. /******/ // Create a new module (and put it into the cache)
  40. /******/
  41. var module = installedModules[moduleId] = {
  42. /******/
  43. i: moduleId,
  44. /******/
  45. l: false,
  46. /******/
  47. exports: {}
  48. /******/
  49. };
  50. /******/
  51. /******/ // Execute the module function
  52. /******/
  53. modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  54. /******/
  55. /******/ // Flag the module as loaded
  56. /******/
  57. module.l = true;
  58. /******/
  59. /******/ // Return the exports of the module
  60. /******/
  61. return module.exports;
  62. /******/
  63. }
  64. /******/
  65. /******/
  66. /******/ // expose the modules object (__webpack_modules__)
  67. /******/
  68. __webpack_require__.m = modules;
  69. /******/
  70. /******/ // expose the module cache
  71. /******/
  72. __webpack_require__.c = installedModules;
  73. /******/
  74. /******/ // define getter function for harmony exports
  75. /******/
  76. __webpack_require__.d = function(exports, name, getter) {
  77. /******/
  78. if (!__webpack_require__.o(exports, name)) {
  79. /******/
  80. Object.defineProperty(exports, name, {
  81. enumerable: true,
  82. get: getter
  83. });
  84. /******/
  85. }
  86. /******/
  87. };
  88. /******/
  89. /******/ // define __esModule on exports
  90. /******/
  91. __webpack_require__.r = function(exports) {
  92. /******/
  93. if (typeof Symbol !== 'undefined' && Symbol.toStringTag) {
  94. /******/
  95. Object.defineProperty(exports, Symbol.toStringTag, {
  96. value: 'Module'
  97. });
  98. /******/
  99. }
  100. /******/
  101. Object.defineProperty(exports, '__esModule', {
  102. value: true
  103. });
  104. /******/
  105. };
  106. /******/
  107. /******/ // create a fake namespace object
  108. /******/ // mode & 1: value is a module id, require it
  109. /******/ // mode & 2: merge all properties of value into the ns
  110. /******/ // mode & 4: return value when already ns object
  111. /******/ // mode & 8|1: behave like require
  112. /******/
  113. __webpack_require__.t = function(value, mode) {
  114. /******/
  115. if (mode & 1) value = __webpack_require__(value);
  116. /******/
  117. if (mode & 8) return value;
  118. /******/
  119. if ((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
  120. /******/
  121. var ns = Object.create(null);
  122. /******/
  123. __webpack_require__.r(ns);
  124. /******/
  125. Object.defineProperty(ns, 'default', {
  126. enumerable: true,
  127. value: value
  128. });
  129. /******/
  130. if (mode & 2 && typeof value != 'string')
  131. for (var key in value) __webpack_require__.d(ns, key, function(key) {
  132. return value[key];
  133. }.bind(null, key));
  134. /******/
  135. return ns;
  136. /******/
  137. };
  138. /******/
  139. /******/ // getDefaultExport function for compatibility with non-harmony modules
  140. /******/
  141. __webpack_require__.n = function(module) {
  142. /******/
  143. var getter = module && module.__esModule ?
  144. /******/
  145. function getDefault() {
  146. return module['default'];
  147. } :
  148. /******/
  149. function getModuleExports() {
  150. return module;
  151. };
  152. /******/
  153. __webpack_require__.d(getter, 'a', getter);
  154. /******/
  155. return getter;
  156. /******/
  157. };
  158. /******/
  159. /******/ // Object.prototype.hasOwnProperty.call
  160. /******/
  161. __webpack_require__.o = function(object, property) {
  162. return Object.prototype.hasOwnProperty.call(object, property);
  163. };
  164. /******/
  165. /******/ // __webpack_public_path__
  166. /******/
  167. __webpack_require__.p = "";
  168. /******/
  169. /******/
  170. /******/ // Load entry module and return exports
  171. /******/
  172. return __webpack_require__(__webpack_require__.s = 0);
  173. /******/
  174. })
  175. /************************************************************************/
  176. /******/
  177. ([
  178. /* 0 */
  179. /***/
  180. (function(module, exports, __webpack_require__) {
  181. "use strict";
  182. ;
  183. var pdfjsWebApp, pdfjsWebAppOptions; {
  184. pdfjsWebApp = __webpack_require__(1);
  185. pdfjsWebAppOptions = __webpack_require__(6);
  186. }; {
  187. __webpack_require__(36);
  188. }; {
  189. __webpack_require__(41);
  190. }
  191. function getViewerConfiguration() {
  192. return {
  193. appContainer: document.body,
  194. mainContainer: document.getElementById('viewerContainer'),
  195. viewerContainer: document.getElementById('viewer'),
  196. eventBus: null,
  197. toolbar: {
  198. container: document.getElementById('toolbarViewer'),
  199. numPages: document.getElementById('numPages'),
  200. pageNumber: document.getElementById('pageNumber'),
  201. scaleSelectContainer: document.getElementById('scaleSelectContainer'),
  202. scaleSelect: document.getElementById('scaleSelect'),
  203. customScaleOption: document.getElementById('customScaleOption'),
  204. previous: document.getElementById('previous'),
  205. next: document.getElementById('next'),
  206. zoomIn: document.getElementById('zoomIn'),
  207. zoomOut: document.getElementById('zoomOut'),
  208. viewFind: document.getElementById('viewFind'),
  209. openFile: document.getElementById('openFile'),
  210. print: document.getElementById('print'),
  211. presentationModeButton: document.getElementById('presentationMode'),
  212. download: document.getElementById('download'),
  213. viewBookmark: document.getElementById('viewBookmark')
  214. },
  215. secondaryToolbar: {
  216. toolbar: document.getElementById('secondaryToolbar'),
  217. toggleButton: document.getElementById('secondaryToolbarToggle'),
  218. toolbarButtonContainer: document.getElementById('secondaryToolbarButtonContainer'),
  219. presentationModeButton: document.getElementById('secondaryPresentationMode'),
  220. openFileButton: document.getElementById('secondaryOpenFile'),
  221. printButton: document.getElementById('secondaryPrint'),
  222. downloadButton: document.getElementById('secondaryDownload'),
  223. viewBookmarkButton: document.getElementById('secondaryViewBookmark'),
  224. firstPageButton: document.getElementById('firstPage'),
  225. lastPageButton: document.getElementById('lastPage'),
  226. pageRotateCwButton: document.getElementById('pageRotateCw'),
  227. pageRotateCcwButton: document.getElementById('pageRotateCcw'),
  228. cursorSelectToolButton: document.getElementById('cursorSelectTool'),
  229. cursorHandToolButton: document.getElementById('cursorHandTool'),
  230. scrollVerticalButton: document.getElementById('scrollVertical'),
  231. scrollHorizontalButton: document.getElementById('scrollHorizontal'),
  232. scrollWrappedButton: document.getElementById('scrollWrapped'),
  233. spreadNoneButton: document.getElementById('spreadNone'),
  234. spreadOddButton: document.getElementById('spreadOdd'),
  235. spreadEvenButton: document.getElementById('spreadEven'),
  236. documentPropertiesButton: document.getElementById('documentProperties')
  237. },
  238. fullscreen: {
  239. contextFirstPage: document.getElementById('contextFirstPage'),
  240. contextLastPage: document.getElementById('contextLastPage'),
  241. contextPageRotateCw: document.getElementById('contextPageRotateCw'),
  242. contextPageRotateCcw: document.getElementById('contextPageRotateCcw')
  243. },
  244. sidebar: {
  245. outerContainer: document.getElementById('outerContainer'),
  246. viewerContainer: document.getElementById('viewerContainer'),
  247. toggleButton: document.getElementById('sidebarToggle'),
  248. thumbnailButton: document.getElementById('viewThumbnail'),
  249. outlineButton: document.getElementById('viewOutline'),
  250. attachmentsButton: document.getElementById('viewAttachments'),
  251. thumbnailView: document.getElementById('thumbnailView'),
  252. outlineView: document.getElementById('outlineView'),
  253. attachmentsView: document.getElementById('attachmentsView')
  254. },
  255. sidebarResizer: {
  256. outerContainer: document.getElementById('outerContainer'),
  257. resizer: document.getElementById('sidebarResizer')
  258. },
  259. findBar: {
  260. bar: document.getElementById('findbar'),
  261. toggleButton: document.getElementById('viewFind'),
  262. findField: document.getElementById('findInput'),
  263. highlightAllCheckbox: document.getElementById('findHighlightAll'),
  264. caseSensitiveCheckbox: document.getElementById('findMatchCase'),
  265. entireWordCheckbox: document.getElementById('findEntireWord'),
  266. findMsg: document.getElementById('findMsg'),
  267. findResultsCount: document.getElementById('findResultsCount'),
  268. findPreviousButton: document.getElementById('findPrevious'),
  269. findNextButton: document.getElementById('findNext')
  270. },
  271. passwordOverlay: {
  272. overlayName: 'passwordOverlay',
  273. container: document.getElementById('passwordOverlay'),
  274. label: document.getElementById('passwordText'),
  275. input: document.getElementById('password'),
  276. submitButton: document.getElementById('passwordSubmit'),
  277. cancelButton: document.getElementById('passwordCancel')
  278. },
  279. documentProperties: {
  280. overlayName: 'documentPropertiesOverlay',
  281. container: document.getElementById('documentPropertiesOverlay'),
  282. closeButton: document.getElementById('documentPropertiesClose'),
  283. fields: {
  284. 'fileName': document.getElementById('fileNameField'),
  285. 'fileSize': document.getElementById('fileSizeField'),
  286. 'title': document.getElementById('titleField'),
  287. 'author': document.getElementById('authorField'),
  288. 'subject': document.getElementById('subjectField'),
  289. 'keywords': document.getElementById('keywordsField'),
  290. 'creationDate': document.getElementById('creationDateField'),
  291. 'modificationDate': document.getElementById('modificationDateField'),
  292. 'creator': document.getElementById('creatorField'),
  293. 'producer': document.getElementById('producerField'),
  294. 'version': document.getElementById('versionField'),
  295. 'pageCount': document.getElementById('pageCountField'),
  296. 'pageSize': document.getElementById('pageSizeField'),
  297. 'linearized': document.getElementById('linearizedField')
  298. }
  299. },
  300. errorWrapper: {
  301. container: document.getElementById('errorWrapper'),
  302. errorMessage: document.getElementById('errorMessage'),
  303. closeButton: document.getElementById('errorClose'),
  304. errorMoreInfo: document.getElementById('errorMoreInfo'),
  305. moreInfoButton: document.getElementById('errorShowMore'),
  306. lessInfoButton: document.getElementById('errorShowLess')
  307. },
  308. printContainer: document.getElementById('printContainer'),
  309. openFileInputName: 'fileInput',
  310. debuggerScriptPath: './debugger.js'
  311. };
  312. }
  313. function webViewerLoad() {
  314. var config = getViewerConfiguration();
  315. window.PDFViewerApplication = pdfjsWebApp.PDFViewerApplication;
  316. window.PDFViewerApplicationOptions = pdfjsWebAppOptions.AppOptions;
  317. var event = document.createEvent('CustomEvent');
  318. event.initCustomEvent('webviewerloaded', true, true, {});
  319. document.dispatchEvent(event);
  320. pdfjsWebApp.PDFViewerApplication.run(config);
  321. }
  322. if (document.readyState === 'interactive' || document.readyState === 'complete') {
  323. webViewerLoad();
  324. } else {
  325. document.addEventListener('DOMContentLoaded', webViewerLoad, true);
  326. }
  327. /***/
  328. }),
  329. /* 1 */
  330. /***/
  331. (function(module, exports, __webpack_require__) {
  332. "use strict";
  333. Object.defineProperty(exports, "__esModule", {
  334. value: true
  335. });
  336. exports.PDFPrintServiceFactory = exports.DefaultExternalServices = exports.PDFViewerApplication =
  337. void 0;
  338. var _regenerator = _interopRequireDefault(__webpack_require__(2));
  339. var _ui_utils = __webpack_require__(5);
  340. var _app_options = __webpack_require__(6);
  341. var _pdfjsLib = __webpack_require__(7);
  342. var _pdf_cursor_tools = __webpack_require__(9);
  343. var _pdf_rendering_queue = __webpack_require__(11);
  344. var _pdf_sidebar = __webpack_require__(12);
  345. var _overlay_manager = __webpack_require__(13);
  346. var _password_prompt = __webpack_require__(14);
  347. var _pdf_attachment_viewer = __webpack_require__(15);
  348. var _pdf_document_properties = __webpack_require__(16);
  349. var _pdf_find_bar = __webpack_require__(17);
  350. var _pdf_find_controller = __webpack_require__(18);
  351. var _pdf_history = __webpack_require__(20);
  352. var _pdf_link_service = __webpack_require__(21);
  353. var _pdf_outline_viewer = __webpack_require__(22);
  354. var _pdf_presentation_mode = __webpack_require__(23);
  355. var _pdf_sidebar_resizer = __webpack_require__(24);
  356. var _pdf_thumbnail_viewer = __webpack_require__(25);
  357. var _pdf_viewer = __webpack_require__(27);
  358. var _secondary_toolbar = __webpack_require__(32);
  359. var _toolbar = __webpack_require__(34);
  360. var _view_history = __webpack_require__(35);
  361. function _interopRequireDefault(obj) {
  362. return obj && obj.__esModule ? obj : {
  363. "default": obj
  364. };
  365. }
  366. function _slicedToArray(arr, i) {
  367. return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest();
  368. }
  369. function _nonIterableRest() {
  370. throw new TypeError("Invalid attempt to destructure non-iterable instance");
  371. }
  372. function _iterableToArrayLimit(arr, i) {
  373. if (!(Symbol.iterator in Object(arr) || Object.prototype.toString.call(arr) ===
  374. "[object Arguments]")) {
  375. return;
  376. }
  377. var _arr = [];
  378. var _n = true;
  379. var _d = false;
  380. var _e = undefined;
  381. try {
  382. for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {
  383. _arr.push(_s.value);
  384. if (i && _arr.length === i) break;
  385. }
  386. } catch (err) {
  387. _d = true;
  388. _e = err;
  389. } finally {
  390. try {
  391. if (!_n && _i["return"] != null) _i["return"]();
  392. } finally {
  393. if (_d) throw _e;
  394. }
  395. }
  396. return _arr;
  397. }
  398. function _arrayWithHoles(arr) {
  399. if (Array.isArray(arr)) return arr;
  400. }
  401. function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
  402. try {
  403. var info = gen[key](arg);
  404. var value = info.value;
  405. } catch (error) {
  406. reject(error);
  407. return;
  408. }
  409. if (info.done) {
  410. resolve(value);
  411. } else {
  412. Promise.resolve(value).then(_next, _throw);
  413. }
  414. }
  415. function _asyncToGenerator(fn) {
  416. return function() {
  417. var self = this,
  418. args = arguments;
  419. return new Promise(function(resolve, reject) {
  420. var gen = fn.apply(self, args);
  421. function _next(value) {
  422. asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
  423. }
  424. function _throw(err) {
  425. asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
  426. }
  427. _next(undefined);
  428. });
  429. };
  430. }
  431. var DEFAULT_SCALE_DELTA = 1.1;
  432. var DISABLE_AUTO_FETCH_LOADING_BAR_TIMEOUT = 5000;
  433. var FORCE_PAGES_LOADED_TIMEOUT = 10000;
  434. var WHEEL_ZOOM_DISABLED_TIMEOUT = 1000;
  435. var ViewOnLoad = {
  436. UNKNOWN: -1,
  437. PREVIOUS: 0,
  438. INITIAL: 1
  439. };
  440. var DefaultExternalServices = {
  441. updateFindControlState: function updateFindControlState(data) {},
  442. updateFindMatchesCount: function updateFindMatchesCount(data) {},
  443. initPassiveLoading: function initPassiveLoading(callbacks) {},
  444. fallback: function fallback(data, callback) {},
  445. reportTelemetry: function reportTelemetry(data) {},
  446. createDownloadManager: function createDownloadManager(options) {
  447. throw new Error('Not implemented: createDownloadManager');
  448. },
  449. createPreferences: function createPreferences() {
  450. throw new Error('Not implemented: createPreferences');
  451. },
  452. createL10n: function createL10n(options) {
  453. throw new Error('Not implemented: createL10n');
  454. },
  455. supportsIntegratedFind: false,
  456. supportsDocumentFonts: true,
  457. supportsDocumentColors: true,
  458. supportedMouseWheelZoomModifierKeys: {
  459. ctrlKey: true,
  460. metaKey: true
  461. }
  462. };
  463. exports.DefaultExternalServices = DefaultExternalServices;
  464. var PDFViewerApplication = {
  465. initialBookmark: document.location.hash.substring(1),
  466. initialized: false,
  467. fellback: false,
  468. appConfig: null,
  469. pdfDocument: null,
  470. pdfLoadingTask: null,
  471. printService: null,
  472. pdfViewer: null,
  473. pdfThumbnailViewer: null,
  474. pdfRenderingQueue: null,
  475. pdfPresentationMode: null,
  476. pdfDocumentProperties: null,
  477. pdfLinkService: null,
  478. pdfHistory: null,
  479. pdfSidebar: null,
  480. pdfSidebarResizer: null,
  481. pdfOutlineViewer: null,
  482. pdfAttachmentViewer: null,
  483. pdfCursorTools: null,
  484. store: null,
  485. downloadManager: null,
  486. overlayManager: null,
  487. preferences: null,
  488. toolbar: null,
  489. secondaryToolbar: null,
  490. eventBus: null,
  491. l10n: null,
  492. isInitialViewSet: false,
  493. downloadComplete: false,
  494. isViewerEmbedded: window.parent !== window,
  495. url: '',
  496. baseUrl: '',
  497. externalServices: DefaultExternalServices,
  498. _boundEvents: {},
  499. contentDispositionFilename: null,
  500. initialize: function() {
  501. var _initialize = _asyncToGenerator(
  502. /*#__PURE__*/
  503. _regenerator["default"].mark(function _callee(appConfig) {
  504. var _this = this;
  505. var appContainer;
  506. return _regenerator["default"].wrap(function _callee$(_context) {
  507. while (1) {
  508. switch (_context.prev = _context.next) {
  509. case 0:
  510. this.preferences = this.externalServices
  511. .createPreferences();
  512. this.appConfig = appConfig;
  513. _context.next = 4;
  514. return this._readPreferences();
  515. case 4:
  516. _context.next = 6;
  517. return this._parseHashParameters();
  518. case 6:
  519. _context.next = 8;
  520. return this._initializeL10n();
  521. case 8:
  522. if (this.isViewerEmbedded && _app_options
  523. .AppOptions.get('externalLinkTarget') ===
  524. _pdfjsLib.LinkTarget.NONE) {
  525. _app_options.AppOptions.set(
  526. 'externalLinkTarget', _pdfjsLib
  527. .LinkTarget.TOP);
  528. }
  529. _context.next = 11;
  530. return this._initializeViewerComponents();
  531. case 11:
  532. this.bindEvents();
  533. this.bindWindowEvents();
  534. appContainer = appConfig.appContainer ||
  535. document.documentElement;
  536. this.l10n.translate(appContainer).then(
  537. function() {
  538. _this.eventBus.dispatch(
  539. 'localized', {
  540. source: _this
  541. });
  542. });
  543. this.initialized = true;
  544. case 16:
  545. case "end":
  546. return _context.stop();
  547. }
  548. }
  549. }, _callee, this);
  550. }));
  551. function initialize(_x) {
  552. return _initialize.apply(this, arguments);
  553. }
  554. return initialize;
  555. }(),
  556. _readPreferences: function() {
  557. var _readPreferences2 = _asyncToGenerator(
  558. /*#__PURE__*/
  559. _regenerator["default"].mark(function _callee2() {
  560. var prefs, name;
  561. return _regenerator["default"].wrap(function _callee2$(_context2) {
  562. while (1) {
  563. switch (_context2.prev = _context2.next) {
  564. case 0:
  565. if (!(_app_options.AppOptions.get(
  566. 'disablePreferences') === true)) {
  567. _context2.next = 2;
  568. break;
  569. }
  570. return _context2.abrupt("return");
  571. case 2:
  572. _context2.prev = 2;
  573. _context2.next = 5;
  574. return this.preferences.getAll();
  575. case 5:
  576. prefs = _context2.sent;
  577. for (name in prefs) {
  578. _app_options.AppOptions.set(name, prefs[
  579. name]);
  580. }
  581. _context2.next = 12;
  582. break;
  583. case 9:
  584. _context2.prev = 9;
  585. _context2.t0 = _context2["catch"](2);
  586. console.error("_readPreferences: \"".concat(
  587. _context2.t0.message, "\"."));
  588. case 12:
  589. case "end":
  590. return _context2.stop();
  591. }
  592. }
  593. }, _callee2, this, [
  594. [2, 9]
  595. ]);
  596. }));
  597. function _readPreferences() {
  598. return _readPreferences2.apply(this, arguments);
  599. }
  600. return _readPreferences;
  601. }(),
  602. _parseHashParameters: function() {
  603. var _parseHashParameters2 = _asyncToGenerator(
  604. /*#__PURE__*/
  605. _regenerator["default"].mark(function _callee3() {
  606. var waitOn, hash, hashParams, viewer, enabled;
  607. return _regenerator["default"].wrap(function _callee3$(_context3) {
  608. while (1) {
  609. switch (_context3.prev = _context3.next) {
  610. case 0:
  611. if (_app_options.AppOptions.get(
  612. 'pdfBugEnabled')) {
  613. _context3.next = 2;
  614. break;
  615. }
  616. return _context3.abrupt("return", undefined);
  617. case 2:
  618. waitOn = [];
  619. hash = document.location.hash.substring(1);
  620. hashParams = (0, _ui_utils.parseQueryString)(
  621. hash);
  622. if ('disableworker' in hashParams && hashParams[
  623. 'disableworker'] === 'true') {
  624. waitOn.push(loadFakeWorker());
  625. }
  626. if ('disablerange' in hashParams) {
  627. _app_options.AppOptions.set('disableRange',
  628. hashParams['disablerange'] ===
  629. 'true');
  630. }
  631. if ('disablestream' in hashParams) {
  632. _app_options.AppOptions.set('disableStream',
  633. hashParams['disablestream'] ===
  634. 'true');
  635. }
  636. if ('disableautofetch' in hashParams) {
  637. _app_options.AppOptions.set(
  638. 'disableAutoFetch', hashParams[
  639. 'disableautofetch'] === 'true');
  640. }
  641. if ('disablefontface' in hashParams) {
  642. _app_options.AppOptions.set(
  643. 'disableFontFace', hashParams[
  644. 'disablefontface'] === 'true');
  645. }
  646. if ('disablehistory' in hashParams) {
  647. _app_options.AppOptions.set(
  648. 'disableHistory', hashParams[
  649. 'disablehistory'] === 'true');
  650. }
  651. if ('webgl' in hashParams) {
  652. _app_options.AppOptions.set('enableWebGL',
  653. hashParams['webgl'] === 'true');
  654. }
  655. if ('useonlycsszoom' in hashParams) {
  656. _app_options.AppOptions.set(
  657. 'useOnlyCssZoom', hashParams[
  658. 'useonlycsszoom'] === 'true');
  659. }
  660. if ('verbosity' in hashParams) {
  661. _app_options.AppOptions.set('verbosity',
  662. hashParams['verbosity'] | 0);
  663. }
  664. if (!('textlayer' in hashParams)) {
  665. _context3.next = 23;
  666. break;
  667. }
  668. _context3.t0 = hashParams['textlayer'];
  669. _context3.next = _context3.t0 === 'off' ? 18 :
  670. _context3.t0 === 'visible' ? 20 : _context3
  671. .t0 === 'shadow' ? 20 : _context3.t0 ===
  672. 'hover' ? 20 : 23;
  673. break;
  674. case 18:
  675. _app_options.AppOptions.set('textLayerMode',
  676. _ui_utils.TextLayerMode.DISABLE);
  677. return _context3.abrupt("break", 23);
  678. case 20:
  679. viewer = this.appConfig.viewerContainer;
  680. viewer.classList.add('textLayer-' + hashParams[
  681. 'textlayer']);
  682. return _context3.abrupt("break", 23);
  683. case 23:
  684. if ('pdfbug' in hashParams) {
  685. _app_options.AppOptions.set('pdfBug', true);
  686. enabled = hashParams['pdfbug'].split(',');
  687. waitOn.push(loadAndEnablePDFBug(enabled));
  688. }
  689. if ('locale' in hashParams) {
  690. _app_options.AppOptions.set('locale',
  691. hashParams['locale']);
  692. }
  693. return _context3.abrupt("return", Promise.all(
  694. waitOn)["catch"](function(reason) {
  695. console.error(
  696. "_parseHashParameters: \""
  697. .concat(reason.message,
  698. "\"."));
  699. }));
  700. case 26:
  701. case "end":
  702. return _context3.stop();
  703. }
  704. }
  705. }, _callee3, this);
  706. }));
  707. function _parseHashParameters() {
  708. return _parseHashParameters2.apply(this, arguments);
  709. }
  710. return _parseHashParameters;
  711. }(),
  712. _initializeL10n: function() {
  713. var _initializeL10n2 = _asyncToGenerator(
  714. /*#__PURE__*/
  715. _regenerator["default"].mark(function _callee4() {
  716. var dir;
  717. return _regenerator["default"].wrap(function _callee4$(_context4) {
  718. while (1) {
  719. switch (_context4.prev = _context4.next) {
  720. case 0:
  721. this.l10n = this.externalServices.createL10n({
  722. locale: _app_options.AppOptions.get(
  723. 'locale')
  724. });
  725. _context4.next = 3;
  726. return this.l10n.getDirection();
  727. case 3:
  728. dir = _context4.sent;
  729. document.getElementsByTagName('html')[0].dir =
  730. dir;
  731. case 5:
  732. case "end":
  733. return _context4.stop();
  734. }
  735. }
  736. }, _callee4, this);
  737. }));
  738. function _initializeL10n() {
  739. return _initializeL10n2.apply(this, arguments);
  740. }
  741. return _initializeL10n;
  742. }(),
  743. _initializeViewerComponents: function() {
  744. var _initializeViewerComponents2 = _asyncToGenerator(
  745. /*#__PURE__*/
  746. _regenerator["default"].mark(function _callee5() {
  747. var appConfig, eventBus, pdfRenderingQueue, pdfLinkService,
  748. downloadManager, findController, container, viewer;
  749. return _regenerator["default"].wrap(function _callee5$(_context5) {
  750. while (1) {
  751. switch (_context5.prev = _context5.next) {
  752. case 0:
  753. appConfig = this.appConfig;
  754. this.overlayManager = new _overlay_manager
  755. .OverlayManager();
  756. eventBus = appConfig.eventBus || (0, _ui_utils
  757. .getGlobalEventBus)(_app_options
  758. .AppOptions.get('eventBusDispatchToDOM')
  759. );
  760. this.eventBus = eventBus;
  761. pdfRenderingQueue = new _pdf_rendering_queue
  762. .PDFRenderingQueue();
  763. pdfRenderingQueue.onIdle = this.cleanup.bind(
  764. this);
  765. this.pdfRenderingQueue = pdfRenderingQueue;
  766. pdfLinkService = new _pdf_link_service
  767. .PDFLinkService({
  768. eventBus: eventBus,
  769. externalLinkTarget: _app_options
  770. .AppOptions.get(
  771. 'externalLinkTarget'),
  772. externalLinkRel: _app_options
  773. .AppOptions.get(
  774. 'externalLinkRel')
  775. });
  776. this.pdfLinkService = pdfLinkService;
  777. downloadManager = this.externalServices
  778. .createDownloadManager({
  779. disableCreateObjectURL: _app_options
  780. .AppOptions.get(
  781. 'disableCreateObjectURL')
  782. });
  783. this.downloadManager = downloadManager;
  784. findController = new _pdf_find_controller
  785. .PDFFindController({
  786. linkService: pdfLinkService,
  787. eventBus: eventBus
  788. });
  789. this.findController = findController;
  790. container = appConfig.mainContainer;
  791. viewer = appConfig.viewerContainer;
  792. this.pdfViewer = new _pdf_viewer.PDFViewer({
  793. container: container,
  794. viewer: viewer,
  795. eventBus: eventBus,
  796. renderingQueue: pdfRenderingQueue,
  797. linkService: pdfLinkService,
  798. downloadManager: downloadManager,
  799. findController: findController,
  800. renderer: _app_options.AppOptions
  801. .get('renderer'),
  802. enableWebGL: _app_options.AppOptions
  803. .get('enableWebGL'),
  804. l10n: this.l10n,
  805. textLayerMode: _app_options
  806. .AppOptions.get(
  807. 'textLayerMode'),
  808. imageResourcesPath: _app_options
  809. .AppOptions.get(
  810. 'imageResourcesPath'),
  811. renderInteractiveForms: _app_options
  812. .AppOptions.get(
  813. 'renderInteractiveForms'),
  814. enablePrintAutoRotate: _app_options
  815. .AppOptions.get(
  816. 'enablePrintAutoRotate'),
  817. useOnlyCssZoom: _app_options
  818. .AppOptions.get(
  819. 'useOnlyCssZoom'),
  820. maxCanvasPixels: _app_options
  821. .AppOptions.get(
  822. 'maxCanvasPixels')
  823. });
  824. pdfRenderingQueue.setViewer(this.pdfViewer);
  825. pdfLinkService.setViewer(this.pdfViewer);
  826. this.pdfThumbnailViewer =
  827. new _pdf_thumbnail_viewer
  828. .PDFThumbnailViewer({
  829. container: appConfig.sidebar
  830. .thumbnailView,
  831. renderingQueue: pdfRenderingQueue,
  832. linkService: pdfLinkService,
  833. l10n: this.l10n
  834. });
  835. pdfRenderingQueue.setThumbnailViewer(this
  836. .pdfThumbnailViewer);
  837. this.pdfHistory = new _pdf_history.PDFHistory({
  838. linkService: pdfLinkService,
  839. eventBus: eventBus
  840. });
  841. pdfLinkService.setHistory(this.pdfHistory);
  842. if (!this.supportsIntegratedFind) {
  843. this.findBar = new _pdf_find_bar.PDFFindBar(
  844. appConfig.findBar, eventBus, this
  845. .l10n);
  846. }
  847. this.pdfDocumentProperties =
  848. new _pdf_document_properties
  849. .PDFDocumentProperties(appConfig
  850. .documentProperties, this
  851. .overlayManager, eventBus, this.l10n);
  852. this.pdfCursorTools = new _pdf_cursor_tools
  853. .PDFCursorTools({
  854. container: container,
  855. eventBus: eventBus,
  856. cursorToolOnLoad: _app_options
  857. .AppOptions.get(
  858. 'cursorToolOnLoad')
  859. });
  860. this.toolbar = new _toolbar.Toolbar(appConfig
  861. .toolbar, eventBus, this.l10n);
  862. this.secondaryToolbar = new _secondary_toolbar
  863. .SecondaryToolbar(appConfig
  864. .secondaryToolbar, container, eventBus);
  865. if (this.supportsFullscreen) {
  866. this.pdfPresentationMode =
  867. new _pdf_presentation_mode
  868. .PDFPresentationMode({
  869. container: container,
  870. viewer: viewer,
  871. pdfViewer: this.pdfViewer,
  872. eventBus: eventBus,
  873. contextMenuItems: appConfig
  874. .fullscreen
  875. });
  876. }
  877. this.passwordPrompt = new _password_prompt
  878. .PasswordPrompt(appConfig.passwordOverlay,
  879. this.overlayManager, this.l10n);
  880. this.pdfOutlineViewer = new _pdf_outline_viewer
  881. .PDFOutlineViewer({
  882. container: appConfig.sidebar
  883. .outlineView,
  884. eventBus: eventBus,
  885. linkService: pdfLinkService
  886. });
  887. this.pdfAttachmentViewer =
  888. new _pdf_attachment_viewer
  889. .PDFAttachmentViewer({
  890. container: appConfig.sidebar
  891. .attachmentsView,
  892. eventBus: eventBus,
  893. downloadManager: downloadManager
  894. });
  895. this.pdfSidebar = new _pdf_sidebar.PDFSidebar({
  896. elements: appConfig.sidebar,
  897. pdfViewer: this.pdfViewer,
  898. pdfThumbnailViewer: this
  899. .pdfThumbnailViewer,
  900. eventBus: eventBus,
  901. l10n: this.l10n
  902. });
  903. this.pdfSidebar.onToggled = this.forceRendering
  904. .bind(this);
  905. this.pdfSidebarResizer =
  906. new _pdf_sidebar_resizer.PDFSidebarResizer(
  907. appConfig.sidebarResizer, eventBus, this
  908. .l10n);
  909. case 34:
  910. case "end":
  911. return _context5.stop();
  912. }
  913. }
  914. }, _callee5, this);
  915. }));
  916. function _initializeViewerComponents() {
  917. return _initializeViewerComponents2.apply(this, arguments);
  918. }
  919. return _initializeViewerComponents;
  920. }(),
  921. run: function run(config) {
  922. this.initialize(config).then(webViewerInitialized);
  923. },
  924. zoomIn: function zoomIn(ticks) {
  925. if (this.pdfViewer.isInPresentationMode) {
  926. return;
  927. }
  928. var newScale = this.pdfViewer.currentScale;
  929. do {
  930. newScale = (newScale * DEFAULT_SCALE_DELTA).toFixed(2);
  931. newScale = Math.ceil(newScale * 10) / 10;
  932. newScale = Math.min(_ui_utils.MAX_SCALE, newScale);
  933. } while (--ticks > 0 && newScale < _ui_utils.MAX_SCALE);
  934. this.pdfViewer.currentScaleValue = newScale;
  935. },
  936. zoomOut: function zoomOut(ticks) {
  937. if (this.pdfViewer.isInPresentationMode) {
  938. return;
  939. }
  940. var newScale = this.pdfViewer.currentScale;
  941. do {
  942. newScale = (newScale / DEFAULT_SCALE_DELTA).toFixed(2);
  943. newScale = Math.floor(newScale * 10) / 10;
  944. newScale = Math.max(_ui_utils.MIN_SCALE, newScale);
  945. } while (--ticks > 0 && newScale > _ui_utils.MIN_SCALE);
  946. this.pdfViewer.currentScaleValue = newScale;
  947. },
  948. zoomReset: function zoomReset() {
  949. if (this.pdfViewer.isInPresentationMode) {
  950. return;
  951. }
  952. this.pdfViewer.currentScaleValue = _ui_utils.DEFAULT_SCALE_VALUE;
  953. },
  954. get pagesCount() {
  955. return this.pdfDocument ? this.pdfDocument.numPages : 0;
  956. },
  957. set page(val) {
  958. this.pdfViewer.currentPageNumber = val;
  959. },
  960. get page() {
  961. return this.pdfViewer.currentPageNumber;
  962. },
  963. get printing() {
  964. return !!this.printService;
  965. },
  966. get supportsPrinting() {
  967. return PDFPrintServiceFactory.instance.supportsPrinting;
  968. },
  969. get supportsFullscreen() {
  970. var support;
  971. var doc = document.documentElement;
  972. support = !!(doc.requestFullscreen || doc.mozRequestFullScreen || doc
  973. .webkitRequestFullScreen || doc.msRequestFullscreen);
  974. if (document.fullscreenEnabled === false || document.mozFullScreenEnabled === false ||
  975. document.webkitFullscreenEnabled === false || document.msFullscreenEnabled === false
  976. ) {
  977. support = false;
  978. }
  979. return (0, _pdfjsLib.shadow)(this, 'supportsFullscreen', support);
  980. },
  981. get supportsIntegratedFind() {
  982. return this.externalServices.supportsIntegratedFind;
  983. },
  984. get supportsDocumentFonts() {
  985. return this.externalServices.supportsDocumentFonts;
  986. },
  987. get supportsDocumentColors() {
  988. return this.externalServices.supportsDocumentColors;
  989. },
  990. get loadingBar() {
  991. var bar = new _ui_utils.ProgressBar('#loadingBar');
  992. return (0, _pdfjsLib.shadow)(this, 'loadingBar', bar);
  993. },
  994. get supportedMouseWheelZoomModifierKeys() {
  995. return this.externalServices.supportedMouseWheelZoomModifierKeys;
  996. },
  997. initPassiveLoading: function initPassiveLoading() {
  998. throw new Error('Not implemented: initPassiveLoading');
  999. },
  1000. setTitleUsingUrl: function setTitleUsingUrl() {
  1001. var url = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
  1002. this.url = url;
  1003. this.baseUrl = url.split('#')[0];
  1004. var title = (0, _ui_utils.getPDFFileNameFromURL)(url, '');
  1005. if (!title) {
  1006. try {
  1007. title = decodeURIComponent((0, _pdfjsLib.getFilenameFromUrl)(url)) || url;
  1008. } catch (ex) {
  1009. title = url;
  1010. }
  1011. }
  1012. this.setTitle(title);
  1013. },
  1014. setTitle: function setTitle(title) {
  1015. if (this.isViewerEmbedded) {
  1016. return;
  1017. }
  1018. document.title = title;
  1019. },
  1020. close: function() {
  1021. var _close = _asyncToGenerator(
  1022. /*#__PURE__*/
  1023. _regenerator["default"].mark(function _callee6() {
  1024. var errorWrapper, promise;
  1025. return _regenerator["default"].wrap(function _callee6$(_context6) {
  1026. while (1) {
  1027. switch (_context6.prev = _context6.next) {
  1028. case 0:
  1029. errorWrapper = this.appConfig.errorWrapper
  1030. .container;
  1031. errorWrapper.setAttribute('hidden', 'true');
  1032. if (this.pdfLoadingTask) {
  1033. _context6.next = 4;
  1034. break;
  1035. }
  1036. return _context6.abrupt("return", undefined);
  1037. case 4:
  1038. promise = this.pdfLoadingTask.destroy();
  1039. this.pdfLoadingTask = null;
  1040. if (this.pdfDocument) {
  1041. this.pdfDocument = null;
  1042. this.pdfThumbnailViewer.setDocument(null);
  1043. this.pdfViewer.setDocument(null);
  1044. this.pdfLinkService.setDocument(null);
  1045. this.pdfDocumentProperties.setDocument(
  1046. null);
  1047. }
  1048. this.store = null;
  1049. this.isInitialViewSet = false;
  1050. this.downloadComplete = false;
  1051. this.url = '';
  1052. this.baseUrl = '';
  1053. this.contentDispositionFilename = null;
  1054. this.pdfSidebar.reset();
  1055. this.pdfOutlineViewer.reset();
  1056. this.pdfAttachmentViewer.reset();
  1057. if (this.findBar) {
  1058. this.findBar.reset();
  1059. }
  1060. this.toolbar.reset();
  1061. this.secondaryToolbar.reset();
  1062. if (typeof PDFBug !== 'undefined') {
  1063. PDFBug.cleanup();
  1064. }
  1065. return _context6.abrupt("return", promise);
  1066. case 21:
  1067. case "end":
  1068. return _context6.stop();
  1069. }
  1070. }
  1071. }, _callee6, this);
  1072. }));
  1073. function close() {
  1074. return _close.apply(this, arguments);
  1075. }
  1076. return close;
  1077. }(),
  1078. open: function() {
  1079. var _open = _asyncToGenerator(
  1080. /*#__PURE__*/
  1081. _regenerator["default"].mark(function _callee7(file, args) {
  1082. var _this2 = this;
  1083. var workerParameters, key, parameters, apiParameters, _key, value,
  1084. _key2, _value, loadingTask;
  1085. return _regenerator["default"].wrap(function _callee7$(_context7) {
  1086. while (1) {
  1087. switch (_context7.prev = _context7.next) {
  1088. case 0:
  1089. if (!this.pdfLoadingTask) {
  1090. _context7.next = 3;
  1091. break;
  1092. }
  1093. _context7.next = 3;
  1094. return this.close();
  1095. case 3:
  1096. workerParameters = _app_options.AppOptions
  1097. .getAll(_app_options.OptionKind.WORKER);
  1098. for (key in workerParameters) {
  1099. _pdfjsLib.GlobalWorkerOptions[key] =
  1100. workerParameters[key];
  1101. }
  1102. parameters = Object.create(null);
  1103. if (typeof file === 'string') {
  1104. this.setTitleUsingUrl(file);
  1105. parameters.url = file;
  1106. } else if (file && 'byteLength' in file) {
  1107. parameters.data = file;
  1108. } else if (file.url && file.originalUrl) {
  1109. this.setTitleUsingUrl(file.originalUrl);
  1110. parameters.url = file.url;
  1111. }
  1112. apiParameters = _app_options.AppOptions.getAll(
  1113. _app_options.OptionKind.API);
  1114. for (_key in apiParameters) {
  1115. value = apiParameters[_key];
  1116. if (_key === 'docBaseUrl' && !value) {}
  1117. parameters[_key] = value;
  1118. }
  1119. if (args) {
  1120. for (_key2 in args) {
  1121. _value = args[_key2];
  1122. if (_key2 === 'length') {
  1123. this.pdfDocumentProperties
  1124. .setFileSize(_value);
  1125. }
  1126. parameters[_key2] = _value;
  1127. }
  1128. }
  1129. loadingTask = (0, _pdfjsLib.getDocument)(
  1130. parameters);
  1131. this.pdfLoadingTask = loadingTask;
  1132. loadingTask.onPassword = function(
  1133. updateCallback, reason) {
  1134. _this2.pdfLinkService
  1135. .externalLinkEnabled = false;
  1136. _this2.passwordPrompt.setUpdateCallback(
  1137. updateCallback, reason);
  1138. _this2.passwordPrompt.open();
  1139. };
  1140. loadingTask.onProgress = function(_ref) {
  1141. var loaded = _ref.loaded,
  1142. total = _ref.total;
  1143. _this2.progress(loaded / total);
  1144. };
  1145. loadingTask.onUnsupportedFeature = this.fallback
  1146. .bind(this);
  1147. return _context7.abrupt("return", loadingTask
  1148. .promise.then(function(pdfDocument) {
  1149. _this2.load(pdfDocument);
  1150. }, function(exception) {
  1151. if (loadingTask !== _this2
  1152. .pdfLoadingTask) {
  1153. return undefined;
  1154. }
  1155. var message = exception &&
  1156. exception.message;
  1157. var loadingErrorMessage;
  1158. if (exception instanceof _pdfjsLib
  1159. .InvalidPDFException) {
  1160. loadingErrorMessage = _this2
  1161. .l10n.get(
  1162. 'invalid_file_error',
  1163. null,
  1164. 'Invalid or corrupted PDF file.'
  1165. );
  1166. } else if (
  1167. exception instanceof _pdfjsLib
  1168. .MissingPDFException) {
  1169. loadingErrorMessage = _this2
  1170. .l10n.get(
  1171. 'missing_file_error',
  1172. null,
  1173. 'PDF 源文件已丢失'
  1174. );
  1175. } else if (
  1176. exception instanceof _pdfjsLib
  1177. .UnexpectedResponseException
  1178. ) {
  1179. loadingErrorMessage = _this2
  1180. .l10n.get(
  1181. 'unexpected_response_error',
  1182. null,
  1183. 'Unexpected server response.'
  1184. );
  1185. } else {
  1186. loadingErrorMessage = _this2
  1187. .l10n.get(
  1188. '加载错误',
  1189. null,
  1190. '加载PDF文件时发生错误,请检查源文件.'
  1191. );
  1192. }
  1193. return loadingErrorMessage.then(
  1194. function(msg) {
  1195. _this2.error(msg, {
  1196. message: message
  1197. });
  1198. throw new Error(
  1199. msg);
  1200. });
  1201. }));
  1202. case 16:
  1203. case "end":
  1204. return _context7.stop();
  1205. }
  1206. }
  1207. }, _callee7, this);
  1208. }));
  1209. function open(_x2, _x3) {
  1210. return _open.apply(this, arguments);
  1211. }
  1212. return open;
  1213. }(),
  1214. download: function download() {
  1215. var _this3 = this;
  1216. function downloadByUrl() {
  1217. downloadManager.downloadUrl(url, filename);
  1218. }
  1219. var url = this.baseUrl;
  1220. var filename = this.contentDispositionFilename || (0, _ui_utils.getPDFFileNameFromURL)(
  1221. this.url);
  1222. var downloadManager = this.downloadManager;
  1223. downloadManager.onerror = function(err) {
  1224. _this3.error("PDF failed to download: ".concat(err));
  1225. };
  1226. if (!this.pdfDocument || !this.downloadComplete) {
  1227. downloadByUrl();
  1228. return;
  1229. }
  1230. this.pdfDocument.getData().then(function(data) {
  1231. var blob = new Blob([data], {
  1232. type: 'application/pdf'
  1233. });
  1234. downloadManager.download(blob, url, filename);
  1235. })["catch"](downloadByUrl);
  1236. },
  1237. fallback: function fallback(featureId) {},
  1238. error: function error(message, moreInfo) {
  1239. var moreInfoText = [this.l10n.get('error_version_info', {
  1240. version: _pdfjsLib.version || '?',
  1241. build: _pdfjsLib.build || '?'
  1242. }, 'PDF.js v{{version}} (build: {{build}})')];
  1243. if (moreInfo) {
  1244. moreInfoText.push(this.l10n.get('error_message', {
  1245. message: moreInfo.message
  1246. }, 'Message: {{message}}'));
  1247. if (moreInfo.stack) {
  1248. moreInfoText.push(this.l10n.get('error_stack', {
  1249. stack: moreInfo.stack
  1250. }, 'Stack: {{stack}}'));
  1251. } else {
  1252. if (moreInfo.filename) {
  1253. moreInfoText.push(this.l10n.get('error_file', {
  1254. file: moreInfo.filename
  1255. }, 'File: {{file}}'));
  1256. }
  1257. if (moreInfo.lineNumber) {
  1258. moreInfoText.push(this.l10n.get('error_line', {
  1259. line: moreInfo.lineNumber
  1260. }, 'Line: {{line}}'));
  1261. }
  1262. }
  1263. }
  1264. var errorWrapperConfig = this.appConfig.errorWrapper;
  1265. var errorWrapper = errorWrapperConfig.container;
  1266. errorWrapper.removeAttribute('hidden');
  1267. var errorMessage = errorWrapperConfig.errorMessage;
  1268. errorMessage.textContent = message;
  1269. var closeButton = errorWrapperConfig.closeButton;
  1270. closeButton.onclick = function() {
  1271. errorWrapper.setAttribute('hidden', 'true');
  1272. };
  1273. var errorMoreInfo = errorWrapperConfig.errorMoreInfo;
  1274. var moreInfoButton = errorWrapperConfig.moreInfoButton;
  1275. var lessInfoButton = errorWrapperConfig.lessInfoButton;
  1276. moreInfoButton.onclick = function() {
  1277. errorMoreInfo.removeAttribute('hidden');
  1278. moreInfoButton.setAttribute('hidden', 'true');
  1279. lessInfoButton.removeAttribute('hidden');
  1280. errorMoreInfo.style.height = errorMoreInfo.scrollHeight + 'px';
  1281. };
  1282. lessInfoButton.onclick = function() {
  1283. errorMoreInfo.setAttribute('hidden', 'true');
  1284. moreInfoButton.removeAttribute('hidden');
  1285. lessInfoButton.setAttribute('hidden', 'true');
  1286. };
  1287. moreInfoButton.oncontextmenu = _ui_utils.noContextMenuHandler;
  1288. lessInfoButton.oncontextmenu = _ui_utils.noContextMenuHandler;
  1289. closeButton.oncontextmenu = _ui_utils.noContextMenuHandler;
  1290. moreInfoButton.removeAttribute('hidden');
  1291. lessInfoButton.setAttribute('hidden', 'true');
  1292. Promise.all(moreInfoText).then(function(parts) {
  1293. errorMoreInfo.value = parts.join('\n');
  1294. });
  1295. },
  1296. progress: function progress(level) {
  1297. var _this4 = this;
  1298. if (this.downloadComplete) {
  1299. return;
  1300. }
  1301. var percent = Math.round(level * 100);
  1302. if (percent > this.loadingBar.percent || isNaN(percent)) {
  1303. this.loadingBar.percent = percent;
  1304. var disableAutoFetch = this.pdfDocument ? this.pdfDocument.loadingParams[
  1305. 'disableAutoFetch'] : _app_options.AppOptions.get('disableAutoFetch');
  1306. if (disableAutoFetch && percent) {
  1307. if (this.disableAutoFetchLoadingBarTimeout) {
  1308. clearTimeout(this.disableAutoFetchLoadingBarTimeout);
  1309. this.disableAutoFetchLoadingBarTimeout = null;
  1310. }
  1311. this.loadingBar.show();
  1312. this.disableAutoFetchLoadingBarTimeout = setTimeout(function() {
  1313. _this4.loadingBar.hide();
  1314. _this4.disableAutoFetchLoadingBarTimeout = null;
  1315. }, DISABLE_AUTO_FETCH_LOADING_BAR_TIMEOUT);
  1316. }
  1317. }
  1318. },
  1319. load: function load(pdfDocument) {
  1320. var _this5 = this;
  1321. this.pdfDocument = pdfDocument;
  1322. pdfDocument.getDownloadInfo().then(function() {
  1323. _this5.downloadComplete = true;
  1324. _this5.loadingBar.hide();
  1325. firstPagePromise.then(function() {
  1326. _this5.eventBus.dispatch('documentloaded', {
  1327. source: _this5
  1328. });
  1329. });
  1330. });
  1331. var pageLayoutPromise = pdfDocument.getPageLayout()["catch"](function() {});
  1332. var pageModePromise = pdfDocument.getPageMode()["catch"](function() {});
  1333. var openActionDestPromise = pdfDocument.getOpenActionDestination()["catch"](
  1334. function() {});
  1335. this.toolbar.setPagesCount(pdfDocument.numPages, false);
  1336. this.secondaryToolbar.setPagesCount(pdfDocument.numPages);
  1337. var store = this.store = new _view_history.ViewHistory(pdfDocument.fingerprint);
  1338. var baseDocumentUrl;
  1339. baseDocumentUrl = null;
  1340. this.pdfLinkService.setDocument(pdfDocument, baseDocumentUrl);
  1341. this.pdfDocumentProperties.setDocument(pdfDocument, this.url);
  1342. var pdfViewer = this.pdfViewer;
  1343. pdfViewer.setDocument(pdfDocument);
  1344. var firstPagePromise = pdfViewer.firstPagePromise;
  1345. var pagesPromise = pdfViewer.pagesPromise;
  1346. var onePageRendered = pdfViewer.onePageRendered;
  1347. var pdfThumbnailViewer = this.pdfThumbnailViewer;
  1348. pdfThumbnailViewer.setDocument(pdfDocument);
  1349. firstPagePromise.then(function(pdfPage) {
  1350. _this5.loadingBar.setWidth(_this5.appConfig.viewerContainer);
  1351. var storePromise = store.getMultiple({
  1352. page: null,
  1353. zoom: _ui_utils.DEFAULT_SCALE_VALUE,
  1354. scrollLeft: '0',
  1355. scrollTop: '0',
  1356. rotation: null,
  1357. sidebarView: _pdf_sidebar.SidebarView.UNKNOWN,
  1358. scrollMode: _ui_utils.ScrollMode.UNKNOWN,
  1359. spreadMode: _ui_utils.SpreadMode.UNKNOWN
  1360. })["catch"](function() {});
  1361. Promise.all([_ui_utils.animationStarted, storePromise, pageLayoutPromise,
  1362. pageModePromise, openActionDestPromise
  1363. ]).then(
  1364. /*#__PURE__*/
  1365. function() {
  1366. var _ref3 = _asyncToGenerator(
  1367. /*#__PURE__*/
  1368. _regenerator["default"].mark(function _callee8(_ref2) {
  1369. var _ref4, timeStamp, _ref4$, values,
  1370. pageLayout, pageMode, openActionDest,
  1371. viewOnLoad, initialBookmark, zoom, hash,
  1372. rotation, sidebarView, scrollMode,
  1373. spreadMode;
  1374. return _regenerator["default"].wrap(
  1375. function _callee8$(_context8) {
  1376. while (1) {
  1377. switch (_context8.prev =
  1378. _context8.next) {
  1379. case 0:
  1380. _ref4 = _slicedToArray(
  1381. _ref2, 5),
  1382. timeStamp = _ref4[
  1383. 0], _ref4$ =
  1384. _ref4[
  1385. 1], values =
  1386. _ref4$ === void 0 ?
  1387. {} : _ref4$,
  1388. pageLayout = _ref4[
  1389. 2], pageMode =
  1390. _ref4[3],
  1391. openActionDest =
  1392. _ref4[4];
  1393. viewOnLoad =
  1394. _app_options
  1395. .AppOptions.get(
  1396. 'viewOnLoad');
  1397. _this5
  1398. ._initializePdfHistory({
  1399. fingerprint: pdfDocument
  1400. .fingerprint,
  1401. viewOnLoad: viewOnLoad,
  1402. initialDest: openActionDest
  1403. });
  1404. initialBookmark = _this5
  1405. .initialBookmark;
  1406. zoom = _app_options
  1407. .AppOptions.get(
  1408. 'defaultZoomValue'
  1409. );
  1410. hash = zoom ? "zoom="
  1411. .concat(zoom) :
  1412. null;
  1413. rotation = null;
  1414. sidebarView =
  1415. _app_options
  1416. .AppOptions.get(
  1417. 'sidebarViewOnLoad'
  1418. );
  1419. scrollMode =
  1420. _app_options
  1421. .AppOptions.get(
  1422. 'scrollModeOnLoad'
  1423. );
  1424. spreadMode =
  1425. _app_options
  1426. .AppOptions.get(
  1427. 'spreadModeOnLoad'
  1428. );
  1429. if (values.page &&
  1430. viewOnLoad !==
  1431. ViewOnLoad.INITIAL
  1432. ) {
  1433. hash = "page="
  1434. .concat(values
  1435. .page,
  1436. "&zoom=")
  1437. .concat(zoom ||
  1438. values.zoom,
  1439. ",") + ""
  1440. .concat(values
  1441. .scrollLeft,
  1442. ",").concat(
  1443. values
  1444. .scrollTop);
  1445. rotation = parseInt(
  1446. values
  1447. .rotation,
  1448. 10);
  1449. if (sidebarView ===
  1450. _pdf_sidebar
  1451. .SidebarView
  1452. .UNKNOWN) {
  1453. sidebarView =
  1454. values
  1455. .sidebarView |
  1456. 0;
  1457. }
  1458. if (scrollMode ===
  1459. _ui_utils
  1460. .ScrollMode
  1461. .UNKNOWN) {
  1462. scrollMode =
  1463. values
  1464. .scrollMode |
  1465. 0;
  1466. }
  1467. if (spreadMode ===
  1468. _ui_utils
  1469. .SpreadMode
  1470. .UNKNOWN) {
  1471. spreadMode =
  1472. values
  1473. .spreadMode |
  1474. 0;
  1475. }
  1476. }
  1477. if (pageMode &&
  1478. sidebarView ===
  1479. _pdf_sidebar
  1480. .SidebarView.UNKNOWN
  1481. ) {
  1482. sidebarView =
  1483. apiPageModeToSidebarView(
  1484. pageMode);
  1485. }
  1486. if (pageLayout &&
  1487. spreadMode ===
  1488. _ui_utils.SpreadMode
  1489. .UNKNOWN) {
  1490. spreadMode =
  1491. apiPageLayoutToSpreadMode(
  1492. pageLayout);
  1493. }
  1494. _this5.setInitialView(
  1495. hash, {
  1496. rotation: rotation,
  1497. sidebarView: sidebarView,
  1498. scrollMode: scrollMode,
  1499. spreadMode: spreadMode
  1500. });
  1501. _this5.eventBus
  1502. .dispatch(
  1503. 'documentinit', {
  1504. source: _this5
  1505. });
  1506. if (!_this5
  1507. .isViewerEmbedded) {
  1508. pdfViewer.focus();
  1509. }
  1510. _context8.next = 18;
  1511. return Promise.race([
  1512. pagesPromise,
  1513. new Promise(
  1514. function(
  1515. resolve
  1516. ) {
  1517. setTimeout
  1518. (resolve,
  1519. FORCE_PAGES_LOADED_TIMEOUT
  1520. );
  1521. })
  1522. ]);
  1523. case 18:
  1524. if (!(!initialBookmark &&
  1525. !hash)) {
  1526. _context8.next = 20;
  1527. break;
  1528. }
  1529. return _context8.abrupt(
  1530. "return");
  1531. case 20:
  1532. if (!pdfViewer
  1533. .hasEqualPageSizes
  1534. ) {
  1535. _context8.next = 22;
  1536. break;
  1537. }
  1538. return _context8.abrupt(
  1539. "return");
  1540. case 22:
  1541. _this5.initialBookmark =
  1542. initialBookmark;
  1543. pdfViewer
  1544. .currentScaleValue =
  1545. pdfViewer
  1546. .currentScaleValue;
  1547. _this5.setInitialView(
  1548. hash);
  1549. case 25:
  1550. case "end":
  1551. return _context8.stop();
  1552. }
  1553. }
  1554. }, _callee8);
  1555. }));
  1556. return function(_x4) {
  1557. return _ref3.apply(this, arguments);
  1558. };
  1559. }())["catch"](function() {
  1560. _this5.setInitialView();
  1561. }).then(function() {
  1562. pdfViewer.update();
  1563. });
  1564. });
  1565. pdfDocument.getPageLabels().then(function(labels) {
  1566. if (!labels || _app_options.AppOptions.get('disablePageLabels')) {
  1567. return;
  1568. }
  1569. var i = 0,
  1570. numLabels = labels.length;
  1571. if (numLabels !== _this5.pagesCount) {
  1572. console.error('The number of Page Labels does not match ' +
  1573. 'the number of pages in the document.');
  1574. return;
  1575. }
  1576. while (i < numLabels && labels[i] === (i + 1).toString()) {
  1577. i++;
  1578. }
  1579. if (i === numLabels) {
  1580. return;
  1581. }
  1582. pdfViewer.setPageLabels(labels);
  1583. pdfThumbnailViewer.setPageLabels(labels);
  1584. _this5.toolbar.setPagesCount(pdfDocument.numPages, true);
  1585. _this5.toolbar.setPageNumber(pdfViewer.currentPageNumber, pdfViewer
  1586. .currentPageLabel);
  1587. });
  1588. pagesPromise.then(function() {
  1589. if (!_this5.supportsPrinting) {
  1590. return;
  1591. }
  1592. pdfDocument.getJavaScript().then(function(javaScript) {
  1593. if (!javaScript) {
  1594. return;
  1595. }
  1596. javaScript.some(function(js) {
  1597. if (!js) {
  1598. return false;
  1599. }
  1600. console.warn(
  1601. 'Warning: JavaScript is not supported');
  1602. _this5.fallback(_pdfjsLib.UNSUPPORTED_FEATURES
  1603. .javaScript);
  1604. return true;
  1605. });
  1606. var regex = /\bprint\s*\(/;
  1607. for (var i = 0, ii = javaScript.length; i < ii; i++) {
  1608. var js = javaScript[i];
  1609. if (js && regex.test(js)) {
  1610. setTimeout(function() {
  1611. window.print();
  1612. });
  1613. return;
  1614. }
  1615. }
  1616. });
  1617. });
  1618. onePageRendered.then(function() {
  1619. pdfDocument.getOutline().then(function(outline) {
  1620. _this5.pdfOutlineViewer.render({
  1621. outline: outline
  1622. });
  1623. });
  1624. pdfDocument.getAttachments().then(function(attachments) {
  1625. _this5.pdfAttachmentViewer.render({
  1626. attachments: attachments
  1627. });
  1628. });
  1629. });
  1630. pdfDocument.getMetadata().then(function(_ref5) {
  1631. var info = _ref5.info,
  1632. metadata = _ref5.metadata,
  1633. contentDispositionFilename = _ref5.contentDispositionFilename;
  1634. _this5.documentInfo = info;
  1635. _this5.metadata = metadata;
  1636. _this5.contentDispositionFilename = contentDispositionFilename;
  1637. console.log('PDF ' + pdfDocument.fingerprint + ' [' + info
  1638. .PDFFormatVersion + ' ' + (info.Producer || '-').trim() + ' / ' + (
  1639. info.Creator || '-').trim() + ']' + ' (PDF.js: ' + (_pdfjsLib
  1640. .version || '-') + (_app_options.AppOptions.get('enableWebGL') ?
  1641. ' [WebGL]' : '') + ')');
  1642. var pdfTitle;
  1643. if (metadata && metadata.has('dc:title')) {
  1644. var title = metadata.get('dc:title');
  1645. if (title !== 'Untitled') {
  1646. pdfTitle = title;
  1647. }
  1648. }
  1649. if (!pdfTitle && info && info['Title']) {
  1650. pdfTitle = info['Title'];
  1651. }
  1652. if (pdfTitle) {
  1653. _this5.setTitle("".concat(pdfTitle, " - ").concat(
  1654. contentDispositionFilename || document.title));
  1655. } else if (contentDispositionFilename) {
  1656. _this5.setTitle(contentDispositionFilename);
  1657. }
  1658. if (info.IsAcroFormPresent) {
  1659. console.warn('Warning: AcroForm/XFA is not supported');
  1660. _this5.fallback(_pdfjsLib.UNSUPPORTED_FEATURES.forms);
  1661. }
  1662. });
  1663. },
  1664. _initializePdfHistory: function _initializePdfHistory(_ref6) {
  1665. var fingerprint = _ref6.fingerprint,
  1666. viewOnLoad = _ref6.viewOnLoad,
  1667. _ref6$initialDest = _ref6.initialDest,
  1668. initialDest = _ref6$initialDest === void 0 ? null : _ref6$initialDest;
  1669. if (_app_options.AppOptions.get('disableHistory') || this.isViewerEmbedded) {
  1670. return;
  1671. }
  1672. this.pdfHistory.initialize({
  1673. fingerprint: fingerprint,
  1674. resetHistory: viewOnLoad === ViewOnLoad.INITIAL,
  1675. updateUrl: _app_options.AppOptions.get('historyUpdateUrl')
  1676. });
  1677. if (this.pdfHistory.initialBookmark) {
  1678. this.initialBookmark = this.pdfHistory.initialBookmark;
  1679. this.initialRotation = this.pdfHistory.initialRotation;
  1680. }
  1681. if (initialDest && !this.initialBookmark && viewOnLoad === ViewOnLoad.UNKNOWN) {
  1682. this.initialBookmark = JSON.stringify(initialDest);
  1683. this.pdfHistory.push({
  1684. explicitDest: initialDest,
  1685. pageNumber: null
  1686. });
  1687. }
  1688. },
  1689. setInitialView: function setInitialView(storedHash) {
  1690. //=========自定义加载到指定页面
  1691. var c_url = window.location.href;
  1692. //获取参数
  1693. if (c_url.indexOf("&") && c_url.indexOf("=")) {
  1694. undefined
  1695. var c_urlArray = {}
  1696. var c_val = c_url.split('?')[1];
  1697. var c_valArray = c_val.split('&');
  1698. for (let i = 0; i < c_valArray.length; i++) {
  1699. undefined
  1700. let c_key = c_valArray[i].split('=')[0];
  1701. let c_value = c_valArray[i].split('=')[1];
  1702. c_urlArray[c_key] = c_value;
  1703. }
  1704. //跳转至指定页码
  1705. if (c_urlArray['page']) {
  1706. undefined
  1707. document.getElementById('pageNumber').value = c_urlArray['page'] * 1;
  1708. this.pdfViewer.currentPageNumber = c_urlArray['page'] * 1;
  1709. console.log('this.pdfViewer.currentPageNumber==', this.pdfViewer
  1710. .currentPageNumber)
  1711. }
  1712. }
  1713. //=================
  1714. var _this6 = this;
  1715. var _ref7 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
  1716. rotation = _ref7.rotation,
  1717. sidebarView = _ref7.sidebarView,
  1718. scrollMode = _ref7.scrollMode,
  1719. spreadMode = _ref7.spreadMode;
  1720. var setRotation = function setRotation(angle) {
  1721. if ((0, _ui_utils.isValidRotation)(angle)) {
  1722. _this6.pdfViewer.pagesRotation = angle;
  1723. }
  1724. };
  1725. var setViewerModes = function setViewerModes(scroll, spread) {
  1726. if ((0, _ui_utils.isValidScrollMode)(scroll)) {
  1727. _this6.pdfViewer.scrollMode = scroll;
  1728. }
  1729. if ((0, _ui_utils.isValidSpreadMode)(spread)) {
  1730. _this6.pdfViewer.spreadMode = spread;
  1731. }
  1732. };
  1733. this.isInitialViewSet = true;
  1734. this.pdfSidebar.setInitialView(sidebarView);
  1735. setViewerModes(scrollMode, spreadMode);
  1736. if (this.initialBookmark) {
  1737. setRotation(this.initialRotation);
  1738. delete this.initialRotation;
  1739. this.pdfLinkService.setHash(this.initialBookmark);
  1740. this.initialBookmark = null;
  1741. } else if (storedHash) {
  1742. setRotation(rotation);
  1743. this.pdfLinkService.setHash(storedHash);
  1744. }
  1745. this.toolbar.setPageNumber(this.pdfViewer.currentPageNumber, this.pdfViewer
  1746. .currentPageLabel);
  1747. this.secondaryToolbar.setPageNumber(this.pdfViewer.currentPageNumber);
  1748. if (!this.pdfViewer.currentScaleValue) {
  1749. this.pdfViewer.currentScaleValue = _ui_utils.DEFAULT_SCALE_VALUE;
  1750. }
  1751. },
  1752. cleanup: function cleanup() {
  1753. if (!this.pdfDocument) {
  1754. return;
  1755. }
  1756. this.pdfViewer.cleanup();
  1757. this.pdfThumbnailViewer.cleanup();
  1758. if (this.pdfViewer.renderer !== _ui_utils.RendererType.SVG) {
  1759. this.pdfDocument.cleanup();
  1760. }
  1761. },
  1762. forceRendering: function forceRendering() {
  1763. this.pdfRenderingQueue.printing = this.printing;
  1764. this.pdfRenderingQueue.isThumbnailViewEnabled = this.pdfSidebar.isThumbnailViewVisible;
  1765. this.pdfRenderingQueue.renderHighestPriority();
  1766. },
  1767. beforePrint: function beforePrint() {
  1768. var _this7 = this;
  1769. if (this.printService) {
  1770. return;
  1771. }
  1772. if (!this.supportsPrinting) {
  1773. this.l10n.get('printing_not_supported', null,
  1774. 'Warning: Printing is not fully supported by ' + 'this browser.').then(
  1775. function(printMessage) {
  1776. _this7.error(printMessage);
  1777. });
  1778. return;
  1779. }
  1780. if (!this.pdfViewer.pageViewsReady) {
  1781. this.l10n.get('printing_not_ready', null,
  1782. 'Warning: The PDF is not fully loaded for printing.').then(function(
  1783. notReadyMessage) {
  1784. window.alert(notReadyMessage);
  1785. });
  1786. return;
  1787. }
  1788. var pagesOverview = this.pdfViewer.getPagesOverview();
  1789. var printContainer = this.appConfig.printContainer;
  1790. var printService = PDFPrintServiceFactory.instance.createPrintService(this.pdfDocument,
  1791. pagesOverview, printContainer, this.l10n);
  1792. this.printService = printService;
  1793. this.forceRendering();
  1794. printService.layout();
  1795. },
  1796. afterPrint: function afterPrint() {
  1797. if (this.printService) {
  1798. this.printService.destroy();
  1799. this.printService = null;
  1800. }
  1801. this.forceRendering();
  1802. },
  1803. rotatePages: function rotatePages(delta) {
  1804. if (!this.pdfDocument) {
  1805. return;
  1806. }
  1807. var newRotation = (this.pdfViewer.pagesRotation + 360 + delta) % 360;
  1808. this.pdfViewer.pagesRotation = newRotation;
  1809. },
  1810. requestPresentationMode: function requestPresentationMode() {
  1811. if (!this.pdfPresentationMode) {
  1812. return;
  1813. }
  1814. this.pdfPresentationMode.request();
  1815. },
  1816. bindEvents: function bindEvents() {
  1817. var eventBus = this.eventBus,
  1818. _boundEvents = this._boundEvents;
  1819. _boundEvents.beforePrint = this.beforePrint.bind(this);
  1820. _boundEvents.afterPrint = this.afterPrint.bind(this);
  1821. eventBus.on('resize', webViewerResize);
  1822. eventBus.on('hashchange', webViewerHashchange);
  1823. eventBus.on('beforeprint', _boundEvents.beforePrint);
  1824. eventBus.on('afterprint', _boundEvents.afterPrint);
  1825. eventBus.on('pagerendered', webViewerPageRendered);
  1826. eventBus.on('textlayerrendered', webViewerTextLayerRendered);
  1827. eventBus.on('updateviewarea', webViewerUpdateViewarea);
  1828. eventBus.on('pagechanging', webViewerPageChanging);
  1829. eventBus.on('scalechanging', webViewerScaleChanging);
  1830. eventBus.on('rotationchanging', webViewerRotationChanging);
  1831. eventBus.on('sidebarviewchanged', webViewerSidebarViewChanged);
  1832. eventBus.on('pagemode', webViewerPageMode);
  1833. eventBus.on('namedaction', webViewerNamedAction);
  1834. eventBus.on('presentationmodechanged', webViewerPresentationModeChanged);
  1835. eventBus.on('presentationmode', webViewerPresentationMode);
  1836. eventBus.on('openfile', webViewerOpenFile);
  1837. eventBus.on('print', webViewerPrint);
  1838. eventBus.on('download', webViewerDownload);
  1839. eventBus.on('firstpage', webViewerFirstPage);
  1840. eventBus.on('lastpage', webViewerLastPage);
  1841. eventBus.on('nextpage', webViewerNextPage);
  1842. eventBus.on('previouspage', webViewerPreviousPage);
  1843. eventBus.on('zoomin', webViewerZoomIn);
  1844. eventBus.on('zoomout', webViewerZoomOut);
  1845. eventBus.on('zoomreset', webViewerZoomReset);
  1846. eventBus.on('pagenumberchanged', webViewerPageNumberChanged);
  1847. eventBus.on('scalechanged', webViewerScaleChanged);
  1848. eventBus.on('rotatecw', webViewerRotateCw);
  1849. eventBus.on('rotateccw', webViewerRotateCcw);
  1850. eventBus.on('switchscrollmode', webViewerSwitchScrollMode);
  1851. eventBus.on('scrollmodechanged', webViewerScrollModeChanged);
  1852. eventBus.on('switchspreadmode', webViewerSwitchSpreadMode);
  1853. eventBus.on('spreadmodechanged', webViewerSpreadModeChanged);
  1854. eventBus.on('documentproperties', webViewerDocumentProperties);
  1855. eventBus.on('find', webViewerFind);
  1856. eventBus.on('findfromurlhash', webViewerFindFromUrlHash);
  1857. eventBus.on('updatefindmatchescount', webViewerUpdateFindMatchesCount);
  1858. eventBus.on('updatefindcontrolstate', webViewerUpdateFindControlState);
  1859. eventBus.on('fileinputchange', webViewerFileInputChange);
  1860. },
  1861. bindWindowEvents: function bindWindowEvents() {
  1862. var eventBus = this.eventBus,
  1863. _boundEvents = this._boundEvents;
  1864. _boundEvents.windowResize = function() {
  1865. eventBus.dispatch('resize', {
  1866. source: window
  1867. });
  1868. };
  1869. _boundEvents.windowHashChange = function() {
  1870. eventBus.dispatch('hashchange', {
  1871. source: window,
  1872. hash: document.location.hash.substring(1)
  1873. });
  1874. };
  1875. _boundEvents.windowBeforePrint = function() {
  1876. eventBus.dispatch('beforeprint', {
  1877. source: window
  1878. });
  1879. };
  1880. _boundEvents.windowAfterPrint = function() {
  1881. eventBus.dispatch('afterprint', {
  1882. source: window
  1883. });
  1884. };
  1885. window.addEventListener('visibilitychange', webViewerVisibilityChange);
  1886. window.addEventListener('wheel', webViewerWheel, {
  1887. passive: false
  1888. });
  1889. window.addEventListener('click', webViewerClick);
  1890. window.addEventListener('keydown', webViewerKeyDown);
  1891. window.addEventListener('resize', _boundEvents.windowResize);
  1892. window.addEventListener('hashchange', _boundEvents.windowHashChange);
  1893. window.addEventListener('beforeprint', _boundEvents.windowBeforePrint);
  1894. window.addEventListener('afterprint', _boundEvents.windowAfterPrint);
  1895. },
  1896. unbindEvents: function unbindEvents() {
  1897. var eventBus = this.eventBus,
  1898. _boundEvents = this._boundEvents;
  1899. eventBus.off('resize', webViewerResize);
  1900. eventBus.off('hashchange', webViewerHashchange);
  1901. eventBus.off('beforeprint', _boundEvents.beforePrint);
  1902. eventBus.off('afterprint', _boundEvents.afterPrint);
  1903. eventBus.off('pagerendered', webViewerPageRendered);
  1904. eventBus.off('textlayerrendered', webViewerTextLayerRendered);
  1905. eventBus.off('updateviewarea', webViewerUpdateViewarea);
  1906. eventBus.off('pagechanging', webViewerPageChanging);
  1907. eventBus.off('scalechanging', webViewerScaleChanging);
  1908. eventBus.off('rotationchanging', webViewerRotationChanging);
  1909. eventBus.off('sidebarviewchanged', webViewerSidebarViewChanged);
  1910. eventBus.off('pagemode', webViewerPageMode);
  1911. eventBus.off('namedaction', webViewerNamedAction);
  1912. eventBus.off('presentationmodechanged', webViewerPresentationModeChanged);
  1913. eventBus.off('presentationmode', webViewerPresentationMode);
  1914. eventBus.off('openfile', webViewerOpenFile);
  1915. eventBus.off('print', webViewerPrint);
  1916. eventBus.off('download', webViewerDownload);
  1917. eventBus.off('firstpage', webViewerFirstPage);
  1918. eventBus.off('lastpage', webViewerLastPage);
  1919. eventBus.off('nextpage', webViewerNextPage);
  1920. eventBus.off('previouspage', webViewerPreviousPage);
  1921. eventBus.off('zoomin', webViewerZoomIn);
  1922. eventBus.off('zoomout', webViewerZoomOut);
  1923. eventBus.off('zoomreset', webViewerZoomReset);
  1924. eventBus.off('pagenumberchanged', webViewerPageNumberChanged);
  1925. eventBus.off('scalechanged', webViewerScaleChanged);
  1926. eventBus.off('rotatecw', webViewerRotateCw);
  1927. eventBus.off('rotateccw', webViewerRotateCcw);
  1928. eventBus.off('switchscrollmode', webViewerSwitchScrollMode);
  1929. eventBus.off('scrollmodechanged', webViewerScrollModeChanged);
  1930. eventBus.off('switchspreadmode', webViewerSwitchSpreadMode);
  1931. eventBus.off('spreadmodechanged', webViewerSpreadModeChanged);
  1932. eventBus.off('documentproperties', webViewerDocumentProperties);
  1933. eventBus.off('find', webViewerFind);
  1934. eventBus.off('findfromurlhash', webViewerFindFromUrlHash);
  1935. eventBus.off('updatefindmatchescount', webViewerUpdateFindMatchesCount);
  1936. eventBus.off('updatefindcontrolstate', webViewerUpdateFindControlState);
  1937. eventBus.off('fileinputchange', webViewerFileInputChange);
  1938. _boundEvents.beforePrint = null;
  1939. _boundEvents.afterPrint = null;
  1940. },
  1941. unbindWindowEvents: function unbindWindowEvents() {
  1942. var _boundEvents = this._boundEvents;
  1943. window.removeEventListener('visibilitychange', webViewerVisibilityChange);
  1944. window.removeEventListener('wheel', webViewerWheel);
  1945. window.removeEventListener('click', webViewerClick);
  1946. window.removeEventListener('keydown', webViewerKeyDown);
  1947. window.removeEventListener('resize', _boundEvents.windowResize);
  1948. window.removeEventListener('hashchange', _boundEvents.windowHashChange);
  1949. window.removeEventListener('beforeprint', _boundEvents.windowBeforePrint);
  1950. window.removeEventListener('afterprint', _boundEvents.windowAfterPrint);
  1951. _boundEvents.windowResize = null;
  1952. _boundEvents.windowHashChange = null;
  1953. _boundEvents.windowBeforePrint = null;
  1954. _boundEvents.windowAfterPrint = null;
  1955. }
  1956. };
  1957. exports.PDFViewerApplication = PDFViewerApplication;
  1958. var validateFileURL; {
  1959. var HOSTED_VIEWER_ORIGINS = ['null', 'http://mozilla.github.io', 'https://mozilla.github.io'];
  1960. validateFileURL = function validateFileURL(file) {
  1961. if (file === undefined) {
  1962. return;
  1963. }
  1964. try {
  1965. var viewerOrigin = new URL(window.location.href).origin || 'null';
  1966. if (HOSTED_VIEWER_ORIGINS.includes(viewerOrigin)) {
  1967. return;
  1968. }
  1969. var _ref8 = new URL(file, window.location.href),
  1970. origin = _ref8.origin,
  1971. protocol = _ref8.protocol;
  1972. // if (origin !== viewerOrigin && protocol !== 'blob:') {
  1973. // throw new Error('file origin does not match viewer\'s');
  1974. // }
  1975. } catch (ex) {
  1976. var message = ex && ex.message;
  1977. PDFViewerApplication.l10n.get('loading_error', null,
  1978. 'An error occurred while loading the PDF.').then(function(loadingErrorMessage) {
  1979. PDFViewerApplication.error(loadingErrorMessage, {
  1980. message: message
  1981. });
  1982. });
  1983. throw ex;
  1984. }
  1985. };
  1986. }
  1987. function loadFakeWorker() {
  1988. if (!_pdfjsLib.GlobalWorkerOptions.workerSrc) {
  1989. _pdfjsLib.GlobalWorkerOptions.workerSrc = _app_options.AppOptions.get('workerSrc');
  1990. }
  1991. return (0, _pdfjsLib.loadScript)(_pdfjsLib.PDFWorker.getWorkerSrc());
  1992. }
  1993. function loadAndEnablePDFBug(enabledTabs) {
  1994. var appConfig = PDFViewerApplication.appConfig;
  1995. return (0, _pdfjsLib.loadScript)(appConfig.debuggerScriptPath).then(function() {
  1996. PDFBug.enable(enabledTabs);
  1997. PDFBug.init({
  1998. OPS: _pdfjsLib.OPS,
  1999. createObjectURL: _pdfjsLib.createObjectURL
  2000. }, appConfig.mainContainer);
  2001. });
  2002. }
  2003. function webViewerInitialized() {
  2004. var appConfig = PDFViewerApplication.appConfig;
  2005. var file;
  2006. var queryString = document.location.search.substring(1);
  2007. var params = (0, _ui_utils.parseQueryString)(queryString);
  2008. file = 'file' in params ? params.file : _app_options.AppOptions.get('defaultUrl');
  2009. validateFileURL(file);
  2010. var fileInput = document.createElement('input');
  2011. fileInput.id = appConfig.openFileInputName;
  2012. fileInput.className = 'fileInput';
  2013. fileInput.setAttribute('type', 'file');
  2014. fileInput.oncontextmenu = _ui_utils.noContextMenuHandler;
  2015. document.body.appendChild(fileInput);
  2016. if (!window.File || !window.FileReader || !window.FileList || !window.Blob) {
  2017. appConfig.toolbar.openFile.setAttribute('hidden', 'true');
  2018. appConfig.secondaryToolbar.openFileButton.setAttribute('hidden', 'true');
  2019. } else {
  2020. fileInput.value = null;
  2021. }
  2022. fileInput.addEventListener('change', function(evt) {
  2023. var files = evt.target.files;
  2024. if (!files || files.length === 0) {
  2025. return;
  2026. }
  2027. PDFViewerApplication.eventBus.dispatch('fileinputchange', {
  2028. source: this,
  2029. fileInput: evt.target
  2030. });
  2031. });
  2032. appConfig.mainContainer.addEventListener('dragover', function(evt) {
  2033. evt.preventDefault();
  2034. evt.dataTransfer.dropEffect = 'move';
  2035. });
  2036. appConfig.mainContainer.addEventListener('drop', function(evt) {
  2037. evt.preventDefault();
  2038. var files = evt.dataTransfer.files;
  2039. if (!files || files.length === 0) {
  2040. return;
  2041. }
  2042. PDFViewerApplication.eventBus.dispatch('fileinputchange', {
  2043. source: this,
  2044. fileInput: evt.dataTransfer
  2045. });
  2046. });
  2047. if (!PDFViewerApplication.supportsPrinting) {
  2048. appConfig.toolbar.print.classList.add('hidden');
  2049. appConfig.secondaryToolbar.printButton.classList.add('hidden');
  2050. }
  2051. if (!PDFViewerApplication.supportsFullscreen) {
  2052. appConfig.toolbar.presentationModeButton.classList.add('hidden');
  2053. appConfig.secondaryToolbar.presentationModeButton.classList.add('hidden');
  2054. }
  2055. if (PDFViewerApplication.supportsIntegratedFind) {
  2056. appConfig.toolbar.viewFind.classList.add('hidden');
  2057. }
  2058. appConfig.mainContainer.addEventListener('transitionend', function(evt) {
  2059. if (evt.target === this) {
  2060. PDFViewerApplication.eventBus.dispatch('resize', {
  2061. source: this
  2062. });
  2063. }
  2064. }, true);
  2065. try {
  2066. webViewerOpenFileViaURL(file);
  2067. } catch (reason) {
  2068. PDFViewerApplication.l10n.get('loading_error', null, 'An error occurred while loading the PDF.')
  2069. .then(function(msg) {
  2070. PDFViewerApplication.error(msg, reason);
  2071. });
  2072. }
  2073. }
  2074. var webViewerOpenFileViaURL; {
  2075. webViewerOpenFileViaURL = function webViewerOpenFileViaURL(file) {
  2076. if (file && file.lastIndexOf('file:', 0) === 0) {
  2077. PDFViewerApplication.setTitleUsingUrl(file);
  2078. var xhr = new XMLHttpRequest();
  2079. xhr.onload = function() {
  2080. PDFViewerApplication.open(new Uint8Array(xhr.response));
  2081. };
  2082. xhr.open('GET', file);
  2083. xhr.responseType = 'arraybuffer';
  2084. xhr.send();
  2085. return;
  2086. }
  2087. if (file) {
  2088. PDFViewerApplication.open(file);
  2089. }
  2090. };
  2091. }
  2092. function webViewerPageRendered(evt) {
  2093. var pageNumber = evt.pageNumber;
  2094. var pageIndex = pageNumber - 1;
  2095. var pageView = PDFViewerApplication.pdfViewer.getPageView(pageIndex);
  2096. if (pageNumber === PDFViewerApplication.page) {
  2097. PDFViewerApplication.toolbar.updateLoadingIndicatorState(false);
  2098. }
  2099. if (!pageView) {
  2100. return;
  2101. }
  2102. if (PDFViewerApplication.pdfSidebar.isThumbnailViewVisible) {
  2103. var thumbnailView = PDFViewerApplication.pdfThumbnailViewer.getThumbnail(pageIndex);
  2104. thumbnailView.setImage(pageView);
  2105. }
  2106. if (typeof Stats !== 'undefined' && Stats.enabled && pageView.stats) {
  2107. Stats.add(pageNumber, pageView.stats);
  2108. }
  2109. if (pageView.error) {
  2110. PDFViewerApplication.l10n.get('rendering_error', null,
  2111. 'An error occurred while rendering the page.').then(function(msg) {
  2112. PDFViewerApplication.error(msg, pageView.error);
  2113. });
  2114. }
  2115. }
  2116. function webViewerTextLayerRendered(evt) {}
  2117. function webViewerPageMode(evt) {
  2118. var mode = evt.mode,
  2119. view;
  2120. switch (mode) {
  2121. case 'thumbs':
  2122. view = _pdf_sidebar.SidebarView.THUMBS;
  2123. break;
  2124. case 'bookmarks':
  2125. case 'outline':
  2126. view = _pdf_sidebar.SidebarView.OUTLINE;
  2127. break;
  2128. case 'attachments':
  2129. view = _pdf_sidebar.SidebarView.ATTACHMENTS;
  2130. break;
  2131. case 'none':
  2132. view = _pdf_sidebar.SidebarView.NONE;
  2133. break;
  2134. default:
  2135. console.error('Invalid "pagemode" hash parameter: ' + mode);
  2136. return;
  2137. }
  2138. PDFViewerApplication.pdfSidebar.switchView(view, true);
  2139. }
  2140. function webViewerNamedAction(evt) {
  2141. var action = evt.action;
  2142. switch (action) {
  2143. case 'GoToPage':
  2144. PDFViewerApplication.appConfig.toolbar.pageNumber.select();
  2145. break;
  2146. case 'Find':
  2147. if (!PDFViewerApplication.supportsIntegratedFind) {
  2148. PDFViewerApplication.findBar.toggle();
  2149. }
  2150. break;
  2151. }
  2152. }
  2153. function webViewerPresentationModeChanged(evt) {
  2154. var active = evt.active,
  2155. switchInProgress = evt.switchInProgress;
  2156. PDFViewerApplication.pdfViewer.presentationModeState = switchInProgress ? _ui_utils
  2157. .PresentationModeState.CHANGING : active ? _ui_utils.PresentationModeState.FULLSCREEN :
  2158. _ui_utils.PresentationModeState.NORMAL;
  2159. }
  2160. function webViewerSidebarViewChanged(evt) {
  2161. PDFViewerApplication.pdfRenderingQueue.isThumbnailViewEnabled = PDFViewerApplication.pdfSidebar
  2162. .isThumbnailViewVisible;
  2163. var store = PDFViewerApplication.store;
  2164. if (store && PDFViewerApplication.isInitialViewSet) {
  2165. store.set('sidebarView', evt.view)["catch"](function() {});
  2166. }
  2167. }
  2168. function webViewerUpdateViewarea(evt) {
  2169. var location = evt.location,
  2170. store = PDFViewerApplication.store;
  2171. if (store && PDFViewerApplication.isInitialViewSet) {
  2172. store.setMultiple({
  2173. 'page': location.pageNumber,
  2174. 'zoom': location.scale,
  2175. 'scrollLeft': location.left,
  2176. 'scrollTop': location.top,
  2177. 'rotation': location.rotation
  2178. })["catch"](function() {});
  2179. }
  2180. var href = PDFViewerApplication.pdfLinkService.getAnchorUrl(location.pdfOpenParams);
  2181. PDFViewerApplication.appConfig.toolbar.viewBookmark.href = href;
  2182. PDFViewerApplication.appConfig.secondaryToolbar.viewBookmarkButton.href = href;
  2183. var currentPage = PDFViewerApplication.pdfViewer.getPageView(PDFViewerApplication.page - 1);
  2184. var loading = currentPage.renderingState !== _pdf_rendering_queue.RenderingStates.FINISHED;
  2185. PDFViewerApplication.toolbar.updateLoadingIndicatorState(loading);
  2186. }
  2187. function webViewerScrollModeChanged(evt) {
  2188. var store = PDFViewerApplication.store;
  2189. if (store && PDFViewerApplication.isInitialViewSet) {
  2190. store.set('scrollMode', evt.mode)["catch"](function() {});
  2191. }
  2192. }
  2193. function webViewerSpreadModeChanged(evt) {
  2194. var store = PDFViewerApplication.store;
  2195. if (store && PDFViewerApplication.isInitialViewSet) {
  2196. store.set('spreadMode', evt.mode)["catch"](function() {});
  2197. }
  2198. }
  2199. function webViewerResize() {
  2200. var pdfDocument = PDFViewerApplication.pdfDocument,
  2201. pdfViewer = PDFViewerApplication.pdfViewer;
  2202. if (!pdfDocument) {
  2203. return;
  2204. }
  2205. var currentScaleValue = pdfViewer.currentScaleValue;
  2206. if (currentScaleValue === 'auto' || currentScaleValue === 'page-fit' || currentScaleValue ===
  2207. 'page-width') {
  2208. pdfViewer.currentScaleValue = currentScaleValue;
  2209. }
  2210. pdfViewer.update();
  2211. }
  2212. function webViewerHashchange(evt) {
  2213. var hash = evt.hash;
  2214. if (!hash) {
  2215. return;
  2216. }
  2217. if (!PDFViewerApplication.isInitialViewSet) {
  2218. PDFViewerApplication.initialBookmark = hash;
  2219. } else if (!PDFViewerApplication.pdfHistory.popStateInProgress) {
  2220. PDFViewerApplication.pdfLinkService.setHash(hash);
  2221. }
  2222. }
  2223. var webViewerFileInputChange; {
  2224. webViewerFileInputChange = function webViewerFileInputChange(evt) {
  2225. if (PDFViewerApplication.pdfViewer && PDFViewerApplication.pdfViewer.isInPresentationMode) {
  2226. return;
  2227. }
  2228. var file = evt.fileInput.files[0];
  2229. if (URL.createObjectURL && !_app_options.AppOptions.get('disableCreateObjectURL')) {
  2230. var url = URL.createObjectURL(file);
  2231. if (file.name) {
  2232. url = {
  2233. url: url,
  2234. originalUrl: file.name
  2235. };
  2236. }
  2237. PDFViewerApplication.open(url);
  2238. } else {
  2239. PDFViewerApplication.setTitleUsingUrl(file.name);
  2240. var fileReader = new FileReader();
  2241. fileReader.onload = function webViewerChangeFileReaderOnload(evt) {
  2242. var buffer = evt.target.result;
  2243. PDFViewerApplication.open(new Uint8Array(buffer));
  2244. };
  2245. fileReader.readAsArrayBuffer(file);
  2246. }
  2247. var appConfig = PDFViewerApplication.appConfig;
  2248. appConfig.toolbar.viewBookmark.setAttribute('hidden', 'true');
  2249. appConfig.secondaryToolbar.viewBookmarkButton.setAttribute('hidden', 'true');
  2250. appConfig.toolbar.download.setAttribute('hidden', 'true');
  2251. appConfig.secondaryToolbar.downloadButton.setAttribute('hidden', 'true');
  2252. };
  2253. }
  2254. function webViewerPresentationMode() {
  2255. PDFViewerApplication.requestPresentationMode();
  2256. }
  2257. function webViewerOpenFile() {
  2258. var openFileInputName = PDFViewerApplication.appConfig.openFileInputName;
  2259. document.getElementById(openFileInputName).click();
  2260. }
  2261. function webViewerPrint() {
  2262. window.print();
  2263. }
  2264. function webViewerDownload() {
  2265. PDFViewerApplication.download();
  2266. }
  2267. function webViewerFirstPage() {
  2268. if (PDFViewerApplication.pdfDocument) {
  2269. PDFViewerApplication.page = 1;
  2270. }
  2271. }
  2272. function webViewerLastPage() {
  2273. if (PDFViewerApplication.pdfDocument) {
  2274. PDFViewerApplication.page = PDFViewerApplication.pagesCount;
  2275. }
  2276. }
  2277. function webViewerNextPage() {
  2278. PDFViewerApplication.page++;
  2279. }
  2280. function webViewerPreviousPage() {
  2281. PDFViewerApplication.page--;
  2282. }
  2283. function webViewerZoomIn() {
  2284. PDFViewerApplication.zoomIn();
  2285. }
  2286. function webViewerZoomOut() {
  2287. PDFViewerApplication.zoomOut();
  2288. }
  2289. function webViewerZoomReset() {
  2290. PDFViewerApplication.zoomReset();
  2291. }
  2292. function webViewerPageNumberChanged(evt) {
  2293. var pdfViewer = PDFViewerApplication.pdfViewer;
  2294. if (evt.value !== '') {
  2295. pdfViewer.currentPageLabel = evt.value;
  2296. }
  2297. if (evt.value !== pdfViewer.currentPageNumber.toString() && evt.value !== pdfViewer
  2298. .currentPageLabel) {
  2299. PDFViewerApplication.toolbar.setPageNumber(pdfViewer.currentPageNumber, pdfViewer
  2300. .currentPageLabel);
  2301. }
  2302. }
  2303. function webViewerScaleChanged(evt) {
  2304. PDFViewerApplication.pdfViewer.currentScaleValue = evt.value;
  2305. }
  2306. function webViewerRotateCw() {
  2307. PDFViewerApplication.rotatePages(90);
  2308. }
  2309. function webViewerRotateCcw() {
  2310. PDFViewerApplication.rotatePages(-90);
  2311. }
  2312. function webViewerSwitchScrollMode(evt) {
  2313. PDFViewerApplication.pdfViewer.scrollMode = evt.mode;
  2314. }
  2315. function webViewerSwitchSpreadMode(evt) {
  2316. PDFViewerApplication.pdfViewer.spreadMode = evt.mode;
  2317. }
  2318. function webViewerDocumentProperties() {
  2319. PDFViewerApplication.pdfDocumentProperties.open();
  2320. }
  2321. function webViewerFind(evt) {
  2322. PDFViewerApplication.findController.executeCommand('find' + evt.type, {
  2323. query: evt.query,
  2324. phraseSearch: evt.phraseSearch,
  2325. caseSensitive: evt.caseSensitive,
  2326. entireWord: evt.entireWord,
  2327. highlightAll: evt.highlightAll,
  2328. findPrevious: evt.findPrevious
  2329. });
  2330. }
  2331. function webViewerFindFromUrlHash(evt) {
  2332. PDFViewerApplication.findController.executeCommand('find', {
  2333. query: evt.query,
  2334. phraseSearch: evt.phraseSearch,
  2335. caseSensitive: false,
  2336. entireWord: false,
  2337. highlightAll: true,
  2338. findPrevious: false
  2339. });
  2340. }
  2341. function webViewerUpdateFindMatchesCount(_ref9) {
  2342. var matchesCount = _ref9.matchesCount;
  2343. if (PDFViewerApplication.supportsIntegratedFind) {
  2344. PDFViewerApplication.externalServices.updateFindMatchesCount(matchesCount);
  2345. } else {
  2346. PDFViewerApplication.findBar.updateResultsCount(matchesCount);
  2347. }
  2348. }
  2349. function webViewerUpdateFindControlState(_ref10) {
  2350. var state = _ref10.state,
  2351. previous = _ref10.previous,
  2352. matchesCount = _ref10.matchesCount;
  2353. if (PDFViewerApplication.supportsIntegratedFind) {
  2354. PDFViewerApplication.externalServices.updateFindControlState({
  2355. result: state,
  2356. findPrevious: previous,
  2357. matchesCount: matchesCount
  2358. });
  2359. } else {
  2360. PDFViewerApplication.findBar.updateUIState(state, previous, matchesCount);
  2361. }
  2362. }
  2363. function webViewerScaleChanging(evt) {
  2364. PDFViewerApplication.toolbar.setPageScale(evt.presetValue, evt.scale);
  2365. PDFViewerApplication.pdfViewer.update();
  2366. }
  2367. function webViewerRotationChanging(evt) {
  2368. PDFViewerApplication.pdfThumbnailViewer.pagesRotation = evt.pagesRotation;
  2369. PDFViewerApplication.forceRendering();
  2370. PDFViewerApplication.pdfViewer.currentPageNumber = evt.pageNumber;
  2371. }
  2372. function webViewerPageChanging(evt) {
  2373. var page = evt.pageNumber;
  2374. PDFViewerApplication.toolbar.setPageNumber(page, evt.pageLabel || null);
  2375. PDFViewerApplication.secondaryToolbar.setPageNumber(page);
  2376. if (PDFViewerApplication.pdfSidebar.isThumbnailViewVisible) {
  2377. PDFViewerApplication.pdfThumbnailViewer.scrollThumbnailIntoView(page);
  2378. }
  2379. if (typeof Stats !== 'undefined' && Stats.enabled) {
  2380. var pageView = PDFViewerApplication.pdfViewer.getPageView(page - 1);
  2381. if (pageView && pageView.stats) {
  2382. Stats.add(page, pageView.stats);
  2383. }
  2384. }
  2385. }
  2386. function webViewerVisibilityChange(evt) {
  2387. if (document.visibilityState === 'visible') {
  2388. setZoomDisabledTimeout();
  2389. }
  2390. }
  2391. var zoomDisabledTimeout = null;
  2392. function setZoomDisabledTimeout() {
  2393. if (zoomDisabledTimeout) {
  2394. clearTimeout(zoomDisabledTimeout);
  2395. }
  2396. zoomDisabledTimeout = setTimeout(function() {
  2397. zoomDisabledTimeout = null;
  2398. }, WHEEL_ZOOM_DISABLED_TIMEOUT);
  2399. }
  2400. function webViewerWheel(evt) {
  2401. var pdfViewer = PDFViewerApplication.pdfViewer,
  2402. supportedMouseWheelZoomModifierKeys = PDFViewerApplication.supportedMouseWheelZoomModifierKeys;
  2403. if (pdfViewer.isInPresentationMode) {
  2404. return;
  2405. }
  2406. if (evt.ctrlKey && supportedMouseWheelZoomModifierKeys.ctrlKey || evt.metaKey &&
  2407. supportedMouseWheelZoomModifierKeys.metaKey) {
  2408. evt.preventDefault();
  2409. if (zoomDisabledTimeout || document.visibilityState === 'hidden') {
  2410. return;
  2411. }
  2412. var previousScale = pdfViewer.currentScale;
  2413. var delta = (0, _ui_utils.normalizeWheelEventDelta)(evt);
  2414. var MOUSE_WHEEL_DELTA_PER_PAGE_SCALE = 3.0;
  2415. var ticks = delta * MOUSE_WHEEL_DELTA_PER_PAGE_SCALE;
  2416. if (ticks < 0) {
  2417. PDFViewerApplication.zoomOut(-ticks);
  2418. } else {
  2419. PDFViewerApplication.zoomIn(ticks);
  2420. }
  2421. var currentScale = pdfViewer.currentScale;
  2422. if (previousScale !== currentScale) {
  2423. var scaleCorrectionFactor = currentScale / previousScale - 1;
  2424. var rect = pdfViewer.container.getBoundingClientRect();
  2425. var dx = evt.clientX - rect.left;
  2426. var dy = evt.clientY - rect.top;
  2427. pdfViewer.container.scrollLeft += dx * scaleCorrectionFactor;
  2428. pdfViewer.container.scrollTop += dy * scaleCorrectionFactor;
  2429. }
  2430. } else {
  2431. setZoomDisabledTimeout();
  2432. }
  2433. }
  2434. function webViewerClick(evt) {
  2435. if (!PDFViewerApplication.secondaryToolbar.isOpen) {
  2436. return;
  2437. }
  2438. var appConfig = PDFViewerApplication.appConfig;
  2439. if (PDFViewerApplication.pdfViewer.containsElement(evt.target) || appConfig.toolbar.container
  2440. .contains(evt.target) && evt.target !== appConfig.secondaryToolbar.toggleButton) {
  2441. PDFViewerApplication.secondaryToolbar.close();
  2442. }
  2443. }
  2444. function webViewerKeyDown(evt) {
  2445. if (PDFViewerApplication.overlayManager.active) {
  2446. return;
  2447. }
  2448. var handled = false,
  2449. ensureViewerFocused = false;
  2450. var cmd = (evt.ctrlKey ? 1 : 0) | (evt.altKey ? 2 : 0) | (evt.shiftKey ? 4 : 0) | (evt.metaKey ? 8 :
  2451. 0);
  2452. var pdfViewer = PDFViewerApplication.pdfViewer;
  2453. var isViewerInPresentationMode = pdfViewer && pdfViewer.isInPresentationMode;
  2454. if (cmd === 1 || cmd === 8 || cmd === 5 || cmd === 12) {
  2455. switch (evt.keyCode) {
  2456. case 70:
  2457. if (!PDFViewerApplication.supportsIntegratedFind) {
  2458. PDFViewerApplication.findBar.open();
  2459. handled = true;
  2460. }
  2461. break;
  2462. case 71:
  2463. if (!PDFViewerApplication.supportsIntegratedFind) {
  2464. var findState = PDFViewerApplication.findController.state;
  2465. if (findState) {
  2466. PDFViewerApplication.findController.executeCommand('findagain', {
  2467. query: findState.query,
  2468. phraseSearch: findState.phraseSearch,
  2469. caseSensitive: findState.caseSensitive,
  2470. entireWord: findState.entireWord,
  2471. highlightAll: findState.highlightAll,
  2472. findPrevious: cmd === 5 || cmd === 12
  2473. });
  2474. }
  2475. handled = true;
  2476. }
  2477. break;
  2478. case 61:
  2479. case 107:
  2480. case 187:
  2481. case 171:
  2482. if (!isViewerInPresentationMode) {
  2483. PDFViewerApplication.zoomIn();
  2484. }
  2485. handled = true;
  2486. break;
  2487. case 173:
  2488. case 109:
  2489. case 189:
  2490. if (!isViewerInPresentationMode) {
  2491. PDFViewerApplication.zoomOut();
  2492. }
  2493. handled = true;
  2494. break;
  2495. case 48:
  2496. case 96:
  2497. if (!isViewerInPresentationMode) {
  2498. setTimeout(function() {
  2499. PDFViewerApplication.zoomReset();
  2500. });
  2501. handled = false;
  2502. }
  2503. break;
  2504. case 38:
  2505. if (isViewerInPresentationMode || PDFViewerApplication.page > 1) {
  2506. PDFViewerApplication.page = 1;
  2507. handled = true;
  2508. ensureViewerFocused = true;
  2509. }
  2510. break;
  2511. case 40:
  2512. if (isViewerInPresentationMode || PDFViewerApplication.page < PDFViewerApplication
  2513. .pagesCount) {
  2514. PDFViewerApplication.page = PDFViewerApplication.pagesCount;
  2515. handled = true;
  2516. ensureViewerFocused = true;
  2517. }
  2518. break;
  2519. }
  2520. }
  2521. if (cmd === 1 || cmd === 8) {
  2522. switch (evt.keyCode) {
  2523. case 83:
  2524. PDFViewerApplication.download();
  2525. handled = true;
  2526. break;
  2527. }
  2528. }
  2529. if (cmd === 3 || cmd === 10) {
  2530. switch (evt.keyCode) {
  2531. case 80:
  2532. PDFViewerApplication.requestPresentationMode();
  2533. handled = true;
  2534. break;
  2535. case 71:
  2536. PDFViewerApplication.appConfig.toolbar.pageNumber.select();
  2537. handled = true;
  2538. break;
  2539. }
  2540. }
  2541. if (handled) {
  2542. if (ensureViewerFocused && !isViewerInPresentationMode) {
  2543. pdfViewer.focus();
  2544. }
  2545. evt.preventDefault();
  2546. return;
  2547. }
  2548. var curElement = document.activeElement || document.querySelector(':focus');
  2549. var curElementTagName = curElement && curElement.tagName.toUpperCase();
  2550. if (curElementTagName === 'INPUT' || curElementTagName === 'TEXTAREA' || curElementTagName ===
  2551. 'SELECT') {
  2552. if (evt.keyCode !== 27) {
  2553. return;
  2554. }
  2555. }
  2556. if (cmd === 0) {
  2557. var turnPage = 0,
  2558. turnOnlyIfPageFit = false;
  2559. switch (evt.keyCode) {
  2560. case 38:
  2561. case 33:
  2562. if (pdfViewer.isVerticalScrollbarEnabled) {
  2563. turnOnlyIfPageFit = true;
  2564. }
  2565. turnPage = -1;
  2566. break;
  2567. case 8:
  2568. if (!isViewerInPresentationMode) {
  2569. turnOnlyIfPageFit = true;
  2570. }
  2571. turnPage = -1;
  2572. break;
  2573. case 37:
  2574. if (pdfViewer.isHorizontalScrollbarEnabled) {
  2575. turnOnlyIfPageFit = true;
  2576. }
  2577. case 75:
  2578. case 80:
  2579. turnPage = -1;
  2580. break;
  2581. case 27:
  2582. if (PDFViewerApplication.secondaryToolbar.isOpen) {
  2583. PDFViewerApplication.secondaryToolbar.close();
  2584. handled = true;
  2585. }
  2586. if (!PDFViewerApplication.supportsIntegratedFind && PDFViewerApplication.findBar
  2587. .opened) {
  2588. PDFViewerApplication.findBar.close();
  2589. handled = true;
  2590. }
  2591. break;
  2592. case 40:
  2593. case 34:
  2594. if (pdfViewer.isVerticalScrollbarEnabled) {
  2595. turnOnlyIfPageFit = true;
  2596. }
  2597. turnPage = 1;
  2598. break;
  2599. case 13:
  2600. case 32:
  2601. if (!isViewerInPresentationMode) {
  2602. turnOnlyIfPageFit = true;
  2603. }
  2604. turnPage = 1;
  2605. break;
  2606. case 39:
  2607. if (pdfViewer.isHorizontalScrollbarEnabled) {
  2608. turnOnlyIfPageFit = true;
  2609. }
  2610. case 74:
  2611. case 78:
  2612. turnPage = 1;
  2613. break;
  2614. case 36:
  2615. if (isViewerInPresentationMode || PDFViewerApplication.page > 1) {
  2616. PDFViewerApplication.page = 1;
  2617. handled = true;
  2618. ensureViewerFocused = true;
  2619. }
  2620. break;
  2621. case 35:
  2622. if (isViewerInPresentationMode || PDFViewerApplication.page <
  2623. PDFViewerApplication.pagesCount) {
  2624. PDFViewerApplication.page = PDFViewerApplication.pagesCount;
  2625. handled = true;
  2626. ensureViewerFocused = true;
  2627. }
  2628. break;
  2629. case 83:
  2630. PDFViewerApplication.pdfCursorTools.switchTool(_pdf_cursor_tools.CursorTool
  2631. .SELECT);
  2632. break;
  2633. case 72:
  2634. PDFViewerApplication.pdfCursorTools.switchTool(_pdf_cursor_tools.CursorTool
  2635. .HAND);
  2636. break;
  2637. case 82:
  2638. PDFViewerApplication.rotatePages(90);
  2639. break;
  2640. case 115:
  2641. PDFViewerApplication.pdfSidebar.toggle();
  2642. break;
  2643. }
  2644. if (turnPage !== 0 && (!turnOnlyIfPageFit || pdfViewer.currentScaleValue === 'page-fit')) {
  2645. if (turnPage > 0) {
  2646. if (PDFViewerApplication.page < PDFViewerApplication.pagesCount) {
  2647. PDFViewerApplication.page++;
  2648. }
  2649. } else {
  2650. if (PDFViewerApplication.page > 1) {
  2651. PDFViewerApplication.page--;
  2652. }
  2653. }
  2654. handled = true;
  2655. }
  2656. }
  2657. if (cmd === 4) {
  2658. switch (evt.keyCode) {
  2659. case 13:
  2660. case 32:
  2661. if (!isViewerInPresentationMode && pdfViewer.currentScaleValue !== 'page-fit') {
  2662. break;
  2663. }
  2664. if (PDFViewerApplication.page > 1) {
  2665. PDFViewerApplication.page--;
  2666. }
  2667. handled = true;
  2668. break;
  2669. case 82:
  2670. PDFViewerApplication.rotatePages(-90);
  2671. break;
  2672. }
  2673. }
  2674. if (!handled && !isViewerInPresentationMode) {
  2675. if (evt.keyCode >= 33 && evt.keyCode <= 40 || evt.keyCode === 32 && curElementTagName !==
  2676. 'BUTTON') {
  2677. ensureViewerFocused = true;
  2678. }
  2679. }
  2680. if (ensureViewerFocused && !pdfViewer.containsElement(curElement)) {
  2681. pdfViewer.focus();
  2682. }
  2683. if (handled) {
  2684. evt.preventDefault();
  2685. }
  2686. }
  2687. function apiPageLayoutToSpreadMode(layout) {
  2688. switch (layout) {
  2689. case 'SinglePage':
  2690. case 'OneColumn':
  2691. return _ui_utils.SpreadMode.NONE;
  2692. case 'TwoColumnLeft':
  2693. case 'TwoPageLeft':
  2694. return _ui_utils.SpreadMode.ODD;
  2695. case 'TwoColumnRight':
  2696. case 'TwoPageRight':
  2697. return _ui_utils.SpreadMode.EVEN;
  2698. }
  2699. return _ui_utils.SpreadMode.NONE;
  2700. }
  2701. function apiPageModeToSidebarView(mode) {
  2702. switch (mode) {
  2703. case 'UseNone':
  2704. return _pdf_sidebar.SidebarView.NONE;
  2705. case 'UseThumbs':
  2706. return _pdf_sidebar.SidebarView.THUMBS;
  2707. case 'UseOutlines':
  2708. return _pdf_sidebar.SidebarView.OUTLINE;
  2709. case 'UseAttachments':
  2710. return _pdf_sidebar.SidebarView.ATTACHMENTS;
  2711. case 'UseOC':
  2712. }
  2713. return _pdf_sidebar.SidebarView.NONE;
  2714. }
  2715. var PDFPrintServiceFactory = {
  2716. instance: {
  2717. supportsPrinting: false,
  2718. createPrintService: function createPrintService() {
  2719. throw new Error('Not implemented: createPrintService');
  2720. }
  2721. }
  2722. };
  2723. exports.PDFPrintServiceFactory = PDFPrintServiceFactory;
  2724. /***/
  2725. }),
  2726. /* 2 */
  2727. /***/
  2728. (function(module, exports, __webpack_require__) {
  2729. "use strict";
  2730. module.exports = __webpack_require__(3);
  2731. /***/
  2732. }),
  2733. /* 3 */
  2734. /***/
  2735. (function(module, exports, __webpack_require__) {
  2736. "use strict";
  2737. /* WEBPACK VAR INJECTION */
  2738. (function(module) {
  2739. function _typeof(obj) {
  2740. if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
  2741. _typeof = function _typeof(obj) {
  2742. return typeof obj;
  2743. };
  2744. } else {
  2745. _typeof = function _typeof(obj) {
  2746. return obj && typeof Symbol === "function" && obj.constructor === Symbol &&
  2747. obj !== Symbol.prototype ? "symbol" : typeof obj;
  2748. };
  2749. }
  2750. return _typeof(obj);
  2751. }
  2752. var runtime = function(exports) {
  2753. "use strict";
  2754. var Op = Object.prototype;
  2755. var hasOwn = Op.hasOwnProperty;
  2756. var undefined;
  2757. var $Symbol = typeof Symbol === "function" ? Symbol : {};
  2758. var iteratorSymbol = $Symbol.iterator || "@@iterator";
  2759. var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator";
  2760. var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
  2761. function wrap(innerFn, outerFn, self, tryLocsList) {
  2762. var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn :
  2763. Generator;
  2764. var generator = Object.create(protoGenerator.prototype);
  2765. var context = new Context(tryLocsList || []);
  2766. generator._invoke = makeInvokeMethod(innerFn, self, context);
  2767. return generator;
  2768. }
  2769. exports.wrap = wrap;
  2770. function tryCatch(fn, obj, arg) {
  2771. try {
  2772. return {
  2773. type: "normal",
  2774. arg: fn.call(obj, arg)
  2775. };
  2776. } catch (err) {
  2777. return {
  2778. type: "throw",
  2779. arg: err
  2780. };
  2781. }
  2782. }
  2783. var GenStateSuspendedStart = "suspendedStart";
  2784. var GenStateSuspendedYield = "suspendedYield";
  2785. var GenStateExecuting = "executing";
  2786. var GenStateCompleted = "completed";
  2787. var ContinueSentinel = {};
  2788. function Generator() {}
  2789. function GeneratorFunction() {}
  2790. function GeneratorFunctionPrototype() {}
  2791. var IteratorPrototype = {};
  2792. IteratorPrototype[iteratorSymbol] = function() {
  2793. return this;
  2794. };
  2795. var getProto = Object.getPrototypeOf;
  2796. var NativeIteratorPrototype = getProto && getProto(getProto(values([])));
  2797. if (NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(
  2798. NativeIteratorPrototype, iteratorSymbol)) {
  2799. IteratorPrototype = NativeIteratorPrototype;
  2800. }
  2801. var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(
  2802. IteratorPrototype);
  2803. GeneratorFunction.prototype = Gp.constructor = GeneratorFunctionPrototype;
  2804. GeneratorFunctionPrototype.constructor = GeneratorFunction;
  2805. GeneratorFunctionPrototype[toStringTagSymbol] = GeneratorFunction.displayName =
  2806. "GeneratorFunction";
  2807. function defineIteratorMethods(prototype) {
  2808. ["next", "throw", "return"].forEach(function(method) {
  2809. prototype[method] = function(arg) {
  2810. return this._invoke(method, arg);
  2811. };
  2812. });
  2813. }
  2814. exports.isGeneratorFunction = function(genFun) {
  2815. var ctor = typeof genFun === "function" && genFun.constructor;
  2816. return ctor ? ctor === GeneratorFunction || (ctor.displayName || ctor.name) ===
  2817. "GeneratorFunction" : false;
  2818. };
  2819. exports.mark = function(genFun) {
  2820. if (Object.setPrototypeOf) {
  2821. Object.setPrototypeOf(genFun, GeneratorFunctionPrototype);
  2822. } else {
  2823. genFun.__proto__ = GeneratorFunctionPrototype;
  2824. if (!(toStringTagSymbol in genFun)) {
  2825. genFun[toStringTagSymbol] = "GeneratorFunction";
  2826. }
  2827. }
  2828. genFun.prototype = Object.create(Gp);
  2829. return genFun;
  2830. };
  2831. exports.awrap = function(arg) {
  2832. return {
  2833. __await: arg
  2834. };
  2835. };
  2836. function AsyncIterator(generator) {
  2837. function invoke(method, arg, resolve, reject) {
  2838. var record = tryCatch(generator[method], generator, arg);
  2839. if (record.type === "throw") {
  2840. reject(record.arg);
  2841. } else {
  2842. var result = record.arg;
  2843. var value = result.value;
  2844. if (value && _typeof(value) === "object" && hasOwn.call(value, "__await")) {
  2845. return Promise.resolve(value.__await).then(function(value) {
  2846. invoke("next", value, resolve, reject);
  2847. }, function(err) {
  2848. invoke("throw", err, resolve, reject);
  2849. });
  2850. }
  2851. return Promise.resolve(value).then(function(unwrapped) {
  2852. result.value = unwrapped;
  2853. resolve(result);
  2854. }, function(error) {
  2855. return invoke("throw", error, resolve, reject);
  2856. });
  2857. }
  2858. }
  2859. var previousPromise;
  2860. function enqueue(method, arg) {
  2861. function callInvokeWithMethodAndArg() {
  2862. return new Promise(function(resolve, reject) {
  2863. invoke(method, arg, resolve, reject);
  2864. });
  2865. }
  2866. return previousPromise = previousPromise ? previousPromise.then(
  2867. callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) :
  2868. callInvokeWithMethodAndArg();
  2869. }
  2870. this._invoke = enqueue;
  2871. }
  2872. defineIteratorMethods(AsyncIterator.prototype);
  2873. AsyncIterator.prototype[asyncIteratorSymbol] = function() {
  2874. return this;
  2875. };
  2876. exports.AsyncIterator = AsyncIterator;
  2877. exports.async = function(innerFn, outerFn, self, tryLocsList) {
  2878. var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList));
  2879. return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function(
  2880. result) {
  2881. return result.done ? result.value : iter.next();
  2882. });
  2883. };
  2884. function makeInvokeMethod(innerFn, self, context) {
  2885. var state = GenStateSuspendedStart;
  2886. return function invoke(method, arg) {
  2887. if (state === GenStateExecuting) {
  2888. throw new Error("Generator is already running");
  2889. }
  2890. if (state === GenStateCompleted) {
  2891. if (method === "throw") {
  2892. throw arg;
  2893. }
  2894. return doneResult();
  2895. }
  2896. context.method = method;
  2897. context.arg = arg;
  2898. while (true) {
  2899. var delegate = context.delegate;
  2900. if (delegate) {
  2901. var delegateResult = maybeInvokeDelegate(delegate, context);
  2902. if (delegateResult) {
  2903. if (delegateResult === ContinueSentinel) continue;
  2904. return delegateResult;
  2905. }
  2906. }
  2907. if (context.method === "next") {
  2908. context.sent = context._sent = context.arg;
  2909. } else if (context.method === "throw") {
  2910. if (state === GenStateSuspendedStart) {
  2911. state = GenStateCompleted;
  2912. throw context.arg;
  2913. }
  2914. context.dispatchException(context.arg);
  2915. } else if (context.method === "return") {
  2916. context.abrupt("return", context.arg);
  2917. }
  2918. state = GenStateExecuting;
  2919. var record = tryCatch(innerFn, self, context);
  2920. if (record.type === "normal") {
  2921. state = context.done ? GenStateCompleted : GenStateSuspendedYield;
  2922. if (record.arg === ContinueSentinel) {
  2923. continue;
  2924. }
  2925. return {
  2926. value: record.arg,
  2927. done: context.done
  2928. };
  2929. } else if (record.type === "throw") {
  2930. state = GenStateCompleted;
  2931. context.method = "throw";
  2932. context.arg = record.arg;
  2933. }
  2934. }
  2935. };
  2936. }
  2937. function maybeInvokeDelegate(delegate, context) {
  2938. var method = delegate.iterator[context.method];
  2939. if (method === undefined) {
  2940. context.delegate = null;
  2941. if (context.method === "throw") {
  2942. if (delegate.iterator["return"]) {
  2943. context.method = "return";
  2944. context.arg = undefined;
  2945. maybeInvokeDelegate(delegate, context);
  2946. if (context.method === "throw") {
  2947. return ContinueSentinel;
  2948. }
  2949. }
  2950. context.method = "throw";
  2951. context.arg = new TypeError(
  2952. "The iterator does not provide a 'throw' method");
  2953. }
  2954. return ContinueSentinel;
  2955. }
  2956. var record = tryCatch(method, delegate.iterator, context.arg);
  2957. if (record.type === "throw") {
  2958. context.method = "throw";
  2959. context.arg = record.arg;
  2960. context.delegate = null;
  2961. return ContinueSentinel;
  2962. }
  2963. var info = record.arg;
  2964. if (!info) {
  2965. context.method = "throw";
  2966. context.arg = new TypeError("iterator result is not an object");
  2967. context.delegate = null;
  2968. return ContinueSentinel;
  2969. }
  2970. if (info.done) {
  2971. context[delegate.resultName] = info.value;
  2972. context.next = delegate.nextLoc;
  2973. if (context.method !== "return") {
  2974. context.method = "next";
  2975. context.arg = undefined;
  2976. }
  2977. } else {
  2978. return info;
  2979. }
  2980. context.delegate = null;
  2981. return ContinueSentinel;
  2982. }
  2983. defineIteratorMethods(Gp);
  2984. Gp[toStringTagSymbol] = "Generator";
  2985. Gp[iteratorSymbol] = function() {
  2986. return this;
  2987. };
  2988. Gp.toString = function() {
  2989. return "[object Generator]";
  2990. };
  2991. function pushTryEntry(locs) {
  2992. var entry = {
  2993. tryLoc: locs[0]
  2994. };
  2995. if (1 in locs) {
  2996. entry.catchLoc = locs[1];
  2997. }
  2998. if (2 in locs) {
  2999. entry.finallyLoc = locs[2];
  3000. entry.afterLoc = locs[3];
  3001. }
  3002. this.tryEntries.push(entry);
  3003. }
  3004. function resetTryEntry(entry) {
  3005. var record = entry.completion || {};
  3006. record.type = "normal";
  3007. delete record.arg;
  3008. entry.completion = record;
  3009. }
  3010. function Context(tryLocsList) {
  3011. this.tryEntries = [{
  3012. tryLoc: "root"
  3013. }];
  3014. tryLocsList.forEach(pushTryEntry, this);
  3015. this.reset(true);
  3016. }
  3017. exports.keys = function(object) {
  3018. var keys = [];
  3019. for (var key in object) {
  3020. keys.push(key);
  3021. }
  3022. keys.reverse();
  3023. return function next() {
  3024. while (keys.length) {
  3025. var key = keys.pop();
  3026. if (key in object) {
  3027. next.value = key;
  3028. next.done = false;
  3029. return next;
  3030. }
  3031. }
  3032. next.done = true;
  3033. return next;
  3034. };
  3035. };
  3036. function values(iterable) {
  3037. if (iterable) {
  3038. var iteratorMethod = iterable[iteratorSymbol];
  3039. if (iteratorMethod) {
  3040. return iteratorMethod.call(iterable);
  3041. }
  3042. if (typeof iterable.next === "function") {
  3043. return iterable;
  3044. }
  3045. if (!isNaN(iterable.length)) {
  3046. var i = -1,
  3047. next = function next() {
  3048. while (++i < iterable.length) {
  3049. if (hasOwn.call(iterable, i)) {
  3050. next.value = iterable[i];
  3051. next.done = false;
  3052. return next;
  3053. }
  3054. }
  3055. next.value = undefined;
  3056. next.done = true;
  3057. return next;
  3058. };
  3059. return next.next = next;
  3060. }
  3061. }
  3062. return {
  3063. next: doneResult
  3064. };
  3065. }
  3066. exports.values = values;
  3067. function doneResult() {
  3068. return {
  3069. value: undefined,
  3070. done: true
  3071. };
  3072. }
  3073. Context.prototype = {
  3074. constructor: Context,
  3075. reset: function reset(skipTempReset) {
  3076. this.prev = 0;
  3077. this.next = 0;
  3078. this.sent = this._sent = undefined;
  3079. this.done = false;
  3080. this.delegate = null;
  3081. this.method = "next";
  3082. this.arg = undefined;
  3083. this.tryEntries.forEach(resetTryEntry);
  3084. if (!skipTempReset) {
  3085. for (var name in this) {
  3086. if (name.charAt(0) === "t" && hasOwn.call(this, name) && !isNaN(
  3087. +name.slice(1))) {
  3088. this[name] = undefined;
  3089. }
  3090. }
  3091. }
  3092. },
  3093. stop: function stop() {
  3094. this.done = true;
  3095. var rootEntry = this.tryEntries[0];
  3096. var rootRecord = rootEntry.completion;
  3097. if (rootRecord.type === "throw") {
  3098. throw rootRecord.arg;
  3099. }
  3100. return this.rval;
  3101. },
  3102. dispatchException: function dispatchException(exception) {
  3103. if (this.done) {
  3104. throw exception;
  3105. }
  3106. var context = this;
  3107. function handle(loc, caught) {
  3108. record.type = "throw";
  3109. record.arg = exception;
  3110. context.next = loc;
  3111. if (caught) {
  3112. context.method = "next";
  3113. context.arg = undefined;
  3114. }
  3115. return !!caught;
  3116. }
  3117. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  3118. var entry = this.tryEntries[i];
  3119. var record = entry.completion;
  3120. if (entry.tryLoc === "root") {
  3121. return handle("end");
  3122. }
  3123. if (entry.tryLoc <= this.prev) {
  3124. var hasCatch = hasOwn.call(entry, "catchLoc");
  3125. var hasFinally = hasOwn.call(entry, "finallyLoc");
  3126. if (hasCatch && hasFinally) {
  3127. if (this.prev < entry.catchLoc) {
  3128. return handle(entry.catchLoc, true);
  3129. } else if (this.prev < entry.finallyLoc) {
  3130. return handle(entry.finallyLoc);
  3131. }
  3132. } else if (hasCatch) {
  3133. if (this.prev < entry.catchLoc) {
  3134. return handle(entry.catchLoc, true);
  3135. }
  3136. } else if (hasFinally) {
  3137. if (this.prev < entry.finallyLoc) {
  3138. return handle(entry.finallyLoc);
  3139. }
  3140. } else {
  3141. throw new Error("try statement without catch or finally");
  3142. }
  3143. }
  3144. }
  3145. },
  3146. abrupt: function abrupt(type, arg) {
  3147. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  3148. var entry = this.tryEntries[i];
  3149. if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") &&
  3150. this.prev < entry.finallyLoc) {
  3151. var finallyEntry = entry;
  3152. break;
  3153. }
  3154. }
  3155. if (finallyEntry && (type === "break" || type === "continue") &&
  3156. finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc) {
  3157. finallyEntry = null;
  3158. }
  3159. var record = finallyEntry ? finallyEntry.completion : {};
  3160. record.type = type;
  3161. record.arg = arg;
  3162. if (finallyEntry) {
  3163. this.method = "next";
  3164. this.next = finallyEntry.finallyLoc;
  3165. return ContinueSentinel;
  3166. }
  3167. return this.complete(record);
  3168. },
  3169. complete: function complete(record, afterLoc) {
  3170. if (record.type === "throw") {
  3171. throw record.arg;
  3172. }
  3173. if (record.type === "break" || record.type === "continue") {
  3174. this.next = record.arg;
  3175. } else if (record.type === "return") {
  3176. this.rval = this.arg = record.arg;
  3177. this.method = "return";
  3178. this.next = "end";
  3179. } else if (record.type === "normal" && afterLoc) {
  3180. this.next = afterLoc;
  3181. }
  3182. return ContinueSentinel;
  3183. },
  3184. finish: function finish(finallyLoc) {
  3185. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  3186. var entry = this.tryEntries[i];
  3187. if (entry.finallyLoc === finallyLoc) {
  3188. this.complete(entry.completion, entry.afterLoc);
  3189. resetTryEntry(entry);
  3190. return ContinueSentinel;
  3191. }
  3192. }
  3193. },
  3194. "catch": function _catch(tryLoc) {
  3195. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  3196. var entry = this.tryEntries[i];
  3197. if (entry.tryLoc === tryLoc) {
  3198. var record = entry.completion;
  3199. if (record.type === "throw") {
  3200. var thrown = record.arg;
  3201. resetTryEntry(entry);
  3202. }
  3203. return thrown;
  3204. }
  3205. }
  3206. throw new Error("illegal catch attempt");
  3207. },
  3208. delegateYield: function delegateYield(iterable, resultName, nextLoc) {
  3209. this.delegate = {
  3210. iterator: values(iterable),
  3211. resultName: resultName,
  3212. nextLoc: nextLoc
  3213. };
  3214. if (this.method === "next") {
  3215. this.arg = undefined;
  3216. }
  3217. return ContinueSentinel;
  3218. }
  3219. };
  3220. return exports;
  3221. }((false ? undefined : _typeof(module)) === "object" ? module.exports : {});
  3222. try {
  3223. regeneratorRuntime = runtime;
  3224. } catch (accidentalStrictMode) {
  3225. Function("r", "regeneratorRuntime = r")(runtime);
  3226. }
  3227. /* WEBPACK VAR INJECTION */
  3228. }.call(this, __webpack_require__(4)(module)))
  3229. /***/
  3230. }),
  3231. /* 4 */
  3232. /***/
  3233. (function(module, exports, __webpack_require__) {
  3234. "use strict";
  3235. module.exports = function(module) {
  3236. if (!module.webpackPolyfill) {
  3237. module.deprecate = function() {};
  3238. module.paths = [];
  3239. if (!module.children) module.children = [];
  3240. Object.defineProperty(module, "loaded", {
  3241. enumerable: true,
  3242. get: function get() {
  3243. return module.l;
  3244. }
  3245. });
  3246. Object.defineProperty(module, "id", {
  3247. enumerable: true,
  3248. get: function get() {
  3249. return module.i;
  3250. }
  3251. });
  3252. module.webpackPolyfill = 1;
  3253. }
  3254. return module;
  3255. };
  3256. /***/
  3257. }),
  3258. /* 5 */
  3259. /***/
  3260. (function(module, exports, __webpack_require__) {
  3261. "use strict";
  3262. Object.defineProperty(exports, "__esModule", {
  3263. value: true
  3264. });
  3265. exports.isValidRotation = isValidRotation;
  3266. exports.isValidScrollMode = isValidScrollMode;
  3267. exports.isValidSpreadMode = isValidSpreadMode;
  3268. exports.isPortraitOrientation = isPortraitOrientation;
  3269. exports.getGlobalEventBus = getGlobalEventBus;
  3270. exports.getPDFFileNameFromURL = getPDFFileNameFromURL;
  3271. exports.noContextMenuHandler = noContextMenuHandler;
  3272. exports.parseQueryString = parseQueryString;
  3273. exports.backtrackBeforeAllVisibleElements = backtrackBeforeAllVisibleElements;
  3274. exports.getVisibleElements = getVisibleElements;
  3275. exports.roundToDivide = roundToDivide;
  3276. exports.getPageSizeInches = getPageSizeInches;
  3277. exports.approximateFraction = approximateFraction;
  3278. exports.getOutputScale = getOutputScale;
  3279. exports.scrollIntoView = scrollIntoView;
  3280. exports.watchScroll = watchScroll;
  3281. exports.binarySearchFirstItem = binarySearchFirstItem;
  3282. exports.normalizeWheelEventDelta = normalizeWheelEventDelta;
  3283. exports.waitOnEventOrTimeout = waitOnEventOrTimeout;
  3284. exports.moveToEndOfArray = moveToEndOfArray;
  3285. exports.WaitOnType = exports.animationStarted = exports.ProgressBar = exports.EventBus = exports
  3286. .NullL10n = exports.SpreadMode = exports.ScrollMode = exports.TextLayerMode = exports.RendererType =
  3287. exports.PresentationModeState = exports.VERTICAL_PADDING = exports.SCROLLBAR_PADDING = exports
  3288. .MAX_AUTO_SCALE = exports.UNKNOWN_SCALE = exports.MAX_SCALE = exports.MIN_SCALE = exports
  3289. .DEFAULT_SCALE = exports.DEFAULT_SCALE_VALUE = exports.CSS_UNITS = void 0;
  3290. var _regenerator = _interopRequireDefault(__webpack_require__(2));
  3291. function _interopRequireDefault(obj) {
  3292. return obj && obj.__esModule ? obj : {
  3293. "default": obj
  3294. };
  3295. }
  3296. function _classCallCheck(instance, Constructor) {
  3297. if (!(instance instanceof Constructor)) {
  3298. throw new TypeError("Cannot call a class as a function");
  3299. }
  3300. }
  3301. function _defineProperties(target, props) {
  3302. for (var i = 0; i < props.length; i++) {
  3303. var descriptor = props[i];
  3304. descriptor.enumerable = descriptor.enumerable || false;
  3305. descriptor.configurable = true;
  3306. if ("value" in descriptor) descriptor.writable = true;
  3307. Object.defineProperty(target, descriptor.key, descriptor);
  3308. }
  3309. }
  3310. function _createClass(Constructor, protoProps, staticProps) {
  3311. if (protoProps) _defineProperties(Constructor.prototype, protoProps);
  3312. if (staticProps) _defineProperties(Constructor, staticProps);
  3313. return Constructor;
  3314. }
  3315. function _typeof(obj) {
  3316. if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
  3317. _typeof = function _typeof(obj) {
  3318. return typeof obj;
  3319. };
  3320. } else {
  3321. _typeof = function _typeof(obj) {
  3322. return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !==
  3323. Symbol.prototype ? "symbol" : typeof obj;
  3324. };
  3325. }
  3326. return _typeof(obj);
  3327. }
  3328. function _slicedToArray(arr, i) {
  3329. return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest();
  3330. }
  3331. function _nonIterableRest() {
  3332. throw new TypeError("Invalid attempt to destructure non-iterable instance");
  3333. }
  3334. function _iterableToArrayLimit(arr, i) {
  3335. if (!(Symbol.iterator in Object(arr) || Object.prototype.toString.call(arr) ===
  3336. "[object Arguments]")) {
  3337. return;
  3338. }
  3339. var _arr = [];
  3340. var _n = true;
  3341. var _d = false;
  3342. var _e = undefined;
  3343. try {
  3344. for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {
  3345. _arr.push(_s.value);
  3346. if (i && _arr.length === i) break;
  3347. }
  3348. } catch (err) {
  3349. _d = true;
  3350. _e = err;
  3351. } finally {
  3352. try {
  3353. if (!_n && _i["return"] != null) _i["return"]();
  3354. } finally {
  3355. if (_d) throw _e;
  3356. }
  3357. }
  3358. return _arr;
  3359. }
  3360. function _arrayWithHoles(arr) {
  3361. if (Array.isArray(arr)) return arr;
  3362. }
  3363. function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
  3364. try {
  3365. var info = gen[key](arg);
  3366. var value = info.value;
  3367. } catch (error) {
  3368. reject(error);
  3369. return;
  3370. }
  3371. if (info.done) {
  3372. resolve(value);
  3373. } else {
  3374. Promise.resolve(value).then(_next, _throw);
  3375. }
  3376. }
  3377. function _asyncToGenerator(fn) {
  3378. return function() {
  3379. var self = this,
  3380. args = arguments;
  3381. return new Promise(function(resolve, reject) {
  3382. var gen = fn.apply(self, args);
  3383. function _next(value) {
  3384. asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
  3385. }
  3386. function _throw(err) {
  3387. asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
  3388. }
  3389. _next(undefined);
  3390. });
  3391. };
  3392. }
  3393. var CSS_UNITS = 96.0 / 72.0;
  3394. exports.CSS_UNITS = CSS_UNITS;
  3395. var DEFAULT_SCALE_VALUE = 'auto';
  3396. exports.DEFAULT_SCALE_VALUE = DEFAULT_SCALE_VALUE;
  3397. var DEFAULT_SCALE = 1.0;
  3398. exports.DEFAULT_SCALE = DEFAULT_SCALE;
  3399. var MIN_SCALE = 0.10;
  3400. exports.MIN_SCALE = MIN_SCALE;
  3401. var MAX_SCALE = 10.0;
  3402. exports.MAX_SCALE = MAX_SCALE;
  3403. var UNKNOWN_SCALE = 0;
  3404. exports.UNKNOWN_SCALE = UNKNOWN_SCALE;
  3405. var MAX_AUTO_SCALE = 1.25;
  3406. exports.MAX_AUTO_SCALE = MAX_AUTO_SCALE;
  3407. var SCROLLBAR_PADDING = 40;
  3408. exports.SCROLLBAR_PADDING = SCROLLBAR_PADDING;
  3409. var VERTICAL_PADDING = 5;
  3410. exports.VERTICAL_PADDING = VERTICAL_PADDING;
  3411. var PresentationModeState = {
  3412. UNKNOWN: 0,
  3413. NORMAL: 1,
  3414. CHANGING: 2,
  3415. FULLSCREEN: 3
  3416. };
  3417. exports.PresentationModeState = PresentationModeState;
  3418. var RendererType = {
  3419. CANVAS: 'canvas',
  3420. SVG: 'svg'
  3421. };
  3422. exports.RendererType = RendererType;
  3423. var TextLayerMode = {
  3424. DISABLE: 0,
  3425. ENABLE: 1,
  3426. ENABLE_ENHANCE: 2
  3427. };
  3428. exports.TextLayerMode = TextLayerMode;
  3429. var ScrollMode = {
  3430. UNKNOWN: -1,
  3431. VERTICAL: 0,
  3432. HORIZONTAL: 1,
  3433. WRAPPED: 2
  3434. };
  3435. exports.ScrollMode = ScrollMode;
  3436. var SpreadMode = {
  3437. UNKNOWN: -1,
  3438. NONE: 0,
  3439. ODD: 1,
  3440. EVEN: 2
  3441. };
  3442. exports.SpreadMode = SpreadMode;
  3443. function formatL10nValue(text, args) {
  3444. if (!args) {
  3445. return text;
  3446. }
  3447. return text.replace(/\{\{\s*(\w+)\s*\}\}/g, function(all, name) {
  3448. return name in args ? args[name] : '{{' + name + '}}';
  3449. });
  3450. }
  3451. var NullL10n = {
  3452. getLanguage: function() {
  3453. var _getLanguage = _asyncToGenerator(
  3454. /*#__PURE__*/
  3455. _regenerator["default"].mark(function _callee() {
  3456. return _regenerator["default"].wrap(function _callee$(_context) {
  3457. while (1) {
  3458. switch (_context.prev = _context.next) {
  3459. case 0:
  3460. return _context.abrupt("return", 'en-us');
  3461. case 1:
  3462. case "end":
  3463. return _context.stop();
  3464. }
  3465. }
  3466. }, _callee);
  3467. }));
  3468. function getLanguage() {
  3469. return _getLanguage.apply(this, arguments);
  3470. }
  3471. return getLanguage;
  3472. }(),
  3473. getDirection: function() {
  3474. var _getDirection = _asyncToGenerator(
  3475. /*#__PURE__*/
  3476. _regenerator["default"].mark(function _callee2() {
  3477. return _regenerator["default"].wrap(function _callee2$(_context2) {
  3478. while (1) {
  3479. switch (_context2.prev = _context2.next) {
  3480. case 0:
  3481. return _context2.abrupt("return", 'ltr');
  3482. case 1:
  3483. case "end":
  3484. return _context2.stop();
  3485. }
  3486. }
  3487. }, _callee2);
  3488. }));
  3489. function getDirection() {
  3490. return _getDirection.apply(this, arguments);
  3491. }
  3492. return getDirection;
  3493. }(),
  3494. get: function() {
  3495. var _get = _asyncToGenerator(
  3496. /*#__PURE__*/
  3497. _regenerator["default"].mark(function _callee3(property, args, fallback) {
  3498. return _regenerator["default"].wrap(function _callee3$(_context3) {
  3499. while (1) {
  3500. switch (_context3.prev = _context3.next) {
  3501. case 0:
  3502. return _context3.abrupt("return",
  3503. formatL10nValue(fallback, args));
  3504. case 1:
  3505. case "end":
  3506. return _context3.stop();
  3507. }
  3508. }
  3509. }, _callee3);
  3510. }));
  3511. function get(_x, _x2, _x3) {
  3512. return _get.apply(this, arguments);
  3513. }
  3514. return get;
  3515. }(),
  3516. translate: function() {
  3517. var _translate = _asyncToGenerator(
  3518. /*#__PURE__*/
  3519. _regenerator["default"].mark(function _callee4(element) {
  3520. return _regenerator["default"].wrap(function _callee4$(_context4) {
  3521. while (1) {
  3522. switch (_context4.prev = _context4.next) {
  3523. case 0:
  3524. case "end":
  3525. return _context4.stop();
  3526. }
  3527. }
  3528. }, _callee4);
  3529. }));
  3530. function translate(_x4) {
  3531. return _translate.apply(this, arguments);
  3532. }
  3533. return translate;
  3534. }()
  3535. };
  3536. exports.NullL10n = NullL10n;
  3537. function getOutputScale(ctx) {
  3538. var devicePixelRatio = window.devicePixelRatio || 1;
  3539. var backingStoreRatio = ctx.webkitBackingStorePixelRatio || ctx.mozBackingStorePixelRatio || ctx
  3540. .msBackingStorePixelRatio || ctx.oBackingStorePixelRatio || ctx.backingStorePixelRatio || 1;
  3541. var pixelRatio = devicePixelRatio / backingStoreRatio;
  3542. return {
  3543. sx: pixelRatio,
  3544. sy: pixelRatio,
  3545. scaled: pixelRatio !== 1
  3546. };
  3547. }
  3548. function scrollIntoView(element, spot) {
  3549. var skipOverflowHiddenElements = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] :
  3550. false;
  3551. var parent = element.offsetParent;
  3552. if (!parent) {
  3553. console.error('offsetParent is not set -- cannot scroll');
  3554. return;
  3555. }
  3556. var offsetY = element.offsetTop + element.clientTop;
  3557. var offsetX = element.offsetLeft + element.clientLeft;
  3558. while (parent.clientHeight === parent.scrollHeight && parent.clientWidth === parent.scrollWidth ||
  3559. skipOverflowHiddenElements && getComputedStyle(parent).overflow === 'hidden') {
  3560. if (parent.dataset._scaleY) {
  3561. offsetY /= parent.dataset._scaleY;
  3562. offsetX /= parent.dataset._scaleX;
  3563. }
  3564. offsetY += parent.offsetTop;
  3565. offsetX += parent.offsetLeft;
  3566. parent = parent.offsetParent;
  3567. if (!parent) {
  3568. return;
  3569. }
  3570. }
  3571. if (spot) {
  3572. if (spot.top !== undefined) {
  3573. offsetY += spot.top;
  3574. }
  3575. if (spot.left !== undefined) {
  3576. offsetX += spot.left;
  3577. parent.scrollLeft = offsetX;
  3578. }
  3579. }
  3580. parent.scrollTop = offsetY;
  3581. }
  3582. function watchScroll(viewAreaElement, callback) {
  3583. var debounceScroll = function debounceScroll(evt) {
  3584. if (rAF) {
  3585. return;
  3586. }
  3587. rAF = window.requestAnimationFrame(function viewAreaElementScrolled() {
  3588. rAF = null;
  3589. var currentX = viewAreaElement.scrollLeft;
  3590. var lastX = state.lastX;
  3591. if (currentX !== lastX) {
  3592. state.right = currentX > lastX;
  3593. }
  3594. state.lastX = currentX;
  3595. var currentY = viewAreaElement.scrollTop;
  3596. var lastY = state.lastY;
  3597. if (currentY !== lastY) {
  3598. state.down = currentY > lastY;
  3599. }
  3600. state.lastY = currentY;
  3601. callback(state);
  3602. });
  3603. };
  3604. var state = {
  3605. right: true,
  3606. down: true,
  3607. lastX: viewAreaElement.scrollLeft,
  3608. lastY: viewAreaElement.scrollTop,
  3609. _eventHandler: debounceScroll
  3610. };
  3611. var rAF = null;
  3612. viewAreaElement.addEventListener('scroll', debounceScroll, true);
  3613. return state;
  3614. }
  3615. function parseQueryString(query) {
  3616. var parts = query.split('&');
  3617. var params = Object.create(null);
  3618. for (var i = 0, ii = parts.length; i < ii; ++i) {
  3619. var param = parts[i].split('=');
  3620. var key = param[0].toLowerCase();
  3621. var value = param.length > 1 ? param[1] : null;
  3622. params[decodeURIComponent(key)] = decodeURIComponent(value);
  3623. }
  3624. return params;
  3625. }
  3626. function binarySearchFirstItem(items, condition) {
  3627. var minIndex = 0;
  3628. var maxIndex = items.length - 1;
  3629. if (items.length === 0 || !condition(items[maxIndex])) {
  3630. return items.length;
  3631. }
  3632. if (condition(items[minIndex])) {
  3633. return minIndex;
  3634. }
  3635. while (minIndex < maxIndex) {
  3636. var currentIndex = minIndex + maxIndex >> 1;
  3637. var currentItem = items[currentIndex];
  3638. if (condition(currentItem)) {
  3639. maxIndex = currentIndex;
  3640. } else {
  3641. minIndex = currentIndex + 1;
  3642. }
  3643. }
  3644. return minIndex;
  3645. }
  3646. function approximateFraction(x) {
  3647. if (Math.floor(x) === x) {
  3648. return [x, 1];
  3649. }
  3650. var xinv = 1 / x;
  3651. var limit = 8;
  3652. if (xinv > limit) {
  3653. return [1, limit];
  3654. } else if (Math.floor(xinv) === xinv) {
  3655. return [1, xinv];
  3656. }
  3657. var x_ = x > 1 ? xinv : x;
  3658. var a = 0,
  3659. b = 1,
  3660. c = 1,
  3661. d = 1;
  3662. while (true) {
  3663. var p = a + c,
  3664. q = b + d;
  3665. if (q > limit) {
  3666. break;
  3667. }
  3668. if (x_ <= p / q) {
  3669. c = p;
  3670. d = q;
  3671. } else {
  3672. a = p;
  3673. b = q;
  3674. }
  3675. }
  3676. var result;
  3677. if (x_ - a / b < c / d - x_) {
  3678. result = x_ === x ? [a, b] : [b, a];
  3679. } else {
  3680. result = x_ === x ? [c, d] : [d, c];
  3681. }
  3682. return result;
  3683. }
  3684. function roundToDivide(x, div) {
  3685. var r = x % div;
  3686. return r === 0 ? x : Math.round(x - r + div);
  3687. }
  3688. function getPageSizeInches(_ref) {
  3689. var view = _ref.view,
  3690. userUnit = _ref.userUnit,
  3691. rotate = _ref.rotate;
  3692. var _view = _slicedToArray(view, 4),
  3693. x1 = _view[0],
  3694. y1 = _view[1],
  3695. x2 = _view[2],
  3696. y2 = _view[3];
  3697. var changeOrientation = rotate % 180 !== 0;
  3698. var width = (x2 - x1) / 72 * userUnit;
  3699. var height = (y2 - y1) / 72 * userUnit;
  3700. return {
  3701. width: changeOrientation ? height : width,
  3702. height: changeOrientation ? width : height
  3703. };
  3704. }
  3705. function backtrackBeforeAllVisibleElements(index, views, top) {
  3706. if (index < 2) {
  3707. return index;
  3708. }
  3709. var elt = views[index].div;
  3710. var pageTop = elt.offsetTop + elt.clientTop;
  3711. if (pageTop >= top) {
  3712. elt = views[index - 1].div;
  3713. pageTop = elt.offsetTop + elt.clientTop;
  3714. }
  3715. for (var i = index - 2; i >= 0; --i) {
  3716. elt = views[i].div;
  3717. if (elt.offsetTop + elt.clientTop + elt.clientHeight <= pageTop) {
  3718. break;
  3719. }
  3720. index = i;
  3721. }
  3722. return index;
  3723. }
  3724. function getVisibleElements(scrollEl, views) {
  3725. var sortByVisibility = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  3726. var horizontal = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
  3727. var top = scrollEl.scrollTop,
  3728. bottom = top + scrollEl.clientHeight;
  3729. var left = scrollEl.scrollLeft,
  3730. right = left + scrollEl.clientWidth;
  3731. function isElementBottomAfterViewTop(view) {
  3732. var element = view.div;
  3733. var elementBottom = element.offsetTop + element.clientTop + element.clientHeight;
  3734. return elementBottom > top;
  3735. }
  3736. function isElementRightAfterViewLeft(view) {
  3737. var element = view.div;
  3738. var elementRight = element.offsetLeft + element.clientLeft + element.clientWidth;
  3739. return elementRight > left;
  3740. }
  3741. var visible = [],
  3742. numViews = views.length;
  3743. var firstVisibleElementInd = numViews === 0 ? 0 : binarySearchFirstItem(views, horizontal ?
  3744. isElementRightAfterViewLeft : isElementBottomAfterViewTop);
  3745. if (firstVisibleElementInd > 0 && firstVisibleElementInd < numViews && !horizontal) {
  3746. firstVisibleElementInd = backtrackBeforeAllVisibleElements(firstVisibleElementInd, views, top);
  3747. }
  3748. var lastEdge = horizontal ? right : -1;
  3749. for (var i = firstVisibleElementInd; i < numViews; i++) {
  3750. var view = views[i],
  3751. element = view.div;
  3752. var currentWidth = element.offsetLeft + element.clientLeft;
  3753. var currentHeight = element.offsetTop + element.clientTop;
  3754. var viewWidth = element.clientWidth,
  3755. viewHeight = element.clientHeight;
  3756. var viewRight = currentWidth + viewWidth;
  3757. var viewBottom = currentHeight + viewHeight;
  3758. if (lastEdge === -1) {
  3759. if (viewBottom >= bottom) {
  3760. lastEdge = viewBottom;
  3761. }
  3762. } else if ((horizontal ? currentWidth : currentHeight) > lastEdge) {
  3763. break;
  3764. }
  3765. if (viewBottom <= top || currentHeight >= bottom || viewRight <= left || currentWidth >=
  3766. right) {
  3767. continue;
  3768. }
  3769. var hiddenHeight = Math.max(0, top - currentHeight) + Math.max(0, viewBottom - bottom);
  3770. var hiddenWidth = Math.max(0, left - currentWidth) + Math.max(0, viewRight - right);
  3771. var percent = (viewHeight - hiddenHeight) * (viewWidth - hiddenWidth) * 100 / viewHeight /
  3772. viewWidth | 0;
  3773. visible.push({
  3774. id: view.id,
  3775. x: currentWidth,
  3776. y: currentHeight,
  3777. view: view,
  3778. percent: percent
  3779. });
  3780. }
  3781. var first = visible[0],
  3782. last = visible[visible.length - 1];
  3783. if (sortByVisibility) {
  3784. visible.sort(function(a, b) {
  3785. var pc = a.percent - b.percent;
  3786. if (Math.abs(pc) > 0.001) {
  3787. return -pc;
  3788. }
  3789. return a.id - b.id;
  3790. });
  3791. }
  3792. return {
  3793. first: first,
  3794. last: last,
  3795. views: visible
  3796. };
  3797. }
  3798. function noContextMenuHandler(evt) {
  3799. evt.preventDefault();
  3800. }
  3801. function isDataSchema(url) {
  3802. var i = 0,
  3803. ii = url.length;
  3804. while (i < ii && url[i].trim() === '') {
  3805. i++;
  3806. }
  3807. return url.substring(i, i + 5).toLowerCase() === 'data:';
  3808. }
  3809. function getPDFFileNameFromURL(url) {
  3810. var defaultFilename = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] :
  3811. 'document.pdf';
  3812. if (typeof url !== 'string') {
  3813. return defaultFilename;
  3814. }
  3815. if (isDataSchema(url)) {
  3816. console.warn('getPDFFileNameFromURL: ' + 'ignoring "data:" URL for performance reasons.');
  3817. return defaultFilename;
  3818. }
  3819. var reURI = /^(?:(?:[^:]+:)?\/\/[^\/]+)?([^?#]*)(\?[^#]*)?(#.*)?$/;
  3820. var reFilename = /[^\/?#=]+\.pdf\b(?!.*\.pdf\b)/i;
  3821. var splitURI = reURI.exec(url);
  3822. var suggestedFilename = reFilename.exec(splitURI[1]) || reFilename.exec(splitURI[2]) || reFilename
  3823. .exec(splitURI[3]);
  3824. if (suggestedFilename) {
  3825. suggestedFilename = suggestedFilename[0];
  3826. if (suggestedFilename.includes('%')) {
  3827. try {
  3828. suggestedFilename = reFilename.exec(decodeURIComponent(suggestedFilename))[0];
  3829. } catch (ex) {}
  3830. }
  3831. }
  3832. return suggestedFilename || defaultFilename;
  3833. }
  3834. function normalizeWheelEventDelta(evt) {
  3835. var delta = Math.sqrt(evt.deltaX * evt.deltaX + evt.deltaY * evt.deltaY);
  3836. var angle = Math.atan2(evt.deltaY, evt.deltaX);
  3837. if (-0.25 * Math.PI < angle && angle < 0.75 * Math.PI) {
  3838. delta = -delta;
  3839. }
  3840. var MOUSE_DOM_DELTA_PIXEL_MODE = 0;
  3841. var MOUSE_DOM_DELTA_LINE_MODE = 1;
  3842. var MOUSE_PIXELS_PER_LINE = 30;
  3843. var MOUSE_LINES_PER_PAGE = 30;
  3844. if (evt.deltaMode === MOUSE_DOM_DELTA_PIXEL_MODE) {
  3845. delta /= MOUSE_PIXELS_PER_LINE * MOUSE_LINES_PER_PAGE;
  3846. } else if (evt.deltaMode === MOUSE_DOM_DELTA_LINE_MODE) {
  3847. delta /= MOUSE_LINES_PER_PAGE;
  3848. }
  3849. return delta;
  3850. }
  3851. function isValidRotation(angle) {
  3852. return Number.isInteger(angle) && angle % 90 === 0;
  3853. }
  3854. function isValidScrollMode(mode) {
  3855. return Number.isInteger(mode) && Object.values(ScrollMode).includes(mode) && mode !== ScrollMode
  3856. .UNKNOWN;
  3857. }
  3858. function isValidSpreadMode(mode) {
  3859. return Number.isInteger(mode) && Object.values(SpreadMode).includes(mode) && mode !== SpreadMode
  3860. .UNKNOWN;
  3861. }
  3862. function isPortraitOrientation(size) {
  3863. return size.width <= size.height;
  3864. }
  3865. var WaitOnType = {
  3866. EVENT: 'event',
  3867. TIMEOUT: 'timeout'
  3868. };
  3869. exports.WaitOnType = WaitOnType;
  3870. function waitOnEventOrTimeout(_ref2) {
  3871. var target = _ref2.target,
  3872. name = _ref2.name,
  3873. _ref2$delay = _ref2.delay,
  3874. delay = _ref2$delay === void 0 ? 0 : _ref2$delay;
  3875. return new Promise(function(resolve, reject) {
  3876. if (_typeof(target) !== 'object' || !(name && typeof name === 'string') || !(Number
  3877. .isInteger(delay) && delay >= 0)) {
  3878. throw new Error('waitOnEventOrTimeout - invalid parameters.');
  3879. }
  3880. function handler(type) {
  3881. if (target instanceof EventBus) {
  3882. target.off(name, eventHandler);
  3883. } else {
  3884. target.removeEventListener(name, eventHandler);
  3885. }
  3886. if (timeout) {
  3887. clearTimeout(timeout);
  3888. }
  3889. resolve(type);
  3890. }
  3891. var eventHandler = handler.bind(null, WaitOnType.EVENT);
  3892. if (target instanceof EventBus) {
  3893. target.on(name, eventHandler);
  3894. } else {
  3895. target.addEventListener(name, eventHandler);
  3896. }
  3897. var timeoutHandler = handler.bind(null, WaitOnType.TIMEOUT);
  3898. var timeout = setTimeout(timeoutHandler, delay);
  3899. });
  3900. }
  3901. var animationStarted = new Promise(function(resolve) {
  3902. window.requestAnimationFrame(resolve);
  3903. });
  3904. exports.animationStarted = animationStarted;
  3905. var EventBus =
  3906. /*#__PURE__*/
  3907. function() {
  3908. function EventBus() {
  3909. var _ref3 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
  3910. _ref3$dispatchToDOM = _ref3.dispatchToDOM,
  3911. dispatchToDOM = _ref3$dispatchToDOM === void 0 ? false : _ref3$dispatchToDOM;
  3912. _classCallCheck(this, EventBus);
  3913. this._listeners = Object.create(null);
  3914. this._dispatchToDOM = dispatchToDOM === true;
  3915. }
  3916. _createClass(EventBus, [{
  3917. key: "on",
  3918. value: function on(eventName, listener) {
  3919. var eventListeners = this._listeners[eventName];
  3920. if (!eventListeners) {
  3921. eventListeners = [];
  3922. this._listeners[eventName] = eventListeners;
  3923. }
  3924. eventListeners.push(listener);
  3925. }
  3926. }, {
  3927. key: "off",
  3928. value: function off(eventName, listener) {
  3929. var eventListeners = this._listeners[eventName];
  3930. var i;
  3931. if (!eventListeners || (i = eventListeners.indexOf(listener)) < 0) {
  3932. return;
  3933. }
  3934. eventListeners.splice(i, 1);
  3935. }
  3936. }, {
  3937. key: "dispatch",
  3938. value: function dispatch(eventName) {
  3939. var eventListeners = this._listeners[eventName];
  3940. if (!eventListeners || eventListeners.length === 0) {
  3941. if (this._dispatchToDOM) {
  3942. var _args5 = Array.prototype.slice.call(arguments, 1);
  3943. this._dispatchDOMEvent(eventName, _args5);
  3944. }
  3945. return;
  3946. }
  3947. var args = Array.prototype.slice.call(arguments, 1);
  3948. eventListeners.slice(0).forEach(function(listener) {
  3949. listener.apply(null, args);
  3950. });
  3951. if (this._dispatchToDOM) {
  3952. this._dispatchDOMEvent(eventName, args);
  3953. }
  3954. }
  3955. }, {
  3956. key: "_dispatchDOMEvent",
  3957. value: function _dispatchDOMEvent(eventName) {
  3958. var args = arguments.length > 1 && arguments[1] !== undefined ?
  3959. arguments[1] : null;
  3960. var details = Object.create(null);
  3961. if (args && args.length > 0) {
  3962. var obj = args[0];
  3963. for (var key in obj) {
  3964. var value = obj[key];
  3965. if (key === 'source') {
  3966. if (value === window || value === document) {
  3967. return;
  3968. }
  3969. continue;
  3970. }
  3971. details[key] = value;
  3972. }
  3973. }
  3974. var event = document.createEvent('CustomEvent');
  3975. event.initCustomEvent(eventName, true, true, details);
  3976. document.dispatchEvent(event);
  3977. }
  3978. }]);
  3979. return EventBus;
  3980. }();
  3981. exports.EventBus = EventBus;
  3982. var globalEventBus = null;
  3983. function getGlobalEventBus() {
  3984. var dispatchToDOM = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  3985. if (!globalEventBus) {
  3986. globalEventBus = new EventBus({
  3987. dispatchToDOM: dispatchToDOM
  3988. });
  3989. }
  3990. return globalEventBus;
  3991. }
  3992. function clamp(v, min, max) {
  3993. return Math.min(Math.max(v, min), max);
  3994. }
  3995. var ProgressBar =
  3996. /*#__PURE__*/
  3997. function() {
  3998. function ProgressBar(id) {
  3999. var _ref4 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
  4000. height = _ref4.height,
  4001. width = _ref4.width,
  4002. units = _ref4.units;
  4003. _classCallCheck(this, ProgressBar);
  4004. this.visible = true;
  4005. this.div = document.querySelector(id + ' .progress');
  4006. this.bar = this.div.parentNode;
  4007. this.height = height || 100;
  4008. this.width = width || 100;
  4009. this.units = units || '%';
  4010. this.div.style.height = this.height + this.units;
  4011. this.percent = 0;
  4012. }
  4013. _createClass(ProgressBar, [{
  4014. key: "_updateBar",
  4015. value: function _updateBar() {
  4016. if (this._indeterminate) {
  4017. this.div.classList.add('indeterminate');
  4018. this.div.style.width = this.width + this.units;
  4019. return;
  4020. }
  4021. this.div.classList.remove('indeterminate');
  4022. var progressSize = this.width * this._percent / 100;
  4023. this.div.style.width = progressSize + this.units;
  4024. }
  4025. }, {
  4026. key: "setWidth",
  4027. value: function setWidth(viewer) {
  4028. if (!viewer) {
  4029. return;
  4030. }
  4031. var container = viewer.parentNode;
  4032. var scrollbarWidth = container.offsetWidth - viewer.offsetWidth;
  4033. if (scrollbarWidth > 0) {
  4034. this.bar.setAttribute('style', 'width: calc(100% - ' +
  4035. scrollbarWidth + 'px);');
  4036. }
  4037. }
  4038. }, {
  4039. key: "hide",
  4040. value: function hide() {
  4041. if (!this.visible) {
  4042. return;
  4043. }
  4044. this.visible = false;
  4045. this.bar.classList.add('hidden');
  4046. document.body.classList.remove('loadingInProgress');
  4047. }
  4048. }, {
  4049. key: "show",
  4050. value: function show() {
  4051. if (this.visible) {
  4052. return;
  4053. }
  4054. this.visible = true;
  4055. document.body.classList.add('loadingInProgress');
  4056. this.bar.classList.remove('hidden');
  4057. }
  4058. }, {
  4059. key: "percent",
  4060. get: function get() {
  4061. return this._percent;
  4062. },
  4063. set: function set(val) {
  4064. this._indeterminate = isNaN(val);
  4065. this._percent = clamp(val, 0, 100);
  4066. this._updateBar();
  4067. }
  4068. }]);
  4069. return ProgressBar;
  4070. }();
  4071. exports.ProgressBar = ProgressBar;
  4072. function moveToEndOfArray(arr, condition) {
  4073. var moved = [],
  4074. len = arr.length;
  4075. var write = 0;
  4076. for (var read = 0; read < len; ++read) {
  4077. if (condition(arr[read])) {
  4078. moved.push(arr[read]);
  4079. } else {
  4080. arr[write] = arr[read];
  4081. ++write;
  4082. }
  4083. }
  4084. for (var _read = 0; write < len; ++_read, ++write) {
  4085. arr[write] = moved[_read];
  4086. }
  4087. }
  4088. /***/
  4089. }),
  4090. /* 6 */
  4091. /***/
  4092. (function(module, exports, __webpack_require__) {
  4093. "use strict";
  4094. Object.defineProperty(exports, "__esModule", {
  4095. value: true
  4096. });
  4097. exports.OptionKind = exports.AppOptions = void 0;
  4098. var _pdfjsLib = __webpack_require__(7);
  4099. var _viewer_compatibility = __webpack_require__(8);
  4100. function _typeof(obj) {
  4101. if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
  4102. _typeof = function _typeof(obj) {
  4103. return typeof obj;
  4104. };
  4105. } else {
  4106. _typeof = function _typeof(obj) {
  4107. return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !==
  4108. Symbol.prototype ? "symbol" : typeof obj;
  4109. };
  4110. }
  4111. return _typeof(obj);
  4112. }
  4113. function _classCallCheck(instance, Constructor) {
  4114. if (!(instance instanceof Constructor)) {
  4115. throw new TypeError("Cannot call a class as a function");
  4116. }
  4117. }
  4118. function _defineProperties(target, props) {
  4119. for (var i = 0; i < props.length; i++) {
  4120. var descriptor = props[i];
  4121. descriptor.enumerable = descriptor.enumerable || false;
  4122. descriptor.configurable = true;
  4123. if ("value" in descriptor) descriptor.writable = true;
  4124. Object.defineProperty(target, descriptor.key, descriptor);
  4125. }
  4126. }
  4127. function _createClass(Constructor, protoProps, staticProps) {
  4128. if (protoProps) _defineProperties(Constructor.prototype, protoProps);
  4129. if (staticProps) _defineProperties(Constructor, staticProps);
  4130. return Constructor;
  4131. }
  4132. var OptionKind = {
  4133. VIEWER: 0x02,
  4134. API: 0x04,
  4135. WORKER: 0x08,
  4136. PREFERENCE: 0x80
  4137. };
  4138. exports.OptionKind = OptionKind;
  4139. var defaultOptions = {
  4140. cursorToolOnLoad: {
  4141. value: 0,
  4142. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  4143. },
  4144. defaultUrl: {
  4145. value: 'compressed.tracemonkey-pldi-09.pdf',
  4146. kind: OptionKind.VIEWER
  4147. },
  4148. defaultZoomValue: {
  4149. value: '',
  4150. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  4151. },
  4152. disableHistory: {
  4153. value: false,
  4154. kind: OptionKind.VIEWER
  4155. },
  4156. disablePageLabels: {
  4157. value: false,
  4158. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  4159. },
  4160. enablePrintAutoRotate: {
  4161. value: false,
  4162. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  4163. },
  4164. enableWebGL: {
  4165. value: false,
  4166. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  4167. },
  4168. eventBusDispatchToDOM: {
  4169. value: false,
  4170. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  4171. },
  4172. externalLinkRel: {
  4173. value: 'noopener noreferrer nofollow',
  4174. kind: OptionKind.VIEWER
  4175. },
  4176. externalLinkTarget: {
  4177. value: 0,
  4178. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  4179. },
  4180. historyUpdateUrl: {
  4181. value: false,
  4182. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  4183. },
  4184. imageResourcesPath: {
  4185. value: './images/',
  4186. kind: OptionKind.VIEWER
  4187. },
  4188. maxCanvasPixels: {
  4189. value: 16777216,
  4190. compatibility: _viewer_compatibility.viewerCompatibilityParams.maxCanvasPixels,
  4191. kind: OptionKind.VIEWER
  4192. },
  4193. pdfBugEnabled: {
  4194. value: false,
  4195. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  4196. },
  4197. renderer: {
  4198. value: 'canvas',
  4199. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  4200. },
  4201. renderInteractiveForms: {
  4202. value: false,
  4203. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  4204. },
  4205. sidebarViewOnLoad: {
  4206. value: -1,
  4207. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  4208. },
  4209. scrollModeOnLoad: {
  4210. value: -1,
  4211. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  4212. },
  4213. spreadModeOnLoad: {
  4214. value: -1,
  4215. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  4216. },
  4217. textLayerMode: {
  4218. value: 1,
  4219. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  4220. },
  4221. useOnlyCssZoom: {
  4222. value: false,
  4223. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  4224. },
  4225. viewOnLoad: {
  4226. value: 0,
  4227. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  4228. },
  4229. cMapPacked: {
  4230. value: true,
  4231. kind: OptionKind.API
  4232. },
  4233. cMapUrl: {
  4234. value: '../web/cmaps/',
  4235. kind: OptionKind.API
  4236. },
  4237. disableAutoFetch: {
  4238. value: false,
  4239. kind: OptionKind.API + OptionKind.PREFERENCE
  4240. },
  4241. disableCreateObjectURL: {
  4242. value: false,
  4243. compatibility: _pdfjsLib.apiCompatibilityParams.disableCreateObjectURL,
  4244. kind: OptionKind.API
  4245. },
  4246. disableFontFace: {
  4247. value: false,
  4248. kind: OptionKind.API + OptionKind.PREFERENCE
  4249. },
  4250. disableRange: {
  4251. value: false,
  4252. kind: OptionKind.API + OptionKind.PREFERENCE
  4253. },
  4254. disableStream: {
  4255. value: false,
  4256. kind: OptionKind.API + OptionKind.PREFERENCE
  4257. },
  4258. docBaseUrl: {
  4259. value: '',
  4260. kind: OptionKind.API
  4261. },
  4262. isEvalSupported: {
  4263. value: true,
  4264. kind: OptionKind.API
  4265. },
  4266. maxImageSize: {
  4267. value: -1,
  4268. kind: OptionKind.API
  4269. },
  4270. pdfBug: {
  4271. value: false,
  4272. kind: OptionKind.API
  4273. },
  4274. verbosity: {
  4275. value: 1,
  4276. kind: OptionKind.API
  4277. },
  4278. workerPort: {
  4279. value: null,
  4280. kind: OptionKind.WORKER
  4281. },
  4282. workerSrc: {
  4283. value: '../build/pdf.worker.js',
  4284. kind: OptionKind.WORKER
  4285. }
  4286. }; {
  4287. defaultOptions.disablePreferences = {
  4288. value: false,
  4289. kind: OptionKind.VIEWER
  4290. };
  4291. defaultOptions.locale = {
  4292. value: typeof navigator !== 'undefined' ? navigator.language : 'en-US',
  4293. kind: OptionKind.VIEWER
  4294. };
  4295. defaultOptions.printResolution = {
  4296. value: 150,
  4297. kind: OptionKind.VIEWER
  4298. };
  4299. }
  4300. var userOptions = Object.create(null);
  4301. var AppOptions =
  4302. /*#__PURE__*/
  4303. function() {
  4304. function AppOptions() {
  4305. _classCallCheck(this, AppOptions);
  4306. throw new Error('Cannot initialize AppOptions.');
  4307. }
  4308. _createClass(AppOptions, null, [{
  4309. key: "get",
  4310. value: function get(name) {
  4311. var userOption = userOptions[name];
  4312. if (userOption !== undefined) {
  4313. return userOption;
  4314. }
  4315. var defaultOption = defaultOptions[name];
  4316. if (defaultOption !== undefined) {
  4317. return defaultOption.compatibility || defaultOption.value;
  4318. }
  4319. return undefined;
  4320. }
  4321. }, {
  4322. key: "getAll",
  4323. value: function getAll() {
  4324. var kind = arguments.length > 0 && arguments[0] !== undefined ?
  4325. arguments[0] : null;
  4326. var options = Object.create(null);
  4327. for (var name in defaultOptions) {
  4328. var defaultOption = defaultOptions[name];
  4329. if (kind) {
  4330. if ((kind & defaultOption.kind) === 0) {
  4331. continue;
  4332. }
  4333. if (kind === OptionKind.PREFERENCE) {
  4334. var value = defaultOption.value,
  4335. valueType = _typeof(value);
  4336. if (valueType === 'boolean' || valueType === 'string' ||
  4337. valueType === 'number' && Number.isInteger(value)) {
  4338. options[name] = value;
  4339. continue;
  4340. }
  4341. throw new Error("Invalid type for preference: ".concat(
  4342. name));
  4343. }
  4344. }
  4345. var userOption = userOptions[name];
  4346. options[name] = userOption !== undefined ? userOption :
  4347. defaultOption.compatibility || defaultOption.value;
  4348. }
  4349. return options;
  4350. }
  4351. }, {
  4352. key: "set",
  4353. value: function set(name, value) {
  4354. userOptions[name] = value;
  4355. }
  4356. }, {
  4357. key: "remove",
  4358. value: function remove(name) {
  4359. delete userOptions[name];
  4360. }
  4361. }]);
  4362. return AppOptions;
  4363. }();
  4364. exports.AppOptions = AppOptions;
  4365. /***/
  4366. }),
  4367. /* 7 */
  4368. /***/
  4369. (function(module, exports, __webpack_require__) {
  4370. "use strict";
  4371. var pdfjsLib;
  4372. if (typeof window !== 'undefined' && window['pdfjs-dist/build/pdf']) {
  4373. pdfjsLib = window['pdfjs-dist/build/pdf'];
  4374. } else {
  4375. pdfjsLib = require('../build/pdf.js');
  4376. }
  4377. module.exports = pdfjsLib;
  4378. /***/
  4379. }),
  4380. /* 8 */
  4381. /***/
  4382. (function(module, exports, __webpack_require__) {
  4383. "use strict";
  4384. var compatibilityParams = Object.create(null); {
  4385. var userAgent = typeof navigator !== 'undefined' && navigator.userAgent || '';
  4386. var isAndroid = /Android/.test(userAgent);
  4387. var isIOS = /\b(iPad|iPhone|iPod)(?=;)/.test(userAgent);
  4388. (function checkCanvasSizeLimitation() {
  4389. if (isIOS || isAndroid) {
  4390. compatibilityParams.maxCanvasPixels = 5242880;
  4391. }
  4392. })();
  4393. }
  4394. exports.viewerCompatibilityParams = Object.freeze(compatibilityParams);
  4395. /***/
  4396. }),
  4397. /* 9 */
  4398. /***/
  4399. (function(module, exports, __webpack_require__) {
  4400. "use strict";
  4401. Object.defineProperty(exports, "__esModule", {
  4402. value: true
  4403. });
  4404. exports.PDFCursorTools = exports.CursorTool = void 0;
  4405. var _grab_to_pan = __webpack_require__(10);
  4406. function _classCallCheck(instance, Constructor) {
  4407. if (!(instance instanceof Constructor)) {
  4408. throw new TypeError("Cannot call a class as a function");
  4409. }
  4410. }
  4411. function _defineProperties(target, props) {
  4412. for (var i = 0; i < props.length; i++) {
  4413. var descriptor = props[i];
  4414. descriptor.enumerable = descriptor.enumerable || false;
  4415. descriptor.configurable = true;
  4416. if ("value" in descriptor) descriptor.writable = true;
  4417. Object.defineProperty(target, descriptor.key, descriptor);
  4418. }
  4419. }
  4420. function _createClass(Constructor, protoProps, staticProps) {
  4421. if (protoProps) _defineProperties(Constructor.prototype, protoProps);
  4422. if (staticProps) _defineProperties(Constructor, staticProps);
  4423. return Constructor;
  4424. }
  4425. var CursorTool = {
  4426. SELECT: 0,
  4427. HAND: 1,
  4428. ZOOM: 2
  4429. };
  4430. exports.CursorTool = CursorTool;
  4431. var PDFCursorTools =
  4432. /*#__PURE__*/
  4433. function() {
  4434. function PDFCursorTools(_ref) {
  4435. var _this = this;
  4436. var container = _ref.container,
  4437. eventBus = _ref.eventBus,
  4438. _ref$cursorToolOnLoad = _ref.cursorToolOnLoad,
  4439. cursorToolOnLoad = _ref$cursorToolOnLoad === void 0 ? CursorTool.SELECT :
  4440. _ref$cursorToolOnLoad;
  4441. _classCallCheck(this, PDFCursorTools);
  4442. this.container = container;
  4443. this.eventBus = eventBus;
  4444. this.active = CursorTool.SELECT;
  4445. this.activeBeforePresentationMode = null;
  4446. this.handTool = new _grab_to_pan.GrabToPan({
  4447. element: this.container
  4448. });
  4449. this._addEventListeners();
  4450. Promise.resolve().then(function() {
  4451. _this.switchTool(cursorToolOnLoad);
  4452. });
  4453. }
  4454. _createClass(PDFCursorTools, [{
  4455. key: "switchTool",
  4456. value: function switchTool(tool) {
  4457. var _this2 = this;
  4458. if (this.activeBeforePresentationMode !== null) {
  4459. return;
  4460. }
  4461. if (tool === this.active) {
  4462. return;
  4463. }
  4464. var disableActiveTool = function disableActiveTool() {
  4465. switch (_this2.active) {
  4466. case CursorTool.SELECT:
  4467. break;
  4468. case CursorTool.HAND:
  4469. _this2.handTool.deactivate();
  4470. break;
  4471. case CursorTool.ZOOM:
  4472. }
  4473. };
  4474. switch (tool) {
  4475. case CursorTool.SELECT:
  4476. disableActiveTool();
  4477. break;
  4478. case CursorTool.HAND:
  4479. disableActiveTool();
  4480. this.handTool.activate();
  4481. break;
  4482. case CursorTool.ZOOM:
  4483. default:
  4484. console.error("switchTool: \"".concat(tool,
  4485. "\" is an unsupported value."));
  4486. return;
  4487. }
  4488. this.active = tool;
  4489. this._dispatchEvent();
  4490. }
  4491. }, {
  4492. key: "_dispatchEvent",
  4493. value: function _dispatchEvent() {
  4494. this.eventBus.dispatch('cursortoolchanged', {
  4495. source: this,
  4496. tool: this.active
  4497. });
  4498. }
  4499. }, {
  4500. key: "_addEventListeners",
  4501. value: function _addEventListeners() {
  4502. var _this3 = this;
  4503. this.eventBus.on('switchcursortool', function(evt) {
  4504. _this3.switchTool(evt.tool);
  4505. });
  4506. this.eventBus.on('presentationmodechanged', function(evt) {
  4507. if (evt.switchInProgress) {
  4508. return;
  4509. }
  4510. var previouslyActive;
  4511. if (evt.active) {
  4512. previouslyActive = _this3.active;
  4513. _this3.switchTool(CursorTool.SELECT);
  4514. _this3.activeBeforePresentationMode = previouslyActive;
  4515. } else {
  4516. previouslyActive = _this3.activeBeforePresentationMode;
  4517. _this3.activeBeforePresentationMode = null;
  4518. _this3.switchTool(previouslyActive);
  4519. }
  4520. });
  4521. }
  4522. }, {
  4523. key: "activeTool",
  4524. get: function get() {
  4525. return this.active;
  4526. }
  4527. }]);
  4528. return PDFCursorTools;
  4529. }();
  4530. exports.PDFCursorTools = PDFCursorTools;
  4531. /***/
  4532. }),
  4533. /* 10 */
  4534. /***/
  4535. (function(module, exports, __webpack_require__) {
  4536. "use strict";
  4537. Object.defineProperty(exports, "__esModule", {
  4538. value: true
  4539. });
  4540. exports.GrabToPan = GrabToPan;
  4541. function GrabToPan(options) {
  4542. this.element = options.element;
  4543. this.document = options.element.ownerDocument;
  4544. if (typeof options.ignoreTarget === 'function') {
  4545. this.ignoreTarget = options.ignoreTarget;
  4546. }
  4547. this.onActiveChanged = options.onActiveChanged;
  4548. this.activate = this.activate.bind(this);
  4549. this.deactivate = this.deactivate.bind(this);
  4550. this.toggle = this.toggle.bind(this);
  4551. this._onmousedown = this._onmousedown.bind(this);
  4552. this._onmousemove = this._onmousemove.bind(this);
  4553. this._endPan = this._endPan.bind(this);
  4554. var overlay = this.overlay = document.createElement('div');
  4555. overlay.className = 'grab-to-pan-grabbing';
  4556. }
  4557. GrabToPan.prototype = {
  4558. CSS_CLASS_GRAB: 'grab-to-pan-grab',
  4559. activate: function GrabToPan_activate() {
  4560. if (!this.active) {
  4561. this.active = true;
  4562. this.element.addEventListener('mousedown', this._onmousedown, true);
  4563. this.element.classList.add(this.CSS_CLASS_GRAB);
  4564. if (this.onActiveChanged) {
  4565. this.onActiveChanged(true);
  4566. }
  4567. }
  4568. },
  4569. deactivate: function GrabToPan_deactivate() {
  4570. if (this.active) {
  4571. this.active = false;
  4572. this.element.removeEventListener('mousedown', this._onmousedown, true);
  4573. this._endPan();
  4574. this.element.classList.remove(this.CSS_CLASS_GRAB);
  4575. if (this.onActiveChanged) {
  4576. this.onActiveChanged(false);
  4577. }
  4578. }
  4579. },
  4580. toggle: function GrabToPan_toggle() {
  4581. if (this.active) {
  4582. this.deactivate();
  4583. } else {
  4584. this.activate();
  4585. }
  4586. },
  4587. ignoreTarget: function GrabToPan_ignoreTarget(node) {
  4588. return node[matchesSelector](
  4589. 'a[href], a[href] *, input, textarea, button, button *, select, option');
  4590. },
  4591. _onmousedown: function GrabToPan__onmousedown(event) {
  4592. if (event.button !== 0 || this.ignoreTarget(event.target)) {
  4593. return;
  4594. }
  4595. if (event.originalTarget) {
  4596. try {
  4597. event.originalTarget.tagName;
  4598. } catch (e) {
  4599. return;
  4600. }
  4601. }
  4602. this.scrollLeftStart = this.element.scrollLeft;
  4603. this.scrollTopStart = this.element.scrollTop;
  4604. this.clientXStart = event.clientX;
  4605. this.clientYStart = event.clientY;
  4606. this.document.addEventListener('mousemove', this._onmousemove, true);
  4607. this.document.addEventListener('mouseup', this._endPan, true);
  4608. this.element.addEventListener('scroll', this._endPan, true);
  4609. event.preventDefault();
  4610. event.stopPropagation();
  4611. var focusedElement = document.activeElement;
  4612. if (focusedElement && !focusedElement.contains(event.target)) {
  4613. focusedElement.blur();
  4614. }
  4615. },
  4616. _onmousemove: function GrabToPan__onmousemove(event) {
  4617. this.element.removeEventListener('scroll', this._endPan, true);
  4618. if (isLeftMouseReleased(event)) {
  4619. this._endPan();
  4620. return;
  4621. }
  4622. var xDiff = event.clientX - this.clientXStart;
  4623. var yDiff = event.clientY - this.clientYStart;
  4624. var scrollTop = this.scrollTopStart - yDiff;
  4625. var scrollLeft = this.scrollLeftStart - xDiff;
  4626. if (this.element.scrollTo) {
  4627. this.element.scrollTo({
  4628. top: scrollTop,
  4629. left: scrollLeft,
  4630. behavior: 'instant'
  4631. });
  4632. } else {
  4633. this.element.scrollTop = scrollTop;
  4634. this.element.scrollLeft = scrollLeft;
  4635. }
  4636. if (!this.overlay.parentNode) {
  4637. document.body.appendChild(this.overlay);
  4638. }
  4639. },
  4640. _endPan: function GrabToPan__endPan() {
  4641. this.element.removeEventListener('scroll', this._endPan, true);
  4642. this.document.removeEventListener('mousemove', this._onmousemove, true);
  4643. this.document.removeEventListener('mouseup', this._endPan, true);
  4644. this.overlay.remove();
  4645. }
  4646. };
  4647. var matchesSelector;
  4648. ['webkitM', 'mozM', 'msM', 'oM', 'm'].some(function(prefix) {
  4649. var name = prefix + 'atches';
  4650. if (name in document.documentElement) {
  4651. matchesSelector = name;
  4652. }
  4653. name += 'Selector';
  4654. if (name in document.documentElement) {
  4655. matchesSelector = name;
  4656. }
  4657. return matchesSelector;
  4658. });
  4659. var isNotIEorIsIE10plus = !document.documentMode || document.documentMode > 9;
  4660. var chrome = window.chrome;
  4661. var isChrome15OrOpera15plus = chrome && (chrome.webstore || chrome.app);
  4662. var isSafari6plus = /Apple/.test(navigator.vendor) && /Version\/([6-9]\d*|[1-5]\d+)/.test(navigator
  4663. .userAgent);
  4664. function isLeftMouseReleased(event) {
  4665. if ('buttons' in event && isNotIEorIsIE10plus) {
  4666. return !(event.buttons & 1);
  4667. }
  4668. if (isChrome15OrOpera15plus || isSafari6plus) {
  4669. return event.which === 0;
  4670. }
  4671. return false;
  4672. }
  4673. /***/
  4674. }),
  4675. /* 11 */
  4676. /***/
  4677. (function(module, exports, __webpack_require__) {
  4678. "use strict";
  4679. Object.defineProperty(exports, "__esModule", {
  4680. value: true
  4681. });
  4682. exports.PDFRenderingQueue = exports.RenderingStates = void 0;
  4683. function _classCallCheck(instance, Constructor) {
  4684. if (!(instance instanceof Constructor)) {
  4685. throw new TypeError("Cannot call a class as a function");
  4686. }
  4687. }
  4688. function _defineProperties(target, props) {
  4689. for (var i = 0; i < props.length; i++) {
  4690. var descriptor = props[i];
  4691. descriptor.enumerable = descriptor.enumerable || false;
  4692. descriptor.configurable = true;
  4693. if ("value" in descriptor) descriptor.writable = true;
  4694. Object.defineProperty(target, descriptor.key, descriptor);
  4695. }
  4696. }
  4697. function _createClass(Constructor, protoProps, staticProps) {
  4698. if (protoProps) _defineProperties(Constructor.prototype, protoProps);
  4699. if (staticProps) _defineProperties(Constructor, staticProps);
  4700. return Constructor;
  4701. }
  4702. var CLEANUP_TIMEOUT = 30000;
  4703. var RenderingStates = {
  4704. INITIAL: 0,
  4705. RUNNING: 1,
  4706. PAUSED: 2,
  4707. FINISHED: 3
  4708. };
  4709. exports.RenderingStates = RenderingStates;
  4710. var PDFRenderingQueue =
  4711. /*#__PURE__*/
  4712. function() {
  4713. function PDFRenderingQueue() {
  4714. _classCallCheck(this, PDFRenderingQueue);
  4715. this.pdfViewer = null;
  4716. this.pdfThumbnailViewer = null;
  4717. this.onIdle = null;
  4718. this.highestPriorityPage = null;
  4719. this.idleTimeout = null;
  4720. this.printing = false;
  4721. this.isThumbnailViewEnabled = false;
  4722. }
  4723. _createClass(PDFRenderingQueue, [{
  4724. key: "setViewer",
  4725. value: function setViewer(pdfViewer) {
  4726. this.pdfViewer = pdfViewer;
  4727. }
  4728. }, {
  4729. key: "setThumbnailViewer",
  4730. value: function setThumbnailViewer(pdfThumbnailViewer) {
  4731. this.pdfThumbnailViewer = pdfThumbnailViewer;
  4732. }
  4733. }, {
  4734. key: "isHighestPriority",
  4735. value: function isHighestPriority(view) {
  4736. return this.highestPriorityPage === view.renderingId;
  4737. }
  4738. }, {
  4739. key: "renderHighestPriority",
  4740. value: function renderHighestPriority(currentlyVisiblePages) {
  4741. if (this.idleTimeout) {
  4742. clearTimeout(this.idleTimeout);
  4743. this.idleTimeout = null;
  4744. }
  4745. if (this.pdfViewer.forceRendering(currentlyVisiblePages)) {
  4746. return;
  4747. }
  4748. if (this.pdfThumbnailViewer && this.isThumbnailViewEnabled) {
  4749. if (this.pdfThumbnailViewer.forceRendering()) {
  4750. return;
  4751. }
  4752. }
  4753. if (this.printing) {
  4754. return;
  4755. }
  4756. if (this.onIdle) {
  4757. this.idleTimeout = setTimeout(this.onIdle.bind(this),
  4758. CLEANUP_TIMEOUT);
  4759. }
  4760. }
  4761. }, {
  4762. key: "getHighestPriority",
  4763. value: function getHighestPriority(visible, views, scrolledDown) {
  4764. var visibleViews = visible.views;
  4765. var numVisible = visibleViews.length;
  4766. if (numVisible === 0) {
  4767. return null;
  4768. }
  4769. for (var i = 0; i < numVisible; ++i) {
  4770. var view = visibleViews[i].view;
  4771. if (!this.isViewFinished(view)) {
  4772. return view;
  4773. }
  4774. }
  4775. if (scrolledDown) {
  4776. var nextPageIndex = visible.last.id;
  4777. if (views[nextPageIndex] && !this.isViewFinished(views[
  4778. nextPageIndex])) {
  4779. return views[nextPageIndex];
  4780. }
  4781. } else {
  4782. var previousPageIndex = visible.first.id - 2;
  4783. if (views[previousPageIndex] && !this.isViewFinished(views[
  4784. previousPageIndex])) {
  4785. return views[previousPageIndex];
  4786. }
  4787. }
  4788. return null;
  4789. }
  4790. }, {
  4791. key: "isViewFinished",
  4792. value: function isViewFinished(view) {
  4793. return view.renderingState === RenderingStates.FINISHED;
  4794. }
  4795. }, {
  4796. key: "renderView",
  4797. value: function renderView(view) {
  4798. var _this = this;
  4799. switch (view.renderingState) {
  4800. case RenderingStates.FINISHED:
  4801. return false;
  4802. case RenderingStates.PAUSED:
  4803. this.highestPriorityPage = view.renderingId;
  4804. view.resume();
  4805. break;
  4806. case RenderingStates.RUNNING:
  4807. this.highestPriorityPage = view.renderingId;
  4808. break;
  4809. case RenderingStates.INITIAL:
  4810. this.highestPriorityPage = view.renderingId;
  4811. view.draw()["finally"](function() {
  4812. _this.renderHighestPriority();
  4813. });
  4814. break;
  4815. }
  4816. return true;
  4817. }
  4818. }]);
  4819. return PDFRenderingQueue;
  4820. }();
  4821. exports.PDFRenderingQueue = PDFRenderingQueue;
  4822. /***/
  4823. }),
  4824. /* 12 */
  4825. /***/
  4826. (function(module, exports, __webpack_require__) {
  4827. "use strict";
  4828. Object.defineProperty(exports, "__esModule", {
  4829. value: true
  4830. });
  4831. exports.PDFSidebar = exports.SidebarView = void 0;
  4832. var _ui_utils = __webpack_require__(5);
  4833. var _pdf_rendering_queue = __webpack_require__(11);
  4834. function _classCallCheck(instance, Constructor) {
  4835. if (!(instance instanceof Constructor)) {
  4836. throw new TypeError("Cannot call a class as a function");
  4837. }
  4838. }
  4839. function _defineProperties(target, props) {
  4840. for (var i = 0; i < props.length; i++) {
  4841. var descriptor = props[i];
  4842. descriptor.enumerable = descriptor.enumerable || false;
  4843. descriptor.configurable = true;
  4844. if ("value" in descriptor) descriptor.writable = true;
  4845. Object.defineProperty(target, descriptor.key, descriptor);
  4846. }
  4847. }
  4848. function _createClass(Constructor, protoProps, staticProps) {
  4849. if (protoProps) _defineProperties(Constructor.prototype, protoProps);
  4850. if (staticProps) _defineProperties(Constructor, staticProps);
  4851. return Constructor;
  4852. }
  4853. var UI_NOTIFICATION_CLASS = 'pdfSidebarNotification';
  4854. var SidebarView = {
  4855. UNKNOWN: -1,
  4856. NONE: 0,
  4857. THUMBS: 1,
  4858. OUTLINE: 2,
  4859. ATTACHMENTS: 3,
  4860. LAYERS: 4
  4861. };
  4862. exports.SidebarView = SidebarView;
  4863. var PDFSidebar =
  4864. /*#__PURE__*/
  4865. function() {
  4866. function PDFSidebar(_ref) {
  4867. var elements = _ref.elements,
  4868. pdfViewer = _ref.pdfViewer,
  4869. pdfThumbnailViewer = _ref.pdfThumbnailViewer,
  4870. eventBus = _ref.eventBus,
  4871. _ref$l10n = _ref.l10n,
  4872. l10n = _ref$l10n === void 0 ? _ui_utils.NullL10n : _ref$l10n,
  4873. _ref$disableNotificat = _ref.disableNotification,
  4874. disableNotification = _ref$disableNotificat === void 0 ? false : _ref$disableNotificat;
  4875. _classCallCheck(this, PDFSidebar);
  4876. this.isOpen = false;
  4877. this.active = SidebarView.THUMBS;
  4878. this.isInitialViewSet = false;
  4879. this.onToggled = null;
  4880. this.pdfViewer = pdfViewer;
  4881. this.pdfThumbnailViewer = pdfThumbnailViewer;
  4882. this.outerContainer = elements.outerContainer;
  4883. this.viewerContainer = elements.viewerContainer;
  4884. this.toggleButton = elements.toggleButton;
  4885. this.thumbnailButton = elements.thumbnailButton;
  4886. this.outlineButton = elements.outlineButton;
  4887. this.attachmentsButton = elements.attachmentsButton;
  4888. this.thumbnailView = elements.thumbnailView;
  4889. this.outlineView = elements.outlineView;
  4890. this.attachmentsView = elements.attachmentsView;
  4891. this.eventBus = eventBus;
  4892. this.l10n = l10n;
  4893. this._disableNotification = disableNotification;
  4894. this._addEventListeners();
  4895. }
  4896. _createClass(PDFSidebar, [{
  4897. key: "reset",
  4898. value: function reset() {
  4899. this.isInitialViewSet = false;
  4900. this._hideUINotification(null);
  4901. this.switchView(SidebarView.THUMBS);
  4902. this.outlineButton.disabled = false;
  4903. this.attachmentsButton.disabled = false;
  4904. }
  4905. }, {
  4906. key: "setInitialView",
  4907. value: function setInitialView() {
  4908. var view = arguments.length > 0 && arguments[0] !== undefined ?
  4909. arguments[0] : SidebarView.NONE;
  4910. if (this.isInitialViewSet) {
  4911. return;
  4912. }
  4913. this.isInitialViewSet = true;
  4914. if (view === SidebarView.NONE || view === SidebarView.UNKNOWN) {
  4915. this._dispatchEvent();
  4916. return;
  4917. }
  4918. if (!this._switchView(view, true)) {
  4919. this._dispatchEvent();
  4920. }
  4921. }
  4922. }, {
  4923. key: "switchView",
  4924. value: function switchView(view) {
  4925. var forceOpen = arguments.length > 1 && arguments[1] !== undefined ?
  4926. arguments[1] : false;
  4927. this._switchView(view, forceOpen);
  4928. }
  4929. }, {
  4930. key: "_switchView",
  4931. value: function _switchView(view) {
  4932. var forceOpen = arguments.length > 1 && arguments[1] !== undefined ?
  4933. arguments[1] : false;
  4934. var isViewChanged = view !== this.active;
  4935. var shouldForceRendering = false;
  4936. switch (view) {
  4937. case SidebarView.NONE:
  4938. if (this.isOpen) {
  4939. this.close();
  4940. return true;
  4941. }
  4942. return false;
  4943. case SidebarView.THUMBS:
  4944. if (this.isOpen && isViewChanged) {
  4945. shouldForceRendering = true;
  4946. }
  4947. break;
  4948. case SidebarView.OUTLINE:
  4949. if (this.outlineButton.disabled) {
  4950. return false;
  4951. }
  4952. break;
  4953. case SidebarView.ATTACHMENTS:
  4954. if (this.attachmentsButton.disabled) {
  4955. return false;
  4956. }
  4957. break;
  4958. default:
  4959. console.error("PDFSidebar._switchView: \"".concat(view,
  4960. "\" is not a valid view."));
  4961. return false;
  4962. }
  4963. this.active = view;
  4964. this.thumbnailButton.classList.toggle('toggled', view === SidebarView
  4965. .THUMBS);
  4966. this.outlineButton.classList.toggle('toggled', view === SidebarView
  4967. .OUTLINE);
  4968. this.attachmentsButton.classList.toggle('toggled', view === SidebarView
  4969. .ATTACHMENTS);
  4970. this.thumbnailView.classList.toggle('hidden', view !== SidebarView
  4971. .THUMBS);
  4972. this.outlineView.classList.toggle('hidden', view !== SidebarView
  4973. .OUTLINE);
  4974. this.attachmentsView.classList.toggle('hidden', view !== SidebarView
  4975. .ATTACHMENTS);
  4976. if (forceOpen && !this.isOpen) {
  4977. this.open();
  4978. return true;
  4979. }
  4980. if (shouldForceRendering) {
  4981. this._updateThumbnailViewer();
  4982. this._forceRendering();
  4983. }
  4984. if (isViewChanged) {
  4985. this._dispatchEvent();
  4986. }
  4987. this._hideUINotification(this.active);
  4988. return isViewChanged;
  4989. }
  4990. }, {
  4991. key: "open",
  4992. value: function open() {
  4993. if (this.isOpen) {
  4994. return;
  4995. }
  4996. this.isOpen = true;
  4997. this.toggleButton.classList.add('toggled');
  4998. this.outerContainer.classList.add('sidebarMoving', 'sidebarOpen');
  4999. if (this.active === SidebarView.THUMBS) {
  5000. this._updateThumbnailViewer();
  5001. }
  5002. this._forceRendering();
  5003. this._dispatchEvent();
  5004. this._hideUINotification(this.active);
  5005. }
  5006. }, {
  5007. key: "close",
  5008. value: function close() {
  5009. if (!this.isOpen) {
  5010. return;
  5011. }
  5012. this.isOpen = false;
  5013. this.toggleButton.classList.remove('toggled');
  5014. this.outerContainer.classList.add('sidebarMoving');
  5015. this.outerContainer.classList.remove('sidebarOpen');
  5016. this._forceRendering();
  5017. this._dispatchEvent();
  5018. }
  5019. }, {
  5020. key: "toggle",
  5021. value: function toggle() {
  5022. if (this.isOpen) {
  5023. this.close();
  5024. } else {
  5025. this.open();
  5026. }
  5027. }
  5028. }, {
  5029. key: "_dispatchEvent",
  5030. value: function _dispatchEvent() {
  5031. this.eventBus.dispatch('sidebarviewchanged', {
  5032. source: this,
  5033. view: this.visibleView
  5034. });
  5035. }
  5036. }, {
  5037. key: "_forceRendering",
  5038. value: function _forceRendering() {
  5039. if (this.onToggled) {
  5040. this.onToggled();
  5041. } else {
  5042. this.pdfViewer.forceRendering();
  5043. this.pdfThumbnailViewer.forceRendering();
  5044. }
  5045. }
  5046. }, {
  5047. key: "_updateThumbnailViewer",
  5048. value: function _updateThumbnailViewer() {
  5049. var pdfViewer = this.pdfViewer,
  5050. pdfThumbnailViewer = this.pdfThumbnailViewer;
  5051. var pagesCount = pdfViewer.pagesCount;
  5052. for (var pageIndex = 0; pageIndex < pagesCount; pageIndex++) {
  5053. var pageView = pdfViewer.getPageView(pageIndex);
  5054. if (pageView && pageView.renderingState === _pdf_rendering_queue
  5055. .RenderingStates.FINISHED) {
  5056. var thumbnailView = pdfThumbnailViewer.getThumbnail(pageIndex);
  5057. thumbnailView.setImage(pageView);
  5058. }
  5059. }
  5060. pdfThumbnailViewer.scrollThumbnailIntoView(pdfViewer.currentPageNumber);
  5061. }
  5062. }, {
  5063. key: "_showUINotification",
  5064. value: function _showUINotification(view) {
  5065. var _this = this;
  5066. if (this._disableNotification) {
  5067. return;
  5068. }
  5069. this.l10n.get('toggle_sidebar_notification.title', null,
  5070. 'Toggle Sidebar (document contains outline/attachments)').then(
  5071. function(msg) {
  5072. _this.toggleButton.title = msg;
  5073. });
  5074. if (!this.isOpen) {
  5075. this.toggleButton.classList.add(UI_NOTIFICATION_CLASS);
  5076. } else if (view === this.active) {
  5077. return;
  5078. }
  5079. switch (view) {
  5080. case SidebarView.OUTLINE:
  5081. this.outlineButton.classList.add(UI_NOTIFICATION_CLASS);
  5082. break;
  5083. case SidebarView.ATTACHMENTS:
  5084. this.attachmentsButton.classList.add(UI_NOTIFICATION_CLASS);
  5085. break;
  5086. }
  5087. }
  5088. }, {
  5089. key: "_hideUINotification",
  5090. value: function _hideUINotification(view) {
  5091. var _this2 = this;
  5092. if (this._disableNotification) {
  5093. return;
  5094. }
  5095. var removeNotification = function removeNotification(view) {
  5096. switch (view) {
  5097. case SidebarView.OUTLINE:
  5098. _this2.outlineButton.classList.remove(
  5099. UI_NOTIFICATION_CLASS);
  5100. break;
  5101. case SidebarView.ATTACHMENTS:
  5102. _this2.attachmentsButton.classList.remove(
  5103. UI_NOTIFICATION_CLASS);
  5104. break;
  5105. }
  5106. };
  5107. if (!this.isOpen && view !== null) {
  5108. return;
  5109. }
  5110. this.toggleButton.classList.remove(UI_NOTIFICATION_CLASS);
  5111. if (view !== null) {
  5112. removeNotification(view);
  5113. return;
  5114. }
  5115. for (view in SidebarView) {
  5116. removeNotification(SidebarView[view]);
  5117. }
  5118. this.l10n.get('toggle_sidebar.title', null, 'Toggle Sidebar').then(
  5119. function(msg) {
  5120. _this2.toggleButton.title = msg;
  5121. });
  5122. }
  5123. }, {
  5124. key: "_addEventListeners",
  5125. value: function _addEventListeners() {
  5126. var _this3 = this;
  5127. this.viewerContainer.addEventListener('transitionend', function(evt) {
  5128. if (evt.target === _this3.viewerContainer) {
  5129. _this3.outerContainer.classList.remove('sidebarMoving');
  5130. }
  5131. });
  5132. this.toggleButton.addEventListener('click', function() {
  5133. _this3.toggle();
  5134. });
  5135. this.thumbnailButton.addEventListener('click', function() {
  5136. _this3.switchView(SidebarView.THUMBS);
  5137. });
  5138. this.outlineButton.addEventListener('click', function() {
  5139. _this3.switchView(SidebarView.OUTLINE);
  5140. });
  5141. this.outlineButton.addEventListener('dblclick', function() {
  5142. _this3.eventBus.dispatch('toggleoutlinetree', {
  5143. source: _this3
  5144. });
  5145. });
  5146. this.attachmentsButton.addEventListener('click', function() {
  5147. _this3.switchView(SidebarView.ATTACHMENTS);
  5148. });
  5149. this.eventBus.on('outlineloaded', function(evt) {
  5150. var outlineCount = evt.outlineCount;
  5151. _this3.outlineButton.disabled = !outlineCount;
  5152. if (outlineCount) {
  5153. _this3._showUINotification(SidebarView.OUTLINE);
  5154. } else if (_this3.active === SidebarView.OUTLINE) {
  5155. _this3.switchView(SidebarView.THUMBS);
  5156. }
  5157. });
  5158. this.eventBus.on('attachmentsloaded', function(evt) {
  5159. if (evt.attachmentsCount) {
  5160. _this3.attachmentsButton.disabled = false;
  5161. _this3._showUINotification(SidebarView.ATTACHMENTS);
  5162. return;
  5163. }
  5164. Promise.resolve().then(function() {
  5165. if (_this3.attachmentsView.hasChildNodes()) {
  5166. return;
  5167. }
  5168. _this3.attachmentsButton.disabled = true;
  5169. if (_this3.active === SidebarView.ATTACHMENTS) {
  5170. _this3.switchView(SidebarView.THUMBS);
  5171. }
  5172. });
  5173. });
  5174. this.eventBus.on('presentationmodechanged', function(evt) {
  5175. if (!evt.active && !evt.switchInProgress && _this3
  5176. .isThumbnailViewVisible) {
  5177. _this3._updateThumbnailViewer();
  5178. }
  5179. });
  5180. }
  5181. }, {
  5182. key: "visibleView",
  5183. get: function get() {
  5184. return this.isOpen ? this.active : SidebarView.NONE;
  5185. }
  5186. }, {
  5187. key: "isThumbnailViewVisible",
  5188. get: function get() {
  5189. return this.isOpen && this.active === SidebarView.THUMBS;
  5190. }
  5191. }, {
  5192. key: "isOutlineViewVisible",
  5193. get: function get() {
  5194. return this.isOpen && this.active === SidebarView.OUTLINE;
  5195. }
  5196. }, {
  5197. key: "isAttachmentsViewVisible",
  5198. get: function get() {
  5199. return this.isOpen && this.active === SidebarView.ATTACHMENTS;
  5200. }
  5201. }]);
  5202. return PDFSidebar;
  5203. }();
  5204. exports.PDFSidebar = PDFSidebar;
  5205. /***/
  5206. }),
  5207. /* 13 */
  5208. /***/
  5209. (function(module, exports, __webpack_require__) {
  5210. "use strict";
  5211. Object.defineProperty(exports, "__esModule", {
  5212. value: true
  5213. });
  5214. exports.OverlayManager = void 0;
  5215. var _regenerator = _interopRequireDefault(__webpack_require__(2));
  5216. function _interopRequireDefault(obj) {
  5217. return obj && obj.__esModule ? obj : {
  5218. "default": obj
  5219. };
  5220. }
  5221. function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
  5222. try {
  5223. var info = gen[key](arg);
  5224. var value = info.value;
  5225. } catch (error) {
  5226. reject(error);
  5227. return;
  5228. }
  5229. if (info.done) {
  5230. resolve(value);
  5231. } else {
  5232. Promise.resolve(value).then(_next, _throw);
  5233. }
  5234. }
  5235. function _asyncToGenerator(fn) {
  5236. return function() {
  5237. var self = this,
  5238. args = arguments;
  5239. return new Promise(function(resolve, reject) {
  5240. var gen = fn.apply(self, args);
  5241. function _next(value) {
  5242. asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
  5243. }
  5244. function _throw(err) {
  5245. asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
  5246. }
  5247. _next(undefined);
  5248. });
  5249. };
  5250. }
  5251. function _classCallCheck(instance, Constructor) {
  5252. if (!(instance instanceof Constructor)) {
  5253. throw new TypeError("Cannot call a class as a function");
  5254. }
  5255. }
  5256. function _defineProperties(target, props) {
  5257. for (var i = 0; i < props.length; i++) {
  5258. var descriptor = props[i];
  5259. descriptor.enumerable = descriptor.enumerable || false;
  5260. descriptor.configurable = true;
  5261. if ("value" in descriptor) descriptor.writable = true;
  5262. Object.defineProperty(target, descriptor.key, descriptor);
  5263. }
  5264. }
  5265. function _createClass(Constructor, protoProps, staticProps) {
  5266. if (protoProps) _defineProperties(Constructor.prototype, protoProps);
  5267. if (staticProps) _defineProperties(Constructor, staticProps);
  5268. return Constructor;
  5269. }
  5270. var OverlayManager =
  5271. /*#__PURE__*/
  5272. function() {
  5273. function OverlayManager() {
  5274. _classCallCheck(this, OverlayManager);
  5275. this._overlays = {};
  5276. this._active = null;
  5277. this._keyDownBound = this._keyDown.bind(this);
  5278. }
  5279. _createClass(OverlayManager, [{
  5280. key: "register",
  5281. value: function() {
  5282. var _register = _asyncToGenerator(
  5283. /*#__PURE__*/
  5284. _regenerator["default"].mark(function _callee(name, element) {
  5285. var callerCloseMethod,
  5286. canForceClose,
  5287. container,
  5288. _args = arguments;
  5289. return _regenerator["default"].wrap(function _callee$(
  5290. _context) {
  5291. while (1) {
  5292. switch (_context.prev = _context.next) {
  5293. case 0:
  5294. callerCloseMethod = _args
  5295. .length > 2 && _args[2] !==
  5296. undefined ? _args[2] : null;
  5297. canForceClose = _args.length >
  5298. 3 && _args[3] !==
  5299. undefined ? _args[3] :
  5300. false;
  5301. if (!(!name || !element || !(
  5302. container = element
  5303. .parentNode))) {
  5304. _context.next = 6;
  5305. break;
  5306. }
  5307. throw new Error(
  5308. 'Not enough parameters.'
  5309. );
  5310. case 6:
  5311. if (!this._overlays[name]) {
  5312. _context.next = 8;
  5313. break;
  5314. }
  5315. throw new Error(
  5316. 'The overlay is already registered.'
  5317. );
  5318. case 8:
  5319. this._overlays[name] = {
  5320. element: element,
  5321. container: container,
  5322. callerCloseMethod: callerCloseMethod,
  5323. canForceClose: canForceClose
  5324. };
  5325. case 9:
  5326. case "end":
  5327. return _context.stop();
  5328. }
  5329. }
  5330. }, _callee, this);
  5331. }));
  5332. function register(_x, _x2) {
  5333. return _register.apply(this, arguments);
  5334. }
  5335. return register;
  5336. }()
  5337. }, {
  5338. key: "unregister",
  5339. value: function() {
  5340. var _unregister = _asyncToGenerator(
  5341. /*#__PURE__*/
  5342. _regenerator["default"].mark(function _callee2(name) {
  5343. return _regenerator["default"].wrap(function _callee2$(
  5344. _context2) {
  5345. while (1) {
  5346. switch (_context2.prev = _context2
  5347. .next) {
  5348. case 0:
  5349. if (this._overlays[name]) {
  5350. _context2.next = 4;
  5351. break;
  5352. }
  5353. throw new Error(
  5354. 'The overlay does not exist.'
  5355. );
  5356. case 4:
  5357. if (!(this._active === name)) {
  5358. _context2.next = 6;
  5359. break;
  5360. }
  5361. throw new Error(
  5362. 'The overlay cannot be removed while it is active.'
  5363. );
  5364. case 6:
  5365. delete this._overlays[name];
  5366. case 7:
  5367. case "end":
  5368. return _context2.stop();
  5369. }
  5370. }
  5371. }, _callee2, this);
  5372. }));
  5373. function unregister(_x3) {
  5374. return _unregister.apply(this, arguments);
  5375. }
  5376. return unregister;
  5377. }()
  5378. }, {
  5379. key: "open",
  5380. value: function() {
  5381. var _open = _asyncToGenerator(
  5382. /*#__PURE__*/
  5383. _regenerator["default"].mark(function _callee3(name) {
  5384. return _regenerator["default"].wrap(function _callee3$(
  5385. _context3) {
  5386. while (1) {
  5387. switch (_context3.prev = _context3
  5388. .next) {
  5389. case 0:
  5390. if (this._overlays[name]) {
  5391. _context3.next = 4;
  5392. break;
  5393. }
  5394. throw new Error(
  5395. 'The overlay does not exist.'
  5396. );
  5397. case 4:
  5398. if (!this._active) {
  5399. _context3.next = 14;
  5400. break;
  5401. }
  5402. if (!this._overlays[name]
  5403. .canForceClose) {
  5404. _context3.next = 9;
  5405. break;
  5406. }
  5407. this._closeThroughCaller();
  5408. _context3.next = 14;
  5409. break;
  5410. case 9:
  5411. if (!(this._active === name)) {
  5412. _context3.next = 13;
  5413. break;
  5414. }
  5415. throw new Error(
  5416. 'The overlay is already active.'
  5417. );
  5418. case 13:
  5419. throw new Error(
  5420. 'Another overlay is currently active.'
  5421. );
  5422. case 14:
  5423. this._active = name;
  5424. this._overlays[this._active]
  5425. .element.classList.remove(
  5426. 'hidden');
  5427. this._overlays[this._active]
  5428. .container.classList.remove(
  5429. 'hidden');
  5430. window.addEventListener(
  5431. 'keydown', this
  5432. ._keyDownBound);
  5433. case 18:
  5434. case "end":
  5435. return _context3.stop();
  5436. }
  5437. }
  5438. }, _callee3, this);
  5439. }));
  5440. function open(_x4) {
  5441. return _open.apply(this, arguments);
  5442. }
  5443. return open;
  5444. }()
  5445. }, {
  5446. key: "close",
  5447. value: function() {
  5448. var _close = _asyncToGenerator(
  5449. /*#__PURE__*/
  5450. _regenerator["default"].mark(function _callee4(name) {
  5451. return _regenerator["default"].wrap(function _callee4$(
  5452. _context4) {
  5453. while (1) {
  5454. switch (_context4.prev = _context4
  5455. .next) {
  5456. case 0:
  5457. if (this._overlays[name]) {
  5458. _context4.next = 4;
  5459. break;
  5460. }
  5461. throw new Error(
  5462. 'The overlay does not exist.'
  5463. );
  5464. case 4:
  5465. if (this._active) {
  5466. _context4.next = 8;
  5467. break;
  5468. }
  5469. throw new Error(
  5470. 'The overlay is currently not active.'
  5471. );
  5472. case 8:
  5473. if (!(this._active !== name)) {
  5474. _context4.next = 10;
  5475. break;
  5476. }
  5477. throw new Error(
  5478. 'Another overlay is currently active.'
  5479. );
  5480. case 10:
  5481. this._overlays[this._active]
  5482. .container.classList.add(
  5483. 'hidden');
  5484. this._overlays[this._active]
  5485. .element.classList.add(
  5486. 'hidden');
  5487. this._active = null;
  5488. window.removeEventListener(
  5489. 'keydown', this
  5490. ._keyDownBound);
  5491. case 14:
  5492. case "end":
  5493. return _context4.stop();
  5494. }
  5495. }
  5496. }, _callee4, this);
  5497. }));
  5498. function close(_x5) {
  5499. return _close.apply(this, arguments);
  5500. }
  5501. return close;
  5502. }()
  5503. }, {
  5504. key: "_keyDown",
  5505. value: function _keyDown(evt) {
  5506. if (this._active && evt.keyCode === 27) {
  5507. this._closeThroughCaller();
  5508. evt.preventDefault();
  5509. }
  5510. }
  5511. }, {
  5512. key: "_closeThroughCaller",
  5513. value: function _closeThroughCaller() {
  5514. if (this._overlays[this._active].callerCloseMethod) {
  5515. this._overlays[this._active].callerCloseMethod();
  5516. }
  5517. if (this._active) {
  5518. this.close(this._active);
  5519. }
  5520. }
  5521. }, {
  5522. key: "active",
  5523. get: function get() {
  5524. return this._active;
  5525. }
  5526. }]);
  5527. return OverlayManager;
  5528. }();
  5529. exports.OverlayManager = OverlayManager;
  5530. /***/
  5531. }),
  5532. /* 14 */
  5533. /***/
  5534. (function(module, exports, __webpack_require__) {
  5535. "use strict";
  5536. Object.defineProperty(exports, "__esModule", {
  5537. value: true
  5538. });
  5539. exports.PasswordPrompt = void 0;
  5540. var _ui_utils = __webpack_require__(5);
  5541. var _pdfjsLib = __webpack_require__(7);
  5542. function _classCallCheck(instance, Constructor) {
  5543. if (!(instance instanceof Constructor)) {
  5544. throw new TypeError("Cannot call a class as a function");
  5545. }
  5546. }
  5547. function _defineProperties(target, props) {
  5548. for (var i = 0; i < props.length; i++) {
  5549. var descriptor = props[i];
  5550. descriptor.enumerable = descriptor.enumerable || false;
  5551. descriptor.configurable = true;
  5552. if ("value" in descriptor) descriptor.writable = true;
  5553. Object.defineProperty(target, descriptor.key, descriptor);
  5554. }
  5555. }
  5556. function _createClass(Constructor, protoProps, staticProps) {
  5557. if (protoProps) _defineProperties(Constructor.prototype, protoProps);
  5558. if (staticProps) _defineProperties(Constructor, staticProps);
  5559. return Constructor;
  5560. }
  5561. var PasswordPrompt =
  5562. /*#__PURE__*/
  5563. function() {
  5564. function PasswordPrompt(options, overlayManager) {
  5565. var _this = this;
  5566. var l10n = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : _ui_utils
  5567. .NullL10n;
  5568. _classCallCheck(this, PasswordPrompt);
  5569. this.overlayName = options.overlayName;
  5570. this.container = options.container;
  5571. this.label = options.label;
  5572. this.input = options.input;
  5573. this.submitButton = options.submitButton;
  5574. this.cancelButton = options.cancelButton;
  5575. this.overlayManager = overlayManager;
  5576. this.l10n = l10n;
  5577. this.updateCallback = null;
  5578. this.reason = null;
  5579. this.submitButton.addEventListener('click', this.verify.bind(this));
  5580. this.cancelButton.addEventListener('click', this.close.bind(this));
  5581. this.input.addEventListener('keydown', function(e) {
  5582. if (e.keyCode === 13) {
  5583. _this.verify();
  5584. }
  5585. });
  5586. this.overlayManager.register(this.overlayName, this.container, this.close.bind(this), true);
  5587. }
  5588. _createClass(PasswordPrompt, [{
  5589. key: "open",
  5590. value: function open() {
  5591. var _this2 = this;
  5592. this.overlayManager.open(this.overlayName).then(function() {
  5593. _this2.input.focus();
  5594. var promptString;
  5595. if (_this2.reason === _pdfjsLib.PasswordResponses
  5596. .INCORRECT_PASSWORD) {
  5597. promptString = _this2.l10n.get('password_invalid', null,
  5598. 'Invalid password. Please try again.');
  5599. } else {
  5600. promptString = _this2.l10n.get('password_label', null,
  5601. 'Enter the password to open this PDF file.');
  5602. }
  5603. promptString.then(function(msg) {
  5604. _this2.label.textContent = msg;
  5605. });
  5606. });
  5607. }
  5608. }, {
  5609. key: "close",
  5610. value: function close() {
  5611. var _this3 = this;
  5612. this.overlayManager.close(this.overlayName).then(function() {
  5613. _this3.input.value = '';
  5614. });
  5615. }
  5616. }, {
  5617. key: "verify",
  5618. value: function verify() {
  5619. var password = this.input.value;
  5620. if (password && password.length > 0) {
  5621. this.close();
  5622. this.updateCallback(password);
  5623. }
  5624. }
  5625. }, {
  5626. key: "setUpdateCallback",
  5627. value: function setUpdateCallback(updateCallback, reason) {
  5628. this.updateCallback = updateCallback;
  5629. this.reason = reason;
  5630. }
  5631. }]);
  5632. return PasswordPrompt;
  5633. }();
  5634. exports.PasswordPrompt = PasswordPrompt;
  5635. /***/
  5636. }),
  5637. /* 15 */
  5638. /***/
  5639. (function(module, exports, __webpack_require__) {
  5640. "use strict";
  5641. Object.defineProperty(exports, "__esModule", {
  5642. value: true
  5643. });
  5644. exports.PDFAttachmentViewer = void 0;
  5645. var _pdfjsLib = __webpack_require__(7);
  5646. function _classCallCheck(instance, Constructor) {
  5647. if (!(instance instanceof Constructor)) {
  5648. throw new TypeError("Cannot call a class as a function");
  5649. }
  5650. }
  5651. function _defineProperties(target, props) {
  5652. for (var i = 0; i < props.length; i++) {
  5653. var descriptor = props[i];
  5654. descriptor.enumerable = descriptor.enumerable || false;
  5655. descriptor.configurable = true;
  5656. if ("value" in descriptor) descriptor.writable = true;
  5657. Object.defineProperty(target, descriptor.key, descriptor);
  5658. }
  5659. }
  5660. function _createClass(Constructor, protoProps, staticProps) {
  5661. if (protoProps) _defineProperties(Constructor.prototype, protoProps);
  5662. if (staticProps) _defineProperties(Constructor, staticProps);
  5663. return Constructor;
  5664. }
  5665. var PDFAttachmentViewer =
  5666. /*#__PURE__*/
  5667. function() {
  5668. function PDFAttachmentViewer(_ref) {
  5669. var container = _ref.container,
  5670. eventBus = _ref.eventBus,
  5671. downloadManager = _ref.downloadManager;
  5672. _classCallCheck(this, PDFAttachmentViewer);
  5673. this.container = container;
  5674. this.eventBus = eventBus;
  5675. this.downloadManager = downloadManager;
  5676. this.reset();
  5677. this.eventBus.on('fileattachmentannotation', this._appendAttachment.bind(this));
  5678. }
  5679. _createClass(PDFAttachmentViewer, [{
  5680. key: "reset",
  5681. value: function reset() {
  5682. var keepRenderedCapability = arguments.length > 0 && arguments[0] !==
  5683. undefined ? arguments[0] : false;
  5684. this.attachments = null;
  5685. this.container.textContent = '';
  5686. if (!keepRenderedCapability) {
  5687. this._renderedCapability = (0, _pdfjsLib.createPromiseCapability)();
  5688. }
  5689. }
  5690. }, {
  5691. key: "_dispatchEvent",
  5692. value: function _dispatchEvent(attachmentsCount) {
  5693. this._renderedCapability.resolve();
  5694. this.eventBus.dispatch('attachmentsloaded', {
  5695. source: this,
  5696. attachmentsCount: attachmentsCount
  5697. });
  5698. }
  5699. }, {
  5700. key: "_bindPdfLink",
  5701. value: function _bindPdfLink(button, content, filename) {
  5702. if (this.downloadManager.disableCreateObjectURL) {
  5703. throw new Error(
  5704. 'bindPdfLink: Unsupported "disableCreateObjectURL" value.');
  5705. }
  5706. var blobUrl;
  5707. button.onclick = function() {
  5708. if (!blobUrl) {
  5709. blobUrl = (0, _pdfjsLib.createObjectURL)(content,
  5710. 'application/pdf');
  5711. }
  5712. var viewerUrl;
  5713. viewerUrl = '?file=' + encodeURIComponent(blobUrl + '#' +
  5714. filename);
  5715. window.open(viewerUrl);
  5716. return false;
  5717. };
  5718. }
  5719. }, {
  5720. key: "_bindLink",
  5721. value: function _bindLink(button, content, filename) {
  5722. var _this = this;
  5723. button.onclick = function() {
  5724. _this.downloadManager.downloadData(content, filename, '');
  5725. return false;
  5726. };
  5727. }
  5728. }, {
  5729. key: "render",
  5730. value: function render(_ref2) {
  5731. var attachments = _ref2.attachments,
  5732. _ref2$keepRenderedCap = _ref2.keepRenderedCapability,
  5733. keepRenderedCapability = _ref2$keepRenderedCap === void 0 ? false :
  5734. _ref2$keepRenderedCap;
  5735. var attachmentsCount = 0;
  5736. if (this.attachments) {
  5737. this.reset(keepRenderedCapability === true);
  5738. }
  5739. this.attachments = attachments || null;
  5740. if (!attachments) {
  5741. this._dispatchEvent(attachmentsCount);
  5742. return;
  5743. }
  5744. var names = Object.keys(attachments).sort(function(a, b) {
  5745. return a.toLowerCase().localeCompare(b.toLowerCase());
  5746. });
  5747. attachmentsCount = names.length;
  5748. for (var i = 0; i < attachmentsCount; i++) {
  5749. var item = attachments[names[i]];
  5750. var filename = (0, _pdfjsLib.removeNullCharacters)((0, _pdfjsLib
  5751. .getFilenameFromUrl)(item.filename));
  5752. var div = document.createElement('div');
  5753. div.className = 'attachmentsItem';
  5754. var button = document.createElement('button');
  5755. button.textContent = filename;
  5756. if (/\.pdf$/i.test(filename) && !this.downloadManager
  5757. .disableCreateObjectURL) {
  5758. this._bindPdfLink(button, item.content, filename);
  5759. } else {
  5760. this._bindLink(button, item.content, filename);
  5761. }
  5762. div.appendChild(button);
  5763. this.container.appendChild(div);
  5764. }
  5765. this._dispatchEvent(attachmentsCount);
  5766. }
  5767. }, {
  5768. key: "_appendAttachment",
  5769. value: function _appendAttachment(_ref3) {
  5770. var _this2 = this;
  5771. var id = _ref3.id,
  5772. filename = _ref3.filename,
  5773. content = _ref3.content;
  5774. this._renderedCapability.promise.then(function() {
  5775. var attachments = _this2.attachments;
  5776. if (!attachments) {
  5777. attachments = Object.create(null);
  5778. } else {
  5779. for (var name in attachments) {
  5780. if (id === name) {
  5781. return;
  5782. }
  5783. }
  5784. }
  5785. attachments[id] = {
  5786. filename: filename,
  5787. content: content
  5788. };
  5789. _this2.render({
  5790. attachments: attachments,
  5791. keepRenderedCapability: true
  5792. });
  5793. });
  5794. }
  5795. }]);
  5796. return PDFAttachmentViewer;
  5797. }();
  5798. exports.PDFAttachmentViewer = PDFAttachmentViewer;
  5799. /***/
  5800. }),
  5801. /* 16 */
  5802. /***/
  5803. (function(module, exports, __webpack_require__) {
  5804. "use strict";
  5805. Object.defineProperty(exports, "__esModule", {
  5806. value: true
  5807. });
  5808. exports.PDFDocumentProperties = void 0;
  5809. var _regenerator = _interopRequireDefault(__webpack_require__(2));
  5810. var _pdfjsLib = __webpack_require__(7);
  5811. var _ui_utils = __webpack_require__(5);
  5812. function _interopRequireDefault(obj) {
  5813. return obj && obj.__esModule ? obj : {
  5814. "default": obj
  5815. };
  5816. }
  5817. function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
  5818. try {
  5819. var info = gen[key](arg);
  5820. var value = info.value;
  5821. } catch (error) {
  5822. reject(error);
  5823. return;
  5824. }
  5825. if (info.done) {
  5826. resolve(value);
  5827. } else {
  5828. Promise.resolve(value).then(_next, _throw);
  5829. }
  5830. }
  5831. function _asyncToGenerator(fn) {
  5832. return function() {
  5833. var self = this,
  5834. args = arguments;
  5835. return new Promise(function(resolve, reject) {
  5836. var gen = fn.apply(self, args);
  5837. function _next(value) {
  5838. asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
  5839. }
  5840. function _throw(err) {
  5841. asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
  5842. }
  5843. _next(undefined);
  5844. });
  5845. };
  5846. }
  5847. function _slicedToArray(arr, i) {
  5848. return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest();
  5849. }
  5850. function _nonIterableRest() {
  5851. throw new TypeError("Invalid attempt to destructure non-iterable instance");
  5852. }
  5853. function _iterableToArrayLimit(arr, i) {
  5854. if (!(Symbol.iterator in Object(arr) || Object.prototype.toString.call(arr) ===
  5855. "[object Arguments]")) {
  5856. return;
  5857. }
  5858. var _arr = [];
  5859. var _n = true;
  5860. var _d = false;
  5861. var _e = undefined;
  5862. try {
  5863. for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {
  5864. _arr.push(_s.value);
  5865. if (i && _arr.length === i) break;
  5866. }
  5867. } catch (err) {
  5868. _d = true;
  5869. _e = err;
  5870. } finally {
  5871. try {
  5872. if (!_n && _i["return"] != null) _i["return"]();
  5873. } finally {
  5874. if (_d) throw _e;
  5875. }
  5876. }
  5877. return _arr;
  5878. }
  5879. function _arrayWithHoles(arr) {
  5880. if (Array.isArray(arr)) return arr;
  5881. }
  5882. function _classCallCheck(instance, Constructor) {
  5883. if (!(instance instanceof Constructor)) {
  5884. throw new TypeError("Cannot call a class as a function");
  5885. }
  5886. }
  5887. function _defineProperties(target, props) {
  5888. for (var i = 0; i < props.length; i++) {
  5889. var descriptor = props[i];
  5890. descriptor.enumerable = descriptor.enumerable || false;
  5891. descriptor.configurable = true;
  5892. if ("value" in descriptor) descriptor.writable = true;
  5893. Object.defineProperty(target, descriptor.key, descriptor);
  5894. }
  5895. }
  5896. function _createClass(Constructor, protoProps, staticProps) {
  5897. if (protoProps) _defineProperties(Constructor.prototype, protoProps);
  5898. if (staticProps) _defineProperties(Constructor, staticProps);
  5899. return Constructor;
  5900. }
  5901. var DEFAULT_FIELD_CONTENT = '-';
  5902. var NON_METRIC_LOCALES = ['en-us', 'en-lr', 'my'];
  5903. var US_PAGE_NAMES = {
  5904. '8.5x11': 'Letter',
  5905. '8.5x14': 'Legal'
  5906. };
  5907. var METRIC_PAGE_NAMES = {
  5908. '297x420': 'A3',
  5909. '210x297': 'A4'
  5910. };
  5911. function getPageName(size, isPortrait, pageNames) {
  5912. var width = isPortrait ? size.width : size.height;
  5913. var height = isPortrait ? size.height : size.width;
  5914. return pageNames["".concat(width, "x").concat(height)];
  5915. }
  5916. var PDFDocumentProperties =
  5917. /*#__PURE__*/
  5918. function() {
  5919. function PDFDocumentProperties(_ref, overlayManager, eventBus) {
  5920. var _this = this;
  5921. var overlayName = _ref.overlayName,
  5922. fields = _ref.fields,
  5923. container = _ref.container,
  5924. closeButton = _ref.closeButton;
  5925. var l10n = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : _ui_utils
  5926. .NullL10n;
  5927. _classCallCheck(this, PDFDocumentProperties);
  5928. this.overlayName = overlayName;
  5929. this.fields = fields;
  5930. this.container = container;
  5931. this.overlayManager = overlayManager;
  5932. this.l10n = l10n;
  5933. this._reset();
  5934. if (closeButton) {
  5935. closeButton.addEventListener('click', this.close.bind(this));
  5936. }
  5937. this.overlayManager.register(this.overlayName, this.container, this.close.bind(this));
  5938. if (eventBus) {
  5939. eventBus.on('pagechanging', function(evt) {
  5940. _this._currentPageNumber = evt.pageNumber;
  5941. });
  5942. eventBus.on('rotationchanging', function(evt) {
  5943. _this._pagesRotation = evt.pagesRotation;
  5944. });
  5945. }
  5946. this._isNonMetricLocale = true;
  5947. l10n.getLanguage().then(function(locale) {
  5948. _this._isNonMetricLocale = NON_METRIC_LOCALES.includes(locale);
  5949. });
  5950. }
  5951. _createClass(PDFDocumentProperties, [{
  5952. key: "open",
  5953. value: function open() {
  5954. var _this2 = this;
  5955. var freezeFieldData = function freezeFieldData(data) {
  5956. Object.defineProperty(_this2, 'fieldData', {
  5957. value: Object.freeze(data),
  5958. writable: false,
  5959. enumerable: true,
  5960. configurable: true
  5961. });
  5962. };
  5963. Promise.all([this.overlayManager.open(this.overlayName), this
  5964. ._dataAvailableCapability.promise
  5965. ]).then(function() {
  5966. var currentPageNumber = _this2._currentPageNumber;
  5967. var pagesRotation = _this2._pagesRotation;
  5968. if (_this2.fieldData && currentPageNumber === _this2
  5969. .fieldData['_currentPageNumber'] && pagesRotation ===
  5970. _this2.fieldData['_pagesRotation']) {
  5971. _this2._updateUI();
  5972. return;
  5973. }
  5974. _this2.pdfDocument.getMetadata().then(function(_ref2) {
  5975. var info = _ref2.info,
  5976. metadata = _ref2.metadata,
  5977. contentDispositionFilename = _ref2
  5978. .contentDispositionFilename;
  5979. return Promise.all([info, metadata,
  5980. contentDispositionFilename || (0,
  5981. _ui_utils.getPDFFileNameFromURL)
  5982. (_this2.url || ''), _this2
  5983. ._parseFileSize(_this2
  5984. .maybeFileSize), _this2
  5985. ._parseDate(info.CreationDate),
  5986. _this2._parseDate(info.ModDate),
  5987. _this2.pdfDocument.getPage(
  5988. currentPageNumber).then(
  5989. function(pdfPage) {
  5990. return _this2
  5991. ._parsePageSize((0,
  5992. _ui_utils
  5993. .getPageSizeInches
  5994. )(pdfPage),
  5995. pagesRotation);
  5996. }), _this2._parseLinearization(
  5997. info.IsLinearized)
  5998. ]);
  5999. }).then(function(_ref3) {
  6000. var _ref4 = _slicedToArray(_ref3, 8),
  6001. info = _ref4[0],
  6002. metadata = _ref4[1],
  6003. fileName = _ref4[2],
  6004. fileSize = _ref4[3],
  6005. creationDate = _ref4[4],
  6006. modDate = _ref4[5],
  6007. pageSize = _ref4[6],
  6008. isLinearized = _ref4[7];
  6009. freezeFieldData({
  6010. 'fileName': fileName,
  6011. 'fileSize': fileSize,
  6012. 'title': info.Title,
  6013. 'author': info.Author,
  6014. 'subject': info.Subject,
  6015. 'keywords': info.Keywords,
  6016. 'creationDate': creationDate,
  6017. 'modificationDate': modDate,
  6018. 'creator': info.Creator,
  6019. 'producer': info.Producer,
  6020. 'version': info.PDFFormatVersion,
  6021. 'pageCount': _this2.pdfDocument
  6022. .numPages,
  6023. 'pageSize': pageSize,
  6024. 'linearized': isLinearized,
  6025. '_currentPageNumber': currentPageNumber,
  6026. '_pagesRotation': pagesRotation
  6027. });
  6028. _this2._updateUI();
  6029. return _this2.pdfDocument.getDownloadInfo();
  6030. }).then(function(_ref5) {
  6031. var length = _ref5.length;
  6032. _this2.maybeFileSize = length;
  6033. return _this2._parseFileSize(length);
  6034. }).then(function(fileSize) {
  6035. if (fileSize === _this2.fieldData['fileSize']) {
  6036. return;
  6037. }
  6038. var data = Object.assign(Object.create(null),
  6039. _this2.fieldData);
  6040. data['fileSize'] = fileSize;
  6041. freezeFieldData(data);
  6042. _this2._updateUI();
  6043. });
  6044. });
  6045. }
  6046. }, {
  6047. key: "close",
  6048. value: function close() {
  6049. this.overlayManager.close(this.overlayName);
  6050. }
  6051. }, {
  6052. key: "setDocument",
  6053. value: function setDocument(pdfDocument) {
  6054. var url = arguments.length > 1 && arguments[1] !== undefined ?
  6055. arguments[1] : null;
  6056. if (this.pdfDocument) {
  6057. this._reset();
  6058. this._updateUI(true);
  6059. }
  6060. if (!pdfDocument) {
  6061. return;
  6062. }
  6063. this.pdfDocument = pdfDocument;
  6064. this.url = url;
  6065. this._dataAvailableCapability.resolve();
  6066. }
  6067. }, {
  6068. key: "setFileSize",
  6069. value: function setFileSize(fileSize) {
  6070. if (Number.isInteger(fileSize) && fileSize > 0) {
  6071. this.maybeFileSize = fileSize;
  6072. }
  6073. }
  6074. }, {
  6075. key: "_reset",
  6076. value: function _reset() {
  6077. this.pdfDocument = null;
  6078. this.url = null;
  6079. this.maybeFileSize = 0;
  6080. delete this.fieldData;
  6081. this._dataAvailableCapability = (0, _pdfjsLib.createPromiseCapability)
  6082. ();
  6083. this._currentPageNumber = 1;
  6084. this._pagesRotation = 0;
  6085. }
  6086. }, {
  6087. key: "_updateUI",
  6088. value: function _updateUI() {
  6089. var reset = arguments.length > 0 && arguments[0] !== undefined ?
  6090. arguments[0] : false;
  6091. if (reset || !this.fieldData) {
  6092. for (var id in this.fields) {
  6093. this.fields[id].textContent = DEFAULT_FIELD_CONTENT;
  6094. }
  6095. return;
  6096. }
  6097. if (this.overlayManager.active !== this.overlayName) {
  6098. return;
  6099. }
  6100. for (var _id in this.fields) {
  6101. var content = this.fieldData[_id];
  6102. this.fields[_id].textContent = content || content === 0 ? content :
  6103. DEFAULT_FIELD_CONTENT;
  6104. }
  6105. }
  6106. }, {
  6107. key: "_parseFileSize",
  6108. value: function() {
  6109. var _parseFileSize2 = _asyncToGenerator(
  6110. /*#__PURE__*/
  6111. _regenerator["default"].mark(function _callee() {
  6112. var fileSize,
  6113. kb,
  6114. _args = arguments;
  6115. return _regenerator["default"].wrap(function _callee$(
  6116. _context) {
  6117. while (1) {
  6118. switch (_context.prev = _context.next) {
  6119. case 0:
  6120. fileSize = _args.length > 0 &&
  6121. _args[0] !== undefined ?
  6122. _args[0] : 0;
  6123. kb = fileSize / 1024;
  6124. if (kb) {
  6125. _context.next = 6;
  6126. break;
  6127. }
  6128. return _context.abrupt("return",
  6129. undefined);
  6130. case 6:
  6131. if (!(kb < 1024)) {
  6132. _context.next = 8;
  6133. break;
  6134. }
  6135. return _context.abrupt("return",
  6136. this.l10n.get(
  6137. 'document_properties_kb', {
  6138. size_kb: (+kb
  6139. .toPrecision(
  6140. 3))
  6141. .toLocaleString(),
  6142. size_b: fileSize
  6143. .toLocaleString()
  6144. },
  6145. '{{size_kb}} KB ({{size_b}} bytes)'
  6146. ));
  6147. case 8:
  6148. return _context.abrupt("return",
  6149. this.l10n.get(
  6150. 'document_properties_mb', {
  6151. size_mb: (+(kb /
  6152. 1024
  6153. )
  6154. .toPrecision(
  6155. 3))
  6156. .toLocaleString(),
  6157. size_b: fileSize
  6158. .toLocaleString()
  6159. },
  6160. '{{size_mb}} MB ({{size_b}} bytes)'
  6161. ));
  6162. case 9:
  6163. case "end":
  6164. return _context.stop();
  6165. }
  6166. }
  6167. }, _callee, this);
  6168. }));
  6169. function _parseFileSize() {
  6170. return _parseFileSize2.apply(this, arguments);
  6171. }
  6172. return _parseFileSize;
  6173. }()
  6174. }, {
  6175. key: "_parsePageSize",
  6176. value: function() {
  6177. var _parsePageSize2 = _asyncToGenerator(
  6178. /*#__PURE__*/
  6179. _regenerator["default"].mark(function _callee2(pageSizeInches,
  6180. pagesRotation) {
  6181. var _this3 = this;
  6182. var isPortrait, sizeInches, sizeMillimeters, pageName,
  6183. name, exactMillimeters, intMillimeters;
  6184. return _regenerator["default"].wrap(function _callee2$(
  6185. _context2) {
  6186. while (1) {
  6187. switch (_context2.prev = _context2
  6188. .next) {
  6189. case 0:
  6190. if (pageSizeInches) {
  6191. _context2.next = 2;
  6192. break;
  6193. }
  6194. return _context2.abrupt(
  6195. "return", undefined);
  6196. case 2:
  6197. if (pagesRotation % 180 !== 0) {
  6198. pageSizeInches = {
  6199. width: pageSizeInches
  6200. .height,
  6201. height: pageSizeInches
  6202. .width
  6203. };
  6204. }
  6205. isPortrait = (0, _ui_utils
  6206. .isPortraitOrientation)(
  6207. pageSizeInches);
  6208. sizeInches = {
  6209. width: Math.round(
  6210. pageSizeInches
  6211. .width * 100) /
  6212. 100,
  6213. height: Math.round(
  6214. pageSizeInches
  6215. .height * 100) /
  6216. 100
  6217. };
  6218. sizeMillimeters = {
  6219. width: Math.round(
  6220. pageSizeInches
  6221. .width * 25.4 *
  6222. 10) / 10,
  6223. height: Math.round(
  6224. pageSizeInches
  6225. .height * 25.4 *
  6226. 10) / 10
  6227. };
  6228. pageName = null;
  6229. name = getPageName(sizeInches,
  6230. isPortrait,
  6231. US_PAGE_NAMES) ||
  6232. getPageName(sizeMillimeters,
  6233. isPortrait,
  6234. METRIC_PAGE_NAMES);
  6235. if (!name && !(Number.isInteger(
  6236. sizeMillimeters
  6237. .width) && Number
  6238. .isInteger(
  6239. sizeMillimeters
  6240. .height))) {
  6241. exactMillimeters = {
  6242. width: pageSizeInches
  6243. .width * 25.4,
  6244. height: pageSizeInches
  6245. .height * 25.4
  6246. };
  6247. intMillimeters = {
  6248. width: Math.round(
  6249. sizeMillimeters
  6250. .width),
  6251. height: Math.round(
  6252. sizeMillimeters
  6253. .height)
  6254. };
  6255. if (Math.abs(
  6256. exactMillimeters
  6257. .width -
  6258. intMillimeters.width
  6259. ) < 0.1 && Math.abs(
  6260. exactMillimeters
  6261. .height -
  6262. intMillimeters
  6263. .height) < 0.1) {
  6264. name = getPageName(
  6265. intMillimeters,
  6266. isPortrait,
  6267. METRIC_PAGE_NAMES
  6268. );
  6269. if (name) {
  6270. sizeInches = {
  6271. width: Math
  6272. .round(
  6273. intMillimeters
  6274. .width /
  6275. 25.4 *
  6276. 100
  6277. ) /
  6278. 100,
  6279. height: Math
  6280. .round(
  6281. intMillimeters
  6282. .height /
  6283. 25.4 *
  6284. 100
  6285. ) /
  6286. 100
  6287. };
  6288. sizeMillimeters =
  6289. intMillimeters;
  6290. }
  6291. }
  6292. }
  6293. if (name) {
  6294. pageName = this.l10n.get(
  6295. 'document_properties_page_size_name_' +
  6296. name.toLowerCase(),
  6297. null, name);
  6298. }
  6299. return _context2.abrupt(
  6300. "return", Promise.all([
  6301. this
  6302. ._isNonMetricLocale ?
  6303. sizeInches :
  6304. sizeMillimeters,
  6305. this.l10n.get(
  6306. 'document_properties_page_size_unit_' +
  6307. (this
  6308. ._isNonMetricLocale ?
  6309. 'inches' :
  6310. 'millimeters'
  6311. ), null,
  6312. this
  6313. ._isNonMetricLocale ?
  6314. 'in' : 'mm'
  6315. ), pageName,
  6316. this.l10n.get(
  6317. 'document_properties_page_size_orientation_' +
  6318. (isPortrait ?
  6319. 'portrait' :
  6320. 'landscape'
  6321. ), null,
  6322. isPortrait ?
  6323. 'portrait' :
  6324. 'landscape')
  6325. ]).then(function(
  6326. _ref6) {
  6327. var _ref7 =
  6328. _slicedToArray(
  6329. _ref6, 4
  6330. ),
  6331. _ref7$ =
  6332. _ref7[0],
  6333. width =
  6334. _ref7$
  6335. .width,
  6336. height =
  6337. _ref7$
  6338. .height,
  6339. unit =
  6340. _ref7[1],
  6341. name =
  6342. _ref7[2],
  6343. orientation =
  6344. _ref7[3];
  6345. return _this3
  6346. .l10n.get(
  6347. 'document_properties_page_size_dimension_' +
  6348. (name ?
  6349. 'name_' :
  6350. ''
  6351. ) +
  6352. 'string', {
  6353. width: width
  6354. .toLocaleString(),
  6355. height: height
  6356. .toLocaleString(),
  6357. unit: unit,
  6358. name: name,
  6359. orientation: orientation
  6360. },
  6361. '{{width}} × {{height}} {{unit}} (' +
  6362. (name ?
  6363. '{{name}}, ' :
  6364. ''
  6365. ) +
  6366. '{{orientation}})'
  6367. );
  6368. }));
  6369. case 11:
  6370. case "end":
  6371. return _context2.stop();
  6372. }
  6373. }
  6374. }, _callee2, this);
  6375. }));
  6376. function _parsePageSize(_x, _x2) {
  6377. return _parsePageSize2.apply(this, arguments);
  6378. }
  6379. return _parsePageSize;
  6380. }()
  6381. }, {
  6382. key: "_parseDate",
  6383. value: function() {
  6384. var _parseDate2 = _asyncToGenerator(
  6385. /*#__PURE__*/
  6386. _regenerator["default"].mark(function _callee3(inputDate) {
  6387. var dateObject;
  6388. return _regenerator["default"].wrap(function _callee3$(
  6389. _context3) {
  6390. while (1) {
  6391. switch (_context3.prev = _context3
  6392. .next) {
  6393. case 0:
  6394. dateObject = _pdfjsLib
  6395. .PDFDateString.toDateObject(
  6396. inputDate);
  6397. if (dateObject) {
  6398. _context3.next = 3;
  6399. break;
  6400. }
  6401. return _context3.abrupt(
  6402. "return", undefined);
  6403. case 3:
  6404. return _context3.abrupt(
  6405. "return", this.l10n.get(
  6406. 'document_properties_date_string', {
  6407. date: dateObject
  6408. .toLocaleDateString(),
  6409. time: dateObject
  6410. .toLocaleTimeString()
  6411. },
  6412. '{{date}}, {{time}}'
  6413. ));
  6414. case 4:
  6415. case "end":
  6416. return _context3.stop();
  6417. }
  6418. }
  6419. }, _callee3, this);
  6420. }));
  6421. function _parseDate(_x3) {
  6422. return _parseDate2.apply(this, arguments);
  6423. }
  6424. return _parseDate;
  6425. }()
  6426. }, {
  6427. key: "_parseLinearization",
  6428. value: function _parseLinearization(isLinearized) {
  6429. return this.l10n.get('document_properties_linearized_' + (isLinearized ?
  6430. 'yes' : 'no'), null, isLinearized ? 'Yes' : 'No');
  6431. }
  6432. }]);
  6433. return PDFDocumentProperties;
  6434. }();
  6435. exports.PDFDocumentProperties = PDFDocumentProperties;
  6436. /***/
  6437. }),
  6438. /* 17 */
  6439. /***/
  6440. (function(module, exports, __webpack_require__) {
  6441. "use strict";
  6442. Object.defineProperty(exports, "__esModule", {
  6443. value: true
  6444. });
  6445. exports.PDFFindBar = void 0;
  6446. var _ui_utils = __webpack_require__(5);
  6447. var _pdf_find_controller = __webpack_require__(18);
  6448. function _classCallCheck(instance, Constructor) {
  6449. if (!(instance instanceof Constructor)) {
  6450. throw new TypeError("Cannot call a class as a function");
  6451. }
  6452. }
  6453. function _defineProperties(target, props) {
  6454. for (var i = 0; i < props.length; i++) {
  6455. var descriptor = props[i];
  6456. descriptor.enumerable = descriptor.enumerable || false;
  6457. descriptor.configurable = true;
  6458. if ("value" in descriptor) descriptor.writable = true;
  6459. Object.defineProperty(target, descriptor.key, descriptor);
  6460. }
  6461. }
  6462. function _createClass(Constructor, protoProps, staticProps) {
  6463. if (protoProps) _defineProperties(Constructor.prototype, protoProps);
  6464. if (staticProps) _defineProperties(Constructor, staticProps);
  6465. return Constructor;
  6466. }
  6467. var MATCHES_COUNT_LIMIT = 1000;
  6468. var PDFFindBar =
  6469. /*#__PURE__*/
  6470. function() {
  6471. function PDFFindBar(options) {
  6472. var _this = this;
  6473. var eventBus = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : (0,
  6474. _ui_utils.getGlobalEventBus)();
  6475. var l10n = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : _ui_utils
  6476. .NullL10n;
  6477. _classCallCheck(this, PDFFindBar);
  6478. this.opened = false;
  6479. this.bar = options.bar || null;
  6480. this.toggleButton = options.toggleButton || null;
  6481. this.findField = options.findField || null;
  6482. this.highlightAll = options.highlightAllCheckbox || null;
  6483. this.caseSensitive = options.caseSensitiveCheckbox || null;
  6484. this.entireWord = options.entireWordCheckbox || null;
  6485. this.findMsg = options.findMsg || null;
  6486. this.findResultsCount = options.findResultsCount || null;
  6487. this.findPreviousButton = options.findPreviousButton || null;
  6488. this.findNextButton = options.findNextButton || null;
  6489. this.eventBus = eventBus;
  6490. this.l10n = l10n;
  6491. this.toggleButton.addEventListener('click', function() {
  6492. _this.toggle();
  6493. });
  6494. this.findField.addEventListener('input', function() {
  6495. _this.dispatchEvent('');
  6496. });
  6497. this.bar.addEventListener('keydown', function(e) {
  6498. switch (e.keyCode) {
  6499. case 13:
  6500. if (e.target === _this.findField) {
  6501. _this.dispatchEvent('again', e.shiftKey);
  6502. }
  6503. break;
  6504. case 27:
  6505. _this.close();
  6506. break;
  6507. }
  6508. });
  6509. this.findPreviousButton.addEventListener('click', function() {
  6510. _this.dispatchEvent('again', true);
  6511. });
  6512. this.findNextButton.addEventListener('click', function() {
  6513. _this.dispatchEvent('again', false);
  6514. });
  6515. this.highlightAll.addEventListener('click', function() {
  6516. _this.dispatchEvent('highlightallchange');
  6517. });
  6518. this.caseSensitive.addEventListener('click', function() {
  6519. _this.dispatchEvent('casesensitivitychange');
  6520. });
  6521. this.entireWord.addEventListener('click', function() {
  6522. _this.dispatchEvent('entirewordchange');
  6523. });
  6524. this.eventBus.on('resize', this._adjustWidth.bind(this));
  6525. }
  6526. _createClass(PDFFindBar, [{
  6527. key: "reset",
  6528. value: function reset() {
  6529. this.updateUIState();
  6530. }
  6531. }, {
  6532. key: "dispatchEvent",
  6533. value: function dispatchEvent(type, findPrev) {
  6534. this.eventBus.dispatch('find', {
  6535. source: this,
  6536. type: type,
  6537. query: this.findField.value,
  6538. phraseSearch: true,
  6539. caseSensitive: this.caseSensitive.checked,
  6540. entireWord: this.entireWord.checked,
  6541. highlightAll: this.highlightAll.checked,
  6542. findPrevious: findPrev
  6543. });
  6544. }
  6545. }, {
  6546. key: "updateUIState",
  6547. value: function updateUIState(state, previous, matchesCount) {
  6548. var _this2 = this;
  6549. var notFound = false;
  6550. var findMsg = '';
  6551. var status = '';
  6552. switch (state) {
  6553. case _pdf_find_controller.FindState.FOUND:
  6554. break;
  6555. case _pdf_find_controller.FindState.PENDING:
  6556. status = 'pending';
  6557. break;
  6558. case _pdf_find_controller.FindState.NOT_FOUND:
  6559. findMsg = this.l10n.get('find_not_found', null,
  6560. 'Phrase not found');
  6561. notFound = true;
  6562. break;
  6563. case _pdf_find_controller.FindState.WRAPPED:
  6564. if (previous) {
  6565. findMsg = this.l10n.get('find_reached_top', null,
  6566. 'Reached top of document, continued from bottom');
  6567. } else {
  6568. findMsg = this.l10n.get('find_reached_bottom', null,
  6569. 'Reached end of document, continued from top');
  6570. }
  6571. break;
  6572. }
  6573. this.findField.classList.toggle('notFound', notFound);
  6574. this.findField.setAttribute('data-status', status);
  6575. Promise.resolve(findMsg).then(function(msg) {
  6576. _this2.findMsg.textContent = msg;
  6577. _this2._adjustWidth();
  6578. });
  6579. this.updateResultsCount(matchesCount);
  6580. }
  6581. }, {
  6582. key: "updateResultsCount",
  6583. value: function updateResultsCount() {
  6584. var _this3 = this;
  6585. var _ref = arguments.length > 0 && arguments[0] !== undefined ?
  6586. arguments[0] : {},
  6587. _ref$current = _ref.current,
  6588. current = _ref$current === void 0 ? 0 : _ref$current,
  6589. _ref$total = _ref.total,
  6590. total = _ref$total === void 0 ? 0 : _ref$total;
  6591. if (!this.findResultsCount) {
  6592. return;
  6593. }
  6594. var matchesCountMsg = '',
  6595. limit = MATCHES_COUNT_LIMIT;
  6596. if (total > 0) {
  6597. if (total > limit) {
  6598. matchesCountMsg = this.l10n.get('find_match_count_limit', {
  6599. limit: limit
  6600. }, 'More than {{limit}} match' + (limit !== 1 ? 'es' :
  6601. ''));
  6602. } else {
  6603. matchesCountMsg = this.l10n.get('find_match_count', {
  6604. current: current,
  6605. total: total
  6606. }, '{{current}} of {{total}} match' + (total !== 1 ?
  6607. 'es' : ''));
  6608. }
  6609. }
  6610. Promise.resolve(matchesCountMsg).then(function(msg) {
  6611. _this3.findResultsCount.textContent = msg;
  6612. _this3.findResultsCount.classList.toggle('hidden', !total);
  6613. _this3._adjustWidth();
  6614. });
  6615. }
  6616. }, {
  6617. key: "open",
  6618. value: function open() {
  6619. if (!this.opened) {
  6620. this.opened = true;
  6621. this.toggleButton.classList.add('toggled');
  6622. this.bar.classList.remove('hidden');
  6623. }
  6624. this.findField.select();
  6625. this.findField.focus();
  6626. this._adjustWidth();
  6627. }
  6628. }, {
  6629. key: "close",
  6630. value: function close() {
  6631. if (!this.opened) {
  6632. return;
  6633. }
  6634. this.opened = false;
  6635. this.toggleButton.classList.remove('toggled');
  6636. this.bar.classList.add('hidden');
  6637. this.eventBus.dispatch('findbarclose', {
  6638. source: this
  6639. });
  6640. }
  6641. }, {
  6642. key: "toggle",
  6643. value: function toggle() {
  6644. if (this.opened) {
  6645. this.close();
  6646. } else {
  6647. this.open();
  6648. }
  6649. }
  6650. }, {
  6651. key: "_adjustWidth",
  6652. value: function _adjustWidth() {
  6653. if (!this.opened) {
  6654. return;
  6655. }
  6656. this.bar.classList.remove('wrapContainers');
  6657. var findbarHeight = this.bar.clientHeight;
  6658. var inputContainerHeight = this.bar.firstElementChild.clientHeight;
  6659. if (findbarHeight > inputContainerHeight) {
  6660. this.bar.classList.add('wrapContainers');
  6661. }
  6662. }
  6663. }]);
  6664. return PDFFindBar;
  6665. }();
  6666. exports.PDFFindBar = PDFFindBar;
  6667. /***/
  6668. }),
  6669. /* 18 */
  6670. /***/
  6671. (function(module, exports, __webpack_require__) {
  6672. "use strict";
  6673. Object.defineProperty(exports, "__esModule", {
  6674. value: true
  6675. });
  6676. exports.PDFFindController = exports.FindState = void 0;
  6677. var _ui_utils = __webpack_require__(5);
  6678. var _pdfjsLib = __webpack_require__(7);
  6679. var _pdf_find_utils = __webpack_require__(19);
  6680. function _classCallCheck(instance, Constructor) {
  6681. if (!(instance instanceof Constructor)) {
  6682. throw new TypeError("Cannot call a class as a function");
  6683. }
  6684. }
  6685. function _defineProperties(target, props) {
  6686. for (var i = 0; i < props.length; i++) {
  6687. var descriptor = props[i];
  6688. descriptor.enumerable = descriptor.enumerable || false;
  6689. descriptor.configurable = true;
  6690. if ("value" in descriptor) descriptor.writable = true;
  6691. Object.defineProperty(target, descriptor.key, descriptor);
  6692. }
  6693. }
  6694. function _createClass(Constructor, protoProps, staticProps) {
  6695. if (protoProps) _defineProperties(Constructor.prototype, protoProps);
  6696. if (staticProps) _defineProperties(Constructor, staticProps);
  6697. return Constructor;
  6698. }
  6699. var FindState = {
  6700. FOUND: 0,
  6701. NOT_FOUND: 1,
  6702. WRAPPED: 2,
  6703. PENDING: 3
  6704. };
  6705. exports.FindState = FindState;
  6706. var FIND_TIMEOUT = 250;
  6707. var MATCH_SCROLL_OFFSET_TOP = -50;
  6708. var MATCH_SCROLL_OFFSET_LEFT = -400;
  6709. var CHARACTERS_TO_NORMALIZE = {
  6710. "\u2018": '\'',
  6711. "\u2019": '\'',
  6712. "\u201A": '\'',
  6713. "\u201B": '\'',
  6714. "\u201C": '"',
  6715. "\u201D": '"',
  6716. "\u201E": '"',
  6717. "\u201F": '"',
  6718. "\xBC": '1/4',
  6719. "\xBD": '1/2',
  6720. "\xBE": '3/4'
  6721. };
  6722. var normalizationRegex = null;
  6723. function normalize(text) {
  6724. if (!normalizationRegex) {
  6725. var replace = Object.keys(CHARACTERS_TO_NORMALIZE).join('');
  6726. normalizationRegex = new RegExp("[".concat(replace, "]"), 'g');
  6727. }
  6728. return text.replace(normalizationRegex, function(ch) {
  6729. return CHARACTERS_TO_NORMALIZE[ch];
  6730. });
  6731. }
  6732. var PDFFindController =
  6733. /*#__PURE__*/
  6734. function() {
  6735. function PDFFindController(_ref) {
  6736. var linkService = _ref.linkService,
  6737. _ref$eventBus = _ref.eventBus,
  6738. eventBus = _ref$eventBus === void 0 ? (0, _ui_utils.getGlobalEventBus)() :
  6739. _ref$eventBus;
  6740. _classCallCheck(this, PDFFindController);
  6741. this._linkService = linkService;
  6742. this._eventBus = eventBus;
  6743. this._reset();
  6744. eventBus.on('findbarclose', this._onFindBarClose.bind(this));
  6745. }
  6746. _createClass(PDFFindController, [{
  6747. key: "setDocument",
  6748. value: function setDocument(pdfDocument) {
  6749. if (this._pdfDocument) {
  6750. this._reset();
  6751. }
  6752. if (!pdfDocument) {
  6753. return;
  6754. }
  6755. this._pdfDocument = pdfDocument;
  6756. this._firstPageCapability.resolve();
  6757. }
  6758. }, {
  6759. key: "executeCommand",
  6760. value: function executeCommand(cmd, state) {
  6761. var _this = this;
  6762. if (!state) {
  6763. return;
  6764. }
  6765. var pdfDocument = this._pdfDocument;
  6766. if (this._state === null || this._shouldDirtyMatch(cmd, state)) {
  6767. this._dirtyMatch = true;
  6768. }
  6769. this._state = state;
  6770. if (cmd !== 'findhighlightallchange') {
  6771. this._updateUIState(FindState.PENDING);
  6772. }
  6773. this._firstPageCapability.promise.then(function() {
  6774. if (!_this._pdfDocument || pdfDocument && _this
  6775. ._pdfDocument !== pdfDocument) {
  6776. return;
  6777. }
  6778. _this._extractText();
  6779. var findbarClosed = !_this._highlightMatches;
  6780. var pendingTimeout = !!_this._findTimeout;
  6781. if (_this._findTimeout) {
  6782. clearTimeout(_this._findTimeout);
  6783. _this._findTimeout = null;
  6784. }
  6785. if (cmd === 'find') {
  6786. _this._findTimeout = setTimeout(function() {
  6787. _this._nextMatch();
  6788. _this._findTimeout = null;
  6789. }, FIND_TIMEOUT);
  6790. } else if (_this._dirtyMatch) {
  6791. _this._nextMatch();
  6792. } else if (cmd === 'findagain') {
  6793. _this._nextMatch();
  6794. if (findbarClosed && _this._state.highlightAll) {
  6795. _this._updateAllPages();
  6796. }
  6797. } else if (cmd === 'findhighlightallchange') {
  6798. if (pendingTimeout) {
  6799. _this._nextMatch();
  6800. } else {
  6801. _this._highlightMatches = true;
  6802. }
  6803. _this._updateAllPages();
  6804. } else {
  6805. _this._nextMatch();
  6806. }
  6807. });
  6808. }
  6809. }, {
  6810. key: "scrollMatchIntoView",
  6811. value: function scrollMatchIntoView(_ref2) {
  6812. var _ref2$element = _ref2.element,
  6813. element = _ref2$element === void 0 ? null : _ref2$element,
  6814. _ref2$pageIndex = _ref2.pageIndex,
  6815. pageIndex = _ref2$pageIndex === void 0 ? -1 : _ref2$pageIndex,
  6816. _ref2$matchIndex = _ref2.matchIndex,
  6817. matchIndex = _ref2$matchIndex === void 0 ? -1 : _ref2$matchIndex;
  6818. if (!this._scrollMatches || !element) {
  6819. return;
  6820. } else if (matchIndex === -1 || matchIndex !== this._selected
  6821. .matchIdx) {
  6822. return;
  6823. } else if (pageIndex === -1 || pageIndex !== this._selected.pageIdx) {
  6824. return;
  6825. }
  6826. this._scrollMatches = false;
  6827. var spot = {
  6828. top: MATCH_SCROLL_OFFSET_TOP,
  6829. left: MATCH_SCROLL_OFFSET_LEFT
  6830. };
  6831. (0, _ui_utils.scrollIntoView)(element, spot, true);
  6832. }
  6833. }, {
  6834. key: "_reset",
  6835. value: function _reset() {
  6836. this._highlightMatches = false;
  6837. this._scrollMatches = false;
  6838. this._pdfDocument = null;
  6839. this._pageMatches = [];
  6840. this._pageMatchesLength = [];
  6841. this._state = null;
  6842. this._selected = {
  6843. pageIdx: -1,
  6844. matchIdx: -1
  6845. };
  6846. this._offset = {
  6847. pageIdx: null,
  6848. matchIdx: null,
  6849. wrapped: false
  6850. };
  6851. this._extractTextPromises = [];
  6852. this._pageContents = [];
  6853. this._matchesCountTotal = 0;
  6854. this._pagesToSearch = null;
  6855. this._pendingFindMatches = Object.create(null);
  6856. this._resumePageIdx = null;
  6857. this._dirtyMatch = false;
  6858. clearTimeout(this._findTimeout);
  6859. this._findTimeout = null;
  6860. this._firstPageCapability = (0, _pdfjsLib.createPromiseCapability)();
  6861. }
  6862. }, {
  6863. key: "_shouldDirtyMatch",
  6864. value: function _shouldDirtyMatch(cmd, state) {
  6865. if (state.query !== this._state.query) {
  6866. return true;
  6867. }
  6868. switch (cmd) {
  6869. case 'findagain':
  6870. var pageNumber = this._selected.pageIdx + 1;
  6871. var linkService = this._linkService;
  6872. if (pageNumber >= 1 && pageNumber <= linkService.pagesCount &&
  6873. pageNumber !== linkService.page && !linkService
  6874. .isPageVisible(pageNumber)) {
  6875. return true;
  6876. }
  6877. return false;
  6878. case 'findhighlightallchange':
  6879. return false;
  6880. }
  6881. return true;
  6882. }
  6883. }, {
  6884. key: "_prepareMatches",
  6885. value: function _prepareMatches(matchesWithLength, matches, matchesLength) {
  6886. function isSubTerm(matchesWithLength, currentIndex) {
  6887. var currentElem = matchesWithLength[currentIndex];
  6888. var nextElem = matchesWithLength[currentIndex + 1];
  6889. if (currentIndex < matchesWithLength.length - 1 && currentElem
  6890. .match === nextElem.match) {
  6891. currentElem.skipped = true;
  6892. return true;
  6893. }
  6894. for (var i = currentIndex - 1; i >= 0; i--) {
  6895. var prevElem = matchesWithLength[i];
  6896. if (prevElem.skipped) {
  6897. continue;
  6898. }
  6899. if (prevElem.match + prevElem.matchLength < currentElem.match) {
  6900. break;
  6901. }
  6902. if (prevElem.match + prevElem.matchLength >= currentElem.match +
  6903. currentElem.matchLength) {
  6904. currentElem.skipped = true;
  6905. return true;
  6906. }
  6907. }
  6908. return false;
  6909. }
  6910. matchesWithLength.sort(function(a, b) {
  6911. return a.match === b.match ? a.matchLength - b.matchLength :
  6912. a.match - b.match;
  6913. });
  6914. for (var i = 0, len = matchesWithLength.length; i < len; i++) {
  6915. if (isSubTerm(matchesWithLength, i)) {
  6916. continue;
  6917. }
  6918. matches.push(matchesWithLength[i].match);
  6919. matchesLength.push(matchesWithLength[i].matchLength);
  6920. }
  6921. }
  6922. }, {
  6923. key: "_isEntireWord",
  6924. value: function _isEntireWord(content, startIdx, length) {
  6925. if (startIdx > 0) {
  6926. var first = content.charCodeAt(startIdx);
  6927. var limit = content.charCodeAt(startIdx - 1);
  6928. if ((0, _pdf_find_utils.getCharacterType)(first) === (0,
  6929. _pdf_find_utils.getCharacterType)(limit)) {
  6930. return false;
  6931. }
  6932. }
  6933. var endIdx = startIdx + length - 1;
  6934. if (endIdx < content.length - 1) {
  6935. var last = content.charCodeAt(endIdx);
  6936. var _limit = content.charCodeAt(endIdx + 1);
  6937. if ((0, _pdf_find_utils.getCharacterType)(last) === (0,
  6938. _pdf_find_utils.getCharacterType)(_limit)) {
  6939. return false;
  6940. }
  6941. }
  6942. return true;
  6943. }
  6944. }, {
  6945. key: "_calculatePhraseMatch",
  6946. value: function _calculatePhraseMatch(query, pageIndex, pageContent,
  6947. entireWord) {
  6948. var matches = [];
  6949. var queryLen = query.length;
  6950. var matchIdx = -queryLen;
  6951. while (true) {
  6952. matchIdx = pageContent.indexOf(query, matchIdx + queryLen);
  6953. if (matchIdx === -1) {
  6954. break;
  6955. }
  6956. if (entireWord && !this._isEntireWord(pageContent, matchIdx,
  6957. queryLen)) {
  6958. continue;
  6959. }
  6960. matches.push(matchIdx);
  6961. }
  6962. this._pageMatches[pageIndex] = matches;
  6963. }
  6964. }, {
  6965. key: "_calculateWordMatch",
  6966. value: function _calculateWordMatch(query, pageIndex, pageContent, entireWord) {
  6967. var matchesWithLength = [];
  6968. var queryArray = query.match(/\S+/g);
  6969. for (var i = 0, len = queryArray.length; i < len; i++) {
  6970. var subquery = queryArray[i];
  6971. var subqueryLen = subquery.length;
  6972. var matchIdx = -subqueryLen;
  6973. while (true) {
  6974. matchIdx = pageContent.indexOf(subquery, matchIdx +
  6975. subqueryLen);
  6976. if (matchIdx === -1) {
  6977. break;
  6978. }
  6979. if (entireWord && !this._isEntireWord(pageContent, matchIdx,
  6980. subqueryLen)) {
  6981. continue;
  6982. }
  6983. matchesWithLength.push({
  6984. match: matchIdx,
  6985. matchLength: subqueryLen,
  6986. skipped: false
  6987. });
  6988. }
  6989. }
  6990. this._pageMatchesLength[pageIndex] = [];
  6991. this._pageMatches[pageIndex] = [];
  6992. this._prepareMatches(matchesWithLength, this._pageMatches[pageIndex],
  6993. this._pageMatchesLength[pageIndex]);
  6994. }
  6995. }, {
  6996. key: "_calculateMatch",
  6997. value: function _calculateMatch(pageIndex) {
  6998. var pageContent = this._pageContents[pageIndex];
  6999. var query = this._query;
  7000. var _this$_state = this._state,
  7001. caseSensitive = _this$_state.caseSensitive,
  7002. entireWord = _this$_state.entireWord,
  7003. phraseSearch = _this$_state.phraseSearch;
  7004. if (query.length === 0) {
  7005. return;
  7006. }
  7007. if (!caseSensitive) {
  7008. pageContent = pageContent.toLowerCase();
  7009. query = query.toLowerCase();
  7010. }
  7011. if (phraseSearch) {
  7012. this._calculatePhraseMatch(query, pageIndex, pageContent,
  7013. entireWord);
  7014. } else {
  7015. this._calculateWordMatch(query, pageIndex, pageContent, entireWord);
  7016. }
  7017. if (this._state.highlightAll) {
  7018. this._updatePage(pageIndex);
  7019. }
  7020. if (this._resumePageIdx === pageIndex) {
  7021. this._resumePageIdx = null;
  7022. this._nextPageMatch();
  7023. }
  7024. var pageMatchesCount = this._pageMatches[pageIndex].length;
  7025. if (pageMatchesCount > 0) {
  7026. this._matchesCountTotal += pageMatchesCount;
  7027. this._updateUIResultsCount();
  7028. }
  7029. }
  7030. }, {
  7031. key: "_extractText",
  7032. value: function _extractText() {
  7033. var _this2 = this;
  7034. if (this._extractTextPromises.length > 0) {
  7035. return;
  7036. }
  7037. var promise = Promise.resolve();
  7038. var _loop = function _loop(i, ii) {
  7039. var extractTextCapability = (0, _pdfjsLib
  7040. .createPromiseCapability)();
  7041. _this2._extractTextPromises[i] = extractTextCapability.promise;
  7042. promise = promise.then(function() {
  7043. return _this2._pdfDocument.getPage(i + 1).then(
  7044. function(pdfPage) {
  7045. return pdfPage.getTextContent({
  7046. normalizeWhitespace: true
  7047. });
  7048. }).then(function(textContent) {
  7049. var textItems = textContent.items;
  7050. var strBuf = [];
  7051. for (var j = 0, jj = textItems
  7052. .length; j < jj; j++) {
  7053. strBuf.push(textItems[j].str);
  7054. }
  7055. _this2._pageContents[i] = normalize(
  7056. strBuf.join(''));
  7057. extractTextCapability.resolve(i);
  7058. }, function(reason) {
  7059. console.error(
  7060. "Unable to get text content for page "
  7061. .concat(i + 1), reason);
  7062. _this2._pageContents[i] = '';
  7063. extractTextCapability.resolve(i);
  7064. });
  7065. });
  7066. };
  7067. for (var i = 0, ii = this._linkService.pagesCount; i < ii; i++) {
  7068. _loop(i, ii);
  7069. }
  7070. }
  7071. }, {
  7072. key: "_updatePage",
  7073. value: function _updatePage(index) {
  7074. if (this._scrollMatches && this._selected.pageIdx === index) {
  7075. this._linkService.page = index + 1;
  7076. }
  7077. this._eventBus.dispatch('updatetextlayermatches', {
  7078. source: this,
  7079. pageIndex: index
  7080. });
  7081. }
  7082. }, {
  7083. key: "_updateAllPages",
  7084. value: function _updateAllPages() {
  7085. this._eventBus.dispatch('updatetextlayermatches', {
  7086. source: this,
  7087. pageIndex: -1
  7088. });
  7089. }
  7090. }, {
  7091. key: "_nextMatch",
  7092. value: function _nextMatch() {
  7093. var _this3 = this;
  7094. var previous = this._state.findPrevious;
  7095. var currentPageIndex = this._linkService.page - 1;
  7096. var numPages = this._linkService.pagesCount;
  7097. this._highlightMatches = true;
  7098. if (this._dirtyMatch) {
  7099. this._dirtyMatch = false;
  7100. this._selected.pageIdx = this._selected.matchIdx = -1;
  7101. this._offset.pageIdx = currentPageIndex;
  7102. this._offset.matchIdx = null;
  7103. this._offset.wrapped = false;
  7104. this._resumePageIdx = null;
  7105. this._pageMatches.length = 0;
  7106. this._pageMatchesLength.length = 0;
  7107. this._matchesCountTotal = 0;
  7108. this._updateAllPages();
  7109. for (var i = 0; i < numPages; i++) {
  7110. if (this._pendingFindMatches[i] === true) {
  7111. continue;
  7112. }
  7113. this._pendingFindMatches[i] = true;
  7114. this._extractTextPromises[i].then(function(pageIdx) {
  7115. delete _this3._pendingFindMatches[pageIdx];
  7116. _this3._calculateMatch(pageIdx);
  7117. });
  7118. }
  7119. }
  7120. if (this._query === '') {
  7121. this._updateUIState(FindState.FOUND);
  7122. return;
  7123. }
  7124. if (this._resumePageIdx) {
  7125. return;
  7126. }
  7127. var offset = this._offset;
  7128. this._pagesToSearch = numPages;
  7129. if (offset.matchIdx !== null) {
  7130. var numPageMatches = this._pageMatches[offset.pageIdx].length;
  7131. if (!previous && offset.matchIdx + 1 < numPageMatches || previous &&
  7132. offset.matchIdx > 0) {
  7133. offset.matchIdx = previous ? offset.matchIdx - 1 : offset
  7134. .matchIdx + 1;
  7135. this._updateMatch(true);
  7136. return;
  7137. }
  7138. this._advanceOffsetPage(previous);
  7139. }
  7140. this._nextPageMatch();
  7141. }
  7142. }, {
  7143. key: "_matchesReady",
  7144. value: function _matchesReady(matches) {
  7145. var offset = this._offset;
  7146. var numMatches = matches.length;
  7147. var previous = this._state.findPrevious;
  7148. if (numMatches) {
  7149. offset.matchIdx = previous ? numMatches - 1 : 0;
  7150. this._updateMatch(true);
  7151. return true;
  7152. }
  7153. this._advanceOffsetPage(previous);
  7154. if (offset.wrapped) {
  7155. offset.matchIdx = null;
  7156. if (this._pagesToSearch < 0) {
  7157. this._updateMatch(false);
  7158. return true;
  7159. }
  7160. }
  7161. return false;
  7162. }
  7163. }, {
  7164. key: "_nextPageMatch",
  7165. value: function _nextPageMatch() {
  7166. if (this._resumePageIdx !== null) {
  7167. console.error('There can only be one pending page.');
  7168. }
  7169. var matches = null;
  7170. do {
  7171. var pageIdx = this._offset.pageIdx;
  7172. matches = this._pageMatches[pageIdx];
  7173. if (!matches) {
  7174. this._resumePageIdx = pageIdx;
  7175. break;
  7176. }
  7177. } while (!this._matchesReady(matches));
  7178. }
  7179. }, {
  7180. key: "_advanceOffsetPage",
  7181. value: function _advanceOffsetPage(previous) {
  7182. var offset = this._offset;
  7183. var numPages = this._linkService.pagesCount;
  7184. offset.pageIdx = previous ? offset.pageIdx - 1 : offset.pageIdx + 1;
  7185. offset.matchIdx = null;
  7186. this._pagesToSearch--;
  7187. if (offset.pageIdx >= numPages || offset.pageIdx < 0) {
  7188. offset.pageIdx = previous ? numPages - 1 : 0;
  7189. offset.wrapped = true;
  7190. }
  7191. }
  7192. }, {
  7193. key: "_updateMatch",
  7194. value: function _updateMatch() {
  7195. var found = arguments.length > 0 && arguments[0] !== undefined ?
  7196. arguments[0] : false;
  7197. var state = FindState.NOT_FOUND;
  7198. var wrapped = this._offset.wrapped;
  7199. this._offset.wrapped = false;
  7200. if (found) {
  7201. var previousPage = this._selected.pageIdx;
  7202. this._selected.pageIdx = this._offset.pageIdx;
  7203. this._selected.matchIdx = this._offset.matchIdx;
  7204. state = wrapped ? FindState.WRAPPED : FindState.FOUND;
  7205. if (previousPage !== -1 && previousPage !== this._selected
  7206. .pageIdx) {
  7207. this._updatePage(previousPage);
  7208. }
  7209. }
  7210. this._updateUIState(state, this._state.findPrevious);
  7211. if (this._selected.pageIdx !== -1) {
  7212. this._scrollMatches = true;
  7213. this._updatePage(this._selected.pageIdx);
  7214. }
  7215. }
  7216. }, {
  7217. key: "_onFindBarClose",
  7218. value: function _onFindBarClose(evt) {
  7219. var _this4 = this;
  7220. var pdfDocument = this._pdfDocument;
  7221. this._firstPageCapability.promise.then(function() {
  7222. if (!_this4._pdfDocument || pdfDocument && _this4
  7223. ._pdfDocument !== pdfDocument) {
  7224. return;
  7225. }
  7226. if (_this4._findTimeout) {
  7227. clearTimeout(_this4._findTimeout);
  7228. _this4._findTimeout = null;
  7229. }
  7230. if (_this4._resumePageIdx) {
  7231. _this4._resumePageIdx = null;
  7232. _this4._dirtyMatch = true;
  7233. }
  7234. _this4._updateUIState(FindState.FOUND);
  7235. _this4._highlightMatches = false;
  7236. _this4._updateAllPages();
  7237. });
  7238. }
  7239. }, {
  7240. key: "_requestMatchesCount",
  7241. value: function _requestMatchesCount() {
  7242. var _this$_selected = this._selected,
  7243. pageIdx = _this$_selected.pageIdx,
  7244. matchIdx = _this$_selected.matchIdx;
  7245. var current = 0,
  7246. total = this._matchesCountTotal;
  7247. if (matchIdx !== -1) {
  7248. for (var i = 0; i < pageIdx; i++) {
  7249. current += this._pageMatches[i] && this._pageMatches[i]
  7250. .length || 0;
  7251. }
  7252. current += matchIdx + 1;
  7253. }
  7254. if (current < 1 || current > total) {
  7255. current = total = 0;
  7256. }
  7257. return {
  7258. current: current,
  7259. total: total
  7260. };
  7261. }
  7262. }, {
  7263. key: "_updateUIResultsCount",
  7264. value: function _updateUIResultsCount() {
  7265. this._eventBus.dispatch('updatefindmatchescount', {
  7266. source: this,
  7267. matchesCount: this._requestMatchesCount()
  7268. });
  7269. }
  7270. }, {
  7271. key: "_updateUIState",
  7272. value: function _updateUIState(state, previous) {
  7273. this._eventBus.dispatch('updatefindcontrolstate', {
  7274. source: this,
  7275. state: state,
  7276. previous: previous,
  7277. matchesCount: this._requestMatchesCount()
  7278. });
  7279. }
  7280. }, {
  7281. key: "highlightMatches",
  7282. get: function get() {
  7283. return this._highlightMatches;
  7284. }
  7285. }, {
  7286. key: "pageMatches",
  7287. get: function get() {
  7288. return this._pageMatches;
  7289. }
  7290. }, {
  7291. key: "pageMatchesLength",
  7292. get: function get() {
  7293. return this._pageMatchesLength;
  7294. }
  7295. }, {
  7296. key: "selected",
  7297. get: function get() {
  7298. return this._selected;
  7299. }
  7300. }, {
  7301. key: "state",
  7302. get: function get() {
  7303. return this._state;
  7304. }
  7305. }, {
  7306. key: "_query",
  7307. get: function get() {
  7308. if (this._state.query !== this._rawQuery) {
  7309. this._rawQuery = this._state.query;
  7310. this._normalizedQuery = normalize(this._state.query);
  7311. }
  7312. return this._normalizedQuery;
  7313. }
  7314. }]);
  7315. return PDFFindController;
  7316. }();
  7317. exports.PDFFindController = PDFFindController;
  7318. /***/
  7319. }),
  7320. /* 19 */
  7321. /***/
  7322. (function(module, exports, __webpack_require__) {
  7323. "use strict";
  7324. Object.defineProperty(exports, "__esModule", {
  7325. value: true
  7326. });
  7327. exports.getCharacterType = getCharacterType;
  7328. exports.CharacterType = void 0;
  7329. var CharacterType = {
  7330. SPACE: 0,
  7331. ALPHA_LETTER: 1,
  7332. PUNCT: 2,
  7333. HAN_LETTER: 3,
  7334. KATAKANA_LETTER: 4,
  7335. HIRAGANA_LETTER: 5,
  7336. HALFWIDTH_KATAKANA_LETTER: 6,
  7337. THAI_LETTER: 7
  7338. };
  7339. exports.CharacterType = CharacterType;
  7340. function isAlphabeticalScript(charCode) {
  7341. return charCode < 0x2E80;
  7342. }
  7343. function isAscii(charCode) {
  7344. return (charCode & 0xFF80) === 0;
  7345. }
  7346. function isAsciiAlpha(charCode) {
  7347. return charCode >= 0x61 && charCode <= 0x7A || charCode >= 0x41 && charCode <= 0x5A;
  7348. }
  7349. function isAsciiDigit(charCode) {
  7350. return charCode >= 0x30 && charCode <= 0x39;
  7351. }
  7352. function isAsciiSpace(charCode) {
  7353. return charCode === 0x20 || charCode === 0x09 || charCode === 0x0D || charCode === 0x0A;
  7354. }
  7355. function isHan(charCode) {
  7356. return charCode >= 0x3400 && charCode <= 0x9FFF || charCode >= 0xF900 && charCode <= 0xFAFF;
  7357. }
  7358. function isKatakana(charCode) {
  7359. return charCode >= 0x30A0 && charCode <= 0x30FF;
  7360. }
  7361. function isHiragana(charCode) {
  7362. return charCode >= 0x3040 && charCode <= 0x309F;
  7363. }
  7364. function isHalfwidthKatakana(charCode) {
  7365. return charCode >= 0xFF60 && charCode <= 0xFF9F;
  7366. }
  7367. function isThai(charCode) {
  7368. return (charCode & 0xFF80) === 0x0E00;
  7369. }
  7370. function getCharacterType(charCode) {
  7371. if (isAlphabeticalScript(charCode)) {
  7372. if (isAscii(charCode)) {
  7373. if (isAsciiSpace(charCode)) {
  7374. return CharacterType.SPACE;
  7375. } else if (isAsciiAlpha(charCode) || isAsciiDigit(charCode) || charCode === 0x5F) {
  7376. return CharacterType.ALPHA_LETTER;
  7377. }
  7378. return CharacterType.PUNCT;
  7379. } else if (isThai(charCode)) {
  7380. return CharacterType.THAI_LETTER;
  7381. } else if (charCode === 0xA0) {
  7382. return CharacterType.SPACE;
  7383. }
  7384. return CharacterType.ALPHA_LETTER;
  7385. }
  7386. if (isHan(charCode)) {
  7387. return CharacterType.HAN_LETTER;
  7388. } else if (isKatakana(charCode)) {
  7389. return CharacterType.KATAKANA_LETTER;
  7390. } else if (isHiragana(charCode)) {
  7391. return CharacterType.HIRAGANA_LETTER;
  7392. } else if (isHalfwidthKatakana(charCode)) {
  7393. return CharacterType.HALFWIDTH_KATAKANA_LETTER;
  7394. }
  7395. return CharacterType.ALPHA_LETTER;
  7396. }
  7397. /***/
  7398. }),
  7399. /* 20 */
  7400. /***/
  7401. (function(module, exports, __webpack_require__) {
  7402. "use strict";
  7403. Object.defineProperty(exports, "__esModule", {
  7404. value: true
  7405. });
  7406. exports.isDestHashesEqual = isDestHashesEqual;
  7407. exports.isDestArraysEqual = isDestArraysEqual;
  7408. exports.PDFHistory = void 0;
  7409. var _ui_utils = __webpack_require__(5);
  7410. function _typeof(obj) {
  7411. if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
  7412. _typeof = function _typeof(obj) {
  7413. return typeof obj;
  7414. };
  7415. } else {
  7416. _typeof = function _typeof(obj) {
  7417. return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !==
  7418. Symbol.prototype ? "symbol" : typeof obj;
  7419. };
  7420. }
  7421. return _typeof(obj);
  7422. }
  7423. function _slicedToArray(arr, i) {
  7424. return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest();
  7425. }
  7426. function _nonIterableRest() {
  7427. throw new TypeError("Invalid attempt to destructure non-iterable instance");
  7428. }
  7429. function _iterableToArrayLimit(arr, i) {
  7430. if (!(Symbol.iterator in Object(arr) || Object.prototype.toString.call(arr) ===
  7431. "[object Arguments]")) {
  7432. return;
  7433. }
  7434. var _arr = [];
  7435. var _n = true;
  7436. var _d = false;
  7437. var _e = undefined;
  7438. try {
  7439. for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {
  7440. _arr.push(_s.value);
  7441. if (i && _arr.length === i) break;
  7442. }
  7443. } catch (err) {
  7444. _d = true;
  7445. _e = err;
  7446. } finally {
  7447. try {
  7448. if (!_n && _i["return"] != null) _i["return"]();
  7449. } finally {
  7450. if (_d) throw _e;
  7451. }
  7452. }
  7453. return _arr;
  7454. }
  7455. function _arrayWithHoles(arr) {
  7456. if (Array.isArray(arr)) return arr;
  7457. }
  7458. function _classCallCheck(instance, Constructor) {
  7459. if (!(instance instanceof Constructor)) {
  7460. throw new TypeError("Cannot call a class as a function");
  7461. }
  7462. }
  7463. function _defineProperties(target, props) {
  7464. for (var i = 0; i < props.length; i++) {
  7465. var descriptor = props[i];
  7466. descriptor.enumerable = descriptor.enumerable || false;
  7467. descriptor.configurable = true;
  7468. if ("value" in descriptor) descriptor.writable = true;
  7469. Object.defineProperty(target, descriptor.key, descriptor);
  7470. }
  7471. }
  7472. function _createClass(Constructor, protoProps, staticProps) {
  7473. if (protoProps) _defineProperties(Constructor.prototype, protoProps);
  7474. if (staticProps) _defineProperties(Constructor, staticProps);
  7475. return Constructor;
  7476. }
  7477. var HASH_CHANGE_TIMEOUT = 1000;
  7478. var POSITION_UPDATED_THRESHOLD = 50;
  7479. var UPDATE_VIEWAREA_TIMEOUT = 1000;
  7480. function getCurrentHash() {
  7481. return document.location.hash;
  7482. }
  7483. function parseCurrentHash(linkService) {
  7484. var hash = unescape(getCurrentHash()).substring(1);
  7485. var params = (0, _ui_utils.parseQueryString)(hash);
  7486. var page = params.page | 0;
  7487. if (!(Number.isInteger(page) && page > 0 && page <= linkService.pagesCount)) {
  7488. page = null;
  7489. }
  7490. return {
  7491. hash: hash,
  7492. page: page,
  7493. rotation: linkService.rotation
  7494. };
  7495. }
  7496. var PDFHistory =
  7497. /*#__PURE__*/
  7498. function() {
  7499. function PDFHistory(_ref) {
  7500. var _this = this;
  7501. var linkService = _ref.linkService,
  7502. eventBus = _ref.eventBus;
  7503. _classCallCheck(this, PDFHistory);
  7504. this.linkService = linkService;
  7505. this.eventBus = eventBus || (0, _ui_utils.getGlobalEventBus)();
  7506. this.initialized = false;
  7507. this.initialBookmark = null;
  7508. this.initialRotation = null;
  7509. this._boundEvents = Object.create(null);
  7510. this._isViewerInPresentationMode = false;
  7511. this._isPagesLoaded = false;
  7512. this.eventBus.on('presentationmodechanged', function(evt) {
  7513. _this._isViewerInPresentationMode = evt.active || evt.switchInProgress;
  7514. });
  7515. this.eventBus.on('pagesloaded', function(evt) {
  7516. _this._isPagesLoaded = !!evt.pagesCount;
  7517. });
  7518. }
  7519. //pdf预览历史
  7520. _createClass(PDFHistory, [{
  7521. key: "initialize",
  7522. value: function initialize(_ref2) {
  7523. var fingerprint = _ref2.fingerprint,
  7524. _ref2$resetHistory = _ref2.resetHistory,
  7525. resetHistory = _ref2$resetHistory === void 0 ? false :
  7526. _ref2$resetHistory,
  7527. _ref2$updateUrl = _ref2.updateUrl,
  7528. updateUrl = _ref2$updateUrl === void 0 ? false : _ref2$updateUrl;
  7529. if (!fingerprint || typeof fingerprint !== 'string') {
  7530. console.error(
  7531. 'PDFHistory.initialize: The "fingerprint" must be a non-empty string.'
  7532. );
  7533. return;
  7534. }
  7535. var reInitialized = this.initialized && this.fingerprint !==
  7536. fingerprint;
  7537. this.fingerprint = fingerprint;
  7538. this._updateUrl = updateUrl === true;
  7539. if (!this.initialized) {
  7540. this._bindEvents();
  7541. }
  7542. var state = window.history.state;
  7543. this.initialized = true;
  7544. this.initialBookmark = null;
  7545. this.initialRotation = null;
  7546. this._popStateInProgress = false;
  7547. this._blockHashChange = 0;
  7548. this._currentHash = getCurrentHash();
  7549. this._numPositionUpdates = 0;
  7550. this._uid = this._maxUid = 0;
  7551. this._destination = null;
  7552. this._position = null;
  7553. if (!this._isValidState(state, true) || resetHistory) {
  7554. var _parseCurrentHash = parseCurrentHash(this.linkService),
  7555. hash = _parseCurrentHash.hash,
  7556. page = _parseCurrentHash.page,
  7557. rotation = _parseCurrentHash.rotation;
  7558. if (!hash || reInitialized || resetHistory) {
  7559. this._pushOrReplaceState(null, true);
  7560. return;
  7561. }
  7562. this._pushOrReplaceState({
  7563. hash: hash,
  7564. page: page,
  7565. rotation: rotation
  7566. }, true);
  7567. return;
  7568. }
  7569. var destination = state.destination;
  7570. this._updateInternalState(destination, state.uid, true);
  7571. if (this._uid > this._maxUid) {
  7572. this._maxUid = this._uid;
  7573. }
  7574. if (destination.rotation !== undefined) {
  7575. this.initialRotation = destination.rotation;
  7576. }
  7577. if (destination.dest) {
  7578. this.initialBookmark = JSON.stringify(destination.dest);
  7579. this._destination.page = null;
  7580. } else if (destination.hash) {
  7581. this.initialBookmark = destination.hash;
  7582. } else if (destination.page) {
  7583. this.initialBookmark = "page=".concat(destination.page);
  7584. }
  7585. }
  7586. }, {
  7587. key: "push",
  7588. value: function push(_ref3) {
  7589. var _this2 = this;
  7590. var _ref3$namedDest = _ref3.namedDest,
  7591. namedDest = _ref3$namedDest === void 0 ? null : _ref3$namedDest,
  7592. explicitDest = _ref3.explicitDest,
  7593. pageNumber = _ref3.pageNumber;
  7594. if (!this.initialized) {
  7595. return;
  7596. }
  7597. if (namedDest && typeof namedDest !== 'string') {
  7598. console.error('PDFHistory.push: ' + "\"".concat(namedDest,
  7599. "\" is not a valid namedDest parameter."));
  7600. return;
  7601. } else if (!Array.isArray(explicitDest)) {
  7602. console.error('PDFHistory.push: ' + "\"".concat(explicitDest,
  7603. "\" is not a valid explicitDest parameter."));
  7604. return;
  7605. } else if (!(Number.isInteger(pageNumber) && pageNumber > 0 &&
  7606. pageNumber <= this.linkService.pagesCount)) {
  7607. if (pageNumber !== null || this._destination) {
  7608. console.error('PDFHistory.push: ' + "\"".concat(pageNumber,
  7609. "\" is not a valid pageNumber parameter."));
  7610. return;
  7611. }
  7612. }
  7613. var hash = namedDest || JSON.stringify(explicitDest);
  7614. if (!hash) {
  7615. return;
  7616. }
  7617. var forceReplace = false;
  7618. if (this._destination && (isDestHashesEqual(this._destination.hash,
  7619. hash) || isDestArraysEqual(this._destination.dest,
  7620. explicitDest))) {
  7621. if (this._destination.page) {
  7622. return;
  7623. }
  7624. forceReplace = true;
  7625. }
  7626. if (this._popStateInProgress && !forceReplace) {
  7627. return;
  7628. }
  7629. this._pushOrReplaceState({
  7630. dest: explicitDest,
  7631. hash: hash,
  7632. page: pageNumber,
  7633. rotation: this.linkService.rotation
  7634. }, forceReplace);
  7635. if (!this._popStateInProgress) {
  7636. this._popStateInProgress = true;
  7637. Promise.resolve().then(function() {
  7638. _this2._popStateInProgress = false;
  7639. });
  7640. }
  7641. }
  7642. }, {
  7643. key: "pushCurrentPosition",
  7644. value: function pushCurrentPosition() {
  7645. if (!this.initialized || this._popStateInProgress) {
  7646. return;
  7647. }
  7648. this._tryPushCurrentPosition();
  7649. }
  7650. }, {
  7651. key: "back",
  7652. value: function back() {
  7653. if (!this.initialized || this._popStateInProgress) {
  7654. return;
  7655. }
  7656. var state = window.history.state;
  7657. if (this._isValidState(state) && state.uid > 0) {
  7658. window.history.back();
  7659. }
  7660. }
  7661. }, {
  7662. key: "forward",
  7663. value: function forward() {
  7664. if (!this.initialized || this._popStateInProgress) {
  7665. return;
  7666. }
  7667. var state = window.history.state;
  7668. if (this._isValidState(state) && state.uid < this._maxUid) {
  7669. window.history.forward();
  7670. }
  7671. }
  7672. }, {
  7673. key: "_pushOrReplaceState",
  7674. value: function _pushOrReplaceState(destination) {
  7675. var forceReplace = arguments.length > 1 && arguments[1] !== undefined ?
  7676. arguments[1] : false;
  7677. var shouldReplace = forceReplace || !this._destination;
  7678. var newState = {
  7679. fingerprint: this.fingerprint,
  7680. uid: shouldReplace ? this._uid : this._uid + 1,
  7681. destination: destination
  7682. };
  7683. this._updateInternalState(destination, newState.uid);
  7684. var newUrl;
  7685. if (this._updateUrl && destination && destination.hash) {
  7686. var baseUrl = document.location.href.split('#')[0];
  7687. if (!baseUrl.startsWith('file://')) {
  7688. newUrl = "".concat(baseUrl, "#").concat(destination.hash);
  7689. }
  7690. }
  7691. if (shouldReplace) {
  7692. if (newUrl) {
  7693. window.history.replaceState(newState, '', newUrl);
  7694. } else {
  7695. window.history.replaceState(newState, '');
  7696. }
  7697. } else {
  7698. this._maxUid = this._uid;
  7699. if (newUrl) {
  7700. window.history.pushState(newState, '', newUrl);
  7701. } else {
  7702. window.history.pushState(newState, '');
  7703. }
  7704. }
  7705. }
  7706. }, {
  7707. key: "_tryPushCurrentPosition",
  7708. value: function _tryPushCurrentPosition() {
  7709. var temporary = arguments.length > 0 && arguments[0] !== undefined ?
  7710. arguments[0] : false;
  7711. if (!this._position) {
  7712. return;
  7713. }
  7714. var position = this._position;
  7715. if (temporary) {
  7716. position = Object.assign(Object.create(null), this._position);
  7717. position.temporary = true;
  7718. }
  7719. if (!this._destination) {
  7720. this._pushOrReplaceState(position);
  7721. return;
  7722. }
  7723. if (this._destination.temporary) {
  7724. this._pushOrReplaceState(position, true);
  7725. return;
  7726. }
  7727. if (this._destination.hash === position.hash) {
  7728. return;
  7729. }
  7730. if (!this._destination.page && (POSITION_UPDATED_THRESHOLD <= 0 || this
  7731. ._numPositionUpdates <= POSITION_UPDATED_THRESHOLD)) {
  7732. return;
  7733. }
  7734. var forceReplace = false;
  7735. if (this._destination.page >= position.first && this._destination
  7736. .page <= position.page) {
  7737. if (this._destination.dest || !this._destination.first) {
  7738. return;
  7739. }
  7740. forceReplace = true;
  7741. }
  7742. this._pushOrReplaceState(position, forceReplace);
  7743. }
  7744. }, {
  7745. key: "_isValidState",
  7746. value: function _isValidState(state) {
  7747. var checkReload = arguments.length > 1 && arguments[1] !== undefined ?
  7748. arguments[1] : false;
  7749. if (!state) {
  7750. return false;
  7751. }
  7752. if (state.fingerprint !== this.fingerprint) {
  7753. if (checkReload) {
  7754. if (typeof state.fingerprint !== 'string' || state.fingerprint
  7755. .length !== this.fingerprint.length) {
  7756. return false;
  7757. }
  7758. var _performance$getEntri = performance.getEntriesByType(
  7759. 'navigation'),
  7760. _performance$getEntri2 = _slicedToArray(
  7761. _performance$getEntri, 1),
  7762. perfEntry = _performance$getEntri2[0];
  7763. if (!perfEntry || perfEntry.type !== 'reload') {
  7764. return false;
  7765. }
  7766. } else {
  7767. return false;
  7768. }
  7769. }
  7770. if (!Number.isInteger(state.uid) || state.uid < 0) {
  7771. return false;
  7772. }
  7773. if (state.destination === null || _typeof(state.destination) !==
  7774. 'object') {
  7775. return false;
  7776. }
  7777. return true;
  7778. }
  7779. }, {
  7780. key: "_updateInternalState",
  7781. value: function _updateInternalState(destination, uid) {
  7782. var removeTemporary = arguments.length > 2 && arguments[2] !==
  7783. undefined ? arguments[2] : false;
  7784. if (this._updateViewareaTimeout) {
  7785. clearTimeout(this._updateViewareaTimeout);
  7786. this._updateViewareaTimeout = null;
  7787. }
  7788. if (removeTemporary && destination && destination.temporary) {
  7789. delete destination.temporary;
  7790. }
  7791. this._destination = destination;
  7792. this._uid = uid;
  7793. this._numPositionUpdates = 0;
  7794. }
  7795. }, {
  7796. key: "_updateViewarea",
  7797. value: function _updateViewarea(_ref4) {
  7798. var _this3 = this;
  7799. var location = _ref4.location;
  7800. if (this._updateViewareaTimeout) {
  7801. clearTimeout(this._updateViewareaTimeout);
  7802. this._updateViewareaTimeout = null;
  7803. }
  7804. this._position = {
  7805. hash: this._isViewerInPresentationMode ? "page=".concat(location
  7806. .pageNumber) : location.pdfOpenParams.substring(1),
  7807. page: this.linkService.page,
  7808. first: location.pageNumber,
  7809. rotation: location.rotation
  7810. };
  7811. if (this._popStateInProgress) {
  7812. return;
  7813. }
  7814. if (POSITION_UPDATED_THRESHOLD > 0 && this._isPagesLoaded && this
  7815. ._destination && !this._destination.page) {
  7816. this._numPositionUpdates++;
  7817. }
  7818. if (UPDATE_VIEWAREA_TIMEOUT > 0) {
  7819. this._updateViewareaTimeout = setTimeout(function() {
  7820. if (!_this3._popStateInProgress) {
  7821. _this3._tryPushCurrentPosition(true);
  7822. }
  7823. _this3._updateViewareaTimeout = null;
  7824. }, UPDATE_VIEWAREA_TIMEOUT);
  7825. }
  7826. }
  7827. }, {
  7828. key: "_popState",
  7829. value: function _popState(_ref5) {
  7830. var _this4 = this;
  7831. var state = _ref5.state;
  7832. var newHash = getCurrentHash(),
  7833. hashChanged = this._currentHash !== newHash;
  7834. this._currentHash = newHash;
  7835. if (!state || false) {
  7836. this._uid++;
  7837. var _parseCurrentHash2 = parseCurrentHash(this.linkService),
  7838. hash = _parseCurrentHash2.hash,
  7839. page = _parseCurrentHash2.page,
  7840. rotation = _parseCurrentHash2.rotation;
  7841. this._pushOrReplaceState({
  7842. hash: hash,
  7843. page: page,
  7844. rotation: rotation
  7845. }, true);
  7846. return;
  7847. }
  7848. if (!this._isValidState(state)) {
  7849. return;
  7850. }
  7851. this._popStateInProgress = true;
  7852. if (hashChanged) {
  7853. this._blockHashChange++;
  7854. (0, _ui_utils.waitOnEventOrTimeout)({
  7855. target: window,
  7856. name: 'hashchange',
  7857. delay: HASH_CHANGE_TIMEOUT
  7858. }).then(function() {
  7859. _this4._blockHashChange--;
  7860. });
  7861. }
  7862. var destination = state.destination;
  7863. this._updateInternalState(destination, state.uid, true);
  7864. if (this._uid > this._maxUid) {
  7865. this._maxUid = this._uid;
  7866. }
  7867. if ((0, _ui_utils.isValidRotation)(destination.rotation)) {
  7868. this.linkService.rotation = destination.rotation;
  7869. }
  7870. if (destination.dest) {
  7871. this.linkService.navigateTo(destination.dest);
  7872. } else if (destination.hash) {
  7873. this.linkService.setHash(destination.hash);
  7874. } else if (destination.page) {
  7875. this.linkService.page = destination.page;
  7876. }
  7877. Promise.resolve().then(function() {
  7878. _this4._popStateInProgress = false;
  7879. });
  7880. }
  7881. }, {
  7882. key: "_bindEvents",
  7883. value: function _bindEvents() {
  7884. var _this5 = this;
  7885. var _boundEvents = this._boundEvents,
  7886. eventBus = this.eventBus;
  7887. _boundEvents.updateViewarea = this._updateViewarea.bind(this);
  7888. _boundEvents.popState = this._popState.bind(this);
  7889. _boundEvents.pageHide = function(evt) {
  7890. if (!_this5._destination || _this5._destination.temporary) {
  7891. _this5._tryPushCurrentPosition();
  7892. }
  7893. };
  7894. eventBus.on('updateviewarea', _boundEvents.updateViewarea);
  7895. window.addEventListener('popstate', _boundEvents.popState);
  7896. window.addEventListener('pagehide', _boundEvents.pageHide);
  7897. }
  7898. }, {
  7899. key: "popStateInProgress",
  7900. get: function get() {
  7901. return this.initialized && (this._popStateInProgress || this
  7902. ._blockHashChange > 0);
  7903. }
  7904. }]);
  7905. return PDFHistory;
  7906. }();
  7907. exports.PDFHistory = PDFHistory;
  7908. function isDestHashesEqual(destHash, pushHash) {
  7909. if (typeof destHash !== 'string' || typeof pushHash !== 'string') {
  7910. return false;
  7911. }
  7912. if (destHash === pushHash) {
  7913. return true;
  7914. }
  7915. var _parseQueryString = (0, _ui_utils.parseQueryString)(destHash),
  7916. nameddest = _parseQueryString.nameddest;
  7917. if (nameddest === pushHash) {
  7918. return true;
  7919. }
  7920. return false;
  7921. }
  7922. function isDestArraysEqual(firstDest, secondDest) {
  7923. function isEntryEqual(first, second) {
  7924. if (_typeof(first) !== _typeof(second)) {
  7925. return false;
  7926. }
  7927. if (Array.isArray(first) || Array.isArray(second)) {
  7928. return false;
  7929. }
  7930. if (first !== null && _typeof(first) === 'object' && second !== null) {
  7931. if (Object.keys(first).length !== Object.keys(second).length) {
  7932. return false;
  7933. }
  7934. for (var key in first) {
  7935. if (!isEntryEqual(first[key], second[key])) {
  7936. return false;
  7937. }
  7938. }
  7939. return true;
  7940. }
  7941. return first === second || Number.isNaN(first) && Number.isNaN(second);
  7942. }
  7943. if (!(Array.isArray(firstDest) && Array.isArray(secondDest))) {
  7944. return false;
  7945. }
  7946. if (firstDest.length !== secondDest.length) {
  7947. return false;
  7948. }
  7949. for (var i = 0, ii = firstDest.length; i < ii; i++) {
  7950. if (!isEntryEqual(firstDest[i], secondDest[i])) {
  7951. return false;
  7952. }
  7953. }
  7954. return true;
  7955. }
  7956. /***/
  7957. }),
  7958. /* 21 */
  7959. /***/
  7960. (function(module, exports, __webpack_require__) {
  7961. "use strict";
  7962. Object.defineProperty(exports, "__esModule", {
  7963. value: true
  7964. });
  7965. exports.SimpleLinkService = exports.PDFLinkService = void 0;
  7966. var _ui_utils = __webpack_require__(5);
  7967. function _typeof(obj) {
  7968. if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
  7969. _typeof = function _typeof(obj) {
  7970. return typeof obj;
  7971. };
  7972. } else {
  7973. _typeof = function _typeof(obj) {
  7974. return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !==
  7975. Symbol.prototype ? "symbol" : typeof obj;
  7976. };
  7977. }
  7978. return _typeof(obj);
  7979. }
  7980. function _classCallCheck(instance, Constructor) {
  7981. if (!(instance instanceof Constructor)) {
  7982. throw new TypeError("Cannot call a class as a function");
  7983. }
  7984. }
  7985. function _defineProperties(target, props) {
  7986. for (var i = 0; i < props.length; i++) {
  7987. var descriptor = props[i];
  7988. descriptor.enumerable = descriptor.enumerable || false;
  7989. descriptor.configurable = true;
  7990. if ("value" in descriptor) descriptor.writable = true;
  7991. Object.defineProperty(target, descriptor.key, descriptor);
  7992. }
  7993. }
  7994. function _createClass(Constructor, protoProps, staticProps) {
  7995. if (protoProps) _defineProperties(Constructor.prototype, protoProps);
  7996. if (staticProps) _defineProperties(Constructor, staticProps);
  7997. return Constructor;
  7998. }
  7999. var PDFLinkService =
  8000. /*#__PURE__*/
  8001. function() {
  8002. function PDFLinkService() {
  8003. var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
  8004. eventBus = _ref.eventBus,
  8005. _ref$externalLinkTarg = _ref.externalLinkTarget,
  8006. externalLinkTarget = _ref$externalLinkTarg === void 0 ? null : _ref$externalLinkTarg,
  8007. _ref$externalLinkRel = _ref.externalLinkRel,
  8008. externalLinkRel = _ref$externalLinkRel === void 0 ? null : _ref$externalLinkRel,
  8009. _ref$externalLinkEnab = _ref.externalLinkEnabled,
  8010. externalLinkEnabled = _ref$externalLinkEnab === void 0 ? true : _ref$externalLinkEnab;
  8011. _classCallCheck(this, PDFLinkService);
  8012. this.eventBus = eventBus || (0, _ui_utils.getGlobalEventBus)();
  8013. this.externalLinkTarget = externalLinkTarget;
  8014. this.externalLinkRel = externalLinkRel;
  8015. this.externalLinkEnabled = externalLinkEnabled;
  8016. this.baseUrl = null;
  8017. this.pdfDocument = null;
  8018. this.pdfViewer = null;
  8019. this.pdfHistory = null;
  8020. this._pagesRefCache = null;
  8021. }
  8022. _createClass(PDFLinkService, [{
  8023. key: "setDocument",
  8024. value: function setDocument(pdfDocument) {
  8025. var baseUrl = arguments.length > 1 && arguments[1] !== undefined ?
  8026. arguments[1] : null;
  8027. this.baseUrl = baseUrl;
  8028. this.pdfDocument = pdfDocument;
  8029. this._pagesRefCache = Object.create(null);
  8030. }
  8031. }, {
  8032. key: "setViewer",
  8033. value: function setViewer(pdfViewer) {
  8034. this.pdfViewer = pdfViewer;
  8035. }
  8036. }, {
  8037. key: "setHistory",
  8038. value: function setHistory(pdfHistory) {
  8039. this.pdfHistory = pdfHistory;
  8040. }
  8041. }, {
  8042. key: "navigateTo",
  8043. value: function navigateTo(dest) {
  8044. var _this = this;
  8045. var goToDestination = function goToDestination(_ref2) {
  8046. var namedDest = _ref2.namedDest,
  8047. explicitDest = _ref2.explicitDest;
  8048. var destRef = explicitDest[0],
  8049. pageNumber;
  8050. if (destRef instanceof Object) {
  8051. pageNumber = _this._cachedPageNumber(destRef);
  8052. if (pageNumber === null) {
  8053. _this.pdfDocument.getPageIndex(destRef).then(function(
  8054. pageIndex) {
  8055. _this.cachePageRef(pageIndex + 1, destRef);
  8056. goToDestination({
  8057. namedDest: namedDest,
  8058. explicitDest: explicitDest
  8059. });
  8060. })["catch"](function() {
  8061. console.error(
  8062. "PDFLinkService.navigateTo: \""
  8063. .concat(destRef, "\" is not ") +
  8064. "a valid page reference, for dest=\""
  8065. .concat(dest, "\"."));
  8066. });
  8067. return;
  8068. }
  8069. } else if (Number.isInteger(destRef)) {
  8070. pageNumber = destRef + 1;
  8071. } else {
  8072. console.error("PDFLinkService.navigateTo: \"".concat(
  8073. destRef, "\" is not ") +
  8074. "a valid destination reference, for dest=\"".concat(
  8075. dest, "\"."));
  8076. return;
  8077. }
  8078. if (!pageNumber || pageNumber < 1 || pageNumber > _this
  8079. .pagesCount) {
  8080. console.error("PDFLinkService.navigateTo: \"".concat(
  8081. pageNumber, "\" is not ") +
  8082. "a valid page number, for dest=\"".concat(dest,
  8083. "\"."));
  8084. return;
  8085. }
  8086. if (_this.pdfHistory) {
  8087. _this.pdfHistory.pushCurrentPosition();
  8088. _this.pdfHistory.push({
  8089. namedDest: namedDest,
  8090. explicitDest: explicitDest,
  8091. pageNumber: pageNumber
  8092. });
  8093. }
  8094. _this.pdfViewer.scrollPageIntoView({
  8095. pageNumber: pageNumber,
  8096. destArray: explicitDest
  8097. });
  8098. };
  8099. new Promise(function(resolve, reject) {
  8100. if (typeof dest === 'string') {
  8101. _this.pdfDocument.getDestination(dest).then(function(
  8102. destArray) {
  8103. resolve({
  8104. namedDest: dest,
  8105. explicitDest: destArray
  8106. });
  8107. });
  8108. return;
  8109. }
  8110. resolve({
  8111. namedDest: '',
  8112. explicitDest: dest
  8113. });
  8114. }).then(function(data) {
  8115. if (!Array.isArray(data.explicitDest)) {
  8116. console.error("PDFLinkService.navigateTo: \"".concat(
  8117. data.explicitDest, "\" is") +
  8118. " not a valid destination array, for dest=\""
  8119. .concat(dest, "\"."));
  8120. return;
  8121. }
  8122. goToDestination(data);
  8123. });
  8124. }
  8125. }, {
  8126. key: "getDestinationHash",
  8127. value: function getDestinationHash(dest) {
  8128. if (typeof dest === 'string') {
  8129. return this.getAnchorUrl('#' + escape(dest));
  8130. }
  8131. if (Array.isArray(dest)) {
  8132. var str = JSON.stringify(dest);
  8133. return this.getAnchorUrl('#' + escape(str));
  8134. }
  8135. return this.getAnchorUrl('');
  8136. }
  8137. }, {
  8138. key: "getAnchorUrl",
  8139. value: function getAnchorUrl(anchor) {
  8140. return (this.baseUrl || '') + anchor;
  8141. }
  8142. }, {
  8143. key: "setHash",
  8144. value: function setHash(hash) {
  8145. var pageNumber, dest;
  8146. if (hash.includes('=')) {
  8147. var params = (0, _ui_utils.parseQueryString)(hash);
  8148. if ('search' in params) {
  8149. this.eventBus.dispatch('findfromurlhash', {
  8150. source: this,
  8151. query: params['search'].replace(/"/g, ''),
  8152. phraseSearch: params['phrase'] === 'true'
  8153. });
  8154. }
  8155. if ('nameddest' in params) {
  8156. this.navigateTo(params.nameddest);
  8157. return;
  8158. }
  8159. if ('page' in params) {
  8160. pageNumber = params.page | 0 || 1;
  8161. }
  8162. if ('zoom' in params) {
  8163. var zoomArgs = params.zoom.split(',');
  8164. var zoomArg = zoomArgs[0];
  8165. var zoomArgNumber = parseFloat(zoomArg);
  8166. if (!zoomArg.includes('Fit')) {
  8167. dest = [null, {
  8168. name: 'XYZ'
  8169. }, zoomArgs.length > 1 ? zoomArgs[1] | 0 : null,
  8170. zoomArgs.length > 2 ? zoomArgs[2] | 0 : null,
  8171. zoomArgNumber ? zoomArgNumber / 100 : zoomArg
  8172. ];
  8173. } else {
  8174. if (zoomArg === 'Fit' || zoomArg === 'FitB') {
  8175. dest = [null, {
  8176. name: zoomArg
  8177. }];
  8178. } else if (zoomArg === 'FitH' || zoomArg === 'FitBH' ||
  8179. zoomArg === 'FitV' || zoomArg === 'FitBV') {
  8180. dest = [null, {
  8181. name: zoomArg
  8182. }, zoomArgs.length > 1 ? zoomArgs[1] | 0 : null];
  8183. } else if (zoomArg === 'FitR') {
  8184. if (zoomArgs.length !== 5) {
  8185. console.error(
  8186. 'PDFLinkService.setHash: Not enough parameters for "FitR".'
  8187. );
  8188. } else {
  8189. dest = [null, {
  8190. name: zoomArg
  8191. }, zoomArgs[1] | 0, zoomArgs[2] | 0,
  8192. zoomArgs[3] | 0, zoomArgs[4] | 0
  8193. ];
  8194. }
  8195. } else {
  8196. console.error("PDFLinkService.setHash: \"".concat(
  8197. zoomArg, "\" is not ") +
  8198. 'a valid zoom value.');
  8199. }
  8200. }
  8201. }
  8202. if (dest) {
  8203. this.pdfViewer.scrollPageIntoView({
  8204. pageNumber: pageNumber || this.page,
  8205. destArray: dest,
  8206. allowNegativeOffset: true
  8207. });
  8208. } else if (pageNumber) {
  8209. this.page = pageNumber;
  8210. }
  8211. if ('pagemode' in params) {
  8212. this.eventBus.dispatch('pagemode', {
  8213. source: this,
  8214. mode: params.pagemode
  8215. });
  8216. }
  8217. } else {
  8218. dest = unescape(hash);
  8219. try {
  8220. dest = JSON.parse(dest);
  8221. if (!Array.isArray(dest)) {
  8222. dest = dest.toString();
  8223. }
  8224. } catch (ex) {}
  8225. if (typeof dest === 'string' || isValidExplicitDestination(dest)) {
  8226. this.navigateTo(dest);
  8227. return;
  8228. }
  8229. console.error("PDFLinkService.setHash: \"".concat(unescape(hash),
  8230. "\" is not ") + 'a valid destination.');
  8231. }
  8232. }
  8233. }, {
  8234. key: "executeNamedAction",
  8235. value: function executeNamedAction(action) {
  8236. switch (action) {
  8237. case 'GoBack':
  8238. if (this.pdfHistory) {
  8239. this.pdfHistory.back();
  8240. }
  8241. break;
  8242. case 'GoForward':
  8243. if (this.pdfHistory) {
  8244. this.pdfHistory.forward();
  8245. }
  8246. break;
  8247. case 'NextPage':
  8248. if (this.page < this.pagesCount) {
  8249. this.page++;
  8250. }
  8251. break;
  8252. case 'PrevPage':
  8253. if (this.page > 1) {
  8254. this.page--;
  8255. }
  8256. break;
  8257. case 'LastPage':
  8258. this.page = this.pagesCount;
  8259. break;
  8260. case 'FirstPage':
  8261. this.page = 1;
  8262. break;
  8263. default:
  8264. break;
  8265. }
  8266. this.eventBus.dispatch('namedaction', {
  8267. source: this,
  8268. action: action
  8269. });
  8270. }
  8271. }, {
  8272. key: "cachePageRef",
  8273. value: function cachePageRef(pageNum, pageRef) {
  8274. if (!pageRef) {
  8275. return;
  8276. }
  8277. var refStr = pageRef.gen === 0 ? "".concat(pageRef.num, "R") : ""
  8278. .concat(pageRef.num, "R").concat(pageRef.gen);
  8279. this._pagesRefCache[refStr] = pageNum;
  8280. }
  8281. }, {
  8282. key: "_cachedPageNumber",
  8283. value: function _cachedPageNumber(pageRef) {
  8284. var refStr = pageRef.gen === 0 ? "".concat(pageRef.num, "R") : ""
  8285. .concat(pageRef.num, "R").concat(pageRef.gen);
  8286. return this._pagesRefCache && this._pagesRefCache[refStr] || null;
  8287. }
  8288. }, {
  8289. key: "isPageVisible",
  8290. value: function isPageVisible(pageNumber) {
  8291. return this.pdfViewer.isPageVisible(pageNumber);
  8292. }
  8293. }, {
  8294. key: "pagesCount",
  8295. get: function get() {
  8296. return this.pdfDocument ? this.pdfDocument.numPages : 0;
  8297. }
  8298. }, {
  8299. key: "page",
  8300. get: function get() {
  8301. return this.pdfViewer.currentPageNumber;
  8302. },
  8303. set: function set(value) {
  8304. this.pdfViewer.currentPageNumber = value;
  8305. }
  8306. }, {
  8307. key: "rotation",
  8308. get: function get() {
  8309. return this.pdfViewer.pagesRotation;
  8310. },
  8311. set: function set(value) {
  8312. this.pdfViewer.pagesRotation = value;
  8313. }
  8314. }]);
  8315. return PDFLinkService;
  8316. }();
  8317. exports.PDFLinkService = PDFLinkService;
  8318. function isValidExplicitDestination(dest) {
  8319. if (!Array.isArray(dest)) {
  8320. return false;
  8321. }
  8322. var destLength = dest.length,
  8323. allowNull = true;
  8324. if (destLength < 2) {
  8325. return false;
  8326. }
  8327. var page = dest[0];
  8328. if (!(_typeof(page) === 'object' && Number.isInteger(page.num) && Number.isInteger(page.gen)) && !(
  8329. Number.isInteger(page) && page >= 0)) {
  8330. return false;
  8331. }
  8332. var zoom = dest[1];
  8333. if (!(_typeof(zoom) === 'object' && typeof zoom.name === 'string')) {
  8334. return false;
  8335. }
  8336. switch (zoom.name) {
  8337. case 'XYZ':
  8338. if (destLength !== 5) {
  8339. return false;
  8340. }
  8341. break;
  8342. case 'Fit':
  8343. case 'FitB':
  8344. return destLength === 2;
  8345. case 'FitH':
  8346. case 'FitBH':
  8347. case 'FitV':
  8348. case 'FitBV':
  8349. if (destLength !== 3) {
  8350. return false;
  8351. }
  8352. break;
  8353. case 'FitR':
  8354. if (destLength !== 6) {
  8355. return false;
  8356. }
  8357. allowNull = false;
  8358. break;
  8359. default:
  8360. return false;
  8361. }
  8362. for (var i = 2; i < destLength; i++) {
  8363. var param = dest[i];
  8364. if (!(typeof param === 'number' || allowNull && param === null)) {
  8365. return false;
  8366. }
  8367. }
  8368. return true;
  8369. }
  8370. var SimpleLinkService =
  8371. /*#__PURE__*/
  8372. function() {
  8373. function SimpleLinkService() {
  8374. _classCallCheck(this, SimpleLinkService);
  8375. this.externalLinkTarget = null;
  8376. this.externalLinkRel = null;
  8377. this.externalLinkEnabled = true;
  8378. }
  8379. _createClass(SimpleLinkService, [{
  8380. key: "navigateTo",
  8381. value: function navigateTo(dest) {}
  8382. }, {
  8383. key: "getDestinationHash",
  8384. value: function getDestinationHash(dest) {
  8385. return '#';
  8386. }
  8387. }, {
  8388. key: "getAnchorUrl",
  8389. value: function getAnchorUrl(hash) {
  8390. return '#';
  8391. }
  8392. }, {
  8393. key: "setHash",
  8394. value: function setHash(hash) {}
  8395. }, {
  8396. key: "executeNamedAction",
  8397. value: function executeNamedAction(action) {}
  8398. }, {
  8399. key: "cachePageRef",
  8400. value: function cachePageRef(pageNum, pageRef) {}
  8401. }, {
  8402. key: "isPageVisible",
  8403. value: function isPageVisible(pageNumber) {
  8404. return true;
  8405. }
  8406. }, {
  8407. key: "pagesCount",
  8408. get: function get() {
  8409. return 0;
  8410. }
  8411. }, {
  8412. key: "page",
  8413. get: function get() {
  8414. return 0;
  8415. },
  8416. set: function set(value) {}
  8417. }, {
  8418. key: "rotation",
  8419. get: function get() {
  8420. return 0;
  8421. },
  8422. set: function set(value) {}
  8423. }]);
  8424. return SimpleLinkService;
  8425. }();
  8426. exports.SimpleLinkService = SimpleLinkService;
  8427. /***/
  8428. }),
  8429. /* 22 */
  8430. /***/
  8431. (function(module, exports, __webpack_require__) {
  8432. "use strict";
  8433. Object.defineProperty(exports, "__esModule", {
  8434. value: true
  8435. });
  8436. exports.PDFOutlineViewer = void 0;
  8437. var _pdfjsLib = __webpack_require__(7);
  8438. function _classCallCheck(instance, Constructor) {
  8439. if (!(instance instanceof Constructor)) {
  8440. throw new TypeError("Cannot call a class as a function");
  8441. }
  8442. }
  8443. function _defineProperties(target, props) {
  8444. for (var i = 0; i < props.length; i++) {
  8445. var descriptor = props[i];
  8446. descriptor.enumerable = descriptor.enumerable || false;
  8447. descriptor.configurable = true;
  8448. if ("value" in descriptor) descriptor.writable = true;
  8449. Object.defineProperty(target, descriptor.key, descriptor);
  8450. }
  8451. }
  8452. function _createClass(Constructor, protoProps, staticProps) {
  8453. if (protoProps) _defineProperties(Constructor.prototype, protoProps);
  8454. if (staticProps) _defineProperties(Constructor, staticProps);
  8455. return Constructor;
  8456. }
  8457. var DEFAULT_TITLE = "\u2013";
  8458. var PDFOutlineViewer =
  8459. /*#__PURE__*/
  8460. function() {
  8461. function PDFOutlineViewer(_ref) {
  8462. var container = _ref.container,
  8463. linkService = _ref.linkService,
  8464. eventBus = _ref.eventBus;
  8465. _classCallCheck(this, PDFOutlineViewer);
  8466. this.container = container;
  8467. this.linkService = linkService;
  8468. this.eventBus = eventBus;
  8469. this.reset();
  8470. eventBus.on('toggleoutlinetree', this.toggleOutlineTree.bind(this));
  8471. }
  8472. _createClass(PDFOutlineViewer, [{
  8473. key: "reset",
  8474. value: function reset() {
  8475. this.outline = null;
  8476. this.lastToggleIsShow = true;
  8477. this.container.textContent = '';
  8478. this.container.classList.remove('outlineWithDeepNesting');
  8479. }
  8480. }, {
  8481. key: "_dispatchEvent",
  8482. value: function _dispatchEvent(outlineCount) {
  8483. this.eventBus.dispatch('outlineloaded', {
  8484. source: this,
  8485. outlineCount: outlineCount
  8486. });
  8487. }
  8488. }, {
  8489. key: "_bindLink",
  8490. value: function _bindLink(element, _ref2) {
  8491. var url = _ref2.url,
  8492. newWindow = _ref2.newWindow,
  8493. dest = _ref2.dest;
  8494. var linkService = this.linkService;
  8495. if (url) {
  8496. (0, _pdfjsLib.addLinkAttributes)(element, {
  8497. url: url,
  8498. target: newWindow ? _pdfjsLib.LinkTarget.BLANK : linkService
  8499. .externalLinkTarget,
  8500. rel: linkService.externalLinkRel,
  8501. enabled: linkService.externalLinkEnabled
  8502. });
  8503. return;
  8504. }
  8505. element.href = linkService.getDestinationHash(dest);
  8506. element.onclick = function() {
  8507. if (dest) {
  8508. linkService.navigateTo(dest);
  8509. }
  8510. return false;
  8511. };
  8512. }
  8513. }, {
  8514. key: "_setStyles",
  8515. value: function _setStyles(element, _ref3) {
  8516. var bold = _ref3.bold,
  8517. italic = _ref3.italic;
  8518. var styleStr = '';
  8519. if (bold) {
  8520. styleStr += 'font-weight: bold;';
  8521. }
  8522. if (italic) {
  8523. styleStr += 'font-style: italic;';
  8524. }
  8525. if (styleStr) {
  8526. element.setAttribute('style', styleStr);
  8527. }
  8528. }
  8529. }, {
  8530. key: "_addToggleButton",
  8531. value: function _addToggleButton(div, _ref4) {
  8532. var _this = this;
  8533. var count = _ref4.count,
  8534. items = _ref4.items;
  8535. var toggler = document.createElement('div');
  8536. toggler.className = 'outlineItemToggler';
  8537. if (count < 0 && Math.abs(count) === items.length) {
  8538. toggler.classList.add('outlineItemsHidden');
  8539. }
  8540. toggler.onclick = function(evt) {
  8541. evt.stopPropagation();
  8542. toggler.classList.toggle('outlineItemsHidden');
  8543. if (evt.shiftKey) {
  8544. var shouldShowAll = !toggler.classList.contains(
  8545. 'outlineItemsHidden');
  8546. _this._toggleOutlineItem(div, shouldShowAll);
  8547. }
  8548. };
  8549. div.insertBefore(toggler, div.firstChild);
  8550. }
  8551. }, {
  8552. key: "_toggleOutlineItem",
  8553. value: function _toggleOutlineItem(root) {
  8554. var show = arguments.length > 1 && arguments[1] !== undefined ?
  8555. arguments[1] : false;
  8556. this.lastToggleIsShow = show;
  8557. var _iteratorNormalCompletion = true;
  8558. var _didIteratorError = false;
  8559. var _iteratorError = undefined;
  8560. try {
  8561. for (var _iterator = root.querySelectorAll('.outlineItemToggler')[
  8562. Symbol.iterator](), _step; !(_iteratorNormalCompletion = (
  8563. _step = _iterator.next()).done); _iteratorNormalCompletion =
  8564. true) {
  8565. var toggler = _step.value;
  8566. toggler.classList.toggle('outlineItemsHidden', !show);
  8567. }
  8568. } catch (err) {
  8569. _didIteratorError = true;
  8570. _iteratorError = err;
  8571. } finally {
  8572. try {
  8573. if (!_iteratorNormalCompletion && _iterator["return"] != null) {
  8574. _iterator["return"]();
  8575. }
  8576. } finally {
  8577. if (_didIteratorError) {
  8578. throw _iteratorError;
  8579. }
  8580. }
  8581. }
  8582. }
  8583. }, {
  8584. key: "toggleOutlineTree",
  8585. value: function toggleOutlineTree() {
  8586. if (!this.outline) {
  8587. return;
  8588. }
  8589. this._toggleOutlineItem(this.container, !this.lastToggleIsShow);
  8590. }
  8591. }, {
  8592. key: "render",
  8593. value: function render(_ref5) {
  8594. var outline = _ref5.outline;
  8595. var outlineCount = 0;
  8596. if (this.outline) {
  8597. this.reset();
  8598. }
  8599. this.outline = outline || null;
  8600. if (!outline) {
  8601. this._dispatchEvent(outlineCount);
  8602. return;
  8603. }
  8604. var fragment = document.createDocumentFragment();
  8605. var queue = [{
  8606. parent: fragment,
  8607. items: this.outline
  8608. }];
  8609. var hasAnyNesting = false;
  8610. while (queue.length > 0) {
  8611. var levelData = queue.shift();
  8612. var _iteratorNormalCompletion2 = true;
  8613. var _didIteratorError2 = false;
  8614. var _iteratorError2 = undefined;
  8615. try {
  8616. for (var _iterator2 = levelData.items[Symbol.iterator](),
  8617. _step2; !(_iteratorNormalCompletion2 = (_step2 =
  8618. _iterator2
  8619. .next()).done); _iteratorNormalCompletion2 = true) {
  8620. var item = _step2.value;
  8621. var div = document.createElement('div');
  8622. div.className = 'outlineItem';
  8623. var element = document.createElement('a');
  8624. this._bindLink(element, item);
  8625. this._setStyles(element, item);
  8626. element.textContent = (0, _pdfjsLib.removeNullCharacters)(
  8627. item.title) || DEFAULT_TITLE;
  8628. div.appendChild(element);
  8629. if (item.items.length > 0) {
  8630. hasAnyNesting = true;
  8631. this._addToggleButton(div, item);
  8632. var itemsDiv = document.createElement('div');
  8633. itemsDiv.className = 'outlineItems';
  8634. div.appendChild(itemsDiv);
  8635. queue.push({
  8636. parent: itemsDiv,
  8637. items: item.items
  8638. });
  8639. }
  8640. levelData.parent.appendChild(div);
  8641. outlineCount++;
  8642. }
  8643. } catch (err) {
  8644. _didIteratorError2 = true;
  8645. _iteratorError2 = err;
  8646. } finally {
  8647. try {
  8648. if (!_iteratorNormalCompletion2 && _iterator2["return"] !=
  8649. null) {
  8650. _iterator2["return"]();
  8651. }
  8652. } finally {
  8653. if (_didIteratorError2) {
  8654. throw _iteratorError2;
  8655. }
  8656. }
  8657. }
  8658. }
  8659. if (hasAnyNesting) {
  8660. this.container.classList.add('outlineWithDeepNesting');
  8661. this.lastToggleIsShow = fragment.querySelectorAll(
  8662. '.outlineItemsHidden').length === 0;
  8663. }
  8664. this.container.appendChild(fragment);
  8665. this._dispatchEvent(outlineCount);
  8666. }
  8667. }]);
  8668. return PDFOutlineViewer;
  8669. }();
  8670. exports.PDFOutlineViewer = PDFOutlineViewer;
  8671. /***/
  8672. }),
  8673. /* 23 */
  8674. /***/
  8675. (function(module, exports, __webpack_require__) {
  8676. "use strict";
  8677. Object.defineProperty(exports, "__esModule", {
  8678. value: true
  8679. });
  8680. exports.PDFPresentationMode = void 0;
  8681. var _ui_utils = __webpack_require__(5);
  8682. function _classCallCheck(instance, Constructor) {
  8683. if (!(instance instanceof Constructor)) {
  8684. throw new TypeError("Cannot call a class as a function");
  8685. }
  8686. }
  8687. function _defineProperties(target, props) {
  8688. for (var i = 0; i < props.length; i++) {
  8689. var descriptor = props[i];
  8690. descriptor.enumerable = descriptor.enumerable || false;
  8691. descriptor.configurable = true;
  8692. if ("value" in descriptor) descriptor.writable = true;
  8693. Object.defineProperty(target, descriptor.key, descriptor);
  8694. }
  8695. }
  8696. function _createClass(Constructor, protoProps, staticProps) {
  8697. if (protoProps) _defineProperties(Constructor.prototype, protoProps);
  8698. if (staticProps) _defineProperties(Constructor, staticProps);
  8699. return Constructor;
  8700. }
  8701. var DELAY_BEFORE_RESETTING_SWITCH_IN_PROGRESS = 1500;
  8702. var DELAY_BEFORE_HIDING_CONTROLS = 3000;
  8703. var ACTIVE_SELECTOR = 'pdfPresentationMode';
  8704. var CONTROLS_SELECTOR = 'pdfPresentationModeControls';
  8705. var MOUSE_SCROLL_COOLDOWN_TIME = 50;
  8706. var PAGE_SWITCH_THRESHOLD = 0.1;
  8707. var SWIPE_MIN_DISTANCE_THRESHOLD = 50;
  8708. var SWIPE_ANGLE_THRESHOLD = Math.PI / 6;
  8709. var PDFPresentationMode =
  8710. /*#__PURE__*/
  8711. function() {
  8712. function PDFPresentationMode(_ref) {
  8713. var _this = this;
  8714. var container = _ref.container,
  8715. _ref$viewer = _ref.viewer,
  8716. viewer = _ref$viewer === void 0 ? null : _ref$viewer,
  8717. pdfViewer = _ref.pdfViewer,
  8718. eventBus = _ref.eventBus,
  8719. _ref$contextMenuItems = _ref.contextMenuItems,
  8720. contextMenuItems = _ref$contextMenuItems === void 0 ? null : _ref$contextMenuItems;
  8721. _classCallCheck(this, PDFPresentationMode);
  8722. this.container = container;
  8723. this.viewer = viewer || container.firstElementChild;
  8724. this.pdfViewer = pdfViewer;
  8725. this.eventBus = eventBus;
  8726. this.active = false;
  8727. this.args = null;
  8728. this.contextMenuOpen = false;
  8729. this.mouseScrollTimeStamp = 0;
  8730. this.mouseScrollDelta = 0;
  8731. this.touchSwipeState = null;
  8732. if (contextMenuItems) {
  8733. contextMenuItems.contextFirstPage.addEventListener('click', function() {
  8734. _this.contextMenuOpen = false;
  8735. _this.eventBus.dispatch('firstpage', {
  8736. source: _this
  8737. });
  8738. });
  8739. contextMenuItems.contextLastPage.addEventListener('click', function() {
  8740. _this.contextMenuOpen = false;
  8741. _this.eventBus.dispatch('lastpage', {
  8742. source: _this
  8743. });
  8744. });
  8745. contextMenuItems.contextPageRotateCw.addEventListener('click', function() {
  8746. _this.contextMenuOpen = false;
  8747. _this.eventBus.dispatch('rotatecw', {
  8748. source: _this
  8749. });
  8750. });
  8751. contextMenuItems.contextPageRotateCcw.addEventListener('click', function() {
  8752. _this.contextMenuOpen = false;
  8753. _this.eventBus.dispatch('rotateccw', {
  8754. source: _this
  8755. });
  8756. });
  8757. }
  8758. }
  8759. _createClass(PDFPresentationMode, [{
  8760. key: "request",
  8761. value: function request() {
  8762. if (this.switchInProgress || this.active || !this.viewer
  8763. .hasChildNodes()) {
  8764. return false;
  8765. }
  8766. this._addFullscreenChangeListeners();
  8767. this._setSwitchInProgress();
  8768. this._notifyStateChange();
  8769. if (this.container.requestFullscreen) {
  8770. this.container.requestFullscreen();
  8771. } else if (this.container.mozRequestFullScreen) {
  8772. this.container.mozRequestFullScreen();
  8773. } else if (this.container.webkitRequestFullscreen) {
  8774. this.container.webkitRequestFullscreen(Element
  8775. .ALLOW_KEYBOARD_INPUT);
  8776. } else if (this.container.msRequestFullscreen) {
  8777. this.container.msRequestFullscreen();
  8778. } else {
  8779. return false;
  8780. }
  8781. this.args = {
  8782. page: this.pdfViewer.currentPageNumber,
  8783. previousScale: this.pdfViewer.currentScaleValue
  8784. };
  8785. return true;
  8786. }
  8787. }, {
  8788. key: "_mouseWheel",
  8789. value: function _mouseWheel(evt) {
  8790. if (!this.active) {
  8791. return;
  8792. }
  8793. evt.preventDefault();
  8794. var delta = (0, _ui_utils.normalizeWheelEventDelta)(evt);
  8795. var currentTime = new Date().getTime();
  8796. var storedTime = this.mouseScrollTimeStamp;
  8797. if (currentTime > storedTime && currentTime - storedTime <
  8798. MOUSE_SCROLL_COOLDOWN_TIME) {
  8799. return;
  8800. }
  8801. if (this.mouseScrollDelta > 0 && delta < 0 || this.mouseScrollDelta <
  8802. 0 && delta > 0) {
  8803. this._resetMouseScrollState();
  8804. }
  8805. this.mouseScrollDelta += delta;
  8806. if (Math.abs(this.mouseScrollDelta) >= PAGE_SWITCH_THRESHOLD) {
  8807. var totalDelta = this.mouseScrollDelta;
  8808. this._resetMouseScrollState();
  8809. var success = totalDelta > 0 ? this._goToPreviousPage() : this
  8810. ._goToNextPage();
  8811. if (success) {
  8812. this.mouseScrollTimeStamp = currentTime;
  8813. }
  8814. }
  8815. }
  8816. }, {
  8817. key: "_goToPreviousPage",
  8818. value: function _goToPreviousPage() {
  8819. var page = this.pdfViewer.currentPageNumber;
  8820. if (page <= 1) {
  8821. return false;
  8822. }
  8823. this.pdfViewer.currentPageNumber = page - 1;
  8824. return true;
  8825. }
  8826. }, {
  8827. key: "_goToNextPage",
  8828. value: function _goToNextPage() {
  8829. var page = this.pdfViewer.currentPageNumber;
  8830. if (page >= this.pdfViewer.pagesCount) {
  8831. return false;
  8832. }
  8833. this.pdfViewer.currentPageNumber = page + 1;
  8834. return true;
  8835. }
  8836. }, {
  8837. key: "_notifyStateChange",
  8838. value: function _notifyStateChange() {
  8839. this.eventBus.dispatch('presentationmodechanged', {
  8840. source: this,
  8841. active: this.active,
  8842. switchInProgress: !!this.switchInProgress
  8843. });
  8844. }
  8845. }, {
  8846. key: "_setSwitchInProgress",
  8847. value: function _setSwitchInProgress() {
  8848. var _this2 = this;
  8849. if (this.switchInProgress) {
  8850. clearTimeout(this.switchInProgress);
  8851. }
  8852. this.switchInProgress = setTimeout(function() {
  8853. _this2._removeFullscreenChangeListeners();
  8854. delete _this2.switchInProgress;
  8855. _this2._notifyStateChange();
  8856. }, DELAY_BEFORE_RESETTING_SWITCH_IN_PROGRESS);
  8857. }
  8858. }, {
  8859. key: "_resetSwitchInProgress",
  8860. value: function _resetSwitchInProgress() {
  8861. if (this.switchInProgress) {
  8862. clearTimeout(this.switchInProgress);
  8863. delete this.switchInProgress;
  8864. }
  8865. }
  8866. }, {
  8867. key: "_enter",
  8868. value: function _enter() {
  8869. var _this3 = this;
  8870. this.active = true;
  8871. this._resetSwitchInProgress();
  8872. this._notifyStateChange();
  8873. this.container.classList.add(ACTIVE_SELECTOR);
  8874. setTimeout(function() {
  8875. _this3.pdfViewer.currentPageNumber = _this3.args.page;
  8876. _this3.pdfViewer.currentScaleValue = 'page-fit';
  8877. }, 0);
  8878. this._addWindowListeners();
  8879. this._showControls();
  8880. this.contextMenuOpen = false;
  8881. this.container.setAttribute('contextmenu', 'viewerContextMenu');
  8882. window.getSelection().removeAllRanges();
  8883. }
  8884. }, {
  8885. key: "_exit",
  8886. value: function _exit() {
  8887. var _this4 = this;
  8888. var page = this.pdfViewer.currentPageNumber;
  8889. this.container.classList.remove(ACTIVE_SELECTOR);
  8890. setTimeout(function() {
  8891. _this4.active = false;
  8892. _this4._removeFullscreenChangeListeners();
  8893. _this4._notifyStateChange();
  8894. _this4.pdfViewer.currentScaleValue = _this4.args
  8895. .previousScale;
  8896. _this4.pdfViewer.currentPageNumber = page;
  8897. _this4.args = null;
  8898. }, 0);
  8899. this._removeWindowListeners();
  8900. this._hideControls();
  8901. this._resetMouseScrollState();
  8902. this.container.removeAttribute('contextmenu');
  8903. this.contextMenuOpen = false;
  8904. }
  8905. }, {
  8906. key: "_mouseDown",
  8907. value: function _mouseDown(evt) {
  8908. if (this.contextMenuOpen) {
  8909. this.contextMenuOpen = false;
  8910. evt.preventDefault();
  8911. return;
  8912. }
  8913. if (evt.button === 0) {
  8914. var isInternalLink = evt.target.href && evt.target.classList
  8915. .contains('internalLink');
  8916. if (!isInternalLink) {
  8917. evt.preventDefault();
  8918. if (evt.shiftKey) {
  8919. this._goToPreviousPage();
  8920. } else {
  8921. this._goToNextPage();
  8922. }
  8923. }
  8924. }
  8925. }
  8926. }, {
  8927. key: "_contextMenu",
  8928. value: function _contextMenu() {
  8929. this.contextMenuOpen = true;
  8930. }
  8931. }, {
  8932. key: "_showControls",
  8933. value: function _showControls() {
  8934. var _this5 = this;
  8935. if (this.controlsTimeout) {
  8936. clearTimeout(this.controlsTimeout);
  8937. } else {
  8938. this.container.classList.add(CONTROLS_SELECTOR);
  8939. }
  8940. this.controlsTimeout = setTimeout(function() {
  8941. _this5.container.classList.remove(CONTROLS_SELECTOR);
  8942. delete _this5.controlsTimeout;
  8943. }, DELAY_BEFORE_HIDING_CONTROLS);
  8944. }
  8945. }, {
  8946. key: "_hideControls",
  8947. value: function _hideControls() {
  8948. if (!this.controlsTimeout) {
  8949. return;
  8950. }
  8951. clearTimeout(this.controlsTimeout);
  8952. this.container.classList.remove(CONTROLS_SELECTOR);
  8953. delete this.controlsTimeout;
  8954. }
  8955. }, {
  8956. key: "_resetMouseScrollState",
  8957. value: function _resetMouseScrollState() {
  8958. this.mouseScrollTimeStamp = 0;
  8959. this.mouseScrollDelta = 0;
  8960. }
  8961. }, {
  8962. key: "_touchSwipe",
  8963. value: function _touchSwipe(evt) {
  8964. if (!this.active) {
  8965. return;
  8966. }
  8967. if (evt.touches.length > 1) {
  8968. this.touchSwipeState = null;
  8969. return;
  8970. }
  8971. switch (evt.type) {
  8972. case 'touchstart':
  8973. this.touchSwipeState = {
  8974. startX: evt.touches[0].pageX,
  8975. startY: evt.touches[0].pageY,
  8976. endX: evt.touches[0].pageX,
  8977. endY: evt.touches[0].pageY
  8978. };
  8979. break;
  8980. case 'touchmove':
  8981. if (this.touchSwipeState === null) {
  8982. return;
  8983. }
  8984. this.touchSwipeState.endX = evt.touches[0].pageX;
  8985. this.touchSwipeState.endY = evt.touches[0].pageY;
  8986. evt.preventDefault();
  8987. break;
  8988. case 'touchend':
  8989. if (this.touchSwipeState === null) {
  8990. return;
  8991. }
  8992. var delta = 0;
  8993. var dx = this.touchSwipeState.endX - this.touchSwipeState
  8994. .startX;
  8995. var dy = this.touchSwipeState.endY - this.touchSwipeState
  8996. .startY;
  8997. var absAngle = Math.abs(Math.atan2(dy, dx));
  8998. if (Math.abs(dx) > SWIPE_MIN_DISTANCE_THRESHOLD && (absAngle <=
  8999. SWIPE_ANGLE_THRESHOLD || absAngle >= Math.PI -
  9000. SWIPE_ANGLE_THRESHOLD)) {
  9001. delta = dx;
  9002. } else if (Math.abs(dy) > SWIPE_MIN_DISTANCE_THRESHOLD && Math
  9003. .abs(absAngle - Math.PI / 2) <= SWIPE_ANGLE_THRESHOLD) {
  9004. delta = dy;
  9005. }
  9006. if (delta > 0) {
  9007. this._goToPreviousPage();
  9008. } else if (delta < 0) {
  9009. this._goToNextPage();
  9010. }
  9011. break;
  9012. }
  9013. }
  9014. }, {
  9015. key: "_addWindowListeners",
  9016. value: function _addWindowListeners() {
  9017. this.showControlsBind = this._showControls.bind(this);
  9018. this.mouseDownBind = this._mouseDown.bind(this);
  9019. this.mouseWheelBind = this._mouseWheel.bind(this);
  9020. this.resetMouseScrollStateBind = this._resetMouseScrollState.bind(this);
  9021. this.contextMenuBind = this._contextMenu.bind(this);
  9022. this.touchSwipeBind = this._touchSwipe.bind(this);
  9023. window.addEventListener('mousemove', this.showControlsBind);
  9024. window.addEventListener('mousedown', this.mouseDownBind);
  9025. window.addEventListener('wheel', this.mouseWheelBind);
  9026. window.addEventListener('keydown', this.resetMouseScrollStateBind);
  9027. window.addEventListener('contextmenu', this.contextMenuBind);
  9028. window.addEventListener('touchstart', this.touchSwipeBind);
  9029. window.addEventListener('touchmove', this.touchSwipeBind);
  9030. window.addEventListener('touchend', this.touchSwipeBind);
  9031. }
  9032. }, {
  9033. key: "_removeWindowListeners",
  9034. value: function _removeWindowListeners() {
  9035. window.removeEventListener('mousemove', this.showControlsBind);
  9036. window.removeEventListener('mousedown', this.mouseDownBind);
  9037. window.removeEventListener('wheel', this.mouseWheelBind);
  9038. window.removeEventListener('keydown', this.resetMouseScrollStateBind);
  9039. window.removeEventListener('contextmenu', this.contextMenuBind);
  9040. window.removeEventListener('touchstart', this.touchSwipeBind);
  9041. window.removeEventListener('touchmove', this.touchSwipeBind);
  9042. window.removeEventListener('touchend', this.touchSwipeBind);
  9043. delete this.showControlsBind;
  9044. delete this.mouseDownBind;
  9045. delete this.mouseWheelBind;
  9046. delete this.resetMouseScrollStateBind;
  9047. delete this.contextMenuBind;
  9048. delete this.touchSwipeBind;
  9049. }
  9050. }, {
  9051. key: "_fullscreenChange",
  9052. value: function _fullscreenChange() {
  9053. if (this.isFullscreen) {
  9054. this._enter();
  9055. } else {
  9056. this._exit();
  9057. }
  9058. }
  9059. }, {
  9060. key: "_addFullscreenChangeListeners",
  9061. value: function _addFullscreenChangeListeners() {
  9062. this.fullscreenChangeBind = this._fullscreenChange.bind(this);
  9063. window.addEventListener('fullscreenchange', this.fullscreenChangeBind);
  9064. window.addEventListener('mozfullscreenchange', this
  9065. .fullscreenChangeBind);
  9066. window.addEventListener('webkitfullscreenchange', this
  9067. .fullscreenChangeBind);
  9068. window.addEventListener('MSFullscreenChange', this
  9069. .fullscreenChangeBind);
  9070. }
  9071. }, {
  9072. key: "_removeFullscreenChangeListeners",
  9073. value: function _removeFullscreenChangeListeners() {
  9074. window.removeEventListener('fullscreenchange', this
  9075. .fullscreenChangeBind);
  9076. window.removeEventListener('mozfullscreenchange', this
  9077. .fullscreenChangeBind);
  9078. window.removeEventListener('webkitfullscreenchange', this
  9079. .fullscreenChangeBind);
  9080. window.removeEventListener('MSFullscreenChange', this
  9081. .fullscreenChangeBind);
  9082. delete this.fullscreenChangeBind;
  9083. }
  9084. }, {
  9085. key: "isFullscreen",
  9086. get: function get() {
  9087. return !!(document.fullscreenElement || document.mozFullScreen ||
  9088. document.webkitIsFullScreen || document.msFullscreenElement);
  9089. }
  9090. }]);
  9091. return PDFPresentationMode;
  9092. }();
  9093. exports.PDFPresentationMode = PDFPresentationMode;
  9094. /***/
  9095. }),
  9096. /* 24 */
  9097. /***/
  9098. (function(module, exports, __webpack_require__) {
  9099. "use strict";
  9100. Object.defineProperty(exports, "__esModule", {
  9101. value: true
  9102. });
  9103. exports.PDFSidebarResizer = void 0;
  9104. var _ui_utils = __webpack_require__(5);
  9105. function _classCallCheck(instance, Constructor) {
  9106. if (!(instance instanceof Constructor)) {
  9107. throw new TypeError("Cannot call a class as a function");
  9108. }
  9109. }
  9110. function _defineProperties(target, props) {
  9111. for (var i = 0; i < props.length; i++) {
  9112. var descriptor = props[i];
  9113. descriptor.enumerable = descriptor.enumerable || false;
  9114. descriptor.configurable = true;
  9115. if ("value" in descriptor) descriptor.writable = true;
  9116. Object.defineProperty(target, descriptor.key, descriptor);
  9117. }
  9118. }
  9119. function _createClass(Constructor, protoProps, staticProps) {
  9120. if (protoProps) _defineProperties(Constructor.prototype, protoProps);
  9121. if (staticProps) _defineProperties(Constructor, staticProps);
  9122. return Constructor;
  9123. }
  9124. var SIDEBAR_WIDTH_VAR = '--sidebar-width';
  9125. var SIDEBAR_MIN_WIDTH = 200;
  9126. var SIDEBAR_RESIZING_CLASS = 'sidebarResizing';
  9127. var PDFSidebarResizer =
  9128. /*#__PURE__*/
  9129. function() {
  9130. function PDFSidebarResizer(options, eventBus) {
  9131. var _this = this;
  9132. var l10n = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : _ui_utils
  9133. .NullL10n;
  9134. _classCallCheck(this, PDFSidebarResizer);
  9135. this.enabled = false;
  9136. this.isRTL = false;
  9137. this.sidebarOpen = false;
  9138. this.doc = document.documentElement;
  9139. this._width = null;
  9140. this._outerContainerWidth = null;
  9141. this._boundEvents = Object.create(null);
  9142. this.outerContainer = options.outerContainer;
  9143. this.resizer = options.resizer;
  9144. this.eventBus = eventBus;
  9145. this.l10n = l10n;
  9146. if (typeof CSS === 'undefined' || typeof CSS.supports !== 'function' || !CSS.supports(
  9147. SIDEBAR_WIDTH_VAR, "calc(-1 * ".concat(SIDEBAR_MIN_WIDTH, "px)"))) {
  9148. console.warn('PDFSidebarResizer: ' +
  9149. 'The browser does not support resizing of the sidebar.');
  9150. return;
  9151. }
  9152. this.enabled = true;
  9153. this.resizer.classList.remove('hidden');
  9154. this.l10n.getDirection().then(function(dir) {
  9155. _this.isRTL = dir === 'rtl';
  9156. });
  9157. this._addEventListeners();
  9158. }
  9159. _createClass(PDFSidebarResizer, [{
  9160. key: "_updateWidth",
  9161. value: function _updateWidth() {
  9162. var width = arguments.length > 0 && arguments[0] !== undefined ?
  9163. arguments[0] : 0;
  9164. if (!this.enabled) {
  9165. return false;
  9166. }
  9167. var maxWidth = Math.floor(this.outerContainerWidth / 2);
  9168. if (width > maxWidth) {
  9169. width = maxWidth;
  9170. }
  9171. if (width < SIDEBAR_MIN_WIDTH) {
  9172. width = SIDEBAR_MIN_WIDTH;
  9173. }
  9174. if (width === this._width) {
  9175. return false;
  9176. }
  9177. this._width = width;
  9178. this.doc.style.setProperty(SIDEBAR_WIDTH_VAR, "".concat(width, "px"));
  9179. return true;
  9180. }
  9181. }, {
  9182. key: "_mouseMove",
  9183. value: function _mouseMove(evt) {
  9184. var width = evt.clientX;
  9185. if (this.isRTL) {
  9186. width = this.outerContainerWidth - width;
  9187. }
  9188. this._updateWidth(width);
  9189. }
  9190. }, {
  9191. key: "_mouseUp",
  9192. value: function _mouseUp(evt) {
  9193. this.outerContainer.classList.remove(SIDEBAR_RESIZING_CLASS);
  9194. this.eventBus.dispatch('resize', {
  9195. source: this
  9196. });
  9197. var _boundEvents = this._boundEvents;
  9198. window.removeEventListener('mousemove', _boundEvents.mouseMove);
  9199. window.removeEventListener('mouseup', _boundEvents.mouseUp);
  9200. }
  9201. }, {
  9202. key: "_addEventListeners",
  9203. value: function _addEventListeners() {
  9204. var _this2 = this;
  9205. if (!this.enabled) {
  9206. return;
  9207. }
  9208. var _boundEvents = this._boundEvents;
  9209. _boundEvents.mouseMove = this._mouseMove.bind(this);
  9210. _boundEvents.mouseUp = this._mouseUp.bind(this);
  9211. this.resizer.addEventListener('mousedown', function(evt) {
  9212. if (evt.button !== 0) {
  9213. return;
  9214. }
  9215. _this2.outerContainer.classList.add(SIDEBAR_RESIZING_CLASS);
  9216. window.addEventListener('mousemove', _boundEvents
  9217. .mouseMove);
  9218. window.addEventListener('mouseup', _boundEvents.mouseUp);
  9219. });
  9220. this.eventBus.on('sidebarviewchanged', function(evt) {
  9221. _this2.sidebarOpen = !!(evt && evt.view);
  9222. });
  9223. this.eventBus.on('resize', function(evt) {
  9224. if (evt && evt.source === window) {
  9225. _this2._outerContainerWidth = null;
  9226. if (_this2._width) {
  9227. if (_this2.sidebarOpen) {
  9228. _this2.outerContainer.classList.add(
  9229. SIDEBAR_RESIZING_CLASS);
  9230. var updated = _this2._updateWidth(_this2
  9231. ._width);
  9232. Promise.resolve().then(function() {
  9233. _this2.outerContainer.classList
  9234. .remove(SIDEBAR_RESIZING_CLASS);
  9235. if (updated) {
  9236. _this2.eventBus.dispatch(
  9237. 'resize', {
  9238. source: _this2
  9239. });
  9240. }
  9241. });
  9242. } else {
  9243. _this2._updateWidth(_this2._width);
  9244. }
  9245. }
  9246. }
  9247. });
  9248. }
  9249. }, {
  9250. key: "outerContainerWidth",
  9251. get: function get() {
  9252. if (!this._outerContainerWidth) {
  9253. this._outerContainerWidth = this.outerContainer.clientWidth;
  9254. }
  9255. return this._outerContainerWidth;
  9256. }
  9257. }]);
  9258. return PDFSidebarResizer;
  9259. }();
  9260. exports.PDFSidebarResizer = PDFSidebarResizer;
  9261. /***/
  9262. }),
  9263. /* 25 */
  9264. /***/
  9265. (function(module, exports, __webpack_require__) {
  9266. "use strict";
  9267. Object.defineProperty(exports, "__esModule", {
  9268. value: true
  9269. });
  9270. exports.PDFThumbnailViewer = void 0;
  9271. var _ui_utils = __webpack_require__(5);
  9272. var _pdf_thumbnail_view = __webpack_require__(26);
  9273. function _classCallCheck(instance, Constructor) {
  9274. if (!(instance instanceof Constructor)) {
  9275. throw new TypeError("Cannot call a class as a function");
  9276. }
  9277. }
  9278. function _defineProperties(target, props) {
  9279. for (var i = 0; i < props.length; i++) {
  9280. var descriptor = props[i];
  9281. descriptor.enumerable = descriptor.enumerable || false;
  9282. descriptor.configurable = true;
  9283. if ("value" in descriptor) descriptor.writable = true;
  9284. Object.defineProperty(target, descriptor.key, descriptor);
  9285. }
  9286. }
  9287. function _createClass(Constructor, protoProps, staticProps) {
  9288. if (protoProps) _defineProperties(Constructor.prototype, protoProps);
  9289. if (staticProps) _defineProperties(Constructor, staticProps);
  9290. return Constructor;
  9291. }
  9292. var THUMBNAIL_SCROLL_MARGIN = -19;
  9293. var THUMBNAIL_SELECTED_CLASS = 'selected';
  9294. var PDFThumbnailViewer =
  9295. /*#__PURE__*/
  9296. function() {
  9297. function PDFThumbnailViewer(_ref) {
  9298. var container = _ref.container,
  9299. linkService = _ref.linkService,
  9300. renderingQueue = _ref.renderingQueue,
  9301. _ref$l10n = _ref.l10n,
  9302. l10n = _ref$l10n === void 0 ? _ui_utils.NullL10n : _ref$l10n;
  9303. _classCallCheck(this, PDFThumbnailViewer);
  9304. this.container = container;
  9305. this.linkService = linkService;
  9306. this.renderingQueue = renderingQueue;
  9307. this.l10n = l10n;
  9308. this.scroll = (0, _ui_utils.watchScroll)(this.container, this._scrollUpdated.bind(this));
  9309. this._resetView();
  9310. }
  9311. _createClass(PDFThumbnailViewer, [{
  9312. key: "_scrollUpdated",
  9313. value: function _scrollUpdated() {
  9314. this.renderingQueue.renderHighestPriority();
  9315. }
  9316. }, {
  9317. key: "getThumbnail",
  9318. value: function getThumbnail(index) {
  9319. return this._thumbnails[index];
  9320. }
  9321. }, {
  9322. key: "_getVisibleThumbs",
  9323. value: function _getVisibleThumbs() {
  9324. return (0, _ui_utils.getVisibleElements)(this.container, this
  9325. ._thumbnails);
  9326. }
  9327. }, {
  9328. key: "scrollThumbnailIntoView",
  9329. value: function scrollThumbnailIntoView(pageNumber) {
  9330. if (!this.pdfDocument) {
  9331. return;
  9332. }
  9333. var thumbnailView = this._thumbnails[pageNumber - 1];
  9334. if (!thumbnailView) {
  9335. console.error(
  9336. 'scrollThumbnailIntoView: Invalid "pageNumber" parameter.');
  9337. return;
  9338. }
  9339. if (pageNumber !== this._currentPageNumber) {
  9340. var prevThumbnailView = this._thumbnails[this._currentPageNumber -
  9341. 1];
  9342. prevThumbnailView.div.classList.remove(THUMBNAIL_SELECTED_CLASS);
  9343. thumbnailView.div.classList.add(THUMBNAIL_SELECTED_CLASS);
  9344. }
  9345. var visibleThumbs = this._getVisibleThumbs();
  9346. var numVisibleThumbs = visibleThumbs.views.length;
  9347. if (numVisibleThumbs > 0) {
  9348. var first = visibleThumbs.first.id;
  9349. var last = numVisibleThumbs > 1 ? visibleThumbs.last.id : first;
  9350. var shouldScroll = false;
  9351. if (pageNumber <= first || pageNumber >= last) {
  9352. shouldScroll = true;
  9353. } else {
  9354. visibleThumbs.views.some(function(view) {
  9355. if (view.id !== pageNumber) {
  9356. return false;
  9357. }
  9358. shouldScroll = view.percent < 100;
  9359. return true;
  9360. });
  9361. }
  9362. if (shouldScroll) {
  9363. (0, _ui_utils.scrollIntoView)(thumbnailView.div, {
  9364. top: THUMBNAIL_SCROLL_MARGIN
  9365. });
  9366. }
  9367. }
  9368. this._currentPageNumber = pageNumber;
  9369. }
  9370. }, {
  9371. key: "cleanup",
  9372. value: function cleanup() {
  9373. _pdf_thumbnail_view.PDFThumbnailView.cleanup();
  9374. }
  9375. }, {
  9376. key: "_resetView",
  9377. value: function _resetView() {
  9378. this._thumbnails = [];
  9379. this._currentPageNumber = 1;
  9380. this._pageLabels = null;
  9381. this._pagesRotation = 0;
  9382. this._pagesRequests = [];
  9383. this.container.textContent = '';
  9384. }
  9385. }, {
  9386. key: "setDocument",
  9387. value: function setDocument(pdfDocument) {
  9388. var _this = this;
  9389. if (this.pdfDocument) {
  9390. this._cancelRendering();
  9391. this._resetView();
  9392. }
  9393. this.pdfDocument = pdfDocument;
  9394. if (!pdfDocument) {
  9395. return;
  9396. }
  9397. pdfDocument.getPage(1).then(function(firstPage) {
  9398. var pagesCount = pdfDocument.numPages;
  9399. var viewport = firstPage.getViewport({
  9400. scale: 1
  9401. });
  9402. for (var pageNum = 1; pageNum <= pagesCount; ++pageNum) {
  9403. var thumbnail = new _pdf_thumbnail_view
  9404. .PDFThumbnailView({
  9405. container: _this.container,
  9406. id: pageNum,
  9407. defaultViewport: viewport.clone(),
  9408. linkService: _this.linkService,
  9409. renderingQueue: _this.renderingQueue,
  9410. disableCanvasToImageConversion: false,
  9411. l10n: _this.l10n
  9412. });
  9413. _this._thumbnails.push(thumbnail);
  9414. }
  9415. var thumbnailView = _this._thumbnails[_this
  9416. ._currentPageNumber - 1];
  9417. thumbnailView.div.classList.add(THUMBNAIL_SELECTED_CLASS);
  9418. })["catch"](function(reason) {
  9419. console.error('Unable to initialize thumbnail viewer',
  9420. reason);
  9421. });
  9422. }
  9423. }, {
  9424. key: "_cancelRendering",
  9425. value: function _cancelRendering() {
  9426. for (var i = 0, ii = this._thumbnails.length; i < ii; i++) {
  9427. if (this._thumbnails[i]) {
  9428. this._thumbnails[i].cancelRendering();
  9429. }
  9430. }
  9431. }
  9432. }, {
  9433. key: "setPageLabels",
  9434. value: function setPageLabels(labels) {
  9435. if (!this.pdfDocument) {
  9436. return;
  9437. }
  9438. if (!labels) {
  9439. this._pageLabels = null;
  9440. } else if (!(Array.isArray(labels) && this.pdfDocument.numPages ===
  9441. labels.length)) {
  9442. this._pageLabels = null;
  9443. console.error(
  9444. 'PDFThumbnailViewer_setPageLabels: Invalid page labels.');
  9445. } else {
  9446. this._pageLabels = labels;
  9447. }
  9448. for (var i = 0, ii = this._thumbnails.length; i < ii; i++) {
  9449. var label = this._pageLabels && this._pageLabels[i];
  9450. this._thumbnails[i].setPageLabel(label);
  9451. }
  9452. }
  9453. }, {
  9454. key: "_ensurePdfPageLoaded",
  9455. value: function _ensurePdfPageLoaded(thumbView) {
  9456. var _this2 = this;
  9457. if (thumbView.pdfPage) {
  9458. return Promise.resolve(thumbView.pdfPage);
  9459. }
  9460. var pageNumber = thumbView.id;
  9461. if (this._pagesRequests[pageNumber]) {
  9462. return this._pagesRequests[pageNumber];
  9463. }
  9464. var promise = this.pdfDocument.getPage(pageNumber).then(function(
  9465. pdfPage) {
  9466. thumbView.setPdfPage(pdfPage);
  9467. _this2._pagesRequests[pageNumber] = null;
  9468. return pdfPage;
  9469. })["catch"](function(reason) {
  9470. console.error('Unable to get page for thumb view', reason);
  9471. _this2._pagesRequests[pageNumber] = null;
  9472. });
  9473. this._pagesRequests[pageNumber] = promise;
  9474. return promise;
  9475. }
  9476. }, {
  9477. key: "forceRendering",
  9478. value: function forceRendering() {
  9479. var _this3 = this;
  9480. var visibleThumbs = this._getVisibleThumbs();
  9481. var thumbView = this.renderingQueue.getHighestPriority(visibleThumbs,
  9482. this._thumbnails, this.scroll.down);
  9483. if (thumbView) {
  9484. this._ensurePdfPageLoaded(thumbView).then(function() {
  9485. _this3.renderingQueue.renderView(thumbView);
  9486. });
  9487. return true;
  9488. }
  9489. return false;
  9490. }
  9491. }, {
  9492. key: "pagesRotation",
  9493. get: function get() {
  9494. return this._pagesRotation;
  9495. },
  9496. set: function set(rotation) {
  9497. if (!(0, _ui_utils.isValidRotation)(rotation)) {
  9498. throw new Error('Invalid thumbnails rotation angle.');
  9499. }
  9500. if (!this.pdfDocument) {
  9501. return;
  9502. }
  9503. if (this._pagesRotation === rotation) {
  9504. return;
  9505. }
  9506. this._pagesRotation = rotation;
  9507. for (var i = 0, ii = this._thumbnails.length; i < ii; i++) {
  9508. this._thumbnails[i].update(rotation);
  9509. }
  9510. }
  9511. }]);
  9512. return PDFThumbnailViewer;
  9513. }();
  9514. exports.PDFThumbnailViewer = PDFThumbnailViewer;
  9515. /***/
  9516. }),
  9517. /* 26 */
  9518. /***/
  9519. (function(module, exports, __webpack_require__) {
  9520. "use strict";
  9521. Object.defineProperty(exports, "__esModule", {
  9522. value: true
  9523. });
  9524. exports.PDFThumbnailView = void 0;
  9525. var _pdfjsLib = __webpack_require__(7);
  9526. var _ui_utils = __webpack_require__(5);
  9527. var _pdf_rendering_queue = __webpack_require__(11);
  9528. function _classCallCheck(instance, Constructor) {
  9529. if (!(instance instanceof Constructor)) {
  9530. throw new TypeError("Cannot call a class as a function");
  9531. }
  9532. }
  9533. function _defineProperties(target, props) {
  9534. for (var i = 0; i < props.length; i++) {
  9535. var descriptor = props[i];
  9536. descriptor.enumerable = descriptor.enumerable || false;
  9537. descriptor.configurable = true;
  9538. if ("value" in descriptor) descriptor.writable = true;
  9539. Object.defineProperty(target, descriptor.key, descriptor);
  9540. }
  9541. }
  9542. function _createClass(Constructor, protoProps, staticProps) {
  9543. if (protoProps) _defineProperties(Constructor.prototype, protoProps);
  9544. if (staticProps) _defineProperties(Constructor, staticProps);
  9545. return Constructor;
  9546. }
  9547. var MAX_NUM_SCALING_STEPS = 3;
  9548. var THUMBNAIL_CANVAS_BORDER_WIDTH = 1;
  9549. var THUMBNAIL_WIDTH = 98;
  9550. var TempImageFactory = function TempImageFactoryClosure() {
  9551. var tempCanvasCache = null;
  9552. return {
  9553. getCanvas: function getCanvas(width, height) {
  9554. var tempCanvas = tempCanvasCache;
  9555. if (!tempCanvas) {
  9556. tempCanvas = document.createElement('canvas');
  9557. tempCanvasCache = tempCanvas;
  9558. }
  9559. tempCanvas.width = width;
  9560. tempCanvas.height = height;
  9561. tempCanvas.mozOpaque = true;
  9562. var ctx = tempCanvas.getContext('2d', {
  9563. alpha: false
  9564. });
  9565. ctx.save();
  9566. ctx.fillStyle = 'rgb(255, 255, 255)';
  9567. ctx.fillRect(0, 0, width, height);
  9568. ctx.restore();
  9569. return tempCanvas;
  9570. },
  9571. destroyCanvas: function destroyCanvas() {
  9572. var tempCanvas = tempCanvasCache;
  9573. if (tempCanvas) {
  9574. tempCanvas.width = 0;
  9575. tempCanvas.height = 0;
  9576. }
  9577. tempCanvasCache = null;
  9578. }
  9579. };
  9580. }();
  9581. var PDFThumbnailView =
  9582. /*#__PURE__*/
  9583. function() {
  9584. function PDFThumbnailView(_ref) {
  9585. var container = _ref.container,
  9586. id = _ref.id,
  9587. defaultViewport = _ref.defaultViewport,
  9588. linkService = _ref.linkService,
  9589. renderingQueue = _ref.renderingQueue,
  9590. _ref$disableCanvasToI = _ref.disableCanvasToImageConversion,
  9591. disableCanvasToImageConversion = _ref$disableCanvasToI === void 0 ? false :
  9592. _ref$disableCanvasToI,
  9593. _ref$l10n = _ref.l10n,
  9594. l10n = _ref$l10n === void 0 ? _ui_utils.NullL10n : _ref$l10n;
  9595. _classCallCheck(this, PDFThumbnailView);
  9596. this.id = id;
  9597. this.renderingId = 'thumbnail' + id;
  9598. this.pageLabel = null;
  9599. this.pdfPage = null;
  9600. this.rotation = 0;
  9601. this.viewport = defaultViewport;
  9602. this.pdfPageRotate = defaultViewport.rotation;
  9603. this.linkService = linkService;
  9604. this.renderingQueue = renderingQueue;
  9605. this.renderTask = null;
  9606. this.renderingState = _pdf_rendering_queue.RenderingStates.INITIAL;
  9607. this.resume = null;
  9608. this.disableCanvasToImageConversion = disableCanvasToImageConversion;
  9609. this.pageWidth = this.viewport.width;
  9610. this.pageHeight = this.viewport.height;
  9611. this.pageRatio = this.pageWidth / this.pageHeight;
  9612. this.canvasWidth = THUMBNAIL_WIDTH;
  9613. this.canvasHeight = this.canvasWidth / this.pageRatio | 0;
  9614. this.scale = this.canvasWidth / this.pageWidth;
  9615. this.l10n = l10n;
  9616. var anchor = document.createElement('a');
  9617. anchor.href = linkService.getAnchorUrl('#page=' + id);
  9618. this.l10n.get('thumb_page_title', {
  9619. page: id
  9620. }, 'Page {{page}}').then(function(msg) {
  9621. anchor.title = msg;
  9622. });
  9623. anchor.onclick = function() {
  9624. linkService.page = id;
  9625. return false;
  9626. };
  9627. this.anchor = anchor;
  9628. var div = document.createElement('div');
  9629. div.className = 'thumbnail';
  9630. div.setAttribute('data-page-number', this.id);
  9631. this.div = div;
  9632. var ring = document.createElement('div');
  9633. ring.className = 'thumbnailSelectionRing';
  9634. var borderAdjustment = 2 * THUMBNAIL_CANVAS_BORDER_WIDTH;
  9635. ring.style.width = this.canvasWidth + borderAdjustment + 'px';
  9636. ring.style.height = this.canvasHeight + borderAdjustment + 'px';
  9637. this.ring = ring;
  9638. div.appendChild(ring);
  9639. anchor.appendChild(div);
  9640. container.appendChild(anchor);
  9641. }
  9642. _createClass(PDFThumbnailView, [{
  9643. key: "setPdfPage",
  9644. value: function setPdfPage(pdfPage) {
  9645. this.pdfPage = pdfPage;
  9646. this.pdfPageRotate = pdfPage.rotate;
  9647. var totalRotation = (this.rotation + this.pdfPageRotate) % 360;
  9648. this.viewport = pdfPage.getViewport({
  9649. scale: 1,
  9650. rotation: totalRotation
  9651. });
  9652. this.reset();
  9653. }
  9654. }, {
  9655. key: "reset",
  9656. value: function reset() {
  9657. this.cancelRendering();
  9658. this.renderingState = _pdf_rendering_queue.RenderingStates.INITIAL;
  9659. this.pageWidth = this.viewport.width;
  9660. this.pageHeight = this.viewport.height;
  9661. this.pageRatio = this.pageWidth / this.pageHeight;
  9662. this.canvasHeight = this.canvasWidth / this.pageRatio | 0;
  9663. this.scale = this.canvasWidth / this.pageWidth;
  9664. this.div.removeAttribute('data-loaded');
  9665. var ring = this.ring;
  9666. var childNodes = ring.childNodes;
  9667. for (var i = childNodes.length - 1; i >= 0; i--) {
  9668. ring.removeChild(childNodes[i]);
  9669. }
  9670. var borderAdjustment = 2 * THUMBNAIL_CANVAS_BORDER_WIDTH;
  9671. ring.style.width = this.canvasWidth + borderAdjustment + 'px';
  9672. ring.style.height = this.canvasHeight + borderAdjustment + 'px';
  9673. if (this.canvas) {
  9674. this.canvas.width = 0;
  9675. this.canvas.height = 0;
  9676. delete this.canvas;
  9677. }
  9678. if (this.image) {
  9679. this.image.removeAttribute('src');
  9680. delete this.image;
  9681. }
  9682. }
  9683. }, {
  9684. key: "update",
  9685. value: function update(rotation) {
  9686. if (typeof rotation !== 'undefined') {
  9687. this.rotation = rotation;
  9688. }
  9689. var totalRotation = (this.rotation + this.pdfPageRotate) % 360;
  9690. this.viewport = this.viewport.clone({
  9691. scale: 1,
  9692. rotation: totalRotation
  9693. });
  9694. this.reset();
  9695. }
  9696. }, {
  9697. key: "cancelRendering",
  9698. value: function cancelRendering() {
  9699. if (this.renderTask) {
  9700. this.renderTask.cancel();
  9701. this.renderTask = null;
  9702. }
  9703. this.resume = null;
  9704. }
  9705. }, {
  9706. key: "_getPageDrawContext",
  9707. value: function _getPageDrawContext() {
  9708. var noCtxScale = arguments.length > 0 && arguments[0] !== undefined ?
  9709. arguments[0] : false;
  9710. var canvas = document.createElement('canvas');
  9711. this.canvas = canvas;
  9712. canvas.mozOpaque = true;
  9713. var ctx = canvas.getContext('2d', {
  9714. alpha: false
  9715. });
  9716. var outputScale = (0, _ui_utils.getOutputScale)(ctx);
  9717. canvas.width = this.canvasWidth * outputScale.sx | 0;
  9718. canvas.height = this.canvasHeight * outputScale.sy | 0;
  9719. canvas.style.width = this.canvasWidth + 'px';
  9720. canvas.style.height = this.canvasHeight + 'px';
  9721. if (!noCtxScale && outputScale.scaled) {
  9722. ctx.scale(outputScale.sx, outputScale.sy);
  9723. }
  9724. return ctx;
  9725. }
  9726. }, {
  9727. key: "_convertCanvasToImage",
  9728. value: function _convertCanvasToImage() {
  9729. var _this = this;
  9730. if (!this.canvas) {
  9731. return;
  9732. }
  9733. if (this.renderingState !== _pdf_rendering_queue.RenderingStates
  9734. .FINISHED) {
  9735. return;
  9736. }
  9737. var id = this.renderingId;
  9738. var className = 'thumbnailImage';
  9739. if (this.disableCanvasToImageConversion) {
  9740. this.canvas.id = id;
  9741. this.canvas.className = className;
  9742. this.l10n.get('thumb_page_canvas', {
  9743. page: this.pageId
  9744. }, 'Thumbnail of Page {{page}}').then(function(msg) {
  9745. _this.canvas.setAttribute('aria-label', msg);
  9746. });
  9747. this.div.setAttribute('data-loaded', true);
  9748. this.ring.appendChild(this.canvas);
  9749. return;
  9750. }
  9751. var image = document.createElement('img');
  9752. image.id = id;
  9753. image.className = className;
  9754. this.l10n.get('thumb_page_canvas', {
  9755. page: this.pageId
  9756. }, 'Thumbnail of Page {{page}}').then(function(msg) {
  9757. image.setAttribute('aria-label', msg);
  9758. });
  9759. image.style.width = this.canvasWidth + 'px';
  9760. image.style.height = this.canvasHeight + 'px';
  9761. image.src = this.canvas.toDataURL();
  9762. this.image = image;
  9763. this.div.setAttribute('data-loaded', true);
  9764. this.ring.appendChild(image);
  9765. this.canvas.width = 0;
  9766. this.canvas.height = 0;
  9767. delete this.canvas;
  9768. }
  9769. }, {
  9770. key: "draw",
  9771. value: function draw() {
  9772. var _this2 = this;
  9773. if (this.renderingState !== _pdf_rendering_queue.RenderingStates
  9774. .INITIAL) {
  9775. console.error('Must be in new state before drawing');
  9776. return Promise.resolve(undefined);
  9777. }
  9778. this.renderingState = _pdf_rendering_queue.RenderingStates.RUNNING;
  9779. var renderCapability = (0, _pdfjsLib.createPromiseCapability)();
  9780. var finishRenderTask = function finishRenderTask(error) {
  9781. if (renderTask === _this2.renderTask) {
  9782. _this2.renderTask = null;
  9783. }
  9784. if (error instanceof _pdfjsLib.RenderingCancelledException) {
  9785. renderCapability.resolve(undefined);
  9786. return;
  9787. }
  9788. _this2.renderingState = _pdf_rendering_queue.RenderingStates
  9789. .FINISHED;
  9790. _this2._convertCanvasToImage();
  9791. if (!error) {
  9792. renderCapability.resolve(undefined);
  9793. } else {
  9794. renderCapability.reject(error);
  9795. }
  9796. };
  9797. var ctx = this._getPageDrawContext();
  9798. var drawViewport = this.viewport.clone({
  9799. scale: this.scale
  9800. });
  9801. var renderContinueCallback = function renderContinueCallback(cont) {
  9802. if (!_this2.renderingQueue.isHighestPriority(_this2)) {
  9803. _this2.renderingState = _pdf_rendering_queue.RenderingStates
  9804. .PAUSED;
  9805. _this2.resume = function() {
  9806. _this2.renderingState = _pdf_rendering_queue
  9807. .RenderingStates.RUNNING;
  9808. cont();
  9809. };
  9810. return;
  9811. }
  9812. cont();
  9813. };
  9814. var renderContext = {
  9815. canvasContext: ctx,
  9816. viewport: drawViewport
  9817. };
  9818. var renderTask = this.renderTask = this.pdfPage.render(renderContext);
  9819. renderTask.onContinue = renderContinueCallback;
  9820. renderTask.promise.then(function() {
  9821. finishRenderTask(null);
  9822. }, function(error) {
  9823. finishRenderTask(error);
  9824. });
  9825. return renderCapability.promise;
  9826. }
  9827. }, {
  9828. key: "setImage",
  9829. value: function setImage(pageView) {
  9830. if (this.renderingState !== _pdf_rendering_queue.RenderingStates
  9831. .INITIAL) {
  9832. return;
  9833. }
  9834. var img = pageView.canvas;
  9835. if (!img) {
  9836. return;
  9837. }
  9838. if (!this.pdfPage) {
  9839. this.setPdfPage(pageView.pdfPage);
  9840. }
  9841. this.renderingState = _pdf_rendering_queue.RenderingStates.FINISHED;
  9842. var ctx = this._getPageDrawContext(true);
  9843. var canvas = ctx.canvas;
  9844. if (img.width <= 2 * canvas.width) {
  9845. ctx.drawImage(img, 0, 0, img.width, img.height, 0, 0, canvas.width,
  9846. canvas.height);
  9847. this._convertCanvasToImage();
  9848. return;
  9849. }
  9850. var reducedWidth = canvas.width << MAX_NUM_SCALING_STEPS;
  9851. var reducedHeight = canvas.height << MAX_NUM_SCALING_STEPS;
  9852. var reducedImage = TempImageFactory.getCanvas(reducedWidth,
  9853. reducedHeight);
  9854. var reducedImageCtx = reducedImage.getContext('2d');
  9855. while (reducedWidth > img.width || reducedHeight > img.height) {
  9856. reducedWidth >>= 1;
  9857. reducedHeight >>= 1;
  9858. }
  9859. reducedImageCtx.drawImage(img, 0, 0, img.width, img.height, 0, 0,
  9860. reducedWidth, reducedHeight);
  9861. while (reducedWidth > 2 * canvas.width) {
  9862. reducedImageCtx.drawImage(reducedImage, 0, 0, reducedWidth,
  9863. reducedHeight, 0, 0, reducedWidth >> 1, reducedHeight >> 1);
  9864. reducedWidth >>= 1;
  9865. reducedHeight >>= 1;
  9866. }
  9867. ctx.drawImage(reducedImage, 0, 0, reducedWidth, reducedHeight, 0, 0,
  9868. canvas.width, canvas.height);
  9869. this._convertCanvasToImage();
  9870. }
  9871. }, {
  9872. key: "setPageLabel",
  9873. value: function setPageLabel(label) {
  9874. var _this3 = this;
  9875. this.pageLabel = typeof label === 'string' ? label : null;
  9876. this.l10n.get('thumb_page_title', {
  9877. page: this.pageId
  9878. }, 'Page {{page}}').then(function(msg) {
  9879. _this3.anchor.title = msg;
  9880. });
  9881. if (this.renderingState !== _pdf_rendering_queue.RenderingStates
  9882. .FINISHED) {
  9883. return;
  9884. }
  9885. this.l10n.get('thumb_page_canvas', {
  9886. page: this.pageId
  9887. }, 'Thumbnail of Page {{page}}').then(function(ariaLabel) {
  9888. if (_this3.image) {
  9889. _this3.image.setAttribute('aria-label', ariaLabel);
  9890. } else if (_this3.disableCanvasToImageConversion && _this3
  9891. .canvas) {
  9892. _this3.canvas.setAttribute('aria-label', ariaLabel);
  9893. }
  9894. });
  9895. }
  9896. }, {
  9897. key: "pageId",
  9898. get: function get() {
  9899. return this.pageLabel !== null ? this.pageLabel : this.id;
  9900. }
  9901. }], [{
  9902. key: "cleanup",
  9903. value: function cleanup() {
  9904. TempImageFactory.destroyCanvas();
  9905. }
  9906. }]);
  9907. return PDFThumbnailView;
  9908. }();
  9909. exports.PDFThumbnailView = PDFThumbnailView;
  9910. /***/
  9911. }),
  9912. /* 27 */
  9913. /***/
  9914. (function(module, exports, __webpack_require__) {
  9915. "use strict";
  9916. Object.defineProperty(exports, "__esModule", {
  9917. value: true
  9918. });
  9919. exports.PDFViewer = void 0;
  9920. var _base_viewer = __webpack_require__(28);
  9921. var _pdfjsLib = __webpack_require__(7);
  9922. function _typeof(obj) {
  9923. if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
  9924. _typeof = function _typeof(obj) {
  9925. return typeof obj;
  9926. };
  9927. } else {
  9928. _typeof = function _typeof(obj) {
  9929. return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !==
  9930. Symbol.prototype ? "symbol" : typeof obj;
  9931. };
  9932. }
  9933. return _typeof(obj);
  9934. }
  9935. function _classCallCheck(instance, Constructor) {
  9936. if (!(instance instanceof Constructor)) {
  9937. throw new TypeError("Cannot call a class as a function");
  9938. }
  9939. }
  9940. function _defineProperties(target, props) {
  9941. for (var i = 0; i < props.length; i++) {
  9942. var descriptor = props[i];
  9943. descriptor.enumerable = descriptor.enumerable || false;
  9944. descriptor.configurable = true;
  9945. if ("value" in descriptor) descriptor.writable = true;
  9946. Object.defineProperty(target, descriptor.key, descriptor);
  9947. }
  9948. }
  9949. function _createClass(Constructor, protoProps, staticProps) {
  9950. if (protoProps) _defineProperties(Constructor.prototype, protoProps);
  9951. if (staticProps) _defineProperties(Constructor, staticProps);
  9952. return Constructor;
  9953. }
  9954. function _possibleConstructorReturn(self, call) {
  9955. if (call && (_typeof(call) === "object" || typeof call === "function")) {
  9956. return call;
  9957. }
  9958. return _assertThisInitialized(self);
  9959. }
  9960. function _assertThisInitialized(self) {
  9961. if (self === void 0) {
  9962. throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
  9963. }
  9964. return self;
  9965. }
  9966. function _get(target, property, receiver) {
  9967. if (typeof Reflect !== "undefined" && Reflect.get) {
  9968. _get = Reflect.get;
  9969. } else {
  9970. _get = function _get(target, property, receiver) {
  9971. var base = _superPropBase(target, property);
  9972. if (!base) return;
  9973. var desc = Object.getOwnPropertyDescriptor(base, property);
  9974. if (desc.get) {
  9975. return desc.get.call(receiver);
  9976. }
  9977. return desc.value;
  9978. };
  9979. }
  9980. return _get(target, property, receiver || target);
  9981. }
  9982. function _superPropBase(object, property) {
  9983. while (!Object.prototype.hasOwnProperty.call(object, property)) {
  9984. object = _getPrototypeOf(object);
  9985. if (object === null) break;
  9986. }
  9987. return object;
  9988. }
  9989. function _getPrototypeOf(o) {
  9990. _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
  9991. return o.__proto__ || Object.getPrototypeOf(o);
  9992. };
  9993. return _getPrototypeOf(o);
  9994. }
  9995. function _inherits(subClass, superClass) {
  9996. if (typeof superClass !== "function" && superClass !== null) {
  9997. throw new TypeError("Super expression must either be null or a function");
  9998. }
  9999. subClass.prototype = Object.create(superClass && superClass.prototype, {
  10000. constructor: {
  10001. value: subClass,
  10002. writable: true,
  10003. configurable: true
  10004. }
  10005. });
  10006. if (superClass) _setPrototypeOf(subClass, superClass);
  10007. }
  10008. function _setPrototypeOf(o, p) {
  10009. _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
  10010. o.__proto__ = p;
  10011. return o;
  10012. };
  10013. return _setPrototypeOf(o, p);
  10014. }
  10015. var PDFViewer =
  10016. /*#__PURE__*/
  10017. function(_BaseViewer) {
  10018. _inherits(PDFViewer, _BaseViewer);
  10019. function PDFViewer() {
  10020. _classCallCheck(this, PDFViewer);
  10021. return _possibleConstructorReturn(this, _getPrototypeOf(PDFViewer).apply(this, arguments));
  10022. }
  10023. _createClass(PDFViewer, [{
  10024. key: "_scrollIntoView",
  10025. value: function _scrollIntoView(_ref) {
  10026. var pageDiv = _ref.pageDiv,
  10027. _ref$pageSpot = _ref.pageSpot,
  10028. pageSpot = _ref$pageSpot === void 0 ? null : _ref$pageSpot,
  10029. _ref$pageNumber = _ref.pageNumber,
  10030. pageNumber = _ref$pageNumber === void 0 ? null : _ref$pageNumber;
  10031. if (!pageSpot && !this.isInPresentationMode) {
  10032. var left = pageDiv.offsetLeft + pageDiv.clientLeft;
  10033. var right = left + pageDiv.clientWidth;
  10034. var _this$container = this.container,
  10035. scrollLeft = _this$container.scrollLeft,
  10036. clientWidth = _this$container.clientWidth;
  10037. if (this._isScrollModeHorizontal || left < scrollLeft || right >
  10038. scrollLeft + clientWidth) {
  10039. pageSpot = {
  10040. left: 0,
  10041. top: 0
  10042. };
  10043. }
  10044. }
  10045. _get(_getPrototypeOf(PDFViewer.prototype), "_scrollIntoView", this)
  10046. .call(this, {
  10047. pageDiv: pageDiv,
  10048. pageSpot: pageSpot,
  10049. pageNumber: pageNumber
  10050. });
  10051. }
  10052. }, {
  10053. key: "_getVisiblePages",
  10054. value: function _getVisiblePages() {
  10055. if (this.isInPresentationMode) {
  10056. return this._getCurrentVisiblePage();
  10057. }
  10058. return _get(_getPrototypeOf(PDFViewer.prototype), "_getVisiblePages",
  10059. this).call(this);
  10060. }
  10061. }, {
  10062. key: "_updateHelper",
  10063. value: function _updateHelper(visiblePages) {
  10064. if (this.isInPresentationMode) {
  10065. return;
  10066. }
  10067. var currentId = this._currentPageNumber;
  10068. var stillFullyVisible = false;
  10069. var _iteratorNormalCompletion = true;
  10070. var _didIteratorError = false;
  10071. var _iteratorError = undefined;
  10072. try {
  10073. for (var _iterator = visiblePages[Symbol.iterator](), _step; !(
  10074. _iteratorNormalCompletion = (_step = _iterator.next()).done
  10075. ); _iteratorNormalCompletion = true) {
  10076. var page = _step.value;
  10077. if (page.percent < 100) {
  10078. break;
  10079. }
  10080. if (page.id === currentId) {
  10081. stillFullyVisible = true;
  10082. break;
  10083. }
  10084. }
  10085. } catch (err) {
  10086. _didIteratorError = true;
  10087. _iteratorError = err;
  10088. } finally {
  10089. try {
  10090. if (!_iteratorNormalCompletion && _iterator["return"] != null) {
  10091. _iterator["return"]();
  10092. }
  10093. } finally {
  10094. if (_didIteratorError) {
  10095. throw _iteratorError;
  10096. }
  10097. }
  10098. }
  10099. if (!stillFullyVisible) {
  10100. currentId = visiblePages[0].id;
  10101. }
  10102. this._setCurrentPageNumber(currentId);
  10103. }
  10104. }, {
  10105. key: "_setDocumentViewerElement",
  10106. get: function get() {
  10107. return (0, _pdfjsLib.shadow)(this, '_setDocumentViewerElement', this
  10108. .viewer);
  10109. }
  10110. }]);
  10111. return PDFViewer;
  10112. }(_base_viewer.BaseViewer);
  10113. exports.PDFViewer = PDFViewer;
  10114. /***/
  10115. }),
  10116. /* 28 */
  10117. /***/
  10118. (function(module, exports, __webpack_require__) {
  10119. "use strict";
  10120. Object.defineProperty(exports, "__esModule", {
  10121. value: true
  10122. });
  10123. exports.BaseViewer = void 0;
  10124. var _ui_utils = __webpack_require__(5);
  10125. var _pdf_rendering_queue = __webpack_require__(11);
  10126. var _annotation_layer_builder = __webpack_require__(29);
  10127. var _pdfjsLib = __webpack_require__(7);
  10128. var _pdf_page_view = __webpack_require__(30);
  10129. var _pdf_link_service = __webpack_require__(21);
  10130. var _text_layer_builder = __webpack_require__(31);
  10131. function _classCallCheck(instance, Constructor) {
  10132. if (!(instance instanceof Constructor)) {
  10133. throw new TypeError("Cannot call a class as a function");
  10134. }
  10135. }
  10136. function _defineProperties(target, props) {
  10137. for (var i = 0; i < props.length; i++) {
  10138. var descriptor = props[i];
  10139. descriptor.enumerable = descriptor.enumerable || false;
  10140. descriptor.configurable = true;
  10141. if ("value" in descriptor) descriptor.writable = true;
  10142. Object.defineProperty(target, descriptor.key, descriptor);
  10143. }
  10144. }
  10145. function _createClass(Constructor, protoProps, staticProps) {
  10146. if (protoProps) _defineProperties(Constructor.prototype, protoProps);
  10147. if (staticProps) _defineProperties(Constructor, staticProps);
  10148. return Constructor;
  10149. }
  10150. var DEFAULT_CACHE_SIZE = 10;
  10151. function PDFPageViewBuffer(size) {
  10152. var data = [];
  10153. this.push = function(view) {
  10154. var i = data.indexOf(view);
  10155. if (i >= 0) {
  10156. data.splice(i, 1);
  10157. }
  10158. data.push(view);
  10159. if (data.length > size) {
  10160. data.shift().destroy();
  10161. }
  10162. };
  10163. this.resize = function(newSize, pagesToKeep) {
  10164. size = newSize;
  10165. if (pagesToKeep) {
  10166. var pageIdsToKeep = new Set();
  10167. for (var i = 0, iMax = pagesToKeep.length; i < iMax; ++i) {
  10168. pageIdsToKeep.add(pagesToKeep[i].id);
  10169. }
  10170. (0, _ui_utils.moveToEndOfArray)(data, function(page) {
  10171. return pageIdsToKeep.has(page.id);
  10172. });
  10173. }
  10174. while (data.length > size) {
  10175. data.shift().destroy();
  10176. }
  10177. };
  10178. }
  10179. function isSameScale(oldScale, newScale) {
  10180. if (newScale === oldScale) {
  10181. return true;
  10182. }
  10183. if (Math.abs(newScale - oldScale) < 1e-15) {
  10184. return true;
  10185. }
  10186. return false;
  10187. }
  10188. var BaseViewer =
  10189. /*#__PURE__*/
  10190. function() {
  10191. function BaseViewer(options) {
  10192. var _this = this;
  10193. _classCallCheck(this, BaseViewer);
  10194. if (this.constructor === BaseViewer) {
  10195. throw new Error('Cannot initialize BaseViewer.');
  10196. }
  10197. this._name = this.constructor.name;
  10198. this.container = options.container;
  10199. this.viewer = options.viewer || options.container.firstElementChild;
  10200. this.eventBus = options.eventBus || (0, _ui_utils.getGlobalEventBus)();
  10201. this.linkService = options.linkService || new _pdf_link_service.SimpleLinkService();
  10202. this.downloadManager = options.downloadManager || null;
  10203. this.findController = options.findController || null;
  10204. this.removePageBorders = options.removePageBorders || false;
  10205. this.textLayerMode = Number.isInteger(options.textLayerMode) ? options.textLayerMode :
  10206. _ui_utils.TextLayerMode.ENABLE;
  10207. this.imageResourcesPath = options.imageResourcesPath || '';
  10208. this.renderInteractiveForms = options.renderInteractiveForms || false;
  10209. this.enablePrintAutoRotate = options.enablePrintAutoRotate || false;
  10210. this.renderer = options.renderer || _ui_utils.RendererType.CANVAS;
  10211. this.enableWebGL = options.enableWebGL || false;
  10212. this.useOnlyCssZoom = options.useOnlyCssZoom || false;
  10213. this.maxCanvasPixels = options.maxCanvasPixels;
  10214. this.l10n = options.l10n || _ui_utils.NullL10n;
  10215. this.defaultRenderingQueue = !options.renderingQueue;
  10216. if (this.defaultRenderingQueue) {
  10217. this.renderingQueue = new _pdf_rendering_queue.PDFRenderingQueue();
  10218. this.renderingQueue.setViewer(this);
  10219. } else {
  10220. this.renderingQueue = options.renderingQueue;
  10221. }
  10222. this.scroll = (0, _ui_utils.watchScroll)(this.container, this._scrollUpdate.bind(this));
  10223. this.presentationModeState = _ui_utils.PresentationModeState.UNKNOWN;
  10224. this._onBeforeDraw = this._onAfterDraw = null;
  10225. this._resetView();
  10226. if (this.removePageBorders) {
  10227. this.viewer.classList.add('removePageBorders');
  10228. }
  10229. Promise.resolve().then(function() {
  10230. _this.eventBus.dispatch('baseviewerinit', {
  10231. source: _this
  10232. });
  10233. });
  10234. }
  10235. _createClass(BaseViewer, [{
  10236. key: "getPageView",
  10237. value: function getPageView(index) {
  10238. return this._pages[index];
  10239. }
  10240. }, {
  10241. key: "_setCurrentPageNumber",
  10242. value: function _setCurrentPageNumber(val) {
  10243. var resetCurrentPageView = arguments.length > 1 && arguments[1] !==
  10244. undefined ? arguments[1] : false;
  10245. if (this._currentPageNumber === val) {
  10246. if (resetCurrentPageView) {
  10247. this._resetCurrentPageView();
  10248. }
  10249. return true;
  10250. }
  10251. if (!(0 < val && val <= this.pagesCount)) {
  10252. return false;
  10253. }
  10254. this._currentPageNumber = val;
  10255. this.eventBus.dispatch('pagechanging', {
  10256. source: this,
  10257. pageNumber: val,
  10258. pageLabel: this._pageLabels && this._pageLabels[val - 1]
  10259. });
  10260. if (resetCurrentPageView) {
  10261. this._resetCurrentPageView();
  10262. }
  10263. return true;
  10264. }
  10265. }, {
  10266. key: "setDocument",
  10267. value: function setDocument(pdfDocument) {
  10268. var _this2 = this;
  10269. if (this.pdfDocument) {
  10270. this._cancelRendering();
  10271. this._resetView();
  10272. if (this.findController) {
  10273. this.findController.setDocument(null);
  10274. }
  10275. }
  10276. this.pdfDocument = pdfDocument;
  10277. if (!pdfDocument) {
  10278. return;
  10279. }
  10280. var pagesCount = pdfDocument.numPages;
  10281. var pagesCapability = (0, _pdfjsLib.createPromiseCapability)();
  10282. this.pagesPromise = pagesCapability.promise;
  10283. pagesCapability.promise.then(function() {
  10284. _this2._pageViewsReady = true;
  10285. _this2.eventBus.dispatch('pagesloaded', {
  10286. source: _this2,
  10287. pagesCount: pagesCount
  10288. });
  10289. });
  10290. var onePageRenderedCapability = (0, _pdfjsLib.createPromiseCapability)
  10291. ();
  10292. this.onePageRendered = onePageRenderedCapability.promise;
  10293. var firstPagePromise = pdfDocument.getPage(1);
  10294. this.firstPagePromise = firstPagePromise;
  10295. this._onBeforeDraw = function(evt) {
  10296. var pageView = _this2._pages[evt.pageNumber - 1];
  10297. if (!pageView) {
  10298. return;
  10299. }
  10300. _this2._buffer.push(pageView);
  10301. };
  10302. this.eventBus.on('pagerender', this._onBeforeDraw);
  10303. this._onAfterDraw = function(evt) {
  10304. if (evt.cssTransform || onePageRenderedCapability.settled) {
  10305. return;
  10306. }
  10307. onePageRenderedCapability.resolve();
  10308. _this2.eventBus.off('pagerendered', _this2._onAfterDraw);
  10309. _this2._onAfterDraw = null;
  10310. };
  10311. this.eventBus.on('pagerendered', this._onAfterDraw);
  10312. firstPagePromise.then(function(pdfPage) {
  10313. var scale = _this2.currentScale;
  10314. var viewport = pdfPage.getViewport({
  10315. scale: scale * _ui_utils.CSS_UNITS
  10316. });
  10317. for (var pageNum = 1; pageNum <= pagesCount; ++pageNum) {
  10318. var textLayerFactory = null;
  10319. if (_this2.textLayerMode !== _ui_utils.TextLayerMode
  10320. .DISABLE) {
  10321. textLayerFactory = _this2;
  10322. }
  10323. var pageView = new _pdf_page_view.PDFPageView({
  10324. container: _this2._setDocumentViewerElement,
  10325. eventBus: _this2.eventBus,
  10326. id: pageNum,
  10327. scale: scale,
  10328. defaultViewport: viewport.clone(),
  10329. renderingQueue: _this2.renderingQueue,
  10330. textLayerFactory: textLayerFactory,
  10331. textLayerMode: _this2.textLayerMode,
  10332. annotationLayerFactory: _this2,
  10333. imageResourcesPath: _this2
  10334. .imageResourcesPath,
  10335. renderInteractiveForms: _this2
  10336. .renderInteractiveForms,
  10337. renderer: _this2.renderer,
  10338. enableWebGL: _this2.enableWebGL,
  10339. useOnlyCssZoom: _this2.useOnlyCssZoom,
  10340. maxCanvasPixels: _this2.maxCanvasPixels,
  10341. l10n: _this2.l10n
  10342. });
  10343. _this2._pages.push(pageView);
  10344. }
  10345. if (_this2._spreadMode !== _ui_utils.SpreadMode.NONE) {
  10346. _this2._updateSpreadMode();
  10347. }
  10348. onePageRenderedCapability.promise.then(function() {
  10349. if (_this2.findController) {
  10350. _this2.findController.setDocument(
  10351. pdfDocument);
  10352. }
  10353. if (pdfDocument.loadingParams[
  10354. 'disableAutoFetch']) {
  10355. pagesCapability.resolve();
  10356. return;
  10357. }
  10358. var getPagesLeft = pagesCount;
  10359. var _loop = function _loop(_pageNum) {
  10360. pdfDocument.getPage(_pageNum).then(
  10361. function(pdfPage) {
  10362. var pageView = _this2
  10363. ._pages[_pageNum - 1];
  10364. if (!pageView.pdfPage) {
  10365. pageView.setPdfPage(
  10366. pdfPage);
  10367. }
  10368. _this2.linkService
  10369. .cachePageRef(_pageNum,
  10370. pdfPage.ref);
  10371. if (--getPagesLeft === 0) {
  10372. pagesCapability
  10373. .resolve();
  10374. }
  10375. },
  10376. function(reason) {
  10377. console.error(
  10378. "Unable to get page "
  10379. .concat(_pageNum,
  10380. " to initialize viewer"
  10381. ), reason);
  10382. if (--getPagesLeft === 0) {
  10383. pagesCapability
  10384. .resolve();
  10385. }
  10386. });
  10387. };
  10388. for (var _pageNum = 1; _pageNum <=
  10389. pagesCount; ++_pageNum) {
  10390. _loop(_pageNum);
  10391. }
  10392. });
  10393. _this2.eventBus.dispatch('pagesinit', {
  10394. source: _this2
  10395. });
  10396. if (_this2.defaultRenderingQueue) {
  10397. _this2.update();
  10398. }
  10399. })["catch"](function(reason) {
  10400. console.error('Unable to initialize viewer', reason);
  10401. });
  10402. }
  10403. }, {
  10404. key: "setPageLabels",
  10405. value: function setPageLabels(labels) {
  10406. if (!this.pdfDocument) {
  10407. return;
  10408. }
  10409. if (!labels) {
  10410. this._pageLabels = null;
  10411. } else if (!(Array.isArray(labels) && this.pdfDocument.numPages ===
  10412. labels.length)) {
  10413. this._pageLabels = null;
  10414. console.error("".concat(this._name,
  10415. ".setPageLabels: Invalid page labels."));
  10416. } else {
  10417. this._pageLabels = labels;
  10418. }
  10419. for (var i = 0, ii = this._pages.length; i < ii; i++) {
  10420. var pageView = this._pages[i];
  10421. var label = this._pageLabels && this._pageLabels[i];
  10422. pageView.setPageLabel(label);
  10423. }
  10424. }
  10425. }, {
  10426. key: "_resetView",
  10427. value: function _resetView() {
  10428. this._pages = [];
  10429. this._currentPageNumber = 1;
  10430. this._currentScale = _ui_utils.UNKNOWN_SCALE;
  10431. this._currentScaleValue = null;
  10432. this._pageLabels = null;
  10433. this._buffer = new PDFPageViewBuffer(DEFAULT_CACHE_SIZE);
  10434. this._location = null;
  10435. this._pagesRotation = 0;
  10436. this._pagesRequests = [];
  10437. this._pageViewsReady = false;
  10438. this._scrollMode = _ui_utils.ScrollMode.VERTICAL;
  10439. this._spreadMode = _ui_utils.SpreadMode.NONE;
  10440. if (this._onBeforeDraw) {
  10441. this.eventBus.off('pagerender', this._onBeforeDraw);
  10442. this._onBeforeDraw = null;
  10443. }
  10444. if (this._onAfterDraw) {
  10445. this.eventBus.off('pagerendered', this._onAfterDraw);
  10446. this._onAfterDraw = null;
  10447. }
  10448. this.viewer.textContent = '';
  10449. this._updateScrollMode();
  10450. }
  10451. }, {
  10452. key: "_scrollUpdate",
  10453. value: function _scrollUpdate() {
  10454. if (this.pagesCount === 0) {
  10455. return;
  10456. }
  10457. this.update();
  10458. }
  10459. }, {
  10460. key: "_scrollIntoView",
  10461. value: function _scrollIntoView(_ref) {
  10462. var pageDiv = _ref.pageDiv,
  10463. _ref$pageSpot = _ref.pageSpot,
  10464. pageSpot = _ref$pageSpot === void 0 ? null : _ref$pageSpot,
  10465. _ref$pageNumber = _ref.pageNumber,
  10466. pageNumber = _ref$pageNumber === void 0 ? null : _ref$pageNumber;
  10467. (0, _ui_utils.scrollIntoView)(pageDiv, pageSpot);
  10468. }
  10469. }, {
  10470. key: "_setScaleUpdatePages",
  10471. value: function _setScaleUpdatePages(newScale, newValue) {
  10472. var noScroll = arguments.length > 2 && arguments[2] !== undefined ?
  10473. arguments[2] : false;
  10474. var preset = arguments.length > 3 && arguments[3] !== undefined ?
  10475. arguments[3] : false;
  10476. this._currentScaleValue = newValue.toString();
  10477. if (isSameScale(this._currentScale, newScale)) {
  10478. if (preset) {
  10479. this.eventBus.dispatch('scalechanging', {
  10480. source: this,
  10481. scale: newScale,
  10482. presetValue: newValue
  10483. });
  10484. }
  10485. return;
  10486. }
  10487. for (var i = 0, ii = this._pages.length; i < ii; i++) {
  10488. this._pages[i].update(newScale);
  10489. }
  10490. this._currentScale = newScale;
  10491. if (!noScroll) {
  10492. var page = this._currentPageNumber,
  10493. dest;
  10494. if (this._location && !(this.isInPresentationMode || this
  10495. .isChangingPresentationMode)) {
  10496. page = this._location.pageNumber;
  10497. dest = [null, {
  10498. name: 'XYZ'
  10499. }, this._location.left, this._location.top, null];
  10500. }
  10501. this.scrollPageIntoView({
  10502. pageNumber: page,
  10503. destArray: dest,
  10504. allowNegativeOffset: true
  10505. });
  10506. }
  10507. this.eventBus.dispatch('scalechanging', {
  10508. source: this,
  10509. scale: newScale,
  10510. presetValue: preset ? newValue : undefined
  10511. });
  10512. if (this.defaultRenderingQueue) {
  10513. this.update();
  10514. }
  10515. }
  10516. }, {
  10517. key: "_setScale",
  10518. value: function _setScale(value) {
  10519. var noScroll = arguments.length > 1 && arguments[1] !== undefined ?
  10520. arguments[1] : false;
  10521. var scale = parseFloat(value);
  10522. if (scale > 0) {
  10523. this._setScaleUpdatePages(scale, value, noScroll, false);
  10524. } else {
  10525. var currentPage = this._pages[this._currentPageNumber - 1];
  10526. if (!currentPage) {
  10527. return;
  10528. }
  10529. var noPadding = this.isInPresentationMode || this.removePageBorders;
  10530. var hPadding = noPadding ? 0 : _ui_utils.SCROLLBAR_PADDING;
  10531. var vPadding = noPadding ? 0 : _ui_utils.VERTICAL_PADDING;
  10532. if (!noPadding && this._isScrollModeHorizontal) {
  10533. var _ref2 = [vPadding, hPadding];
  10534. hPadding = _ref2[0];
  10535. vPadding = _ref2[1];
  10536. }
  10537. var pageWidthScale = (this.container.clientWidth - hPadding) /
  10538. currentPage.width * currentPage.scale;
  10539. var pageHeightScale = (this.container.clientHeight - vPadding) /
  10540. currentPage.height * currentPage.scale;
  10541. switch (value) {
  10542. case 'page-actual':
  10543. scale = 1;
  10544. break;
  10545. case 'page-width':
  10546. scale = pageWidthScale;
  10547. break;
  10548. case 'page-height':
  10549. scale = pageHeightScale;
  10550. break;
  10551. case 'page-fit':
  10552. scale = Math.min(pageWidthScale, pageHeightScale);
  10553. break;
  10554. case 'auto':
  10555. var horizontalScale = (0, _ui_utils.isPortraitOrientation)(
  10556. currentPage) ? pageWidthScale : Math.min(
  10557. pageHeightScale, pageWidthScale);
  10558. scale = Math.min(_ui_utils.MAX_AUTO_SCALE, horizontalScale);
  10559. break;
  10560. default:
  10561. console.error("".concat(this._name, "._setScale: \"")
  10562. .concat(value, "\" is an unknown zoom value."));
  10563. return;
  10564. }
  10565. this._setScaleUpdatePages(scale, value, noScroll, true);
  10566. }
  10567. }
  10568. }, {
  10569. key: "_resetCurrentPageView",
  10570. value: function _resetCurrentPageView() {
  10571. if (this.isInPresentationMode) {
  10572. this._setScale(this._currentScaleValue, true);
  10573. }
  10574. var pageView = this._pages[this._currentPageNumber - 1];
  10575. this._scrollIntoView({
  10576. pageDiv: pageView.div
  10577. });
  10578. }
  10579. }, {
  10580. key: "scrollPageIntoView",
  10581. value: function scrollPageIntoView(_ref3) {
  10582. var pageNumber = _ref3.pageNumber,
  10583. _ref3$destArray = _ref3.destArray,
  10584. destArray = _ref3$destArray === void 0 ? null : _ref3$destArray,
  10585. _ref3$allowNegativeOf = _ref3.allowNegativeOffset,
  10586. allowNegativeOffset = _ref3$allowNegativeOf === void 0 ? false :
  10587. _ref3$allowNegativeOf;
  10588. if (!this.pdfDocument) {
  10589. return;
  10590. }
  10591. var pageView = Number.isInteger(pageNumber) && this._pages[pageNumber -
  10592. 1];
  10593. if (!pageView) {
  10594. console.error("".concat(this._name, ".scrollPageIntoView: ") + "\""
  10595. .concat(pageNumber,
  10596. "\" is not a valid pageNumber parameter."));
  10597. return;
  10598. }
  10599. if (this.isInPresentationMode || !destArray) {
  10600. this._setCurrentPageNumber(pageNumber, true);
  10601. return;
  10602. }
  10603. var x = 0,
  10604. y = 0;
  10605. var width = 0,
  10606. height = 0,
  10607. widthScale,
  10608. heightScale;
  10609. var changeOrientation = pageView.rotation % 180 === 0 ? false : true;
  10610. var pageWidth = (changeOrientation ? pageView.height : pageView.width) /
  10611. pageView.scale / _ui_utils.CSS_UNITS;
  10612. var pageHeight = (changeOrientation ? pageView.width : pageView
  10613. .height) / pageView.scale / _ui_utils.CSS_UNITS;
  10614. var scale = 0;
  10615. switch (destArray[1].name) {
  10616. case 'XYZ':
  10617. x = destArray[2];
  10618. y = destArray[3];
  10619. scale = destArray[4];
  10620. x = x !== null ? x : 0;
  10621. y = y !== null ? y : pageHeight;
  10622. break;
  10623. case 'Fit':
  10624. case 'FitB':
  10625. scale = 'page-fit';
  10626. break;
  10627. case 'FitH':
  10628. case 'FitBH':
  10629. y = destArray[2];
  10630. scale = 'page-width';
  10631. if (y === null && this._location) {
  10632. x = this._location.left;
  10633. y = this._location.top;
  10634. }
  10635. break;
  10636. case 'FitV':
  10637. case 'FitBV':
  10638. x = destArray[2];
  10639. width = pageWidth;
  10640. height = pageHeight;
  10641. scale = 'page-height';
  10642. break;
  10643. case 'FitR':
  10644. x = destArray[2];
  10645. y = destArray[3];
  10646. width = destArray[4] - x;
  10647. height = destArray[5] - y;
  10648. var hPadding = this.removePageBorders ? 0 : _ui_utils
  10649. .SCROLLBAR_PADDING;
  10650. var vPadding = this.removePageBorders ? 0 : _ui_utils
  10651. .VERTICAL_PADDING;
  10652. widthScale = (this.container.clientWidth - hPadding) / width /
  10653. _ui_utils.CSS_UNITS;
  10654. heightScale = (this.container.clientHeight - vPadding) /
  10655. height / _ui_utils.CSS_UNITS;
  10656. scale = Math.min(Math.abs(widthScale), Math.abs(heightScale));
  10657. break;
  10658. default:
  10659. console.error("".concat(this._name, ".scrollPageIntoView: ") +
  10660. "\"".concat(destArray[1].name,
  10661. "\" is not a valid destination type."));
  10662. return;
  10663. }
  10664. if (scale && scale !== this._currentScale) {
  10665. this.currentScaleValue = scale;
  10666. } else if (this._currentScale === _ui_utils.UNKNOWN_SCALE) {
  10667. this.currentScaleValue = _ui_utils.DEFAULT_SCALE_VALUE;
  10668. }
  10669. if (scale === 'page-fit' && !destArray[4]) {
  10670. this._scrollIntoView({
  10671. pageDiv: pageView.div,
  10672. pageNumber: pageNumber
  10673. });
  10674. return;
  10675. }
  10676. var boundingRect = [pageView.viewport.convertToViewportPoint(x, y),
  10677. pageView.viewport.convertToViewportPoint(x + width, y + height)
  10678. ];
  10679. var left = Math.min(boundingRect[0][0], boundingRect[1][0]);
  10680. var top = Math.min(boundingRect[0][1], boundingRect[1][1]);
  10681. if (!allowNegativeOffset) {
  10682. left = Math.max(left, 0);
  10683. top = Math.max(top, 0);
  10684. }
  10685. this._scrollIntoView({
  10686. pageDiv: pageView.div,
  10687. pageSpot: {
  10688. left: left,
  10689. top: top
  10690. },
  10691. pageNumber: pageNumber
  10692. });
  10693. }
  10694. }, {
  10695. key: "_updateLocation",
  10696. value: function _updateLocation(firstPage) {
  10697. var currentScale = this._currentScale;
  10698. var currentScaleValue = this._currentScaleValue;
  10699. var normalizedScaleValue = parseFloat(currentScaleValue) ===
  10700. currentScale ? Math.round(currentScale * 10000) / 100 :
  10701. currentScaleValue;
  10702. var pageNumber = firstPage.id;
  10703. var pdfOpenParams = '#page=' + pageNumber;
  10704. pdfOpenParams += '&zoom=' + normalizedScaleValue;
  10705. var currentPageView = this._pages[pageNumber - 1];
  10706. var container = this.container;
  10707. var topLeft = currentPageView.getPagePoint(container.scrollLeft -
  10708. firstPage.x, container.scrollTop - firstPage.y);
  10709. var intLeft = Math.round(topLeft[0]);
  10710. var intTop = Math.round(topLeft[1]);
  10711. pdfOpenParams += ',' + intLeft + ',' + intTop;
  10712. this._location = {
  10713. pageNumber: pageNumber,
  10714. scale: normalizedScaleValue,
  10715. top: intTop,
  10716. left: intLeft,
  10717. rotation: this._pagesRotation,
  10718. pdfOpenParams: pdfOpenParams
  10719. };
  10720. }
  10721. }, {
  10722. key: "_updateHelper",
  10723. value: function _updateHelper(visiblePages) {
  10724. throw new Error('Not implemented: _updateHelper');
  10725. }
  10726. }, {
  10727. key: "update",
  10728. value: function update() {
  10729. var visible = this._getVisiblePages();
  10730. var visiblePages = visible.views,
  10731. numVisiblePages = visiblePages.length;
  10732. if (numVisiblePages === 0) {
  10733. return;
  10734. }
  10735. var newCacheSize = Math.max(DEFAULT_CACHE_SIZE, 2 * numVisiblePages +
  10736. 1);
  10737. this._buffer.resize(newCacheSize, visiblePages);
  10738. this.renderingQueue.renderHighestPriority(visible);
  10739. this._updateHelper(visiblePages);
  10740. this._updateLocation(visible.first);
  10741. this.eventBus.dispatch('updateviewarea', {
  10742. source: this,
  10743. location: this._location
  10744. });
  10745. }
  10746. }, {
  10747. key: "containsElement",
  10748. value: function containsElement(element) {
  10749. return this.container.contains(element);
  10750. }
  10751. }, {
  10752. key: "focus",
  10753. value: function focus() {
  10754. this.container.focus();
  10755. }
  10756. }, {
  10757. key: "_getCurrentVisiblePage",
  10758. value: function _getCurrentVisiblePage() {
  10759. if (!this.pagesCount) {
  10760. return {
  10761. views: []
  10762. };
  10763. }
  10764. var pageView = this._pages[this._currentPageNumber - 1];
  10765. var element = pageView.div;
  10766. var view = {
  10767. id: pageView.id,
  10768. x: element.offsetLeft + element.clientLeft,
  10769. y: element.offsetTop + element.clientTop,
  10770. view: pageView
  10771. };
  10772. return {
  10773. first: view,
  10774. last: view,
  10775. views: [view]
  10776. };
  10777. }
  10778. }, {
  10779. key: "_getVisiblePages",
  10780. value: function _getVisiblePages() {
  10781. return (0, _ui_utils.getVisibleElements)(this.container, this._pages,
  10782. true, this._isScrollModeHorizontal);
  10783. }
  10784. }, {
  10785. key: "isPageVisible",
  10786. value: function isPageVisible(pageNumber) {
  10787. if (!this.pdfDocument) {
  10788. return false;
  10789. }
  10790. if (this.pageNumber < 1 || pageNumber > this.pagesCount) {
  10791. console.error("".concat(this._name, ".isPageVisible: \"").concat(
  10792. pageNumber, "\" is out of bounds."));
  10793. return false;
  10794. }
  10795. return this._getVisiblePages().views.some(function(view) {
  10796. return view.id === pageNumber;
  10797. });
  10798. }
  10799. }, {
  10800. key: "cleanup",
  10801. value: function cleanup() {
  10802. for (var i = 0, ii = this._pages.length; i < ii; i++) {
  10803. if (this._pages[i] && this._pages[i].renderingState !==
  10804. _pdf_rendering_queue.RenderingStates.FINISHED) {
  10805. this._pages[i].reset();
  10806. }
  10807. }
  10808. }
  10809. }, {
  10810. key: "_cancelRendering",
  10811. value: function _cancelRendering() {
  10812. for (var i = 0, ii = this._pages.length; i < ii; i++) {
  10813. if (this._pages[i]) {
  10814. this._pages[i].cancelRendering();
  10815. }
  10816. }
  10817. }
  10818. }, {
  10819. key: "_ensurePdfPageLoaded",
  10820. value: function _ensurePdfPageLoaded(pageView) {
  10821. var _this3 = this;
  10822. if (pageView.pdfPage) {
  10823. return Promise.resolve(pageView.pdfPage);
  10824. }
  10825. var pageNumber = pageView.id;
  10826. if (this._pagesRequests[pageNumber]) {
  10827. return this._pagesRequests[pageNumber];
  10828. }
  10829. var promise = this.pdfDocument.getPage(pageNumber).then(function(
  10830. pdfPage) {
  10831. if (!pageView.pdfPage) {
  10832. pageView.setPdfPage(pdfPage);
  10833. }
  10834. _this3._pagesRequests[pageNumber] = null;
  10835. return pdfPage;
  10836. })["catch"](function(reason) {
  10837. console.error('Unable to get page for page view', reason);
  10838. _this3._pagesRequests[pageNumber] = null;
  10839. });
  10840. this._pagesRequests[pageNumber] = promise;
  10841. return promise;
  10842. }
  10843. }, {
  10844. key: "forceRendering",
  10845. value: function forceRendering(currentlyVisiblePages) {
  10846. var _this4 = this;
  10847. var visiblePages = currentlyVisiblePages || this._getVisiblePages();
  10848. var scrollAhead = this._isScrollModeHorizontal ? this.scroll.right :
  10849. this.scroll.down;
  10850. var pageView = this.renderingQueue.getHighestPriority(visiblePages, this
  10851. ._pages, scrollAhead);
  10852. if (pageView) {
  10853. this._ensurePdfPageLoaded(pageView).then(function() {
  10854. _this4.renderingQueue.renderView(pageView);
  10855. });
  10856. return true;
  10857. }
  10858. return false;
  10859. }
  10860. }, {
  10861. key: "createTextLayerBuilder",
  10862. value: function createTextLayerBuilder(textLayerDiv, pageIndex, viewport) {
  10863. var enhanceTextSelection = arguments.length > 3 && arguments[3] !==
  10864. undefined ? arguments[3] : false;
  10865. return new _text_layer_builder.TextLayerBuilder({
  10866. textLayerDiv: textLayerDiv,
  10867. eventBus: this.eventBus,
  10868. pageIndex: pageIndex,
  10869. viewport: viewport,
  10870. findController: this.isInPresentationMode ? null : this
  10871. .findController,
  10872. enhanceTextSelection: this.isInPresentationMode ? false :
  10873. enhanceTextSelection
  10874. });
  10875. }
  10876. }, {
  10877. key: "createAnnotationLayerBuilder",
  10878. value: function createAnnotationLayerBuilder(pageDiv, pdfPage) {
  10879. var imageResourcesPath = arguments.length > 2 && arguments[2] !==
  10880. undefined ? arguments[2] : '';
  10881. var renderInteractiveForms = arguments.length > 3 && arguments[3] !==
  10882. undefined ? arguments[3] : false;
  10883. var l10n = arguments.length > 4 && arguments[4] !== undefined ?
  10884. arguments[4] : _ui_utils.NullL10n;
  10885. return new _annotation_layer_builder.AnnotationLayerBuilder({
  10886. pageDiv: pageDiv,
  10887. pdfPage: pdfPage,
  10888. imageResourcesPath: imageResourcesPath,
  10889. renderInteractiveForms: renderInteractiveForms,
  10890. linkService: this.linkService,
  10891. downloadManager: this.downloadManager,
  10892. l10n: l10n
  10893. });
  10894. }
  10895. }, {
  10896. key: "getPagesOverview",
  10897. value: function getPagesOverview() {
  10898. var pagesOverview = this._pages.map(function(pageView) {
  10899. var viewport = pageView.pdfPage.getViewport({
  10900. scale: 1
  10901. });
  10902. return {
  10903. width: viewport.width,
  10904. height: viewport.height,
  10905. rotation: viewport.rotation
  10906. };
  10907. });
  10908. if (!this.enablePrintAutoRotate) {
  10909. return pagesOverview;
  10910. }
  10911. var isFirstPagePortrait = (0, _ui_utils.isPortraitOrientation)(
  10912. pagesOverview[0]);
  10913. return pagesOverview.map(function(size) {
  10914. if (isFirstPagePortrait === (0, _ui_utils
  10915. .isPortraitOrientation)(size)) {
  10916. return size;
  10917. }
  10918. return {
  10919. width: size.height,
  10920. height: size.width,
  10921. rotation: (size.rotation + 90) % 360
  10922. };
  10923. });
  10924. }
  10925. }, {
  10926. key: "_updateScrollMode",
  10927. value: function _updateScrollMode() {
  10928. var pageNumber = arguments.length > 0 && arguments[0] !== undefined ?
  10929. arguments[0] : null;
  10930. var scrollMode = this._scrollMode,
  10931. viewer = this.viewer;
  10932. viewer.classList.toggle('scrollHorizontal', scrollMode === _ui_utils
  10933. .ScrollMode.HORIZONTAL);
  10934. viewer.classList.toggle('scrollWrapped', scrollMode === _ui_utils
  10935. .ScrollMode.WRAPPED);
  10936. if (!this.pdfDocument || !pageNumber) {
  10937. return;
  10938. }
  10939. if (this._currentScaleValue && isNaN(this._currentScaleValue)) {
  10940. this._setScale(this._currentScaleValue, true);
  10941. }
  10942. this._setCurrentPageNumber(pageNumber, true);
  10943. this.update();
  10944. }
  10945. }, {
  10946. key: "_updateSpreadMode",
  10947. value: function _updateSpreadMode() {
  10948. var pageNumber = arguments.length > 0 && arguments[0] !== undefined ?
  10949. arguments[0] : null;
  10950. if (!this.pdfDocument) {
  10951. return;
  10952. }
  10953. var viewer = this.viewer,
  10954. pages = this._pages;
  10955. viewer.textContent = '';
  10956. if (this._spreadMode === _ui_utils.SpreadMode.NONE) {
  10957. for (var i = 0, iMax = pages.length; i < iMax; ++i) {
  10958. viewer.appendChild(pages[i].div);
  10959. }
  10960. } else {
  10961. var parity = this._spreadMode - 1;
  10962. var spread = null;
  10963. for (var _i = 0, _iMax = pages.length; _i < _iMax; ++_i) {
  10964. if (spread === null) {
  10965. spread = document.createElement('div');
  10966. spread.className = 'spread';
  10967. viewer.appendChild(spread);
  10968. } else if (_i % 2 === parity) {
  10969. spread = spread.cloneNode(false);
  10970. viewer.appendChild(spread);
  10971. }
  10972. spread.appendChild(pages[_i].div);
  10973. }
  10974. }
  10975. if (!pageNumber) {
  10976. return;
  10977. }
  10978. this._setCurrentPageNumber(pageNumber, true);
  10979. this.update();
  10980. }
  10981. }, {
  10982. key: "pagesCount",
  10983. get: function get() {
  10984. return this._pages.length;
  10985. }
  10986. }, {
  10987. key: "pageViewsReady",
  10988. get: function get() {
  10989. return this._pageViewsReady;
  10990. }
  10991. }, {
  10992. key: "currentPageNumber",
  10993. get: function get() {
  10994. return this._currentPageNumber;
  10995. },
  10996. set: function set(val) {
  10997. if (!Number.isInteger(val)) {
  10998. throw new Error('Invalid page number.');
  10999. }
  11000. if (!this.pdfDocument) {
  11001. return;
  11002. }
  11003. if (!this._setCurrentPageNumber(val, true)) {
  11004. console.error("".concat(this._name, ".currentPageNumber: \"")
  11005. .concat(val, "\" is not a valid page."));
  11006. }
  11007. }
  11008. }, {
  11009. key: "currentPageLabel",
  11010. get: function get() {
  11011. return this._pageLabels && this._pageLabels[this._currentPageNumber -
  11012. 1];
  11013. },
  11014. set: function set(val) {
  11015. if (!this.pdfDocument) {
  11016. return;
  11017. }
  11018. var page = val | 0;
  11019. if (this._pageLabels) {
  11020. var i = this._pageLabels.indexOf(val);
  11021. if (i >= 0) {
  11022. page = i + 1;
  11023. }
  11024. }
  11025. if (!this._setCurrentPageNumber(page, true)) {
  11026. console.error("".concat(this._name, ".currentPageLabel: \"").concat(
  11027. val, "\" is not a valid page."));
  11028. }
  11029. }
  11030. }, {
  11031. key: "currentScale",
  11032. get: function get() {
  11033. return this._currentScale !== _ui_utils.UNKNOWN_SCALE ? this
  11034. ._currentScale : _ui_utils.DEFAULT_SCALE;
  11035. },
  11036. set: function set(val) {
  11037. if (isNaN(val)) {
  11038. throw new Error('Invalid numeric scale.');
  11039. }
  11040. if (!this.pdfDocument) {
  11041. return;
  11042. }
  11043. this._setScale(val, false);
  11044. }
  11045. }, {
  11046. key: "currentScaleValue",
  11047. get: function get() {
  11048. return this._currentScaleValue;
  11049. },
  11050. set: function set(val) {
  11051. if (!this.pdfDocument) {
  11052. return;
  11053. }
  11054. this._setScale(val, false);
  11055. }
  11056. }, {
  11057. key: "pagesRotation",
  11058. get: function get() {
  11059. return this._pagesRotation;
  11060. },
  11061. set: function set(rotation) {
  11062. if (!(0, _ui_utils.isValidRotation)(rotation)) {
  11063. throw new Error('Invalid pages rotation angle.');
  11064. }
  11065. if (!this.pdfDocument) {
  11066. return;
  11067. }
  11068. if (this._pagesRotation === rotation) {
  11069. return;
  11070. }
  11071. this._pagesRotation = rotation;
  11072. var pageNumber = this._currentPageNumber;
  11073. for (var i = 0, ii = this._pages.length; i < ii; i++) {
  11074. var pageView = this._pages[i];
  11075. pageView.update(pageView.scale, rotation);
  11076. }
  11077. if (this._currentScaleValue) {
  11078. this._setScale(this._currentScaleValue, true);
  11079. }
  11080. this.eventBus.dispatch('rotationchanging', {
  11081. source: this,
  11082. pagesRotation: rotation,
  11083. pageNumber: pageNumber
  11084. });
  11085. if (this.defaultRenderingQueue) {
  11086. this.update();
  11087. }
  11088. }
  11089. }, {
  11090. key: "_setDocumentViewerElement",
  11091. get: function get() {
  11092. throw new Error('Not implemented: _setDocumentViewerElement');
  11093. }
  11094. }, {
  11095. key: "_isScrollModeHorizontal",
  11096. get: function get() {
  11097. return this.isInPresentationMode ? false : this._scrollMode ===
  11098. _ui_utils.ScrollMode.HORIZONTAL;
  11099. }
  11100. }, {
  11101. key: "isInPresentationMode",
  11102. get: function get() {
  11103. return this.presentationModeState === _ui_utils.PresentationModeState
  11104. .FULLSCREEN;
  11105. }
  11106. }, {
  11107. key: "isChangingPresentationMode",
  11108. get: function get() {
  11109. return this.presentationModeState === _ui_utils.PresentationModeState
  11110. .CHANGING;
  11111. }
  11112. }, {
  11113. key: "isHorizontalScrollbarEnabled",
  11114. get: function get() {
  11115. return this.isInPresentationMode ? false : this.container.scrollWidth >
  11116. this.container.clientWidth;
  11117. }
  11118. }, {
  11119. key: "isVerticalScrollbarEnabled",
  11120. get: function get() {
  11121. return this.isInPresentationMode ? false : this.container.scrollHeight >
  11122. this.container.clientHeight;
  11123. }
  11124. }, {
  11125. key: "hasEqualPageSizes",
  11126. get: function get() {
  11127. var firstPageView = this._pages[0];
  11128. for (var i = 1, ii = this._pages.length; i < ii; ++i) {
  11129. var pageView = this._pages[i];
  11130. if (pageView.width !== firstPageView.width || pageView.height !==
  11131. firstPageView.height) {
  11132. return false;
  11133. }
  11134. }
  11135. return true;
  11136. }
  11137. }, {
  11138. key: "scrollMode",
  11139. get: function get() {
  11140. return this._scrollMode;
  11141. },
  11142. set: function set(mode) {
  11143. if (this._scrollMode === mode) {
  11144. return;
  11145. }
  11146. if (!(0, _ui_utils.isValidScrollMode)(mode)) {
  11147. throw new Error("Invalid scroll mode: ".concat(mode));
  11148. }
  11149. this._scrollMode = mode;
  11150. this.eventBus.dispatch('scrollmodechanged', {
  11151. source: this,
  11152. mode: mode
  11153. });
  11154. this._updateScrollMode(this._currentPageNumber);
  11155. }
  11156. }, {
  11157. key: "spreadMode",
  11158. get: function get() {
  11159. return this._spreadMode;
  11160. },
  11161. set: function set(mode) {
  11162. if (this._spreadMode === mode) {
  11163. return;
  11164. }
  11165. if (!(0, _ui_utils.isValidSpreadMode)(mode)) {
  11166. throw new Error("Invalid spread mode: ".concat(mode));
  11167. }
  11168. this._spreadMode = mode;
  11169. this.eventBus.dispatch('spreadmodechanged', {
  11170. source: this,
  11171. mode: mode
  11172. });
  11173. this._updateSpreadMode(this._currentPageNumber);
  11174. }
  11175. }]);
  11176. return BaseViewer;
  11177. }();
  11178. exports.BaseViewer = BaseViewer;
  11179. /***/
  11180. }),
  11181. /* 29 */
  11182. /***/
  11183. (function(module, exports, __webpack_require__) {
  11184. "use strict";
  11185. Object.defineProperty(exports, "__esModule", {
  11186. value: true
  11187. });
  11188. exports.DefaultAnnotationLayerFactory = exports.AnnotationLayerBuilder = void 0;
  11189. var _pdfjsLib = __webpack_require__(7);
  11190. var _ui_utils = __webpack_require__(5);
  11191. var _pdf_link_service = __webpack_require__(21);
  11192. function _classCallCheck(instance, Constructor) {
  11193. if (!(instance instanceof Constructor)) {
  11194. throw new TypeError("Cannot call a class as a function");
  11195. }
  11196. }
  11197. function _defineProperties(target, props) {
  11198. for (var i = 0; i < props.length; i++) {
  11199. var descriptor = props[i];
  11200. descriptor.enumerable = descriptor.enumerable || false;
  11201. descriptor.configurable = true;
  11202. if ("value" in descriptor) descriptor.writable = true;
  11203. Object.defineProperty(target, descriptor.key, descriptor);
  11204. }
  11205. }
  11206. function _createClass(Constructor, protoProps, staticProps) {
  11207. if (protoProps) _defineProperties(Constructor.prototype, protoProps);
  11208. if (staticProps) _defineProperties(Constructor, staticProps);
  11209. return Constructor;
  11210. }
  11211. var AnnotationLayerBuilder =
  11212. /*#__PURE__*/
  11213. function() {
  11214. function AnnotationLayerBuilder(_ref) {
  11215. var pageDiv = _ref.pageDiv,
  11216. pdfPage = _ref.pdfPage,
  11217. linkService = _ref.linkService,
  11218. downloadManager = _ref.downloadManager,
  11219. _ref$imageResourcesPa = _ref.imageResourcesPath,
  11220. imageResourcesPath = _ref$imageResourcesPa === void 0 ? '' : _ref$imageResourcesPa,
  11221. _ref$renderInteractiv = _ref.renderInteractiveForms,
  11222. renderInteractiveForms = _ref$renderInteractiv === void 0 ? false :
  11223. _ref$renderInteractiv,
  11224. _ref$l10n = _ref.l10n,
  11225. l10n = _ref$l10n === void 0 ? _ui_utils.NullL10n : _ref$l10n;
  11226. _classCallCheck(this, AnnotationLayerBuilder);
  11227. this.pageDiv = pageDiv;
  11228. this.pdfPage = pdfPage;
  11229. this.linkService = linkService;
  11230. this.downloadManager = downloadManager;
  11231. this.imageResourcesPath = imageResourcesPath;
  11232. this.renderInteractiveForms = renderInteractiveForms;
  11233. this.l10n = l10n;
  11234. this.div = null;
  11235. this._cancelled = false;
  11236. }
  11237. _createClass(AnnotationLayerBuilder, [{
  11238. key: "render",
  11239. value: function render(viewport) {
  11240. var _this = this;
  11241. var intent = arguments.length > 1 && arguments[1] !== undefined ?
  11242. arguments[1] : 'display';
  11243. this.pdfPage.getAnnotations({
  11244. intent: intent
  11245. }).then(function(annotations) {
  11246. if (_this._cancelled) {
  11247. return;
  11248. }
  11249. var parameters = {
  11250. viewport: viewport.clone({
  11251. dontFlip: true
  11252. }),
  11253. div: _this.div,
  11254. annotations: annotations,
  11255. page: _this.pdfPage,
  11256. imageResourcesPath: _this.imageResourcesPath,
  11257. renderInteractiveForms: _this
  11258. .renderInteractiveForms,
  11259. linkService: _this.linkService,
  11260. downloadManager: _this.downloadManager
  11261. };
  11262. if (_this.div) {
  11263. _pdfjsLib.AnnotationLayer.update(parameters);
  11264. } else {
  11265. if (annotations.length === 0) {
  11266. return;
  11267. }
  11268. _this.div = document.createElement('div');
  11269. _this.div.className = 'annotationLayer';
  11270. _this.pageDiv.appendChild(_this.div);
  11271. parameters.div = _this.div;
  11272. _pdfjsLib.AnnotationLayer.render(parameters);
  11273. _this.l10n.translate(_this.div);
  11274. }
  11275. });
  11276. }
  11277. }, {
  11278. key: "cancel",
  11279. value: function cancel() {
  11280. this._cancelled = true;
  11281. }
  11282. }, {
  11283. key: "hide",
  11284. value: function hide() {
  11285. if (!this.div) {
  11286. return;
  11287. }
  11288. this.div.setAttribute('hidden', 'true');
  11289. }
  11290. }]);
  11291. return AnnotationLayerBuilder;
  11292. }();
  11293. exports.AnnotationLayerBuilder = AnnotationLayerBuilder;
  11294. var DefaultAnnotationLayerFactory =
  11295. /*#__PURE__*/
  11296. function() {
  11297. function DefaultAnnotationLayerFactory() {
  11298. _classCallCheck(this, DefaultAnnotationLayerFactory);
  11299. }
  11300. _createClass(DefaultAnnotationLayerFactory, [{
  11301. key: "createAnnotationLayerBuilder",
  11302. value: function createAnnotationLayerBuilder(pageDiv, pdfPage) {
  11303. var imageResourcesPath = arguments.length > 2 && arguments[2] !==
  11304. undefined ? arguments[2] : '';
  11305. var renderInteractiveForms = arguments.length > 3 && arguments[3] !==
  11306. undefined ? arguments[3] : false;
  11307. var l10n = arguments.length > 4 && arguments[4] !== undefined ?
  11308. arguments[4] : _ui_utils.NullL10n;
  11309. return new AnnotationLayerBuilder({
  11310. pageDiv: pageDiv,
  11311. pdfPage: pdfPage,
  11312. imageResourcesPath: imageResourcesPath,
  11313. renderInteractiveForms: renderInteractiveForms,
  11314. linkService: new _pdf_link_service.SimpleLinkService(),
  11315. l10n: l10n
  11316. });
  11317. }
  11318. }]);
  11319. return DefaultAnnotationLayerFactory;
  11320. }();
  11321. exports.DefaultAnnotationLayerFactory = DefaultAnnotationLayerFactory;
  11322. /***/
  11323. }),
  11324. /* 30 */
  11325. /***/
  11326. (function(module, exports, __webpack_require__) {
  11327. "use strict";
  11328. Object.defineProperty(exports, "__esModule", {
  11329. value: true
  11330. });
  11331. exports.PDFPageView = void 0;
  11332. var _regenerator = _interopRequireDefault(__webpack_require__(2));
  11333. var _ui_utils = __webpack_require__(5);
  11334. var _pdfjsLib = __webpack_require__(7);
  11335. var _pdf_rendering_queue = __webpack_require__(11);
  11336. var _viewer_compatibility = __webpack_require__(8);
  11337. function _interopRequireDefault(obj) {
  11338. return obj && obj.__esModule ? obj : {
  11339. "default": obj
  11340. };
  11341. }
  11342. function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
  11343. try {
  11344. var info = gen[key](arg);
  11345. var value = info.value;
  11346. } catch (error) {
  11347. reject(error);
  11348. return;
  11349. }
  11350. if (info.done) {
  11351. resolve(value);
  11352. } else {
  11353. Promise.resolve(value).then(_next, _throw);
  11354. }
  11355. }
  11356. function _asyncToGenerator(fn) {
  11357. return function() {
  11358. var self = this,
  11359. args = arguments;
  11360. return new Promise(function(resolve, reject) {
  11361. var gen = fn.apply(self, args);
  11362. function _next(value) {
  11363. asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
  11364. }
  11365. function _throw(err) {
  11366. asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
  11367. }
  11368. _next(undefined);
  11369. });
  11370. };
  11371. }
  11372. function _classCallCheck(instance, Constructor) {
  11373. if (!(instance instanceof Constructor)) {
  11374. throw new TypeError("Cannot call a class as a function");
  11375. }
  11376. }
  11377. function _defineProperties(target, props) {
  11378. for (var i = 0; i < props.length; i++) {
  11379. var descriptor = props[i];
  11380. descriptor.enumerable = descriptor.enumerable || false;
  11381. descriptor.configurable = true;
  11382. if ("value" in descriptor) descriptor.writable = true;
  11383. Object.defineProperty(target, descriptor.key, descriptor);
  11384. }
  11385. }
  11386. function _createClass(Constructor, protoProps, staticProps) {
  11387. if (protoProps) _defineProperties(Constructor.prototype, protoProps);
  11388. if (staticProps) _defineProperties(Constructor, staticProps);
  11389. return Constructor;
  11390. }
  11391. var MAX_CANVAS_PIXELS = _viewer_compatibility.viewerCompatibilityParams.maxCanvasPixels || 16777216;
  11392. var PDFPageView =
  11393. /*#__PURE__*/
  11394. function() {
  11395. function PDFPageView(options) {
  11396. _classCallCheck(this, PDFPageView);
  11397. var container = options.container;
  11398. var defaultViewport = options.defaultViewport;
  11399. this.id = options.id;
  11400. this.renderingId = 'page' + this.id;
  11401. this.pdfPage = null;
  11402. this.pageLabel = null;
  11403. this.rotation = 0;
  11404. this.scale = options.scale || _ui_utils.DEFAULT_SCALE;
  11405. this.viewport = defaultViewport;
  11406. this.pdfPageRotate = defaultViewport.rotation;
  11407. this.hasRestrictedScaling = false;
  11408. this.textLayerMode = Number.isInteger(options.textLayerMode) ? options.textLayerMode :
  11409. _ui_utils.TextLayerMode.ENABLE;
  11410. this.imageResourcesPath = options.imageResourcesPath || '';
  11411. this.renderInteractiveForms = options.renderInteractiveForms || false;
  11412. this.useOnlyCssZoom = options.useOnlyCssZoom || false;
  11413. this.maxCanvasPixels = options.maxCanvasPixels || MAX_CANVAS_PIXELS;
  11414. this.eventBus = options.eventBus || (0, _ui_utils.getGlobalEventBus)();
  11415. this.renderingQueue = options.renderingQueue;
  11416. this.textLayerFactory = options.textLayerFactory;
  11417. this.annotationLayerFactory = options.annotationLayerFactory;
  11418. this.renderer = options.renderer || _ui_utils.RendererType.CANVAS;
  11419. this.enableWebGL = options.enableWebGL || false;
  11420. this.l10n = options.l10n || _ui_utils.NullL10n;
  11421. this.paintTask = null;
  11422. this.paintedViewportMap = new WeakMap();
  11423. this.renderingState = _pdf_rendering_queue.RenderingStates.INITIAL;
  11424. this.resume = null;
  11425. this.error = null;
  11426. this.annotationLayer = null;
  11427. this.textLayer = null;
  11428. this.zoomLayer = null;
  11429. var div = document.createElement('div');
  11430. div.className = 'page';
  11431. div.style.width = Math.floor(this.viewport.width) + 'px';
  11432. div.style.height = Math.floor(this.viewport.height) + 'px';
  11433. div.setAttribute('data-page-number', this.id);
  11434. this.div = div;
  11435. container.appendChild(div);
  11436. }
  11437. _createClass(PDFPageView, [{
  11438. key: "setPdfPage",
  11439. value: function setPdfPage(pdfPage) {
  11440. this.pdfPage = pdfPage;
  11441. this.pdfPageRotate = pdfPage.rotate;
  11442. var totalRotation = (this.rotation + this.pdfPageRotate) % 360;
  11443. this.viewport = pdfPage.getViewport({
  11444. scale: this.scale * _ui_utils.CSS_UNITS,
  11445. rotation: totalRotation
  11446. });
  11447. this.stats = pdfPage.stats;
  11448. this.reset();
  11449. }
  11450. }, {
  11451. key: "destroy",
  11452. value: function destroy() {
  11453. this.reset();
  11454. if (this.pdfPage) {
  11455. this.pdfPage.cleanup();
  11456. }
  11457. }
  11458. }, {
  11459. key: "_resetZoomLayer",
  11460. value: function _resetZoomLayer() {
  11461. var removeFromDOM = arguments.length > 0 && arguments[0] !== undefined ?
  11462. arguments[0] : false;
  11463. if (!this.zoomLayer) {
  11464. return;
  11465. }
  11466. var zoomLayerCanvas = this.zoomLayer.firstChild;
  11467. this.paintedViewportMap["delete"](zoomLayerCanvas);
  11468. zoomLayerCanvas.width = 0;
  11469. zoomLayerCanvas.height = 0;
  11470. if (removeFromDOM) {
  11471. this.zoomLayer.remove();
  11472. }
  11473. this.zoomLayer = null;
  11474. }
  11475. }, {
  11476. key: "reset",
  11477. value: function reset() {
  11478. var keepZoomLayer = arguments.length > 0 && arguments[0] !== undefined ?
  11479. arguments[0] : false;
  11480. var keepAnnotations = arguments.length > 1 && arguments[1] !==
  11481. undefined ? arguments[1] : false;
  11482. this.cancelRendering(keepAnnotations);
  11483. this.renderingState = _pdf_rendering_queue.RenderingStates.INITIAL;
  11484. var div = this.div;
  11485. div.style.width = Math.floor(this.viewport.width) + 'px';
  11486. div.style.height = Math.floor(this.viewport.height) + 'px';
  11487. var childNodes = div.childNodes;
  11488. var currentZoomLayerNode = keepZoomLayer && this.zoomLayer || null;
  11489. var currentAnnotationNode = keepAnnotations && this.annotationLayer &&
  11490. this.annotationLayer.div || null;
  11491. for (var i = childNodes.length - 1; i >= 0; i--) {
  11492. var node = childNodes[i];
  11493. if (currentZoomLayerNode === node || currentAnnotationNode ===
  11494. node) {
  11495. continue;
  11496. }
  11497. div.removeChild(node);
  11498. }
  11499. div.removeAttribute('data-loaded');
  11500. if (currentAnnotationNode) {
  11501. this.annotationLayer.hide();
  11502. } else if (this.annotationLayer) {
  11503. this.annotationLayer.cancel();
  11504. this.annotationLayer = null;
  11505. }
  11506. if (!currentZoomLayerNode) {
  11507. if (this.canvas) {
  11508. this.paintedViewportMap["delete"](this.canvas);
  11509. this.canvas.width = 0;
  11510. this.canvas.height = 0;
  11511. delete this.canvas;
  11512. }
  11513. this._resetZoomLayer();
  11514. }
  11515. if (this.svg) {
  11516. this.paintedViewportMap["delete"](this.svg);
  11517. delete this.svg;
  11518. }
  11519. this.loadingIconDiv = document.createElement('div');
  11520. this.loadingIconDiv.className = 'loadingIcon';
  11521. div.appendChild(this.loadingIconDiv);
  11522. }
  11523. }, {
  11524. key: "update",
  11525. value: function update(scale, rotation) {
  11526. this.scale = scale || this.scale;
  11527. if (typeof rotation !== 'undefined') {
  11528. this.rotation = rotation;
  11529. }
  11530. var totalRotation = (this.rotation + this.pdfPageRotate) % 360;
  11531. this.viewport = this.viewport.clone({
  11532. scale: this.scale * _ui_utils.CSS_UNITS,
  11533. rotation: totalRotation
  11534. });
  11535. if (this.svg) {
  11536. this.cssTransform(this.svg, true);
  11537. this.eventBus.dispatch('pagerendered', {
  11538. source: this,
  11539. pageNumber: this.id,
  11540. cssTransform: true,
  11541. timestamp: performance.now()
  11542. });
  11543. return;
  11544. }
  11545. var isScalingRestricted = false;
  11546. if (this.canvas && this.maxCanvasPixels > 0) {
  11547. var outputScale = this.outputScale;
  11548. if ((Math.floor(this.viewport.width) * outputScale.sx | 0) * (Math
  11549. .floor(this.viewport.height) * outputScale.sy | 0) > this
  11550. .maxCanvasPixels) {
  11551. isScalingRestricted = true;
  11552. }
  11553. }
  11554. if (this.canvas) {
  11555. if (this.useOnlyCssZoom || this.hasRestrictedScaling &&
  11556. isScalingRestricted) {
  11557. this.cssTransform(this.canvas, true);
  11558. this.eventBus.dispatch('pagerendered', {
  11559. source: this,
  11560. pageNumber: this.id,
  11561. cssTransform: true,
  11562. timestamp: performance.now()
  11563. });
  11564. return;
  11565. }
  11566. if (!this.zoomLayer && !this.canvas.hasAttribute('hidden')) {
  11567. this.zoomLayer = this.canvas.parentNode;
  11568. this.zoomLayer.style.position = 'absolute';
  11569. }
  11570. }
  11571. if (this.zoomLayer) {
  11572. this.cssTransform(this.zoomLayer.firstChild);
  11573. }
  11574. this.reset(true, true);
  11575. }
  11576. }, {
  11577. key: "cancelRendering",
  11578. value: function cancelRendering() {
  11579. var keepAnnotations = arguments.length > 0 && arguments[0] !==
  11580. undefined ? arguments[0] : false;
  11581. if (this.paintTask) {
  11582. this.paintTask.cancel();
  11583. this.paintTask = null;
  11584. }
  11585. this.resume = null;
  11586. if (this.textLayer) {
  11587. this.textLayer.cancel();
  11588. this.textLayer = null;
  11589. }
  11590. if (!keepAnnotations && this.annotationLayer) {
  11591. this.annotationLayer.cancel();
  11592. this.annotationLayer = null;
  11593. }
  11594. }
  11595. }, {
  11596. key: "cssTransform",
  11597. value: function cssTransform(target) {
  11598. var redrawAnnotations = arguments.length > 1 && arguments[1] !==
  11599. undefined ? arguments[1] : false;
  11600. var width = this.viewport.width;
  11601. var height = this.viewport.height;
  11602. var div = this.div;
  11603. target.style.width = target.parentNode.style.width = div.style.width =
  11604. Math.floor(width) + 'px';
  11605. target.style.height = target.parentNode.style.height = div.style
  11606. .height = Math.floor(height) + 'px';
  11607. var relativeRotation = this.viewport.rotation - this.paintedViewportMap
  11608. .get(target).rotation;
  11609. var absRotation = Math.abs(relativeRotation);
  11610. var scaleX = 1,
  11611. scaleY = 1;
  11612. if (absRotation === 90 || absRotation === 270) {
  11613. scaleX = height / width;
  11614. scaleY = width / height;
  11615. }
  11616. var cssTransform = 'rotate(' + relativeRotation + 'deg) ' + 'scale(' +
  11617. scaleX + ',' + scaleY + ')';
  11618. target.style.transform = cssTransform;
  11619. if (this.textLayer) {
  11620. var textLayerViewport = this.textLayer.viewport;
  11621. var textRelativeRotation = this.viewport.rotation -
  11622. textLayerViewport.rotation;
  11623. var textAbsRotation = Math.abs(textRelativeRotation);
  11624. var scale = width / textLayerViewport.width;
  11625. if (textAbsRotation === 90 || textAbsRotation === 270) {
  11626. scale = width / textLayerViewport.height;
  11627. }
  11628. var textLayerDiv = this.textLayer.textLayerDiv;
  11629. var transX, transY;
  11630. switch (textAbsRotation) {
  11631. case 0:
  11632. transX = transY = 0;
  11633. break;
  11634. case 90:
  11635. transX = 0;
  11636. transY = '-' + textLayerDiv.style.height;
  11637. break;
  11638. case 180:
  11639. transX = '-' + textLayerDiv.style.width;
  11640. transY = '-' + textLayerDiv.style.height;
  11641. break;
  11642. case 270:
  11643. transX = '-' + textLayerDiv.style.width;
  11644. transY = 0;
  11645. break;
  11646. default:
  11647. console.error('Bad rotation value.');
  11648. break;
  11649. }
  11650. textLayerDiv.style.transform = 'rotate(' + textAbsRotation +
  11651. 'deg) ' + 'scale(' + scale + ', ' + scale + ') ' +
  11652. 'translate(' + transX + ', ' + transY + ')';
  11653. textLayerDiv.style.transformOrigin = '0% 0%';
  11654. }
  11655. if (redrawAnnotations && this.annotationLayer) {
  11656. this.annotationLayer.render(this.viewport, 'display');
  11657. }
  11658. }
  11659. }, {
  11660. key: "getPagePoint",
  11661. value: function getPagePoint(x, y) {
  11662. return this.viewport.convertToPdfPoint(x, y);
  11663. }
  11664. }, {
  11665. key: "draw",
  11666. value: function draw() {
  11667. var _this = this;
  11668. if (this.renderingState !== _pdf_rendering_queue.RenderingStates
  11669. .INITIAL) {
  11670. console.error('Must be in new state before drawing');
  11671. this.reset();
  11672. }
  11673. if (!this.pdfPage) {
  11674. this.renderingState = _pdf_rendering_queue.RenderingStates.FINISHED;
  11675. return Promise.reject(new Error('Page is not loaded'));
  11676. }
  11677. this.renderingState = _pdf_rendering_queue.RenderingStates.RUNNING;
  11678. var pdfPage = this.pdfPage;
  11679. var div = this.div;
  11680. var canvasWrapper = document.createElement('div');
  11681. canvasWrapper.style.width = div.style.width;
  11682. canvasWrapper.style.height = div.style.height;
  11683. canvasWrapper.classList.add('canvasWrapper');
  11684. if (this.annotationLayer && this.annotationLayer.div) {
  11685. div.insertBefore(canvasWrapper, this.annotationLayer.div);
  11686. } else {
  11687. div.appendChild(canvasWrapper);
  11688. }
  11689. var textLayer = null;
  11690. if (this.textLayerMode !== _ui_utils.TextLayerMode.DISABLE && this
  11691. .textLayerFactory) {
  11692. var textLayerDiv = document.createElement('div');
  11693. textLayerDiv.className = 'textLayer';
  11694. textLayerDiv.style.width = canvasWrapper.style.width;
  11695. textLayerDiv.style.height = canvasWrapper.style.height;
  11696. if (this.annotationLayer && this.annotationLayer.div) {
  11697. div.insertBefore(textLayerDiv, this.annotationLayer.div);
  11698. } else {
  11699. div.appendChild(textLayerDiv);
  11700. }
  11701. textLayer = this.textLayerFactory.createTextLayerBuilder(
  11702. textLayerDiv, this.id - 1, this.viewport, this
  11703. .textLayerMode === _ui_utils.TextLayerMode.ENABLE_ENHANCE);
  11704. }
  11705. this.textLayer = textLayer;
  11706. var renderContinueCallback = null;
  11707. if (this.renderingQueue) {
  11708. renderContinueCallback = function renderContinueCallback(cont) {
  11709. if (!_this.renderingQueue.isHighestPriority(_this)) {
  11710. _this.renderingState = _pdf_rendering_queue
  11711. .RenderingStates.PAUSED;
  11712. _this.resume = function() {
  11713. _this.renderingState = _pdf_rendering_queue
  11714. .RenderingStates.RUNNING;
  11715. cont();
  11716. };
  11717. return;
  11718. }
  11719. cont();
  11720. };
  11721. }
  11722. var finishPaintTask =
  11723. /*#__PURE__*/
  11724. function() {
  11725. var _ref = _asyncToGenerator(
  11726. /*#__PURE__*/
  11727. _regenerator["default"].mark(function _callee(error) {
  11728. return _regenerator["default"].wrap(
  11729. function _callee$(_context) {
  11730. while (1) {
  11731. switch (_context.prev = _context
  11732. .next) {
  11733. case 0:
  11734. if (paintTask === _this
  11735. .paintTask) {
  11736. _this.paintTask =
  11737. null;
  11738. }
  11739. if (!(error instanceof _pdfjsLib
  11740. .RenderingCancelledException
  11741. )) {
  11742. _context.next = 4;
  11743. break;
  11744. }
  11745. _this.error = null;
  11746. return _context.abrupt(
  11747. "return");
  11748. case 4:
  11749. _this.renderingState =
  11750. _pdf_rendering_queue
  11751. .RenderingStates
  11752. .FINISHED;
  11753. if (_this
  11754. .loadingIconDiv) {
  11755. div.removeChild(
  11756. _this
  11757. .loadingIconDiv
  11758. );
  11759. delete _this
  11760. .loadingIconDiv;
  11761. }
  11762. _this._resetZoomLayer(
  11763. true);
  11764. _this.error = error;
  11765. _this.stats = pdfPage
  11766. .stats;
  11767. _this.eventBus.dispatch(
  11768. 'pagerendered', {
  11769. source: _this,
  11770. pageNumber: _this
  11771. .id,
  11772. cssTransform: false,
  11773. timestamp: performance
  11774. .now()
  11775. });
  11776. if (!error) {
  11777. _context.next = 12;
  11778. break;
  11779. }
  11780. throw error;
  11781. case 12:
  11782. case "end":
  11783. return _context.stop();
  11784. }
  11785. }
  11786. }, _callee);
  11787. }));
  11788. return function finishPaintTask(_x) {
  11789. return _ref.apply(this, arguments);
  11790. };
  11791. }();
  11792. var paintTask = this.renderer === _ui_utils.RendererType.SVG ? this
  11793. .paintOnSvg(canvasWrapper) : this.paintOnCanvas(canvasWrapper);
  11794. paintTask.onRenderContinue = renderContinueCallback;
  11795. this.paintTask = paintTask;
  11796. var resultPromise = paintTask.promise.then(function() {
  11797. return finishPaintTask(null).then(function() {
  11798. if (textLayer) {
  11799. var readableStream = pdfPage
  11800. .streamTextContent({
  11801. normalizeWhitespace: true
  11802. });
  11803. textLayer.setTextContentStream(
  11804. readableStream);
  11805. textLayer.render();
  11806. }
  11807. });
  11808. }, function(reason) {
  11809. return finishPaintTask(reason);
  11810. });
  11811. if (this.annotationLayerFactory) {
  11812. if (!this.annotationLayer) {
  11813. this.annotationLayer = this.annotationLayerFactory
  11814. .createAnnotationLayerBuilder(div, pdfPage, this
  11815. .imageResourcesPath, this.renderInteractiveForms, this
  11816. .l10n);
  11817. }
  11818. this.annotationLayer.render(this.viewport, 'display');
  11819. }
  11820. div.setAttribute('data-loaded', true);
  11821. this.eventBus.dispatch('pagerender', {
  11822. source: this,
  11823. pageNumber: this.id
  11824. });
  11825. return resultPromise;
  11826. }
  11827. }, {
  11828. key: "paintOnCanvas",
  11829. value: function paintOnCanvas(canvasWrapper) {
  11830. var renderCapability = (0, _pdfjsLib.createPromiseCapability)();
  11831. var result = {
  11832. promise: renderCapability.promise,
  11833. onRenderContinue: function onRenderContinue(cont) {
  11834. cont();
  11835. },
  11836. cancel: function cancel() {
  11837. renderTask.cancel();
  11838. }
  11839. };
  11840. var viewport = this.viewport;
  11841. var canvas = document.createElement('canvas');
  11842. canvas.id = this.renderingId;
  11843. canvas.setAttribute('hidden', 'hidden');
  11844. var isCanvasHidden = true;
  11845. var showCanvas = function showCanvas() {
  11846. if (isCanvasHidden) {
  11847. canvas.removeAttribute('hidden');
  11848. isCanvasHidden = false;
  11849. }
  11850. };
  11851. canvasWrapper.appendChild(canvas);
  11852. this.canvas = canvas;
  11853. canvas.mozOpaque = true;
  11854. var ctx = canvas.getContext('2d', {
  11855. alpha: false
  11856. });
  11857. var outputScale = (0, _ui_utils.getOutputScale)(ctx);
  11858. this.outputScale = outputScale;
  11859. if (this.useOnlyCssZoom) {
  11860. var actualSizeViewport = viewport.clone({
  11861. scale: _ui_utils.CSS_UNITS
  11862. });
  11863. outputScale.sx *= actualSizeViewport.width / viewport.width;
  11864. outputScale.sy *= actualSizeViewport.height / viewport.height;
  11865. outputScale.scaled = true;
  11866. }
  11867. if (this.maxCanvasPixels > 0) {
  11868. var pixelsInViewport = viewport.width * viewport.height;
  11869. var maxScale = Math.sqrt(this.maxCanvasPixels / pixelsInViewport);
  11870. if (outputScale.sx > maxScale || outputScale.sy > maxScale) {
  11871. outputScale.sx = maxScale;
  11872. outputScale.sy = maxScale;
  11873. outputScale.scaled = true;
  11874. this.hasRestrictedScaling = true;
  11875. } else {
  11876. this.hasRestrictedScaling = false;
  11877. }
  11878. }
  11879. var sfx = (0, _ui_utils.approximateFraction)(outputScale.sx);
  11880. var sfy = (0, _ui_utils.approximateFraction)(outputScale.sy);
  11881. canvas.width = (0, _ui_utils.roundToDivide)(viewport.width * outputScale
  11882. .sx, sfx[0]);
  11883. canvas.height = (0, _ui_utils.roundToDivide)(viewport.height *
  11884. outputScale.sy, sfy[0]);
  11885. canvas.style.width = (0, _ui_utils.roundToDivide)(viewport.width, sfx[
  11886. 1]) + 'px';
  11887. canvas.style.height = (0, _ui_utils.roundToDivide)(viewport.height, sfy[
  11888. 1]) + 'px';
  11889. this.paintedViewportMap.set(canvas, viewport);
  11890. var transform = !outputScale.scaled ? null : [outputScale.sx, 0, 0,
  11891. outputScale.sy, 0, 0
  11892. ];
  11893. var renderContext = {
  11894. canvasContext: ctx,
  11895. transform: transform,
  11896. viewport: this.viewport,
  11897. enableWebGL: this.enableWebGL,
  11898. renderInteractiveForms: this.renderInteractiveForms
  11899. };
  11900. var renderTask = this.pdfPage.render(renderContext);
  11901. renderTask.onContinue = function(cont) {
  11902. showCanvas();
  11903. if (result.onRenderContinue) {
  11904. result.onRenderContinue(cont);
  11905. } else {
  11906. cont();
  11907. }
  11908. };
  11909. renderTask.promise.then(function() {
  11910. showCanvas();
  11911. renderCapability.resolve(undefined);
  11912. }, function(error) {
  11913. showCanvas();
  11914. renderCapability.reject(error);
  11915. });
  11916. return result;
  11917. }
  11918. }, {
  11919. key: "paintOnSvg",
  11920. value: function paintOnSvg(wrapper) {
  11921. var _this2 = this;
  11922. var cancelled = false;
  11923. var ensureNotCancelled = function ensureNotCancelled() {
  11924. if (cancelled) {
  11925. throw new _pdfjsLib.RenderingCancelledException(
  11926. 'Rendering cancelled, page ' + _this2.id, 'svg');
  11927. }
  11928. };
  11929. var pdfPage = this.pdfPage;
  11930. var actualSizeViewport = this.viewport.clone({
  11931. scale: _ui_utils.CSS_UNITS
  11932. });
  11933. var promise = pdfPage.getOperatorList().then(function(opList) {
  11934. ensureNotCancelled();
  11935. var svgGfx = new _pdfjsLib.SVGGraphics(pdfPage.commonObjs,
  11936. pdfPage.objs);
  11937. return svgGfx.getSVG(opList, actualSizeViewport).then(
  11938. function(svg) {
  11939. ensureNotCancelled();
  11940. _this2.svg = svg;
  11941. _this2.paintedViewportMap.set(svg,
  11942. actualSizeViewport);
  11943. svg.style.width = wrapper.style.width;
  11944. svg.style.height = wrapper.style.height;
  11945. _this2.renderingState = _pdf_rendering_queue
  11946. .RenderingStates.FINISHED;
  11947. wrapper.appendChild(svg);
  11948. });
  11949. });
  11950. return {
  11951. promise: promise,
  11952. onRenderContinue: function onRenderContinue(cont) {
  11953. cont();
  11954. },
  11955. cancel: function cancel() {
  11956. cancelled = true;
  11957. }
  11958. };
  11959. }
  11960. }, {
  11961. key: "setPageLabel",
  11962. value: function setPageLabel(label) {
  11963. this.pageLabel = typeof label === 'string' ? label : null;
  11964. if (this.pageLabel !== null) {
  11965. this.div.setAttribute('data-page-label', this.pageLabel);
  11966. } else {
  11967. this.div.removeAttribute('data-page-label');
  11968. }
  11969. }
  11970. }, {
  11971. key: "width",
  11972. get: function get() {
  11973. return this.viewport.width;
  11974. }
  11975. }, {
  11976. key: "height",
  11977. get: function get() {
  11978. return this.viewport.height;
  11979. }
  11980. }]);
  11981. return PDFPageView;
  11982. }();
  11983. exports.PDFPageView = PDFPageView;
  11984. /***/
  11985. }),
  11986. /* 31 */
  11987. /***/
  11988. (function(module, exports, __webpack_require__) {
  11989. "use strict";
  11990. Object.defineProperty(exports, "__esModule", {
  11991. value: true
  11992. });
  11993. exports.DefaultTextLayerFactory = exports.TextLayerBuilder = void 0;
  11994. var _ui_utils = __webpack_require__(5);
  11995. var _pdfjsLib = __webpack_require__(7);
  11996. function _classCallCheck(instance, Constructor) {
  11997. if (!(instance instanceof Constructor)) {
  11998. throw new TypeError("Cannot call a class as a function");
  11999. }
  12000. }
  12001. function _defineProperties(target, props) {
  12002. for (var i = 0; i < props.length; i++) {
  12003. var descriptor = props[i];
  12004. descriptor.enumerable = descriptor.enumerable || false;
  12005. descriptor.configurable = true;
  12006. if ("value" in descriptor) descriptor.writable = true;
  12007. Object.defineProperty(target, descriptor.key, descriptor);
  12008. }
  12009. }
  12010. function _createClass(Constructor, protoProps, staticProps) {
  12011. if (protoProps) _defineProperties(Constructor.prototype, protoProps);
  12012. if (staticProps) _defineProperties(Constructor, staticProps);
  12013. return Constructor;
  12014. }
  12015. var EXPAND_DIVS_TIMEOUT = 300;
  12016. var TextLayerBuilder =
  12017. /*#__PURE__*/
  12018. function() {
  12019. function TextLayerBuilder(_ref) {
  12020. var textLayerDiv = _ref.textLayerDiv,
  12021. eventBus = _ref.eventBus,
  12022. pageIndex = _ref.pageIndex,
  12023. viewport = _ref.viewport,
  12024. _ref$findController = _ref.findController,
  12025. findController = _ref$findController === void 0 ? null : _ref$findController,
  12026. _ref$enhanceTextSelec = _ref.enhanceTextSelection,
  12027. enhanceTextSelection = _ref$enhanceTextSelec === void 0 ? false : _ref$enhanceTextSelec;
  12028. _classCallCheck(this, TextLayerBuilder);
  12029. this.textLayerDiv = textLayerDiv;
  12030. this.eventBus = eventBus || (0, _ui_utils.getGlobalEventBus)();
  12031. this.textContent = null;
  12032. this.textContentItemsStr = [];
  12033. this.textContentStream = null;
  12034. this.renderingDone = false;
  12035. this.pageIdx = pageIndex;
  12036. this.pageNumber = this.pageIdx + 1;
  12037. this.matches = [];
  12038. this.viewport = viewport;
  12039. this.textDivs = [];
  12040. this.findController = findController;
  12041. this.textLayerRenderTask = null;
  12042. this.enhanceTextSelection = enhanceTextSelection;
  12043. this._onUpdateTextLayerMatches = null;
  12044. this._bindMouse();
  12045. }
  12046. _createClass(TextLayerBuilder, [{
  12047. key: "_finishRendering",
  12048. value: function _finishRendering() {
  12049. this.renderingDone = true;
  12050. if (!this.enhanceTextSelection) {
  12051. var endOfContent = document.createElement('div');
  12052. endOfContent.className = 'endOfContent';
  12053. this.textLayerDiv.appendChild(endOfContent);
  12054. }
  12055. this.eventBus.dispatch('textlayerrendered', {
  12056. source: this,
  12057. pageNumber: this.pageNumber,
  12058. numTextDivs: this.textDivs.length
  12059. });
  12060. }
  12061. }, {
  12062. key: "render",
  12063. value: function render() {
  12064. var _this = this;
  12065. var timeout = arguments.length > 0 && arguments[0] !== undefined ?
  12066. arguments[0] : 0;
  12067. if (!(this.textContent || this.textContentStream) || this
  12068. .renderingDone) {
  12069. return;
  12070. }
  12071. this.cancel();
  12072. this.textDivs = [];
  12073. var textLayerFrag = document.createDocumentFragment();
  12074. this.textLayerRenderTask = (0, _pdfjsLib.renderTextLayer)({
  12075. textContent: this.textContent,
  12076. textContentStream: this.textContentStream,
  12077. container: textLayerFrag,
  12078. viewport: this.viewport,
  12079. textDivs: this.textDivs,
  12080. textContentItemsStr: this.textContentItemsStr,
  12081. timeout: timeout,
  12082. enhanceTextSelection: this.enhanceTextSelection
  12083. });
  12084. this.textLayerRenderTask.promise.then(function() {
  12085. _this.textLayerDiv.appendChild(textLayerFrag);
  12086. _this._finishRendering();
  12087. _this._updateMatches();
  12088. }, function(reason) {});
  12089. if (!this._onUpdateTextLayerMatches) {
  12090. this._onUpdateTextLayerMatches = function(evt) {
  12091. if (evt.pageIndex === _this.pageIdx || evt.pageIndex === -
  12092. 1) {
  12093. _this._updateMatches();
  12094. }
  12095. };
  12096. this.eventBus.on('updatetextlayermatches', this
  12097. ._onUpdateTextLayerMatches);
  12098. }
  12099. }
  12100. }, {
  12101. key: "cancel",
  12102. value: function cancel() {
  12103. if (this.textLayerRenderTask) {
  12104. this.textLayerRenderTask.cancel();
  12105. this.textLayerRenderTask = null;
  12106. }
  12107. if (this._onUpdateTextLayerMatches) {
  12108. this.eventBus.off('updatetextlayermatches', this
  12109. ._onUpdateTextLayerMatches);
  12110. this._onUpdateTextLayerMatches = null;
  12111. }
  12112. }
  12113. }, {
  12114. key: "setTextContentStream",
  12115. value: function setTextContentStream(readableStream) {
  12116. this.cancel();
  12117. this.textContentStream = readableStream;
  12118. }
  12119. }, {
  12120. key: "setTextContent",
  12121. value: function setTextContent(textContent) {
  12122. this.cancel();
  12123. this.textContent = textContent;
  12124. }
  12125. }, {
  12126. key: "_convertMatches",
  12127. value: function _convertMatches(matches, matchesLength) {
  12128. if (!matches) {
  12129. return [];
  12130. }
  12131. var findController = this.findController,
  12132. textContentItemsStr = this.textContentItemsStr;
  12133. var i = 0,
  12134. iIndex = 0;
  12135. var end = textContentItemsStr.length - 1;
  12136. var queryLen = findController.state.query.length;
  12137. var result = [];
  12138. for (var m = 0, mm = matches.length; m < mm; m++) {
  12139. var matchIdx = matches[m];
  12140. while (i !== end && matchIdx >= iIndex + textContentItemsStr[i]
  12141. .length) {
  12142. iIndex += textContentItemsStr[i].length;
  12143. i++;
  12144. }
  12145. if (i === textContentItemsStr.length) {
  12146. console.error('Could not find a matching mapping');
  12147. }
  12148. var match = {
  12149. begin: {
  12150. divIdx: i,
  12151. offset: matchIdx - iIndex
  12152. }
  12153. };
  12154. if (matchesLength) {
  12155. matchIdx += matchesLength[m];
  12156. } else {
  12157. matchIdx += queryLen;
  12158. }
  12159. while (i !== end && matchIdx > iIndex + textContentItemsStr[i]
  12160. .length) {
  12161. iIndex += textContentItemsStr[i].length;
  12162. i++;
  12163. }
  12164. match.end = {
  12165. divIdx: i,
  12166. offset: matchIdx - iIndex
  12167. };
  12168. result.push(match);
  12169. }
  12170. return result;
  12171. }
  12172. }, {
  12173. key: "_renderMatches",
  12174. value: function _renderMatches(matches) {
  12175. if (matches.length === 0) {
  12176. return;
  12177. }
  12178. var findController = this.findController,
  12179. pageIdx = this.pageIdx,
  12180. textContentItemsStr = this.textContentItemsStr,
  12181. textDivs = this.textDivs;
  12182. var isSelectedPage = pageIdx === findController.selected.pageIdx;
  12183. var selectedMatchIdx = findController.selected.matchIdx;
  12184. var highlightAll = findController.state.highlightAll;
  12185. var prevEnd = null;
  12186. var infinity = {
  12187. divIdx: -1,
  12188. offset: undefined
  12189. };
  12190. function beginText(begin, className) {
  12191. var divIdx = begin.divIdx;
  12192. textDivs[divIdx].textContent = '';
  12193. appendTextToDiv(divIdx, 0, begin.offset, className);
  12194. }
  12195. function appendTextToDiv(divIdx, fromOffset, toOffset, className) {
  12196. var div = textDivs[divIdx];
  12197. var content = textContentItemsStr[divIdx].substring(fromOffset,
  12198. toOffset);
  12199. var node = document.createTextNode(content);
  12200. if (className) {
  12201. var span = document.createElement('span');
  12202. span.className = className;
  12203. span.appendChild(node);
  12204. div.appendChild(span);
  12205. return;
  12206. }
  12207. div.appendChild(node);
  12208. }
  12209. var i0 = selectedMatchIdx,
  12210. i1 = i0 + 1;
  12211. if (highlightAll) {
  12212. i0 = 0;
  12213. i1 = matches.length;
  12214. } else if (!isSelectedPage) {
  12215. return;
  12216. }
  12217. for (var i = i0; i < i1; i++) {
  12218. var match = matches[i];
  12219. var begin = match.begin;
  12220. var end = match.end;
  12221. var isSelected = isSelectedPage && i === selectedMatchIdx;
  12222. var highlightSuffix = isSelected ? ' selected' : '';
  12223. if (isSelected) {
  12224. findController.scrollMatchIntoView({
  12225. element: textDivs[begin.divIdx],
  12226. pageIndex: pageIdx,
  12227. matchIndex: selectedMatchIdx
  12228. });
  12229. }
  12230. if (!prevEnd || begin.divIdx !== prevEnd.divIdx) {
  12231. if (prevEnd !== null) {
  12232. appendTextToDiv(prevEnd.divIdx, prevEnd.offset, infinity
  12233. .offset);
  12234. }
  12235. beginText(begin);
  12236. } else {
  12237. appendTextToDiv(prevEnd.divIdx, prevEnd.offset, begin.offset);
  12238. }
  12239. if (begin.divIdx === end.divIdx) {
  12240. appendTextToDiv(begin.divIdx, begin.offset, end.offset,
  12241. 'highlight' + highlightSuffix);
  12242. } else {
  12243. appendTextToDiv(begin.divIdx, begin.offset, infinity.offset,
  12244. 'highlight begin' + highlightSuffix);
  12245. for (var n0 = begin.divIdx + 1, n1 = end.divIdx; n0 <
  12246. n1; n0++) {
  12247. textDivs[n0].className = 'highlight middle' +
  12248. highlightSuffix;
  12249. }
  12250. beginText(end, 'highlight end' + highlightSuffix);
  12251. }
  12252. prevEnd = end;
  12253. }
  12254. if (prevEnd) {
  12255. appendTextToDiv(prevEnd.divIdx, prevEnd.offset, infinity.offset);
  12256. }
  12257. }
  12258. }, {
  12259. key: "_updateMatches",
  12260. value: function _updateMatches() {
  12261. if (!this.renderingDone) {
  12262. return;
  12263. }
  12264. var findController = this.findController,
  12265. matches = this.matches,
  12266. pageIdx = this.pageIdx,
  12267. textContentItemsStr = this.textContentItemsStr,
  12268. textDivs = this.textDivs;
  12269. var clearedUntilDivIdx = -1;
  12270. for (var i = 0, ii = matches.length; i < ii; i++) {
  12271. var match = matches[i];
  12272. var begin = Math.max(clearedUntilDivIdx, match.begin.divIdx);
  12273. for (var n = begin, end = match.end.divIdx; n <= end; n++) {
  12274. var div = textDivs[n];
  12275. div.textContent = textContentItemsStr[n];
  12276. div.className = '';
  12277. }
  12278. clearedUntilDivIdx = match.end.divIdx + 1;
  12279. }
  12280. if (!findController || !findController.highlightMatches) {
  12281. return;
  12282. }
  12283. var pageMatches = findController.pageMatches[pageIdx] || null;
  12284. var pageMatchesLength = findController.pageMatchesLength[pageIdx] ||
  12285. null;
  12286. this.matches = this._convertMatches(pageMatches, pageMatchesLength);
  12287. this._renderMatches(this.matches);
  12288. }
  12289. }, {
  12290. key: "_bindMouse",
  12291. value: function _bindMouse() {
  12292. var _this2 = this;
  12293. var div = this.textLayerDiv;
  12294. var expandDivsTimer = null;
  12295. div.addEventListener('mousedown', function(evt) {
  12296. if (_this2.enhanceTextSelection && _this2
  12297. .textLayerRenderTask) {
  12298. _this2.textLayerRenderTask.expandTextDivs(true);
  12299. if (expandDivsTimer) {
  12300. clearTimeout(expandDivsTimer);
  12301. expandDivsTimer = null;
  12302. }
  12303. return;
  12304. }
  12305. var end = div.querySelector('.endOfContent');
  12306. if (!end) {
  12307. return;
  12308. }
  12309. var adjustTop = evt.target !== div;
  12310. adjustTop = adjustTop && window.getComputedStyle(end)
  12311. .getPropertyValue('-moz-user-select') !== 'none';
  12312. if (adjustTop) {
  12313. var divBounds = div.getBoundingClientRect();
  12314. var r = Math.max(0, (evt.pageY - divBounds.top) /
  12315. divBounds.height);
  12316. end.style.top = (r * 100).toFixed(2) + '%';
  12317. }
  12318. end.classList.add('active');
  12319. });
  12320. div.addEventListener('mouseup', function() {
  12321. if (_this2.enhanceTextSelection && _this2
  12322. .textLayerRenderTask) {
  12323. expandDivsTimer = setTimeout(function() {
  12324. if (_this2.textLayerRenderTask) {
  12325. _this2.textLayerRenderTask
  12326. .expandTextDivs(false);
  12327. }
  12328. expandDivsTimer = null;
  12329. }, EXPAND_DIVS_TIMEOUT);
  12330. return;
  12331. }
  12332. var end = div.querySelector('.endOfContent');
  12333. if (!end) {
  12334. return;
  12335. }
  12336. end.style.top = '';
  12337. end.classList.remove('active');
  12338. });
  12339. }
  12340. }]);
  12341. return TextLayerBuilder;
  12342. }();
  12343. exports.TextLayerBuilder = TextLayerBuilder;
  12344. var DefaultTextLayerFactory =
  12345. /*#__PURE__*/
  12346. function() {
  12347. function DefaultTextLayerFactory() {
  12348. _classCallCheck(this, DefaultTextLayerFactory);
  12349. }
  12350. _createClass(DefaultTextLayerFactory, [{
  12351. key: "createTextLayerBuilder",
  12352. value: function createTextLayerBuilder(textLayerDiv, pageIndex, viewport) {
  12353. var enhanceTextSelection = arguments.length > 3 && arguments[3] !==
  12354. undefined ? arguments[3] : false;
  12355. return new TextLayerBuilder({
  12356. textLayerDiv: textLayerDiv,
  12357. pageIndex: pageIndex,
  12358. viewport: viewport,
  12359. enhanceTextSelection: enhanceTextSelection
  12360. });
  12361. }
  12362. }]);
  12363. return DefaultTextLayerFactory;
  12364. }();
  12365. exports.DefaultTextLayerFactory = DefaultTextLayerFactory;
  12366. /***/
  12367. }),
  12368. /* 32 */
  12369. /***/
  12370. (function(module, exports, __webpack_require__) {
  12371. "use strict";
  12372. Object.defineProperty(exports, "__esModule", {
  12373. value: true
  12374. });
  12375. exports.SecondaryToolbar = void 0;
  12376. var _ui_utils = __webpack_require__(5);
  12377. var _pdf_cursor_tools = __webpack_require__(9);
  12378. var _pdf_single_page_viewer = __webpack_require__(33);
  12379. function _classCallCheck(instance, Constructor) {
  12380. if (!(instance instanceof Constructor)) {
  12381. throw new TypeError("Cannot call a class as a function");
  12382. }
  12383. }
  12384. function _defineProperties(target, props) {
  12385. for (var i = 0; i < props.length; i++) {
  12386. var descriptor = props[i];
  12387. descriptor.enumerable = descriptor.enumerable || false;
  12388. descriptor.configurable = true;
  12389. if ("value" in descriptor) descriptor.writable = true;
  12390. Object.defineProperty(target, descriptor.key, descriptor);
  12391. }
  12392. }
  12393. function _createClass(Constructor, protoProps, staticProps) {
  12394. if (protoProps) _defineProperties(Constructor.prototype, protoProps);
  12395. if (staticProps) _defineProperties(Constructor, staticProps);
  12396. return Constructor;
  12397. }
  12398. var SecondaryToolbar =
  12399. /*#__PURE__*/
  12400. function() {
  12401. function SecondaryToolbar(options, mainContainer, eventBus) {
  12402. var _this = this;
  12403. _classCallCheck(this, SecondaryToolbar);
  12404. this.toolbar = options.toolbar;
  12405. this.toggleButton = options.toggleButton;
  12406. this.toolbarButtonContainer = options.toolbarButtonContainer;
  12407. this.buttons = [{
  12408. element: options.presentationModeButton,
  12409. eventName: 'presentationmode',
  12410. close: true
  12411. }, {
  12412. element: options.openFileButton,
  12413. eventName: 'openfile',
  12414. close: true
  12415. }, {
  12416. element: options.printButton,
  12417. eventName: 'print',
  12418. close: true
  12419. }, {
  12420. element: options.downloadButton,
  12421. eventName: 'download',
  12422. close: true
  12423. }, {
  12424. element: options.viewBookmarkButton,
  12425. eventName: null,
  12426. close: true
  12427. }, {
  12428. element: options.firstPageButton,
  12429. eventName: 'firstpage',
  12430. close: true
  12431. }, {
  12432. element: options.lastPageButton,
  12433. eventName: 'lastpage',
  12434. close: true
  12435. }, {
  12436. element: options.pageRotateCwButton,
  12437. eventName: 'rotatecw',
  12438. close: false
  12439. }, {
  12440. element: options.pageRotateCcwButton,
  12441. eventName: 'rotateccw',
  12442. close: false
  12443. }, {
  12444. element: options.cursorSelectToolButton,
  12445. eventName: 'switchcursortool',
  12446. eventDetails: {
  12447. tool: _pdf_cursor_tools.CursorTool.SELECT
  12448. },
  12449. close: true
  12450. }, {
  12451. element: options.cursorHandToolButton,
  12452. eventName: 'switchcursortool',
  12453. eventDetails: {
  12454. tool: _pdf_cursor_tools.CursorTool.HAND
  12455. },
  12456. close: true
  12457. }, {
  12458. element: options.scrollVerticalButton,
  12459. eventName: 'switchscrollmode',
  12460. eventDetails: {
  12461. mode: _ui_utils.ScrollMode.VERTICAL
  12462. },
  12463. close: true
  12464. }, {
  12465. element: options.scrollHorizontalButton,
  12466. eventName: 'switchscrollmode',
  12467. eventDetails: {
  12468. mode: _ui_utils.ScrollMode.HORIZONTAL
  12469. },
  12470. close: true
  12471. }, {
  12472. element: options.scrollWrappedButton,
  12473. eventName: 'switchscrollmode',
  12474. eventDetails: {
  12475. mode: _ui_utils.ScrollMode.WRAPPED
  12476. },
  12477. close: true
  12478. }, {
  12479. element: options.spreadNoneButton,
  12480. eventName: 'switchspreadmode',
  12481. eventDetails: {
  12482. mode: _ui_utils.SpreadMode.NONE
  12483. },
  12484. close: true
  12485. }, {
  12486. element: options.spreadOddButton,
  12487. eventName: 'switchspreadmode',
  12488. eventDetails: {
  12489. mode: _ui_utils.SpreadMode.ODD
  12490. },
  12491. close: true
  12492. }, {
  12493. element: options.spreadEvenButton,
  12494. eventName: 'switchspreadmode',
  12495. eventDetails: {
  12496. mode: _ui_utils.SpreadMode.EVEN
  12497. },
  12498. close: true
  12499. }, {
  12500. element: options.documentPropertiesButton,
  12501. eventName: 'documentproperties',
  12502. close: true
  12503. }];
  12504. this.items = {
  12505. firstPage: options.firstPageButton,
  12506. lastPage: options.lastPageButton,
  12507. pageRotateCw: options.pageRotateCwButton,
  12508. pageRotateCcw: options.pageRotateCcwButton
  12509. };
  12510. this.mainContainer = mainContainer;
  12511. this.eventBus = eventBus;
  12512. this.opened = false;
  12513. this.containerHeight = null;
  12514. this.previousContainerHeight = null;
  12515. this.reset();
  12516. this._bindClickListeners();
  12517. this._bindCursorToolsListener(options);
  12518. this._bindScrollModeListener(options);
  12519. this._bindSpreadModeListener(options);
  12520. this.eventBus.on('resize', this._setMaxHeight.bind(this));
  12521. this.eventBus.on('baseviewerinit', function(evt) {
  12522. if (evt.source instanceof _pdf_single_page_viewer.PDFSinglePageViewer) {
  12523. _this.toolbarButtonContainer.classList.add('hiddenScrollModeButtons',
  12524. 'hiddenSpreadModeButtons');
  12525. } else {
  12526. _this.toolbarButtonContainer.classList.remove('hiddenScrollModeButtons',
  12527. 'hiddenSpreadModeButtons');
  12528. }
  12529. });
  12530. }
  12531. _createClass(SecondaryToolbar, [{
  12532. key: "setPageNumber",
  12533. value: function setPageNumber(pageNumber) {
  12534. this.pageNumber = pageNumber;
  12535. this._updateUIState();
  12536. }
  12537. }, {
  12538. key: "setPagesCount",
  12539. value: function setPagesCount(pagesCount) {
  12540. this.pagesCount = pagesCount;
  12541. this._updateUIState();
  12542. }
  12543. }, {
  12544. key: "reset",
  12545. value: function reset() {
  12546. this.pageNumber = 0;
  12547. this.pagesCount = 0;
  12548. this._updateUIState();
  12549. this.eventBus.dispatch('secondarytoolbarreset', {
  12550. source: this
  12551. });
  12552. }
  12553. }, {
  12554. key: "_updateUIState",
  12555. value: function _updateUIState() {
  12556. this.items.firstPage.disabled = this.pageNumber <= 1;
  12557. this.items.lastPage.disabled = this.pageNumber >= this.pagesCount;
  12558. this.items.pageRotateCw.disabled = this.pagesCount === 0;
  12559. this.items.pageRotateCcw.disabled = this.pagesCount === 0;
  12560. }
  12561. }, {
  12562. key: "_bindClickListeners",
  12563. value: function _bindClickListeners() {
  12564. var _this2 = this;
  12565. this.toggleButton.addEventListener('click', this.toggle.bind(this));
  12566. var _loop = function _loop(button) {
  12567. var _this2$buttons$button = _this2.buttons[button],
  12568. element = _this2$buttons$button.element,
  12569. eventName = _this2$buttons$button.eventName,
  12570. close = _this2$buttons$button.close,
  12571. eventDetails = _this2$buttons$button.eventDetails;
  12572. element.addEventListener('click', function(evt) {
  12573. if (eventName !== null) {
  12574. var details = {
  12575. source: _this2
  12576. };
  12577. for (var property in eventDetails) {
  12578. details[property] = eventDetails[property];
  12579. }
  12580. _this2.eventBus.dispatch(eventName, details);
  12581. }
  12582. if (close) {
  12583. _this2.close();
  12584. }
  12585. });
  12586. };
  12587. for (var button in this.buttons) {
  12588. _loop(button);
  12589. }
  12590. }
  12591. }, {
  12592. key: "_bindCursorToolsListener",
  12593. value: function _bindCursorToolsListener(buttons) {
  12594. this.eventBus.on('cursortoolchanged', function(_ref) {
  12595. var tool = _ref.tool;
  12596. buttons.cursorSelectToolButton.classList.toggle('toggled',
  12597. tool === _pdf_cursor_tools.CursorTool.SELECT);
  12598. buttons.cursorHandToolButton.classList.toggle('toggled',
  12599. tool === _pdf_cursor_tools.CursorTool.HAND);
  12600. });
  12601. }
  12602. }, {
  12603. key: "_bindScrollModeListener",
  12604. value: function _bindScrollModeListener(buttons) {
  12605. var _this3 = this;
  12606. function scrollModeChanged(_ref2) {
  12607. var mode = _ref2.mode;
  12608. buttons.scrollVerticalButton.classList.toggle('toggled', mode ===
  12609. _ui_utils.ScrollMode.VERTICAL);
  12610. buttons.scrollHorizontalButton.classList.toggle('toggled', mode ===
  12611. _ui_utils.ScrollMode.HORIZONTAL);
  12612. buttons.scrollWrappedButton.classList.toggle('toggled', mode ===
  12613. _ui_utils.ScrollMode.WRAPPED);
  12614. var isScrollModeHorizontal = mode === _ui_utils.ScrollMode
  12615. .HORIZONTAL;
  12616. buttons.spreadNoneButton.disabled = isScrollModeHorizontal;
  12617. buttons.spreadOddButton.disabled = isScrollModeHorizontal;
  12618. buttons.spreadEvenButton.disabled = isScrollModeHorizontal;
  12619. }
  12620. this.eventBus.on('scrollmodechanged', scrollModeChanged);
  12621. this.eventBus.on('secondarytoolbarreset', function(evt) {
  12622. if (evt.source === _this3) {
  12623. scrollModeChanged({
  12624. mode: _ui_utils.ScrollMode.VERTICAL
  12625. });
  12626. }
  12627. });
  12628. }
  12629. }, {
  12630. key: "_bindSpreadModeListener",
  12631. value: function _bindSpreadModeListener(buttons) {
  12632. var _this4 = this;
  12633. function spreadModeChanged(_ref3) {
  12634. var mode = _ref3.mode;
  12635. buttons.spreadNoneButton.classList.toggle('toggled', mode ===
  12636. _ui_utils.SpreadMode.NONE);
  12637. buttons.spreadOddButton.classList.toggle('toggled', mode ===
  12638. _ui_utils.SpreadMode.ODD);
  12639. buttons.spreadEvenButton.classList.toggle('toggled', mode ===
  12640. _ui_utils.SpreadMode.EVEN);
  12641. }
  12642. this.eventBus.on('spreadmodechanged', spreadModeChanged);
  12643. this.eventBus.on('secondarytoolbarreset', function(evt) {
  12644. if (evt.source === _this4) {
  12645. spreadModeChanged({
  12646. mode: _ui_utils.SpreadMode.NONE
  12647. });
  12648. }
  12649. });
  12650. }
  12651. }, {
  12652. key: "open",
  12653. value: function open() {
  12654. if (this.opened) {
  12655. return;
  12656. }
  12657. this.opened = true;
  12658. this._setMaxHeight();
  12659. this.toggleButton.classList.add('toggled');
  12660. this.toolbar.classList.remove('hidden');
  12661. }
  12662. }, {
  12663. key: "close",
  12664. value: function close() {
  12665. if (!this.opened) {
  12666. return;
  12667. }
  12668. this.opened = false;
  12669. this.toolbar.classList.add('hidden');
  12670. this.toggleButton.classList.remove('toggled');
  12671. }
  12672. }, {
  12673. key: "toggle",
  12674. value: function toggle() {
  12675. if (this.opened) {
  12676. this.close();
  12677. } else {
  12678. this.open();
  12679. }
  12680. }
  12681. }, {
  12682. key: "_setMaxHeight",
  12683. value: function _setMaxHeight() {
  12684. if (!this.opened) {
  12685. return;
  12686. }
  12687. this.containerHeight = this.mainContainer.clientHeight;
  12688. if (this.containerHeight === this.previousContainerHeight) {
  12689. return;
  12690. }
  12691. this.toolbarButtonContainer.setAttribute('style', 'max-height: ' + (this
  12692. .containerHeight - _ui_utils.SCROLLBAR_PADDING) + 'px;');
  12693. this.previousContainerHeight = this.containerHeight;
  12694. }
  12695. }, {
  12696. key: "isOpen",
  12697. get: function get() {
  12698. return this.opened;
  12699. }
  12700. }]);
  12701. return SecondaryToolbar;
  12702. }();
  12703. exports.SecondaryToolbar = SecondaryToolbar;
  12704. /***/
  12705. }),
  12706. /* 33 */
  12707. /***/
  12708. (function(module, exports, __webpack_require__) {
  12709. "use strict";
  12710. Object.defineProperty(exports, "__esModule", {
  12711. value: true
  12712. });
  12713. exports.PDFSinglePageViewer = void 0;
  12714. var _base_viewer = __webpack_require__(28);
  12715. var _pdfjsLib = __webpack_require__(7);
  12716. function _typeof(obj) {
  12717. if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
  12718. _typeof = function _typeof(obj) {
  12719. return typeof obj;
  12720. };
  12721. } else {
  12722. _typeof = function _typeof(obj) {
  12723. return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !==
  12724. Symbol.prototype ? "symbol" : typeof obj;
  12725. };
  12726. }
  12727. return _typeof(obj);
  12728. }
  12729. function _classCallCheck(instance, Constructor) {
  12730. if (!(instance instanceof Constructor)) {
  12731. throw new TypeError("Cannot call a class as a function");
  12732. }
  12733. }
  12734. function _defineProperties(target, props) {
  12735. for (var i = 0; i < props.length; i++) {
  12736. var descriptor = props[i];
  12737. descriptor.enumerable = descriptor.enumerable || false;
  12738. descriptor.configurable = true;
  12739. if ("value" in descriptor) descriptor.writable = true;
  12740. Object.defineProperty(target, descriptor.key, descriptor);
  12741. }
  12742. }
  12743. function _createClass(Constructor, protoProps, staticProps) {
  12744. if (protoProps) _defineProperties(Constructor.prototype, protoProps);
  12745. if (staticProps) _defineProperties(Constructor, staticProps);
  12746. return Constructor;
  12747. }
  12748. function _possibleConstructorReturn(self, call) {
  12749. if (call && (_typeof(call) === "object" || typeof call === "function")) {
  12750. return call;
  12751. }
  12752. return _assertThisInitialized(self);
  12753. }
  12754. function _assertThisInitialized(self) {
  12755. if (self === void 0) {
  12756. throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
  12757. }
  12758. return self;
  12759. }
  12760. function _get(target, property, receiver) {
  12761. if (typeof Reflect !== "undefined" && Reflect.get) {
  12762. _get = Reflect.get;
  12763. } else {
  12764. _get = function _get(target, property, receiver) {
  12765. var base = _superPropBase(target, property);
  12766. if (!base) return;
  12767. var desc = Object.getOwnPropertyDescriptor(base, property);
  12768. if (desc.get) {
  12769. return desc.get.call(receiver);
  12770. }
  12771. return desc.value;
  12772. };
  12773. }
  12774. return _get(target, property, receiver || target);
  12775. }
  12776. function _superPropBase(object, property) {
  12777. while (!Object.prototype.hasOwnProperty.call(object, property)) {
  12778. object = _getPrototypeOf(object);
  12779. if (object === null) break;
  12780. }
  12781. return object;
  12782. }
  12783. function _getPrototypeOf(o) {
  12784. _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
  12785. return o.__proto__ || Object.getPrototypeOf(o);
  12786. };
  12787. return _getPrototypeOf(o);
  12788. }
  12789. function _inherits(subClass, superClass) {
  12790. if (typeof superClass !== "function" && superClass !== null) {
  12791. throw new TypeError("Super expression must either be null or a function");
  12792. }
  12793. subClass.prototype = Object.create(superClass && superClass.prototype, {
  12794. constructor: {
  12795. value: subClass,
  12796. writable: true,
  12797. configurable: true
  12798. }
  12799. });
  12800. if (superClass) _setPrototypeOf(subClass, superClass);
  12801. }
  12802. function _setPrototypeOf(o, p) {
  12803. _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
  12804. o.__proto__ = p;
  12805. return o;
  12806. };
  12807. return _setPrototypeOf(o, p);
  12808. }
  12809. var PDFSinglePageViewer =
  12810. /*#__PURE__*/
  12811. function(_BaseViewer) {
  12812. _inherits(PDFSinglePageViewer, _BaseViewer);
  12813. function PDFSinglePageViewer(options) {
  12814. var _this;
  12815. _classCallCheck(this, PDFSinglePageViewer);
  12816. _this = _possibleConstructorReturn(this, _getPrototypeOf(PDFSinglePageViewer).call(this,
  12817. options));
  12818. _this.eventBus.on('pagesinit', function(evt) {
  12819. _this._ensurePageViewVisible();
  12820. });
  12821. return _this;
  12822. }
  12823. _createClass(PDFSinglePageViewer, [{
  12824. key: "_resetView",
  12825. value: function _resetView() {
  12826. _get(_getPrototypeOf(PDFSinglePageViewer.prototype), "_resetView", this)
  12827. .call(this);
  12828. this._previousPageNumber = 1;
  12829. this._shadowViewer = document.createDocumentFragment();
  12830. this._updateScrollDown = null;
  12831. }
  12832. }, {
  12833. key: "_ensurePageViewVisible",
  12834. value: function _ensurePageViewVisible() {
  12835. var pageView = this._pages[this._currentPageNumber - 1];
  12836. var previousPageView = this._pages[this._previousPageNumber - 1];
  12837. var viewerNodes = this.viewer.childNodes;
  12838. switch (viewerNodes.length) {
  12839. case 0:
  12840. this.viewer.appendChild(pageView.div);
  12841. break;
  12842. case 1:
  12843. if (viewerNodes[0] !== previousPageView.div) {
  12844. throw new Error(
  12845. '_ensurePageViewVisible: Unexpected previously visible page.'
  12846. );
  12847. }
  12848. if (pageView === previousPageView) {
  12849. break;
  12850. }
  12851. this._shadowViewer.appendChild(previousPageView.div);
  12852. this.viewer.appendChild(pageView.div);
  12853. this.container.scrollTop = 0;
  12854. break;
  12855. default:
  12856. throw new Error(
  12857. '_ensurePageViewVisible: Only one page should be visible at a time.'
  12858. );
  12859. }
  12860. this._previousPageNumber = this._currentPageNumber;
  12861. }
  12862. }, {
  12863. key: "_scrollUpdate",
  12864. value: function _scrollUpdate() {
  12865. if (this._updateScrollDown) {
  12866. this._updateScrollDown();
  12867. }
  12868. _get(_getPrototypeOf(PDFSinglePageViewer.prototype), "_scrollUpdate",
  12869. this).call(this);
  12870. }
  12871. }, {
  12872. key: "_scrollIntoView",
  12873. value: function _scrollIntoView(_ref) {
  12874. var _this2 = this;
  12875. var pageDiv = _ref.pageDiv,
  12876. _ref$pageSpot = _ref.pageSpot,
  12877. pageSpot = _ref$pageSpot === void 0 ? null : _ref$pageSpot,
  12878. _ref$pageNumber = _ref.pageNumber,
  12879. pageNumber = _ref$pageNumber === void 0 ? null : _ref$pageNumber;
  12880. if (pageNumber) {
  12881. this._setCurrentPageNumber(pageNumber);
  12882. }
  12883. var scrolledDown = this._currentPageNumber >= this._previousPageNumber;
  12884. this._ensurePageViewVisible();
  12885. this.update();
  12886. _get(_getPrototypeOf(PDFSinglePageViewer.prototype), "_scrollIntoView",
  12887. this).call(this, {
  12888. pageDiv: pageDiv,
  12889. pageSpot: pageSpot,
  12890. pageNumber: pageNumber
  12891. });
  12892. this._updateScrollDown = function() {
  12893. _this2.scroll.down = scrolledDown;
  12894. _this2._updateScrollDown = null;
  12895. };
  12896. }
  12897. }, {
  12898. key: "_getVisiblePages",
  12899. value: function _getVisiblePages() {
  12900. return this._getCurrentVisiblePage();
  12901. }
  12902. }, {
  12903. key: "_updateHelper",
  12904. value: function _updateHelper(visiblePages) {}
  12905. }, {
  12906. key: "_updateScrollMode",
  12907. value: function _updateScrollMode() {}
  12908. }, {
  12909. key: "_updateSpreadMode",
  12910. value: function _updateSpreadMode() {}
  12911. }, {
  12912. key: "_setDocumentViewerElement",
  12913. get: function get() {
  12914. return (0, _pdfjsLib.shadow)(this, '_setDocumentViewerElement', this
  12915. ._shadowViewer);
  12916. }
  12917. }, {
  12918. key: "_isScrollModeHorizontal",
  12919. get: function get() {
  12920. return (0, _pdfjsLib.shadow)(this, '_isScrollModeHorizontal', false);
  12921. }
  12922. }]);
  12923. return PDFSinglePageViewer;
  12924. }(_base_viewer.BaseViewer);
  12925. exports.PDFSinglePageViewer = PDFSinglePageViewer;
  12926. /***/
  12927. }),
  12928. /* 34 */
  12929. /***/
  12930. (function(module, exports, __webpack_require__) {
  12931. "use strict";
  12932. Object.defineProperty(exports, "__esModule", {
  12933. value: true
  12934. });
  12935. exports.Toolbar = void 0;
  12936. var _ui_utils = __webpack_require__(5);
  12937. function _classCallCheck(instance, Constructor) {
  12938. if (!(instance instanceof Constructor)) {
  12939. throw new TypeError("Cannot call a class as a function");
  12940. }
  12941. }
  12942. function _defineProperties(target, props) {
  12943. for (var i = 0; i < props.length; i++) {
  12944. var descriptor = props[i];
  12945. descriptor.enumerable = descriptor.enumerable || false;
  12946. descriptor.configurable = true;
  12947. if ("value" in descriptor) descriptor.writable = true;
  12948. Object.defineProperty(target, descriptor.key, descriptor);
  12949. }
  12950. }
  12951. function _createClass(Constructor, protoProps, staticProps) {
  12952. if (protoProps) _defineProperties(Constructor.prototype, protoProps);
  12953. if (staticProps) _defineProperties(Constructor, staticProps);
  12954. return Constructor;
  12955. }
  12956. var PAGE_NUMBER_LOADING_INDICATOR = 'visiblePageIsLoading';
  12957. var SCALE_SELECT_CONTAINER_PADDING = 8;
  12958. var SCALE_SELECT_PADDING = 22;
  12959. var Toolbar =
  12960. /*#__PURE__*/
  12961. function() {
  12962. function Toolbar(options, eventBus) {
  12963. var l10n = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : _ui_utils
  12964. .NullL10n;
  12965. _classCallCheck(this, Toolbar);
  12966. this.toolbar = options.container;
  12967. this.eventBus = eventBus;
  12968. this.l10n = l10n;
  12969. this.items = options;
  12970. this._wasLocalized = false;
  12971. this.reset();
  12972. this._bindListeners();
  12973. }
  12974. _createClass(Toolbar, [{
  12975. key: "setPageNumber",
  12976. value: function setPageNumber(pageNumber, pageLabel) {
  12977. this.pageNumber = pageNumber;
  12978. this.pageLabel = pageLabel;
  12979. this._updateUIState(false);
  12980. }
  12981. }, {
  12982. key: "setPagesCount",
  12983. value: function setPagesCount(pagesCount, hasPageLabels) {
  12984. this.pagesCount = pagesCount;
  12985. this.hasPageLabels = hasPageLabels;
  12986. this._updateUIState(true);
  12987. }
  12988. }, {
  12989. key: "setPageScale",
  12990. value: function setPageScale(pageScaleValue, pageScale) {
  12991. this.pageScaleValue = (pageScaleValue || pageScale).toString();
  12992. this.pageScale = pageScale;
  12993. this._updateUIState(false);
  12994. }
  12995. }, {
  12996. key: "reset",
  12997. value: function reset() {
  12998. this.pageNumber = 0;
  12999. this.pageLabel = null;
  13000. this.hasPageLabels = false;
  13001. this.pagesCount = 0;
  13002. this.pageScaleValue = _ui_utils.DEFAULT_SCALE_VALUE;
  13003. this.pageScale = _ui_utils.DEFAULT_SCALE;
  13004. this._updateUIState(true);
  13005. this.updateLoadingIndicatorState();
  13006. }
  13007. }, {
  13008. key: "_bindListeners",
  13009. value: function _bindListeners() {
  13010. var _this = this;
  13011. var eventBus = this.eventBus,
  13012. items = this.items;
  13013. var self = this;
  13014. items.previous.addEventListener('click', function() {
  13015. eventBus.dispatch('previouspage', {
  13016. source: self
  13017. });
  13018. });
  13019. items.next.addEventListener('click', function() {
  13020. eventBus.dispatch('nextpage', {
  13021. source: self
  13022. });
  13023. });
  13024. items.zoomIn.addEventListener('click', function() {
  13025. eventBus.dispatch('zoomin', {
  13026. source: self
  13027. });
  13028. });
  13029. items.zoomOut.addEventListener('click', function() {
  13030. eventBus.dispatch('zoomout', {
  13031. source: self
  13032. });
  13033. });
  13034. items.pageNumber.addEventListener('click', function() {
  13035. this.select();
  13036. });
  13037. items.pageNumber.addEventListener('change', function() {
  13038. eventBus.dispatch('pagenumberchanged', {
  13039. source: self,
  13040. value: this.value
  13041. });
  13042. });
  13043. items.scaleSelect.addEventListener('change', function() {
  13044. if (this.value === 'custom') {
  13045. return;
  13046. }
  13047. eventBus.dispatch('scalechanged', {
  13048. source: self,
  13049. value: this.value
  13050. });
  13051. });
  13052. items.presentationModeButton.addEventListener('click', function() {
  13053. eventBus.dispatch('presentationmode', {
  13054. source: self
  13055. });
  13056. });
  13057. items.openFile.addEventListener('click', function() {
  13058. eventBus.dispatch('openfile', {
  13059. source: self
  13060. });
  13061. });
  13062. items.print.addEventListener('click', function() {
  13063. eventBus.dispatch('print', {
  13064. source: self
  13065. });
  13066. });
  13067. items.download.addEventListener('click', function() {
  13068. eventBus.dispatch('download', {
  13069. source: self
  13070. });
  13071. });
  13072. items.scaleSelect.oncontextmenu = _ui_utils.noContextMenuHandler;
  13073. eventBus.on('localized', function() {
  13074. _this._localized();
  13075. });
  13076. }
  13077. }, {
  13078. key: "_localized",
  13079. value: function _localized() {
  13080. this._wasLocalized = true;
  13081. this._adjustScaleWidth();
  13082. this._updateUIState(true);
  13083. }
  13084. }, {
  13085. key: "_updateUIState",
  13086. value: function _updateUIState() {
  13087. var resetNumPages = arguments.length > 0 && arguments[0] !== undefined ?
  13088. arguments[0] : false;
  13089. if (!this._wasLocalized) {
  13090. return;
  13091. }
  13092. var pageNumber = this.pageNumber,
  13093. pagesCount = this.pagesCount,
  13094. pageScaleValue = this.pageScaleValue,
  13095. pageScale = this.pageScale,
  13096. items = this.items;
  13097. if (resetNumPages) {
  13098. if (this.hasPageLabels) {
  13099. items.pageNumber.type = 'text';
  13100. } else {
  13101. items.pageNumber.type = 'number';
  13102. this.l10n.get('of_pages', {
  13103. pagesCount: pagesCount
  13104. }, 'of {{pagesCount}}').then(function(msg) {
  13105. items.numPages.textContent = msg;
  13106. });
  13107. }
  13108. items.pageNumber.max = pagesCount;
  13109. }
  13110. if (this.hasPageLabels) {
  13111. items.pageNumber.value = this.pageLabel;
  13112. this.l10n.get('page_of_pages', {
  13113. pageNumber: pageNumber,
  13114. pagesCount: pagesCount
  13115. }, '({{pageNumber}} of {{pagesCount}})').then(function(msg) {
  13116. items.numPages.textContent = msg;
  13117. });
  13118. } else {
  13119. items.pageNumber.value = pageNumber;
  13120. }
  13121. items.previous.disabled = pageNumber <= 1;
  13122. items.next.disabled = pageNumber >= pagesCount;
  13123. items.zoomOut.disabled = pageScale <= _ui_utils.MIN_SCALE;
  13124. items.zoomIn.disabled = pageScale >= _ui_utils.MAX_SCALE;
  13125. var customScale = Math.round(pageScale * 10000) / 100;
  13126. this.l10n.get('page_scale_percent', {
  13127. scale: customScale
  13128. }, '{{scale}}%').then(function(msg) {
  13129. var options = items.scaleSelect.options;
  13130. var predefinedValueFound = false;
  13131. for (var i = 0, ii = options.length; i < ii; i++) {
  13132. var option = options[i];
  13133. if (option.value !== pageScaleValue) {
  13134. option.selected = false;
  13135. continue;
  13136. }
  13137. option.selected = true;
  13138. predefinedValueFound = true;
  13139. }
  13140. if (!predefinedValueFound) {
  13141. items.customScaleOption.textContent = msg;
  13142. items.customScaleOption.selected = true;
  13143. }
  13144. });
  13145. }
  13146. }, {
  13147. key: "updateLoadingIndicatorState",
  13148. value: function updateLoadingIndicatorState() {
  13149. var loading = arguments.length > 0 && arguments[0] !== undefined ?
  13150. arguments[0] : false;
  13151. var pageNumberInput = this.items.pageNumber;
  13152. pageNumberInput.classList.toggle(PAGE_NUMBER_LOADING_INDICATOR,
  13153. loading);
  13154. }
  13155. }, {
  13156. key: "_adjustScaleWidth",
  13157. value: function _adjustScaleWidth() {
  13158. var container = this.items.scaleSelectContainer;
  13159. var select = this.items.scaleSelect;
  13160. _ui_utils.animationStarted.then(function() {
  13161. if (container.clientWidth === 0) {
  13162. container.setAttribute('style', 'display: inherit;');
  13163. }
  13164. if (container.clientWidth > 0) {
  13165. select.setAttribute('style', 'min-width: inherit;');
  13166. var width = select.clientWidth +
  13167. SCALE_SELECT_CONTAINER_PADDING;
  13168. select.setAttribute('style', 'min-width: ' + (width +
  13169. SCALE_SELECT_PADDING) + 'px;');
  13170. container.setAttribute('style', 'min-width: ' + width +
  13171. 'px; ' + 'max-width: ' + width + 'px;');
  13172. }
  13173. });
  13174. }
  13175. }]);
  13176. return Toolbar;
  13177. }();
  13178. exports.Toolbar = Toolbar;
  13179. /***/
  13180. }),
  13181. /* 35 */
  13182. /***/
  13183. (function(module, exports, __webpack_require__) {
  13184. "use strict";
  13185. Object.defineProperty(exports, "__esModule", {
  13186. value: true
  13187. });
  13188. exports.ViewHistory = void 0;
  13189. var _regenerator = _interopRequireDefault(__webpack_require__(2));
  13190. function _interopRequireDefault(obj) {
  13191. return obj && obj.__esModule ? obj : {
  13192. "default": obj
  13193. };
  13194. }
  13195. function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
  13196. try {
  13197. var info = gen[key](arg);
  13198. var value = info.value;
  13199. } catch (error) {
  13200. reject(error);
  13201. return;
  13202. }
  13203. if (info.done) {
  13204. resolve(value);
  13205. } else {
  13206. Promise.resolve(value).then(_next, _throw);
  13207. }
  13208. }
  13209. function _asyncToGenerator(fn) {
  13210. return function() {
  13211. var self = this,
  13212. args = arguments;
  13213. return new Promise(function(resolve, reject) {
  13214. var gen = fn.apply(self, args);
  13215. function _next(value) {
  13216. asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
  13217. }
  13218. function _throw(err) {
  13219. asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
  13220. }
  13221. _next(undefined);
  13222. });
  13223. };
  13224. }
  13225. function _classCallCheck(instance, Constructor) {
  13226. if (!(instance instanceof Constructor)) {
  13227. throw new TypeError("Cannot call a class as a function");
  13228. }
  13229. }
  13230. function _defineProperties(target, props) {
  13231. for (var i = 0; i < props.length; i++) {
  13232. var descriptor = props[i];
  13233. descriptor.enumerable = descriptor.enumerable || false;
  13234. descriptor.configurable = true;
  13235. if ("value" in descriptor) descriptor.writable = true;
  13236. Object.defineProperty(target, descriptor.key, descriptor);
  13237. }
  13238. }
  13239. function _createClass(Constructor, protoProps, staticProps) {
  13240. if (protoProps) _defineProperties(Constructor.prototype, protoProps);
  13241. if (staticProps) _defineProperties(Constructor, staticProps);
  13242. return Constructor;
  13243. }
  13244. var DEFAULT_VIEW_HISTORY_CACHE_SIZE = 20;
  13245. var ViewHistory =
  13246. /*#__PURE__*/
  13247. function() {
  13248. function ViewHistory(fingerprint) {
  13249. var _this = this;
  13250. var cacheSize = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] :
  13251. DEFAULT_VIEW_HISTORY_CACHE_SIZE;
  13252. _classCallCheck(this, ViewHistory);
  13253. this.fingerprint = fingerprint;
  13254. this.cacheSize = cacheSize;
  13255. this._initializedPromise = this._readFromStorage().then(function(databaseStr) {
  13256. var database = JSON.parse(databaseStr || '{}');
  13257. if (!('files' in database)) {
  13258. database.files = [];
  13259. } else {
  13260. while (database.files.length >= _this.cacheSize) {
  13261. database.files.shift();
  13262. }
  13263. }
  13264. var index = -1;
  13265. for (var i = 0, length = database.files.length; i < length; i++) {
  13266. var branch = database.files[i];
  13267. if (branch.fingerprint === _this.fingerprint) {
  13268. index = i;
  13269. break;
  13270. }
  13271. }
  13272. if (index === -1) {
  13273. index = database.files.push({
  13274. fingerprint: _this.fingerprint
  13275. }) - 1;
  13276. }
  13277. _this.file = database.files[index];
  13278. _this.database = database;
  13279. });
  13280. }
  13281. _createClass(ViewHistory, [{
  13282. key: "_writeToStorage",
  13283. value: function() {
  13284. var _writeToStorage2 = _asyncToGenerator(
  13285. /*#__PURE__*/
  13286. _regenerator["default"].mark(function _callee() {
  13287. var databaseStr;
  13288. return _regenerator["default"].wrap(function _callee$(
  13289. _context) {
  13290. while (1) {
  13291. switch (_context.prev = _context.next) {
  13292. case 0:
  13293. databaseStr = JSON.stringify(
  13294. this.database);
  13295. localStorage.setItem(
  13296. 'pdfjs.history',
  13297. databaseStr);
  13298. // let arr = this.database.files[0]
  13299. /* 这里不读缓存 走window事件 */
  13300. let data = [
  13301. {totalPage: window.PDFViewerApplication.pagesCount},
  13302. {page: window.PDFViewerApplication.page},
  13303. ]
  13304. // console.log("0000",window.PDFViewerApplication.page,window.PDFViewerApplication.pagesCount)
  13305. // console.log("pdf记录:",data)
  13306. // uni.webView.getEnv(function(res) {
  13307. // console.log('当前环境:' + JSON.stringify(res));
  13308. // });
  13309. uni.postMessage({
  13310. data: data
  13311. });
  13312. case 2:
  13313. case "end":
  13314. return _context.stop();
  13315. }
  13316. }
  13317. }, _callee, this);
  13318. }));
  13319. function _writeToStorage() {
  13320. return _writeToStorage2.apply(this, arguments);
  13321. }
  13322. return _writeToStorage;
  13323. }()
  13324. }, {
  13325. key: "_readFromStorage",
  13326. value: function() {
  13327. var _readFromStorage2 = _asyncToGenerator(
  13328. /*#__PURE__*/
  13329. _regenerator["default"].mark(function _callee2() {
  13330. return _regenerator["default"].wrap(function _callee2$(
  13331. _context2) {
  13332. while (1) {
  13333. switch (_context2.prev = _context2
  13334. .next) {
  13335. case 0:
  13336. return _context2.abrupt(
  13337. "return", localStorage
  13338. .getItem(
  13339. 'pdfjs.history'));
  13340. case 1:
  13341. case "end":
  13342. return _context2.stop();
  13343. }
  13344. }
  13345. }, _callee2);
  13346. }));
  13347. function _readFromStorage() {
  13348. return _readFromStorage2.apply(this, arguments);
  13349. }
  13350. return _readFromStorage;
  13351. }()
  13352. }, {
  13353. key: "set",
  13354. value: function() {
  13355. var _set = _asyncToGenerator(
  13356. /*#__PURE__*/
  13357. _regenerator["default"].mark(function _callee3(name, val) {
  13358. return _regenerator["default"].wrap(function _callee3$(
  13359. _context3) {
  13360. while (1) {
  13361. switch (_context3.prev = _context3
  13362. .next) {
  13363. case 0:
  13364. _context3.next = 2;
  13365. return this._initializedPromise;
  13366. case 2:
  13367. this.file[name] = val;
  13368. return _context3.abrupt(
  13369. "return", this
  13370. ._writeToStorage());
  13371. case 4:
  13372. case "end":
  13373. return _context3.stop();
  13374. }
  13375. }
  13376. }, _callee3, this);
  13377. }));
  13378. function set(_x, _x2) {
  13379. return _set.apply(this, arguments);
  13380. }
  13381. return set;
  13382. }()
  13383. }, {
  13384. key: "setMultiple",
  13385. value: function() {
  13386. var _setMultiple = _asyncToGenerator(
  13387. /*#__PURE__*/
  13388. _regenerator["default"].mark(function _callee4(properties) {
  13389. var name;
  13390. return _regenerator["default"].wrap(function _callee4$(
  13391. _context4) {
  13392. while (1) {
  13393. switch (_context4.prev = _context4
  13394. .next) {
  13395. case 0:
  13396. _context4.next = 2;
  13397. return this._initializedPromise;
  13398. case 2:
  13399. for (name in properties) {
  13400. this.file[name] =
  13401. properties[name];
  13402. }
  13403. return _context4.abrupt(
  13404. "return", this
  13405. ._writeToStorage());
  13406. case 4:
  13407. case "end":
  13408. return _context4.stop();
  13409. }
  13410. }
  13411. }, _callee4, this);
  13412. }));
  13413. function setMultiple(_x3) {
  13414. return _setMultiple.apply(this, arguments);
  13415. }
  13416. return setMultiple;
  13417. }()
  13418. }, {
  13419. key: "get",
  13420. value: function() {
  13421. var _get = _asyncToGenerator(
  13422. /*#__PURE__*/
  13423. _regenerator["default"].mark(function _callee5(name,
  13424. defaultValue) {
  13425. var val;
  13426. return _regenerator["default"].wrap(function _callee5$(
  13427. _context5) {
  13428. while (1) {
  13429. switch (_context5.prev = _context5
  13430. .next) {
  13431. case 0:
  13432. _context5.next = 2;
  13433. return this._initializedPromise;
  13434. case 2:
  13435. val = this.file[name];
  13436. return _context5.abrupt(
  13437. "return", val !==
  13438. undefined ? val :
  13439. defaultValue);
  13440. case 4:
  13441. case "end":
  13442. return _context5.stop();
  13443. }
  13444. }
  13445. }, _callee5, this);
  13446. }));
  13447. function get(_x4, _x5) {
  13448. return _get.apply(this, arguments);
  13449. }
  13450. return get;
  13451. }()
  13452. }, {
  13453. key: "getMultiple",
  13454. value: function() {
  13455. var _getMultiple = _asyncToGenerator(
  13456. /*#__PURE__*/
  13457. _regenerator["default"].mark(function _callee6(properties) {
  13458. var values, name, val;
  13459. return _regenerator["default"].wrap(function _callee6$(
  13460. _context6) {
  13461. while (1) {
  13462. switch (_context6.prev = _context6
  13463. .next) {
  13464. case 0:
  13465. _context6.next = 2;
  13466. return this._initializedPromise;
  13467. case 2:
  13468. values = Object.create(null);
  13469. for (name in properties) {
  13470. val = this.file[name];
  13471. values[name] = val !==
  13472. undefined ? val :
  13473. properties[name];
  13474. }
  13475. return _context6.abrupt(
  13476. "return", values);
  13477. case 5:
  13478. case "end":
  13479. return _context6.stop();
  13480. }
  13481. }
  13482. }, _callee6, this);
  13483. }));
  13484. function getMultiple(_x6) {
  13485. return _getMultiple.apply(this, arguments);
  13486. }
  13487. return getMultiple;
  13488. }()
  13489. }]);
  13490. return ViewHistory;
  13491. }();
  13492. exports.ViewHistory = ViewHistory;
  13493. /***/
  13494. }),
  13495. /* 36 */
  13496. /***/
  13497. (function(module, exports, __webpack_require__) {
  13498. "use strict";
  13499. Object.defineProperty(exports, "__esModule", {
  13500. value: true
  13501. });
  13502. exports.GenericCom = void 0;
  13503. var _regenerator = _interopRequireDefault(__webpack_require__(2));
  13504. var _app = __webpack_require__(1);
  13505. var _preferences = __webpack_require__(37);
  13506. var _download_manager = __webpack_require__(38);
  13507. var _genericl10n = __webpack_require__(39);
  13508. function _interopRequireDefault(obj) {
  13509. return obj && obj.__esModule ? obj : {
  13510. "default": obj
  13511. };
  13512. }
  13513. function _typeof(obj) {
  13514. if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
  13515. _typeof = function _typeof(obj) {
  13516. return typeof obj;
  13517. };
  13518. } else {
  13519. _typeof = function _typeof(obj) {
  13520. return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !==
  13521. Symbol.prototype ? "symbol" : typeof obj;
  13522. };
  13523. }
  13524. return _typeof(obj);
  13525. }
  13526. function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
  13527. try {
  13528. var info = gen[key](arg);
  13529. var value = info.value;
  13530. } catch (error) {
  13531. reject(error);
  13532. return;
  13533. }
  13534. if (info.done) {
  13535. resolve(value);
  13536. } else {
  13537. Promise.resolve(value).then(_next, _throw);
  13538. }
  13539. }
  13540. function _asyncToGenerator(fn) {
  13541. return function() {
  13542. var self = this,
  13543. args = arguments;
  13544. return new Promise(function(resolve, reject) {
  13545. var gen = fn.apply(self, args);
  13546. function _next(value) {
  13547. asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
  13548. }
  13549. function _throw(err) {
  13550. asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
  13551. }
  13552. _next(undefined);
  13553. });
  13554. };
  13555. }
  13556. function _classCallCheck(instance, Constructor) {
  13557. if (!(instance instanceof Constructor)) {
  13558. throw new TypeError("Cannot call a class as a function");
  13559. }
  13560. }
  13561. function _defineProperties(target, props) {
  13562. for (var i = 0; i < props.length; i++) {
  13563. var descriptor = props[i];
  13564. descriptor.enumerable = descriptor.enumerable || false;
  13565. descriptor.configurable = true;
  13566. if ("value" in descriptor) descriptor.writable = true;
  13567. Object.defineProperty(target, descriptor.key, descriptor);
  13568. }
  13569. }
  13570. function _createClass(Constructor, protoProps, staticProps) {
  13571. if (protoProps) _defineProperties(Constructor.prototype, protoProps);
  13572. if (staticProps) _defineProperties(Constructor, staticProps);
  13573. return Constructor;
  13574. }
  13575. function _possibleConstructorReturn(self, call) {
  13576. if (call && (_typeof(call) === "object" || typeof call === "function")) {
  13577. return call;
  13578. }
  13579. return _assertThisInitialized(self);
  13580. }
  13581. function _assertThisInitialized(self) {
  13582. if (self === void 0) {
  13583. throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
  13584. }
  13585. return self;
  13586. }
  13587. function _getPrototypeOf(o) {
  13588. _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
  13589. return o.__proto__ || Object.getPrototypeOf(o);
  13590. };
  13591. return _getPrototypeOf(o);
  13592. }
  13593. function _inherits(subClass, superClass) {
  13594. if (typeof superClass !== "function" && superClass !== null) {
  13595. throw new TypeError("Super expression must either be null or a function");
  13596. }
  13597. subClass.prototype = Object.create(superClass && superClass.prototype, {
  13598. constructor: {
  13599. value: subClass,
  13600. writable: true,
  13601. configurable: true
  13602. }
  13603. });
  13604. if (superClass) _setPrototypeOf(subClass, superClass);
  13605. }
  13606. function _setPrototypeOf(o, p) {
  13607. _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
  13608. o.__proto__ = p;
  13609. return o;
  13610. };
  13611. return _setPrototypeOf(o, p);
  13612. }
  13613. ;
  13614. var GenericCom = {};
  13615. exports.GenericCom = GenericCom;
  13616. var GenericPreferences =
  13617. /*#__PURE__*/
  13618. function(_BasePreferences) {
  13619. _inherits(GenericPreferences, _BasePreferences);
  13620. function GenericPreferences() {
  13621. _classCallCheck(this, GenericPreferences);
  13622. return _possibleConstructorReturn(this, _getPrototypeOf(GenericPreferences).apply(this,
  13623. arguments));
  13624. }
  13625. _createClass(GenericPreferences, [{
  13626. key: "_writeToStorage",
  13627. value: function() {
  13628. var _writeToStorage2 = _asyncToGenerator(
  13629. /*#__PURE__*/
  13630. _regenerator["default"].mark(function _callee(prefObj) {
  13631. return _regenerator["default"].wrap(function _callee$(
  13632. _context) {
  13633. while (1) {
  13634. switch (_context.prev = _context.next) {
  13635. case 0:
  13636. localStorage.setItem(
  13637. 'pdfjs.preferences',
  13638. JSON.stringify(prefObj));
  13639. case 1:
  13640. case "end":
  13641. return _context.stop();
  13642. }
  13643. }
  13644. }, _callee);
  13645. }));
  13646. function _writeToStorage(_x) {
  13647. return _writeToStorage2.apply(this, arguments);
  13648. }
  13649. return _writeToStorage;
  13650. }()
  13651. }, {
  13652. key: "_readFromStorage",
  13653. value: function() {
  13654. var _readFromStorage2 = _asyncToGenerator(
  13655. /*#__PURE__*/
  13656. _regenerator["default"].mark(function _callee2(prefObj) {
  13657. return _regenerator["default"].wrap(function _callee2$(
  13658. _context2) {
  13659. while (1) {
  13660. switch (_context2.prev = _context2
  13661. .next) {
  13662. case 0:
  13663. return _context2.abrupt(
  13664. "return", JSON.parse(
  13665. localStorage
  13666. .getItem(
  13667. 'pdfjs.preferences'
  13668. )));
  13669. case 1:
  13670. case "end":
  13671. return _context2.stop();
  13672. }
  13673. }
  13674. }, _callee2);
  13675. }));
  13676. function _readFromStorage(_x2) {
  13677. return _readFromStorage2.apply(this, arguments);
  13678. }
  13679. return _readFromStorage;
  13680. }()
  13681. }]);
  13682. return GenericPreferences;
  13683. }(_preferences.BasePreferences);
  13684. var GenericExternalServices = Object.create(_app.DefaultExternalServices);
  13685. GenericExternalServices.createDownloadManager = function(options) {
  13686. return new _download_manager.DownloadManager(options);
  13687. };
  13688. GenericExternalServices.createPreferences = function() {
  13689. return new GenericPreferences();
  13690. };
  13691. GenericExternalServices.createL10n = function(_ref) {
  13692. var _ref$locale = _ref.locale,
  13693. locale = _ref$locale === void 0 ? 'en-US' : _ref$locale;
  13694. return new _genericl10n.GenericL10n(locale);
  13695. };
  13696. _app.PDFViewerApplication.externalServices = GenericExternalServices;
  13697. /***/
  13698. }),
  13699. /* 37 */
  13700. /***/
  13701. (function(module, exports, __webpack_require__) {
  13702. "use strict";
  13703. Object.defineProperty(exports, "__esModule", {
  13704. value: true
  13705. });
  13706. exports.BasePreferences = void 0;
  13707. var _regenerator = _interopRequireDefault(__webpack_require__(2));
  13708. function _interopRequireDefault(obj) {
  13709. return obj && obj.__esModule ? obj : {
  13710. "default": obj
  13711. };
  13712. }
  13713. function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
  13714. try {
  13715. var info = gen[key](arg);
  13716. var value = info.value;
  13717. } catch (error) {
  13718. reject(error);
  13719. return;
  13720. }
  13721. if (info.done) {
  13722. resolve(value);
  13723. } else {
  13724. Promise.resolve(value).then(_next, _throw);
  13725. }
  13726. }
  13727. function _asyncToGenerator(fn) {
  13728. return function() {
  13729. var self = this,
  13730. args = arguments;
  13731. return new Promise(function(resolve, reject) {
  13732. var gen = fn.apply(self, args);
  13733. function _next(value) {
  13734. asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
  13735. }
  13736. function _throw(err) {
  13737. asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
  13738. }
  13739. _next(undefined);
  13740. });
  13741. };
  13742. }
  13743. function _typeof(obj) {
  13744. if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
  13745. _typeof = function _typeof(obj) {
  13746. return typeof obj;
  13747. };
  13748. } else {
  13749. _typeof = function _typeof(obj) {
  13750. return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !==
  13751. Symbol.prototype ? "symbol" : typeof obj;
  13752. };
  13753. }
  13754. return _typeof(obj);
  13755. }
  13756. function _classCallCheck(instance, Constructor) {
  13757. if (!(instance instanceof Constructor)) {
  13758. throw new TypeError("Cannot call a class as a function");
  13759. }
  13760. }
  13761. function _defineProperties(target, props) {
  13762. for (var i = 0; i < props.length; i++) {
  13763. var descriptor = props[i];
  13764. descriptor.enumerable = descriptor.enumerable || false;
  13765. descriptor.configurable = true;
  13766. if ("value" in descriptor) descriptor.writable = true;
  13767. Object.defineProperty(target, descriptor.key, descriptor);
  13768. }
  13769. }
  13770. function _createClass(Constructor, protoProps, staticProps) {
  13771. if (protoProps) _defineProperties(Constructor.prototype, protoProps);
  13772. if (staticProps) _defineProperties(Constructor, staticProps);
  13773. return Constructor;
  13774. }
  13775. var defaultPreferences = null;
  13776. function getDefaultPreferences() {
  13777. if (!defaultPreferences) {
  13778. defaultPreferences = Promise.resolve({
  13779. "cursorToolOnLoad": 0,
  13780. "defaultZoomValue": "",
  13781. "disablePageLabels": false,
  13782. "enablePrintAutoRotate": false,
  13783. "enableWebGL": false,
  13784. "eventBusDispatchToDOM": false,
  13785. "externalLinkTarget": 0,
  13786. "historyUpdateUrl": false,
  13787. "pdfBugEnabled": false,
  13788. "renderer": "canvas",
  13789. "renderInteractiveForms": false,
  13790. "sidebarViewOnLoad": -1,
  13791. "scrollModeOnLoad": -1,
  13792. "spreadModeOnLoad": -1,
  13793. "textLayerMode": 1,
  13794. "useOnlyCssZoom": false,
  13795. "viewOnLoad": 0,
  13796. "disableAutoFetch": false,
  13797. "disableFontFace": false,
  13798. "disableRange": false,
  13799. "disableStream": false
  13800. });
  13801. }
  13802. return defaultPreferences;
  13803. }
  13804. var BasePreferences =
  13805. /*#__PURE__*/
  13806. function() {
  13807. function BasePreferences() {
  13808. var _this = this;
  13809. _classCallCheck(this, BasePreferences);
  13810. if (this.constructor === BasePreferences) {
  13811. throw new Error('Cannot initialize BasePreferences.');
  13812. }
  13813. this.prefs = null;
  13814. this._initializedPromise = getDefaultPreferences().then(function(defaults) {
  13815. Object.defineProperty(_this, 'defaults', {
  13816. value: Object.freeze(defaults),
  13817. writable: false,
  13818. enumerable: true,
  13819. configurable: false
  13820. });
  13821. _this.prefs = Object.assign(Object.create(null), defaults);
  13822. return _this._readFromStorage(defaults);
  13823. }).then(function(prefs) {
  13824. if (!prefs) {
  13825. return;
  13826. }
  13827. for (var name in prefs) {
  13828. var defaultValue = _this.defaults[name],
  13829. prefValue = prefs[name];
  13830. if (defaultValue === undefined || _typeof(prefValue) !== _typeof(
  13831. defaultValue)) {
  13832. continue;
  13833. }
  13834. _this.prefs[name] = prefValue;
  13835. }
  13836. });
  13837. }
  13838. _createClass(BasePreferences, [{
  13839. key: "_writeToStorage",
  13840. value: function() {
  13841. var _writeToStorage2 = _asyncToGenerator(
  13842. /*#__PURE__*/
  13843. _regenerator["default"].mark(function _callee(prefObj) {
  13844. return _regenerator["default"].wrap(function _callee$(
  13845. _context) {
  13846. while (1) {
  13847. switch (_context.prev = _context.next) {
  13848. case 0:
  13849. throw new Error(
  13850. 'Not implemented: _writeToStorage'
  13851. );
  13852. case 1:
  13853. case "end":
  13854. return _context.stop();
  13855. }
  13856. }
  13857. }, _callee);
  13858. }));
  13859. function _writeToStorage(_x) {
  13860. return _writeToStorage2.apply(this, arguments);
  13861. }
  13862. return _writeToStorage;
  13863. }()
  13864. }, {
  13865. key: "_readFromStorage",
  13866. value: function() {
  13867. var _readFromStorage2 = _asyncToGenerator(
  13868. /*#__PURE__*/
  13869. _regenerator["default"].mark(function _callee2(prefObj) {
  13870. return _regenerator["default"].wrap(function _callee2$(
  13871. _context2) {
  13872. while (1) {
  13873. switch (_context2.prev = _context2
  13874. .next) {
  13875. case 0:
  13876. throw new Error(
  13877. 'Not implemented: _readFromStorage'
  13878. );
  13879. case 1:
  13880. case "end":
  13881. return _context2.stop();
  13882. }
  13883. }
  13884. }, _callee2);
  13885. }));
  13886. function _readFromStorage(_x2) {
  13887. return _readFromStorage2.apply(this, arguments);
  13888. }
  13889. return _readFromStorage;
  13890. }()
  13891. }, {
  13892. key: "reset",
  13893. value: function() {
  13894. var _reset = _asyncToGenerator(
  13895. /*#__PURE__*/
  13896. _regenerator["default"].mark(function _callee3() {
  13897. return _regenerator["default"].wrap(function _callee3$(
  13898. _context3) {
  13899. while (1) {
  13900. switch (_context3.prev = _context3
  13901. .next) {
  13902. case 0:
  13903. _context3.next = 2;
  13904. return this._initializedPromise;
  13905. case 2:
  13906. this.prefs = Object.assign(
  13907. Object.create(null),
  13908. this.defaults);
  13909. return _context3.abrupt(
  13910. "return", this
  13911. ._writeToStorage(this
  13912. .defaults));
  13913. case 4:
  13914. case "end":
  13915. return _context3.stop();
  13916. }
  13917. }
  13918. }, _callee3, this);
  13919. }));
  13920. function reset() {
  13921. return _reset.apply(this, arguments);
  13922. }
  13923. return reset;
  13924. }()
  13925. }, {
  13926. key: "set",
  13927. value: function() {
  13928. var _set = _asyncToGenerator(
  13929. /*#__PURE__*/
  13930. _regenerator["default"].mark(function _callee4(name, value) {
  13931. var defaultValue, valueType, defaultType;
  13932. return _regenerator["default"].wrap(function _callee4$(
  13933. _context4) {
  13934. while (1) {
  13935. switch (_context4.prev = _context4
  13936. .next) {
  13937. case 0:
  13938. _context4.next = 2;
  13939. return this._initializedPromise;
  13940. case 2:
  13941. defaultValue = this.defaults[
  13942. name];
  13943. if (!(defaultValue ===
  13944. undefined)) {
  13945. _context4.next = 7;
  13946. break;
  13947. }
  13948. throw new Error(
  13949. "Set preference: \""
  13950. .concat(name,
  13951. "\" is undefined."));
  13952. case 7:
  13953. if (!(value === undefined)) {
  13954. _context4.next = 9;
  13955. break;
  13956. }
  13957. throw new Error(
  13958. 'Set preference: no value is specified.'
  13959. );
  13960. case 9:
  13961. valueType = _typeof(value);
  13962. defaultType = _typeof(
  13963. defaultValue);
  13964. if (!(valueType !==
  13965. defaultType)) {
  13966. _context4.next = 19;
  13967. break;
  13968. }
  13969. if (!(valueType === 'number' &&
  13970. defaultType === 'string'
  13971. )) {
  13972. _context4.next = 16;
  13973. break;
  13974. }
  13975. value = value.toString();
  13976. _context4.next = 17;
  13977. break;
  13978. case 16:
  13979. throw new Error(
  13980. "Set preference: \""
  13981. .concat(value,
  13982. "\" is a ").concat(
  13983. valueType, ", ") +
  13984. "expected a ".concat(
  13985. defaultType, "."));
  13986. case 17:
  13987. _context4.next = 21;
  13988. break;
  13989. case 19:
  13990. if (!(valueType === 'number' &&
  13991. !Number.isInteger(value)
  13992. )) {
  13993. _context4.next = 21;
  13994. break;
  13995. }
  13996. throw new Error(
  13997. "Set preference: \""
  13998. .concat(value,
  13999. "\" must be an integer."
  14000. ));
  14001. case 21:
  14002. this.prefs[name] = value;
  14003. return _context4.abrupt(
  14004. "return", this
  14005. ._writeToStorage(this
  14006. .prefs));
  14007. case 23:
  14008. case "end":
  14009. return _context4.stop();
  14010. }
  14011. }
  14012. }, _callee4, this);
  14013. }));
  14014. function set(_x3, _x4) {
  14015. return _set.apply(this, arguments);
  14016. }
  14017. return set;
  14018. }()
  14019. }, {
  14020. key: "get",
  14021. value: function() {
  14022. var _get = _asyncToGenerator(
  14023. /*#__PURE__*/
  14024. _regenerator["default"].mark(function _callee5(name) {
  14025. var defaultValue, prefValue;
  14026. return _regenerator["default"].wrap(function _callee5$(
  14027. _context5) {
  14028. while (1) {
  14029. switch (_context5.prev = _context5
  14030. .next) {
  14031. case 0:
  14032. _context5.next = 2;
  14033. return this._initializedPromise;
  14034. case 2:
  14035. defaultValue = this.defaults[
  14036. name];
  14037. if (!(defaultValue ===
  14038. undefined)) {
  14039. _context5.next = 7;
  14040. break;
  14041. }
  14042. throw new Error(
  14043. "Get preference: \""
  14044. .concat(name,
  14045. "\" is undefined."));
  14046. case 7:
  14047. prefValue = this.prefs[name];
  14048. if (!(prefValue !==
  14049. undefined)) {
  14050. _context5.next = 10;
  14051. break;
  14052. }
  14053. return _context5.abrupt(
  14054. "return", prefValue);
  14055. case 10:
  14056. return _context5.abrupt(
  14057. "return", defaultValue);
  14058. case 11:
  14059. case "end":
  14060. return _context5.stop();
  14061. }
  14062. }
  14063. }, _callee5, this);
  14064. }));
  14065. function get(_x5) {
  14066. return _get.apply(this, arguments);
  14067. }
  14068. return get;
  14069. }()
  14070. }, {
  14071. key: "getAll",
  14072. value: function() {
  14073. var _getAll = _asyncToGenerator(
  14074. /*#__PURE__*/
  14075. _regenerator["default"].mark(function _callee6() {
  14076. return _regenerator["default"].wrap(function _callee6$(
  14077. _context6) {
  14078. while (1) {
  14079. switch (_context6.prev = _context6
  14080. .next) {
  14081. case 0:
  14082. _context6.next = 2;
  14083. return this._initializedPromise;
  14084. case 2:
  14085. return _context6.abrupt(
  14086. "return", Object.assign(
  14087. Object.create(null),
  14088. this.defaults, this
  14089. .prefs));
  14090. case 3:
  14091. case "end":
  14092. return _context6.stop();
  14093. }
  14094. }
  14095. }, _callee6, this);
  14096. }));
  14097. function getAll() {
  14098. return _getAll.apply(this, arguments);
  14099. }
  14100. return getAll;
  14101. }()
  14102. }]);
  14103. return BasePreferences;
  14104. }();
  14105. exports.BasePreferences = BasePreferences;
  14106. /***/
  14107. }),
  14108. /* 38 */
  14109. /***/
  14110. (function(module, exports, __webpack_require__) {
  14111. "use strict";
  14112. Object.defineProperty(exports, "__esModule", {
  14113. value: true
  14114. });
  14115. exports.DownloadManager = void 0;
  14116. var _pdfjsLib = __webpack_require__(7);
  14117. function _classCallCheck(instance, Constructor) {
  14118. if (!(instance instanceof Constructor)) {
  14119. throw new TypeError("Cannot call a class as a function");
  14120. }
  14121. }
  14122. function _defineProperties(target, props) {
  14123. for (var i = 0; i < props.length; i++) {
  14124. var descriptor = props[i];
  14125. descriptor.enumerable = descriptor.enumerable || false;
  14126. descriptor.configurable = true;
  14127. if ("value" in descriptor) descriptor.writable = true;
  14128. Object.defineProperty(target, descriptor.key, descriptor);
  14129. }
  14130. }
  14131. function _createClass(Constructor, protoProps, staticProps) {
  14132. if (protoProps) _defineProperties(Constructor.prototype, protoProps);
  14133. if (staticProps) _defineProperties(Constructor, staticProps);
  14134. return Constructor;
  14135. }
  14136. ;
  14137. var DISABLE_CREATE_OBJECT_URL = _pdfjsLib.apiCompatibilityParams.disableCreateObjectURL || false;
  14138. function _download(blobUrl, filename) {
  14139. var a = document.createElement('a');
  14140. if (!a.click) {
  14141. throw new Error('DownloadManager: "a.click()" is not supported.');
  14142. }
  14143. a.href = blobUrl;
  14144. a.target = '_parent';
  14145. if ('download' in a) {
  14146. a.download = filename;
  14147. }
  14148. (document.body || document.documentElement).appendChild(a);
  14149. a.click();
  14150. a.remove();
  14151. }
  14152. var DownloadManager =
  14153. /*#__PURE__*/
  14154. function() {
  14155. function DownloadManager(_ref) {
  14156. var _ref$disableCreateObj = _ref.disableCreateObjectURL,
  14157. disableCreateObjectURL = _ref$disableCreateObj === void 0 ? DISABLE_CREATE_OBJECT_URL :
  14158. _ref$disableCreateObj;
  14159. _classCallCheck(this, DownloadManager);
  14160. this.disableCreateObjectURL = disableCreateObjectURL;
  14161. }
  14162. _createClass(DownloadManager, [{
  14163. key: "downloadUrl",
  14164. value: function downloadUrl(url, filename) {
  14165. if (!(0, _pdfjsLib.createValidAbsoluteUrl)(url, 'http://example.com')) {
  14166. return;
  14167. }
  14168. _download(url + '#pdfjs.action=download', filename);
  14169. }
  14170. }, {
  14171. key: "downloadData",
  14172. value: function downloadData(data, filename, contentType) {
  14173. if (navigator.msSaveBlob) {
  14174. navigator.msSaveBlob(new Blob([data], {
  14175. type: contentType
  14176. }), filename);
  14177. return;
  14178. }
  14179. var blobUrl = (0, _pdfjsLib.createObjectURL)(data, contentType, this
  14180. .disableCreateObjectURL);
  14181. _download(blobUrl, filename);
  14182. }
  14183. }, {
  14184. key: "download",
  14185. value: function download(blob, url, filename) {
  14186. if (navigator.msSaveBlob) {
  14187. if (!navigator.msSaveBlob(blob, filename)) {
  14188. this.downloadUrl(url, filename);
  14189. }
  14190. return;
  14191. }
  14192. if (this.disableCreateObjectURL) {
  14193. this.downloadUrl(url, filename);
  14194. return;
  14195. }
  14196. var blobUrl = URL.createObjectURL(blob);
  14197. _download(blobUrl, filename);
  14198. }
  14199. }]);
  14200. return DownloadManager;
  14201. }();
  14202. exports.DownloadManager = DownloadManager;
  14203. /***/
  14204. }),
  14205. /* 39 */
  14206. /***/
  14207. (function(module, exports, __webpack_require__) {
  14208. "use strict";
  14209. Object.defineProperty(exports, "__esModule", {
  14210. value: true
  14211. });
  14212. exports.GenericL10n = void 0;
  14213. var _regenerator = _interopRequireDefault(__webpack_require__(2));
  14214. __webpack_require__(40);
  14215. function _interopRequireDefault(obj) {
  14216. return obj && obj.__esModule ? obj : {
  14217. "default": obj
  14218. };
  14219. }
  14220. function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
  14221. try {
  14222. var info = gen[key](arg);
  14223. var value = info.value;
  14224. } catch (error) {
  14225. reject(error);
  14226. return;
  14227. }
  14228. if (info.done) {
  14229. resolve(value);
  14230. } else {
  14231. Promise.resolve(value).then(_next, _throw);
  14232. }
  14233. }
  14234. function _asyncToGenerator(fn) {
  14235. return function() {
  14236. var self = this,
  14237. args = arguments;
  14238. return new Promise(function(resolve, reject) {
  14239. var gen = fn.apply(self, args);
  14240. function _next(value) {
  14241. asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
  14242. }
  14243. function _throw(err) {
  14244. asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
  14245. }
  14246. _next(undefined);
  14247. });
  14248. };
  14249. }
  14250. function _classCallCheck(instance, Constructor) {
  14251. if (!(instance instanceof Constructor)) {
  14252. throw new TypeError("Cannot call a class as a function");
  14253. }
  14254. }
  14255. function _defineProperties(target, props) {
  14256. for (var i = 0; i < props.length; i++) {
  14257. var descriptor = props[i];
  14258. descriptor.enumerable = descriptor.enumerable || false;
  14259. descriptor.configurable = true;
  14260. if ("value" in descriptor) descriptor.writable = true;
  14261. Object.defineProperty(target, descriptor.key, descriptor);
  14262. }
  14263. }
  14264. function _createClass(Constructor, protoProps, staticProps) {
  14265. if (protoProps) _defineProperties(Constructor.prototype, protoProps);
  14266. if (staticProps) _defineProperties(Constructor, staticProps);
  14267. return Constructor;
  14268. }
  14269. var webL10n = document.webL10n;
  14270. var GenericL10n =
  14271. /*#__PURE__*/
  14272. function() {
  14273. function GenericL10n(lang) {
  14274. _classCallCheck(this, GenericL10n);
  14275. this._lang = lang;
  14276. this._ready = new Promise(function(resolve, reject) {
  14277. webL10n.setLanguage(lang, function() {
  14278. resolve(webL10n);
  14279. });
  14280. });
  14281. }
  14282. _createClass(GenericL10n, [{
  14283. key: "getLanguage",
  14284. value: function() {
  14285. var _getLanguage = _asyncToGenerator(
  14286. /*#__PURE__*/
  14287. _regenerator["default"].mark(function _callee() {
  14288. var l10n;
  14289. return _regenerator["default"].wrap(function _callee$(
  14290. _context) {
  14291. while (1) {
  14292. switch (_context.prev = _context.next) {
  14293. case 0:
  14294. _context.next = 2;
  14295. return this._ready;
  14296. case 2:
  14297. l10n = _context.sent;
  14298. return _context.abrupt("return",
  14299. l10n.getLanguage());
  14300. case 4:
  14301. case "end":
  14302. return _context.stop();
  14303. }
  14304. }
  14305. }, _callee, this);
  14306. }));
  14307. function getLanguage() {
  14308. return _getLanguage.apply(this, arguments);
  14309. }
  14310. return getLanguage;
  14311. }()
  14312. }, {
  14313. key: "getDirection",
  14314. value: function() {
  14315. var _getDirection = _asyncToGenerator(
  14316. /*#__PURE__*/
  14317. _regenerator["default"].mark(function _callee2() {
  14318. var l10n;
  14319. return _regenerator["default"].wrap(function _callee2$(
  14320. _context2) {
  14321. while (1) {
  14322. switch (_context2.prev = _context2
  14323. .next) {
  14324. case 0:
  14325. _context2.next = 2;
  14326. return this._ready;
  14327. case 2:
  14328. l10n = _context2.sent;
  14329. return _context2.abrupt(
  14330. "return", l10n
  14331. .getDirection());
  14332. case 4:
  14333. case "end":
  14334. return _context2.stop();
  14335. }
  14336. }
  14337. }, _callee2, this);
  14338. }));
  14339. function getDirection() {
  14340. return _getDirection.apply(this, arguments);
  14341. }
  14342. return getDirection;
  14343. }()
  14344. }, {
  14345. key: "get",
  14346. value: function() {
  14347. var _get = _asyncToGenerator(
  14348. /*#__PURE__*/
  14349. _regenerator["default"].mark(function _callee3(property, args,
  14350. fallback) {
  14351. var l10n;
  14352. return _regenerator["default"].wrap(function _callee3$(
  14353. _context3) {
  14354. while (1) {
  14355. switch (_context3.prev = _context3
  14356. .next) {
  14357. case 0:
  14358. _context3.next = 2;
  14359. return this._ready;
  14360. case 2:
  14361. l10n = _context3.sent;
  14362. return _context3.abrupt(
  14363. "return", l10n.get(
  14364. property, args,
  14365. fallback));
  14366. case 4:
  14367. case "end":
  14368. return _context3.stop();
  14369. }
  14370. }
  14371. }, _callee3, this);
  14372. }));
  14373. function get(_x, _x2, _x3) {
  14374. return _get.apply(this, arguments);
  14375. }
  14376. return get;
  14377. }()
  14378. }, {
  14379. key: "translate",
  14380. value: function() {
  14381. var _translate = _asyncToGenerator(
  14382. /*#__PURE__*/
  14383. _regenerator["default"].mark(function _callee4(element) {
  14384. var l10n;
  14385. return _regenerator["default"].wrap(function _callee4$(
  14386. _context4) {
  14387. while (1) {
  14388. switch (_context4.prev = _context4
  14389. .next) {
  14390. case 0:
  14391. _context4.next = 2;
  14392. return this._ready;
  14393. case 2:
  14394. l10n = _context4.sent;
  14395. return _context4.abrupt(
  14396. "return", l10n
  14397. .translate(element));
  14398. case 4:
  14399. case "end":
  14400. return _context4.stop();
  14401. }
  14402. }
  14403. }, _callee4, this);
  14404. }));
  14405. function translate(_x4) {
  14406. return _translate.apply(this, arguments);
  14407. }
  14408. return translate;
  14409. }()
  14410. }]);
  14411. return GenericL10n;
  14412. }();
  14413. exports.GenericL10n = GenericL10n;
  14414. /***/
  14415. }),
  14416. /* 40 */
  14417. /***/
  14418. (function(module, exports, __webpack_require__) {
  14419. "use strict";
  14420. document.webL10n = function(window, document, undefined) {
  14421. var gL10nData = {};
  14422. var gTextData = '';
  14423. var gTextProp = 'textContent';
  14424. var gLanguage = '';
  14425. var gMacros = {};
  14426. var gReadyState = 'loading';
  14427. var gAsyncResourceLoading = true;
  14428. function getL10nResourceLinks() {
  14429. return document.querySelectorAll('link[type="application/l10n"]');
  14430. }
  14431. function getL10nDictionary() {
  14432. var script = document.querySelector('script[type="application/l10n"]');
  14433. return script ? JSON.parse(script.innerHTML) : null;
  14434. }
  14435. function getTranslatableChildren(element) {
  14436. return element ? element.querySelectorAll('*[data-l10n-id]') : [];
  14437. }
  14438. function getL10nAttributes(element) {
  14439. if (!element) return {};
  14440. var l10nId = element.getAttribute('data-l10n-id');
  14441. var l10nArgs = element.getAttribute('data-l10n-args');
  14442. var args = {};
  14443. if (l10nArgs) {
  14444. try {
  14445. args = JSON.parse(l10nArgs);
  14446. } catch (e) {
  14447. console.warn('could not parse arguments for #' + l10nId);
  14448. }
  14449. }
  14450. return {
  14451. id: l10nId,
  14452. args: args
  14453. };
  14454. }
  14455. function xhrLoadText(url, onSuccess, onFailure) {
  14456. onSuccess = onSuccess || function _onSuccess(data) {};
  14457. onFailure = onFailure || function _onFailure() {};
  14458. var xhr = new XMLHttpRequest();
  14459. xhr.open('GET', url, gAsyncResourceLoading);
  14460. if (xhr.overrideMimeType) {
  14461. xhr.overrideMimeType('text/plain; charset=utf-8');
  14462. }
  14463. xhr.onreadystatechange = function() {
  14464. if (xhr.readyState == 4) {
  14465. if (xhr.status == 200 || xhr.status === 0) {
  14466. onSuccess(xhr.responseText);
  14467. } else {
  14468. onFailure();
  14469. }
  14470. }
  14471. };
  14472. xhr.onerror = onFailure;
  14473. xhr.ontimeout = onFailure;
  14474. try {
  14475. xhr.send(null);
  14476. } catch (e) {
  14477. onFailure();
  14478. }
  14479. }
  14480. function parseResource(href, lang, successCallback, failureCallback) {
  14481. var baseURL = href.replace(/[^\/]*$/, '') || './';
  14482. function evalString(text) {
  14483. if (text.lastIndexOf('\\') < 0) return text;
  14484. return text.replace(/\\\\/g, '\\').replace(/\\n/g, '\n').replace(/\\r/g, '\r').replace(
  14485. /\\t/g, '\t').replace(/\\b/g, '\b').replace(/\\f/g, '\f').replace(/\\{/g, '{')
  14486. .replace(/\\}/g, '}').replace(/\\"/g, '"').replace(/\\'/g, "'");
  14487. }
  14488. function parseProperties(text, parsedPropertiesCallback) {
  14489. var dictionary = {};
  14490. var reBlank = /^\s*|\s*$/;
  14491. var reComment = /^\s*#|^\s*$/;
  14492. var reSection = /^\s*\[(.*)\]\s*$/;
  14493. var reImport = /^\s*@import\s+url\((.*)\)\s*$/i;
  14494. var reSplit = /^([^=\s]*)\s*=\s*(.+)$/;
  14495. function parseRawLines(rawText, extendedSyntax, parsedRawLinesCallback) {
  14496. var entries = rawText.replace(reBlank, '').split(/[\r\n]+/);
  14497. var currentLang = '*';
  14498. var genericLang = lang.split('-', 1)[0];
  14499. var skipLang = false;
  14500. var match = '';
  14501. function nextEntry() {
  14502. while (true) {
  14503. if (!entries.length) {
  14504. parsedRawLinesCallback();
  14505. return;
  14506. }
  14507. var line = entries.shift();
  14508. if (reComment.test(line)) continue;
  14509. if (extendedSyntax) {
  14510. match = reSection.exec(line);
  14511. if (match) {
  14512. currentLang = match[1].toLowerCase();
  14513. skipLang = currentLang !== '*' && currentLang !== lang &&
  14514. currentLang !== genericLang;
  14515. continue;
  14516. } else if (skipLang) {
  14517. continue;
  14518. }
  14519. match = reImport.exec(line);
  14520. if (match) {
  14521. loadImport(baseURL + match[1], nextEntry);
  14522. return;
  14523. }
  14524. }
  14525. var tmp = line.match(reSplit);
  14526. if (tmp && tmp.length == 3) {
  14527. dictionary[tmp[1]] = evalString(tmp[2]);
  14528. }
  14529. }
  14530. }
  14531. nextEntry();
  14532. }
  14533. function loadImport(url, callback) {
  14534. xhrLoadText(url, function(content) {
  14535. parseRawLines(content, false, callback);
  14536. }, function() {
  14537. console.warn(url + ' not found.');
  14538. callback();
  14539. });
  14540. }
  14541. parseRawLines(text, true, function() {
  14542. parsedPropertiesCallback(dictionary);
  14543. });
  14544. }
  14545. xhrLoadText(href, function(response) {
  14546. gTextData += response;
  14547. parseProperties(response, function(data) {
  14548. for (var key in data) {
  14549. var id,
  14550. prop,
  14551. index = key.lastIndexOf('.');
  14552. if (index > 0) {
  14553. id = key.substring(0, index);
  14554. prop = key.substring(index + 1);
  14555. } else {
  14556. id = key;
  14557. prop = gTextProp;
  14558. }
  14559. if (!gL10nData[id]) {
  14560. gL10nData[id] = {};
  14561. }
  14562. gL10nData[id][prop] = data[key];
  14563. }
  14564. if (successCallback) {
  14565. successCallback();
  14566. }
  14567. });
  14568. }, failureCallback);
  14569. }
  14570. function loadLocale(lang, callback) {
  14571. if (lang) {
  14572. lang = lang.toLowerCase();
  14573. }
  14574. callback = callback || function _callback() {};
  14575. clear();
  14576. gLanguage = lang;
  14577. var langLinks = getL10nResourceLinks();
  14578. var langCount = langLinks.length;
  14579. if (langCount === 0) {
  14580. var dict = getL10nDictionary();
  14581. if (dict && dict.locales && dict.default_locale) {
  14582. console.log('using the embedded JSON directory, early way out');
  14583. gL10nData = dict.locales[lang];
  14584. if (!gL10nData) {
  14585. var defaultLocale = dict.default_locale.toLowerCase();
  14586. for (var anyCaseLang in dict.locales) {
  14587. anyCaseLang = anyCaseLang.toLowerCase();
  14588. if (anyCaseLang === lang) {
  14589. gL10nData = dict.locales[lang];
  14590. break;
  14591. } else if (anyCaseLang === defaultLocale) {
  14592. gL10nData = dict.locales[defaultLocale];
  14593. }
  14594. }
  14595. }
  14596. callback();
  14597. } else {
  14598. console.log('no resource to load, early way out');
  14599. }
  14600. gReadyState = 'complete';
  14601. return;
  14602. }
  14603. var onResourceLoaded = null;
  14604. var gResourceCount = 0;
  14605. onResourceLoaded = function onResourceLoaded() {
  14606. gResourceCount++;
  14607. if (gResourceCount >= langCount) {
  14608. callback();
  14609. gReadyState = 'complete';
  14610. }
  14611. };
  14612. function L10nResourceLink(link) {
  14613. var href = link.href;
  14614. this.load = function(lang, callback) {
  14615. parseResource(href, lang, callback, function() {
  14616. console.warn(href + ' not found.');
  14617. console.warn('"' + lang + '" resource not found');
  14618. gLanguage = '';
  14619. callback();
  14620. });
  14621. };
  14622. }
  14623. for (var i = 0; i < langCount; i++) {
  14624. var resource = new L10nResourceLink(langLinks[i]);
  14625. resource.load(lang, onResourceLoaded);
  14626. }
  14627. }
  14628. function clear() {
  14629. gL10nData = {};
  14630. gTextData = '';
  14631. gLanguage = '';
  14632. }
  14633. function getPluralRules(lang) {
  14634. var locales2rules = {
  14635. 'af': 3,
  14636. 'ak': 4,
  14637. 'am': 4,
  14638. 'ar': 1,
  14639. 'asa': 3,
  14640. 'az': 0,
  14641. 'be': 11,
  14642. 'bem': 3,
  14643. 'bez': 3,
  14644. 'bg': 3,
  14645. 'bh': 4,
  14646. 'bm': 0,
  14647. 'bn': 3,
  14648. 'bo': 0,
  14649. 'br': 20,
  14650. 'brx': 3,
  14651. 'bs': 11,
  14652. 'ca': 3,
  14653. 'cgg': 3,
  14654. 'chr': 3,
  14655. 'cs': 12,
  14656. 'cy': 17,
  14657. 'da': 3,
  14658. 'de': 3,
  14659. 'dv': 3,
  14660. 'dz': 0,
  14661. 'ee': 3,
  14662. 'el': 3,
  14663. 'en': 3,
  14664. 'eo': 3,
  14665. 'es': 3,
  14666. 'et': 3,
  14667. 'eu': 3,
  14668. 'fa': 0,
  14669. 'ff': 5,
  14670. 'fi': 3,
  14671. 'fil': 4,
  14672. 'fo': 3,
  14673. 'fr': 5,
  14674. 'fur': 3,
  14675. 'fy': 3,
  14676. 'ga': 8,
  14677. 'gd': 24,
  14678. 'gl': 3,
  14679. 'gsw': 3,
  14680. 'gu': 3,
  14681. 'guw': 4,
  14682. 'gv': 23,
  14683. 'ha': 3,
  14684. 'haw': 3,
  14685. 'he': 2,
  14686. 'hi': 4,
  14687. 'hr': 11,
  14688. 'hu': 0,
  14689. 'id': 0,
  14690. 'ig': 0,
  14691. 'ii': 0,
  14692. 'is': 3,
  14693. 'it': 3,
  14694. 'iu': 7,
  14695. 'ja': 0,
  14696. 'jmc': 3,
  14697. 'jv': 0,
  14698. 'ka': 0,
  14699. 'kab': 5,
  14700. 'kaj': 3,
  14701. 'kcg': 3,
  14702. 'kde': 0,
  14703. 'kea': 0,
  14704. 'kk': 3,
  14705. 'kl': 3,
  14706. 'km': 0,
  14707. 'kn': 0,
  14708. 'ko': 0,
  14709. 'ksb': 3,
  14710. 'ksh': 21,
  14711. 'ku': 3,
  14712. 'kw': 7,
  14713. 'lag': 18,
  14714. 'lb': 3,
  14715. 'lg': 3,
  14716. 'ln': 4,
  14717. 'lo': 0,
  14718. 'lt': 10,
  14719. 'lv': 6,
  14720. 'mas': 3,
  14721. 'mg': 4,
  14722. 'mk': 16,
  14723. 'ml': 3,
  14724. 'mn': 3,
  14725. 'mo': 9,
  14726. 'mr': 3,
  14727. 'ms': 0,
  14728. 'mt': 15,
  14729. 'my': 0,
  14730. 'nah': 3,
  14731. 'naq': 7,
  14732. 'nb': 3,
  14733. 'nd': 3,
  14734. 'ne': 3,
  14735. 'nl': 3,
  14736. 'nn': 3,
  14737. 'no': 3,
  14738. 'nr': 3,
  14739. 'nso': 4,
  14740. 'ny': 3,
  14741. 'nyn': 3,
  14742. 'om': 3,
  14743. 'or': 3,
  14744. 'pa': 3,
  14745. 'pap': 3,
  14746. 'pl': 13,
  14747. 'ps': 3,
  14748. 'pt': 3,
  14749. 'rm': 3,
  14750. 'ro': 9,
  14751. 'rof': 3,
  14752. 'ru': 11,
  14753. 'rwk': 3,
  14754. 'sah': 0,
  14755. 'saq': 3,
  14756. 'se': 7,
  14757. 'seh': 3,
  14758. 'ses': 0,
  14759. 'sg': 0,
  14760. 'sh': 11,
  14761. 'shi': 19,
  14762. 'sk': 12,
  14763. 'sl': 14,
  14764. 'sma': 7,
  14765. 'smi': 7,
  14766. 'smj': 7,
  14767. 'smn': 7,
  14768. 'sms': 7,
  14769. 'sn': 3,
  14770. 'so': 3,
  14771. 'sq': 3,
  14772. 'sr': 11,
  14773. 'ss': 3,
  14774. 'ssy': 3,
  14775. 'st': 3,
  14776. 'sv': 3,
  14777. 'sw': 3,
  14778. 'syr': 3,
  14779. 'ta': 3,
  14780. 'te': 3,
  14781. 'teo': 3,
  14782. 'th': 0,
  14783. 'ti': 4,
  14784. 'tig': 3,
  14785. 'tk': 3,
  14786. 'tl': 4,
  14787. 'tn': 3,
  14788. 'to': 0,
  14789. 'tr': 0,
  14790. 'ts': 3,
  14791. 'tzm': 22,
  14792. 'uk': 11,
  14793. 'ur': 3,
  14794. 've': 3,
  14795. 'vi': 0,
  14796. 'vun': 3,
  14797. 'wa': 4,
  14798. 'wae': 3,
  14799. 'wo': 0,
  14800. 'xh': 3,
  14801. 'xog': 3,
  14802. 'yo': 0,
  14803. 'zh': 0,
  14804. 'zu': 3
  14805. };
  14806. function isIn(n, list) {
  14807. return list.indexOf(n) !== -1;
  14808. }
  14809. function isBetween(n, start, end) {
  14810. return start <= n && n <= end;
  14811. }
  14812. var pluralRules = {
  14813. '0': function _(n) {
  14814. return 'other';
  14815. },
  14816. '1': function _(n) {
  14817. if (isBetween(n % 100, 3, 10)) return 'few';
  14818. if (n === 0) return 'zero';
  14819. if (isBetween(n % 100, 11, 99)) return 'many';
  14820. if (n == 2) return 'two';
  14821. if (n == 1) return 'one';
  14822. return 'other';
  14823. },
  14824. '2': function _(n) {
  14825. if (n !== 0 && n % 10 === 0) return 'many';
  14826. if (n == 2) return 'two';
  14827. if (n == 1) return 'one';
  14828. return 'other';
  14829. },
  14830. '3': function _(n) {
  14831. if (n == 1) return 'one';
  14832. return 'other';
  14833. },
  14834. '4': function _(n) {
  14835. if (isBetween(n, 0, 1)) return 'one';
  14836. return 'other';
  14837. },
  14838. '5': function _(n) {
  14839. if (isBetween(n, 0, 2) && n != 2) return 'one';
  14840. return 'other';
  14841. },
  14842. '6': function _(n) {
  14843. if (n === 0) return 'zero';
  14844. if (n % 10 == 1 && n % 100 != 11) return 'one';
  14845. return 'other';
  14846. },
  14847. '7': function _(n) {
  14848. if (n == 2) return 'two';
  14849. if (n == 1) return 'one';
  14850. return 'other';
  14851. },
  14852. '8': function _(n) {
  14853. if (isBetween(n, 3, 6)) return 'few';
  14854. if (isBetween(n, 7, 10)) return 'many';
  14855. if (n == 2) return 'two';
  14856. if (n == 1) return 'one';
  14857. return 'other';
  14858. },
  14859. '9': function _(n) {
  14860. if (n === 0 || n != 1 && isBetween(n % 100, 1, 19)) return 'few';
  14861. if (n == 1) return 'one';
  14862. return 'other';
  14863. },
  14864. '10': function _(n) {
  14865. if (isBetween(n % 10, 2, 9) && !isBetween(n % 100, 11, 19)) return 'few';
  14866. if (n % 10 == 1 && !isBetween(n % 100, 11, 19)) return 'one';
  14867. return 'other';
  14868. },
  14869. '11': function _(n) {
  14870. if (isBetween(n % 10, 2, 4) && !isBetween(n % 100, 12, 14)) return 'few';
  14871. if (n % 10 === 0 || isBetween(n % 10, 5, 9) || isBetween(n % 100, 11, 14))
  14872. return 'many';
  14873. if (n % 10 == 1 && n % 100 != 11) return 'one';
  14874. return 'other';
  14875. },
  14876. '12': function _(n) {
  14877. if (isBetween(n, 2, 4)) return 'few';
  14878. if (n == 1) return 'one';
  14879. return 'other';
  14880. },
  14881. '13': function _(n) {
  14882. if (isBetween(n % 10, 2, 4) && !isBetween(n % 100, 12, 14)) return 'few';
  14883. if (n != 1 && isBetween(n % 10, 0, 1) || isBetween(n % 10, 5, 9) ||
  14884. isBetween(n % 100, 12, 14)) return 'many';
  14885. if (n == 1) return 'one';
  14886. return 'other';
  14887. },
  14888. '14': function _(n) {
  14889. if (isBetween(n % 100, 3, 4)) return 'few';
  14890. if (n % 100 == 2) return 'two';
  14891. if (n % 100 == 1) return 'one';
  14892. return 'other';
  14893. },
  14894. '15': function _(n) {
  14895. if (n === 0 || isBetween(n % 100, 2, 10)) return 'few';
  14896. if (isBetween(n % 100, 11, 19)) return 'many';
  14897. if (n == 1) return 'one';
  14898. return 'other';
  14899. },
  14900. '16': function _(n) {
  14901. if (n % 10 == 1 && n != 11) return 'one';
  14902. return 'other';
  14903. },
  14904. '17': function _(n) {
  14905. if (n == 3) return 'few';
  14906. if (n === 0) return 'zero';
  14907. if (n == 6) return 'many';
  14908. if (n == 2) return 'two';
  14909. if (n == 1) return 'one';
  14910. return 'other';
  14911. },
  14912. '18': function _(n) {
  14913. if (n === 0) return 'zero';
  14914. if (isBetween(n, 0, 2) && n !== 0 && n != 2) return 'one';
  14915. return 'other';
  14916. },
  14917. '19': function _(n) {
  14918. if (isBetween(n, 2, 10)) return 'few';
  14919. if (isBetween(n, 0, 1)) return 'one';
  14920. return 'other';
  14921. },
  14922. '20': function _(n) {
  14923. if ((isBetween(n % 10, 3, 4) || n % 10 == 9) && !(isBetween(n % 100, 10,
  14924. 19) || isBetween(n % 100, 70, 79) || isBetween(n % 100, 90, 99)))
  14925. return 'few';
  14926. if (n % 1000000 === 0 && n !== 0) return 'many';
  14927. if (n % 10 == 2 && !isIn(n % 100, [12, 72, 92])) return 'two';
  14928. if (n % 10 == 1 && !isIn(n % 100, [11, 71, 91])) return 'one';
  14929. return 'other';
  14930. },
  14931. '21': function _(n) {
  14932. if (n === 0) return 'zero';
  14933. if (n == 1) return 'one';
  14934. return 'other';
  14935. },
  14936. '22': function _(n) {
  14937. if (isBetween(n, 0, 1) || isBetween(n, 11, 99)) return 'one';
  14938. return 'other';
  14939. },
  14940. '23': function _(n) {
  14941. if (isBetween(n % 10, 1, 2) || n % 20 === 0) return 'one';
  14942. return 'other';
  14943. },
  14944. '24': function _(n) {
  14945. if (isBetween(n, 3, 10) || isBetween(n, 13, 19)) return 'few';
  14946. if (isIn(n, [2, 12])) return 'two';
  14947. if (isIn(n, [1, 11])) return 'one';
  14948. return 'other';
  14949. }
  14950. };
  14951. var index = locales2rules[lang.replace(/-.*$/, '')];
  14952. if (!(index in pluralRules)) {
  14953. console.warn('plural form unknown for [' + lang + ']');
  14954. return function() {
  14955. return 'other';
  14956. };
  14957. }
  14958. return pluralRules[index];
  14959. }
  14960. gMacros.plural = function(str, param, key, prop) {
  14961. var n = parseFloat(param);
  14962. if (isNaN(n)) return str;
  14963. if (prop != gTextProp) return str;
  14964. if (!gMacros._pluralRules) {
  14965. gMacros._pluralRules = getPluralRules(gLanguage);
  14966. }
  14967. var index = '[' + gMacros._pluralRules(n) + ']';
  14968. if (n === 0 && key + '[zero]' in gL10nData) {
  14969. str = gL10nData[key + '[zero]'][prop];
  14970. } else if (n == 1 && key + '[one]' in gL10nData) {
  14971. str = gL10nData[key + '[one]'][prop];
  14972. } else if (n == 2 && key + '[two]' in gL10nData) {
  14973. str = gL10nData[key + '[two]'][prop];
  14974. } else if (key + index in gL10nData) {
  14975. str = gL10nData[key + index][prop];
  14976. } else if (key + '[other]' in gL10nData) {
  14977. str = gL10nData[key + '[other]'][prop];
  14978. }
  14979. return str;
  14980. };
  14981. function getL10nData(key, args, fallback) {
  14982. var data = gL10nData[key];
  14983. if (!data) {
  14984. // console.warn('#' + key + ' is undefined.');
  14985. if (!fallback) {
  14986. return null;
  14987. }
  14988. data = fallback;
  14989. }
  14990. var rv = {};
  14991. for (var prop in data) {
  14992. var str = data[prop];
  14993. str = substIndexes(str, args, key, prop);
  14994. str = substArguments(str, args, key);
  14995. rv[prop] = str;
  14996. }
  14997. return rv;
  14998. }
  14999. function substIndexes(str, args, key, prop) {
  15000. var reIndex = /\{\[\s*([a-zA-Z]+)\(([a-zA-Z]+)\)\s*\]\}/;
  15001. var reMatch = reIndex.exec(str);
  15002. if (!reMatch || !reMatch.length) return str;
  15003. var macroName = reMatch[1];
  15004. var paramName = reMatch[2];
  15005. var param;
  15006. if (args && paramName in args) {
  15007. param = args[paramName];
  15008. } else if (paramName in gL10nData) {
  15009. param = gL10nData[paramName];
  15010. }
  15011. if (macroName in gMacros) {
  15012. var macro = gMacros[macroName];
  15013. str = macro(str, param, key, prop);
  15014. }
  15015. return str;
  15016. }
  15017. function substArguments(str, args, key) {
  15018. var reArgs = /\{\{\s*(.+?)\s*\}\}/g;
  15019. return str.replace(reArgs, function(matched_text, arg) {
  15020. if (args && arg in args) {
  15021. return args[arg];
  15022. }
  15023. if (arg in gL10nData) {
  15024. return gL10nData[arg];
  15025. }
  15026. console.log('argument {{' + arg + '}} for #' + key + ' is undefined.');
  15027. return matched_text;
  15028. });
  15029. }
  15030. function translateElement(element) {
  15031. var l10n = getL10nAttributes(element);
  15032. if (!l10n.id) return;
  15033. var data = getL10nData(l10n.id, l10n.args);
  15034. if (!data) {
  15035. // console.warn('#' + l10n.id + ' is undefined.');
  15036. return;
  15037. }
  15038. if (data[gTextProp]) {
  15039. if (getChildElementCount(element) === 0) {
  15040. element[gTextProp] = data[gTextProp];
  15041. } else {
  15042. var children = element.childNodes;
  15043. var found = false;
  15044. for (var i = 0, l = children.length; i < l; i++) {
  15045. if (children[i].nodeType === 3 && /\S/.test(children[i].nodeValue)) {
  15046. if (found) {
  15047. children[i].nodeValue = '';
  15048. } else {
  15049. children[i].nodeValue = data[gTextProp];
  15050. found = true;
  15051. }
  15052. }
  15053. }
  15054. if (!found) {
  15055. var textNode = document.createTextNode(data[gTextProp]);
  15056. element.insertBefore(textNode, element.firstChild);
  15057. }
  15058. }
  15059. delete data[gTextProp];
  15060. }
  15061. for (var k in data) {
  15062. element[k] = data[k];
  15063. }
  15064. }
  15065. function getChildElementCount(element) {
  15066. if (element.children) {
  15067. return element.children.length;
  15068. }
  15069. if (typeof element.childElementCount !== 'undefined') {
  15070. return element.childElementCount;
  15071. }
  15072. var count = 0;
  15073. for (var i = 0; i < element.childNodes.length; i++) {
  15074. count += element.nodeType === 1 ? 1 : 0;
  15075. }
  15076. return count;
  15077. }
  15078. function translateFragment(element) {
  15079. element = element || document.documentElement;
  15080. var children = getTranslatableChildren(element);
  15081. var elementCount = children.length;
  15082. for (var i = 0; i < elementCount; i++) {
  15083. translateElement(children[i]);
  15084. }
  15085. translateElement(element);
  15086. }
  15087. return {
  15088. get: function get(key, args, fallbackString) {
  15089. var index = key.lastIndexOf('.');
  15090. var prop = gTextProp;
  15091. if (index > 0) {
  15092. prop = key.substring(index + 1);
  15093. key = key.substring(0, index);
  15094. }
  15095. var fallback;
  15096. if (fallbackString) {
  15097. fallback = {};
  15098. fallback[prop] = fallbackString;
  15099. }
  15100. var data = getL10nData(key, args, fallback);
  15101. if (data && prop in data) {
  15102. return data[prop];
  15103. }
  15104. return '{{' + key + '}}';
  15105. },
  15106. getData: function getData() {
  15107. return gL10nData;
  15108. },
  15109. getText: function getText() {
  15110. return gTextData;
  15111. },
  15112. getLanguage: function getLanguage() {
  15113. return gLanguage;
  15114. },
  15115. setLanguage: function setLanguage(lang, callback) {
  15116. loadLocale(lang, function() {
  15117. if (callback) callback();
  15118. });
  15119. },
  15120. getDirection: function getDirection() {
  15121. var rtlList = ['ar', 'he', 'fa', 'ps', 'ur'];
  15122. var shortCode = gLanguage.split('-', 1)[0];
  15123. return rtlList.indexOf(shortCode) >= 0 ? 'rtl' : 'ltr';
  15124. },
  15125. translate: translateFragment,
  15126. getReadyState: function getReadyState() {
  15127. return gReadyState;
  15128. },
  15129. ready: function ready(callback) {
  15130. if (!callback) {
  15131. return;
  15132. } else if (gReadyState == 'complete' || gReadyState == 'interactive') {
  15133. window.setTimeout(function() {
  15134. callback();
  15135. });
  15136. } else if (document.addEventListener) {
  15137. document.addEventListener('localized', function once() {
  15138. document.removeEventListener('localized', once);
  15139. callback();
  15140. });
  15141. }
  15142. }
  15143. };
  15144. }(window, document);
  15145. /***/
  15146. }),
  15147. /* 41 */
  15148. /***/
  15149. (function(module, exports, __webpack_require__) {
  15150. "use strict";
  15151. Object.defineProperty(exports, "__esModule", {
  15152. value: true
  15153. });
  15154. exports.PDFPrintService = PDFPrintService;
  15155. var _ui_utils = __webpack_require__(5);
  15156. var _app = __webpack_require__(1);
  15157. var _app_options = __webpack_require__(6);
  15158. var activeService = null;
  15159. var overlayManager = null;
  15160. function renderPage(activeServiceOnEntry, pdfDocument, pageNumber, size) {
  15161. var scratchCanvas = activeService.scratchCanvas;
  15162. var PRINT_RESOLUTION = _app_options.AppOptions.get('printResolution') || 150;
  15163. var PRINT_UNITS = PRINT_RESOLUTION / 72.0;
  15164. scratchCanvas.width = Math.floor(size.width * PRINT_UNITS);
  15165. scratchCanvas.height = Math.floor(size.height * PRINT_UNITS);
  15166. var width = Math.floor(size.width * _ui_utils.CSS_UNITS) + 'px';
  15167. var height = Math.floor(size.height * _ui_utils.CSS_UNITS) + 'px';
  15168. var ctx = scratchCanvas.getContext('2d');
  15169. ctx.save();
  15170. ctx.fillStyle = 'rgb(255, 255, 255)';
  15171. ctx.fillRect(0, 0, scratchCanvas.width, scratchCanvas.height);
  15172. ctx.restore();
  15173. return pdfDocument.getPage(pageNumber).then(function(pdfPage) {
  15174. var renderContext = {
  15175. canvasContext: ctx,
  15176. transform: [PRINT_UNITS, 0, 0, PRINT_UNITS, 0, 0],
  15177. viewport: pdfPage.getViewport({
  15178. scale: 1,
  15179. rotation: size.rotation
  15180. }),
  15181. intent: 'print'
  15182. };
  15183. return pdfPage.render(renderContext).promise;
  15184. }).then(function() {
  15185. return {
  15186. width: width,
  15187. height: height
  15188. };
  15189. });
  15190. }
  15191. function PDFPrintService(pdfDocument, pagesOverview, printContainer, l10n) {
  15192. this.pdfDocument = pdfDocument;
  15193. this.pagesOverview = pagesOverview;
  15194. this.printContainer = printContainer;
  15195. this.l10n = l10n || _ui_utils.NullL10n;
  15196. this.disableCreateObjectURL = pdfDocument.loadingParams['disableCreateObjectURL'];
  15197. this.currentPage = -1;
  15198. this.scratchCanvas = document.createElement('canvas');
  15199. }
  15200. PDFPrintService.prototype = {
  15201. layout: function layout() {
  15202. this.throwIfInactive();
  15203. var body = document.querySelector('body');
  15204. body.setAttribute('data-pdfjsprinting', true);
  15205. var hasEqualPageSizes = this.pagesOverview.every(function(size) {
  15206. return size.width === this.pagesOverview[0].width && size.height === this
  15207. .pagesOverview[0].height;
  15208. }, this);
  15209. if (!hasEqualPageSizes) {
  15210. console.warn('Not all pages have the same size. The printed ' +
  15211. 'result may be incorrect!');
  15212. }
  15213. this.pageStyleSheet = document.createElement('style');
  15214. var pageSize = this.pagesOverview[0];
  15215. this.pageStyleSheet.textContent = '@supports ((size:A4) and (size:1pt 1pt)) {' +
  15216. '@page { size: ' + pageSize.width + 'pt ' + pageSize.height + 'pt;}' + '}';
  15217. body.appendChild(this.pageStyleSheet);
  15218. },
  15219. destroy: function destroy() {
  15220. if (activeService !== this) {
  15221. return;
  15222. }
  15223. this.printContainer.textContent = '';
  15224. var body = document.querySelector('body');
  15225. body.removeAttribute('data-pdfjsprinting');
  15226. if (this.pageStyleSheet) {
  15227. this.pageStyleSheet.remove();
  15228. this.pageStyleSheet = null;
  15229. }
  15230. this.scratchCanvas.width = this.scratchCanvas.height = 0;
  15231. this.scratchCanvas = null;
  15232. activeService = null;
  15233. ensureOverlay().then(function() {
  15234. if (overlayManager.active !== 'printServiceOverlay') {
  15235. return;
  15236. }
  15237. overlayManager.close('printServiceOverlay');
  15238. });
  15239. },
  15240. renderPages: function renderPages() {
  15241. var _this = this;
  15242. var pageCount = this.pagesOverview.length;
  15243. var renderNextPage = function renderNextPage(resolve, reject) {
  15244. _this.throwIfInactive();
  15245. if (++_this.currentPage >= pageCount) {
  15246. renderProgress(pageCount, pageCount, _this.l10n);
  15247. resolve();
  15248. return;
  15249. }
  15250. var index = _this.currentPage;
  15251. renderProgress(index, pageCount, _this.l10n);
  15252. renderPage(_this, _this.pdfDocument, index + 1, _this.pagesOverview[index])
  15253. .then(_this.useRenderedPage.bind(_this)).then(function() {
  15254. renderNextPage(resolve, reject);
  15255. }, reject);
  15256. };
  15257. return new Promise(renderNextPage);
  15258. },
  15259. useRenderedPage: function useRenderedPage(printItem) {
  15260. this.throwIfInactive();
  15261. var img = document.createElement('img');
  15262. img.style.width = printItem.width;
  15263. img.style.height = printItem.height;
  15264. var scratchCanvas = this.scratchCanvas;
  15265. if ('toBlob' in scratchCanvas && !this.disableCreateObjectURL) {
  15266. scratchCanvas.toBlob(function(blob) {
  15267. img.src = URL.createObjectURL(blob);
  15268. });
  15269. } else {
  15270. img.src = scratchCanvas.toDataURL();
  15271. }
  15272. var wrapper = document.createElement('div');
  15273. wrapper.appendChild(img);
  15274. this.printContainer.appendChild(wrapper);
  15275. return new Promise(function(resolve, reject) {
  15276. img.onload = resolve;
  15277. img.onerror = reject;
  15278. });
  15279. },
  15280. performPrint: function performPrint() {
  15281. var _this2 = this;
  15282. this.throwIfInactive();
  15283. return new Promise(function(resolve) {
  15284. setTimeout(function() {
  15285. if (!_this2.active) {
  15286. resolve();
  15287. return;
  15288. }
  15289. print.call(window);
  15290. setTimeout(resolve, 20);
  15291. }, 0);
  15292. });
  15293. },
  15294. get active() {
  15295. return this === activeService;
  15296. },
  15297. throwIfInactive: function throwIfInactive() {
  15298. if (!this.active) {
  15299. throw new Error('This print request was cancelled or completed.');
  15300. }
  15301. }
  15302. };
  15303. var print = window.print;
  15304. window.print = function print() {
  15305. if (activeService) {
  15306. console.warn('Ignored window.print() because of a pending print job.');
  15307. return;
  15308. }
  15309. ensureOverlay().then(function() {
  15310. if (activeService) {
  15311. overlayManager.open('printServiceOverlay');
  15312. }
  15313. });
  15314. try {
  15315. dispatchEvent('beforeprint');
  15316. } finally {
  15317. if (!activeService) {
  15318. console.error('Expected print service to be initialized.');
  15319. ensureOverlay().then(function() {
  15320. if (overlayManager.active === 'printServiceOverlay') {
  15321. overlayManager.close('printServiceOverlay');
  15322. }
  15323. });
  15324. return;
  15325. }
  15326. var activeServiceOnEntry = activeService;
  15327. activeService.renderPages().then(function() {
  15328. return activeServiceOnEntry.performPrint();
  15329. })["catch"](function() {}).then(function() {
  15330. if (activeServiceOnEntry.active) {
  15331. abort();
  15332. }
  15333. });
  15334. }
  15335. };
  15336. function dispatchEvent(eventType) {
  15337. var event = document.createEvent('CustomEvent');
  15338. event.initCustomEvent(eventType, false, false, 'custom');
  15339. window.dispatchEvent(event);
  15340. }
  15341. function abort() {
  15342. if (activeService) {
  15343. activeService.destroy();
  15344. dispatchEvent('afterprint');
  15345. }
  15346. }
  15347. function renderProgress(index, total, l10n) {
  15348. var progressContainer = document.getElementById('printServiceOverlay');
  15349. var progress = Math.round(100 * index / total);
  15350. var progressBar = progressContainer.querySelector('progress');
  15351. var progressPerc = progressContainer.querySelector('.relative-progress');
  15352. progressBar.value = progress;
  15353. l10n.get('print_progress_percent', {
  15354. progress: progress
  15355. }, progress + '%').then(function(msg) {
  15356. progressPerc.textContent = msg;
  15357. });
  15358. }
  15359. var hasAttachEvent = !!document.attachEvent;
  15360. window.addEventListener('keydown', function(event) {
  15361. if (event.keyCode === 80 && (event.ctrlKey || event.metaKey) && !event.altKey && (!event
  15362. .shiftKey || window.chrome || window.opera)) {
  15363. window.print();
  15364. if (hasAttachEvent) {
  15365. return;
  15366. }
  15367. event.preventDefault();
  15368. if (event.stopImmediatePropagation) {
  15369. event.stopImmediatePropagation();
  15370. } else {
  15371. event.stopPropagation();
  15372. }
  15373. }
  15374. }, true);
  15375. if (hasAttachEvent) {
  15376. document.attachEvent('onkeydown', function(event) {
  15377. event = event || window.event;
  15378. if (event.keyCode === 80 && event.ctrlKey) {
  15379. event.keyCode = 0;
  15380. return false;
  15381. }
  15382. });
  15383. }
  15384. if ('onbeforeprint' in window) {
  15385. var stopPropagationIfNeeded = function stopPropagationIfNeeded(event) {
  15386. if (event.detail !== 'custom' && event.stopImmediatePropagation) {
  15387. event.stopImmediatePropagation();
  15388. }
  15389. };
  15390. window.addEventListener('beforeprint', stopPropagationIfNeeded);
  15391. window.addEventListener('afterprint', stopPropagationIfNeeded);
  15392. }
  15393. var overlayPromise;
  15394. function ensureOverlay() {
  15395. if (!overlayPromise) {
  15396. overlayManager = _app.PDFViewerApplication.overlayManager;
  15397. if (!overlayManager) {
  15398. throw new Error('The overlay manager has not yet been initialized.');
  15399. }
  15400. overlayPromise = overlayManager.register('printServiceOverlay', document.getElementById(
  15401. 'printServiceOverlay'), abort, true);
  15402. document.getElementById('printCancel').onclick = abort;
  15403. }
  15404. return overlayPromise;
  15405. }
  15406. _app.PDFPrintServiceFactory.instance = {
  15407. supportsPrinting: true,
  15408. createPrintService: function createPrintService(pdfDocument, pagesOverview, printContainer,
  15409. l10n) {
  15410. if (activeService) {
  15411. throw new Error('The print service is created and active.');
  15412. }
  15413. activeService = new PDFPrintService(pdfDocument, pagesOverview, printContainer, l10n);
  15414. return activeService;
  15415. }
  15416. };
  15417. /***/
  15418. })
  15419. /******/
  15420. ]);
  15421. //# sourceMappingURL=viewer.js.map