viewer.js 536 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219
  1. /**
  2. * @licstart The following is the entire license notice for the
  3. * Javascript code in this page
  4. *
  5. * Copyright 2020 Mozilla Foundation
  6. *
  7. * Licensed under the Apache License, Version 2.0 (the "License");
  8. * you may not use this file except in compliance with the License.
  9. * You may obtain a copy of the License at
  10. *
  11. * http://www.apache.org/licenses/LICENSE-2.0
  12. *
  13. * Unless required by applicable law or agreed to in writing, software
  14. * distributed under the License is distributed on an "AS IS" BASIS,
  15. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  16. * See the License for the specific language governing permissions and
  17. * limitations under the License.
  18. *
  19. * @licend The above is the entire license notice for the
  20. * Javascript code in this page
  21. */
  22. /******/ (function(modules) { // webpackBootstrap
  23. /******/ // The module cache
  24. /******/ var installedModules = {};
  25. /******/
  26. /******/ // The require function
  27. /******/ function __webpack_require__(moduleId) {
  28. /******/
  29. /******/ // Check if module is in cache
  30. /******/ if(installedModules[moduleId]) {
  31. /******/ return installedModules[moduleId].exports;
  32. /******/ }
  33. /******/ // Create a new module (and put it into the cache)
  34. /******/ var module = installedModules[moduleId] = {
  35. /******/ i: moduleId,
  36. /******/ l: false,
  37. /******/ exports: {}
  38. /******/ };
  39. /******/
  40. /******/ // Execute the module function
  41. /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  42. /******/
  43. /******/ // Flag the module as loaded
  44. /******/ module.l = true;
  45. /******/
  46. /******/ // Return the exports of the module
  47. /******/ return module.exports;
  48. /******/ }
  49. /******/
  50. /******/
  51. /******/ // expose the modules object (__webpack_modules__)
  52. /******/ __webpack_require__.m = modules;
  53. /******/
  54. /******/ // expose the module cache
  55. /******/ __webpack_require__.c = installedModules;
  56. /******/
  57. /******/ // define getter function for harmony exports
  58. /******/ __webpack_require__.d = function(exports, name, getter) {
  59. /******/ if(!__webpack_require__.o(exports, name)) {
  60. /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
  61. /******/ }
  62. /******/ };
  63. /******/
  64. /******/ // define __esModule on exports
  65. /******/ __webpack_require__.r = function(exports) {
  66. /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
  67. /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
  68. /******/ }
  69. /******/ Object.defineProperty(exports, '__esModule', { value: true });
  70. /******/ };
  71. /******/
  72. /******/ // create a fake namespace object
  73. /******/ // mode & 1: value is a module id, require it
  74. /******/ // mode & 2: merge all properties of value into the ns
  75. /******/ // mode & 4: return value when already ns object
  76. /******/ // mode & 8|1: behave like require
  77. /******/ __webpack_require__.t = function(value, mode) {
  78. /******/ if(mode & 1) value = __webpack_require__(value);
  79. /******/ if(mode & 8) return value;
  80. /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
  81. /******/ var ns = Object.create(null);
  82. /******/ __webpack_require__.r(ns);
  83. /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
  84. /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
  85. /******/ return ns;
  86. /******/ };
  87. /******/
  88. /******/ // getDefaultExport function for compatibility with non-harmony modules
  89. /******/ __webpack_require__.n = function(module) {
  90. /******/ var getter = module && module.__esModule ?
  91. /******/ function getDefault() { return module['default']; } :
  92. /******/ function getModuleExports() { return module; };
  93. /******/ __webpack_require__.d(getter, 'a', getter);
  94. /******/ return getter;
  95. /******/ };
  96. /******/
  97. /******/ // Object.prototype.hasOwnProperty.call
  98. /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
  99. /******/
  100. /******/ // __webpack_public_path__
  101. /******/ __webpack_require__.p = "";
  102. /******/
  103. /******/
  104. /******/ // Load entry module and return exports
  105. /******/ return __webpack_require__(__webpack_require__.s = 0);
  106. /******/ })
  107. /************************************************************************/
  108. /******/ ([
  109. /* 0 */
  110. /***/ (function(module, exports, __webpack_require__) {
  111. "use strict";
  112. ;
  113. var pdfjsWebApp, pdfjsWebAppOptions;
  114. {
  115. pdfjsWebApp = __webpack_require__(1);
  116. pdfjsWebAppOptions = __webpack_require__(6);
  117. }
  118. ;
  119. {
  120. __webpack_require__(38);
  121. }
  122. ;
  123. {
  124. __webpack_require__(43);
  125. }
  126. function getViewerConfiguration() {
  127. return {
  128. appContainer: document.body,
  129. mainContainer: document.getElementById("viewerContainer"),
  130. viewerContainer: document.getElementById("viewer"),
  131. eventBus: null,
  132. toolbar: {
  133. container: document.getElementById("toolbarViewer"),
  134. numPages: document.getElementById("numPages"),
  135. pageNumber: document.getElementById("pageNumber"),
  136. scaleSelectContainer: document.getElementById("scaleSelectContainer"),
  137. scaleSelect: document.getElementById("scaleSelect"),
  138. customScaleOption: document.getElementById("customScaleOption"),
  139. previous: document.getElementById("previous"),
  140. next: document.getElementById("next"),
  141. zoomIn: document.getElementById("zoomIn"),
  142. zoomOut: document.getElementById("zoomOut"),
  143. viewFind: document.getElementById("viewFind"),
  144. openFile: document.getElementById("openFile"),
  145. print: document.getElementById("print"),
  146. presentationModeButton: document.getElementById("presentationMode"),
  147. download: document.getElementById("download"),
  148. viewBookmark: document.getElementById("viewBookmark")
  149. },
  150. secondaryToolbar: {
  151. toolbar: document.getElementById("secondaryToolbar"),
  152. toggleButton: document.getElementById("secondaryToolbarToggle"),
  153. toolbarButtonContainer: document.getElementById("secondaryToolbarButtonContainer"),
  154. presentationModeButton: document.getElementById("secondaryPresentationMode"),
  155. openFileButton: document.getElementById("secondaryOpenFile"),
  156. printButton: document.getElementById("secondaryPrint"),
  157. downloadButton: document.getElementById("secondaryDownload"),
  158. viewBookmarkButton: document.getElementById("secondaryViewBookmark"),
  159. firstPageButton: document.getElementById("firstPage"),
  160. lastPageButton: document.getElementById("lastPage"),
  161. pageRotateCwButton: document.getElementById("pageRotateCw"),
  162. pageRotateCcwButton: document.getElementById("pageRotateCcw"),
  163. cursorSelectToolButton: document.getElementById("cursorSelectTool"),
  164. cursorHandToolButton: document.getElementById("cursorHandTool"),
  165. scrollVerticalButton: document.getElementById("scrollVertical"),
  166. scrollHorizontalButton: document.getElementById("scrollHorizontal"),
  167. scrollWrappedButton: document.getElementById("scrollWrapped"),
  168. spreadNoneButton: document.getElementById("spreadNone"),
  169. spreadOddButton: document.getElementById("spreadOdd"),
  170. spreadEvenButton: document.getElementById("spreadEven"),
  171. documentPropertiesButton: document.getElementById("documentProperties")
  172. },
  173. fullscreen: {
  174. contextFirstPage: document.getElementById("contextFirstPage"),
  175. contextLastPage: document.getElementById("contextLastPage"),
  176. contextPageRotateCw: document.getElementById("contextPageRotateCw"),
  177. contextPageRotateCcw: document.getElementById("contextPageRotateCcw")
  178. },
  179. sidebar: {
  180. outerContainer: document.getElementById("outerContainer"),
  181. viewerContainer: document.getElementById("viewerContainer"),
  182. toggleButton: document.getElementById("sidebarToggle"),
  183. thumbnailButton: document.getElementById("viewThumbnail"),
  184. outlineButton: document.getElementById("viewOutline"),
  185. attachmentsButton: document.getElementById("viewAttachments"),
  186. layersButton: document.getElementById("viewLayers"),
  187. thumbnailView: document.getElementById("thumbnailView"),
  188. outlineView: document.getElementById("outlineView"),
  189. attachmentsView: document.getElementById("attachmentsView"),
  190. layersView: document.getElementById("layersView")
  191. },
  192. sidebarResizer: {
  193. outerContainer: document.getElementById("outerContainer"),
  194. resizer: document.getElementById("sidebarResizer")
  195. },
  196. findBar: {
  197. bar: document.getElementById("findbar"),
  198. toggleButton: document.getElementById("viewFind"),
  199. findField: document.getElementById("findInput"),
  200. highlightAllCheckbox: document.getElementById("findHighlightAll"),
  201. caseSensitiveCheckbox: document.getElementById("findMatchCase"),
  202. entireWordCheckbox: document.getElementById("findEntireWord"),
  203. findMsg: document.getElementById("findMsg"),
  204. findResultsCount: document.getElementById("findResultsCount"),
  205. findPreviousButton: document.getElementById("findPrevious"),
  206. findNextButton: document.getElementById("findNext")
  207. },
  208. passwordOverlay: {
  209. overlayName: "passwordOverlay",
  210. container: document.getElementById("passwordOverlay"),
  211. label: document.getElementById("passwordText"),
  212. input: document.getElementById("password"),
  213. submitButton: document.getElementById("passwordSubmit"),
  214. cancelButton: document.getElementById("passwordCancel")
  215. },
  216. documentProperties: {
  217. overlayName: "documentPropertiesOverlay",
  218. container: document.getElementById("documentPropertiesOverlay"),
  219. closeButton: document.getElementById("documentPropertiesClose"),
  220. fields: {
  221. fileName: document.getElementById("fileNameField"),
  222. fileSize: document.getElementById("fileSizeField"),
  223. title: document.getElementById("titleField"),
  224. author: document.getElementById("authorField"),
  225. subject: document.getElementById("subjectField"),
  226. keywords: document.getElementById("keywordsField"),
  227. creationDate: document.getElementById("creationDateField"),
  228. modificationDate: document.getElementById("modificationDateField"),
  229. creator: document.getElementById("creatorField"),
  230. producer: document.getElementById("producerField"),
  231. version: document.getElementById("versionField"),
  232. pageCount: document.getElementById("pageCountField"),
  233. pageSize: document.getElementById("pageSizeField"),
  234. linearized: document.getElementById("linearizedField")
  235. }
  236. },
  237. errorWrapper: {
  238. container: document.getElementById("errorWrapper"),
  239. errorMessage: document.getElementById("errorMessage"),
  240. closeButton: document.getElementById("errorClose"),
  241. errorMoreInfo: document.getElementById("errorMoreInfo"),
  242. moreInfoButton: document.getElementById("errorShowMore"),
  243. lessInfoButton: document.getElementById("errorShowLess")
  244. },
  245. printContainer: document.getElementById("printContainer"),
  246. openFileInputName: "fileInput",
  247. debuggerScriptPath: "./debugger.js"
  248. };
  249. }
  250. function webViewerLoad() {
  251. var config = getViewerConfiguration();
  252. window.PDFViewerApplication = pdfjsWebApp.PDFViewerApplication;
  253. window.PDFViewerApplicationOptions = pdfjsWebAppOptions.AppOptions;
  254. var event = document.createEvent("CustomEvent");
  255. event.initCustomEvent("webviewerloaded", true, true, {
  256. source: window
  257. });
  258. try {
  259. parent.document.dispatchEvent(event);
  260. } catch (ex) {
  261. console.error("webviewerloaded: ".concat(ex));
  262. document.dispatchEvent(event);
  263. }
  264. pdfjsWebApp.PDFViewerApplication.run(config);
  265. }
  266. if (document.readyState === "interactive" || document.readyState === "complete") {
  267. webViewerLoad();
  268. } else {
  269. document.addEventListener("DOMContentLoaded", webViewerLoad, true);
  270. }
  271. /***/ }),
  272. /* 1 */
  273. /***/ (function(module, exports, __webpack_require__) {
  274. "use strict";
  275. Object.defineProperty(exports, "__esModule", {
  276. value: true
  277. });
  278. exports.PDFPrintServiceFactory = exports.DefaultExternalServices = exports.PDFViewerApplication = void 0;
  279. var _regenerator = _interopRequireDefault(__webpack_require__(2));
  280. var _ui_utils = __webpack_require__(5);
  281. var _app_options = __webpack_require__(6);
  282. var _pdfjsLib = __webpack_require__(8);
  283. var _pdf_cursor_tools = __webpack_require__(9);
  284. var _pdf_rendering_queue = __webpack_require__(11);
  285. var _pdf_sidebar = __webpack_require__(12);
  286. var _overlay_manager = __webpack_require__(13);
  287. var _password_prompt = __webpack_require__(14);
  288. var _pdf_attachment_viewer = __webpack_require__(15);
  289. var _pdf_document_properties = __webpack_require__(17);
  290. var _pdf_find_bar = __webpack_require__(18);
  291. var _pdf_find_controller = __webpack_require__(19);
  292. var _pdf_history = __webpack_require__(21);
  293. var _pdf_layer_viewer = __webpack_require__(22);
  294. var _pdf_link_service = __webpack_require__(23);
  295. var _pdf_outline_viewer = __webpack_require__(24);
  296. var _pdf_presentation_mode = __webpack_require__(25);
  297. var _pdf_sidebar_resizer = __webpack_require__(26);
  298. var _pdf_thumbnail_viewer = __webpack_require__(27);
  299. var _pdf_viewer = __webpack_require__(29);
  300. var _secondary_toolbar = __webpack_require__(34);
  301. var _toolbar = __webpack_require__(36);
  302. var _viewer_compatibility = __webpack_require__(7);
  303. var _view_history = __webpack_require__(37);
  304. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  305. function _createForOfIteratorHelper(o, allowArrayLike) { var it; if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e2) { throw _e2; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = o[Symbol.iterator](); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e3) { didErr = true; err = _e3; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
  306. function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
  307. function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
  308. function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
  309. function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
  310. function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
  311. function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
  312. function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
  313. function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
  314. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  315. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  316. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  317. var DEFAULT_SCALE_DELTA = 1.1;
  318. var DISABLE_AUTO_FETCH_LOADING_BAR_TIMEOUT = 5000;
  319. var FORCE_PAGES_LOADED_TIMEOUT = 10000;
  320. var WHEEL_ZOOM_DISABLED_TIMEOUT = 1000;
  321. var ENABLE_PERMISSIONS_CLASS = "enablePermissions";
  322. var ViewOnLoad = {
  323. UNKNOWN: -1,
  324. PREVIOUS: 0,
  325. INITIAL: 1
  326. };
  327. var KNOWN_VERSIONS = ["1.0", "1.1", "1.2", "1.3", "1.4", "1.5", "1.6", "1.7", "1.8", "1.9", "2.0", "2.1", "2.2", "2.3"];
  328. var KNOWN_GENERATORS = ["acrobat distiller", "acrobat pdfwriter", "adobe livecycle", "adobe pdf library", "adobe photoshop", "ghostscript", "tcpdf", "cairo", "dvipdfm", "dvips", "pdftex", "pdfkit", "itext", "prince", "quarkxpress", "mac os x", "microsoft", "openoffice", "oracle", "luradocument", "pdf-xchange", "antenna house", "aspose.cells", "fpdf"];
  329. var DefaultExternalServices = /*#__PURE__*/function () {
  330. function DefaultExternalServices() {
  331. _classCallCheck(this, DefaultExternalServices);
  332. throw new Error("Cannot initialize DefaultExternalServices.");
  333. }
  334. _createClass(DefaultExternalServices, null, [{
  335. key: "updateFindControlState",
  336. value: function updateFindControlState(data) {}
  337. }, {
  338. key: "updateFindMatchesCount",
  339. value: function updateFindMatchesCount(data) {}
  340. }, {
  341. key: "initPassiveLoading",
  342. value: function initPassiveLoading(callbacks) {}
  343. }, {
  344. key: "fallback",
  345. value: function fallback(data, callback) {}
  346. }, {
  347. key: "reportTelemetry",
  348. value: function reportTelemetry(data) {}
  349. }, {
  350. key: "createDownloadManager",
  351. value: function createDownloadManager(options) {
  352. throw new Error("Not implemented: createDownloadManager");
  353. }
  354. }, {
  355. key: "createPreferences",
  356. value: function createPreferences() {
  357. throw new Error("Not implemented: createPreferences");
  358. }
  359. }, {
  360. key: "createL10n",
  361. value: function createL10n(options) {
  362. throw new Error("Not implemented: createL10n");
  363. }
  364. }, {
  365. key: "supportsIntegratedFind",
  366. get: function get() {
  367. return (0, _pdfjsLib.shadow)(this, "supportsIntegratedFind", false);
  368. }
  369. }, {
  370. key: "supportsDocumentFonts",
  371. get: function get() {
  372. return (0, _pdfjsLib.shadow)(this, "supportsDocumentFonts", true);
  373. }
  374. }, {
  375. key: "supportedMouseWheelZoomModifierKeys",
  376. get: function get() {
  377. return (0, _pdfjsLib.shadow)(this, "supportedMouseWheelZoomModifierKeys", {
  378. ctrlKey: true,
  379. metaKey: true
  380. });
  381. }
  382. }, {
  383. key: "isInAutomation",
  384. get: function get() {
  385. return (0, _pdfjsLib.shadow)(this, "isInAutomation", false);
  386. }
  387. }]);
  388. return DefaultExternalServices;
  389. }();
  390. exports.DefaultExternalServices = DefaultExternalServices;
  391. var PDFViewerApplication = {
  392. initialBookmark: document.location.hash.substring(1),
  393. _initializedCapability: (0, _pdfjsLib.createPromiseCapability)(),
  394. fellback: false,
  395. appConfig: null,
  396. pdfDocument: null,
  397. pdfLoadingTask: null,
  398. printService: null,
  399. pdfViewer: null,
  400. pdfThumbnailViewer: null,
  401. pdfRenderingQueue: null,
  402. pdfPresentationMode: null,
  403. pdfDocumentProperties: null,
  404. pdfLinkService: null,
  405. pdfHistory: null,
  406. pdfSidebar: null,
  407. pdfSidebarResizer: null,
  408. pdfOutlineViewer: null,
  409. pdfAttachmentViewer: null,
  410. pdfLayerViewer: null,
  411. pdfCursorTools: null,
  412. store: null,
  413. downloadManager: null,
  414. overlayManager: null,
  415. preferences: null,
  416. toolbar: null,
  417. secondaryToolbar: null,
  418. eventBus: null,
  419. l10n: null,
  420. isInitialViewSet: false,
  421. downloadComplete: false,
  422. isViewerEmbedded: window.parent !== window,
  423. url: "",
  424. baseUrl: "",
  425. externalServices: DefaultExternalServices,
  426. _boundEvents: {},
  427. contentDispositionFilename: null,
  428. triggerDelayedFallback: null,
  429. _saveInProgress: false,
  430. _wheelUnusedTicks: 0,
  431. initialize: function initialize(appConfig) {
  432. var _this = this;
  433. return _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
  434. var appContainer;
  435. return _regenerator["default"].wrap(function _callee$(_context) {
  436. while (1) {
  437. switch (_context.prev = _context.next) {
  438. case 0:
  439. _this.preferences = _this.externalServices.createPreferences();
  440. _this.appConfig = appConfig;
  441. _context.next = 4;
  442. return _this._readPreferences();
  443. case 4:
  444. _context.next = 6;
  445. return _this._parseHashParameters();
  446. case 6:
  447. _context.next = 8;
  448. return _this._initializeL10n();
  449. case 8:
  450. if (_this.isViewerEmbedded && _app_options.AppOptions.get("externalLinkTarget") === _pdfjsLib.LinkTarget.NONE) {
  451. _app_options.AppOptions.set("externalLinkTarget", _pdfjsLib.LinkTarget.TOP);
  452. }
  453. _context.next = 11;
  454. return _this._initializeViewerComponents();
  455. case 11:
  456. _this.bindEvents();
  457. _this.bindWindowEvents();
  458. appContainer = appConfig.appContainer || document.documentElement;
  459. _this.l10n.translate(appContainer).then(function () {
  460. _this.eventBus.dispatch("localized", {
  461. source: _this
  462. });
  463. });
  464. _this._initializedCapability.resolve();
  465. case 16:
  466. case "end":
  467. return _context.stop();
  468. }
  469. }
  470. }, _callee);
  471. }))();
  472. },
  473. _readPreferences: function _readPreferences() {
  474. var _this2 = this;
  475. return _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee2() {
  476. var prefs, name;
  477. return _regenerator["default"].wrap(function _callee2$(_context2) {
  478. while (1) {
  479. switch (_context2.prev = _context2.next) {
  480. case 0:
  481. if (!_app_options.AppOptions.get("disablePreferences")) {
  482. _context2.next = 2;
  483. break;
  484. }
  485. return _context2.abrupt("return");
  486. case 2:
  487. _context2.prev = 2;
  488. _context2.next = 5;
  489. return _this2.preferences.getAll();
  490. case 5:
  491. prefs = _context2.sent;
  492. for (name in prefs) {
  493. _app_options.AppOptions.set(name, prefs[name]);
  494. }
  495. _context2.next = 12;
  496. break;
  497. case 9:
  498. _context2.prev = 9;
  499. _context2.t0 = _context2["catch"](2);
  500. console.error("_readPreferences: \"".concat(_context2.t0.message, "\"."));
  501. case 12:
  502. case "end":
  503. return _context2.stop();
  504. }
  505. }
  506. }, _callee2, null, [[2, 9]]);
  507. }))();
  508. },
  509. _parseHashParameters: function _parseHashParameters() {
  510. var _this3 = this;
  511. return _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee3() {
  512. var hash, hashParams, waitOn, viewer, enabled;
  513. return _regenerator["default"].wrap(function _callee3$(_context3) {
  514. while (1) {
  515. switch (_context3.prev = _context3.next) {
  516. case 0:
  517. if (_app_options.AppOptions.get("pdfBugEnabled")) {
  518. _context3.next = 2;
  519. break;
  520. }
  521. return _context3.abrupt("return", undefined);
  522. case 2:
  523. hash = document.location.hash.substring(1);
  524. if (hash) {
  525. _context3.next = 5;
  526. break;
  527. }
  528. return _context3.abrupt("return", undefined);
  529. case 5:
  530. hashParams = (0, _ui_utils.parseQueryString)(hash), waitOn = [];
  531. if ("disableworker" in hashParams && hashParams.disableworker === "true") {
  532. waitOn.push(loadFakeWorker());
  533. }
  534. if ("disablerange" in hashParams) {
  535. _app_options.AppOptions.set("disableRange", hashParams.disablerange === "true");
  536. }
  537. if ("disablestream" in hashParams) {
  538. _app_options.AppOptions.set("disableStream", hashParams.disablestream === "true");
  539. }
  540. if ("disableautofetch" in hashParams) {
  541. _app_options.AppOptions.set("disableAutoFetch", hashParams.disableautofetch === "true");
  542. }
  543. if ("disablefontface" in hashParams) {
  544. _app_options.AppOptions.set("disableFontFace", hashParams.disablefontface === "true");
  545. }
  546. if ("disablehistory" in hashParams) {
  547. _app_options.AppOptions.set("disableHistory", hashParams.disablehistory === "true");
  548. }
  549. if ("webgl" in hashParams) {
  550. _app_options.AppOptions.set("enableWebGL", hashParams.webgl === "true");
  551. }
  552. if ("verbosity" in hashParams) {
  553. _app_options.AppOptions.set("verbosity", hashParams.verbosity | 0);
  554. }
  555. if (!("textlayer" in hashParams)) {
  556. _context3.next = 23;
  557. break;
  558. }
  559. _context3.t0 = hashParams.textlayer;
  560. _context3.next = _context3.t0 === "off" ? 18 : _context3.t0 === "visible" ? 20 : _context3.t0 === "shadow" ? 20 : _context3.t0 === "hover" ? 20 : 23;
  561. break;
  562. case 18:
  563. _app_options.AppOptions.set("textLayerMode", _ui_utils.TextLayerMode.DISABLE);
  564. return _context3.abrupt("break", 23);
  565. case 20:
  566. viewer = _this3.appConfig.viewerContainer;
  567. viewer.classList.add("textLayer-" + hashParams.textlayer);
  568. return _context3.abrupt("break", 23);
  569. case 23:
  570. if ("pdfbug" in hashParams) {
  571. _app_options.AppOptions.set("pdfBug", true);
  572. _app_options.AppOptions.set("fontExtraProperties", true);
  573. enabled = hashParams.pdfbug.split(",");
  574. waitOn.push(loadAndEnablePDFBug(enabled));
  575. }
  576. if ("locale" in hashParams) {
  577. _app_options.AppOptions.set("locale", hashParams.locale);
  578. }
  579. return _context3.abrupt("return", Promise.all(waitOn)["catch"](function (reason) {
  580. console.error("_parseHashParameters: \"".concat(reason.message, "\"."));
  581. }));
  582. case 26:
  583. case "end":
  584. return _context3.stop();
  585. }
  586. }
  587. }, _callee3);
  588. }))();
  589. },
  590. _initializeL10n: function _initializeL10n() {
  591. var _this4 = this;
  592. return _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee4() {
  593. var dir;
  594. return _regenerator["default"].wrap(function _callee4$(_context4) {
  595. while (1) {
  596. switch (_context4.prev = _context4.next) {
  597. case 0:
  598. _this4.l10n = _this4.externalServices.createL10n({
  599. locale: _app_options.AppOptions.get("locale")
  600. });
  601. _context4.next = 3;
  602. return _this4.l10n.getDirection();
  603. case 3:
  604. dir = _context4.sent;
  605. document.getElementsByTagName("html")[0].dir = dir;
  606. case 5:
  607. case "end":
  608. return _context4.stop();
  609. }
  610. }
  611. }, _callee4);
  612. }))();
  613. },
  614. _initializeViewerComponents: function _initializeViewerComponents() {
  615. var _this5 = this;
  616. return _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee5() {
  617. var appConfig, eventBus, pdfRenderingQueue, pdfLinkService, downloadManager, findController, container, viewer;
  618. return _regenerator["default"].wrap(function _callee5$(_context5) {
  619. while (1) {
  620. switch (_context5.prev = _context5.next) {
  621. case 0:
  622. appConfig = _this5.appConfig;
  623. eventBus = appConfig.eventBus || new _ui_utils.EventBus({
  624. isInAutomation: _this5.externalServices.isInAutomation
  625. });
  626. _this5.eventBus = eventBus;
  627. _this5.overlayManager = new _overlay_manager.OverlayManager();
  628. pdfRenderingQueue = new _pdf_rendering_queue.PDFRenderingQueue();
  629. pdfRenderingQueue.onIdle = _this5.cleanup.bind(_this5);
  630. _this5.pdfRenderingQueue = pdfRenderingQueue;
  631. pdfLinkService = new _pdf_link_service.PDFLinkService({
  632. eventBus: eventBus,
  633. externalLinkTarget: _app_options.AppOptions.get("externalLinkTarget"),
  634. externalLinkRel: _app_options.AppOptions.get("externalLinkRel"),
  635. ignoreDestinationZoom: _app_options.AppOptions.get("ignoreDestinationZoom")
  636. });
  637. _this5.pdfLinkService = pdfLinkService;
  638. downloadManager = _this5.externalServices.createDownloadManager();
  639. _this5.downloadManager = downloadManager;
  640. findController = new _pdf_find_controller.PDFFindController({
  641. linkService: pdfLinkService,
  642. eventBus: eventBus
  643. });
  644. _this5.findController = findController;
  645. container = appConfig.mainContainer;
  646. viewer = appConfig.viewerContainer;
  647. _this5.pdfViewer = new _pdf_viewer.PDFViewer({
  648. container: container,
  649. viewer: viewer,
  650. eventBus: eventBus,
  651. renderingQueue: pdfRenderingQueue,
  652. linkService: pdfLinkService,
  653. downloadManager: downloadManager,
  654. findController: findController,
  655. renderer: _app_options.AppOptions.get("renderer"),
  656. enableWebGL: _app_options.AppOptions.get("enableWebGL"),
  657. l10n: _this5.l10n,
  658. textLayerMode: _app_options.AppOptions.get("textLayerMode"),
  659. imageResourcesPath: _app_options.AppOptions.get("imageResourcesPath"),
  660. renderInteractiveForms: _app_options.AppOptions.get("renderInteractiveForms"),
  661. enablePrintAutoRotate: _app_options.AppOptions.get("enablePrintAutoRotate"),
  662. useOnlyCssZoom: _app_options.AppOptions.get("useOnlyCssZoom"),
  663. maxCanvasPixels: _app_options.AppOptions.get("maxCanvasPixels")
  664. });
  665. pdfRenderingQueue.setViewer(_this5.pdfViewer);
  666. pdfLinkService.setViewer(_this5.pdfViewer);
  667. _this5.pdfThumbnailViewer = new _pdf_thumbnail_viewer.PDFThumbnailViewer({
  668. container: appConfig.sidebar.thumbnailView,
  669. eventBus: eventBus,
  670. renderingQueue: pdfRenderingQueue,
  671. linkService: pdfLinkService,
  672. l10n: _this5.l10n
  673. });
  674. pdfRenderingQueue.setThumbnailViewer(_this5.pdfThumbnailViewer);
  675. _this5.pdfHistory = new _pdf_history.PDFHistory({
  676. linkService: pdfLinkService,
  677. eventBus: eventBus
  678. });
  679. pdfLinkService.setHistory(_this5.pdfHistory);
  680. if (!_this5.supportsIntegratedFind) {
  681. _this5.findBar = new _pdf_find_bar.PDFFindBar(appConfig.findBar, eventBus, _this5.l10n);
  682. }
  683. _this5.pdfDocumentProperties = new _pdf_document_properties.PDFDocumentProperties(appConfig.documentProperties, _this5.overlayManager, eventBus, _this5.l10n);
  684. _this5.pdfCursorTools = new _pdf_cursor_tools.PDFCursorTools({
  685. container: container,
  686. eventBus: eventBus,
  687. cursorToolOnLoad: _app_options.AppOptions.get("cursorToolOnLoad")
  688. });
  689. _this5.toolbar = new _toolbar.Toolbar(appConfig.toolbar, eventBus, _this5.l10n);
  690. _this5.secondaryToolbar = new _secondary_toolbar.SecondaryToolbar(appConfig.secondaryToolbar, container, eventBus);
  691. if (_this5.supportsFullscreen) {
  692. _this5.pdfPresentationMode = new _pdf_presentation_mode.PDFPresentationMode({
  693. container: container,
  694. pdfViewer: _this5.pdfViewer,
  695. eventBus: eventBus,
  696. contextMenuItems: appConfig.fullscreen
  697. });
  698. }
  699. _this5.passwordPrompt = new _password_prompt.PasswordPrompt(appConfig.passwordOverlay, _this5.overlayManager, _this5.l10n);
  700. _this5.pdfOutlineViewer = new _pdf_outline_viewer.PDFOutlineViewer({
  701. container: appConfig.sidebar.outlineView,
  702. eventBus: eventBus,
  703. linkService: pdfLinkService
  704. });
  705. _this5.pdfAttachmentViewer = new _pdf_attachment_viewer.PDFAttachmentViewer({
  706. container: appConfig.sidebar.attachmentsView,
  707. eventBus: eventBus,
  708. downloadManager: downloadManager
  709. });
  710. _this5.pdfLayerViewer = new _pdf_layer_viewer.PDFLayerViewer({
  711. container: appConfig.sidebar.layersView,
  712. eventBus: eventBus,
  713. l10n: _this5.l10n
  714. });
  715. _this5.pdfSidebar = new _pdf_sidebar.PDFSidebar({
  716. elements: appConfig.sidebar,
  717. pdfViewer: _this5.pdfViewer,
  718. pdfThumbnailViewer: _this5.pdfThumbnailViewer,
  719. eventBus: eventBus,
  720. l10n: _this5.l10n
  721. });
  722. _this5.pdfSidebar.onToggled = _this5.forceRendering.bind(_this5);
  723. _this5.pdfSidebarResizer = new _pdf_sidebar_resizer.PDFSidebarResizer(appConfig.sidebarResizer, eventBus, _this5.l10n);
  724. case 35:
  725. case "end":
  726. return _context5.stop();
  727. }
  728. }
  729. }, _callee5);
  730. }))();
  731. },
  732. run: function run(config) {
  733. this.initialize(config).then(webViewerInitialized);
  734. },
  735. get initialized() {
  736. return this._initializedCapability.settled;
  737. },
  738. get initializedPromise() {
  739. return this._initializedCapability.promise;
  740. },
  741. zoomIn: function zoomIn(ticks) {
  742. if (this.pdfViewer.isInPresentationMode) {
  743. return;
  744. }
  745. var newScale = this.pdfViewer.currentScale;
  746. do {
  747. newScale = (newScale * DEFAULT_SCALE_DELTA).toFixed(2);
  748. newScale = Math.ceil(newScale * 10) / 10;
  749. newScale = Math.min(_ui_utils.MAX_SCALE, newScale);
  750. } while (--ticks > 0 && newScale < _ui_utils.MAX_SCALE);
  751. this.pdfViewer.currentScaleValue = newScale;
  752. },
  753. zoomOut: function zoomOut(ticks) {
  754. if (this.pdfViewer.isInPresentationMode) {
  755. return;
  756. }
  757. var newScale = this.pdfViewer.currentScale;
  758. do {
  759. newScale = (newScale / DEFAULT_SCALE_DELTA).toFixed(2);
  760. newScale = Math.floor(newScale * 10) / 10;
  761. newScale = Math.max(_ui_utils.MIN_SCALE, newScale);
  762. } while (--ticks > 0 && newScale > _ui_utils.MIN_SCALE);
  763. this.pdfViewer.currentScaleValue = newScale;
  764. },
  765. zoomReset: function zoomReset() {
  766. if (this.pdfViewer.isInPresentationMode) {
  767. return;
  768. }
  769. this.pdfViewer.currentScaleValue = _ui_utils.DEFAULT_SCALE_VALUE;
  770. },
  771. get pagesCount() {
  772. return this.pdfDocument ? this.pdfDocument.numPages : 0;
  773. },
  774. get page() {
  775. return this.pdfViewer.currentPageNumber;
  776. },
  777. set page(val) {
  778. this.pdfViewer.currentPageNumber = val;
  779. },
  780. get printing() {
  781. return !!this.printService;
  782. },
  783. get supportsPrinting() {
  784. return PDFPrintServiceFactory.instance.supportsPrinting;
  785. },
  786. get supportsFullscreen() {
  787. var support;
  788. var doc = document.documentElement;
  789. support = !!(doc.requestFullscreen || doc.mozRequestFullScreen || doc.webkitRequestFullScreen || doc.msRequestFullscreen);
  790. if (document.fullscreenEnabled === false || document.mozFullScreenEnabled === false || document.webkitFullscreenEnabled === false || document.msFullscreenEnabled === false) {
  791. support = false;
  792. }
  793. return (0, _pdfjsLib.shadow)(this, "supportsFullscreen", support);
  794. },
  795. get supportsIntegratedFind() {
  796. return this.externalServices.supportsIntegratedFind;
  797. },
  798. get supportsDocumentFonts() {
  799. return this.externalServices.supportsDocumentFonts;
  800. },
  801. get loadingBar() {
  802. var bar = new _ui_utils.ProgressBar("#loadingBar");
  803. return (0, _pdfjsLib.shadow)(this, "loadingBar", bar);
  804. },
  805. get supportedMouseWheelZoomModifierKeys() {
  806. return this.externalServices.supportedMouseWheelZoomModifierKeys;
  807. },
  808. initPassiveLoading: function initPassiveLoading() {
  809. throw new Error("Not implemented: initPassiveLoading");
  810. },
  811. setTitleUsingUrl: function setTitleUsingUrl() {
  812. var url = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "";
  813. this.url = url;
  814. this.baseUrl = url.split("#")[0];
  815. var title = (0, _ui_utils.getPDFFileNameFromURL)(url, "");
  816. if (!title) {
  817. try {
  818. title = decodeURIComponent((0, _pdfjsLib.getFilenameFromUrl)(url)) || url;
  819. } catch (ex) {
  820. title = url;
  821. }
  822. }
  823. this.setTitle(title);
  824. },
  825. setTitle: function setTitle(title) {
  826. if (this.isViewerEmbedded) {
  827. return;
  828. }
  829. document.title = title;
  830. },
  831. close: function close() {
  832. var _this6 = this;
  833. return _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee6() {
  834. var errorWrapper, promise;
  835. return _regenerator["default"].wrap(function _callee6$(_context6) {
  836. while (1) {
  837. switch (_context6.prev = _context6.next) {
  838. case 0:
  839. errorWrapper = _this6.appConfig.errorWrapper.container;
  840. errorWrapper.setAttribute("hidden", "true");
  841. if (_this6.pdfLoadingTask) {
  842. _context6.next = 4;
  843. break;
  844. }
  845. return _context6.abrupt("return", undefined);
  846. case 4:
  847. promise = _this6.pdfLoadingTask.destroy();
  848. _this6.pdfLoadingTask = null;
  849. if (_this6.pdfDocument) {
  850. _this6.pdfDocument = null;
  851. _this6.pdfThumbnailViewer.setDocument(null);
  852. _this6.pdfViewer.setDocument(null);
  853. _this6.pdfLinkService.setDocument(null);
  854. _this6.pdfDocumentProperties.setDocument(null);
  855. }
  856. webViewerResetPermissions();
  857. _this6.store = null;
  858. _this6.isInitialViewSet = false;
  859. _this6.downloadComplete = false;
  860. _this6.url = "";
  861. _this6.baseUrl = "";
  862. _this6.contentDispositionFilename = null;
  863. _this6.triggerDelayedFallback = null;
  864. _this6._saveInProgress = false;
  865. _this6.pdfSidebar.reset();
  866. _this6.pdfOutlineViewer.reset();
  867. _this6.pdfAttachmentViewer.reset();
  868. _this6.pdfLayerViewer.reset();
  869. if (_this6.pdfHistory) {
  870. _this6.pdfHistory.reset();
  871. }
  872. if (_this6.findBar) {
  873. _this6.findBar.reset();
  874. }
  875. _this6.toolbar.reset();
  876. _this6.secondaryToolbar.reset();
  877. if (typeof PDFBug !== "undefined") {
  878. PDFBug.cleanup();
  879. }
  880. return _context6.abrupt("return", promise);
  881. case 26:
  882. case "end":
  883. return _context6.stop();
  884. }
  885. }
  886. }, _callee6);
  887. }))();
  888. },
  889. open: function open(file, args) {
  890. var _this7 = this;
  891. return _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee7() {
  892. var workerParameters, key, parameters, apiParameters, _key, value, _key2, _value, loadingTask;
  893. return _regenerator["default"].wrap(function _callee7$(_context7) {
  894. while (1) {
  895. switch (_context7.prev = _context7.next) {
  896. case 0:
  897. if (!_this7.pdfLoadingTask) {
  898. _context7.next = 3;
  899. break;
  900. }
  901. _context7.next = 3;
  902. return _this7.close();
  903. case 3:
  904. workerParameters = _app_options.AppOptions.getAll(_app_options.OptionKind.WORKER);
  905. for (key in workerParameters) {
  906. _pdfjsLib.GlobalWorkerOptions[key] = workerParameters[key];
  907. }
  908. parameters = Object.create(null);
  909. if (typeof file === "string") {
  910. _this7.setTitleUsingUrl(file);
  911. parameters.url = file;
  912. } else if (file && "byteLength" in file) {
  913. parameters.data = file;
  914. } else if (file.url && file.originalUrl) {
  915. _this7.setTitleUsingUrl(file.originalUrl);
  916. parameters.url = file.url;
  917. }
  918. apiParameters = _app_options.AppOptions.getAll(_app_options.OptionKind.API);
  919. for (_key in apiParameters) {
  920. value = apiParameters[_key];
  921. if (_key === "docBaseUrl" && !value) {}
  922. parameters[_key] = value;
  923. }
  924. if (args) {
  925. for (_key2 in args) {
  926. _value = args[_key2];
  927. if (_key2 === "length") {
  928. _this7.pdfDocumentProperties.setFileSize(_value);
  929. }
  930. parameters[_key2] = _value;
  931. }
  932. }
  933. loadingTask = (0, _pdfjsLib.getDocument)(parameters);
  934. _this7.pdfLoadingTask = loadingTask;
  935. loadingTask.onPassword = function (updateCallback, reason) {
  936. _this7.pdfLinkService.externalLinkEnabled = false;
  937. _this7.passwordPrompt.setUpdateCallback(updateCallback, reason);
  938. _this7.passwordPrompt.open();
  939. };
  940. loadingTask.onProgress = function (_ref) {
  941. var loaded = _ref.loaded,
  942. total = _ref.total;
  943. _this7.progress(loaded / total);
  944. };
  945. loadingTask.onUnsupportedFeature = _this7.fallback.bind(_this7);
  946. return _context7.abrupt("return", loadingTask.promise.then(function (pdfDocument) {
  947. _this7.load(pdfDocument);
  948. }, function (exception) {
  949. if (loadingTask !== _this7.pdfLoadingTask) {
  950. return undefined;
  951. }
  952. var message = exception && exception.message;
  953. var loadingErrorMessage;
  954. if (exception instanceof _pdfjsLib.InvalidPDFException) {
  955. loadingErrorMessage = _this7.l10n.get("invalid_file_error", null, "Invalid or corrupted PDF file.");
  956. } else if (exception instanceof _pdfjsLib.MissingPDFException) {
  957. loadingErrorMessage = _this7.l10n.get("missing_file_error", null, "Missing PDF file.");
  958. } else if (exception instanceof _pdfjsLib.UnexpectedResponseException) {
  959. loadingErrorMessage = _this7.l10n.get("unexpected_response_error", null, "Unexpected server response.");
  960. } else {
  961. loadingErrorMessage = _this7.l10n.get("loading_error", null, "An error occurred while loading the PDF.");
  962. }
  963. return loadingErrorMessage.then(function (msg) {
  964. _this7.error(msg, {
  965. message: message
  966. });
  967. throw exception;
  968. });
  969. }));
  970. case 16:
  971. case "end":
  972. return _context7.stop();
  973. }
  974. }
  975. }, _callee7);
  976. }))();
  977. },
  978. download: function download() {
  979. var _this8 = this;
  980. var _ref2 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
  981. _ref2$sourceEventType = _ref2.sourceEventType,
  982. sourceEventType = _ref2$sourceEventType === void 0 ? "download" : _ref2$sourceEventType;
  983. function downloadByUrl() {
  984. downloadManager.downloadUrl(url, filename);
  985. }
  986. var url = this.baseUrl;
  987. var filename = this.contentDispositionFilename || (0, _ui_utils.getPDFFileNameFromURL)(this.url);
  988. var downloadManager = this.downloadManager;
  989. downloadManager.onerror = function (err) {
  990. _this8.error("PDF failed to download: ".concat(err));
  991. };
  992. if (!this.pdfDocument || !this.downloadComplete) {
  993. downloadByUrl();
  994. return;
  995. }
  996. this.pdfDocument.getData().then(function (data) {
  997. var blob = new Blob([data], {
  998. type: "application/pdf"
  999. });
  1000. downloadManager.download(blob, url, filename, sourceEventType);
  1001. })["catch"](downloadByUrl);
  1002. },
  1003. save: function save() {
  1004. var _this9 = this;
  1005. var _ref3 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
  1006. _ref3$sourceEventType = _ref3.sourceEventType,
  1007. sourceEventType = _ref3$sourceEventType === void 0 ? "download" : _ref3$sourceEventType;
  1008. if (this._saveInProgress) {
  1009. return;
  1010. }
  1011. var url = this.baseUrl;
  1012. var filename = this.contentDispositionFilename || (0, _ui_utils.getPDFFileNameFromURL)(this.url);
  1013. var downloadManager = this.downloadManager;
  1014. downloadManager.onerror = function (err) {
  1015. _this9.error("PDF failed to be saved: ".concat(err));
  1016. };
  1017. if (!this.pdfDocument || !this.downloadComplete) {
  1018. this.download({
  1019. sourceEventType: sourceEventType
  1020. });
  1021. return;
  1022. }
  1023. this._saveInProgress = true;
  1024. this.pdfDocument.saveDocument(this.pdfDocument.annotationStorage).then(function (data) {
  1025. var blob = new Blob([data], {
  1026. type: "application/pdf"
  1027. });
  1028. downloadManager.download(blob, url, filename, sourceEventType);
  1029. })["catch"](function () {
  1030. _this9.download({
  1031. sourceEventType: sourceEventType
  1032. });
  1033. })["finally"](function () {
  1034. _this9._saveInProgress = false;
  1035. });
  1036. },
  1037. _delayedFallback: function _delayedFallback(featureId) {
  1038. var _this10 = this;
  1039. this.externalServices.reportTelemetry({
  1040. type: "unsupportedFeature",
  1041. featureId: featureId
  1042. });
  1043. if (!this.triggerDelayedFallback) {
  1044. this.triggerDelayedFallback = function () {
  1045. _this10.fallback(featureId);
  1046. _this10.triggerDelayedFallback = null;
  1047. };
  1048. }
  1049. },
  1050. fallback: function fallback(featureId) {
  1051. this.externalServices.reportTelemetry({
  1052. type: "unsupportedFeature",
  1053. featureId: featureId
  1054. });
  1055. if (this.fellback) {
  1056. return;
  1057. }
  1058. this.fellback = true;
  1059. this.externalServices.fallback({
  1060. featureId: featureId,
  1061. url: this.baseUrl
  1062. }, function response(download) {
  1063. if (!download) {
  1064. return;
  1065. }
  1066. PDFViewerApplication.download({
  1067. sourceEventType: "download"
  1068. });
  1069. });
  1070. },
  1071. error: function error(message, moreInfo) {
  1072. var moreInfoText = [this.l10n.get("error_version_info", {
  1073. version: _pdfjsLib.version || "?",
  1074. build: _pdfjsLib.build || "?"
  1075. }, "PDF.js v{{version}} (build: {{build}})")];
  1076. if (moreInfo) {
  1077. moreInfoText.push(this.l10n.get("error_message", {
  1078. message: moreInfo.message
  1079. }, "Message: {{message}}"));
  1080. if (moreInfo.stack) {
  1081. moreInfoText.push(this.l10n.get("error_stack", {
  1082. stack: moreInfo.stack
  1083. }, "Stack: {{stack}}"));
  1084. } else {
  1085. if (moreInfo.filename) {
  1086. moreInfoText.push(this.l10n.get("error_file", {
  1087. file: moreInfo.filename
  1088. }, "File: {{file}}"));
  1089. }
  1090. if (moreInfo.lineNumber) {
  1091. moreInfoText.push(this.l10n.get("error_line", {
  1092. line: moreInfo.lineNumber
  1093. }, "Line: {{line}}"));
  1094. }
  1095. }
  1096. }
  1097. var errorWrapperConfig = this.appConfig.errorWrapper;
  1098. var errorWrapper = errorWrapperConfig.container;
  1099. errorWrapper.removeAttribute("hidden");
  1100. var errorMessage = errorWrapperConfig.errorMessage;
  1101. errorMessage.textContent = message;
  1102. var closeButton = errorWrapperConfig.closeButton;
  1103. closeButton.onclick = function () {
  1104. errorWrapper.setAttribute("hidden", "true");
  1105. };
  1106. var errorMoreInfo = errorWrapperConfig.errorMoreInfo;
  1107. var moreInfoButton = errorWrapperConfig.moreInfoButton;
  1108. var lessInfoButton = errorWrapperConfig.lessInfoButton;
  1109. moreInfoButton.onclick = function () {
  1110. errorMoreInfo.removeAttribute("hidden");
  1111. moreInfoButton.setAttribute("hidden", "true");
  1112. lessInfoButton.removeAttribute("hidden");
  1113. errorMoreInfo.style.height = errorMoreInfo.scrollHeight + "px";
  1114. };
  1115. lessInfoButton.onclick = function () {
  1116. errorMoreInfo.setAttribute("hidden", "true");
  1117. moreInfoButton.removeAttribute("hidden");
  1118. lessInfoButton.setAttribute("hidden", "true");
  1119. };
  1120. moreInfoButton.oncontextmenu = _ui_utils.noContextMenuHandler;
  1121. lessInfoButton.oncontextmenu = _ui_utils.noContextMenuHandler;
  1122. closeButton.oncontextmenu = _ui_utils.noContextMenuHandler;
  1123. moreInfoButton.removeAttribute("hidden");
  1124. lessInfoButton.setAttribute("hidden", "true");
  1125. Promise.all(moreInfoText).then(function (parts) {
  1126. errorMoreInfo.value = parts.join("\n");
  1127. });
  1128. },
  1129. progress: function progress(level) {
  1130. var _this11 = this;
  1131. if (this.downloadComplete) {
  1132. return;
  1133. }
  1134. var percent = Math.round(level * 100);
  1135. if (percent > this.loadingBar.percent || isNaN(percent)) {
  1136. this.loadingBar.percent = percent;
  1137. var disableAutoFetch = this.pdfDocument ? this.pdfDocument.loadingParams.disableAutoFetch : _app_options.AppOptions.get("disableAutoFetch");
  1138. if (disableAutoFetch && percent) {
  1139. if (this.disableAutoFetchLoadingBarTimeout) {
  1140. clearTimeout(this.disableAutoFetchLoadingBarTimeout);
  1141. this.disableAutoFetchLoadingBarTimeout = null;
  1142. }
  1143. this.loadingBar.show();
  1144. this.disableAutoFetchLoadingBarTimeout = setTimeout(function () {
  1145. _this11.loadingBar.hide();
  1146. _this11.disableAutoFetchLoadingBarTimeout = null;
  1147. }, DISABLE_AUTO_FETCH_LOADING_BAR_TIMEOUT);
  1148. }
  1149. }
  1150. },
  1151. load: function load(pdfDocument) {
  1152. var _this12 = this;
  1153. this.pdfDocument = pdfDocument;
  1154. pdfDocument.getDownloadInfo().then(function () {
  1155. _this12.downloadComplete = true;
  1156. _this12.loadingBar.hide();
  1157. firstPagePromise.then(function () {
  1158. _this12.eventBus.dispatch("documentloaded", {
  1159. source: _this12
  1160. });
  1161. });
  1162. });
  1163. var pageLayoutPromise = pdfDocument.getPageLayout()["catch"](function () {});
  1164. var pageModePromise = pdfDocument.getPageMode()["catch"](function () {});
  1165. var openActionPromise = pdfDocument.getOpenAction()["catch"](function () {});
  1166. this.toolbar.setPagesCount(pdfDocument.numPages, false);
  1167. this.secondaryToolbar.setPagesCount(pdfDocument.numPages);
  1168. var baseDocumentUrl;
  1169. baseDocumentUrl = null;
  1170. this.pdfLinkService.setDocument(pdfDocument, baseDocumentUrl);
  1171. this.pdfDocumentProperties.setDocument(pdfDocument, this.url);
  1172. var annotationStorage = pdfDocument.annotationStorage;
  1173. annotationStorage.onSetModified = function () {
  1174. window.addEventListener("beforeunload", beforeUnload);
  1175. };
  1176. annotationStorage.onResetModified = function () {
  1177. window.removeEventListener("beforeunload", beforeUnload);
  1178. };
  1179. var pdfViewer = this.pdfViewer;
  1180. pdfViewer.setDocument(pdfDocument);
  1181. var firstPagePromise = pdfViewer.firstPagePromise,
  1182. onePageRendered = pdfViewer.onePageRendered,
  1183. pagesPromise = pdfViewer.pagesPromise;
  1184. var pdfThumbnailViewer = this.pdfThumbnailViewer;
  1185. pdfThumbnailViewer.setDocument(pdfDocument);
  1186. var storedPromise = (this.store = new _view_history.ViewHistory(pdfDocument.fingerprint)).getMultiple({
  1187. page: null,
  1188. zoom: _ui_utils.DEFAULT_SCALE_VALUE,
  1189. scrollLeft: "0",
  1190. scrollTop: "0",
  1191. rotation: null,
  1192. sidebarView: _pdf_sidebar.SidebarView.UNKNOWN,
  1193. scrollMode: _ui_utils.ScrollMode.UNKNOWN,
  1194. spreadMode: _ui_utils.SpreadMode.UNKNOWN
  1195. })["catch"](function () {
  1196. return Object.create(null);
  1197. });
  1198. firstPagePromise.then(function (pdfPage) {
  1199. _this12.loadingBar.setWidth(_this12.appConfig.viewerContainer);
  1200. Promise.all([_ui_utils.animationStarted, storedPromise, pageLayoutPromise, pageModePromise, openActionPromise]).then( /*#__PURE__*/function () {
  1201. var _ref5 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee8(_ref4) {
  1202. var _ref6, timeStamp, stored, pageLayout, pageMode, openAction, viewOnLoad, initialBookmark, zoom, hash, rotation, sidebarView, scrollMode, spreadMode;
  1203. return _regenerator["default"].wrap(function _callee8$(_context8) {
  1204. while (1) {
  1205. switch (_context8.prev = _context8.next) {
  1206. case 0:
  1207. _ref6 = _slicedToArray(_ref4, 5), timeStamp = _ref6[0], stored = _ref6[1], pageLayout = _ref6[2], pageMode = _ref6[3], openAction = _ref6[4];
  1208. viewOnLoad = _app_options.AppOptions.get("viewOnLoad");
  1209. _this12._initializePdfHistory({
  1210. fingerprint: pdfDocument.fingerprint,
  1211. viewOnLoad: viewOnLoad,
  1212. initialDest: openAction && openAction.dest
  1213. });
  1214. initialBookmark = _this12.initialBookmark;
  1215. zoom = _app_options.AppOptions.get("defaultZoomValue");
  1216. hash = zoom ? "zoom=".concat(zoom) : null;
  1217. rotation = null;
  1218. sidebarView = _app_options.AppOptions.get("sidebarViewOnLoad");
  1219. scrollMode = _app_options.AppOptions.get("scrollModeOnLoad");
  1220. spreadMode = _app_options.AppOptions.get("spreadModeOnLoad");
  1221. if (stored.page && viewOnLoad !== ViewOnLoad.INITIAL) {
  1222. hash = "page=".concat(stored.page, "&zoom=").concat(zoom || stored.zoom, ",") + "".concat(stored.scrollLeft, ",").concat(stored.scrollTop);
  1223. rotation = parseInt(stored.rotation, 10);
  1224. if (sidebarView === _pdf_sidebar.SidebarView.UNKNOWN) {
  1225. sidebarView = stored.sidebarView | 0;
  1226. }
  1227. if (scrollMode === _ui_utils.ScrollMode.UNKNOWN) {
  1228. scrollMode = stored.scrollMode | 0;
  1229. }
  1230. if (spreadMode === _ui_utils.SpreadMode.UNKNOWN) {
  1231. spreadMode = stored.spreadMode | 0;
  1232. }
  1233. }
  1234. if (pageMode && sidebarView === _pdf_sidebar.SidebarView.UNKNOWN) {
  1235. sidebarView = apiPageModeToSidebarView(pageMode);
  1236. }
  1237. if (pageLayout && spreadMode === _ui_utils.SpreadMode.UNKNOWN) {
  1238. spreadMode = apiPageLayoutToSpreadMode(pageLayout);
  1239. }
  1240. _this12.setInitialView(hash, {
  1241. rotation: rotation,
  1242. sidebarView: sidebarView,
  1243. scrollMode: scrollMode,
  1244. spreadMode: spreadMode
  1245. });
  1246. _this12.eventBus.dispatch("documentinit", {
  1247. source: _this12
  1248. });
  1249. if (!_this12.isViewerEmbedded) {
  1250. pdfViewer.focus();
  1251. }
  1252. _this12._initializePermissions(pdfDocument);
  1253. _context8.next = 19;
  1254. return Promise.race([pagesPromise, new Promise(function (resolve) {
  1255. setTimeout(resolve, FORCE_PAGES_LOADED_TIMEOUT);
  1256. })]);
  1257. case 19:
  1258. if (!(!initialBookmark && !hash)) {
  1259. _context8.next = 21;
  1260. break;
  1261. }
  1262. return _context8.abrupt("return");
  1263. case 21:
  1264. if (!pdfViewer.hasEqualPageSizes) {
  1265. _context8.next = 23;
  1266. break;
  1267. }
  1268. return _context8.abrupt("return");
  1269. case 23:
  1270. _this12.initialBookmark = initialBookmark;
  1271. pdfViewer.currentScaleValue = pdfViewer.currentScaleValue;
  1272. _this12.setInitialView(hash);
  1273. case 26:
  1274. case "end":
  1275. return _context8.stop();
  1276. }
  1277. }
  1278. }, _callee8);
  1279. }));
  1280. return function (_x) {
  1281. return _ref5.apply(this, arguments);
  1282. };
  1283. }())["catch"](function () {
  1284. _this12.setInitialView();
  1285. }).then(function () {
  1286. pdfViewer.update();
  1287. });
  1288. });
  1289. pagesPromise.then(function () {
  1290. _this12._initializeAutoPrint(pdfDocument, openActionPromise);
  1291. });
  1292. onePageRendered.then(function () {
  1293. pdfDocument.getOutline().then(function (outline) {
  1294. _this12.pdfOutlineViewer.render({
  1295. outline: outline
  1296. });
  1297. });
  1298. pdfDocument.getAttachments().then(function (attachments) {
  1299. _this12.pdfAttachmentViewer.render({
  1300. attachments: attachments
  1301. });
  1302. });
  1303. pdfViewer.optionalContentConfigPromise.then(function (optionalContentConfig) {
  1304. _this12.pdfLayerViewer.render({
  1305. optionalContentConfig: optionalContentConfig,
  1306. pdfDocument: pdfDocument
  1307. });
  1308. });
  1309. });
  1310. this._initializePageLabels(pdfDocument);
  1311. this._initializeMetadata(pdfDocument);
  1312. },
  1313. _initializeAutoPrint: function _initializeAutoPrint(pdfDocument, openActionPromise) {
  1314. var _this13 = this;
  1315. return _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee9() {
  1316. var _yield$Promise$all, _yield$Promise$all2, openAction, javaScript, triggerAutoPrint, _iterator, _step, js;
  1317. return _regenerator["default"].wrap(function _callee9$(_context9) {
  1318. while (1) {
  1319. switch (_context9.prev = _context9.next) {
  1320. case 0:
  1321. _context9.next = 2;
  1322. return Promise.all([openActionPromise, pdfDocument.getJavaScript()]);
  1323. case 2:
  1324. _yield$Promise$all = _context9.sent;
  1325. _yield$Promise$all2 = _slicedToArray(_yield$Promise$all, 2);
  1326. openAction = _yield$Promise$all2[0];
  1327. javaScript = _yield$Promise$all2[1];
  1328. if (!(pdfDocument !== _this13.pdfDocument)) {
  1329. _context9.next = 8;
  1330. break;
  1331. }
  1332. return _context9.abrupt("return");
  1333. case 8:
  1334. triggerAutoPrint = false;
  1335. if (openAction && openAction.action === "Print") {
  1336. triggerAutoPrint = true;
  1337. }
  1338. if (!javaScript) {
  1339. _context9.next = 31;
  1340. break;
  1341. }
  1342. javaScript.some(function (js) {
  1343. if (!js) {
  1344. return false;
  1345. }
  1346. console.warn("Warning: JavaScript is not supported");
  1347. _this13._delayedFallback(_pdfjsLib.UNSUPPORTED_FEATURES.javaScript);
  1348. return true;
  1349. });
  1350. if (triggerAutoPrint) {
  1351. _context9.next = 31;
  1352. break;
  1353. }
  1354. _iterator = _createForOfIteratorHelper(javaScript);
  1355. _context9.prev = 14;
  1356. _iterator.s();
  1357. case 16:
  1358. if ((_step = _iterator.n()).done) {
  1359. _context9.next = 23;
  1360. break;
  1361. }
  1362. js = _step.value;
  1363. if (!(js && _ui_utils.AutoPrintRegExp.test(js))) {
  1364. _context9.next = 21;
  1365. break;
  1366. }
  1367. triggerAutoPrint = true;
  1368. return _context9.abrupt("break", 23);
  1369. case 21:
  1370. _context9.next = 16;
  1371. break;
  1372. case 23:
  1373. _context9.next = 28;
  1374. break;
  1375. case 25:
  1376. _context9.prev = 25;
  1377. _context9.t0 = _context9["catch"](14);
  1378. _iterator.e(_context9.t0);
  1379. case 28:
  1380. _context9.prev = 28;
  1381. _iterator.f();
  1382. return _context9.finish(28);
  1383. case 31:
  1384. if (_this13.supportsPrinting) {
  1385. _context9.next = 33;
  1386. break;
  1387. }
  1388. return _context9.abrupt("return");
  1389. case 33:
  1390. if (triggerAutoPrint) {
  1391. setTimeout(function () {
  1392. window.print();
  1393. });
  1394. }
  1395. case 34:
  1396. case "end":
  1397. return _context9.stop();
  1398. }
  1399. }
  1400. }, _callee9, null, [[14, 25, 28, 31]]);
  1401. }))();
  1402. },
  1403. _initializeMetadata: function _initializeMetadata(pdfDocument) {
  1404. var _this14 = this;
  1405. return _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee10() {
  1406. var _yield$pdfDocument$ge, info, metadata, contentDispositionFilename, pdfTitle, infoTitle, metadataTitle, versionId, generatorId, producer, formType;
  1407. return _regenerator["default"].wrap(function _callee10$(_context10) {
  1408. while (1) {
  1409. switch (_context10.prev = _context10.next) {
  1410. case 0:
  1411. _context10.next = 2;
  1412. return pdfDocument.getMetadata();
  1413. case 2:
  1414. _yield$pdfDocument$ge = _context10.sent;
  1415. info = _yield$pdfDocument$ge.info;
  1416. metadata = _yield$pdfDocument$ge.metadata;
  1417. contentDispositionFilename = _yield$pdfDocument$ge.contentDispositionFilename;
  1418. if (!(pdfDocument !== _this14.pdfDocument)) {
  1419. _context10.next = 8;
  1420. break;
  1421. }
  1422. return _context10.abrupt("return");
  1423. case 8:
  1424. _this14.documentInfo = info;
  1425. _this14.metadata = metadata;
  1426. _this14.contentDispositionFilename = contentDispositionFilename;
  1427. console.log("PDF ".concat(pdfDocument.fingerprint, " [").concat(info.PDFFormatVersion, " ") + "".concat((info.Producer || "-").trim(), " / ").concat((info.Creator || "-").trim(), "] ") + "(PDF.js: ".concat(_pdfjsLib.version || "-") + "".concat(_this14.pdfViewer.enableWebGL ? " [WebGL]" : "", ")"));
  1428. infoTitle = info && info.Title;
  1429. if (infoTitle) {
  1430. pdfTitle = infoTitle;
  1431. }
  1432. metadataTitle = metadata && metadata.get("dc:title");
  1433. if (metadataTitle) {
  1434. if (metadataTitle !== "Untitled" && !/[\uFFF0-\uFFFF]/g.test(metadataTitle)) {
  1435. pdfTitle = metadataTitle;
  1436. }
  1437. }
  1438. if (pdfTitle) {
  1439. _this14.setTitle("".concat(pdfTitle, " - ").concat(contentDispositionFilename || document.title));
  1440. } else if (contentDispositionFilename) {
  1441. _this14.setTitle(contentDispositionFilename);
  1442. }
  1443. if (info.IsXFAPresent && !info.IsAcroFormPresent) {
  1444. console.warn("Warning: XFA is not supported");
  1445. _this14._delayedFallback(_pdfjsLib.UNSUPPORTED_FEATURES.forms);
  1446. } else if ((info.IsAcroFormPresent || info.IsXFAPresent) && !_this14.pdfViewer.renderInteractiveForms) {
  1447. console.warn("Warning: Interactive form support is not enabled");
  1448. _this14._delayedFallback(_pdfjsLib.UNSUPPORTED_FEATURES.forms);
  1449. }
  1450. versionId = "other";
  1451. if (KNOWN_VERSIONS.includes(info.PDFFormatVersion)) {
  1452. versionId = "v".concat(info.PDFFormatVersion.replace(".", "_"));
  1453. }
  1454. generatorId = "other";
  1455. if (info.Producer) {
  1456. producer = info.Producer.toLowerCase();
  1457. KNOWN_GENERATORS.some(function (generator) {
  1458. if (!producer.includes(generator)) {
  1459. return false;
  1460. }
  1461. generatorId = generator.replace(/[ .\-]/g, "_");
  1462. return true;
  1463. });
  1464. }
  1465. formType = null;
  1466. if (info.IsXFAPresent) {
  1467. formType = "xfa";
  1468. } else if (info.IsAcroFormPresent) {
  1469. formType = "acroform";
  1470. }
  1471. _this14.externalServices.reportTelemetry({
  1472. type: "documentInfo",
  1473. version: versionId,
  1474. generator: generatorId,
  1475. formType: formType
  1476. });
  1477. case 25:
  1478. case "end":
  1479. return _context10.stop();
  1480. }
  1481. }
  1482. }, _callee10);
  1483. }))();
  1484. },
  1485. _initializePageLabels: function _initializePageLabels(pdfDocument) {
  1486. var _this15 = this;
  1487. return _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee11() {
  1488. var labels, numLabels, i, pdfViewer, pdfThumbnailViewer, toolbar;
  1489. return _regenerator["default"].wrap(function _callee11$(_context11) {
  1490. while (1) {
  1491. switch (_context11.prev = _context11.next) {
  1492. case 0:
  1493. _context11.next = 2;
  1494. return pdfDocument.getPageLabels();
  1495. case 2:
  1496. labels = _context11.sent;
  1497. if (!(pdfDocument !== _this15.pdfDocument)) {
  1498. _context11.next = 5;
  1499. break;
  1500. }
  1501. return _context11.abrupt("return");
  1502. case 5:
  1503. if (!(!labels || _app_options.AppOptions.get("disablePageLabels"))) {
  1504. _context11.next = 7;
  1505. break;
  1506. }
  1507. return _context11.abrupt("return");
  1508. case 7:
  1509. numLabels = labels.length;
  1510. if (!(numLabels !== _this15.pagesCount)) {
  1511. _context11.next = 11;
  1512. break;
  1513. }
  1514. console.error("The number of Page Labels does not match the number of pages in the document.");
  1515. return _context11.abrupt("return");
  1516. case 11:
  1517. i = 0;
  1518. while (i < numLabels && labels[i] === (i + 1).toString()) {
  1519. i++;
  1520. }
  1521. if (!(i === numLabels)) {
  1522. _context11.next = 15;
  1523. break;
  1524. }
  1525. return _context11.abrupt("return");
  1526. case 15:
  1527. pdfViewer = _this15.pdfViewer, pdfThumbnailViewer = _this15.pdfThumbnailViewer, toolbar = _this15.toolbar;
  1528. pdfViewer.setPageLabels(labels);
  1529. pdfThumbnailViewer.setPageLabels(labels);
  1530. toolbar.setPagesCount(numLabels, true);
  1531. toolbar.setPageNumber(pdfViewer.currentPageNumber, pdfViewer.currentPageLabel);
  1532. case 20:
  1533. case "end":
  1534. return _context11.stop();
  1535. }
  1536. }
  1537. }, _callee11);
  1538. }))();
  1539. },
  1540. _initializePdfHistory: function _initializePdfHistory(_ref7) {
  1541. var fingerprint = _ref7.fingerprint,
  1542. viewOnLoad = _ref7.viewOnLoad,
  1543. _ref7$initialDest = _ref7.initialDest,
  1544. initialDest = _ref7$initialDest === void 0 ? null : _ref7$initialDest;
  1545. if (this.isViewerEmbedded || _app_options.AppOptions.get("disableHistory")) {
  1546. return;
  1547. }
  1548. this.pdfHistory.initialize({
  1549. fingerprint: fingerprint,
  1550. resetHistory: viewOnLoad === ViewOnLoad.INITIAL,
  1551. updateUrl: _app_options.AppOptions.get("historyUpdateUrl")
  1552. });
  1553. if (this.pdfHistory.initialBookmark) {
  1554. this.initialBookmark = this.pdfHistory.initialBookmark;
  1555. this.initialRotation = this.pdfHistory.initialRotation;
  1556. }
  1557. if (initialDest && !this.initialBookmark && viewOnLoad === ViewOnLoad.UNKNOWN) {
  1558. this.initialBookmark = JSON.stringify(initialDest);
  1559. this.pdfHistory.push({
  1560. explicitDest: initialDest,
  1561. pageNumber: null
  1562. });
  1563. }
  1564. },
  1565. _initializePermissions: function _initializePermissions(pdfDocument) {
  1566. var _this16 = this;
  1567. return _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee12() {
  1568. var permissions;
  1569. return _regenerator["default"].wrap(function _callee12$(_context12) {
  1570. while (1) {
  1571. switch (_context12.prev = _context12.next) {
  1572. case 0:
  1573. _context12.next = 2;
  1574. return pdfDocument.getPermissions();
  1575. case 2:
  1576. permissions = _context12.sent;
  1577. if (!(pdfDocument !== _this16.pdfDocument)) {
  1578. _context12.next = 5;
  1579. break;
  1580. }
  1581. return _context12.abrupt("return");
  1582. case 5:
  1583. if (!(!permissions || !_app_options.AppOptions.get("enablePermissions"))) {
  1584. _context12.next = 7;
  1585. break;
  1586. }
  1587. return _context12.abrupt("return");
  1588. case 7:
  1589. if (!permissions.includes(_pdfjsLib.PermissionFlag.COPY)) {
  1590. _this16.appConfig.viewerContainer.classList.add(ENABLE_PERMISSIONS_CLASS);
  1591. }
  1592. case 8:
  1593. case "end":
  1594. return _context12.stop();
  1595. }
  1596. }
  1597. }, _callee12);
  1598. }))();
  1599. },
  1600. setInitialView: function setInitialView(storedHash) {
  1601. var _this17 = this;
  1602. var _ref8 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
  1603. rotation = _ref8.rotation,
  1604. sidebarView = _ref8.sidebarView,
  1605. scrollMode = _ref8.scrollMode,
  1606. spreadMode = _ref8.spreadMode;
  1607. var setRotation = function setRotation(angle) {
  1608. if ((0, _ui_utils.isValidRotation)(angle)) {
  1609. _this17.pdfViewer.pagesRotation = angle;
  1610. }
  1611. };
  1612. var setViewerModes = function setViewerModes(scroll, spread) {
  1613. if ((0, _ui_utils.isValidScrollMode)(scroll)) {
  1614. _this17.pdfViewer.scrollMode = scroll;
  1615. }
  1616. if ((0, _ui_utils.isValidSpreadMode)(spread)) {
  1617. _this17.pdfViewer.spreadMode = spread;
  1618. }
  1619. };
  1620. this.isInitialViewSet = true;
  1621. this.pdfSidebar.setInitialView(sidebarView);
  1622. setViewerModes(scrollMode, spreadMode);
  1623. if (this.initialBookmark) {
  1624. setRotation(this.initialRotation);
  1625. delete this.initialRotation;
  1626. this.pdfLinkService.setHash(this.initialBookmark);
  1627. this.initialBookmark = null;
  1628. } else if (storedHash) {
  1629. setRotation(rotation);
  1630. this.pdfLinkService.setHash(storedHash);
  1631. }
  1632. this.toolbar.setPageNumber(this.pdfViewer.currentPageNumber, this.pdfViewer.currentPageLabel);
  1633. this.secondaryToolbar.setPageNumber(this.pdfViewer.currentPageNumber);
  1634. if (!this.pdfViewer.currentScaleValue) {
  1635. this.pdfViewer.currentScaleValue = _ui_utils.DEFAULT_SCALE_VALUE;
  1636. }
  1637. },
  1638. cleanup: function cleanup() {
  1639. if (!this.pdfDocument) {
  1640. return;
  1641. }
  1642. this.pdfViewer.cleanup();
  1643. this.pdfThumbnailViewer.cleanup();
  1644. if (this.pdfViewer.renderer !== _ui_utils.RendererType.SVG) {
  1645. this.pdfDocument.cleanup();
  1646. }
  1647. },
  1648. forceRendering: function forceRendering() {
  1649. this.pdfRenderingQueue.printing = this.printing;
  1650. this.pdfRenderingQueue.isThumbnailViewEnabled = this.pdfSidebar.isThumbnailViewVisible;
  1651. this.pdfRenderingQueue.renderHighestPriority();
  1652. },
  1653. beforePrint: function beforePrint() {
  1654. var _this18 = this;
  1655. if (this.printService) {
  1656. return;
  1657. }
  1658. if (!this.supportsPrinting) {
  1659. this.l10n.get("printing_not_supported", null, "Warning: Printing is not fully supported by this browser.").then(function (printMessage) {
  1660. _this18.error(printMessage);
  1661. });
  1662. return;
  1663. }
  1664. if (!this.pdfViewer.pageViewsReady) {
  1665. this.l10n.get("printing_not_ready", null, "Warning: The PDF is not fully loaded for printing.").then(function (notReadyMessage) {
  1666. window.alert(notReadyMessage);
  1667. });
  1668. return;
  1669. }
  1670. var pagesOverview = this.pdfViewer.getPagesOverview();
  1671. var printContainer = this.appConfig.printContainer;
  1672. var printResolution = _app_options.AppOptions.get("printResolution");
  1673. var optionalContentConfigPromise = this.pdfViewer.optionalContentConfigPromise;
  1674. var printService = PDFPrintServiceFactory.instance.createPrintService(this.pdfDocument, pagesOverview, printContainer, printResolution, optionalContentConfigPromise, this.l10n);
  1675. this.printService = printService;
  1676. this.forceRendering();
  1677. printService.layout();
  1678. this.externalServices.reportTelemetry({
  1679. type: "print"
  1680. });
  1681. },
  1682. afterPrint: function afterPrint() {
  1683. if (this.printService) {
  1684. this.printService.destroy();
  1685. this.printService = null;
  1686. if (this.pdfDocument) {
  1687. this.pdfDocument.annotationStorage.resetModified();
  1688. }
  1689. }
  1690. this.forceRendering();
  1691. },
  1692. rotatePages: function rotatePages(delta) {
  1693. if (!this.pdfDocument) {
  1694. return;
  1695. }
  1696. var newRotation = (this.pdfViewer.pagesRotation + 360 + delta) % 360;
  1697. this.pdfViewer.pagesRotation = newRotation;
  1698. },
  1699. requestPresentationMode: function requestPresentationMode() {
  1700. if (!this.pdfPresentationMode) {
  1701. return;
  1702. }
  1703. this.pdfPresentationMode.request();
  1704. },
  1705. bindEvents: function bindEvents() {
  1706. var eventBus = this.eventBus,
  1707. _boundEvents = this._boundEvents;
  1708. _boundEvents.beforePrint = this.beforePrint.bind(this);
  1709. _boundEvents.afterPrint = this.afterPrint.bind(this);
  1710. eventBus._on("resize", webViewerResize);
  1711. eventBus._on("hashchange", webViewerHashchange);
  1712. eventBus._on("beforeprint", _boundEvents.beforePrint);
  1713. eventBus._on("afterprint", _boundEvents.afterPrint);
  1714. eventBus._on("pagerendered", webViewerPageRendered);
  1715. eventBus._on("updateviewarea", webViewerUpdateViewarea);
  1716. eventBus._on("pagechanging", webViewerPageChanging);
  1717. eventBus._on("scalechanging", webViewerScaleChanging);
  1718. eventBus._on("rotationchanging", webViewerRotationChanging);
  1719. eventBus._on("sidebarviewchanged", webViewerSidebarViewChanged);
  1720. eventBus._on("pagemode", webViewerPageMode);
  1721. eventBus._on("namedaction", webViewerNamedAction);
  1722. eventBus._on("presentationmodechanged", webViewerPresentationModeChanged);
  1723. eventBus._on("presentationmode", webViewerPresentationMode);
  1724. eventBus._on("print", webViewerPrint);
  1725. eventBus._on("download", webViewerDownload);
  1726. eventBus._on("save", webViewerSave);
  1727. eventBus._on("firstpage", webViewerFirstPage);
  1728. eventBus._on("lastpage", webViewerLastPage);
  1729. eventBus._on("nextpage", webViewerNextPage);
  1730. eventBus._on("previouspage", webViewerPreviousPage);
  1731. eventBus._on("zoomin", webViewerZoomIn);
  1732. eventBus._on("zoomout", webViewerZoomOut);
  1733. eventBus._on("zoomreset", webViewerZoomReset);
  1734. eventBus._on("pagenumberchanged", webViewerPageNumberChanged);
  1735. eventBus._on("scalechanged", webViewerScaleChanged);
  1736. eventBus._on("rotatecw", webViewerRotateCw);
  1737. eventBus._on("rotateccw", webViewerRotateCcw);
  1738. eventBus._on("optionalcontentconfig", webViewerOptionalContentConfig);
  1739. eventBus._on("switchscrollmode", webViewerSwitchScrollMode);
  1740. eventBus._on("scrollmodechanged", webViewerScrollModeChanged);
  1741. eventBus._on("switchspreadmode", webViewerSwitchSpreadMode);
  1742. eventBus._on("spreadmodechanged", webViewerSpreadModeChanged);
  1743. eventBus._on("documentproperties", webViewerDocumentProperties);
  1744. eventBus._on("find", webViewerFind);
  1745. eventBus._on("findfromurlhash", webViewerFindFromUrlHash);
  1746. eventBus._on("updatefindmatchescount", webViewerUpdateFindMatchesCount);
  1747. eventBus._on("updatefindcontrolstate", webViewerUpdateFindControlState);
  1748. eventBus._on("fileinputchange", webViewerFileInputChange);
  1749. eventBus._on("openfile", webViewerOpenFile);
  1750. },
  1751. bindWindowEvents: function bindWindowEvents() {
  1752. var eventBus = this.eventBus,
  1753. _boundEvents = this._boundEvents;
  1754. _boundEvents.windowResize = function () {
  1755. eventBus.dispatch("resize", {
  1756. source: window
  1757. });
  1758. };
  1759. _boundEvents.windowHashChange = function () {
  1760. eventBus.dispatch("hashchange", {
  1761. source: window,
  1762. hash: document.location.hash.substring(1)
  1763. });
  1764. };
  1765. _boundEvents.windowBeforePrint = function () {
  1766. eventBus.dispatch("beforeprint", {
  1767. source: window
  1768. });
  1769. };
  1770. _boundEvents.windowAfterPrint = function () {
  1771. eventBus.dispatch("afterprint", {
  1772. source: window
  1773. });
  1774. };
  1775. window.addEventListener("visibilitychange", webViewerVisibilityChange);
  1776. window.addEventListener("wheel", webViewerWheel, {
  1777. passive: false
  1778. });
  1779. window.addEventListener("touchstart", webViewerTouchStart, {
  1780. passive: false
  1781. });
  1782. window.addEventListener("click", webViewerClick);
  1783. window.addEventListener("keydown", webViewerKeyDown);
  1784. window.addEventListener("keyup", webViewerKeyUp);
  1785. window.addEventListener("resize", _boundEvents.windowResize);
  1786. window.addEventListener("hashchange", _boundEvents.windowHashChange);
  1787. window.addEventListener("beforeprint", _boundEvents.windowBeforePrint);
  1788. window.addEventListener("afterprint", _boundEvents.windowAfterPrint);
  1789. },
  1790. unbindEvents: function unbindEvents() {
  1791. var eventBus = this.eventBus,
  1792. _boundEvents = this._boundEvents;
  1793. eventBus._off("resize", webViewerResize);
  1794. eventBus._off("hashchange", webViewerHashchange);
  1795. eventBus._off("beforeprint", _boundEvents.beforePrint);
  1796. eventBus._off("afterprint", _boundEvents.afterPrint);
  1797. eventBus._off("pagerendered", webViewerPageRendered);
  1798. eventBus._off("updateviewarea", webViewerUpdateViewarea);
  1799. eventBus._off("pagechanging", webViewerPageChanging);
  1800. eventBus._off("scalechanging", webViewerScaleChanging);
  1801. eventBus._off("rotationchanging", webViewerRotationChanging);
  1802. eventBus._off("sidebarviewchanged", webViewerSidebarViewChanged);
  1803. eventBus._off("pagemode", webViewerPageMode);
  1804. eventBus._off("namedaction", webViewerNamedAction);
  1805. eventBus._off("presentationmodechanged", webViewerPresentationModeChanged);
  1806. eventBus._off("presentationmode", webViewerPresentationMode);
  1807. eventBus._off("print", webViewerPrint);
  1808. eventBus._off("download", webViewerDownload);
  1809. eventBus._off("save", webViewerSave);
  1810. eventBus._off("firstpage", webViewerFirstPage);
  1811. eventBus._off("lastpage", webViewerLastPage);
  1812. eventBus._off("nextpage", webViewerNextPage);
  1813. eventBus._off("previouspage", webViewerPreviousPage);
  1814. eventBus._off("zoomin", webViewerZoomIn);
  1815. eventBus._off("zoomout", webViewerZoomOut);
  1816. eventBus._off("zoomreset", webViewerZoomReset);
  1817. eventBus._off("pagenumberchanged", webViewerPageNumberChanged);
  1818. eventBus._off("scalechanged", webViewerScaleChanged);
  1819. eventBus._off("rotatecw", webViewerRotateCw);
  1820. eventBus._off("rotateccw", webViewerRotateCcw);
  1821. eventBus._off("optionalcontentconfig", webViewerOptionalContentConfig);
  1822. eventBus._off("switchscrollmode", webViewerSwitchScrollMode);
  1823. eventBus._off("scrollmodechanged", webViewerScrollModeChanged);
  1824. eventBus._off("switchspreadmode", webViewerSwitchSpreadMode);
  1825. eventBus._off("spreadmodechanged", webViewerSpreadModeChanged);
  1826. eventBus._off("documentproperties", webViewerDocumentProperties);
  1827. eventBus._off("find", webViewerFind);
  1828. eventBus._off("findfromurlhash", webViewerFindFromUrlHash);
  1829. eventBus._off("updatefindmatchescount", webViewerUpdateFindMatchesCount);
  1830. eventBus._off("updatefindcontrolstate", webViewerUpdateFindControlState);
  1831. eventBus._off("fileinputchange", webViewerFileInputChange);
  1832. eventBus._off("openfile", webViewerOpenFile);
  1833. _boundEvents.beforePrint = null;
  1834. _boundEvents.afterPrint = null;
  1835. },
  1836. unbindWindowEvents: function unbindWindowEvents() {
  1837. var _boundEvents = this._boundEvents;
  1838. window.removeEventListener("visibilitychange", webViewerVisibilityChange);
  1839. window.removeEventListener("wheel", webViewerWheel, {
  1840. passive: false
  1841. });
  1842. window.removeEventListener("touchstart", webViewerTouchStart, {
  1843. passive: false
  1844. });
  1845. window.removeEventListener("click", webViewerClick);
  1846. window.removeEventListener("keydown", webViewerKeyDown);
  1847. window.removeEventListener("keyup", webViewerKeyUp);
  1848. window.removeEventListener("resize", _boundEvents.windowResize);
  1849. window.removeEventListener("hashchange", _boundEvents.windowHashChange);
  1850. window.removeEventListener("beforeprint", _boundEvents.windowBeforePrint);
  1851. window.removeEventListener("afterprint", _boundEvents.windowAfterPrint);
  1852. _boundEvents.windowResize = null;
  1853. _boundEvents.windowHashChange = null;
  1854. _boundEvents.windowBeforePrint = null;
  1855. _boundEvents.windowAfterPrint = null;
  1856. },
  1857. accumulateWheelTicks: function accumulateWheelTicks(ticks) {
  1858. if (this._wheelUnusedTicks > 0 && ticks < 0 || this._wheelUnusedTicks < 0 && ticks > 0) {
  1859. this._wheelUnusedTicks = 0;
  1860. }
  1861. this._wheelUnusedTicks += ticks;
  1862. var wholeTicks = Math.sign(this._wheelUnusedTicks) * Math.floor(Math.abs(this._wheelUnusedTicks));
  1863. this._wheelUnusedTicks -= wholeTicks;
  1864. return wholeTicks;
  1865. }
  1866. };
  1867. exports.PDFViewerApplication = PDFViewerApplication;
  1868. var validateFileURL;
  1869. {
  1870. var HOSTED_VIEWER_ORIGINS = ["null", "http://mozilla.github.io", "https://mozilla.github.io"];
  1871. validateFileURL = function validateFileURL(file) {
  1872. if (file === undefined) {
  1873. return;
  1874. }
  1875. try {
  1876. var viewerOrigin = new URL(window.location.href).origin || "null";
  1877. if (HOSTED_VIEWER_ORIGINS.includes(viewerOrigin)) {
  1878. return;
  1879. }
  1880. var _URL = new URL(file, window.location.href),
  1881. origin = _URL.origin,
  1882. protocol = _URL.protocol;
  1883. //跨域限制
  1884. // if (origin !== viewerOrigin && protocol !== "blob:") {
  1885. // throw new Error("file origin does not match viewer's");
  1886. // }
  1887. } catch (ex) {
  1888. var message = ex && ex.message;
  1889. PDFViewerApplication.l10n.get("loading_error", null, "An error occurred while loading the PDF.").then(function (loadingErrorMessage) {
  1890. PDFViewerApplication.error(loadingErrorMessage, {
  1891. message: message
  1892. });
  1893. });
  1894. throw ex;
  1895. }
  1896. };
  1897. }
  1898. function loadFakeWorker() {
  1899. return _loadFakeWorker.apply(this, arguments);
  1900. }
  1901. function _loadFakeWorker() {
  1902. _loadFakeWorker = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee13() {
  1903. return _regenerator["default"].wrap(function _callee13$(_context13) {
  1904. while (1) {
  1905. switch (_context13.prev = _context13.next) {
  1906. case 0:
  1907. if (!_pdfjsLib.GlobalWorkerOptions.workerSrc) {
  1908. _pdfjsLib.GlobalWorkerOptions.workerSrc = _app_options.AppOptions.get("workerSrc");
  1909. }
  1910. return _context13.abrupt("return", (0, _pdfjsLib.loadScript)(_pdfjsLib.PDFWorker.getWorkerSrc()));
  1911. case 2:
  1912. case "end":
  1913. return _context13.stop();
  1914. }
  1915. }
  1916. }, _callee13);
  1917. }));
  1918. return _loadFakeWorker.apply(this, arguments);
  1919. }
  1920. function loadAndEnablePDFBug(enabledTabs) {
  1921. var appConfig = PDFViewerApplication.appConfig;
  1922. return (0, _pdfjsLib.loadScript)(appConfig.debuggerScriptPath).then(function () {
  1923. PDFBug.enable(enabledTabs);
  1924. PDFBug.init({
  1925. OPS: _pdfjsLib.OPS
  1926. }, appConfig.mainContainer);
  1927. });
  1928. }
  1929. function webViewerInitialized() {
  1930. var appConfig = PDFViewerApplication.appConfig;
  1931. var file;
  1932. var queryString = document.location.search.substring(1);
  1933. var params = (0, _ui_utils.parseQueryString)(queryString);
  1934. file = "file" in params ? params.file : _app_options.AppOptions.get("defaultUrl");
  1935. validateFileURL(file);
  1936. var fileInput = document.createElement("input");
  1937. fileInput.id = appConfig.openFileInputName;
  1938. fileInput.className = "fileInput";
  1939. fileInput.setAttribute("type", "file");
  1940. fileInput.oncontextmenu = _ui_utils.noContextMenuHandler;
  1941. document.body.appendChild(fileInput);
  1942. if (!window.File || !window.FileReader || !window.FileList || !window.Blob) {
  1943. appConfig.toolbar.openFile.setAttribute("hidden", "true");
  1944. appConfig.secondaryToolbar.openFileButton.setAttribute("hidden", "true");
  1945. } else {
  1946. fileInput.value = null;
  1947. }
  1948. fileInput.addEventListener("change", function (evt) {
  1949. var files = evt.target.files;
  1950. if (!files || files.length === 0) {
  1951. return;
  1952. }
  1953. PDFViewerApplication.eventBus.dispatch("fileinputchange", {
  1954. source: this,
  1955. fileInput: evt.target
  1956. });
  1957. });
  1958. appConfig.mainContainer.addEventListener("dragover", function (evt) {
  1959. evt.preventDefault();
  1960. evt.dataTransfer.dropEffect = "move";
  1961. });
  1962. appConfig.mainContainer.addEventListener("drop", function (evt) {
  1963. evt.preventDefault();
  1964. var files = evt.dataTransfer.files;
  1965. if (!files || files.length === 0) {
  1966. return;
  1967. }
  1968. PDFViewerApplication.eventBus.dispatch("fileinputchange", {
  1969. source: this,
  1970. fileInput: evt.dataTransfer
  1971. });
  1972. });
  1973. if (!PDFViewerApplication.supportsDocumentFonts) {
  1974. _app_options.AppOptions.set("disableFontFace", true);
  1975. PDFViewerApplication.l10n.get("web_fonts_disabled", null, "Web fonts are disabled: unable to use embedded PDF fonts.").then(function (msg) {
  1976. console.warn(msg);
  1977. });
  1978. }
  1979. if (!PDFViewerApplication.supportsPrinting) {
  1980. appConfig.toolbar.print.classList.add("hidden");
  1981. appConfig.secondaryToolbar.printButton.classList.add("hidden");
  1982. }
  1983. if (!PDFViewerApplication.supportsFullscreen) {
  1984. appConfig.toolbar.presentationModeButton.classList.add("hidden");
  1985. appConfig.secondaryToolbar.presentationModeButton.classList.add("hidden");
  1986. }
  1987. if (PDFViewerApplication.supportsIntegratedFind) {
  1988. appConfig.toolbar.viewFind.classList.add("hidden");
  1989. }
  1990. appConfig.mainContainer.addEventListener("transitionend", function (evt) {
  1991. if (evt.target === this) {
  1992. PDFViewerApplication.eventBus.dispatch("resize", {
  1993. source: this
  1994. });
  1995. }
  1996. }, true);
  1997. try {
  1998. webViewerOpenFileViaURL(file);
  1999. } catch (reason) {
  2000. PDFViewerApplication.l10n.get("loading_error", null, "An error occurred while loading the PDF.").then(function (msg) {
  2001. PDFViewerApplication.error(msg, reason);
  2002. });
  2003. }
  2004. }
  2005. var webViewerOpenFileViaURL;
  2006. {
  2007. webViewerOpenFileViaURL = function webViewerOpenFileViaURL(file) {
  2008. if (file && file.lastIndexOf("file:", 0) === 0) {
  2009. PDFViewerApplication.setTitleUsingUrl(file);
  2010. var xhr = new XMLHttpRequest();
  2011. xhr.onload = function () {
  2012. PDFViewerApplication.open(new Uint8Array(xhr.response));
  2013. };
  2014. xhr.open("GET", file);
  2015. xhr.responseType = "arraybuffer";
  2016. xhr.send();
  2017. return;
  2018. }
  2019. if (file) {
  2020. PDFViewerApplication.open(file);
  2021. }
  2022. };
  2023. }
  2024. function webViewerResetPermissions() {
  2025. var appConfig = PDFViewerApplication.appConfig;
  2026. if (!appConfig) {
  2027. return;
  2028. }
  2029. appConfig.viewerContainer.classList.remove(ENABLE_PERMISSIONS_CLASS);
  2030. }
  2031. function webViewerPageRendered(evt) {
  2032. var pageNumber = evt.pageNumber;
  2033. var pageIndex = pageNumber - 1;
  2034. var pageView = PDFViewerApplication.pdfViewer.getPageView(pageIndex);
  2035. if (pageNumber === PDFViewerApplication.page) {
  2036. PDFViewerApplication.toolbar.updateLoadingIndicatorState(false);
  2037. }
  2038. if (!pageView) {
  2039. return;
  2040. }
  2041. if (PDFViewerApplication.pdfSidebar.isThumbnailViewVisible) {
  2042. var thumbnailView = PDFViewerApplication.pdfThumbnailViewer.getThumbnail(pageIndex);
  2043. thumbnailView.setImage(pageView);
  2044. }
  2045. if (typeof Stats !== "undefined" && Stats.enabled && pageView.stats) {
  2046. Stats.add(pageNumber, pageView.stats);
  2047. }
  2048. if (pageView.error) {
  2049. PDFViewerApplication.l10n.get("rendering_error", null, "An error occurred while rendering the page.").then(function (msg) {
  2050. PDFViewerApplication.error(msg, pageView.error);
  2051. });
  2052. }
  2053. PDFViewerApplication.externalServices.reportTelemetry({
  2054. type: "pageInfo",
  2055. timestamp: evt.timestamp
  2056. });
  2057. PDFViewerApplication.pdfDocument.getStats().then(function (stats) {
  2058. PDFViewerApplication.externalServices.reportTelemetry({
  2059. type: "documentStats",
  2060. stats: stats
  2061. });
  2062. });
  2063. }
  2064. function webViewerPageMode(_ref9) {
  2065. var mode = _ref9.mode;
  2066. var view;
  2067. switch (mode) {
  2068. case "thumbs":
  2069. view = _pdf_sidebar.SidebarView.THUMBS;
  2070. break;
  2071. case "bookmarks":
  2072. case "outline":
  2073. view = _pdf_sidebar.SidebarView.OUTLINE;
  2074. break;
  2075. case "attachments":
  2076. view = _pdf_sidebar.SidebarView.ATTACHMENTS;
  2077. break;
  2078. case "layers":
  2079. view = _pdf_sidebar.SidebarView.LAYERS;
  2080. break;
  2081. case "none":
  2082. view = _pdf_sidebar.SidebarView.NONE;
  2083. break;
  2084. default:
  2085. console.error('Invalid "pagemode" hash parameter: ' + mode);
  2086. return;
  2087. }
  2088. PDFViewerApplication.pdfSidebar.switchView(view, true);
  2089. }
  2090. function webViewerNamedAction(evt) {
  2091. switch (evt.action) {
  2092. case "GoToPage":
  2093. PDFViewerApplication.appConfig.toolbar.pageNumber.select();
  2094. break;
  2095. case "Find":
  2096. if (!PDFViewerApplication.supportsIntegratedFind) {
  2097. PDFViewerApplication.findBar.toggle();
  2098. }
  2099. break;
  2100. case "Print":
  2101. if (PDFViewerApplication.supportsPrinting) {
  2102. webViewerPrint();
  2103. }
  2104. break;
  2105. case "SaveAs":
  2106. webViewerSave();
  2107. break;
  2108. }
  2109. }
  2110. function webViewerPresentationModeChanged(_ref10) {
  2111. var active = _ref10.active,
  2112. switchInProgress = _ref10.switchInProgress;
  2113. var state = _ui_utils.PresentationModeState.NORMAL;
  2114. if (switchInProgress) {
  2115. state = _ui_utils.PresentationModeState.CHANGING;
  2116. } else if (active) {
  2117. state = _ui_utils.PresentationModeState.FULLSCREEN;
  2118. }
  2119. PDFViewerApplication.pdfViewer.presentationModeState = state;
  2120. }
  2121. function webViewerSidebarViewChanged(evt) {
  2122. PDFViewerApplication.pdfRenderingQueue.isThumbnailViewEnabled = PDFViewerApplication.pdfSidebar.isThumbnailViewVisible;
  2123. var store = PDFViewerApplication.store;
  2124. if (store && PDFViewerApplication.isInitialViewSet) {
  2125. store.set("sidebarView", evt.view)["catch"](function () {});
  2126. }
  2127. }
  2128. function webViewerUpdateViewarea(evt) {
  2129. var location = evt.location,
  2130. store = PDFViewerApplication.store;
  2131. if (store && PDFViewerApplication.isInitialViewSet) {
  2132. store.setMultiple({
  2133. page: location.pageNumber,
  2134. zoom: location.scale,
  2135. scrollLeft: location.left,
  2136. scrollTop: location.top,
  2137. rotation: location.rotation
  2138. })["catch"](function () {});
  2139. }
  2140. var href = PDFViewerApplication.pdfLinkService.getAnchorUrl(location.pdfOpenParams);
  2141. PDFViewerApplication.appConfig.toolbar.viewBookmark.href = href;
  2142. PDFViewerApplication.appConfig.secondaryToolbar.viewBookmarkButton.href = href;
  2143. var currentPage = PDFViewerApplication.pdfViewer.getPageView(PDFViewerApplication.page - 1);
  2144. var loading = currentPage.renderingState !== _pdf_rendering_queue.RenderingStates.FINISHED;
  2145. PDFViewerApplication.toolbar.updateLoadingIndicatorState(loading);
  2146. }
  2147. function webViewerScrollModeChanged(evt) {
  2148. var store = PDFViewerApplication.store;
  2149. if (store && PDFViewerApplication.isInitialViewSet) {
  2150. store.set("scrollMode", evt.mode)["catch"](function () {});
  2151. }
  2152. }
  2153. function webViewerSpreadModeChanged(evt) {
  2154. var store = PDFViewerApplication.store;
  2155. if (store && PDFViewerApplication.isInitialViewSet) {
  2156. store.set("spreadMode", evt.mode)["catch"](function () {});
  2157. }
  2158. }
  2159. function webViewerResize() {
  2160. var pdfDocument = PDFViewerApplication.pdfDocument,
  2161. pdfViewer = PDFViewerApplication.pdfViewer;
  2162. if (!pdfDocument) {
  2163. return;
  2164. }
  2165. var currentScaleValue = pdfViewer.currentScaleValue;
  2166. if (currentScaleValue === "auto" || currentScaleValue === "page-fit" || currentScaleValue === "page-width") {
  2167. pdfViewer.currentScaleValue = currentScaleValue;
  2168. }
  2169. pdfViewer.update();
  2170. }
  2171. function webViewerHashchange(evt) {
  2172. var hash = evt.hash;
  2173. if (!hash) {
  2174. return;
  2175. }
  2176. if (!PDFViewerApplication.isInitialViewSet) {
  2177. PDFViewerApplication.initialBookmark = hash;
  2178. } else if (!PDFViewerApplication.pdfHistory.popStateInProgress) {
  2179. PDFViewerApplication.pdfLinkService.setHash(hash);
  2180. }
  2181. }
  2182. var webViewerFileInputChange, webViewerOpenFile;
  2183. {
  2184. webViewerFileInputChange = function webViewerFileInputChange(evt) {
  2185. if (PDFViewerApplication.pdfViewer && PDFViewerApplication.pdfViewer.isInPresentationMode) {
  2186. return;
  2187. }
  2188. var file = evt.fileInput.files[0];
  2189. if (!_viewer_compatibility.viewerCompatibilityParams.disableCreateObjectURL) {
  2190. var url = URL.createObjectURL(file);
  2191. if (file.name) {
  2192. url = {
  2193. url: url,
  2194. originalUrl: file.name
  2195. };
  2196. }
  2197. PDFViewerApplication.open(url);
  2198. } else {
  2199. PDFViewerApplication.setTitleUsingUrl(file.name);
  2200. var fileReader = new FileReader();
  2201. fileReader.onload = function webViewerChangeFileReaderOnload(event) {
  2202. var buffer = event.target.result;
  2203. PDFViewerApplication.open(new Uint8Array(buffer));
  2204. };
  2205. fileReader.readAsArrayBuffer(file);
  2206. }
  2207. var appConfig = PDFViewerApplication.appConfig;
  2208. appConfig.toolbar.viewBookmark.setAttribute("hidden", "true");
  2209. appConfig.secondaryToolbar.viewBookmarkButton.setAttribute("hidden", "true");
  2210. appConfig.toolbar.download.setAttribute("hidden", "true");
  2211. appConfig.secondaryToolbar.downloadButton.setAttribute("hidden", "true");
  2212. };
  2213. webViewerOpenFile = function webViewerOpenFile(evt) {
  2214. var openFileInputName = PDFViewerApplication.appConfig.openFileInputName;
  2215. document.getElementById(openFileInputName).click();
  2216. };
  2217. }
  2218. function webViewerPresentationMode() {
  2219. PDFViewerApplication.requestPresentationMode();
  2220. }
  2221. function webViewerPrint() {
  2222. window.print();
  2223. }
  2224. function webViewerDownloadOrSave(sourceEventType) {
  2225. if (PDFViewerApplication.pdfDocument && PDFViewerApplication.pdfDocument.annotationStorage.size > 0) {
  2226. PDFViewerApplication.save({
  2227. sourceEventType: sourceEventType
  2228. });
  2229. } else {
  2230. PDFViewerApplication.download({
  2231. sourceEventType: sourceEventType
  2232. });
  2233. }
  2234. }
  2235. function webViewerDownload() {
  2236. webViewerDownloadOrSave("download");
  2237. }
  2238. function webViewerSave() {
  2239. webViewerDownloadOrSave("save");
  2240. }
  2241. function webViewerFirstPage() {
  2242. if (PDFViewerApplication.pdfDocument) {
  2243. PDFViewerApplication.page = 1;
  2244. }
  2245. }
  2246. function webViewerLastPage() {
  2247. if (PDFViewerApplication.pdfDocument) {
  2248. PDFViewerApplication.page = PDFViewerApplication.pagesCount;
  2249. }
  2250. }
  2251. function webViewerNextPage() {
  2252. PDFViewerApplication.page++;
  2253. }
  2254. function webViewerPreviousPage() {
  2255. PDFViewerApplication.page--;
  2256. }
  2257. function webViewerZoomIn() {
  2258. PDFViewerApplication.zoomIn();
  2259. }
  2260. function webViewerZoomOut() {
  2261. PDFViewerApplication.zoomOut();
  2262. }
  2263. function webViewerZoomReset() {
  2264. PDFViewerApplication.zoomReset();
  2265. }
  2266. function webViewerPageNumberChanged(evt) {
  2267. var pdfViewer = PDFViewerApplication.pdfViewer;
  2268. if (evt.value !== "") {
  2269. pdfViewer.currentPageLabel = evt.value;
  2270. }
  2271. if (evt.value !== pdfViewer.currentPageNumber.toString() && evt.value !== pdfViewer.currentPageLabel) {
  2272. PDFViewerApplication.toolbar.setPageNumber(pdfViewer.currentPageNumber, pdfViewer.currentPageLabel);
  2273. }
  2274. }
  2275. function webViewerScaleChanged(evt) {
  2276. PDFViewerApplication.pdfViewer.currentScaleValue = evt.value;
  2277. }
  2278. function webViewerRotateCw() {
  2279. PDFViewerApplication.rotatePages(90);
  2280. }
  2281. function webViewerRotateCcw() {
  2282. PDFViewerApplication.rotatePages(-90);
  2283. }
  2284. function webViewerOptionalContentConfig(evt) {
  2285. PDFViewerApplication.pdfViewer.optionalContentConfigPromise = evt.promise;
  2286. }
  2287. function webViewerSwitchScrollMode(evt) {
  2288. PDFViewerApplication.pdfViewer.scrollMode = evt.mode;
  2289. }
  2290. function webViewerSwitchSpreadMode(evt) {
  2291. PDFViewerApplication.pdfViewer.spreadMode = evt.mode;
  2292. }
  2293. function webViewerDocumentProperties() {
  2294. PDFViewerApplication.pdfDocumentProperties.open();
  2295. }
  2296. function webViewerFind(evt) {
  2297. PDFViewerApplication.findController.executeCommand("find" + evt.type, {
  2298. query: evt.query,
  2299. phraseSearch: evt.phraseSearch,
  2300. caseSensitive: evt.caseSensitive,
  2301. entireWord: evt.entireWord,
  2302. highlightAll: evt.highlightAll,
  2303. findPrevious: evt.findPrevious
  2304. });
  2305. }
  2306. function webViewerFindFromUrlHash(evt) {
  2307. PDFViewerApplication.findController.executeCommand("find", {
  2308. query: evt.query,
  2309. phraseSearch: evt.phraseSearch,
  2310. caseSensitive: false,
  2311. entireWord: false,
  2312. highlightAll: true,
  2313. findPrevious: false
  2314. });
  2315. }
  2316. function webViewerUpdateFindMatchesCount(_ref11) {
  2317. var matchesCount = _ref11.matchesCount;
  2318. if (PDFViewerApplication.supportsIntegratedFind) {
  2319. PDFViewerApplication.externalServices.updateFindMatchesCount(matchesCount);
  2320. } else {
  2321. PDFViewerApplication.findBar.updateResultsCount(matchesCount);
  2322. }
  2323. }
  2324. function webViewerUpdateFindControlState(_ref12) {
  2325. var state = _ref12.state,
  2326. previous = _ref12.previous,
  2327. matchesCount = _ref12.matchesCount,
  2328. rawQuery = _ref12.rawQuery;
  2329. if (PDFViewerApplication.supportsIntegratedFind) {
  2330. PDFViewerApplication.externalServices.updateFindControlState({
  2331. result: state,
  2332. findPrevious: previous,
  2333. matchesCount: matchesCount,
  2334. rawQuery: rawQuery
  2335. });
  2336. } else {
  2337. PDFViewerApplication.findBar.updateUIState(state, previous, matchesCount);
  2338. }
  2339. }
  2340. function webViewerScaleChanging(evt) {
  2341. PDFViewerApplication.toolbar.setPageScale(evt.presetValue, evt.scale);
  2342. PDFViewerApplication.pdfViewer.update();
  2343. }
  2344. function webViewerRotationChanging(evt) {
  2345. PDFViewerApplication.pdfThumbnailViewer.pagesRotation = evt.pagesRotation;
  2346. PDFViewerApplication.forceRendering();
  2347. PDFViewerApplication.pdfViewer.currentPageNumber = evt.pageNumber;
  2348. }
  2349. function webViewerPageChanging(evt) {
  2350. var page = evt.pageNumber;
  2351. PDFViewerApplication.toolbar.setPageNumber(page, evt.pageLabel || null);
  2352. PDFViewerApplication.secondaryToolbar.setPageNumber(page);
  2353. if (PDFViewerApplication.pdfSidebar.isThumbnailViewVisible) {
  2354. PDFViewerApplication.pdfThumbnailViewer.scrollThumbnailIntoView(page);
  2355. }
  2356. if (typeof Stats !== "undefined" && Stats.enabled) {
  2357. var pageView = PDFViewerApplication.pdfViewer.getPageView(page - 1);
  2358. if (pageView && pageView.stats) {
  2359. Stats.add(page, pageView.stats);
  2360. }
  2361. }
  2362. }
  2363. function webViewerVisibilityChange(evt) {
  2364. if (document.visibilityState === "visible") {
  2365. setZoomDisabledTimeout();
  2366. }
  2367. }
  2368. var zoomDisabledTimeout = null;
  2369. function setZoomDisabledTimeout() {
  2370. if (zoomDisabledTimeout) {
  2371. clearTimeout(zoomDisabledTimeout);
  2372. }
  2373. zoomDisabledTimeout = setTimeout(function () {
  2374. zoomDisabledTimeout = null;
  2375. }, WHEEL_ZOOM_DISABLED_TIMEOUT);
  2376. }
  2377. function webViewerWheel(evt) {
  2378. var pdfViewer = PDFViewerApplication.pdfViewer,
  2379. supportedMouseWheelZoomModifierKeys = PDFViewerApplication.supportedMouseWheelZoomModifierKeys;
  2380. if (pdfViewer.isInPresentationMode) {
  2381. return;
  2382. }
  2383. if (evt.ctrlKey && supportedMouseWheelZoomModifierKeys.ctrlKey || evt.metaKey && supportedMouseWheelZoomModifierKeys.metaKey) {
  2384. evt.preventDefault();
  2385. if (zoomDisabledTimeout || document.visibilityState === "hidden") {
  2386. return;
  2387. }
  2388. var previousScale = pdfViewer.currentScale;
  2389. var delta = (0, _ui_utils.normalizeWheelEventDirection)(evt);
  2390. var ticks = 0;
  2391. if (evt.deltaMode === WheelEvent.DOM_DELTA_LINE || evt.deltaMode === WheelEvent.DOM_DELTA_PAGE) {
  2392. if (Math.abs(delta) >= 1) {
  2393. ticks = Math.sign(delta);
  2394. } else {
  2395. ticks = PDFViewerApplication.accumulateWheelTicks(delta);
  2396. }
  2397. } else {
  2398. var PIXELS_PER_LINE_SCALE = 30;
  2399. ticks = PDFViewerApplication.accumulateWheelTicks(delta / PIXELS_PER_LINE_SCALE);
  2400. }
  2401. if (ticks < 0) {
  2402. PDFViewerApplication.zoomOut(-ticks);
  2403. } else if (ticks > 0) {
  2404. PDFViewerApplication.zoomIn(ticks);
  2405. }
  2406. var currentScale = pdfViewer.currentScale;
  2407. if (previousScale !== currentScale) {
  2408. var scaleCorrectionFactor = currentScale / previousScale - 1;
  2409. var rect = pdfViewer.container.getBoundingClientRect();
  2410. var dx = evt.clientX - rect.left;
  2411. var dy = evt.clientY - rect.top;
  2412. pdfViewer.container.scrollLeft += dx * scaleCorrectionFactor;
  2413. pdfViewer.container.scrollTop += dy * scaleCorrectionFactor;
  2414. }
  2415. } else {
  2416. setZoomDisabledTimeout();
  2417. }
  2418. }
  2419. function webViewerTouchStart(evt) {
  2420. if (evt.touches.length > 1) {
  2421. evt.preventDefault();
  2422. }
  2423. }
  2424. function webViewerClick(evt) {
  2425. if (PDFViewerApplication.triggerDelayedFallback && PDFViewerApplication.pdfViewer.containsElement(evt.target)) {
  2426. PDFViewerApplication.triggerDelayedFallback();
  2427. }
  2428. if (!PDFViewerApplication.secondaryToolbar.isOpen) {
  2429. return;
  2430. }
  2431. var appConfig = PDFViewerApplication.appConfig;
  2432. if (PDFViewerApplication.pdfViewer.containsElement(evt.target) || appConfig.toolbar.container.contains(evt.target) && evt.target !== appConfig.secondaryToolbar.toggleButton) {
  2433. PDFViewerApplication.secondaryToolbar.close();
  2434. }
  2435. }
  2436. function webViewerKeyUp(evt) {
  2437. if (evt.keyCode === 9) {
  2438. if (PDFViewerApplication.triggerDelayedFallback) {
  2439. PDFViewerApplication.triggerDelayedFallback();
  2440. }
  2441. }
  2442. }
  2443. function webViewerKeyDown(evt) {
  2444. if (PDFViewerApplication.overlayManager.active) {
  2445. return;
  2446. }
  2447. var handled = false,
  2448. ensureViewerFocused = false;
  2449. var cmd = (evt.ctrlKey ? 1 : 0) | (evt.altKey ? 2 : 0) | (evt.shiftKey ? 4 : 0) | (evt.metaKey ? 8 : 0);
  2450. var pdfViewer = PDFViewerApplication.pdfViewer;
  2451. var isViewerInPresentationMode = pdfViewer && pdfViewer.isInPresentationMode;
  2452. if (cmd === 1 || cmd === 8 || cmd === 5 || cmd === 12) {
  2453. switch (evt.keyCode) {
  2454. case 70:
  2455. if (!PDFViewerApplication.supportsIntegratedFind) {
  2456. PDFViewerApplication.findBar.open();
  2457. handled = true;
  2458. }
  2459. break;
  2460. case 71:
  2461. if (!PDFViewerApplication.supportsIntegratedFind) {
  2462. var findState = PDFViewerApplication.findController.state;
  2463. if (findState) {
  2464. PDFViewerApplication.findController.executeCommand("findagain", {
  2465. query: findState.query,
  2466. phraseSearch: findState.phraseSearch,
  2467. caseSensitive: findState.caseSensitive,
  2468. entireWord: findState.entireWord,
  2469. highlightAll: findState.highlightAll,
  2470. findPrevious: cmd === 5 || cmd === 12
  2471. });
  2472. }
  2473. handled = true;
  2474. }
  2475. break;
  2476. case 61:
  2477. case 107:
  2478. case 187:
  2479. case 171:
  2480. if (!isViewerInPresentationMode) {
  2481. PDFViewerApplication.zoomIn();
  2482. }
  2483. handled = true;
  2484. break;
  2485. case 173:
  2486. case 109:
  2487. case 189:
  2488. if (!isViewerInPresentationMode) {
  2489. PDFViewerApplication.zoomOut();
  2490. }
  2491. handled = true;
  2492. break;
  2493. case 48:
  2494. case 96:
  2495. if (!isViewerInPresentationMode) {
  2496. setTimeout(function () {
  2497. PDFViewerApplication.zoomReset();
  2498. });
  2499. handled = false;
  2500. }
  2501. break;
  2502. case 38:
  2503. if (isViewerInPresentationMode || PDFViewerApplication.page > 1) {
  2504. PDFViewerApplication.page = 1;
  2505. handled = true;
  2506. ensureViewerFocused = true;
  2507. }
  2508. break;
  2509. case 40:
  2510. if (isViewerInPresentationMode || PDFViewerApplication.page < PDFViewerApplication.pagesCount) {
  2511. PDFViewerApplication.page = PDFViewerApplication.pagesCount;
  2512. handled = true;
  2513. ensureViewerFocused = true;
  2514. }
  2515. break;
  2516. }
  2517. }
  2518. var eventBus = PDFViewerApplication.eventBus;
  2519. if (cmd === 1 || cmd === 8) {
  2520. switch (evt.keyCode) {
  2521. case 83:
  2522. eventBus.dispatch("download", {
  2523. source: window
  2524. });
  2525. handled = true;
  2526. break;
  2527. case 79:
  2528. {
  2529. eventBus.dispatch("openfile", {
  2530. source: window
  2531. });
  2532. handled = true;
  2533. }
  2534. break;
  2535. }
  2536. }
  2537. if (cmd === 3 || cmd === 10) {
  2538. switch (evt.keyCode) {
  2539. case 80:
  2540. PDFViewerApplication.requestPresentationMode();
  2541. handled = true;
  2542. break;
  2543. case 71:
  2544. PDFViewerApplication.appConfig.toolbar.pageNumber.select();
  2545. handled = true;
  2546. break;
  2547. }
  2548. }
  2549. if (handled) {
  2550. if (ensureViewerFocused && !isViewerInPresentationMode) {
  2551. pdfViewer.focus();
  2552. }
  2553. evt.preventDefault();
  2554. return;
  2555. }
  2556. var curElement = document.activeElement || document.querySelector(":focus");
  2557. var curElementTagName = curElement && curElement.tagName.toUpperCase();
  2558. if (curElementTagName === "INPUT" || curElementTagName === "TEXTAREA" || curElementTagName === "SELECT" || curElement && curElement.isContentEditable) {
  2559. if (evt.keyCode !== 27) {
  2560. return;
  2561. }
  2562. }
  2563. if (cmd === 0) {
  2564. var turnPage = 0,
  2565. turnOnlyIfPageFit = false;
  2566. switch (evt.keyCode) {
  2567. case 38:
  2568. case 33:
  2569. if (pdfViewer.isVerticalScrollbarEnabled) {
  2570. turnOnlyIfPageFit = true;
  2571. }
  2572. turnPage = -1;
  2573. break;
  2574. case 8:
  2575. if (!isViewerInPresentationMode) {
  2576. turnOnlyIfPageFit = true;
  2577. }
  2578. turnPage = -1;
  2579. break;
  2580. case 37:
  2581. if (pdfViewer.isHorizontalScrollbarEnabled) {
  2582. turnOnlyIfPageFit = true;
  2583. }
  2584. case 75:
  2585. case 80:
  2586. turnPage = -1;
  2587. break;
  2588. case 27:
  2589. if (PDFViewerApplication.secondaryToolbar.isOpen) {
  2590. PDFViewerApplication.secondaryToolbar.close();
  2591. handled = true;
  2592. }
  2593. if (!PDFViewerApplication.supportsIntegratedFind && PDFViewerApplication.findBar.opened) {
  2594. PDFViewerApplication.findBar.close();
  2595. handled = true;
  2596. }
  2597. break;
  2598. case 40:
  2599. case 34:
  2600. if (pdfViewer.isVerticalScrollbarEnabled) {
  2601. turnOnlyIfPageFit = true;
  2602. }
  2603. turnPage = 1;
  2604. break;
  2605. case 13:
  2606. case 32:
  2607. if (!isViewerInPresentationMode) {
  2608. turnOnlyIfPageFit = true;
  2609. }
  2610. turnPage = 1;
  2611. break;
  2612. case 39:
  2613. if (pdfViewer.isHorizontalScrollbarEnabled) {
  2614. turnOnlyIfPageFit = true;
  2615. }
  2616. case 74:
  2617. case 78:
  2618. turnPage = 1;
  2619. break;
  2620. case 36:
  2621. if (isViewerInPresentationMode || PDFViewerApplication.page > 1) {
  2622. PDFViewerApplication.page = 1;
  2623. handled = true;
  2624. ensureViewerFocused = true;
  2625. }
  2626. break;
  2627. case 35:
  2628. if (isViewerInPresentationMode || PDFViewerApplication.page < PDFViewerApplication.pagesCount) {
  2629. PDFViewerApplication.page = PDFViewerApplication.pagesCount;
  2630. handled = true;
  2631. ensureViewerFocused = true;
  2632. }
  2633. break;
  2634. case 83:
  2635. PDFViewerApplication.pdfCursorTools.switchTool(_pdf_cursor_tools.CursorTool.SELECT);
  2636. break;
  2637. case 72:
  2638. PDFViewerApplication.pdfCursorTools.switchTool(_pdf_cursor_tools.CursorTool.HAND);
  2639. break;
  2640. case 82:
  2641. PDFViewerApplication.rotatePages(90);
  2642. break;
  2643. case 115:
  2644. PDFViewerApplication.pdfSidebar.toggle();
  2645. break;
  2646. }
  2647. if (turnPage !== 0 && (!turnOnlyIfPageFit || pdfViewer.currentScaleValue === "page-fit")) {
  2648. if (turnPage > 0) {
  2649. if (PDFViewerApplication.page < PDFViewerApplication.pagesCount) {
  2650. PDFViewerApplication.page++;
  2651. }
  2652. } else {
  2653. if (PDFViewerApplication.page > 1) {
  2654. PDFViewerApplication.page--;
  2655. }
  2656. }
  2657. handled = true;
  2658. }
  2659. }
  2660. if (cmd === 4) {
  2661. switch (evt.keyCode) {
  2662. case 13:
  2663. case 32:
  2664. if (!isViewerInPresentationMode && pdfViewer.currentScaleValue !== "page-fit") {
  2665. break;
  2666. }
  2667. if (PDFViewerApplication.page > 1) {
  2668. PDFViewerApplication.page--;
  2669. }
  2670. handled = true;
  2671. break;
  2672. case 82:
  2673. PDFViewerApplication.rotatePages(-90);
  2674. break;
  2675. }
  2676. }
  2677. if (!handled && !isViewerInPresentationMode) {
  2678. if (evt.keyCode >= 33 && evt.keyCode <= 40 || evt.keyCode === 32 && curElementTagName !== "BUTTON") {
  2679. ensureViewerFocused = true;
  2680. }
  2681. }
  2682. if (ensureViewerFocused && !pdfViewer.containsElement(curElement)) {
  2683. pdfViewer.focus();
  2684. }
  2685. if (handled) {
  2686. evt.preventDefault();
  2687. }
  2688. }
  2689. function beforeUnload(evt) {
  2690. evt.preventDefault();
  2691. evt.returnValue = "";
  2692. return false;
  2693. }
  2694. function apiPageLayoutToSpreadMode(layout) {
  2695. switch (layout) {
  2696. case "SinglePage":
  2697. case "OneColumn":
  2698. return _ui_utils.SpreadMode.NONE;
  2699. case "TwoColumnLeft":
  2700. case "TwoPageLeft":
  2701. return _ui_utils.SpreadMode.ODD;
  2702. case "TwoColumnRight":
  2703. case "TwoPageRight":
  2704. return _ui_utils.SpreadMode.EVEN;
  2705. }
  2706. return _ui_utils.SpreadMode.NONE;
  2707. }
  2708. function apiPageModeToSidebarView(mode) {
  2709. switch (mode) {
  2710. case "UseNone":
  2711. return _pdf_sidebar.SidebarView.NONE;
  2712. case "UseThumbs":
  2713. return _pdf_sidebar.SidebarView.THUMBS;
  2714. case "UseOutlines":
  2715. return _pdf_sidebar.SidebarView.OUTLINE;
  2716. case "UseAttachments":
  2717. return _pdf_sidebar.SidebarView.ATTACHMENTS;
  2718. case "UseOC":
  2719. return _pdf_sidebar.SidebarView.LAYERS;
  2720. }
  2721. return _pdf_sidebar.SidebarView.NONE;
  2722. }
  2723. var PDFPrintServiceFactory = {
  2724. instance: {
  2725. supportsPrinting: false,
  2726. createPrintService: function createPrintService() {
  2727. throw new Error("Not implemented: createPrintService");
  2728. }
  2729. }
  2730. };
  2731. exports.PDFPrintServiceFactory = PDFPrintServiceFactory;
  2732. /***/ }),
  2733. /* 2 */
  2734. /***/ (function(module, exports, __webpack_require__) {
  2735. "use strict";
  2736. module.exports = __webpack_require__(3);
  2737. /***/ }),
  2738. /* 3 */
  2739. /***/ (function(module, exports, __webpack_require__) {
  2740. "use strict";
  2741. /* WEBPACK VAR INJECTION */(function(module) {
  2742. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  2743. var runtime = function (exports) {
  2744. "use strict";
  2745. var Op = Object.prototype;
  2746. var hasOwn = Op.hasOwnProperty;
  2747. var undefined;
  2748. var $Symbol = typeof Symbol === "function" ? Symbol : {};
  2749. var iteratorSymbol = $Symbol.iterator || "@@iterator";
  2750. var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator";
  2751. var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
  2752. function define(obj, key, value) {
  2753. Object.defineProperty(obj, key, {
  2754. value: value,
  2755. enumerable: true,
  2756. configurable: true,
  2757. writable: true
  2758. });
  2759. return obj[key];
  2760. }
  2761. try {
  2762. define({}, "");
  2763. } catch (err) {
  2764. define = function define(obj, key, value) {
  2765. return obj[key] = value;
  2766. };
  2767. }
  2768. function wrap(innerFn, outerFn, self, tryLocsList) {
  2769. var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator;
  2770. var generator = Object.create(protoGenerator.prototype);
  2771. var context = new Context(tryLocsList || []);
  2772. generator._invoke = makeInvokeMethod(innerFn, self, context);
  2773. return generator;
  2774. }
  2775. exports.wrap = wrap;
  2776. function tryCatch(fn, obj, arg) {
  2777. try {
  2778. return {
  2779. type: "normal",
  2780. arg: fn.call(obj, arg)
  2781. };
  2782. } catch (err) {
  2783. return {
  2784. type: "throw",
  2785. arg: err
  2786. };
  2787. }
  2788. }
  2789. var GenStateSuspendedStart = "suspendedStart";
  2790. var GenStateSuspendedYield = "suspendedYield";
  2791. var GenStateExecuting = "executing";
  2792. var GenStateCompleted = "completed";
  2793. var ContinueSentinel = {};
  2794. function Generator() {}
  2795. function GeneratorFunction() {}
  2796. function GeneratorFunctionPrototype() {}
  2797. var IteratorPrototype = {};
  2798. IteratorPrototype[iteratorSymbol] = function () {
  2799. return this;
  2800. };
  2801. var getProto = Object.getPrototypeOf;
  2802. var NativeIteratorPrototype = getProto && getProto(getProto(values([])));
  2803. if (NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) {
  2804. IteratorPrototype = NativeIteratorPrototype;
  2805. }
  2806. var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype);
  2807. GeneratorFunction.prototype = Gp.constructor = GeneratorFunctionPrototype;
  2808. GeneratorFunctionPrototype.constructor = GeneratorFunction;
  2809. GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction");
  2810. function defineIteratorMethods(prototype) {
  2811. ["next", "throw", "return"].forEach(function (method) {
  2812. define(prototype, method, function (arg) {
  2813. return this._invoke(method, arg);
  2814. });
  2815. });
  2816. }
  2817. exports.isGeneratorFunction = function (genFun) {
  2818. var ctor = typeof genFun === "function" && genFun.constructor;
  2819. return ctor ? ctor === GeneratorFunction || (ctor.displayName || ctor.name) === "GeneratorFunction" : false;
  2820. };
  2821. exports.mark = function (genFun) {
  2822. if (Object.setPrototypeOf) {
  2823. Object.setPrototypeOf(genFun, GeneratorFunctionPrototype);
  2824. } else {
  2825. genFun.__proto__ = GeneratorFunctionPrototype;
  2826. define(genFun, toStringTagSymbol, "GeneratorFunction");
  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, PromiseImpl) {
  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 PromiseImpl.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 PromiseImpl.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 PromiseImpl(function (resolve, reject) {
  2863. invoke(method, arg, resolve, reject);
  2864. });
  2865. }
  2866. return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
  2867. }
  2868. this._invoke = enqueue;
  2869. }
  2870. defineIteratorMethods(AsyncIterator.prototype);
  2871. AsyncIterator.prototype[asyncIteratorSymbol] = function () {
  2872. return this;
  2873. };
  2874. exports.AsyncIterator = AsyncIterator;
  2875. exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) {
  2876. if (PromiseImpl === void 0) PromiseImpl = Promise;
  2877. var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl);
  2878. return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) {
  2879. return result.done ? result.value : iter.next();
  2880. });
  2881. };
  2882. function makeInvokeMethod(innerFn, self, context) {
  2883. var state = GenStateSuspendedStart;
  2884. return function invoke(method, arg) {
  2885. if (state === GenStateExecuting) {
  2886. throw new Error("Generator is already running");
  2887. }
  2888. if (state === GenStateCompleted) {
  2889. if (method === "throw") {
  2890. throw arg;
  2891. }
  2892. return doneResult();
  2893. }
  2894. context.method = method;
  2895. context.arg = arg;
  2896. while (true) {
  2897. var delegate = context.delegate;
  2898. if (delegate) {
  2899. var delegateResult = maybeInvokeDelegate(delegate, context);
  2900. if (delegateResult) {
  2901. if (delegateResult === ContinueSentinel) continue;
  2902. return delegateResult;
  2903. }
  2904. }
  2905. if (context.method === "next") {
  2906. context.sent = context._sent = context.arg;
  2907. } else if (context.method === "throw") {
  2908. if (state === GenStateSuspendedStart) {
  2909. state = GenStateCompleted;
  2910. throw context.arg;
  2911. }
  2912. context.dispatchException(context.arg);
  2913. } else if (context.method === "return") {
  2914. context.abrupt("return", context.arg);
  2915. }
  2916. state = GenStateExecuting;
  2917. var record = tryCatch(innerFn, self, context);
  2918. if (record.type === "normal") {
  2919. state = context.done ? GenStateCompleted : GenStateSuspendedYield;
  2920. if (record.arg === ContinueSentinel) {
  2921. continue;
  2922. }
  2923. return {
  2924. value: record.arg,
  2925. done: context.done
  2926. };
  2927. } else if (record.type === "throw") {
  2928. state = GenStateCompleted;
  2929. context.method = "throw";
  2930. context.arg = record.arg;
  2931. }
  2932. }
  2933. };
  2934. }
  2935. function maybeInvokeDelegate(delegate, context) {
  2936. var method = delegate.iterator[context.method];
  2937. if (method === undefined) {
  2938. context.delegate = null;
  2939. if (context.method === "throw") {
  2940. if (delegate.iterator["return"]) {
  2941. context.method = "return";
  2942. context.arg = undefined;
  2943. maybeInvokeDelegate(delegate, context);
  2944. if (context.method === "throw") {
  2945. return ContinueSentinel;
  2946. }
  2947. }
  2948. context.method = "throw";
  2949. context.arg = new TypeError("The iterator does not provide a 'throw' method");
  2950. }
  2951. return ContinueSentinel;
  2952. }
  2953. var record = tryCatch(method, delegate.iterator, context.arg);
  2954. if (record.type === "throw") {
  2955. context.method = "throw";
  2956. context.arg = record.arg;
  2957. context.delegate = null;
  2958. return ContinueSentinel;
  2959. }
  2960. var info = record.arg;
  2961. if (!info) {
  2962. context.method = "throw";
  2963. context.arg = new TypeError("iterator result is not an object");
  2964. context.delegate = null;
  2965. return ContinueSentinel;
  2966. }
  2967. if (info.done) {
  2968. context[delegate.resultName] = info.value;
  2969. context.next = delegate.nextLoc;
  2970. if (context.method !== "return") {
  2971. context.method = "next";
  2972. context.arg = undefined;
  2973. }
  2974. } else {
  2975. return info;
  2976. }
  2977. context.delegate = null;
  2978. return ContinueSentinel;
  2979. }
  2980. defineIteratorMethods(Gp);
  2981. define(Gp, toStringTagSymbol, "Generator");
  2982. Gp[iteratorSymbol] = function () {
  2983. return this;
  2984. };
  2985. Gp.toString = function () {
  2986. return "[object Generator]";
  2987. };
  2988. function pushTryEntry(locs) {
  2989. var entry = {
  2990. tryLoc: locs[0]
  2991. };
  2992. if (1 in locs) {
  2993. entry.catchLoc = locs[1];
  2994. }
  2995. if (2 in locs) {
  2996. entry.finallyLoc = locs[2];
  2997. entry.afterLoc = locs[3];
  2998. }
  2999. this.tryEntries.push(entry);
  3000. }
  3001. function resetTryEntry(entry) {
  3002. var record = entry.completion || {};
  3003. record.type = "normal";
  3004. delete record.arg;
  3005. entry.completion = record;
  3006. }
  3007. function Context(tryLocsList) {
  3008. this.tryEntries = [{
  3009. tryLoc: "root"
  3010. }];
  3011. tryLocsList.forEach(pushTryEntry, this);
  3012. this.reset(true);
  3013. }
  3014. exports.keys = function (object) {
  3015. var keys = [];
  3016. for (var key in object) {
  3017. keys.push(key);
  3018. }
  3019. keys.reverse();
  3020. return function next() {
  3021. while (keys.length) {
  3022. var key = keys.pop();
  3023. if (key in object) {
  3024. next.value = key;
  3025. next.done = false;
  3026. return next;
  3027. }
  3028. }
  3029. next.done = true;
  3030. return next;
  3031. };
  3032. };
  3033. function values(iterable) {
  3034. if (iterable) {
  3035. var iteratorMethod = iterable[iteratorSymbol];
  3036. if (iteratorMethod) {
  3037. return iteratorMethod.call(iterable);
  3038. }
  3039. if (typeof iterable.next === "function") {
  3040. return iterable;
  3041. }
  3042. if (!isNaN(iterable.length)) {
  3043. var i = -1,
  3044. next = function next() {
  3045. while (++i < iterable.length) {
  3046. if (hasOwn.call(iterable, i)) {
  3047. next.value = iterable[i];
  3048. next.done = false;
  3049. return next;
  3050. }
  3051. }
  3052. next.value = undefined;
  3053. next.done = true;
  3054. return next;
  3055. };
  3056. return next.next = next;
  3057. }
  3058. }
  3059. return {
  3060. next: doneResult
  3061. };
  3062. }
  3063. exports.values = values;
  3064. function doneResult() {
  3065. return {
  3066. value: undefined,
  3067. done: true
  3068. };
  3069. }
  3070. Context.prototype = {
  3071. constructor: Context,
  3072. reset: function reset(skipTempReset) {
  3073. this.prev = 0;
  3074. this.next = 0;
  3075. this.sent = this._sent = undefined;
  3076. this.done = false;
  3077. this.delegate = null;
  3078. this.method = "next";
  3079. this.arg = undefined;
  3080. this.tryEntries.forEach(resetTryEntry);
  3081. if (!skipTempReset) {
  3082. for (var name in this) {
  3083. if (name.charAt(0) === "t" && hasOwn.call(this, name) && !isNaN(+name.slice(1))) {
  3084. this[name] = undefined;
  3085. }
  3086. }
  3087. }
  3088. },
  3089. stop: function stop() {
  3090. this.done = true;
  3091. var rootEntry = this.tryEntries[0];
  3092. var rootRecord = rootEntry.completion;
  3093. if (rootRecord.type === "throw") {
  3094. throw rootRecord.arg;
  3095. }
  3096. return this.rval;
  3097. },
  3098. dispatchException: function dispatchException(exception) {
  3099. if (this.done) {
  3100. throw exception;
  3101. }
  3102. var context = this;
  3103. function handle(loc, caught) {
  3104. record.type = "throw";
  3105. record.arg = exception;
  3106. context.next = loc;
  3107. if (caught) {
  3108. context.method = "next";
  3109. context.arg = undefined;
  3110. }
  3111. return !!caught;
  3112. }
  3113. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  3114. var entry = this.tryEntries[i];
  3115. var record = entry.completion;
  3116. if (entry.tryLoc === "root") {
  3117. return handle("end");
  3118. }
  3119. if (entry.tryLoc <= this.prev) {
  3120. var hasCatch = hasOwn.call(entry, "catchLoc");
  3121. var hasFinally = hasOwn.call(entry, "finallyLoc");
  3122. if (hasCatch && hasFinally) {
  3123. if (this.prev < entry.catchLoc) {
  3124. return handle(entry.catchLoc, true);
  3125. } else if (this.prev < entry.finallyLoc) {
  3126. return handle(entry.finallyLoc);
  3127. }
  3128. } else if (hasCatch) {
  3129. if (this.prev < entry.catchLoc) {
  3130. return handle(entry.catchLoc, true);
  3131. }
  3132. } else if (hasFinally) {
  3133. if (this.prev < entry.finallyLoc) {
  3134. return handle(entry.finallyLoc);
  3135. }
  3136. } else {
  3137. throw new Error("try statement without catch or finally");
  3138. }
  3139. }
  3140. }
  3141. },
  3142. abrupt: function abrupt(type, arg) {
  3143. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  3144. var entry = this.tryEntries[i];
  3145. if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
  3146. var finallyEntry = entry;
  3147. break;
  3148. }
  3149. }
  3150. if (finallyEntry && (type === "break" || type === "continue") && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc) {
  3151. finallyEntry = null;
  3152. }
  3153. var record = finallyEntry ? finallyEntry.completion : {};
  3154. record.type = type;
  3155. record.arg = arg;
  3156. if (finallyEntry) {
  3157. this.method = "next";
  3158. this.next = finallyEntry.finallyLoc;
  3159. return ContinueSentinel;
  3160. }
  3161. return this.complete(record);
  3162. },
  3163. complete: function complete(record, afterLoc) {
  3164. if (record.type === "throw") {
  3165. throw record.arg;
  3166. }
  3167. if (record.type === "break" || record.type === "continue") {
  3168. this.next = record.arg;
  3169. } else if (record.type === "return") {
  3170. this.rval = this.arg = record.arg;
  3171. this.method = "return";
  3172. this.next = "end";
  3173. } else if (record.type === "normal" && afterLoc) {
  3174. this.next = afterLoc;
  3175. }
  3176. return ContinueSentinel;
  3177. },
  3178. finish: function finish(finallyLoc) {
  3179. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  3180. var entry = this.tryEntries[i];
  3181. if (entry.finallyLoc === finallyLoc) {
  3182. this.complete(entry.completion, entry.afterLoc);
  3183. resetTryEntry(entry);
  3184. return ContinueSentinel;
  3185. }
  3186. }
  3187. },
  3188. "catch": function _catch(tryLoc) {
  3189. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  3190. var entry = this.tryEntries[i];
  3191. if (entry.tryLoc === tryLoc) {
  3192. var record = entry.completion;
  3193. if (record.type === "throw") {
  3194. var thrown = record.arg;
  3195. resetTryEntry(entry);
  3196. }
  3197. return thrown;
  3198. }
  3199. }
  3200. throw new Error("illegal catch attempt");
  3201. },
  3202. delegateYield: function delegateYield(iterable, resultName, nextLoc) {
  3203. this.delegate = {
  3204. iterator: values(iterable),
  3205. resultName: resultName,
  3206. nextLoc: nextLoc
  3207. };
  3208. if (this.method === "next") {
  3209. this.arg = undefined;
  3210. }
  3211. return ContinueSentinel;
  3212. }
  3213. };
  3214. return exports;
  3215. }(( false ? undefined : _typeof(module)) === "object" ? module.exports : {});
  3216. try {
  3217. regeneratorRuntime = runtime;
  3218. } catch (accidentalStrictMode) {
  3219. Function("r", "regeneratorRuntime = r")(runtime);
  3220. }
  3221. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(4)(module)))
  3222. /***/ }),
  3223. /* 4 */
  3224. /***/ (function(module, exports, __webpack_require__) {
  3225. "use strict";
  3226. module.exports = function (module) {
  3227. if (!module.webpackPolyfill) {
  3228. module.deprecate = function () {};
  3229. module.paths = [];
  3230. if (!module.children) module.children = [];
  3231. Object.defineProperty(module, "loaded", {
  3232. enumerable: true,
  3233. get: function get() {
  3234. return module.l;
  3235. }
  3236. });
  3237. Object.defineProperty(module, "id", {
  3238. enumerable: true,
  3239. get: function get() {
  3240. return module.i;
  3241. }
  3242. });
  3243. module.webpackPolyfill = 1;
  3244. }
  3245. return module;
  3246. };
  3247. /***/ }),
  3248. /* 5 */
  3249. /***/ (function(module, exports, __webpack_require__) {
  3250. "use strict";
  3251. Object.defineProperty(exports, "__esModule", {
  3252. value: true
  3253. });
  3254. exports.isValidRotation = isValidRotation;
  3255. exports.isValidScrollMode = isValidScrollMode;
  3256. exports.isValidSpreadMode = isValidSpreadMode;
  3257. exports.isPortraitOrientation = isPortraitOrientation;
  3258. exports.clamp = clamp;
  3259. exports.getPDFFileNameFromURL = getPDFFileNameFromURL;
  3260. exports.noContextMenuHandler = noContextMenuHandler;
  3261. exports.parseQueryString = parseQueryString;
  3262. exports.backtrackBeforeAllVisibleElements = backtrackBeforeAllVisibleElements;
  3263. exports.getVisibleElements = getVisibleElements;
  3264. exports.roundToDivide = roundToDivide;
  3265. exports.getPageSizeInches = getPageSizeInches;
  3266. exports.approximateFraction = approximateFraction;
  3267. exports.getOutputScale = getOutputScale;
  3268. exports.scrollIntoView = scrollIntoView;
  3269. exports.watchScroll = watchScroll;
  3270. exports.binarySearchFirstItem = binarySearchFirstItem;
  3271. exports.normalizeWheelEventDirection = normalizeWheelEventDirection;
  3272. exports.normalizeWheelEventDelta = normalizeWheelEventDelta;
  3273. exports.waitOnEventOrTimeout = waitOnEventOrTimeout;
  3274. exports.moveToEndOfArray = moveToEndOfArray;
  3275. exports.WaitOnType = exports.animationStarted = exports.ProgressBar = exports.EventBus = exports.NullL10n = exports.SpreadMode = exports.ScrollMode = exports.TextLayerMode = exports.RendererType = exports.PresentationModeState = exports.VERTICAL_PADDING = exports.SCROLLBAR_PADDING = exports.MAX_AUTO_SCALE = exports.UNKNOWN_SCALE = exports.MAX_SCALE = exports.MIN_SCALE = exports.DEFAULT_SCALE = exports.DEFAULT_SCALE_VALUE = exports.CSS_UNITS = exports.AutoPrintRegExp = void 0;
  3276. var _regenerator = _interopRequireDefault(__webpack_require__(2));
  3277. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  3278. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  3279. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  3280. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  3281. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  3282. function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
  3283. function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
  3284. function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
  3285. function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
  3286. function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
  3287. function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
  3288. function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
  3289. function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
  3290. var CSS_UNITS = 96.0 / 72.0;
  3291. exports.CSS_UNITS = CSS_UNITS;
  3292. var DEFAULT_SCALE_VALUE = "auto";
  3293. exports.DEFAULT_SCALE_VALUE = DEFAULT_SCALE_VALUE;
  3294. var DEFAULT_SCALE = 1.0;
  3295. exports.DEFAULT_SCALE = DEFAULT_SCALE;
  3296. var MIN_SCALE = 0.1;
  3297. exports.MIN_SCALE = MIN_SCALE;
  3298. var MAX_SCALE = 10.0;
  3299. exports.MAX_SCALE = MAX_SCALE;
  3300. var UNKNOWN_SCALE = 0;
  3301. exports.UNKNOWN_SCALE = UNKNOWN_SCALE;
  3302. var MAX_AUTO_SCALE = 1.25;
  3303. exports.MAX_AUTO_SCALE = MAX_AUTO_SCALE;
  3304. var SCROLLBAR_PADDING = 40;
  3305. exports.SCROLLBAR_PADDING = SCROLLBAR_PADDING;
  3306. var VERTICAL_PADDING = 5;
  3307. exports.VERTICAL_PADDING = VERTICAL_PADDING;
  3308. var PresentationModeState = {
  3309. UNKNOWN: 0,
  3310. NORMAL: 1,
  3311. CHANGING: 2,
  3312. FULLSCREEN: 3
  3313. };
  3314. exports.PresentationModeState = PresentationModeState;
  3315. var RendererType = {
  3316. CANVAS: "canvas",
  3317. SVG: "svg"
  3318. };
  3319. exports.RendererType = RendererType;
  3320. var TextLayerMode = {
  3321. DISABLE: 0,
  3322. ENABLE: 1,
  3323. ENABLE_ENHANCE: 2
  3324. };
  3325. exports.TextLayerMode = TextLayerMode;
  3326. var ScrollMode = {
  3327. UNKNOWN: -1,
  3328. VERTICAL: 0,
  3329. HORIZONTAL: 1,
  3330. WRAPPED: 2
  3331. };
  3332. exports.ScrollMode = ScrollMode;
  3333. var SpreadMode = {
  3334. UNKNOWN: -1,
  3335. NONE: 0,
  3336. ODD: 1,
  3337. EVEN: 2
  3338. };
  3339. exports.SpreadMode = SpreadMode;
  3340. var AutoPrintRegExp = /\bprint\s*\(/;
  3341. exports.AutoPrintRegExp = AutoPrintRegExp;
  3342. function formatL10nValue(text, args) {
  3343. if (!args) {
  3344. return text;
  3345. }
  3346. return text.replace(/\{\{\s*(\w+)\s*\}\}/g, function (all, name) {
  3347. return name in args ? args[name] : "{{" + name + "}}";
  3348. });
  3349. }
  3350. var NullL10n = {
  3351. getLanguage: function getLanguage() {
  3352. return _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
  3353. return _regenerator["default"].wrap(function _callee$(_context) {
  3354. while (1) {
  3355. switch (_context.prev = _context.next) {
  3356. case 0:
  3357. return _context.abrupt("return", "en-us");
  3358. case 1:
  3359. case "end":
  3360. return _context.stop();
  3361. }
  3362. }
  3363. }, _callee);
  3364. }))();
  3365. },
  3366. getDirection: function getDirection() {
  3367. return _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee2() {
  3368. return _regenerator["default"].wrap(function _callee2$(_context2) {
  3369. while (1) {
  3370. switch (_context2.prev = _context2.next) {
  3371. case 0:
  3372. return _context2.abrupt("return", "ltr");
  3373. case 1:
  3374. case "end":
  3375. return _context2.stop();
  3376. }
  3377. }
  3378. }, _callee2);
  3379. }))();
  3380. },
  3381. get: function get(property, args, fallback) {
  3382. return _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee3() {
  3383. return _regenerator["default"].wrap(function _callee3$(_context3) {
  3384. while (1) {
  3385. switch (_context3.prev = _context3.next) {
  3386. case 0:
  3387. return _context3.abrupt("return", formatL10nValue(fallback, args));
  3388. case 1:
  3389. case "end":
  3390. return _context3.stop();
  3391. }
  3392. }
  3393. }, _callee3);
  3394. }))();
  3395. },
  3396. translate: function translate(element) {
  3397. return _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee4() {
  3398. return _regenerator["default"].wrap(function _callee4$(_context4) {
  3399. while (1) {
  3400. switch (_context4.prev = _context4.next) {
  3401. case 0:
  3402. case "end":
  3403. return _context4.stop();
  3404. }
  3405. }
  3406. }, _callee4);
  3407. }))();
  3408. }
  3409. };
  3410. exports.NullL10n = NullL10n;
  3411. function getOutputScale(ctx) {
  3412. var devicePixelRatio = window.devicePixelRatio || 1;
  3413. var backingStoreRatio = ctx.webkitBackingStorePixelRatio || ctx.mozBackingStorePixelRatio || ctx.msBackingStorePixelRatio || ctx.oBackingStorePixelRatio || ctx.backingStorePixelRatio || 1;
  3414. var pixelRatio = devicePixelRatio / backingStoreRatio;
  3415. return {
  3416. sx: pixelRatio,
  3417. sy: pixelRatio,
  3418. scaled: pixelRatio !== 1
  3419. };
  3420. }
  3421. function scrollIntoView(element, spot) {
  3422. var skipOverflowHiddenElements = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  3423. var parent = element.offsetParent;
  3424. if (!parent) {
  3425. console.error("offsetParent is not set -- cannot scroll");
  3426. return;
  3427. }
  3428. var offsetY = element.offsetTop + element.clientTop;
  3429. var offsetX = element.offsetLeft + element.clientLeft;
  3430. while (parent.clientHeight === parent.scrollHeight && parent.clientWidth === parent.scrollWidth || skipOverflowHiddenElements && getComputedStyle(parent).overflow === "hidden") {
  3431. if (parent.dataset._scaleY) {
  3432. offsetY /= parent.dataset._scaleY;
  3433. offsetX /= parent.dataset._scaleX;
  3434. }
  3435. offsetY += parent.offsetTop;
  3436. offsetX += parent.offsetLeft;
  3437. parent = parent.offsetParent;
  3438. if (!parent) {
  3439. return;
  3440. }
  3441. }
  3442. if (spot) {
  3443. if (spot.top !== undefined) {
  3444. offsetY += spot.top;
  3445. }
  3446. if (spot.left !== undefined) {
  3447. offsetX += spot.left;
  3448. parent.scrollLeft = offsetX;
  3449. }
  3450. }
  3451. parent.scrollTop = offsetY;
  3452. }
  3453. function watchScroll(viewAreaElement, callback) {
  3454. var debounceScroll = function debounceScroll(evt) {
  3455. if (rAF) {
  3456. return;
  3457. }
  3458. rAF = window.requestAnimationFrame(function viewAreaElementScrolled() {
  3459. rAF = null;
  3460. var currentX = viewAreaElement.scrollLeft;
  3461. var lastX = state.lastX;
  3462. if (currentX !== lastX) {
  3463. state.right = currentX > lastX;
  3464. }
  3465. state.lastX = currentX;
  3466. var currentY = viewAreaElement.scrollTop;
  3467. var lastY = state.lastY;
  3468. if (currentY !== lastY) {
  3469. state.down = currentY > lastY;
  3470. }
  3471. state.lastY = currentY;
  3472. callback(state);
  3473. });
  3474. };
  3475. var state = {
  3476. right: true,
  3477. down: true,
  3478. lastX: viewAreaElement.scrollLeft,
  3479. lastY: viewAreaElement.scrollTop,
  3480. _eventHandler: debounceScroll
  3481. };
  3482. var rAF = null;
  3483. viewAreaElement.addEventListener("scroll", debounceScroll, true);
  3484. return state;
  3485. }
  3486. function parseQueryString(query) {
  3487. var parts = query.split("&");
  3488. var params = Object.create(null);
  3489. for (var i = 0, ii = parts.length; i < ii; ++i) {
  3490. var param = parts[i].split("=");
  3491. var key = param[0].toLowerCase();
  3492. var value = param.length > 1 ? param[1] : null;
  3493. params[decodeURIComponent(key)] = decodeURIComponent(value);
  3494. }
  3495. return params;
  3496. }
  3497. function binarySearchFirstItem(items, condition) {
  3498. var minIndex = 0;
  3499. var maxIndex = items.length - 1;
  3500. if (maxIndex < 0 || !condition(items[maxIndex])) {
  3501. return items.length;
  3502. }
  3503. if (condition(items[minIndex])) {
  3504. return minIndex;
  3505. }
  3506. while (minIndex < maxIndex) {
  3507. var currentIndex = minIndex + maxIndex >> 1;
  3508. var currentItem = items[currentIndex];
  3509. if (condition(currentItem)) {
  3510. maxIndex = currentIndex;
  3511. } else {
  3512. minIndex = currentIndex + 1;
  3513. }
  3514. }
  3515. return minIndex;
  3516. }
  3517. function approximateFraction(x) {
  3518. if (Math.floor(x) === x) {
  3519. return [x, 1];
  3520. }
  3521. var xinv = 1 / x;
  3522. var limit = 8;
  3523. if (xinv > limit) {
  3524. return [1, limit];
  3525. } else if (Math.floor(xinv) === xinv) {
  3526. return [1, xinv];
  3527. }
  3528. var x_ = x > 1 ? xinv : x;
  3529. var a = 0,
  3530. b = 1,
  3531. c = 1,
  3532. d = 1;
  3533. while (true) {
  3534. var p = a + c,
  3535. q = b + d;
  3536. if (q > limit) {
  3537. break;
  3538. }
  3539. if (x_ <= p / q) {
  3540. c = p;
  3541. d = q;
  3542. } else {
  3543. a = p;
  3544. b = q;
  3545. }
  3546. }
  3547. var result;
  3548. if (x_ - a / b < c / d - x_) {
  3549. result = x_ === x ? [a, b] : [b, a];
  3550. } else {
  3551. result = x_ === x ? [c, d] : [d, c];
  3552. }
  3553. return result;
  3554. }
  3555. function roundToDivide(x, div) {
  3556. var r = x % div;
  3557. return r === 0 ? x : Math.round(x - r + div);
  3558. }
  3559. function getPageSizeInches(_ref) {
  3560. var view = _ref.view,
  3561. userUnit = _ref.userUnit,
  3562. rotate = _ref.rotate;
  3563. var _view = _slicedToArray(view, 4),
  3564. x1 = _view[0],
  3565. y1 = _view[1],
  3566. x2 = _view[2],
  3567. y2 = _view[3];
  3568. var changeOrientation = rotate % 180 !== 0;
  3569. var width = (x2 - x1) / 72 * userUnit;
  3570. var height = (y2 - y1) / 72 * userUnit;
  3571. return {
  3572. width: changeOrientation ? height : width,
  3573. height: changeOrientation ? width : height
  3574. };
  3575. }
  3576. function backtrackBeforeAllVisibleElements(index, views, top) {
  3577. if (index < 2) {
  3578. return index;
  3579. }
  3580. var elt = views[index].div;
  3581. var pageTop = elt.offsetTop + elt.clientTop;
  3582. if (pageTop >= top) {
  3583. elt = views[index - 1].div;
  3584. pageTop = elt.offsetTop + elt.clientTop;
  3585. }
  3586. for (var i = index - 2; i >= 0; --i) {
  3587. elt = views[i].div;
  3588. if (elt.offsetTop + elt.clientTop + elt.clientHeight <= pageTop) {
  3589. break;
  3590. }
  3591. index = i;
  3592. }
  3593. return index;
  3594. }
  3595. function getVisibleElements(scrollEl, views) {
  3596. var sortByVisibility = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  3597. var horizontal = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
  3598. var top = scrollEl.scrollTop,
  3599. bottom = top + scrollEl.clientHeight;
  3600. var left = scrollEl.scrollLeft,
  3601. right = left + scrollEl.clientWidth;
  3602. function isElementBottomAfterViewTop(view) {
  3603. var element = view.div;
  3604. var elementBottom = element.offsetTop + element.clientTop + element.clientHeight;
  3605. return elementBottom > top;
  3606. }
  3607. function isElementRightAfterViewLeft(view) {
  3608. var element = view.div;
  3609. var elementRight = element.offsetLeft + element.clientLeft + element.clientWidth;
  3610. return elementRight > left;
  3611. }
  3612. var visible = [],
  3613. numViews = views.length;
  3614. var firstVisibleElementInd = numViews === 0 ? 0 : binarySearchFirstItem(views, horizontal ? isElementRightAfterViewLeft : isElementBottomAfterViewTop);
  3615. if (firstVisibleElementInd > 0 && firstVisibleElementInd < numViews && !horizontal) {
  3616. firstVisibleElementInd = backtrackBeforeAllVisibleElements(firstVisibleElementInd, views, top);
  3617. }
  3618. var lastEdge = horizontal ? right : -1;
  3619. for (var i = firstVisibleElementInd; i < numViews; i++) {
  3620. var view = views[i],
  3621. element = view.div;
  3622. var currentWidth = element.offsetLeft + element.clientLeft;
  3623. var currentHeight = element.offsetTop + element.clientTop;
  3624. var viewWidth = element.clientWidth,
  3625. viewHeight = element.clientHeight;
  3626. var viewRight = currentWidth + viewWidth;
  3627. var viewBottom = currentHeight + viewHeight;
  3628. if (lastEdge === -1) {
  3629. if (viewBottom >= bottom) {
  3630. lastEdge = viewBottom;
  3631. }
  3632. } else if ((horizontal ? currentWidth : currentHeight) > lastEdge) {
  3633. break;
  3634. }
  3635. if (viewBottom <= top || currentHeight >= bottom || viewRight <= left || currentWidth >= right) {
  3636. continue;
  3637. }
  3638. var hiddenHeight = Math.max(0, top - currentHeight) + Math.max(0, viewBottom - bottom);
  3639. var hiddenWidth = Math.max(0, left - currentWidth) + Math.max(0, viewRight - right);
  3640. var percent = (viewHeight - hiddenHeight) * (viewWidth - hiddenWidth) * 100 / viewHeight / viewWidth | 0;
  3641. visible.push({
  3642. id: view.id,
  3643. x: currentWidth,
  3644. y: currentHeight,
  3645. view: view,
  3646. percent: percent
  3647. });
  3648. }
  3649. var first = visible[0],
  3650. last = visible[visible.length - 1];
  3651. if (sortByVisibility) {
  3652. visible.sort(function (a, b) {
  3653. var pc = a.percent - b.percent;
  3654. if (Math.abs(pc) > 0.001) {
  3655. return -pc;
  3656. }
  3657. return a.id - b.id;
  3658. });
  3659. }
  3660. return {
  3661. first: first,
  3662. last: last,
  3663. views: visible
  3664. };
  3665. }
  3666. function noContextMenuHandler(evt) {
  3667. evt.preventDefault();
  3668. }
  3669. function isDataSchema(url) {
  3670. var i = 0;
  3671. var ii = url.length;
  3672. while (i < ii && url[i].trim() === "") {
  3673. i++;
  3674. }
  3675. return url.substring(i, i + 5).toLowerCase() === "data:";
  3676. }
  3677. function getPDFFileNameFromURL(url) {
  3678. var defaultFilename = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "document.pdf";
  3679. if (typeof url !== "string") {
  3680. return defaultFilename;
  3681. }
  3682. if (isDataSchema(url)) {
  3683. console.warn("getPDFFileNameFromURL: " + 'ignoring "data:" URL for performance reasons.');
  3684. return defaultFilename;
  3685. }
  3686. var reURI = /^(?:(?:[^:]+:)?\/\/[^\/]+)?([^?#]*)(\?[^#]*)?(#.*)?$/;
  3687. var reFilename = /[^\/?#=]+\.pdf\b(?!.*\.pdf\b)/i;
  3688. var splitURI = reURI.exec(url);
  3689. var suggestedFilename = reFilename.exec(splitURI[1]) || reFilename.exec(splitURI[2]) || reFilename.exec(splitURI[3]);
  3690. if (suggestedFilename) {
  3691. suggestedFilename = suggestedFilename[0];
  3692. if (suggestedFilename.includes("%")) {
  3693. try {
  3694. suggestedFilename = reFilename.exec(decodeURIComponent(suggestedFilename))[0];
  3695. } catch (ex) {}
  3696. }
  3697. }
  3698. return suggestedFilename || defaultFilename;
  3699. }
  3700. function normalizeWheelEventDirection(evt) {
  3701. var delta = Math.sqrt(evt.deltaX * evt.deltaX + evt.deltaY * evt.deltaY);
  3702. var angle = Math.atan2(evt.deltaY, evt.deltaX);
  3703. if (-0.25 * Math.PI < angle && angle < 0.75 * Math.PI) {
  3704. delta = -delta;
  3705. }
  3706. return delta;
  3707. }
  3708. function normalizeWheelEventDelta(evt) {
  3709. var delta = normalizeWheelEventDirection(evt);
  3710. var MOUSE_DOM_DELTA_PIXEL_MODE = 0;
  3711. var MOUSE_DOM_DELTA_LINE_MODE = 1;
  3712. var MOUSE_PIXELS_PER_LINE = 30;
  3713. var MOUSE_LINES_PER_PAGE = 30;
  3714. if (evt.deltaMode === MOUSE_DOM_DELTA_PIXEL_MODE) {
  3715. delta /= MOUSE_PIXELS_PER_LINE * MOUSE_LINES_PER_PAGE;
  3716. } else if (evt.deltaMode === MOUSE_DOM_DELTA_LINE_MODE) {
  3717. delta /= MOUSE_LINES_PER_PAGE;
  3718. }
  3719. return delta;
  3720. }
  3721. function isValidRotation(angle) {
  3722. return Number.isInteger(angle) && angle % 90 === 0;
  3723. }
  3724. function isValidScrollMode(mode) {
  3725. return Number.isInteger(mode) && Object.values(ScrollMode).includes(mode) && mode !== ScrollMode.UNKNOWN;
  3726. }
  3727. function isValidSpreadMode(mode) {
  3728. return Number.isInteger(mode) && Object.values(SpreadMode).includes(mode) && mode !== SpreadMode.UNKNOWN;
  3729. }
  3730. function isPortraitOrientation(size) {
  3731. return size.width <= size.height;
  3732. }
  3733. var WaitOnType = {
  3734. EVENT: "event",
  3735. TIMEOUT: "timeout"
  3736. };
  3737. exports.WaitOnType = WaitOnType;
  3738. function waitOnEventOrTimeout(_ref2) {
  3739. var target = _ref2.target,
  3740. name = _ref2.name,
  3741. _ref2$delay = _ref2.delay,
  3742. delay = _ref2$delay === void 0 ? 0 : _ref2$delay;
  3743. return new Promise(function (resolve, reject) {
  3744. if (_typeof(target) !== "object" || !(name && typeof name === "string") || !(Number.isInteger(delay) && delay >= 0)) {
  3745. throw new Error("waitOnEventOrTimeout - invalid parameters.");
  3746. }
  3747. function handler(type) {
  3748. if (target instanceof EventBus) {
  3749. target._off(name, eventHandler);
  3750. } else {
  3751. target.removeEventListener(name, eventHandler);
  3752. }
  3753. if (timeout) {
  3754. clearTimeout(timeout);
  3755. }
  3756. resolve(type);
  3757. }
  3758. var eventHandler = handler.bind(null, WaitOnType.EVENT);
  3759. if (target instanceof EventBus) {
  3760. target._on(name, eventHandler);
  3761. } else {
  3762. target.addEventListener(name, eventHandler);
  3763. }
  3764. var timeoutHandler = handler.bind(null, WaitOnType.TIMEOUT);
  3765. var timeout = setTimeout(timeoutHandler, delay);
  3766. });
  3767. }
  3768. var animationStarted = new Promise(function (resolve) {
  3769. window.requestAnimationFrame(resolve);
  3770. });
  3771. exports.animationStarted = animationStarted;
  3772. function dispatchDOMEvent(eventName) {
  3773. var args = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  3774. throw new Error("Not implemented: dispatchDOMEvent");
  3775. }
  3776. var EventBus = /*#__PURE__*/function () {
  3777. function EventBus(options) {
  3778. _classCallCheck(this, EventBus);
  3779. this._listeners = Object.create(null);
  3780. }
  3781. _createClass(EventBus, [{
  3782. key: "on",
  3783. value: function on(eventName, listener) {
  3784. this._on(eventName, listener, {
  3785. external: true
  3786. });
  3787. }
  3788. }, {
  3789. key: "off",
  3790. value: function off(eventName, listener) {
  3791. this._off(eventName, listener, {
  3792. external: true
  3793. });
  3794. }
  3795. }, {
  3796. key: "dispatch",
  3797. value: function dispatch(eventName) {
  3798. var eventListeners = this._listeners[eventName];
  3799. if (!eventListeners || eventListeners.length === 0) {
  3800. return;
  3801. }
  3802. var args = Array.prototype.slice.call(arguments, 1);
  3803. var externalListeners;
  3804. eventListeners.slice(0).forEach(function (_ref3) {
  3805. var listener = _ref3.listener,
  3806. external = _ref3.external;
  3807. if (external) {
  3808. if (!externalListeners) {
  3809. externalListeners = [];
  3810. }
  3811. externalListeners.push(listener);
  3812. return;
  3813. }
  3814. listener.apply(null, args);
  3815. });
  3816. if (externalListeners) {
  3817. externalListeners.forEach(function (listener) {
  3818. listener.apply(null, args);
  3819. });
  3820. externalListeners = null;
  3821. }
  3822. }
  3823. }, {
  3824. key: "_on",
  3825. value: function _on(eventName, listener) {
  3826. var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
  3827. var eventListeners = this._listeners[eventName];
  3828. if (!eventListeners) {
  3829. this._listeners[eventName] = eventListeners = [];
  3830. }
  3831. eventListeners.push({
  3832. listener: listener,
  3833. external: (options && options.external) === true
  3834. });
  3835. }
  3836. }, {
  3837. key: "_off",
  3838. value: function _off(eventName, listener) {
  3839. var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
  3840. var eventListeners = this._listeners[eventName];
  3841. if (!eventListeners) {
  3842. return;
  3843. }
  3844. for (var i = 0, ii = eventListeners.length; i < ii; i++) {
  3845. if (eventListeners[i].listener === listener) {
  3846. eventListeners.splice(i, 1);
  3847. return;
  3848. }
  3849. }
  3850. }
  3851. }]);
  3852. return EventBus;
  3853. }();
  3854. exports.EventBus = EventBus;
  3855. function clamp(v, min, max) {
  3856. return Math.min(Math.max(v, min), max);
  3857. }
  3858. var ProgressBar = /*#__PURE__*/function () {
  3859. function ProgressBar(id) {
  3860. var _ref4 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
  3861. height = _ref4.height,
  3862. width = _ref4.width,
  3863. units = _ref4.units;
  3864. _classCallCheck(this, ProgressBar);
  3865. this.visible = true;
  3866. this.div = document.querySelector(id + " .progress");
  3867. this.bar = this.div.parentNode;
  3868. this.height = height || 100;
  3869. this.width = width || 100;
  3870. this.units = units || "%";
  3871. this.div.style.height = this.height + this.units;
  3872. this.percent = 0;
  3873. }
  3874. _createClass(ProgressBar, [{
  3875. key: "_updateBar",
  3876. value: function _updateBar() {
  3877. if (this._indeterminate) {
  3878. this.div.classList.add("indeterminate");
  3879. this.div.style.width = this.width + this.units;
  3880. return;
  3881. }
  3882. this.div.classList.remove("indeterminate");
  3883. var progressSize = this.width * this._percent / 100;
  3884. this.div.style.width = progressSize + this.units;
  3885. }
  3886. }, {
  3887. key: "setWidth",
  3888. value: function setWidth(viewer) {
  3889. if (!viewer) {
  3890. return;
  3891. }
  3892. var container = viewer.parentNode;
  3893. var scrollbarWidth = container.offsetWidth - viewer.offsetWidth;
  3894. if (scrollbarWidth > 0) {
  3895. this.bar.style.width = "calc(100% - ".concat(scrollbarWidth, "px)");
  3896. }
  3897. }
  3898. }, {
  3899. key: "hide",
  3900. value: function hide() {
  3901. if (!this.visible) {
  3902. return;
  3903. }
  3904. this.visible = false;
  3905. this.bar.classList.add("hidden");
  3906. document.body.classList.remove("loadingInProgress");
  3907. }
  3908. }, {
  3909. key: "show",
  3910. value: function show() {
  3911. if (this.visible) {
  3912. return;
  3913. }
  3914. this.visible = true;
  3915. document.body.classList.add("loadingInProgress");
  3916. this.bar.classList.remove("hidden");
  3917. }
  3918. }, {
  3919. key: "percent",
  3920. get: function get() {
  3921. return this._percent;
  3922. },
  3923. set: function set(val) {
  3924. this._indeterminate = isNaN(val);
  3925. this._percent = clamp(val, 0, 100);
  3926. this._updateBar();
  3927. }
  3928. }]);
  3929. return ProgressBar;
  3930. }();
  3931. exports.ProgressBar = ProgressBar;
  3932. function moveToEndOfArray(arr, condition) {
  3933. var moved = [],
  3934. len = arr.length;
  3935. var write = 0;
  3936. for (var read = 0; read < len; ++read) {
  3937. if (condition(arr[read])) {
  3938. moved.push(arr[read]);
  3939. } else {
  3940. arr[write] = arr[read];
  3941. ++write;
  3942. }
  3943. }
  3944. for (var _read = 0; write < len; ++_read, ++write) {
  3945. arr[write] = moved[_read];
  3946. }
  3947. }
  3948. /***/ }),
  3949. /* 6 */
  3950. /***/ (function(module, exports, __webpack_require__) {
  3951. "use strict";
  3952. Object.defineProperty(exports, "__esModule", {
  3953. value: true
  3954. });
  3955. exports.OptionKind = exports.AppOptions = void 0;
  3956. var _viewer_compatibility = __webpack_require__(7);
  3957. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  3958. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  3959. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  3960. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  3961. var OptionKind = {
  3962. VIEWER: 0x02,
  3963. API: 0x04,
  3964. WORKER: 0x08,
  3965. PREFERENCE: 0x80
  3966. };
  3967. exports.OptionKind = OptionKind;
  3968. var defaultOptions = {
  3969. cursorToolOnLoad: {
  3970. value: 0,
  3971. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  3972. },
  3973. defaultUrl: {
  3974. value: "compressed.tracemonkey-pldi-09.pdf",
  3975. kind: OptionKind.VIEWER
  3976. },
  3977. defaultZoomValue: {
  3978. value: "",
  3979. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  3980. },
  3981. disableHistory: {
  3982. value: false,
  3983. kind: OptionKind.VIEWER
  3984. },
  3985. disablePageLabels: {
  3986. value: false,
  3987. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  3988. },
  3989. enablePermissions: {
  3990. value: false,
  3991. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  3992. },
  3993. enablePrintAutoRotate: {
  3994. value: false,
  3995. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  3996. },
  3997. enableWebGL: {
  3998. value: false,
  3999. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  4000. },
  4001. externalLinkRel: {
  4002. value: "noopener noreferrer nofollow",
  4003. kind: OptionKind.VIEWER
  4004. },
  4005. externalLinkTarget: {
  4006. value: 0,
  4007. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  4008. },
  4009. historyUpdateUrl: {
  4010. value: false,
  4011. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  4012. },
  4013. ignoreDestinationZoom: {
  4014. value: false,
  4015. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  4016. },
  4017. imageResourcesPath: {
  4018. value: "./images/",
  4019. kind: OptionKind.VIEWER
  4020. },
  4021. maxCanvasPixels: {
  4022. value: 16777216,
  4023. compatibility: _viewer_compatibility.viewerCompatibilityParams.maxCanvasPixels,
  4024. kind: OptionKind.VIEWER
  4025. },
  4026. pdfBugEnabled: {
  4027. value: false,
  4028. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  4029. },
  4030. printResolution: {
  4031. value: 150,
  4032. kind: OptionKind.VIEWER
  4033. },
  4034. renderer: {
  4035. value: "canvas",
  4036. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  4037. },
  4038. renderInteractiveForms: {
  4039. value: true,
  4040. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  4041. },
  4042. sidebarViewOnLoad: {
  4043. value: -1,
  4044. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  4045. },
  4046. scrollModeOnLoad: {
  4047. value: -1,
  4048. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  4049. },
  4050. spreadModeOnLoad: {
  4051. value: -1,
  4052. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  4053. },
  4054. textLayerMode: {
  4055. value: 1,
  4056. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  4057. },
  4058. useOnlyCssZoom: {
  4059. value: false,
  4060. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  4061. },
  4062. viewOnLoad: {
  4063. value: 0,
  4064. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  4065. },
  4066. cMapPacked: {
  4067. value: true,
  4068. kind: OptionKind.API
  4069. },
  4070. cMapUrl: {
  4071. value: "../web/cmaps/",
  4072. kind: OptionKind.API
  4073. },
  4074. disableAutoFetch: {
  4075. value: false,
  4076. kind: OptionKind.API + OptionKind.PREFERENCE
  4077. },
  4078. disableFontFace: {
  4079. value: false,
  4080. kind: OptionKind.API + OptionKind.PREFERENCE
  4081. },
  4082. disableRange: {
  4083. value: false,
  4084. kind: OptionKind.API + OptionKind.PREFERENCE
  4085. },
  4086. disableStream: {
  4087. value: false,
  4088. kind: OptionKind.API + OptionKind.PREFERENCE
  4089. },
  4090. docBaseUrl: {
  4091. value: "",
  4092. kind: OptionKind.API
  4093. },
  4094. fontExtraProperties: {
  4095. value: false,
  4096. kind: OptionKind.API
  4097. },
  4098. isEvalSupported: {
  4099. value: true,
  4100. kind: OptionKind.API
  4101. },
  4102. maxImageSize: {
  4103. value: -1,
  4104. kind: OptionKind.API
  4105. },
  4106. pdfBug: {
  4107. value: false,
  4108. kind: OptionKind.API
  4109. },
  4110. verbosity: {
  4111. value: 1,
  4112. kind: OptionKind.API
  4113. },
  4114. workerPort: {
  4115. value: null,
  4116. kind: OptionKind.WORKER
  4117. },
  4118. workerSrc: {
  4119. value: "../build/pdf.worker.js",
  4120. kind: OptionKind.WORKER
  4121. }
  4122. };
  4123. {
  4124. defaultOptions.disablePreferences = {
  4125. value: false,
  4126. kind: OptionKind.VIEWER
  4127. };
  4128. defaultOptions.locale = {
  4129. value: typeof navigator !== "undefined" ? navigator.language : "en-US",
  4130. kind: OptionKind.VIEWER
  4131. };
  4132. }
  4133. var userOptions = Object.create(null);
  4134. var AppOptions = /*#__PURE__*/function () {
  4135. function AppOptions() {
  4136. _classCallCheck(this, AppOptions);
  4137. throw new Error("Cannot initialize AppOptions.");
  4138. }
  4139. _createClass(AppOptions, null, [{
  4140. key: "get",
  4141. value: function get(name) {
  4142. var userOption = userOptions[name];
  4143. if (userOption !== undefined) {
  4144. return userOption;
  4145. }
  4146. var defaultOption = defaultOptions[name];
  4147. if (defaultOption !== undefined) {
  4148. return defaultOption.compatibility || defaultOption.value;
  4149. }
  4150. return undefined;
  4151. }
  4152. }, {
  4153. key: "getAll",
  4154. value: function getAll() {
  4155. var kind = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
  4156. var options = Object.create(null);
  4157. for (var name in defaultOptions) {
  4158. var defaultOption = defaultOptions[name];
  4159. if (kind) {
  4160. if ((kind & defaultOption.kind) === 0) {
  4161. continue;
  4162. }
  4163. if (kind === OptionKind.PREFERENCE) {
  4164. var value = defaultOption.value,
  4165. valueType = _typeof(value);
  4166. if (valueType === "boolean" || valueType === "string" || valueType === "number" && Number.isInteger(value)) {
  4167. options[name] = value;
  4168. continue;
  4169. }
  4170. throw new Error("Invalid type for preference: ".concat(name));
  4171. }
  4172. }
  4173. var userOption = userOptions[name];
  4174. options[name] = userOption !== undefined ? userOption : defaultOption.compatibility || defaultOption.value;
  4175. }
  4176. return options;
  4177. }
  4178. }, {
  4179. key: "set",
  4180. value: function set(name, value) {
  4181. userOptions[name] = value;
  4182. }
  4183. }, {
  4184. key: "remove",
  4185. value: function remove(name) {
  4186. delete userOptions[name];
  4187. }
  4188. }]);
  4189. return AppOptions;
  4190. }();
  4191. exports.AppOptions = AppOptions;
  4192. /***/ }),
  4193. /* 7 */
  4194. /***/ (function(module, exports, __webpack_require__) {
  4195. "use strict";
  4196. Object.defineProperty(exports, "__esModule", {
  4197. value: true
  4198. });
  4199. exports.viewerCompatibilityParams = void 0;
  4200. var compatibilityParams = Object.create(null);
  4201. {
  4202. var userAgent = typeof navigator !== "undefined" && navigator.userAgent || "";
  4203. var platform = typeof navigator !== "undefined" && navigator.platform || "";
  4204. var maxTouchPoints = typeof navigator !== "undefined" && navigator.maxTouchPoints || 1;
  4205. var isAndroid = /Android/.test(userAgent);
  4206. var isIE = /Trident/.test(userAgent);
  4207. var isIOS = /\b(iPad|iPhone|iPod)(?=;)/.test(userAgent) || platform === "MacIntel" && maxTouchPoints > 1;
  4208. var isIOSChrome = /CriOS/.test(userAgent);
  4209. (function checkOnBlobSupport() {
  4210. if (isIE || isIOSChrome) {
  4211. compatibilityParams.disableCreateObjectURL = true;
  4212. }
  4213. })();
  4214. (function checkCanvasSizeLimitation() {
  4215. if (isIOS || isAndroid) {
  4216. compatibilityParams.maxCanvasPixels = 5242880;
  4217. }
  4218. })();
  4219. }
  4220. var viewerCompatibilityParams = Object.freeze(compatibilityParams);
  4221. exports.viewerCompatibilityParams = viewerCompatibilityParams;
  4222. /***/ }),
  4223. /* 8 */
  4224. /***/ (function(module, exports, __webpack_require__) {
  4225. "use strict";
  4226. var pdfjsLib;
  4227. if (typeof window !== "undefined" && window["pdfjs-dist/build/pdf"]) {
  4228. pdfjsLib = window["pdfjs-dist/build/pdf"];
  4229. } else {
  4230. pdfjsLib = require("../build/pdf.js");
  4231. }
  4232. module.exports = pdfjsLib;
  4233. /***/ }),
  4234. /* 9 */
  4235. /***/ (function(module, exports, __webpack_require__) {
  4236. "use strict";
  4237. Object.defineProperty(exports, "__esModule", {
  4238. value: true
  4239. });
  4240. exports.PDFCursorTools = exports.CursorTool = void 0;
  4241. var _grab_to_pan = __webpack_require__(10);
  4242. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  4243. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  4244. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  4245. var CursorTool = {
  4246. SELECT: 0,
  4247. HAND: 1,
  4248. ZOOM: 2
  4249. };
  4250. exports.CursorTool = CursorTool;
  4251. var PDFCursorTools = /*#__PURE__*/function () {
  4252. function PDFCursorTools(_ref) {
  4253. var _this = this;
  4254. var container = _ref.container,
  4255. eventBus = _ref.eventBus,
  4256. _ref$cursorToolOnLoad = _ref.cursorToolOnLoad,
  4257. cursorToolOnLoad = _ref$cursorToolOnLoad === void 0 ? CursorTool.SELECT : _ref$cursorToolOnLoad;
  4258. _classCallCheck(this, PDFCursorTools);
  4259. this.container = container;
  4260. this.eventBus = eventBus;
  4261. this.active = CursorTool.SELECT;
  4262. this.activeBeforePresentationMode = null;
  4263. this.handTool = new _grab_to_pan.GrabToPan({
  4264. element: this.container
  4265. });
  4266. this._addEventListeners();
  4267. Promise.resolve().then(function () {
  4268. _this.switchTool(cursorToolOnLoad);
  4269. });
  4270. }
  4271. _createClass(PDFCursorTools, [{
  4272. key: "switchTool",
  4273. value: function switchTool(tool) {
  4274. var _this2 = this;
  4275. if (this.activeBeforePresentationMode !== null) {
  4276. return;
  4277. }
  4278. if (tool === this.active) {
  4279. return;
  4280. }
  4281. var disableActiveTool = function disableActiveTool() {
  4282. switch (_this2.active) {
  4283. case CursorTool.SELECT:
  4284. break;
  4285. case CursorTool.HAND:
  4286. _this2.handTool.deactivate();
  4287. break;
  4288. case CursorTool.ZOOM:
  4289. }
  4290. };
  4291. switch (tool) {
  4292. case CursorTool.SELECT:
  4293. disableActiveTool();
  4294. break;
  4295. case CursorTool.HAND:
  4296. disableActiveTool();
  4297. this.handTool.activate();
  4298. break;
  4299. case CursorTool.ZOOM:
  4300. default:
  4301. console.error("switchTool: \"".concat(tool, "\" is an unsupported value."));
  4302. return;
  4303. }
  4304. this.active = tool;
  4305. this._dispatchEvent();
  4306. }
  4307. }, {
  4308. key: "_dispatchEvent",
  4309. value: function _dispatchEvent() {
  4310. this.eventBus.dispatch("cursortoolchanged", {
  4311. source: this,
  4312. tool: this.active
  4313. });
  4314. }
  4315. }, {
  4316. key: "_addEventListeners",
  4317. value: function _addEventListeners() {
  4318. var _this3 = this;
  4319. this.eventBus._on("switchcursortool", function (evt) {
  4320. _this3.switchTool(evt.tool);
  4321. });
  4322. this.eventBus._on("presentationmodechanged", function (evt) {
  4323. if (evt.switchInProgress) {
  4324. return;
  4325. }
  4326. var previouslyActive;
  4327. if (evt.active) {
  4328. previouslyActive = _this3.active;
  4329. _this3.switchTool(CursorTool.SELECT);
  4330. _this3.activeBeforePresentationMode = previouslyActive;
  4331. } else {
  4332. previouslyActive = _this3.activeBeforePresentationMode;
  4333. _this3.activeBeforePresentationMode = null;
  4334. _this3.switchTool(previouslyActive);
  4335. }
  4336. });
  4337. }
  4338. }, {
  4339. key: "activeTool",
  4340. get: function get() {
  4341. return this.active;
  4342. }
  4343. }]);
  4344. return PDFCursorTools;
  4345. }();
  4346. exports.PDFCursorTools = PDFCursorTools;
  4347. /***/ }),
  4348. /* 10 */
  4349. /***/ (function(module, exports, __webpack_require__) {
  4350. "use strict";
  4351. Object.defineProperty(exports, "__esModule", {
  4352. value: true
  4353. });
  4354. exports.GrabToPan = GrabToPan;
  4355. function GrabToPan(options) {
  4356. this.element = options.element;
  4357. this.document = options.element.ownerDocument;
  4358. if (typeof options.ignoreTarget === "function") {
  4359. this.ignoreTarget = options.ignoreTarget;
  4360. }
  4361. this.onActiveChanged = options.onActiveChanged;
  4362. this.activate = this.activate.bind(this);
  4363. this.deactivate = this.deactivate.bind(this);
  4364. this.toggle = this.toggle.bind(this);
  4365. this._onmousedown = this._onmousedown.bind(this);
  4366. this._onmousemove = this._onmousemove.bind(this);
  4367. this._endPan = this._endPan.bind(this);
  4368. var overlay = this.overlay = document.createElement("div");
  4369. overlay.className = "grab-to-pan-grabbing";
  4370. }
  4371. GrabToPan.prototype = {
  4372. CSS_CLASS_GRAB: "grab-to-pan-grab",
  4373. activate: function GrabToPan_activate() {
  4374. if (!this.active) {
  4375. this.active = true;
  4376. this.element.addEventListener("mousedown", this._onmousedown, true);
  4377. this.element.classList.add(this.CSS_CLASS_GRAB);
  4378. if (this.onActiveChanged) {
  4379. this.onActiveChanged(true);
  4380. }
  4381. }
  4382. },
  4383. deactivate: function GrabToPan_deactivate() {
  4384. if (this.active) {
  4385. this.active = false;
  4386. this.element.removeEventListener("mousedown", this._onmousedown, true);
  4387. this._endPan();
  4388. this.element.classList.remove(this.CSS_CLASS_GRAB);
  4389. if (this.onActiveChanged) {
  4390. this.onActiveChanged(false);
  4391. }
  4392. }
  4393. },
  4394. toggle: function GrabToPan_toggle() {
  4395. if (this.active) {
  4396. this.deactivate();
  4397. } else {
  4398. this.activate();
  4399. }
  4400. },
  4401. ignoreTarget: function GrabToPan_ignoreTarget(node) {
  4402. return node[matchesSelector]("a[href], a[href] *, input, textarea, button, button *, select, option");
  4403. },
  4404. _onmousedown: function GrabToPan__onmousedown(event) {
  4405. if (event.button !== 0 || this.ignoreTarget(event.target)) {
  4406. return;
  4407. }
  4408. if (event.originalTarget) {
  4409. try {
  4410. event.originalTarget.tagName;
  4411. } catch (e) {
  4412. return;
  4413. }
  4414. }
  4415. this.scrollLeftStart = this.element.scrollLeft;
  4416. this.scrollTopStart = this.element.scrollTop;
  4417. this.clientXStart = event.clientX;
  4418. this.clientYStart = event.clientY;
  4419. this.document.addEventListener("mousemove", this._onmousemove, true);
  4420. this.document.addEventListener("mouseup", this._endPan, true);
  4421. this.element.addEventListener("scroll", this._endPan, true);
  4422. event.preventDefault();
  4423. event.stopPropagation();
  4424. var focusedElement = document.activeElement;
  4425. if (focusedElement && !focusedElement.contains(event.target)) {
  4426. focusedElement.blur();
  4427. }
  4428. },
  4429. _onmousemove: function GrabToPan__onmousemove(event) {
  4430. this.element.removeEventListener("scroll", this._endPan, true);
  4431. if (isLeftMouseReleased(event)) {
  4432. this._endPan();
  4433. return;
  4434. }
  4435. var xDiff = event.clientX - this.clientXStart;
  4436. var yDiff = event.clientY - this.clientYStart;
  4437. var scrollTop = this.scrollTopStart - yDiff;
  4438. var scrollLeft = this.scrollLeftStart - xDiff;
  4439. if (this.element.scrollTo) {
  4440. this.element.scrollTo({
  4441. top: scrollTop,
  4442. left: scrollLeft,
  4443. behavior: "instant"
  4444. });
  4445. } else {
  4446. this.element.scrollTop = scrollTop;
  4447. this.element.scrollLeft = scrollLeft;
  4448. }
  4449. if (!this.overlay.parentNode) {
  4450. document.body.appendChild(this.overlay);
  4451. }
  4452. },
  4453. _endPan: function GrabToPan__endPan() {
  4454. this.element.removeEventListener("scroll", this._endPan, true);
  4455. this.document.removeEventListener("mousemove", this._onmousemove, true);
  4456. this.document.removeEventListener("mouseup", this._endPan, true);
  4457. this.overlay.remove();
  4458. }
  4459. };
  4460. var matchesSelector;
  4461. ["webkitM", "mozM", "msM", "oM", "m"].some(function (prefix) {
  4462. var name = prefix + "atches";
  4463. if (name in document.documentElement) {
  4464. matchesSelector = name;
  4465. }
  4466. name += "Selector";
  4467. if (name in document.documentElement) {
  4468. matchesSelector = name;
  4469. }
  4470. return matchesSelector;
  4471. });
  4472. var isNotIEorIsIE10plus = !document.documentMode || document.documentMode > 9;
  4473. var chrome = window.chrome;
  4474. var isChrome15OrOpera15plus = chrome && (chrome.webstore || chrome.app);
  4475. var isSafari6plus = /Apple/.test(navigator.vendor) && /Version\/([6-9]\d*|[1-5]\d+)/.test(navigator.userAgent);
  4476. function isLeftMouseReleased(event) {
  4477. if ("buttons" in event && isNotIEorIsIE10plus) {
  4478. return !(event.buttons & 1);
  4479. }
  4480. if (isChrome15OrOpera15plus || isSafari6plus) {
  4481. return event.which === 0;
  4482. }
  4483. return false;
  4484. }
  4485. /***/ }),
  4486. /* 11 */
  4487. /***/ (function(module, exports, __webpack_require__) {
  4488. "use strict";
  4489. Object.defineProperty(exports, "__esModule", {
  4490. value: true
  4491. });
  4492. exports.PDFRenderingQueue = exports.RenderingStates = void 0;
  4493. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  4494. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  4495. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  4496. var CLEANUP_TIMEOUT = 30000;
  4497. var RenderingStates = {
  4498. INITIAL: 0,
  4499. RUNNING: 1,
  4500. PAUSED: 2,
  4501. FINISHED: 3
  4502. };
  4503. exports.RenderingStates = RenderingStates;
  4504. var PDFRenderingQueue = /*#__PURE__*/function () {
  4505. function PDFRenderingQueue() {
  4506. _classCallCheck(this, PDFRenderingQueue);
  4507. this.pdfViewer = null;
  4508. this.pdfThumbnailViewer = null;
  4509. this.onIdle = null;
  4510. this.highestPriorityPage = null;
  4511. this.idleTimeout = null;
  4512. this.printing = false;
  4513. this.isThumbnailViewEnabled = false;
  4514. }
  4515. _createClass(PDFRenderingQueue, [{
  4516. key: "setViewer",
  4517. value: function setViewer(pdfViewer) {
  4518. this.pdfViewer = pdfViewer;
  4519. }
  4520. }, {
  4521. key: "setThumbnailViewer",
  4522. value: function setThumbnailViewer(pdfThumbnailViewer) {
  4523. this.pdfThumbnailViewer = pdfThumbnailViewer;
  4524. }
  4525. }, {
  4526. key: "isHighestPriority",
  4527. value: function isHighestPriority(view) {
  4528. return this.highestPriorityPage === view.renderingId;
  4529. }
  4530. }, {
  4531. key: "renderHighestPriority",
  4532. value: function renderHighestPriority(currentlyVisiblePages) {
  4533. if (this.idleTimeout) {
  4534. clearTimeout(this.idleTimeout);
  4535. this.idleTimeout = null;
  4536. }
  4537. if (this.pdfViewer.forceRendering(currentlyVisiblePages)) {
  4538. return;
  4539. }
  4540. if (this.pdfThumbnailViewer && this.isThumbnailViewEnabled) {
  4541. if (this.pdfThumbnailViewer.forceRendering()) {
  4542. return;
  4543. }
  4544. }
  4545. if (this.printing) {
  4546. return;
  4547. }
  4548. if (this.onIdle) {
  4549. this.idleTimeout = setTimeout(this.onIdle.bind(this), CLEANUP_TIMEOUT);
  4550. }
  4551. }
  4552. }, {
  4553. key: "getHighestPriority",
  4554. value: function getHighestPriority(visible, views, scrolledDown) {
  4555. var visibleViews = visible.views;
  4556. var numVisible = visibleViews.length;
  4557. if (numVisible === 0) {
  4558. return null;
  4559. }
  4560. for (var i = 0; i < numVisible; ++i) {
  4561. var view = visibleViews[i].view;
  4562. if (!this.isViewFinished(view)) {
  4563. return view;
  4564. }
  4565. }
  4566. if (scrolledDown) {
  4567. var nextPageIndex = visible.last.id;
  4568. if (views[nextPageIndex] && !this.isViewFinished(views[nextPageIndex])) {
  4569. return views[nextPageIndex];
  4570. }
  4571. } else {
  4572. var previousPageIndex = visible.first.id - 2;
  4573. if (views[previousPageIndex] && !this.isViewFinished(views[previousPageIndex])) {
  4574. return views[previousPageIndex];
  4575. }
  4576. }
  4577. return null;
  4578. }
  4579. }, {
  4580. key: "isViewFinished",
  4581. value: function isViewFinished(view) {
  4582. return view.renderingState === RenderingStates.FINISHED;
  4583. }
  4584. }, {
  4585. key: "renderView",
  4586. value: function renderView(view) {
  4587. var _this = this;
  4588. switch (view.renderingState) {
  4589. case RenderingStates.FINISHED:
  4590. return false;
  4591. case RenderingStates.PAUSED:
  4592. this.highestPriorityPage = view.renderingId;
  4593. view.resume();
  4594. break;
  4595. case RenderingStates.RUNNING:
  4596. this.highestPriorityPage = view.renderingId;
  4597. break;
  4598. case RenderingStates.INITIAL:
  4599. this.highestPriorityPage = view.renderingId;
  4600. view.draw()["finally"](function () {
  4601. _this.renderHighestPriority();
  4602. })["catch"](function (reason) {
  4603. console.error("renderView: \"".concat(reason, "\""));
  4604. });
  4605. break;
  4606. }
  4607. return true;
  4608. }
  4609. }]);
  4610. return PDFRenderingQueue;
  4611. }();
  4612. exports.PDFRenderingQueue = PDFRenderingQueue;
  4613. /***/ }),
  4614. /* 12 */
  4615. /***/ (function(module, exports, __webpack_require__) {
  4616. "use strict";
  4617. Object.defineProperty(exports, "__esModule", {
  4618. value: true
  4619. });
  4620. exports.PDFSidebar = exports.SidebarView = void 0;
  4621. var _ui_utils = __webpack_require__(5);
  4622. var _pdf_rendering_queue = __webpack_require__(11);
  4623. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  4624. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  4625. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  4626. var UI_NOTIFICATION_CLASS = "pdfSidebarNotification";
  4627. var SidebarView = {
  4628. UNKNOWN: -1,
  4629. NONE: 0,
  4630. THUMBS: 1,
  4631. OUTLINE: 2,
  4632. ATTACHMENTS: 3,
  4633. LAYERS: 4
  4634. };
  4635. exports.SidebarView = SidebarView;
  4636. var PDFSidebar = /*#__PURE__*/function () {
  4637. function PDFSidebar(_ref) {
  4638. var elements = _ref.elements,
  4639. pdfViewer = _ref.pdfViewer,
  4640. pdfThumbnailViewer = _ref.pdfThumbnailViewer,
  4641. eventBus = _ref.eventBus,
  4642. _ref$l10n = _ref.l10n,
  4643. l10n = _ref$l10n === void 0 ? _ui_utils.NullL10n : _ref$l10n,
  4644. _ref$disableNotificat = _ref.disableNotification,
  4645. disableNotification = _ref$disableNotificat === void 0 ? false : _ref$disableNotificat;
  4646. _classCallCheck(this, PDFSidebar);
  4647. this.isOpen = false;
  4648. this.active = SidebarView.THUMBS;
  4649. this.isInitialViewSet = false;
  4650. this.onToggled = null;
  4651. this.pdfViewer = pdfViewer;
  4652. this.pdfThumbnailViewer = pdfThumbnailViewer;
  4653. this.outerContainer = elements.outerContainer;
  4654. this.viewerContainer = elements.viewerContainer;
  4655. this.toggleButton = elements.toggleButton;
  4656. this.thumbnailButton = elements.thumbnailButton;
  4657. this.outlineButton = elements.outlineButton;
  4658. this.attachmentsButton = elements.attachmentsButton;
  4659. this.layersButton = elements.layersButton;
  4660. this.thumbnailView = elements.thumbnailView;
  4661. this.outlineView = elements.outlineView;
  4662. this.attachmentsView = elements.attachmentsView;
  4663. this.layersView = elements.layersView;
  4664. this.eventBus = eventBus;
  4665. this.l10n = l10n;
  4666. this._disableNotification = disableNotification;
  4667. this._addEventListeners();
  4668. }
  4669. _createClass(PDFSidebar, [{
  4670. key: "reset",
  4671. value: function reset() {
  4672. this.isInitialViewSet = false;
  4673. this._hideUINotification(null);
  4674. this.switchView(SidebarView.THUMBS);
  4675. this.outlineButton.disabled = false;
  4676. this.attachmentsButton.disabled = false;
  4677. this.layersButton.disabled = false;
  4678. }
  4679. }, {
  4680. key: "setInitialView",
  4681. value: function setInitialView() {
  4682. var view = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : SidebarView.NONE;
  4683. if (this.isInitialViewSet) {
  4684. return;
  4685. }
  4686. this.isInitialViewSet = true;
  4687. if (view === SidebarView.NONE || view === SidebarView.UNKNOWN) {
  4688. this._dispatchEvent();
  4689. return;
  4690. }
  4691. if (!this._switchView(view, true)) {
  4692. this._dispatchEvent();
  4693. }
  4694. }
  4695. }, {
  4696. key: "switchView",
  4697. value: function switchView(view) {
  4698. var forceOpen = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  4699. this._switchView(view, forceOpen);
  4700. }
  4701. }, {
  4702. key: "_switchView",
  4703. value: function _switchView(view) {
  4704. var forceOpen = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  4705. var isViewChanged = view !== this.active;
  4706. var shouldForceRendering = false;
  4707. switch (view) {
  4708. case SidebarView.NONE:
  4709. if (this.isOpen) {
  4710. this.close();
  4711. return true;
  4712. }
  4713. return false;
  4714. case SidebarView.THUMBS:
  4715. if (this.isOpen && isViewChanged) {
  4716. shouldForceRendering = true;
  4717. }
  4718. break;
  4719. case SidebarView.OUTLINE:
  4720. if (this.outlineButton.disabled) {
  4721. return false;
  4722. }
  4723. break;
  4724. case SidebarView.ATTACHMENTS:
  4725. if (this.attachmentsButton.disabled) {
  4726. return false;
  4727. }
  4728. break;
  4729. case SidebarView.LAYERS:
  4730. if (this.layersButton.disabled) {
  4731. return false;
  4732. }
  4733. break;
  4734. default:
  4735. console.error("PDFSidebar._switchView: \"".concat(view, "\" is not a valid view."));
  4736. return false;
  4737. }
  4738. this.active = view;
  4739. this.thumbnailButton.classList.toggle("toggled", view === SidebarView.THUMBS);
  4740. this.outlineButton.classList.toggle("toggled", view === SidebarView.OUTLINE);
  4741. this.attachmentsButton.classList.toggle("toggled", view === SidebarView.ATTACHMENTS);
  4742. this.layersButton.classList.toggle("toggled", view === SidebarView.LAYERS);
  4743. this.thumbnailView.classList.toggle("hidden", view !== SidebarView.THUMBS);
  4744. this.outlineView.classList.toggle("hidden", view !== SidebarView.OUTLINE);
  4745. this.attachmentsView.classList.toggle("hidden", view !== SidebarView.ATTACHMENTS);
  4746. this.layersView.classList.toggle("hidden", view !== SidebarView.LAYERS);
  4747. if (forceOpen && !this.isOpen) {
  4748. this.open();
  4749. return true;
  4750. }
  4751. if (shouldForceRendering) {
  4752. this._updateThumbnailViewer();
  4753. this._forceRendering();
  4754. }
  4755. if (isViewChanged) {
  4756. this._dispatchEvent();
  4757. }
  4758. this._hideUINotification(this.active);
  4759. return isViewChanged;
  4760. }
  4761. }, {
  4762. key: "open",
  4763. value: function open() {
  4764. if (this.isOpen) {
  4765. return;
  4766. }
  4767. this.isOpen = true;
  4768. this.toggleButton.classList.add("toggled");
  4769. this.outerContainer.classList.add("sidebarMoving", "sidebarOpen");
  4770. if (this.active === SidebarView.THUMBS) {
  4771. this._updateThumbnailViewer();
  4772. }
  4773. this._forceRendering();
  4774. this._dispatchEvent();
  4775. this._hideUINotification(this.active);
  4776. }
  4777. }, {
  4778. key: "close",
  4779. value: function close() {
  4780. if (!this.isOpen) {
  4781. return;
  4782. }
  4783. this.isOpen = false;
  4784. this.toggleButton.classList.remove("toggled");
  4785. this.outerContainer.classList.add("sidebarMoving");
  4786. this.outerContainer.classList.remove("sidebarOpen");
  4787. this._forceRendering();
  4788. this._dispatchEvent();
  4789. }
  4790. }, {
  4791. key: "toggle",
  4792. value: function toggle() {
  4793. if (this.isOpen) {
  4794. this.close();
  4795. } else {
  4796. this.open();
  4797. }
  4798. }
  4799. }, {
  4800. key: "_dispatchEvent",
  4801. value: function _dispatchEvent() {
  4802. this.eventBus.dispatch("sidebarviewchanged", {
  4803. source: this,
  4804. view: this.visibleView
  4805. });
  4806. }
  4807. }, {
  4808. key: "_forceRendering",
  4809. value: function _forceRendering() {
  4810. if (this.onToggled) {
  4811. this.onToggled();
  4812. } else {
  4813. this.pdfViewer.forceRendering();
  4814. this.pdfThumbnailViewer.forceRendering();
  4815. }
  4816. }
  4817. }, {
  4818. key: "_updateThumbnailViewer",
  4819. value: function _updateThumbnailViewer() {
  4820. var pdfViewer = this.pdfViewer,
  4821. pdfThumbnailViewer = this.pdfThumbnailViewer;
  4822. var pagesCount = pdfViewer.pagesCount;
  4823. for (var pageIndex = 0; pageIndex < pagesCount; pageIndex++) {
  4824. var pageView = pdfViewer.getPageView(pageIndex);
  4825. if (pageView && pageView.renderingState === _pdf_rendering_queue.RenderingStates.FINISHED) {
  4826. var thumbnailView = pdfThumbnailViewer.getThumbnail(pageIndex);
  4827. thumbnailView.setImage(pageView);
  4828. }
  4829. }
  4830. pdfThumbnailViewer.scrollThumbnailIntoView(pdfViewer.currentPageNumber);
  4831. }
  4832. }, {
  4833. key: "_showUINotification",
  4834. value: function _showUINotification(view) {
  4835. var _this = this;
  4836. if (this._disableNotification) {
  4837. return;
  4838. }
  4839. this.l10n.get("toggle_sidebar_notification2.title", null, "Toggle Sidebar (document contains outline/attachments/layers)").then(function (msg) {
  4840. _this.toggleButton.title = msg;
  4841. });
  4842. if (!this.isOpen) {
  4843. this.toggleButton.classList.add(UI_NOTIFICATION_CLASS);
  4844. } else if (view === this.active) {
  4845. return;
  4846. }
  4847. switch (view) {
  4848. case SidebarView.OUTLINE:
  4849. this.outlineButton.classList.add(UI_NOTIFICATION_CLASS);
  4850. break;
  4851. case SidebarView.ATTACHMENTS:
  4852. this.attachmentsButton.classList.add(UI_NOTIFICATION_CLASS);
  4853. break;
  4854. case SidebarView.LAYERS:
  4855. this.layersButton.classList.add(UI_NOTIFICATION_CLASS);
  4856. break;
  4857. }
  4858. }
  4859. }, {
  4860. key: "_hideUINotification",
  4861. value: function _hideUINotification(view) {
  4862. var _this2 = this;
  4863. if (this._disableNotification) {
  4864. return;
  4865. }
  4866. var removeNotification = function removeNotification(sidebarView) {
  4867. switch (sidebarView) {
  4868. case SidebarView.OUTLINE:
  4869. _this2.outlineButton.classList.remove(UI_NOTIFICATION_CLASS);
  4870. break;
  4871. case SidebarView.ATTACHMENTS:
  4872. _this2.attachmentsButton.classList.remove(UI_NOTIFICATION_CLASS);
  4873. break;
  4874. case SidebarView.LAYERS:
  4875. _this2.layersButton.classList.remove(UI_NOTIFICATION_CLASS);
  4876. break;
  4877. }
  4878. };
  4879. if (!this.isOpen && view !== null) {
  4880. return;
  4881. }
  4882. this.toggleButton.classList.remove(UI_NOTIFICATION_CLASS);
  4883. if (view !== null) {
  4884. removeNotification(view);
  4885. return;
  4886. }
  4887. for (view in SidebarView) {
  4888. removeNotification(SidebarView[view]);
  4889. }
  4890. this.l10n.get("toggle_sidebar.title", null, "Toggle Sidebar").then(function (msg) {
  4891. _this2.toggleButton.title = msg;
  4892. });
  4893. }
  4894. }, {
  4895. key: "_addEventListeners",
  4896. value: function _addEventListeners() {
  4897. var _this3 = this;
  4898. this.viewerContainer.addEventListener("transitionend", function (evt) {
  4899. if (evt.target === _this3.viewerContainer) {
  4900. _this3.outerContainer.classList.remove("sidebarMoving");
  4901. }
  4902. });
  4903. this.toggleButton.addEventListener("click", function () {
  4904. _this3.toggle();
  4905. });
  4906. this.thumbnailButton.addEventListener("click", function () {
  4907. _this3.switchView(SidebarView.THUMBS);
  4908. });
  4909. this.outlineButton.addEventListener("click", function () {
  4910. _this3.switchView(SidebarView.OUTLINE);
  4911. });
  4912. this.outlineButton.addEventListener("dblclick", function () {
  4913. _this3.eventBus.dispatch("toggleoutlinetree", {
  4914. source: _this3
  4915. });
  4916. });
  4917. this.attachmentsButton.addEventListener("click", function () {
  4918. _this3.switchView(SidebarView.ATTACHMENTS);
  4919. });
  4920. this.layersButton.addEventListener("click", function () {
  4921. _this3.switchView(SidebarView.LAYERS);
  4922. });
  4923. this.layersButton.addEventListener("dblclick", function () {
  4924. _this3.eventBus.dispatch("resetlayers", {
  4925. source: _this3
  4926. });
  4927. });
  4928. var onTreeLoaded = function onTreeLoaded(count, button, view) {
  4929. button.disabled = !count;
  4930. if (count) {
  4931. _this3._showUINotification(view);
  4932. } else if (_this3.active === view) {
  4933. _this3.switchView(SidebarView.THUMBS);
  4934. }
  4935. };
  4936. this.eventBus._on("outlineloaded", function (evt) {
  4937. onTreeLoaded(evt.outlineCount, _this3.outlineButton, SidebarView.OUTLINE);
  4938. });
  4939. this.eventBus._on("attachmentsloaded", function (evt) {
  4940. onTreeLoaded(evt.attachmentsCount, _this3.attachmentsButton, SidebarView.ATTACHMENTS);
  4941. });
  4942. this.eventBus._on("layersloaded", function (evt) {
  4943. onTreeLoaded(evt.layersCount, _this3.layersButton, SidebarView.LAYERS);
  4944. });
  4945. this.eventBus._on("presentationmodechanged", function (evt) {
  4946. if (!evt.active && !evt.switchInProgress && _this3.isThumbnailViewVisible) {
  4947. _this3._updateThumbnailViewer();
  4948. }
  4949. });
  4950. }
  4951. }, {
  4952. key: "visibleView",
  4953. get: function get() {
  4954. return this.isOpen ? this.active : SidebarView.NONE;
  4955. }
  4956. }, {
  4957. key: "isThumbnailViewVisible",
  4958. get: function get() {
  4959. return this.isOpen && this.active === SidebarView.THUMBS;
  4960. }
  4961. }, {
  4962. key: "isOutlineViewVisible",
  4963. get: function get() {
  4964. return this.isOpen && this.active === SidebarView.OUTLINE;
  4965. }
  4966. }, {
  4967. key: "isAttachmentsViewVisible",
  4968. get: function get() {
  4969. return this.isOpen && this.active === SidebarView.ATTACHMENTS;
  4970. }
  4971. }, {
  4972. key: "isLayersViewVisible",
  4973. get: function get() {
  4974. return this.isOpen && this.active === SidebarView.LAYERS;
  4975. }
  4976. }]);
  4977. return PDFSidebar;
  4978. }();
  4979. exports.PDFSidebar = PDFSidebar;
  4980. /***/ }),
  4981. /* 13 */
  4982. /***/ (function(module, exports, __webpack_require__) {
  4983. "use strict";
  4984. Object.defineProperty(exports, "__esModule", {
  4985. value: true
  4986. });
  4987. exports.OverlayManager = void 0;
  4988. var _regenerator = _interopRequireDefault(__webpack_require__(2));
  4989. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  4990. function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
  4991. function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
  4992. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  4993. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  4994. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  4995. var OverlayManager = /*#__PURE__*/function () {
  4996. function OverlayManager() {
  4997. _classCallCheck(this, OverlayManager);
  4998. this._overlays = {};
  4999. this._active = null;
  5000. this._keyDownBound = this._keyDown.bind(this);
  5001. }
  5002. _createClass(OverlayManager, [{
  5003. key: "register",
  5004. value: function () {
  5005. var _register = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee(name, element) {
  5006. var callerCloseMethod,
  5007. canForceClose,
  5008. container,
  5009. _args = arguments;
  5010. return _regenerator["default"].wrap(function _callee$(_context) {
  5011. while (1) {
  5012. switch (_context.prev = _context.next) {
  5013. case 0:
  5014. callerCloseMethod = _args.length > 2 && _args[2] !== undefined ? _args[2] : null;
  5015. canForceClose = _args.length > 3 && _args[3] !== undefined ? _args[3] : false;
  5016. if (!(!name || !element || !(container = element.parentNode))) {
  5017. _context.next = 6;
  5018. break;
  5019. }
  5020. throw new Error("Not enough parameters.");
  5021. case 6:
  5022. if (!this._overlays[name]) {
  5023. _context.next = 8;
  5024. break;
  5025. }
  5026. throw new Error("The overlay is already registered.");
  5027. case 8:
  5028. this._overlays[name] = {
  5029. element: element,
  5030. container: container,
  5031. callerCloseMethod: callerCloseMethod,
  5032. canForceClose: canForceClose
  5033. };
  5034. case 9:
  5035. case "end":
  5036. return _context.stop();
  5037. }
  5038. }
  5039. }, _callee, this);
  5040. }));
  5041. function register(_x, _x2) {
  5042. return _register.apply(this, arguments);
  5043. }
  5044. return register;
  5045. }()
  5046. }, {
  5047. key: "unregister",
  5048. value: function () {
  5049. var _unregister = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee2(name) {
  5050. return _regenerator["default"].wrap(function _callee2$(_context2) {
  5051. while (1) {
  5052. switch (_context2.prev = _context2.next) {
  5053. case 0:
  5054. if (this._overlays[name]) {
  5055. _context2.next = 4;
  5056. break;
  5057. }
  5058. throw new Error("The overlay does not exist.");
  5059. case 4:
  5060. if (!(this._active === name)) {
  5061. _context2.next = 6;
  5062. break;
  5063. }
  5064. throw new Error("The overlay cannot be removed while it is active.");
  5065. case 6:
  5066. delete this._overlays[name];
  5067. case 7:
  5068. case "end":
  5069. return _context2.stop();
  5070. }
  5071. }
  5072. }, _callee2, this);
  5073. }));
  5074. function unregister(_x3) {
  5075. return _unregister.apply(this, arguments);
  5076. }
  5077. return unregister;
  5078. }()
  5079. }, {
  5080. key: "open",
  5081. value: function () {
  5082. var _open = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee3(name) {
  5083. return _regenerator["default"].wrap(function _callee3$(_context3) {
  5084. while (1) {
  5085. switch (_context3.prev = _context3.next) {
  5086. case 0:
  5087. if (this._overlays[name]) {
  5088. _context3.next = 4;
  5089. break;
  5090. }
  5091. throw new Error("The overlay does not exist.");
  5092. case 4:
  5093. if (!this._active) {
  5094. _context3.next = 14;
  5095. break;
  5096. }
  5097. if (!this._overlays[name].canForceClose) {
  5098. _context3.next = 9;
  5099. break;
  5100. }
  5101. this._closeThroughCaller();
  5102. _context3.next = 14;
  5103. break;
  5104. case 9:
  5105. if (!(this._active === name)) {
  5106. _context3.next = 13;
  5107. break;
  5108. }
  5109. throw new Error("The overlay is already active.");
  5110. case 13:
  5111. throw new Error("Another overlay is currently active.");
  5112. case 14:
  5113. this._active = name;
  5114. this._overlays[this._active].element.classList.remove("hidden");
  5115. this._overlays[this._active].container.classList.remove("hidden");
  5116. window.addEventListener("keydown", this._keyDownBound);
  5117. case 18:
  5118. case "end":
  5119. return _context3.stop();
  5120. }
  5121. }
  5122. }, _callee3, this);
  5123. }));
  5124. function open(_x4) {
  5125. return _open.apply(this, arguments);
  5126. }
  5127. return open;
  5128. }()
  5129. }, {
  5130. key: "close",
  5131. value: function () {
  5132. var _close = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee4(name) {
  5133. return _regenerator["default"].wrap(function _callee4$(_context4) {
  5134. while (1) {
  5135. switch (_context4.prev = _context4.next) {
  5136. case 0:
  5137. if (this._overlays[name]) {
  5138. _context4.next = 4;
  5139. break;
  5140. }
  5141. throw new Error("The overlay does not exist.");
  5142. case 4:
  5143. if (this._active) {
  5144. _context4.next = 8;
  5145. break;
  5146. }
  5147. throw new Error("The overlay is currently not active.");
  5148. case 8:
  5149. if (!(this._active !== name)) {
  5150. _context4.next = 10;
  5151. break;
  5152. }
  5153. throw new Error("Another overlay is currently active.");
  5154. case 10:
  5155. this._overlays[this._active].container.classList.add("hidden");
  5156. this._overlays[this._active].element.classList.add("hidden");
  5157. this._active = null;
  5158. window.removeEventListener("keydown", this._keyDownBound);
  5159. case 14:
  5160. case "end":
  5161. return _context4.stop();
  5162. }
  5163. }
  5164. }, _callee4, this);
  5165. }));
  5166. function close(_x5) {
  5167. return _close.apply(this, arguments);
  5168. }
  5169. return close;
  5170. }()
  5171. }, {
  5172. key: "_keyDown",
  5173. value: function _keyDown(evt) {
  5174. if (this._active && evt.keyCode === 27) {
  5175. this._closeThroughCaller();
  5176. evt.preventDefault();
  5177. }
  5178. }
  5179. }, {
  5180. key: "_closeThroughCaller",
  5181. value: function _closeThroughCaller() {
  5182. if (this._overlays[this._active].callerCloseMethod) {
  5183. this._overlays[this._active].callerCloseMethod();
  5184. }
  5185. if (this._active) {
  5186. this.close(this._active);
  5187. }
  5188. }
  5189. }, {
  5190. key: "active",
  5191. get: function get() {
  5192. return this._active;
  5193. }
  5194. }]);
  5195. return OverlayManager;
  5196. }();
  5197. exports.OverlayManager = OverlayManager;
  5198. /***/ }),
  5199. /* 14 */
  5200. /***/ (function(module, exports, __webpack_require__) {
  5201. "use strict";
  5202. Object.defineProperty(exports, "__esModule", {
  5203. value: true
  5204. });
  5205. exports.PasswordPrompt = void 0;
  5206. var _ui_utils = __webpack_require__(5);
  5207. var _pdfjsLib = __webpack_require__(8);
  5208. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  5209. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  5210. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  5211. var PasswordPrompt = /*#__PURE__*/function () {
  5212. function PasswordPrompt(options, overlayManager) {
  5213. var _this = this;
  5214. var l10n = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : _ui_utils.NullL10n;
  5215. _classCallCheck(this, PasswordPrompt);
  5216. this.overlayName = options.overlayName;
  5217. this.container = options.container;
  5218. this.label = options.label;
  5219. this.input = options.input;
  5220. this.submitButton = options.submitButton;
  5221. this.cancelButton = options.cancelButton;
  5222. this.overlayManager = overlayManager;
  5223. this.l10n = l10n;
  5224. this.updateCallback = null;
  5225. this.reason = null;
  5226. this.submitButton.addEventListener("click", this.verify.bind(this));
  5227. this.cancelButton.addEventListener("click", this.close.bind(this));
  5228. this.input.addEventListener("keydown", function (e) {
  5229. if (e.keyCode === 13) {
  5230. _this.verify();
  5231. }
  5232. });
  5233. this.overlayManager.register(this.overlayName, this.container, this.close.bind(this), true);
  5234. }
  5235. _createClass(PasswordPrompt, [{
  5236. key: "open",
  5237. value: function open() {
  5238. var _this2 = this;
  5239. this.overlayManager.open(this.overlayName).then(function () {
  5240. _this2.input.focus();
  5241. var promptString;
  5242. if (_this2.reason === _pdfjsLib.PasswordResponses.INCORRECT_PASSWORD) {
  5243. promptString = _this2.l10n.get("password_invalid", null, "Invalid password. Please try again.");
  5244. } else {
  5245. promptString = _this2.l10n.get("password_label", null, "Enter the password to open this PDF file.");
  5246. }
  5247. promptString.then(function (msg) {
  5248. _this2.label.textContent = msg;
  5249. });
  5250. });
  5251. }
  5252. }, {
  5253. key: "close",
  5254. value: function close() {
  5255. var _this3 = this;
  5256. this.overlayManager.close(this.overlayName).then(function () {
  5257. _this3.input.value = "";
  5258. });
  5259. }
  5260. }, {
  5261. key: "verify",
  5262. value: function verify() {
  5263. var password = this.input.value;
  5264. if (password && password.length > 0) {
  5265. this.close();
  5266. this.updateCallback(password);
  5267. }
  5268. }
  5269. }, {
  5270. key: "setUpdateCallback",
  5271. value: function setUpdateCallback(updateCallback, reason) {
  5272. this.updateCallback = updateCallback;
  5273. this.reason = reason;
  5274. }
  5275. }]);
  5276. return PasswordPrompt;
  5277. }();
  5278. exports.PasswordPrompt = PasswordPrompt;
  5279. /***/ }),
  5280. /* 15 */
  5281. /***/ (function(module, exports, __webpack_require__) {
  5282. "use strict";
  5283. Object.defineProperty(exports, "__esModule", {
  5284. value: true
  5285. });
  5286. exports.PDFAttachmentViewer = void 0;
  5287. var _pdfjsLib = __webpack_require__(8);
  5288. var _base_tree_viewer = __webpack_require__(16);
  5289. var _viewer_compatibility = __webpack_require__(7);
  5290. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  5291. function _createForOfIteratorHelper(o, allowArrayLike) { var it; if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = o[Symbol.iterator](); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
  5292. function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
  5293. function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
  5294. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  5295. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  5296. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  5297. function _get(target, property, receiver) { if (typeof Reflect !== "undefined" && Reflect.get) { _get = Reflect.get; } else { _get = function _get(target, property, receiver) { var base = _superPropBase(target, property); if (!base) return; var desc = Object.getOwnPropertyDescriptor(base, property); if (desc.get) { return desc.get.call(receiver); } return desc.value; }; } return _get(target, property, receiver || target); }
  5298. function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
  5299. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  5300. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  5301. function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  5302. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  5303. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  5304. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
  5305. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  5306. var PdfFileRegExp = /\.pdf$/i;
  5307. var PDFAttachmentViewer = /*#__PURE__*/function (_BaseTreeViewer) {
  5308. _inherits(PDFAttachmentViewer, _BaseTreeViewer);
  5309. var _super = _createSuper(PDFAttachmentViewer);
  5310. function PDFAttachmentViewer(options) {
  5311. var _this;
  5312. _classCallCheck(this, PDFAttachmentViewer);
  5313. _this = _super.call(this, options);
  5314. _this.downloadManager = options.downloadManager;
  5315. _this.eventBus._on("fileattachmentannotation", _this._appendAttachment.bind(_assertThisInitialized(_this)));
  5316. return _this;
  5317. }
  5318. _createClass(PDFAttachmentViewer, [{
  5319. key: "reset",
  5320. value: function reset() {
  5321. var keepRenderedCapability = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  5322. _get(_getPrototypeOf(PDFAttachmentViewer.prototype), "reset", this).call(this);
  5323. this._attachments = null;
  5324. if (!keepRenderedCapability) {
  5325. this._renderedCapability = (0, _pdfjsLib.createPromiseCapability)();
  5326. }
  5327. if (this._pendingDispatchEvent) {
  5328. clearTimeout(this._pendingDispatchEvent);
  5329. }
  5330. this._pendingDispatchEvent = null;
  5331. }
  5332. }, {
  5333. key: "_dispatchEvent",
  5334. value: function _dispatchEvent(attachmentsCount) {
  5335. var _this2 = this;
  5336. this._renderedCapability.resolve();
  5337. if (this._pendingDispatchEvent) {
  5338. clearTimeout(this._pendingDispatchEvent);
  5339. this._pendingDispatchEvent = null;
  5340. }
  5341. if (attachmentsCount === 0) {
  5342. this._pendingDispatchEvent = setTimeout(function () {
  5343. _this2.eventBus.dispatch("attachmentsloaded", {
  5344. source: _this2,
  5345. attachmentsCount: 0
  5346. });
  5347. _this2._pendingDispatchEvent = null;
  5348. });
  5349. return;
  5350. }
  5351. this.eventBus.dispatch("attachmentsloaded", {
  5352. source: this,
  5353. attachmentsCount: attachmentsCount
  5354. });
  5355. }
  5356. }, {
  5357. key: "_bindPdfLink",
  5358. value: function _bindPdfLink(element, _ref) {
  5359. var _this3 = this;
  5360. var content = _ref.content,
  5361. filename = _ref.filename;
  5362. var blobUrl;
  5363. element.onclick = function () {
  5364. if (!blobUrl) {
  5365. blobUrl = URL.createObjectURL(new Blob([content], {
  5366. type: "application/pdf"
  5367. }));
  5368. }
  5369. var viewerUrl;
  5370. viewerUrl = "?file=" + encodeURIComponent(blobUrl + "#" + filename);
  5371. try {
  5372. window.open(viewerUrl);
  5373. } catch (ex) {
  5374. console.error("_bindPdfLink: ".concat(ex));
  5375. URL.revokeObjectURL(blobUrl);
  5376. blobUrl = null;
  5377. _this3.downloadManager.downloadData(content, filename, "application/pdf");
  5378. }
  5379. return false;
  5380. };
  5381. }
  5382. }, {
  5383. key: "_bindLink",
  5384. value: function _bindLink(element, _ref2) {
  5385. var _this4 = this;
  5386. var content = _ref2.content,
  5387. filename = _ref2.filename;
  5388. element.onclick = function () {
  5389. var contentType = PdfFileRegExp.test(filename) ? "application/pdf" : "";
  5390. _this4.downloadManager.downloadData(content, filename, contentType);
  5391. return false;
  5392. };
  5393. }
  5394. }, {
  5395. key: "render",
  5396. value: function render(_ref3) {
  5397. var attachments = _ref3.attachments,
  5398. _ref3$keepRenderedCap = _ref3.keepRenderedCapability,
  5399. keepRenderedCapability = _ref3$keepRenderedCap === void 0 ? false : _ref3$keepRenderedCap;
  5400. if (this._attachments) {
  5401. this.reset(keepRenderedCapability);
  5402. }
  5403. this._attachments = attachments || null;
  5404. if (!attachments) {
  5405. this._dispatchEvent(0);
  5406. return;
  5407. }
  5408. var names = Object.keys(attachments).sort(function (a, b) {
  5409. return a.toLowerCase().localeCompare(b.toLowerCase());
  5410. });
  5411. var fragment = document.createDocumentFragment();
  5412. var attachmentsCount = 0;
  5413. var _iterator = _createForOfIteratorHelper(names),
  5414. _step;
  5415. try {
  5416. for (_iterator.s(); !(_step = _iterator.n()).done;) {
  5417. var name = _step.value;
  5418. var item = attachments[name];
  5419. var filename = (0, _pdfjsLib.getFilenameFromUrl)(item.filename);
  5420. var div = document.createElement("div");
  5421. div.className = "treeItem";
  5422. var element = document.createElement("a");
  5423. if (PdfFileRegExp.test(filename) && !_viewer_compatibility.viewerCompatibilityParams.disableCreateObjectURL) {
  5424. this._bindPdfLink(element, {
  5425. content: item.content,
  5426. filename: filename
  5427. });
  5428. } else {
  5429. this._bindLink(element, {
  5430. content: item.content,
  5431. filename: filename
  5432. });
  5433. }
  5434. element.textContent = this._normalizeTextContent(filename);
  5435. div.appendChild(element);
  5436. fragment.appendChild(div);
  5437. attachmentsCount++;
  5438. }
  5439. } catch (err) {
  5440. _iterator.e(err);
  5441. } finally {
  5442. _iterator.f();
  5443. }
  5444. this.container.appendChild(fragment);
  5445. this._dispatchEvent(attachmentsCount);
  5446. }
  5447. }, {
  5448. key: "_appendAttachment",
  5449. value: function _appendAttachment(_ref4) {
  5450. var _this5 = this;
  5451. var id = _ref4.id,
  5452. filename = _ref4.filename,
  5453. content = _ref4.content;
  5454. var renderedPromise = this._renderedCapability.promise;
  5455. renderedPromise.then(function () {
  5456. if (renderedPromise !== _this5._renderedCapability.promise) {
  5457. return;
  5458. }
  5459. var attachments = _this5._attachments;
  5460. if (!attachments) {
  5461. attachments = Object.create(null);
  5462. } else {
  5463. for (var name in attachments) {
  5464. if (id === name) {
  5465. return;
  5466. }
  5467. }
  5468. }
  5469. attachments[id] = {
  5470. filename: filename,
  5471. content: content
  5472. };
  5473. _this5.render({
  5474. attachments: attachments,
  5475. keepRenderedCapability: true
  5476. });
  5477. });
  5478. }
  5479. }]);
  5480. return PDFAttachmentViewer;
  5481. }(_base_tree_viewer.BaseTreeViewer);
  5482. exports.PDFAttachmentViewer = PDFAttachmentViewer;
  5483. /***/ }),
  5484. /* 16 */
  5485. /***/ (function(module, exports, __webpack_require__) {
  5486. "use strict";
  5487. Object.defineProperty(exports, "__esModule", {
  5488. value: true
  5489. });
  5490. exports.BaseTreeViewer = void 0;
  5491. var _pdfjsLib = __webpack_require__(8);
  5492. function _createForOfIteratorHelper(o, allowArrayLike) { var it; if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = o[Symbol.iterator](); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
  5493. function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
  5494. function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
  5495. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  5496. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  5497. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  5498. var BaseTreeViewer = /*#__PURE__*/function () {
  5499. function BaseTreeViewer(options) {
  5500. _classCallCheck(this, BaseTreeViewer);
  5501. if (this.constructor === BaseTreeViewer) {
  5502. throw new Error("Cannot initialize BaseTreeViewer.");
  5503. }
  5504. this.container = options.container;
  5505. this.eventBus = options.eventBus;
  5506. this.reset();
  5507. }
  5508. _createClass(BaseTreeViewer, [{
  5509. key: "reset",
  5510. value: function reset() {
  5511. this._lastToggleIsShow = true;
  5512. this.container.textContent = "";
  5513. this.container.classList.remove("treeWithDeepNesting");
  5514. }
  5515. }, {
  5516. key: "_dispatchEvent",
  5517. value: function _dispatchEvent(count) {
  5518. throw new Error("Not implemented: _dispatchEvent");
  5519. }
  5520. }, {
  5521. key: "_bindLink",
  5522. value: function _bindLink(element, params) {
  5523. throw new Error("Not implemented: _bindLink");
  5524. }
  5525. }, {
  5526. key: "_normalizeTextContent",
  5527. value: function _normalizeTextContent(str) {
  5528. return (0, _pdfjsLib.removeNullCharacters)(str) || "\u2013";
  5529. }
  5530. }, {
  5531. key: "_addToggleButton",
  5532. value: function _addToggleButton(div) {
  5533. var _this = this;
  5534. var hidden = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  5535. var toggler = document.createElement("div");
  5536. toggler.className = "treeItemToggler";
  5537. if (hidden) {
  5538. toggler.classList.add("treeItemsHidden");
  5539. }
  5540. toggler.onclick = function (evt) {
  5541. evt.stopPropagation();
  5542. toggler.classList.toggle("treeItemsHidden");
  5543. if (evt.shiftKey) {
  5544. var shouldShowAll = !toggler.classList.contains("treeItemsHidden");
  5545. _this._toggleTreeItem(div, shouldShowAll);
  5546. }
  5547. };
  5548. div.insertBefore(toggler, div.firstChild);
  5549. }
  5550. }, {
  5551. key: "_toggleTreeItem",
  5552. value: function _toggleTreeItem(root) {
  5553. var show = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  5554. this._lastToggleIsShow = show;
  5555. var _iterator = _createForOfIteratorHelper(root.querySelectorAll(".treeItemToggler")),
  5556. _step;
  5557. try {
  5558. for (_iterator.s(); !(_step = _iterator.n()).done;) {
  5559. var toggler = _step.value;
  5560. toggler.classList.toggle("treeItemsHidden", !show);
  5561. }
  5562. } catch (err) {
  5563. _iterator.e(err);
  5564. } finally {
  5565. _iterator.f();
  5566. }
  5567. }
  5568. }, {
  5569. key: "_toggleAllTreeItems",
  5570. value: function _toggleAllTreeItems() {
  5571. this._toggleTreeItem(this.container, !this._lastToggleIsShow);
  5572. }
  5573. }, {
  5574. key: "render",
  5575. value: function render(params) {
  5576. throw new Error("Not implemented: render");
  5577. }
  5578. }]);
  5579. return BaseTreeViewer;
  5580. }();
  5581. exports.BaseTreeViewer = BaseTreeViewer;
  5582. /***/ }),
  5583. /* 17 */
  5584. /***/ (function(module, exports, __webpack_require__) {
  5585. "use strict";
  5586. Object.defineProperty(exports, "__esModule", {
  5587. value: true
  5588. });
  5589. exports.PDFDocumentProperties = void 0;
  5590. var _regenerator = _interopRequireDefault(__webpack_require__(2));
  5591. var _pdfjsLib = __webpack_require__(8);
  5592. var _ui_utils = __webpack_require__(5);
  5593. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  5594. function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
  5595. function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
  5596. function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
  5597. function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
  5598. function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
  5599. function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
  5600. function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
  5601. function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
  5602. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  5603. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  5604. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  5605. var DEFAULT_FIELD_CONTENT = "-";
  5606. var NON_METRIC_LOCALES = ["en-us", "en-lr", "my"];
  5607. var US_PAGE_NAMES = {
  5608. "8.5x11": "Letter",
  5609. "8.5x14": "Legal"
  5610. };
  5611. var METRIC_PAGE_NAMES = {
  5612. "297x420": "A3",
  5613. "210x297": "A4"
  5614. };
  5615. function getPageName(size, isPortrait, pageNames) {
  5616. var width = isPortrait ? size.width : size.height;
  5617. var height = isPortrait ? size.height : size.width;
  5618. return pageNames["".concat(width, "x").concat(height)];
  5619. }
  5620. var PDFDocumentProperties = /*#__PURE__*/function () {
  5621. function PDFDocumentProperties(_ref, overlayManager, eventBus) {
  5622. var _this = this;
  5623. var overlayName = _ref.overlayName,
  5624. fields = _ref.fields,
  5625. container = _ref.container,
  5626. closeButton = _ref.closeButton;
  5627. var l10n = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : _ui_utils.NullL10n;
  5628. _classCallCheck(this, PDFDocumentProperties);
  5629. this.overlayName = overlayName;
  5630. this.fields = fields;
  5631. this.container = container;
  5632. this.overlayManager = overlayManager;
  5633. this.l10n = l10n;
  5634. this._reset();
  5635. closeButton.addEventListener("click", this.close.bind(this));
  5636. this.overlayManager.register(this.overlayName, this.container, this.close.bind(this));
  5637. eventBus._on("pagechanging", function (evt) {
  5638. _this._currentPageNumber = evt.pageNumber;
  5639. });
  5640. eventBus._on("rotationchanging", function (evt) {
  5641. _this._pagesRotation = evt.pagesRotation;
  5642. });
  5643. this._isNonMetricLocale = true;
  5644. l10n.getLanguage().then(function (locale) {
  5645. _this._isNonMetricLocale = NON_METRIC_LOCALES.includes(locale);
  5646. });
  5647. }
  5648. _createClass(PDFDocumentProperties, [{
  5649. key: "open",
  5650. value: function open() {
  5651. var _this2 = this;
  5652. var freezeFieldData = function freezeFieldData(data) {
  5653. Object.defineProperty(_this2, "fieldData", {
  5654. value: Object.freeze(data),
  5655. writable: false,
  5656. enumerable: true,
  5657. configurable: true
  5658. });
  5659. };
  5660. Promise.all([this.overlayManager.open(this.overlayName), this._dataAvailableCapability.promise]).then(function () {
  5661. var currentPageNumber = _this2._currentPageNumber;
  5662. var pagesRotation = _this2._pagesRotation;
  5663. if (_this2.fieldData && currentPageNumber === _this2.fieldData._currentPageNumber && pagesRotation === _this2.fieldData._pagesRotation) {
  5664. _this2._updateUI();
  5665. return;
  5666. }
  5667. _this2.pdfDocument.getMetadata().then(function (_ref2) {
  5668. var info = _ref2.info,
  5669. metadata = _ref2.metadata,
  5670. contentDispositionFilename = _ref2.contentDispositionFilename;
  5671. return Promise.all([info, metadata, contentDispositionFilename || (0, _ui_utils.getPDFFileNameFromURL)(_this2.url), _this2._parseFileSize(_this2.maybeFileSize), _this2._parseDate(info.CreationDate), _this2._parseDate(info.ModDate), _this2.pdfDocument.getPage(currentPageNumber).then(function (pdfPage) {
  5672. return _this2._parsePageSize((0, _ui_utils.getPageSizeInches)(pdfPage), pagesRotation);
  5673. }), _this2._parseLinearization(info.IsLinearized)]);
  5674. }).then(function (_ref3) {
  5675. var _ref4 = _slicedToArray(_ref3, 8),
  5676. info = _ref4[0],
  5677. metadata = _ref4[1],
  5678. fileName = _ref4[2],
  5679. fileSize = _ref4[3],
  5680. creationDate = _ref4[4],
  5681. modDate = _ref4[5],
  5682. pageSize = _ref4[6],
  5683. isLinearized = _ref4[7];
  5684. freezeFieldData({
  5685. fileName: fileName,
  5686. fileSize: fileSize,
  5687. title: info.Title,
  5688. author: info.Author,
  5689. subject: info.Subject,
  5690. keywords: info.Keywords,
  5691. creationDate: creationDate,
  5692. modificationDate: modDate,
  5693. creator: info.Creator,
  5694. producer: info.Producer,
  5695. version: info.PDFFormatVersion,
  5696. pageCount: _this2.pdfDocument.numPages,
  5697. pageSize: pageSize,
  5698. linearized: isLinearized,
  5699. _currentPageNumber: currentPageNumber,
  5700. _pagesRotation: pagesRotation
  5701. });
  5702. _this2._updateUI();
  5703. return _this2.pdfDocument.getDownloadInfo();
  5704. }).then(function (_ref5) {
  5705. var length = _ref5.length;
  5706. _this2.maybeFileSize = length;
  5707. return _this2._parseFileSize(length);
  5708. }).then(function (fileSize) {
  5709. if (fileSize === _this2.fieldData.fileSize) {
  5710. return;
  5711. }
  5712. var data = Object.assign(Object.create(null), _this2.fieldData);
  5713. data.fileSize = fileSize;
  5714. freezeFieldData(data);
  5715. _this2._updateUI();
  5716. });
  5717. });
  5718. }
  5719. }, {
  5720. key: "close",
  5721. value: function close() {
  5722. this.overlayManager.close(this.overlayName);
  5723. }
  5724. }, {
  5725. key: "setDocument",
  5726. value: function setDocument(pdfDocument) {
  5727. var url = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  5728. if (this.pdfDocument) {
  5729. this._reset();
  5730. this._updateUI(true);
  5731. }
  5732. if (!pdfDocument) {
  5733. return;
  5734. }
  5735. this.pdfDocument = pdfDocument;
  5736. this.url = url;
  5737. this._dataAvailableCapability.resolve();
  5738. }
  5739. }, {
  5740. key: "setFileSize",
  5741. value: function setFileSize(fileSize) {
  5742. if (Number.isInteger(fileSize) && fileSize > 0) {
  5743. this.maybeFileSize = fileSize;
  5744. }
  5745. }
  5746. }, {
  5747. key: "_reset",
  5748. value: function _reset() {
  5749. this.pdfDocument = null;
  5750. this.url = null;
  5751. this.maybeFileSize = 0;
  5752. delete this.fieldData;
  5753. this._dataAvailableCapability = (0, _pdfjsLib.createPromiseCapability)();
  5754. this._currentPageNumber = 1;
  5755. this._pagesRotation = 0;
  5756. }
  5757. }, {
  5758. key: "_updateUI",
  5759. value: function _updateUI() {
  5760. var reset = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  5761. if (reset || !this.fieldData) {
  5762. for (var id in this.fields) {
  5763. this.fields[id].textContent = DEFAULT_FIELD_CONTENT;
  5764. }
  5765. return;
  5766. }
  5767. if (this.overlayManager.active !== this.overlayName) {
  5768. return;
  5769. }
  5770. for (var _id in this.fields) {
  5771. var content = this.fieldData[_id];
  5772. this.fields[_id].textContent = content || content === 0 ? content : DEFAULT_FIELD_CONTENT;
  5773. }
  5774. }
  5775. }, {
  5776. key: "_parseFileSize",
  5777. value: function () {
  5778. var _parseFileSize2 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
  5779. var fileSize,
  5780. kb,
  5781. _args = arguments;
  5782. return _regenerator["default"].wrap(function _callee$(_context) {
  5783. while (1) {
  5784. switch (_context.prev = _context.next) {
  5785. case 0:
  5786. fileSize = _args.length > 0 && _args[0] !== undefined ? _args[0] : 0;
  5787. kb = fileSize / 1024;
  5788. if (kb) {
  5789. _context.next = 6;
  5790. break;
  5791. }
  5792. return _context.abrupt("return", undefined);
  5793. case 6:
  5794. if (!(kb < 1024)) {
  5795. _context.next = 8;
  5796. break;
  5797. }
  5798. return _context.abrupt("return", this.l10n.get("document_properties_kb", {
  5799. size_kb: (+kb.toPrecision(3)).toLocaleString(),
  5800. size_b: fileSize.toLocaleString()
  5801. }, "{{size_kb}} KB ({{size_b}} bytes)"));
  5802. case 8:
  5803. return _context.abrupt("return", this.l10n.get("document_properties_mb", {
  5804. size_mb: (+(kb / 1024).toPrecision(3)).toLocaleString(),
  5805. size_b: fileSize.toLocaleString()
  5806. }, "{{size_mb}} MB ({{size_b}} bytes)"));
  5807. case 9:
  5808. case "end":
  5809. return _context.stop();
  5810. }
  5811. }
  5812. }, _callee, this);
  5813. }));
  5814. function _parseFileSize() {
  5815. return _parseFileSize2.apply(this, arguments);
  5816. }
  5817. return _parseFileSize;
  5818. }()
  5819. }, {
  5820. key: "_parsePageSize",
  5821. value: function () {
  5822. var _parsePageSize2 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee2(pageSizeInches, pagesRotation) {
  5823. var _this3 = this;
  5824. var isPortrait, sizeInches, sizeMillimeters, pageName, rawName, exactMillimeters, intMillimeters;
  5825. return _regenerator["default"].wrap(function _callee2$(_context2) {
  5826. while (1) {
  5827. switch (_context2.prev = _context2.next) {
  5828. case 0:
  5829. if (pageSizeInches) {
  5830. _context2.next = 2;
  5831. break;
  5832. }
  5833. return _context2.abrupt("return", undefined);
  5834. case 2:
  5835. if (pagesRotation % 180 !== 0) {
  5836. pageSizeInches = {
  5837. width: pageSizeInches.height,
  5838. height: pageSizeInches.width
  5839. };
  5840. }
  5841. isPortrait = (0, _ui_utils.isPortraitOrientation)(pageSizeInches);
  5842. sizeInches = {
  5843. width: Math.round(pageSizeInches.width * 100) / 100,
  5844. height: Math.round(pageSizeInches.height * 100) / 100
  5845. };
  5846. sizeMillimeters = {
  5847. width: Math.round(pageSizeInches.width * 25.4 * 10) / 10,
  5848. height: Math.round(pageSizeInches.height * 25.4 * 10) / 10
  5849. };
  5850. pageName = null;
  5851. rawName = getPageName(sizeInches, isPortrait, US_PAGE_NAMES) || getPageName(sizeMillimeters, isPortrait, METRIC_PAGE_NAMES);
  5852. if (!rawName && !(Number.isInteger(sizeMillimeters.width) && Number.isInteger(sizeMillimeters.height))) {
  5853. exactMillimeters = {
  5854. width: pageSizeInches.width * 25.4,
  5855. height: pageSizeInches.height * 25.4
  5856. };
  5857. intMillimeters = {
  5858. width: Math.round(sizeMillimeters.width),
  5859. height: Math.round(sizeMillimeters.height)
  5860. };
  5861. if (Math.abs(exactMillimeters.width - intMillimeters.width) < 0.1 && Math.abs(exactMillimeters.height - intMillimeters.height) < 0.1) {
  5862. rawName = getPageName(intMillimeters, isPortrait, METRIC_PAGE_NAMES);
  5863. if (rawName) {
  5864. sizeInches = {
  5865. width: Math.round(intMillimeters.width / 25.4 * 100) / 100,
  5866. height: Math.round(intMillimeters.height / 25.4 * 100) / 100
  5867. };
  5868. sizeMillimeters = intMillimeters;
  5869. }
  5870. }
  5871. }
  5872. if (rawName) {
  5873. pageName = this.l10n.get("document_properties_page_size_name_" + rawName.toLowerCase(), null, rawName);
  5874. }
  5875. return _context2.abrupt("return", Promise.all([this._isNonMetricLocale ? sizeInches : sizeMillimeters, this.l10n.get("document_properties_page_size_unit_" + (this._isNonMetricLocale ? "inches" : "millimeters"), null, this._isNonMetricLocale ? "in" : "mm"), pageName, this.l10n.get("document_properties_page_size_orientation_" + (isPortrait ? "portrait" : "landscape"), null, isPortrait ? "portrait" : "landscape")]).then(function (_ref6) {
  5876. var _ref7 = _slicedToArray(_ref6, 4),
  5877. _ref7$ = _ref7[0],
  5878. width = _ref7$.width,
  5879. height = _ref7$.height,
  5880. unit = _ref7[1],
  5881. name = _ref7[2],
  5882. orientation = _ref7[3];
  5883. return _this3.l10n.get("document_properties_page_size_dimension_" + (name ? "name_" : "") + "string", {
  5884. width: width.toLocaleString(),
  5885. height: height.toLocaleString(),
  5886. unit: unit,
  5887. name: name,
  5888. orientation: orientation
  5889. }, "{{width}} × {{height}} {{unit}} (" + (name ? "{{name}}, " : "") + "{{orientation}})");
  5890. }));
  5891. case 11:
  5892. case "end":
  5893. return _context2.stop();
  5894. }
  5895. }
  5896. }, _callee2, this);
  5897. }));
  5898. function _parsePageSize(_x, _x2) {
  5899. return _parsePageSize2.apply(this, arguments);
  5900. }
  5901. return _parsePageSize;
  5902. }()
  5903. }, {
  5904. key: "_parseDate",
  5905. value: function () {
  5906. var _parseDate2 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee3(inputDate) {
  5907. var dateObject;
  5908. return _regenerator["default"].wrap(function _callee3$(_context3) {
  5909. while (1) {
  5910. switch (_context3.prev = _context3.next) {
  5911. case 0:
  5912. dateObject = _pdfjsLib.PDFDateString.toDateObject(inputDate);
  5913. if (dateObject) {
  5914. _context3.next = 3;
  5915. break;
  5916. }
  5917. return _context3.abrupt("return", undefined);
  5918. case 3:
  5919. return _context3.abrupt("return", this.l10n.get("document_properties_date_string", {
  5920. date: dateObject.toLocaleDateString(),
  5921. time: dateObject.toLocaleTimeString()
  5922. }, "{{date}}, {{time}}"));
  5923. case 4:
  5924. case "end":
  5925. return _context3.stop();
  5926. }
  5927. }
  5928. }, _callee3, this);
  5929. }));
  5930. function _parseDate(_x3) {
  5931. return _parseDate2.apply(this, arguments);
  5932. }
  5933. return _parseDate;
  5934. }()
  5935. }, {
  5936. key: "_parseLinearization",
  5937. value: function _parseLinearization(isLinearized) {
  5938. return this.l10n.get("document_properties_linearized_" + (isLinearized ? "yes" : "no"), null, isLinearized ? "Yes" : "No");
  5939. }
  5940. }]);
  5941. return PDFDocumentProperties;
  5942. }();
  5943. exports.PDFDocumentProperties = PDFDocumentProperties;
  5944. /***/ }),
  5945. /* 18 */
  5946. /***/ (function(module, exports, __webpack_require__) {
  5947. "use strict";
  5948. Object.defineProperty(exports, "__esModule", {
  5949. value: true
  5950. });
  5951. exports.PDFFindBar = void 0;
  5952. var _pdf_find_controller = __webpack_require__(19);
  5953. var _ui_utils = __webpack_require__(5);
  5954. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  5955. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  5956. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  5957. var MATCHES_COUNT_LIMIT = 1000;
  5958. var PDFFindBar = /*#__PURE__*/function () {
  5959. function PDFFindBar(options, eventBus) {
  5960. var _this = this;
  5961. var l10n = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : _ui_utils.NullL10n;
  5962. _classCallCheck(this, PDFFindBar);
  5963. this.opened = false;
  5964. this.bar = options.bar || null;
  5965. this.toggleButton = options.toggleButton || null;
  5966. this.findField = options.findField || null;
  5967. this.highlightAll = options.highlightAllCheckbox || null;
  5968. this.caseSensitive = options.caseSensitiveCheckbox || null;
  5969. this.entireWord = options.entireWordCheckbox || null;
  5970. this.findMsg = options.findMsg || null;
  5971. this.findResultsCount = options.findResultsCount || null;
  5972. this.findPreviousButton = options.findPreviousButton || null;
  5973. this.findNextButton = options.findNextButton || null;
  5974. this.eventBus = eventBus;
  5975. this.l10n = l10n;
  5976. this.toggleButton.addEventListener("click", function () {
  5977. _this.toggle();
  5978. });
  5979. this.findField.addEventListener("input", function () {
  5980. _this.dispatchEvent("");
  5981. });
  5982. this.bar.addEventListener("keydown", function (e) {
  5983. switch (e.keyCode) {
  5984. case 13:
  5985. if (e.target === _this.findField) {
  5986. _this.dispatchEvent("again", e.shiftKey);
  5987. }
  5988. break;
  5989. case 27:
  5990. _this.close();
  5991. break;
  5992. }
  5993. });
  5994. this.findPreviousButton.addEventListener("click", function () {
  5995. _this.dispatchEvent("again", true);
  5996. });
  5997. this.findNextButton.addEventListener("click", function () {
  5998. _this.dispatchEvent("again", false);
  5999. });
  6000. this.highlightAll.addEventListener("click", function () {
  6001. _this.dispatchEvent("highlightallchange");
  6002. });
  6003. this.caseSensitive.addEventListener("click", function () {
  6004. _this.dispatchEvent("casesensitivitychange");
  6005. });
  6006. this.entireWord.addEventListener("click", function () {
  6007. _this.dispatchEvent("entirewordchange");
  6008. });
  6009. this.eventBus._on("resize", this._adjustWidth.bind(this));
  6010. }
  6011. _createClass(PDFFindBar, [{
  6012. key: "reset",
  6013. value: function reset() {
  6014. this.updateUIState();
  6015. }
  6016. }, {
  6017. key: "dispatchEvent",
  6018. value: function dispatchEvent(type, findPrev) {
  6019. this.eventBus.dispatch("find", {
  6020. source: this,
  6021. type: type,
  6022. query: this.findField.value,
  6023. phraseSearch: true,
  6024. caseSensitive: this.caseSensitive.checked,
  6025. entireWord: this.entireWord.checked,
  6026. highlightAll: this.highlightAll.checked,
  6027. findPrevious: findPrev
  6028. });
  6029. }
  6030. }, {
  6031. key: "updateUIState",
  6032. value: function updateUIState(state, previous, matchesCount) {
  6033. var _this2 = this;
  6034. var notFound = false;
  6035. var findMsg = "";
  6036. var status = "";
  6037. switch (state) {
  6038. case _pdf_find_controller.FindState.FOUND:
  6039. break;
  6040. case _pdf_find_controller.FindState.PENDING:
  6041. status = "pending";
  6042. break;
  6043. case _pdf_find_controller.FindState.NOT_FOUND:
  6044. findMsg = this.l10n.get("find_not_found", null, "Phrase not found");
  6045. notFound = true;
  6046. break;
  6047. case _pdf_find_controller.FindState.WRAPPED:
  6048. if (previous) {
  6049. findMsg = this.l10n.get("find_reached_top", null, "Reached top of document, continued from bottom");
  6050. } else {
  6051. findMsg = this.l10n.get("find_reached_bottom", null, "Reached end of document, continued from top");
  6052. }
  6053. break;
  6054. }
  6055. this.findField.classList.toggle("notFound", notFound);
  6056. this.findField.setAttribute("data-status", status);
  6057. Promise.resolve(findMsg).then(function (msg) {
  6058. _this2.findMsg.textContent = msg;
  6059. _this2._adjustWidth();
  6060. });
  6061. this.updateResultsCount(matchesCount);
  6062. }
  6063. }, {
  6064. key: "updateResultsCount",
  6065. value: function updateResultsCount() {
  6066. var _this3 = this;
  6067. var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
  6068. _ref$current = _ref.current,
  6069. current = _ref$current === void 0 ? 0 : _ref$current,
  6070. _ref$total = _ref.total,
  6071. total = _ref$total === void 0 ? 0 : _ref$total;
  6072. if (!this.findResultsCount) {
  6073. return;
  6074. }
  6075. var limit = MATCHES_COUNT_LIMIT;
  6076. var matchesCountMsg = "";
  6077. if (total > 0) {
  6078. if (total > limit) {
  6079. matchesCountMsg = this.l10n.get("find_match_count_limit", {
  6080. limit: limit
  6081. }, "More than {{limit}} match" + (limit !== 1 ? "es" : ""));
  6082. } else {
  6083. matchesCountMsg = this.l10n.get("find_match_count", {
  6084. current: current,
  6085. total: total
  6086. }, "{{current}} of {{total}} match" + (total !== 1 ? "es" : ""));
  6087. }
  6088. }
  6089. Promise.resolve(matchesCountMsg).then(function (msg) {
  6090. _this3.findResultsCount.textContent = msg;
  6091. _this3.findResultsCount.classList.toggle("hidden", !total);
  6092. _this3._adjustWidth();
  6093. });
  6094. }
  6095. }, {
  6096. key: "open",
  6097. value: function open() {
  6098. if (!this.opened) {
  6099. this.opened = true;
  6100. this.toggleButton.classList.add("toggled");
  6101. this.bar.classList.remove("hidden");
  6102. }
  6103. this.findField.select();
  6104. this.findField.focus();
  6105. this._adjustWidth();
  6106. }
  6107. }, {
  6108. key: "close",
  6109. value: function close() {
  6110. if (!this.opened) {
  6111. return;
  6112. }
  6113. this.opened = false;
  6114. this.toggleButton.classList.remove("toggled");
  6115. this.bar.classList.add("hidden");
  6116. this.eventBus.dispatch("findbarclose", {
  6117. source: this
  6118. });
  6119. }
  6120. }, {
  6121. key: "toggle",
  6122. value: function toggle() {
  6123. if (this.opened) {
  6124. this.close();
  6125. } else {
  6126. this.open();
  6127. }
  6128. }
  6129. }, {
  6130. key: "_adjustWidth",
  6131. value: function _adjustWidth() {
  6132. if (!this.opened) {
  6133. return;
  6134. }
  6135. this.bar.classList.remove("wrapContainers");
  6136. var findbarHeight = this.bar.clientHeight;
  6137. var inputContainerHeight = this.bar.firstElementChild.clientHeight;
  6138. if (findbarHeight > inputContainerHeight) {
  6139. this.bar.classList.add("wrapContainers");
  6140. }
  6141. }
  6142. }]);
  6143. return PDFFindBar;
  6144. }();
  6145. exports.PDFFindBar = PDFFindBar;
  6146. /***/ }),
  6147. /* 19 */
  6148. /***/ (function(module, exports, __webpack_require__) {
  6149. "use strict";
  6150. Object.defineProperty(exports, "__esModule", {
  6151. value: true
  6152. });
  6153. exports.PDFFindController = exports.FindState = void 0;
  6154. var _pdfjsLib = __webpack_require__(8);
  6155. var _pdf_find_utils = __webpack_require__(20);
  6156. var _ui_utils = __webpack_require__(5);
  6157. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  6158. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  6159. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  6160. var FindState = {
  6161. FOUND: 0,
  6162. NOT_FOUND: 1,
  6163. WRAPPED: 2,
  6164. PENDING: 3
  6165. };
  6166. exports.FindState = FindState;
  6167. var FIND_TIMEOUT = 250;
  6168. var MATCH_SCROLL_OFFSET_TOP = -50;
  6169. var MATCH_SCROLL_OFFSET_LEFT = -400;
  6170. var CHARACTERS_TO_NORMALIZE = {
  6171. "\u2018": "'",
  6172. "\u2019": "'",
  6173. "\u201A": "'",
  6174. "\u201B": "'",
  6175. "\u201C": '"',
  6176. "\u201D": '"',
  6177. "\u201E": '"',
  6178. "\u201F": '"',
  6179. "\xBC": "1/4",
  6180. "\xBD": "1/2",
  6181. "\xBE": "3/4"
  6182. };
  6183. var normalizationRegex = null;
  6184. function normalize(text) {
  6185. if (!normalizationRegex) {
  6186. var replace = Object.keys(CHARACTERS_TO_NORMALIZE).join("");
  6187. normalizationRegex = new RegExp("[".concat(replace, "]"), "g");
  6188. }
  6189. return text.replace(normalizationRegex, function (ch) {
  6190. return CHARACTERS_TO_NORMALIZE[ch];
  6191. });
  6192. }
  6193. var PDFFindController = /*#__PURE__*/function () {
  6194. function PDFFindController(_ref) {
  6195. var linkService = _ref.linkService,
  6196. eventBus = _ref.eventBus;
  6197. _classCallCheck(this, PDFFindController);
  6198. this._linkService = linkService;
  6199. this._eventBus = eventBus;
  6200. this._reset();
  6201. eventBus._on("findbarclose", this._onFindBarClose.bind(this));
  6202. }
  6203. _createClass(PDFFindController, [{
  6204. key: "setDocument",
  6205. value: function setDocument(pdfDocument) {
  6206. if (this._pdfDocument) {
  6207. this._reset();
  6208. }
  6209. if (!pdfDocument) {
  6210. return;
  6211. }
  6212. this._pdfDocument = pdfDocument;
  6213. this._firstPageCapability.resolve();
  6214. }
  6215. }, {
  6216. key: "executeCommand",
  6217. value: function executeCommand(cmd, state) {
  6218. var _this = this;
  6219. if (!state) {
  6220. return;
  6221. }
  6222. var pdfDocument = this._pdfDocument;
  6223. if (this._state === null || this._shouldDirtyMatch(cmd, state)) {
  6224. this._dirtyMatch = true;
  6225. }
  6226. this._state = state;
  6227. if (cmd !== "findhighlightallchange") {
  6228. this._updateUIState(FindState.PENDING);
  6229. }
  6230. this._firstPageCapability.promise.then(function () {
  6231. if (!_this._pdfDocument || pdfDocument && _this._pdfDocument !== pdfDocument) {
  6232. return;
  6233. }
  6234. _this._extractText();
  6235. var findbarClosed = !_this._highlightMatches;
  6236. var pendingTimeout = !!_this._findTimeout;
  6237. if (_this._findTimeout) {
  6238. clearTimeout(_this._findTimeout);
  6239. _this._findTimeout = null;
  6240. }
  6241. if (cmd === "find") {
  6242. _this._findTimeout = setTimeout(function () {
  6243. _this._nextMatch();
  6244. _this._findTimeout = null;
  6245. }, FIND_TIMEOUT);
  6246. } else if (_this._dirtyMatch) {
  6247. _this._nextMatch();
  6248. } else if (cmd === "findagain") {
  6249. _this._nextMatch();
  6250. if (findbarClosed && _this._state.highlightAll) {
  6251. _this._updateAllPages();
  6252. }
  6253. } else if (cmd === "findhighlightallchange") {
  6254. if (pendingTimeout) {
  6255. _this._nextMatch();
  6256. } else {
  6257. _this._highlightMatches = true;
  6258. }
  6259. _this._updateAllPages();
  6260. } else {
  6261. _this._nextMatch();
  6262. }
  6263. });
  6264. }
  6265. }, {
  6266. key: "scrollMatchIntoView",
  6267. value: function scrollMatchIntoView(_ref2) {
  6268. var _ref2$element = _ref2.element,
  6269. element = _ref2$element === void 0 ? null : _ref2$element,
  6270. _ref2$pageIndex = _ref2.pageIndex,
  6271. pageIndex = _ref2$pageIndex === void 0 ? -1 : _ref2$pageIndex,
  6272. _ref2$matchIndex = _ref2.matchIndex,
  6273. matchIndex = _ref2$matchIndex === void 0 ? -1 : _ref2$matchIndex;
  6274. if (!this._scrollMatches || !element) {
  6275. return;
  6276. } else if (matchIndex === -1 || matchIndex !== this._selected.matchIdx) {
  6277. return;
  6278. } else if (pageIndex === -1 || pageIndex !== this._selected.pageIdx) {
  6279. return;
  6280. }
  6281. this._scrollMatches = false;
  6282. var spot = {
  6283. top: MATCH_SCROLL_OFFSET_TOP,
  6284. left: MATCH_SCROLL_OFFSET_LEFT
  6285. };
  6286. (0, _ui_utils.scrollIntoView)(element, spot, true);
  6287. }
  6288. }, {
  6289. key: "_reset",
  6290. value: function _reset() {
  6291. this._highlightMatches = false;
  6292. this._scrollMatches = false;
  6293. this._pdfDocument = null;
  6294. this._pageMatches = [];
  6295. this._pageMatchesLength = [];
  6296. this._state = null;
  6297. this._selected = {
  6298. pageIdx: -1,
  6299. matchIdx: -1
  6300. };
  6301. this._offset = {
  6302. pageIdx: null,
  6303. matchIdx: null,
  6304. wrapped: false
  6305. };
  6306. this._extractTextPromises = [];
  6307. this._pageContents = [];
  6308. this._matchesCountTotal = 0;
  6309. this._pagesToSearch = null;
  6310. this._pendingFindMatches = Object.create(null);
  6311. this._resumePageIdx = null;
  6312. this._dirtyMatch = false;
  6313. clearTimeout(this._findTimeout);
  6314. this._findTimeout = null;
  6315. this._firstPageCapability = (0, _pdfjsLib.createPromiseCapability)();
  6316. }
  6317. }, {
  6318. key: "_shouldDirtyMatch",
  6319. value: function _shouldDirtyMatch(cmd, state) {
  6320. if (state.query !== this._state.query) {
  6321. return true;
  6322. }
  6323. switch (cmd) {
  6324. case "findagain":
  6325. var pageNumber = this._selected.pageIdx + 1;
  6326. var linkService = this._linkService;
  6327. if (pageNumber >= 1 && pageNumber <= linkService.pagesCount && pageNumber !== linkService.page && !linkService.isPageVisible(pageNumber)) {
  6328. return true;
  6329. }
  6330. return false;
  6331. case "findhighlightallchange":
  6332. return false;
  6333. }
  6334. return true;
  6335. }
  6336. }, {
  6337. key: "_prepareMatches",
  6338. value: function _prepareMatches(matchesWithLength, matches, matchesLength) {
  6339. function isSubTerm(currentIndex) {
  6340. var currentElem = matchesWithLength[currentIndex];
  6341. var nextElem = matchesWithLength[currentIndex + 1];
  6342. if (currentIndex < matchesWithLength.length - 1 && currentElem.match === nextElem.match) {
  6343. currentElem.skipped = true;
  6344. return true;
  6345. }
  6346. for (var i = currentIndex - 1; i >= 0; i--) {
  6347. var prevElem = matchesWithLength[i];
  6348. if (prevElem.skipped) {
  6349. continue;
  6350. }
  6351. if (prevElem.match + prevElem.matchLength < currentElem.match) {
  6352. break;
  6353. }
  6354. if (prevElem.match + prevElem.matchLength >= currentElem.match + currentElem.matchLength) {
  6355. currentElem.skipped = true;
  6356. return true;
  6357. }
  6358. }
  6359. return false;
  6360. }
  6361. matchesWithLength.sort(function (a, b) {
  6362. return a.match === b.match ? a.matchLength - b.matchLength : a.match - b.match;
  6363. });
  6364. for (var i = 0, len = matchesWithLength.length; i < len; i++) {
  6365. if (isSubTerm(i)) {
  6366. continue;
  6367. }
  6368. matches.push(matchesWithLength[i].match);
  6369. matchesLength.push(matchesWithLength[i].matchLength);
  6370. }
  6371. }
  6372. }, {
  6373. key: "_isEntireWord",
  6374. value: function _isEntireWord(content, startIdx, length) {
  6375. if (startIdx > 0) {
  6376. var first = content.charCodeAt(startIdx);
  6377. var limit = content.charCodeAt(startIdx - 1);
  6378. if ((0, _pdf_find_utils.getCharacterType)(first) === (0, _pdf_find_utils.getCharacterType)(limit)) {
  6379. return false;
  6380. }
  6381. }
  6382. var endIdx = startIdx + length - 1;
  6383. if (endIdx < content.length - 1) {
  6384. var last = content.charCodeAt(endIdx);
  6385. var _limit = content.charCodeAt(endIdx + 1);
  6386. if ((0, _pdf_find_utils.getCharacterType)(last) === (0, _pdf_find_utils.getCharacterType)(_limit)) {
  6387. return false;
  6388. }
  6389. }
  6390. return true;
  6391. }
  6392. }, {
  6393. key: "_calculatePhraseMatch",
  6394. value: function _calculatePhraseMatch(query, pageIndex, pageContent, entireWord) {
  6395. var matches = [];
  6396. var queryLen = query.length;
  6397. var matchIdx = -queryLen;
  6398. while (true) {
  6399. matchIdx = pageContent.indexOf(query, matchIdx + queryLen);
  6400. if (matchIdx === -1) {
  6401. break;
  6402. }
  6403. if (entireWord && !this._isEntireWord(pageContent, matchIdx, queryLen)) {
  6404. continue;
  6405. }
  6406. matches.push(matchIdx);
  6407. }
  6408. this._pageMatches[pageIndex] = matches;
  6409. }
  6410. }, {
  6411. key: "_calculateWordMatch",
  6412. value: function _calculateWordMatch(query, pageIndex, pageContent, entireWord) {
  6413. var matchesWithLength = [];
  6414. var queryArray = query.match(/\S+/g);
  6415. for (var i = 0, len = queryArray.length; i < len; i++) {
  6416. var subquery = queryArray[i];
  6417. var subqueryLen = subquery.length;
  6418. var matchIdx = -subqueryLen;
  6419. while (true) {
  6420. matchIdx = pageContent.indexOf(subquery, matchIdx + subqueryLen);
  6421. if (matchIdx === -1) {
  6422. break;
  6423. }
  6424. if (entireWord && !this._isEntireWord(pageContent, matchIdx, subqueryLen)) {
  6425. continue;
  6426. }
  6427. matchesWithLength.push({
  6428. match: matchIdx,
  6429. matchLength: subqueryLen,
  6430. skipped: false
  6431. });
  6432. }
  6433. }
  6434. this._pageMatchesLength[pageIndex] = [];
  6435. this._pageMatches[pageIndex] = [];
  6436. this._prepareMatches(matchesWithLength, this._pageMatches[pageIndex], this._pageMatchesLength[pageIndex]);
  6437. }
  6438. }, {
  6439. key: "_calculateMatch",
  6440. value: function _calculateMatch(pageIndex) {
  6441. var pageContent = this._pageContents[pageIndex];
  6442. var query = this._query;
  6443. var _this$_state = this._state,
  6444. caseSensitive = _this$_state.caseSensitive,
  6445. entireWord = _this$_state.entireWord,
  6446. phraseSearch = _this$_state.phraseSearch;
  6447. if (query.length === 0) {
  6448. return;
  6449. }
  6450. if (!caseSensitive) {
  6451. pageContent = pageContent.toLowerCase();
  6452. query = query.toLowerCase();
  6453. }
  6454. if (phraseSearch) {
  6455. this._calculatePhraseMatch(query, pageIndex, pageContent, entireWord);
  6456. } else {
  6457. this._calculateWordMatch(query, pageIndex, pageContent, entireWord);
  6458. }
  6459. if (this._state.highlightAll) {
  6460. this._updatePage(pageIndex);
  6461. }
  6462. if (this._resumePageIdx === pageIndex) {
  6463. this._resumePageIdx = null;
  6464. this._nextPageMatch();
  6465. }
  6466. var pageMatchesCount = this._pageMatches[pageIndex].length;
  6467. if (pageMatchesCount > 0) {
  6468. this._matchesCountTotal += pageMatchesCount;
  6469. this._updateUIResultsCount();
  6470. }
  6471. }
  6472. }, {
  6473. key: "_extractText",
  6474. value: function _extractText() {
  6475. var _this2 = this;
  6476. if (this._extractTextPromises.length > 0) {
  6477. return;
  6478. }
  6479. var promise = Promise.resolve();
  6480. var _loop = function _loop(i, ii) {
  6481. var extractTextCapability = (0, _pdfjsLib.createPromiseCapability)();
  6482. _this2._extractTextPromises[i] = extractTextCapability.promise;
  6483. promise = promise.then(function () {
  6484. return _this2._pdfDocument.getPage(i + 1).then(function (pdfPage) {
  6485. return pdfPage.getTextContent({
  6486. normalizeWhitespace: true
  6487. });
  6488. }).then(function (textContent) {
  6489. var textItems = textContent.items;
  6490. var strBuf = [];
  6491. for (var j = 0, jj = textItems.length; j < jj; j++) {
  6492. strBuf.push(textItems[j].str);
  6493. }
  6494. _this2._pageContents[i] = normalize(strBuf.join(""));
  6495. extractTextCapability.resolve(i);
  6496. }, function (reason) {
  6497. console.error("Unable to get text content for page ".concat(i + 1), reason);
  6498. _this2._pageContents[i] = "";
  6499. extractTextCapability.resolve(i);
  6500. });
  6501. });
  6502. };
  6503. for (var i = 0, ii = this._linkService.pagesCount; i < ii; i++) {
  6504. _loop(i, ii);
  6505. }
  6506. }
  6507. }, {
  6508. key: "_updatePage",
  6509. value: function _updatePage(index) {
  6510. if (this._scrollMatches && this._selected.pageIdx === index) {
  6511. this._linkService.page = index + 1;
  6512. }
  6513. this._eventBus.dispatch("updatetextlayermatches", {
  6514. source: this,
  6515. pageIndex: index
  6516. });
  6517. }
  6518. }, {
  6519. key: "_updateAllPages",
  6520. value: function _updateAllPages() {
  6521. this._eventBus.dispatch("updatetextlayermatches", {
  6522. source: this,
  6523. pageIndex: -1
  6524. });
  6525. }
  6526. }, {
  6527. key: "_nextMatch",
  6528. value: function _nextMatch() {
  6529. var _this3 = this;
  6530. var previous = this._state.findPrevious;
  6531. var currentPageIndex = this._linkService.page - 1;
  6532. var numPages = this._linkService.pagesCount;
  6533. this._highlightMatches = true;
  6534. if (this._dirtyMatch) {
  6535. this._dirtyMatch = false;
  6536. this._selected.pageIdx = this._selected.matchIdx = -1;
  6537. this._offset.pageIdx = currentPageIndex;
  6538. this._offset.matchIdx = null;
  6539. this._offset.wrapped = false;
  6540. this._resumePageIdx = null;
  6541. this._pageMatches.length = 0;
  6542. this._pageMatchesLength.length = 0;
  6543. this._matchesCountTotal = 0;
  6544. this._updateAllPages();
  6545. for (var i = 0; i < numPages; i++) {
  6546. if (this._pendingFindMatches[i] === true) {
  6547. continue;
  6548. }
  6549. this._pendingFindMatches[i] = true;
  6550. this._extractTextPromises[i].then(function (pageIdx) {
  6551. delete _this3._pendingFindMatches[pageIdx];
  6552. _this3._calculateMatch(pageIdx);
  6553. });
  6554. }
  6555. }
  6556. if (this._query === "") {
  6557. this._updateUIState(FindState.FOUND);
  6558. return;
  6559. }
  6560. if (this._resumePageIdx) {
  6561. return;
  6562. }
  6563. var offset = this._offset;
  6564. this._pagesToSearch = numPages;
  6565. if (offset.matchIdx !== null) {
  6566. var numPageMatches = this._pageMatches[offset.pageIdx].length;
  6567. if (!previous && offset.matchIdx + 1 < numPageMatches || previous && offset.matchIdx > 0) {
  6568. offset.matchIdx = previous ? offset.matchIdx - 1 : offset.matchIdx + 1;
  6569. this._updateMatch(true);
  6570. return;
  6571. }
  6572. this._advanceOffsetPage(previous);
  6573. }
  6574. this._nextPageMatch();
  6575. }
  6576. }, {
  6577. key: "_matchesReady",
  6578. value: function _matchesReady(matches) {
  6579. var offset = this._offset;
  6580. var numMatches = matches.length;
  6581. var previous = this._state.findPrevious;
  6582. if (numMatches) {
  6583. offset.matchIdx = previous ? numMatches - 1 : 0;
  6584. this._updateMatch(true);
  6585. return true;
  6586. }
  6587. this._advanceOffsetPage(previous);
  6588. if (offset.wrapped) {
  6589. offset.matchIdx = null;
  6590. if (this._pagesToSearch < 0) {
  6591. this._updateMatch(false);
  6592. return true;
  6593. }
  6594. }
  6595. return false;
  6596. }
  6597. }, {
  6598. key: "_nextPageMatch",
  6599. value: function _nextPageMatch() {
  6600. if (this._resumePageIdx !== null) {
  6601. console.error("There can only be one pending page.");
  6602. }
  6603. var matches = null;
  6604. do {
  6605. var pageIdx = this._offset.pageIdx;
  6606. matches = this._pageMatches[pageIdx];
  6607. if (!matches) {
  6608. this._resumePageIdx = pageIdx;
  6609. break;
  6610. }
  6611. } while (!this._matchesReady(matches));
  6612. }
  6613. }, {
  6614. key: "_advanceOffsetPage",
  6615. value: function _advanceOffsetPage(previous) {
  6616. var offset = this._offset;
  6617. var numPages = this._linkService.pagesCount;
  6618. offset.pageIdx = previous ? offset.pageIdx - 1 : offset.pageIdx + 1;
  6619. offset.matchIdx = null;
  6620. this._pagesToSearch--;
  6621. if (offset.pageIdx >= numPages || offset.pageIdx < 0) {
  6622. offset.pageIdx = previous ? numPages - 1 : 0;
  6623. offset.wrapped = true;
  6624. }
  6625. }
  6626. }, {
  6627. key: "_updateMatch",
  6628. value: function _updateMatch() {
  6629. var found = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  6630. var state = FindState.NOT_FOUND;
  6631. var wrapped = this._offset.wrapped;
  6632. this._offset.wrapped = false;
  6633. if (found) {
  6634. var previousPage = this._selected.pageIdx;
  6635. this._selected.pageIdx = this._offset.pageIdx;
  6636. this._selected.matchIdx = this._offset.matchIdx;
  6637. state = wrapped ? FindState.WRAPPED : FindState.FOUND;
  6638. if (previousPage !== -1 && previousPage !== this._selected.pageIdx) {
  6639. this._updatePage(previousPage);
  6640. }
  6641. }
  6642. this._updateUIState(state, this._state.findPrevious);
  6643. if (this._selected.pageIdx !== -1) {
  6644. this._scrollMatches = true;
  6645. this._updatePage(this._selected.pageIdx);
  6646. }
  6647. }
  6648. }, {
  6649. key: "_onFindBarClose",
  6650. value: function _onFindBarClose(evt) {
  6651. var _this4 = this;
  6652. var pdfDocument = this._pdfDocument;
  6653. this._firstPageCapability.promise.then(function () {
  6654. if (!_this4._pdfDocument || pdfDocument && _this4._pdfDocument !== pdfDocument) {
  6655. return;
  6656. }
  6657. if (_this4._findTimeout) {
  6658. clearTimeout(_this4._findTimeout);
  6659. _this4._findTimeout = null;
  6660. }
  6661. if (_this4._resumePageIdx) {
  6662. _this4._resumePageIdx = null;
  6663. _this4._dirtyMatch = true;
  6664. }
  6665. _this4._updateUIState(FindState.FOUND);
  6666. _this4._highlightMatches = false;
  6667. _this4._updateAllPages();
  6668. });
  6669. }
  6670. }, {
  6671. key: "_requestMatchesCount",
  6672. value: function _requestMatchesCount() {
  6673. var _this$_selected = this._selected,
  6674. pageIdx = _this$_selected.pageIdx,
  6675. matchIdx = _this$_selected.matchIdx;
  6676. var current = 0,
  6677. total = this._matchesCountTotal;
  6678. if (matchIdx !== -1) {
  6679. for (var i = 0; i < pageIdx; i++) {
  6680. current += this._pageMatches[i] && this._pageMatches[i].length || 0;
  6681. }
  6682. current += matchIdx + 1;
  6683. }
  6684. if (current < 1 || current > total) {
  6685. current = total = 0;
  6686. }
  6687. return {
  6688. current: current,
  6689. total: total
  6690. };
  6691. }
  6692. }, {
  6693. key: "_updateUIResultsCount",
  6694. value: function _updateUIResultsCount() {
  6695. this._eventBus.dispatch("updatefindmatchescount", {
  6696. source: this,
  6697. matchesCount: this._requestMatchesCount()
  6698. });
  6699. }
  6700. }, {
  6701. key: "_updateUIState",
  6702. value: function _updateUIState(state, previous) {
  6703. this._eventBus.dispatch("updatefindcontrolstate", {
  6704. source: this,
  6705. state: state,
  6706. previous: previous,
  6707. matchesCount: this._requestMatchesCount(),
  6708. rawQuery: this._state ? this._state.query : null
  6709. });
  6710. }
  6711. }, {
  6712. key: "highlightMatches",
  6713. get: function get() {
  6714. return this._highlightMatches;
  6715. }
  6716. }, {
  6717. key: "pageMatches",
  6718. get: function get() {
  6719. return this._pageMatches;
  6720. }
  6721. }, {
  6722. key: "pageMatchesLength",
  6723. get: function get() {
  6724. return this._pageMatchesLength;
  6725. }
  6726. }, {
  6727. key: "selected",
  6728. get: function get() {
  6729. return this._selected;
  6730. }
  6731. }, {
  6732. key: "state",
  6733. get: function get() {
  6734. return this._state;
  6735. }
  6736. }, {
  6737. key: "_query",
  6738. get: function get() {
  6739. if (this._state.query !== this._rawQuery) {
  6740. this._rawQuery = this._state.query;
  6741. this._normalizedQuery = normalize(this._state.query);
  6742. }
  6743. return this._normalizedQuery;
  6744. }
  6745. }]);
  6746. return PDFFindController;
  6747. }();
  6748. exports.PDFFindController = PDFFindController;
  6749. /***/ }),
  6750. /* 20 */
  6751. /***/ (function(module, exports, __webpack_require__) {
  6752. "use strict";
  6753. Object.defineProperty(exports, "__esModule", {
  6754. value: true
  6755. });
  6756. exports.getCharacterType = getCharacterType;
  6757. exports.CharacterType = void 0;
  6758. var CharacterType = {
  6759. SPACE: 0,
  6760. ALPHA_LETTER: 1,
  6761. PUNCT: 2,
  6762. HAN_LETTER: 3,
  6763. KATAKANA_LETTER: 4,
  6764. HIRAGANA_LETTER: 5,
  6765. HALFWIDTH_KATAKANA_LETTER: 6,
  6766. THAI_LETTER: 7
  6767. };
  6768. exports.CharacterType = CharacterType;
  6769. function isAlphabeticalScript(charCode) {
  6770. return charCode < 0x2e80;
  6771. }
  6772. function isAscii(charCode) {
  6773. return (charCode & 0xff80) === 0;
  6774. }
  6775. function isAsciiAlpha(charCode) {
  6776. return charCode >= 0x61 && charCode <= 0x7a || charCode >= 0x41 && charCode <= 0x5a;
  6777. }
  6778. function isAsciiDigit(charCode) {
  6779. return charCode >= 0x30 && charCode <= 0x39;
  6780. }
  6781. function isAsciiSpace(charCode) {
  6782. return charCode === 0x20 || charCode === 0x09 || charCode === 0x0d || charCode === 0x0a;
  6783. }
  6784. function isHan(charCode) {
  6785. return charCode >= 0x3400 && charCode <= 0x9fff || charCode >= 0xf900 && charCode <= 0xfaff;
  6786. }
  6787. function isKatakana(charCode) {
  6788. return charCode >= 0x30a0 && charCode <= 0x30ff;
  6789. }
  6790. function isHiragana(charCode) {
  6791. return charCode >= 0x3040 && charCode <= 0x309f;
  6792. }
  6793. function isHalfwidthKatakana(charCode) {
  6794. return charCode >= 0xff60 && charCode <= 0xff9f;
  6795. }
  6796. function isThai(charCode) {
  6797. return (charCode & 0xff80) === 0x0e00;
  6798. }
  6799. function getCharacterType(charCode) {
  6800. if (isAlphabeticalScript(charCode)) {
  6801. if (isAscii(charCode)) {
  6802. if (isAsciiSpace(charCode)) {
  6803. return CharacterType.SPACE;
  6804. } else if (isAsciiAlpha(charCode) || isAsciiDigit(charCode) || charCode === 0x5f) {
  6805. return CharacterType.ALPHA_LETTER;
  6806. }
  6807. return CharacterType.PUNCT;
  6808. } else if (isThai(charCode)) {
  6809. return CharacterType.THAI_LETTER;
  6810. } else if (charCode === 0xa0) {
  6811. return CharacterType.SPACE;
  6812. }
  6813. return CharacterType.ALPHA_LETTER;
  6814. }
  6815. if (isHan(charCode)) {
  6816. return CharacterType.HAN_LETTER;
  6817. } else if (isKatakana(charCode)) {
  6818. return CharacterType.KATAKANA_LETTER;
  6819. } else if (isHiragana(charCode)) {
  6820. return CharacterType.HIRAGANA_LETTER;
  6821. } else if (isHalfwidthKatakana(charCode)) {
  6822. return CharacterType.HALFWIDTH_KATAKANA_LETTER;
  6823. }
  6824. return CharacterType.ALPHA_LETTER;
  6825. }
  6826. /***/ }),
  6827. /* 21 */
  6828. /***/ (function(module, exports, __webpack_require__) {
  6829. "use strict";
  6830. Object.defineProperty(exports, "__esModule", {
  6831. value: true
  6832. });
  6833. exports.isDestHashesEqual = isDestHashesEqual;
  6834. exports.isDestArraysEqual = isDestArraysEqual;
  6835. exports.PDFHistory = void 0;
  6836. var _ui_utils = __webpack_require__(5);
  6837. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  6838. function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
  6839. function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
  6840. function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
  6841. function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
  6842. function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
  6843. function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
  6844. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  6845. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  6846. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  6847. var HASH_CHANGE_TIMEOUT = 1000;
  6848. var POSITION_UPDATED_THRESHOLD = 50;
  6849. var UPDATE_VIEWAREA_TIMEOUT = 1000;
  6850. function getCurrentHash() {
  6851. return document.location.hash;
  6852. }
  6853. var PDFHistory = /*#__PURE__*/function () {
  6854. function PDFHistory(_ref) {
  6855. var _this = this;
  6856. var linkService = _ref.linkService,
  6857. eventBus = _ref.eventBus;
  6858. _classCallCheck(this, PDFHistory);
  6859. this.linkService = linkService;
  6860. this.eventBus = eventBus;
  6861. this._initialized = false;
  6862. this._fingerprint = "";
  6863. this.reset();
  6864. this._boundEvents = null;
  6865. this._isViewerInPresentationMode = false;
  6866. this.eventBus._on("presentationmodechanged", function (evt) {
  6867. _this._isViewerInPresentationMode = evt.active || evt.switchInProgress;
  6868. });
  6869. this.eventBus._on("pagesinit", function () {
  6870. _this._isPagesLoaded = false;
  6871. var onPagesLoaded = function onPagesLoaded(evt) {
  6872. _this.eventBus._off("pagesloaded", onPagesLoaded);
  6873. _this._isPagesLoaded = !!evt.pagesCount;
  6874. };
  6875. _this.eventBus._on("pagesloaded", onPagesLoaded);
  6876. });
  6877. }
  6878. _createClass(PDFHistory, [{
  6879. key: "initialize",
  6880. value: function initialize(_ref2) {
  6881. var fingerprint = _ref2.fingerprint,
  6882. _ref2$resetHistory = _ref2.resetHistory,
  6883. resetHistory = _ref2$resetHistory === void 0 ? false : _ref2$resetHistory,
  6884. _ref2$updateUrl = _ref2.updateUrl,
  6885. updateUrl = _ref2$updateUrl === void 0 ? false : _ref2$updateUrl;
  6886. if (!fingerprint || typeof fingerprint !== "string") {
  6887. console.error('PDFHistory.initialize: The "fingerprint" must be a non-empty string.');
  6888. return;
  6889. }
  6890. if (this._initialized) {
  6891. this.reset();
  6892. }
  6893. var reInitialized = this._fingerprint !== "" && this._fingerprint !== fingerprint;
  6894. this._fingerprint = fingerprint;
  6895. this._updateUrl = updateUrl === true;
  6896. this._initialized = true;
  6897. this._bindEvents();
  6898. var state = window.history.state;
  6899. this._popStateInProgress = false;
  6900. this._blockHashChange = 0;
  6901. this._currentHash = getCurrentHash();
  6902. this._numPositionUpdates = 0;
  6903. this._uid = this._maxUid = 0;
  6904. this._destination = null;
  6905. this._position = null;
  6906. if (!this._isValidState(state, true) || resetHistory) {
  6907. var _this$_parseCurrentHa = this._parseCurrentHash(true),
  6908. hash = _this$_parseCurrentHa.hash,
  6909. page = _this$_parseCurrentHa.page,
  6910. rotation = _this$_parseCurrentHa.rotation;
  6911. if (!hash || reInitialized || resetHistory) {
  6912. this._pushOrReplaceState(null, true);
  6913. return;
  6914. }
  6915. this._pushOrReplaceState({
  6916. hash: hash,
  6917. page: page,
  6918. rotation: rotation
  6919. }, true);
  6920. return;
  6921. }
  6922. var destination = state.destination;
  6923. this._updateInternalState(destination, state.uid, true);
  6924. if (this._uid > this._maxUid) {
  6925. this._maxUid = this._uid;
  6926. }
  6927. if (destination.rotation !== undefined) {
  6928. this._initialRotation = destination.rotation;
  6929. }
  6930. if (destination.dest) {
  6931. this._initialBookmark = JSON.stringify(destination.dest);
  6932. this._destination.page = null;
  6933. } else if (destination.hash) {
  6934. this._initialBookmark = destination.hash;
  6935. } else if (destination.page) {
  6936. this._initialBookmark = "page=".concat(destination.page);
  6937. }
  6938. }
  6939. }, {
  6940. key: "reset",
  6941. value: function reset() {
  6942. if (this._initialized) {
  6943. this._pageHide();
  6944. this._initialized = false;
  6945. this._unbindEvents();
  6946. }
  6947. if (this._updateViewareaTimeout) {
  6948. clearTimeout(this._updateViewareaTimeout);
  6949. this._updateViewareaTimeout = null;
  6950. }
  6951. this._initialBookmark = null;
  6952. this._initialRotation = null;
  6953. }
  6954. }, {
  6955. key: "push",
  6956. value: function push(_ref3) {
  6957. var _this2 = this;
  6958. var _ref3$namedDest = _ref3.namedDest,
  6959. namedDest = _ref3$namedDest === void 0 ? null : _ref3$namedDest,
  6960. explicitDest = _ref3.explicitDest,
  6961. pageNumber = _ref3.pageNumber;
  6962. if (!this._initialized) {
  6963. return;
  6964. }
  6965. if (namedDest && typeof namedDest !== "string") {
  6966. console.error("PDFHistory.push: " + "\"".concat(namedDest, "\" is not a valid namedDest parameter."));
  6967. return;
  6968. } else if (!Array.isArray(explicitDest)) {
  6969. console.error("PDFHistory.push: " + "\"".concat(explicitDest, "\" is not a valid explicitDest parameter."));
  6970. return;
  6971. } else if (!(Number.isInteger(pageNumber) && pageNumber > 0 && pageNumber <= this.linkService.pagesCount)) {
  6972. if (pageNumber !== null || this._destination) {
  6973. console.error("PDFHistory.push: " + "\"".concat(pageNumber, "\" is not a valid pageNumber parameter."));
  6974. return;
  6975. }
  6976. }
  6977. var hash = namedDest || JSON.stringify(explicitDest);
  6978. if (!hash) {
  6979. return;
  6980. }
  6981. var forceReplace = false;
  6982. if (this._destination && (isDestHashesEqual(this._destination.hash, hash) || isDestArraysEqual(this._destination.dest, explicitDest))) {
  6983. if (this._destination.page) {
  6984. return;
  6985. }
  6986. forceReplace = true;
  6987. }
  6988. if (this._popStateInProgress && !forceReplace) {
  6989. return;
  6990. }
  6991. this._pushOrReplaceState({
  6992. dest: explicitDest,
  6993. hash: hash,
  6994. page: pageNumber,
  6995. rotation: this.linkService.rotation
  6996. }, forceReplace);
  6997. if (!this._popStateInProgress) {
  6998. this._popStateInProgress = true;
  6999. Promise.resolve().then(function () {
  7000. _this2._popStateInProgress = false;
  7001. });
  7002. }
  7003. }
  7004. }, {
  7005. key: "pushCurrentPosition",
  7006. value: function pushCurrentPosition() {
  7007. if (!this._initialized || this._popStateInProgress) {
  7008. return;
  7009. }
  7010. this._tryPushCurrentPosition();
  7011. }
  7012. }, {
  7013. key: "back",
  7014. value: function back() {
  7015. if (!this._initialized || this._popStateInProgress) {
  7016. return;
  7017. }
  7018. var state = window.history.state;
  7019. if (this._isValidState(state) && state.uid > 0) {
  7020. window.history.back();
  7021. }
  7022. }
  7023. }, {
  7024. key: "forward",
  7025. value: function forward() {
  7026. if (!this._initialized || this._popStateInProgress) {
  7027. return;
  7028. }
  7029. var state = window.history.state;
  7030. if (this._isValidState(state) && state.uid < this._maxUid) {
  7031. window.history.forward();
  7032. }
  7033. }
  7034. }, {
  7035. key: "_pushOrReplaceState",
  7036. value: function _pushOrReplaceState(destination) {
  7037. var forceReplace = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  7038. var shouldReplace = forceReplace || !this._destination;
  7039. var newState = {
  7040. fingerprint: this._fingerprint,
  7041. uid: shouldReplace ? this._uid : this._uid + 1,
  7042. destination: destination
  7043. };
  7044. this._updateInternalState(destination, newState.uid);
  7045. var newUrl;
  7046. if (this._updateUrl && destination && destination.hash) {
  7047. var baseUrl = document.location.href.split("#")[0];
  7048. if (!baseUrl.startsWith("file://")) {
  7049. newUrl = "".concat(baseUrl, "#").concat(destination.hash);
  7050. }
  7051. }
  7052. if (shouldReplace) {
  7053. window.history.replaceState(newState, "", newUrl);
  7054. } else {
  7055. this._maxUid = this._uid;
  7056. window.history.pushState(newState, "", newUrl);
  7057. }
  7058. }
  7059. }, {
  7060. key: "_tryPushCurrentPosition",
  7061. value: function _tryPushCurrentPosition() {
  7062. var temporary = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  7063. if (!this._position) {
  7064. return;
  7065. }
  7066. var position = this._position;
  7067. if (temporary) {
  7068. position = Object.assign(Object.create(null), this._position);
  7069. position.temporary = true;
  7070. }
  7071. if (!this._destination) {
  7072. this._pushOrReplaceState(position);
  7073. return;
  7074. }
  7075. if (this._destination.temporary) {
  7076. this._pushOrReplaceState(position, true);
  7077. return;
  7078. }
  7079. if (this._destination.hash === position.hash) {
  7080. return;
  7081. }
  7082. if (!this._destination.page && (POSITION_UPDATED_THRESHOLD <= 0 || this._numPositionUpdates <= POSITION_UPDATED_THRESHOLD)) {
  7083. return;
  7084. }
  7085. var forceReplace = false;
  7086. if (this._destination.page >= position.first && this._destination.page <= position.page) {
  7087. if (this._destination.dest || !this._destination.first) {
  7088. return;
  7089. }
  7090. forceReplace = true;
  7091. }
  7092. this._pushOrReplaceState(position, forceReplace);
  7093. }
  7094. }, {
  7095. key: "_isValidState",
  7096. value: function _isValidState(state) {
  7097. var checkReload = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  7098. if (!state) {
  7099. return false;
  7100. }
  7101. if (state.fingerprint !== this._fingerprint) {
  7102. if (checkReload) {
  7103. if (typeof state.fingerprint !== "string" || state.fingerprint.length !== this._fingerprint.length) {
  7104. return false;
  7105. }
  7106. var _performance$getEntri = performance.getEntriesByType("navigation"),
  7107. _performance$getEntri2 = _slicedToArray(_performance$getEntri, 1),
  7108. perfEntry = _performance$getEntri2[0];
  7109. if (!perfEntry || perfEntry.type !== "reload") {
  7110. return false;
  7111. }
  7112. } else {
  7113. return false;
  7114. }
  7115. }
  7116. if (!Number.isInteger(state.uid) || state.uid < 0) {
  7117. return false;
  7118. }
  7119. if (state.destination === null || _typeof(state.destination) !== "object") {
  7120. return false;
  7121. }
  7122. return true;
  7123. }
  7124. }, {
  7125. key: "_updateInternalState",
  7126. value: function _updateInternalState(destination, uid) {
  7127. var removeTemporary = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  7128. if (this._updateViewareaTimeout) {
  7129. clearTimeout(this._updateViewareaTimeout);
  7130. this._updateViewareaTimeout = null;
  7131. }
  7132. if (removeTemporary && destination && destination.temporary) {
  7133. delete destination.temporary;
  7134. }
  7135. this._destination = destination;
  7136. this._uid = uid;
  7137. this._numPositionUpdates = 0;
  7138. }
  7139. }, {
  7140. key: "_parseCurrentHash",
  7141. value: function _parseCurrentHash() {
  7142. var checkNameddest = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  7143. var hash = unescape(getCurrentHash()).substring(1);
  7144. var params = (0, _ui_utils.parseQueryString)(hash);
  7145. var nameddest = params.nameddest || "";
  7146. var page = params.page | 0;
  7147. if (!(Number.isInteger(page) && page > 0 && page <= this.linkService.pagesCount) || checkNameddest && nameddest.length > 0) {
  7148. page = null;
  7149. }
  7150. return {
  7151. hash: hash,
  7152. page: page,
  7153. rotation: this.linkService.rotation
  7154. };
  7155. }
  7156. }, {
  7157. key: "_updateViewarea",
  7158. value: function _updateViewarea(_ref4) {
  7159. var _this3 = this;
  7160. var location = _ref4.location;
  7161. if (this._updateViewareaTimeout) {
  7162. clearTimeout(this._updateViewareaTimeout);
  7163. this._updateViewareaTimeout = null;
  7164. }
  7165. this._position = {
  7166. hash: this._isViewerInPresentationMode ? "page=".concat(location.pageNumber) : location.pdfOpenParams.substring(1),
  7167. page: this.linkService.page,
  7168. first: location.pageNumber,
  7169. rotation: location.rotation
  7170. };
  7171. if (this._popStateInProgress) {
  7172. return;
  7173. }
  7174. if (POSITION_UPDATED_THRESHOLD > 0 && this._isPagesLoaded && this._destination && !this._destination.page) {
  7175. this._numPositionUpdates++;
  7176. }
  7177. if (UPDATE_VIEWAREA_TIMEOUT > 0) {
  7178. this._updateViewareaTimeout = setTimeout(function () {
  7179. if (!_this3._popStateInProgress) {
  7180. _this3._tryPushCurrentPosition(true);
  7181. }
  7182. _this3._updateViewareaTimeout = null;
  7183. }, UPDATE_VIEWAREA_TIMEOUT);
  7184. }
  7185. }
  7186. }, {
  7187. key: "_popState",
  7188. value: function _popState(_ref5) {
  7189. var _this4 = this;
  7190. var state = _ref5.state;
  7191. var newHash = getCurrentHash(),
  7192. hashChanged = this._currentHash !== newHash;
  7193. this._currentHash = newHash;
  7194. if (!state) {
  7195. this._uid++;
  7196. var _this$_parseCurrentHa2 = this._parseCurrentHash(),
  7197. hash = _this$_parseCurrentHa2.hash,
  7198. page = _this$_parseCurrentHa2.page,
  7199. rotation = _this$_parseCurrentHa2.rotation;
  7200. this._pushOrReplaceState({
  7201. hash: hash,
  7202. page: page,
  7203. rotation: rotation
  7204. }, true);
  7205. return;
  7206. }
  7207. if (!this._isValidState(state)) {
  7208. return;
  7209. }
  7210. this._popStateInProgress = true;
  7211. if (hashChanged) {
  7212. this._blockHashChange++;
  7213. (0, _ui_utils.waitOnEventOrTimeout)({
  7214. target: window,
  7215. name: "hashchange",
  7216. delay: HASH_CHANGE_TIMEOUT
  7217. }).then(function () {
  7218. _this4._blockHashChange--;
  7219. });
  7220. }
  7221. var destination = state.destination;
  7222. this._updateInternalState(destination, state.uid, true);
  7223. if (this._uid > this._maxUid) {
  7224. this._maxUid = this._uid;
  7225. }
  7226. if ((0, _ui_utils.isValidRotation)(destination.rotation)) {
  7227. this.linkService.rotation = destination.rotation;
  7228. }
  7229. if (destination.dest) {
  7230. this.linkService.navigateTo(destination.dest);
  7231. } else if (destination.hash) {
  7232. this.linkService.setHash(destination.hash);
  7233. } else if (destination.page) {
  7234. this.linkService.page = destination.page;
  7235. }
  7236. Promise.resolve().then(function () {
  7237. _this4._popStateInProgress = false;
  7238. });
  7239. }
  7240. }, {
  7241. key: "_pageHide",
  7242. value: function _pageHide() {
  7243. if (!this._destination || this._destination.temporary) {
  7244. this._tryPushCurrentPosition();
  7245. }
  7246. }
  7247. }, {
  7248. key: "_bindEvents",
  7249. value: function _bindEvents() {
  7250. if (this._boundEvents) {
  7251. return;
  7252. }
  7253. this._boundEvents = {
  7254. updateViewarea: this._updateViewarea.bind(this),
  7255. popState: this._popState.bind(this),
  7256. pageHide: this._pageHide.bind(this)
  7257. };
  7258. this.eventBus._on("updateviewarea", this._boundEvents.updateViewarea);
  7259. window.addEventListener("popstate", this._boundEvents.popState);
  7260. window.addEventListener("pagehide", this._boundEvents.pageHide);
  7261. }
  7262. }, {
  7263. key: "_unbindEvents",
  7264. value: function _unbindEvents() {
  7265. if (!this._boundEvents) {
  7266. return;
  7267. }
  7268. this.eventBus._off("updateviewarea", this._boundEvents.updateViewarea);
  7269. window.removeEventListener("popstate", this._boundEvents.popState);
  7270. window.removeEventListener("pagehide", this._boundEvents.pageHide);
  7271. this._boundEvents = null;
  7272. }
  7273. }, {
  7274. key: "popStateInProgress",
  7275. get: function get() {
  7276. return this._initialized && (this._popStateInProgress || this._blockHashChange > 0);
  7277. }
  7278. }, {
  7279. key: "initialBookmark",
  7280. get: function get() {
  7281. return this._initialized ? this._initialBookmark : null;
  7282. }
  7283. }, {
  7284. key: "initialRotation",
  7285. get: function get() {
  7286. return this._initialized ? this._initialRotation : null;
  7287. }
  7288. }]);
  7289. return PDFHistory;
  7290. }();
  7291. exports.PDFHistory = PDFHistory;
  7292. function isDestHashesEqual(destHash, pushHash) {
  7293. if (typeof destHash !== "string" || typeof pushHash !== "string") {
  7294. return false;
  7295. }
  7296. if (destHash === pushHash) {
  7297. return true;
  7298. }
  7299. var _parseQueryString = (0, _ui_utils.parseQueryString)(destHash),
  7300. nameddest = _parseQueryString.nameddest;
  7301. if (nameddest === pushHash) {
  7302. return true;
  7303. }
  7304. return false;
  7305. }
  7306. function isDestArraysEqual(firstDest, secondDest) {
  7307. function isEntryEqual(first, second) {
  7308. if (_typeof(first) !== _typeof(second)) {
  7309. return false;
  7310. }
  7311. if (Array.isArray(first) || Array.isArray(second)) {
  7312. return false;
  7313. }
  7314. if (first !== null && _typeof(first) === "object" && second !== null) {
  7315. if (Object.keys(first).length !== Object.keys(second).length) {
  7316. return false;
  7317. }
  7318. for (var key in first) {
  7319. if (!isEntryEqual(first[key], second[key])) {
  7320. return false;
  7321. }
  7322. }
  7323. return true;
  7324. }
  7325. return first === second || Number.isNaN(first) && Number.isNaN(second);
  7326. }
  7327. if (!(Array.isArray(firstDest) && Array.isArray(secondDest))) {
  7328. return false;
  7329. }
  7330. if (firstDest.length !== secondDest.length) {
  7331. return false;
  7332. }
  7333. for (var i = 0, ii = firstDest.length; i < ii; i++) {
  7334. if (!isEntryEqual(firstDest[i], secondDest[i])) {
  7335. return false;
  7336. }
  7337. }
  7338. return true;
  7339. }
  7340. /***/ }),
  7341. /* 22 */
  7342. /***/ (function(module, exports, __webpack_require__) {
  7343. "use strict";
  7344. Object.defineProperty(exports, "__esModule", {
  7345. value: true
  7346. });
  7347. exports.PDFLayerViewer = void 0;
  7348. var _regenerator = _interopRequireDefault(__webpack_require__(2));
  7349. var _base_tree_viewer = __webpack_require__(16);
  7350. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  7351. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  7352. function _createForOfIteratorHelper(o, allowArrayLike) { var it; if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = o[Symbol.iterator](); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
  7353. function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
  7354. function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
  7355. function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
  7356. function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
  7357. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  7358. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  7359. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  7360. function _get(target, property, receiver) { if (typeof Reflect !== "undefined" && Reflect.get) { _get = Reflect.get; } else { _get = function _get(target, property, receiver) { var base = _superPropBase(target, property); if (!base) return; var desc = Object.getOwnPropertyDescriptor(base, property); if (desc.get) { return desc.get.call(receiver); } return desc.value; }; } return _get(target, property, receiver || target); }
  7361. function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
  7362. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  7363. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  7364. function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  7365. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  7366. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  7367. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
  7368. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  7369. var PDFLayerViewer = /*#__PURE__*/function (_BaseTreeViewer) {
  7370. _inherits(PDFLayerViewer, _BaseTreeViewer);
  7371. var _super = _createSuper(PDFLayerViewer);
  7372. function PDFLayerViewer(options) {
  7373. var _this;
  7374. _classCallCheck(this, PDFLayerViewer);
  7375. _this = _super.call(this, options);
  7376. _this.l10n = options.l10n;
  7377. _this.eventBus._on("resetlayers", _this._resetLayers.bind(_assertThisInitialized(_this)));
  7378. _this.eventBus._on("togglelayerstree", _this._toggleAllTreeItems.bind(_assertThisInitialized(_this)));
  7379. return _this;
  7380. }
  7381. _createClass(PDFLayerViewer, [{
  7382. key: "reset",
  7383. value: function reset() {
  7384. _get(_getPrototypeOf(PDFLayerViewer.prototype), "reset", this).call(this);
  7385. this._optionalContentConfig = null;
  7386. this._pdfDocument = null;
  7387. }
  7388. }, {
  7389. key: "_dispatchEvent",
  7390. value: function _dispatchEvent(layersCount) {
  7391. this.eventBus.dispatch("layersloaded", {
  7392. source: this,
  7393. layersCount: layersCount
  7394. });
  7395. }
  7396. }, {
  7397. key: "_bindLink",
  7398. value: function _bindLink(element, _ref) {
  7399. var _this2 = this;
  7400. var groupId = _ref.groupId,
  7401. input = _ref.input;
  7402. var setVisibility = function setVisibility() {
  7403. _this2._optionalContentConfig.setVisibility(groupId, input.checked);
  7404. _this2.eventBus.dispatch("optionalcontentconfig", {
  7405. source: _this2,
  7406. promise: Promise.resolve(_this2._optionalContentConfig)
  7407. });
  7408. };
  7409. element.onclick = function (evt) {
  7410. if (evt.target === input) {
  7411. setVisibility();
  7412. return true;
  7413. } else if (evt.target !== element) {
  7414. return true;
  7415. }
  7416. input.checked = !input.checked;
  7417. setVisibility();
  7418. return false;
  7419. };
  7420. }
  7421. }, {
  7422. key: "_setNestedName",
  7423. value: function () {
  7424. var _setNestedName2 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee(element, _ref2) {
  7425. var _ref2$name, name;
  7426. return _regenerator["default"].wrap(function _callee$(_context) {
  7427. while (1) {
  7428. switch (_context.prev = _context.next) {
  7429. case 0:
  7430. _ref2$name = _ref2.name, name = _ref2$name === void 0 ? null : _ref2$name;
  7431. if (!(typeof name === "string")) {
  7432. _context.next = 4;
  7433. break;
  7434. }
  7435. element.textContent = this._normalizeTextContent(name);
  7436. return _context.abrupt("return");
  7437. case 4:
  7438. _context.next = 6;
  7439. return this.l10n.get("additional_layers", null, "Additional Layers");
  7440. case 6:
  7441. element.textContent = _context.sent;
  7442. element.style.fontStyle = "italic";
  7443. case 8:
  7444. case "end":
  7445. return _context.stop();
  7446. }
  7447. }
  7448. }, _callee, this);
  7449. }));
  7450. function _setNestedName(_x, _x2) {
  7451. return _setNestedName2.apply(this, arguments);
  7452. }
  7453. return _setNestedName;
  7454. }()
  7455. }, {
  7456. key: "_addToggleButton",
  7457. value: function _addToggleButton(div, _ref3) {
  7458. var _ref3$name = _ref3.name,
  7459. name = _ref3$name === void 0 ? null : _ref3$name;
  7460. _get(_getPrototypeOf(PDFLayerViewer.prototype), "_addToggleButton", this).call(this, div, name === null);
  7461. }
  7462. }, {
  7463. key: "_toggleAllTreeItems",
  7464. value: function _toggleAllTreeItems() {
  7465. if (!this._optionalContentConfig) {
  7466. return;
  7467. }
  7468. _get(_getPrototypeOf(PDFLayerViewer.prototype), "_toggleAllTreeItems", this).call(this);
  7469. }
  7470. }, {
  7471. key: "render",
  7472. value: function render(_ref4) {
  7473. var optionalContentConfig = _ref4.optionalContentConfig,
  7474. pdfDocument = _ref4.pdfDocument;
  7475. if (this._optionalContentConfig) {
  7476. this.reset();
  7477. }
  7478. this._optionalContentConfig = optionalContentConfig || null;
  7479. this._pdfDocument = pdfDocument || null;
  7480. var groups = optionalContentConfig && optionalContentConfig.getOrder();
  7481. if (!groups) {
  7482. this._dispatchEvent(0);
  7483. return;
  7484. }
  7485. var fragment = document.createDocumentFragment(),
  7486. queue = [{
  7487. parent: fragment,
  7488. groups: groups
  7489. }];
  7490. var layersCount = 0,
  7491. hasAnyNesting = false;
  7492. while (queue.length > 0) {
  7493. var levelData = queue.shift();
  7494. var _iterator = _createForOfIteratorHelper(levelData.groups),
  7495. _step;
  7496. try {
  7497. for (_iterator.s(); !(_step = _iterator.n()).done;) {
  7498. var groupId = _step.value;
  7499. var div = document.createElement("div");
  7500. div.className = "treeItem";
  7501. var element = document.createElement("a");
  7502. div.appendChild(element);
  7503. if (_typeof(groupId) === "object") {
  7504. hasAnyNesting = true;
  7505. this._addToggleButton(div, groupId);
  7506. this._setNestedName(element, groupId);
  7507. var itemsDiv = document.createElement("div");
  7508. itemsDiv.className = "treeItems";
  7509. div.appendChild(itemsDiv);
  7510. queue.push({
  7511. parent: itemsDiv,
  7512. groups: groupId.order
  7513. });
  7514. } else {
  7515. var group = optionalContentConfig.getGroup(groupId);
  7516. var input = document.createElement("input");
  7517. this._bindLink(element, {
  7518. groupId: groupId,
  7519. input: input
  7520. });
  7521. input.type = "checkbox";
  7522. input.id = groupId;
  7523. input.checked = group.visible;
  7524. var label = document.createElement("label");
  7525. label.setAttribute("for", groupId);
  7526. label.textContent = this._normalizeTextContent(group.name);
  7527. element.appendChild(input);
  7528. element.appendChild(label);
  7529. layersCount++;
  7530. }
  7531. levelData.parent.appendChild(div);
  7532. }
  7533. } catch (err) {
  7534. _iterator.e(err);
  7535. } finally {
  7536. _iterator.f();
  7537. }
  7538. }
  7539. if (hasAnyNesting) {
  7540. this.container.classList.add("treeWithDeepNesting");
  7541. this._lastToggleIsShow = fragment.querySelectorAll(".treeItemsHidden").length === 0;
  7542. }
  7543. this.container.appendChild(fragment);
  7544. this._dispatchEvent(layersCount);
  7545. }
  7546. }, {
  7547. key: "_resetLayers",
  7548. value: function () {
  7549. var _resetLayers2 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee2() {
  7550. var optionalContentConfig;
  7551. return _regenerator["default"].wrap(function _callee2$(_context2) {
  7552. while (1) {
  7553. switch (_context2.prev = _context2.next) {
  7554. case 0:
  7555. if (this._optionalContentConfig) {
  7556. _context2.next = 2;
  7557. break;
  7558. }
  7559. return _context2.abrupt("return");
  7560. case 2:
  7561. _context2.next = 4;
  7562. return this._pdfDocument.getOptionalContentConfig();
  7563. case 4:
  7564. optionalContentConfig = _context2.sent;
  7565. this.eventBus.dispatch("optionalcontentconfig", {
  7566. source: this,
  7567. promise: Promise.resolve(optionalContentConfig)
  7568. });
  7569. this.render({
  7570. optionalContentConfig: optionalContentConfig,
  7571. pdfDocument: this._pdfDocument
  7572. });
  7573. case 7:
  7574. case "end":
  7575. return _context2.stop();
  7576. }
  7577. }
  7578. }, _callee2, this);
  7579. }));
  7580. function _resetLayers() {
  7581. return _resetLayers2.apply(this, arguments);
  7582. }
  7583. return _resetLayers;
  7584. }()
  7585. }]);
  7586. return PDFLayerViewer;
  7587. }(_base_tree_viewer.BaseTreeViewer);
  7588. exports.PDFLayerViewer = PDFLayerViewer;
  7589. /***/ }),
  7590. /* 23 */
  7591. /***/ (function(module, exports, __webpack_require__) {
  7592. "use strict";
  7593. Object.defineProperty(exports, "__esModule", {
  7594. value: true
  7595. });
  7596. exports.SimpleLinkService = exports.PDFLinkService = void 0;
  7597. var _ui_utils = __webpack_require__(5);
  7598. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  7599. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  7600. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  7601. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  7602. var PDFLinkService = /*#__PURE__*/function () {
  7603. function PDFLinkService() {
  7604. var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
  7605. eventBus = _ref.eventBus,
  7606. _ref$externalLinkTarg = _ref.externalLinkTarget,
  7607. externalLinkTarget = _ref$externalLinkTarg === void 0 ? null : _ref$externalLinkTarg,
  7608. _ref$externalLinkRel = _ref.externalLinkRel,
  7609. externalLinkRel = _ref$externalLinkRel === void 0 ? null : _ref$externalLinkRel,
  7610. _ref$externalLinkEnab = _ref.externalLinkEnabled,
  7611. externalLinkEnabled = _ref$externalLinkEnab === void 0 ? true : _ref$externalLinkEnab,
  7612. _ref$ignoreDestinatio = _ref.ignoreDestinationZoom,
  7613. ignoreDestinationZoom = _ref$ignoreDestinatio === void 0 ? false : _ref$ignoreDestinatio;
  7614. _classCallCheck(this, PDFLinkService);
  7615. this.eventBus = eventBus;
  7616. this.externalLinkTarget = externalLinkTarget;
  7617. this.externalLinkRel = externalLinkRel;
  7618. this.externalLinkEnabled = externalLinkEnabled;
  7619. this._ignoreDestinationZoom = ignoreDestinationZoom;
  7620. this.baseUrl = null;
  7621. this.pdfDocument = null;
  7622. this.pdfViewer = null;
  7623. this.pdfHistory = null;
  7624. this._pagesRefCache = null;
  7625. }
  7626. _createClass(PDFLinkService, [{
  7627. key: "setDocument",
  7628. value: function setDocument(pdfDocument) {
  7629. var baseUrl = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  7630. this.baseUrl = baseUrl;
  7631. this.pdfDocument = pdfDocument;
  7632. this._pagesRefCache = Object.create(null);
  7633. }
  7634. }, {
  7635. key: "setViewer",
  7636. value: function setViewer(pdfViewer) {
  7637. this.pdfViewer = pdfViewer;
  7638. }
  7639. }, {
  7640. key: "setHistory",
  7641. value: function setHistory(pdfHistory) {
  7642. this.pdfHistory = pdfHistory;
  7643. }
  7644. }, {
  7645. key: "navigateTo",
  7646. value: function navigateTo(dest) {
  7647. var _this = this;
  7648. var goToDestination = function goToDestination(_ref2) {
  7649. var namedDest = _ref2.namedDest,
  7650. explicitDest = _ref2.explicitDest;
  7651. var destRef = explicitDest[0];
  7652. var pageNumber;
  7653. if (destRef instanceof Object) {
  7654. pageNumber = _this._cachedPageNumber(destRef);
  7655. if (pageNumber === null) {
  7656. _this.pdfDocument.getPageIndex(destRef).then(function (pageIndex) {
  7657. _this.cachePageRef(pageIndex + 1, destRef);
  7658. goToDestination({
  7659. namedDest: namedDest,
  7660. explicitDest: explicitDest
  7661. });
  7662. })["catch"](function () {
  7663. console.error("PDFLinkService.navigateTo: \"".concat(destRef, "\" is not ") + "a valid page reference, for dest=\"".concat(dest, "\"."));
  7664. });
  7665. return;
  7666. }
  7667. } else if (Number.isInteger(destRef)) {
  7668. pageNumber = destRef + 1;
  7669. } else {
  7670. console.error("PDFLinkService.navigateTo: \"".concat(destRef, "\" is not ") + "a valid destination reference, for dest=\"".concat(dest, "\"."));
  7671. return;
  7672. }
  7673. if (!pageNumber || pageNumber < 1 || pageNumber > _this.pagesCount) {
  7674. console.error("PDFLinkService.navigateTo: \"".concat(pageNumber, "\" is not ") + "a valid page number, for dest=\"".concat(dest, "\"."));
  7675. return;
  7676. }
  7677. if (_this.pdfHistory) {
  7678. _this.pdfHistory.pushCurrentPosition();
  7679. _this.pdfHistory.push({
  7680. namedDest: namedDest,
  7681. explicitDest: explicitDest,
  7682. pageNumber: pageNumber
  7683. });
  7684. }
  7685. _this.pdfViewer.scrollPageIntoView({
  7686. pageNumber: pageNumber,
  7687. destArray: explicitDest,
  7688. ignoreDestinationZoom: _this._ignoreDestinationZoom
  7689. });
  7690. };
  7691. new Promise(function (resolve, reject) {
  7692. if (typeof dest === "string") {
  7693. _this.pdfDocument.getDestination(dest).then(function (destArray) {
  7694. resolve({
  7695. namedDest: dest,
  7696. explicitDest: destArray
  7697. });
  7698. });
  7699. return;
  7700. }
  7701. resolve({
  7702. namedDest: "",
  7703. explicitDest: dest
  7704. });
  7705. }).then(function (data) {
  7706. if (!Array.isArray(data.explicitDest)) {
  7707. console.error("PDFLinkService.navigateTo: \"".concat(data.explicitDest, "\" is") + " not a valid destination array, for dest=\"".concat(dest, "\"."));
  7708. return;
  7709. }
  7710. goToDestination(data);
  7711. });
  7712. }
  7713. }, {
  7714. key: "getDestinationHash",
  7715. value: function getDestinationHash(dest) {
  7716. if (typeof dest === "string") {
  7717. return this.getAnchorUrl("#" + escape(dest));
  7718. }
  7719. if (Array.isArray(dest)) {
  7720. var str = JSON.stringify(dest);
  7721. return this.getAnchorUrl("#" + escape(str));
  7722. }
  7723. return this.getAnchorUrl("");
  7724. }
  7725. }, {
  7726. key: "getAnchorUrl",
  7727. value: function getAnchorUrl(anchor) {
  7728. return (this.baseUrl || "") + anchor;
  7729. }
  7730. }, {
  7731. key: "setHash",
  7732. value: function setHash(hash) {
  7733. var pageNumber, dest;
  7734. if (hash.includes("=")) {
  7735. var params = (0, _ui_utils.parseQueryString)(hash);
  7736. if ("search" in params) {
  7737. this.eventBus.dispatch("findfromurlhash", {
  7738. source: this,
  7739. query: params.search.replace(/"/g, ""),
  7740. phraseSearch: params.phrase === "true"
  7741. });
  7742. }
  7743. if ("page" in params) {
  7744. pageNumber = params.page | 0 || 1;
  7745. }
  7746. if ("zoom" in params) {
  7747. var zoomArgs = params.zoom.split(",");
  7748. var zoomArg = zoomArgs[0];
  7749. var zoomArgNumber = parseFloat(zoomArg);
  7750. if (!zoomArg.includes("Fit")) {
  7751. dest = [null, {
  7752. name: "XYZ"
  7753. }, zoomArgs.length > 1 ? zoomArgs[1] | 0 : null, zoomArgs.length > 2 ? zoomArgs[2] | 0 : null, zoomArgNumber ? zoomArgNumber / 100 : zoomArg];
  7754. } else {
  7755. if (zoomArg === "Fit" || zoomArg === "FitB") {
  7756. dest = [null, {
  7757. name: zoomArg
  7758. }];
  7759. } else if (zoomArg === "FitH" || zoomArg === "FitBH" || zoomArg === "FitV" || zoomArg === "FitBV") {
  7760. dest = [null, {
  7761. name: zoomArg
  7762. }, zoomArgs.length > 1 ? zoomArgs[1] | 0 : null];
  7763. } else if (zoomArg === "FitR") {
  7764. if (zoomArgs.length !== 5) {
  7765. console.error('PDFLinkService.setHash: Not enough parameters for "FitR".');
  7766. } else {
  7767. dest = [null, {
  7768. name: zoomArg
  7769. }, zoomArgs[1] | 0, zoomArgs[2] | 0, zoomArgs[3] | 0, zoomArgs[4] | 0];
  7770. }
  7771. } else {
  7772. console.error("PDFLinkService.setHash: \"".concat(zoomArg, "\" is not ") + "a valid zoom value.");
  7773. }
  7774. }
  7775. }
  7776. if (dest) {
  7777. this.pdfViewer.scrollPageIntoView({
  7778. pageNumber: pageNumber || this.page,
  7779. destArray: dest,
  7780. allowNegativeOffset: true
  7781. });
  7782. } else if (pageNumber) {
  7783. this.page = pageNumber;
  7784. }
  7785. if ("pagemode" in params) {
  7786. this.eventBus.dispatch("pagemode", {
  7787. source: this,
  7788. mode: params.pagemode
  7789. });
  7790. }
  7791. if ("nameddest" in params) {
  7792. this.navigateTo(params.nameddest);
  7793. }
  7794. } else {
  7795. dest = unescape(hash);
  7796. try {
  7797. dest = JSON.parse(dest);
  7798. if (!Array.isArray(dest)) {
  7799. dest = dest.toString();
  7800. }
  7801. } catch (ex) {}
  7802. if (typeof dest === "string" || isValidExplicitDestination(dest)) {
  7803. this.navigateTo(dest);
  7804. return;
  7805. }
  7806. console.error("PDFLinkService.setHash: \"".concat(unescape(hash), "\" is not ") + "a valid destination.");
  7807. }
  7808. }
  7809. }, {
  7810. key: "executeNamedAction",
  7811. value: function executeNamedAction(action) {
  7812. switch (action) {
  7813. case "GoBack":
  7814. if (this.pdfHistory) {
  7815. this.pdfHistory.back();
  7816. }
  7817. break;
  7818. case "GoForward":
  7819. if (this.pdfHistory) {
  7820. this.pdfHistory.forward();
  7821. }
  7822. break;
  7823. case "NextPage":
  7824. if (this.page < this.pagesCount) {
  7825. this.page++;
  7826. }
  7827. break;
  7828. case "PrevPage":
  7829. if (this.page > 1) {
  7830. this.page--;
  7831. }
  7832. break;
  7833. case "LastPage":
  7834. this.page = this.pagesCount;
  7835. break;
  7836. case "FirstPage":
  7837. this.page = 1;
  7838. break;
  7839. default:
  7840. break;
  7841. }
  7842. this.eventBus.dispatch("namedaction", {
  7843. source: this,
  7844. action: action
  7845. });
  7846. }
  7847. }, {
  7848. key: "cachePageRef",
  7849. value: function cachePageRef(pageNum, pageRef) {
  7850. if (!pageRef) {
  7851. return;
  7852. }
  7853. var refStr = pageRef.gen === 0 ? "".concat(pageRef.num, "R") : "".concat(pageRef.num, "R").concat(pageRef.gen);
  7854. this._pagesRefCache[refStr] = pageNum;
  7855. }
  7856. }, {
  7857. key: "_cachedPageNumber",
  7858. value: function _cachedPageNumber(pageRef) {
  7859. var refStr = pageRef.gen === 0 ? "".concat(pageRef.num, "R") : "".concat(pageRef.num, "R").concat(pageRef.gen);
  7860. return this._pagesRefCache && this._pagesRefCache[refStr] || null;
  7861. }
  7862. }, {
  7863. key: "isPageVisible",
  7864. value: function isPageVisible(pageNumber) {
  7865. return this.pdfViewer.isPageVisible(pageNumber);
  7866. }
  7867. }, {
  7868. key: "pagesCount",
  7869. get: function get() {
  7870. return this.pdfDocument ? this.pdfDocument.numPages : 0;
  7871. }
  7872. }, {
  7873. key: "page",
  7874. get: function get() {
  7875. return this.pdfViewer.currentPageNumber;
  7876. },
  7877. set: function set(value) {
  7878. this.pdfViewer.currentPageNumber = value;
  7879. }
  7880. }, {
  7881. key: "rotation",
  7882. get: function get() {
  7883. return this.pdfViewer.pagesRotation;
  7884. },
  7885. set: function set(value) {
  7886. this.pdfViewer.pagesRotation = value;
  7887. }
  7888. }]);
  7889. return PDFLinkService;
  7890. }();
  7891. exports.PDFLinkService = PDFLinkService;
  7892. function isValidExplicitDestination(dest) {
  7893. if (!Array.isArray(dest)) {
  7894. return false;
  7895. }
  7896. var destLength = dest.length;
  7897. if (destLength < 2) {
  7898. return false;
  7899. }
  7900. var page = dest[0];
  7901. if (!(_typeof(page) === "object" && Number.isInteger(page.num) && Number.isInteger(page.gen)) && !(Number.isInteger(page) && page >= 0)) {
  7902. return false;
  7903. }
  7904. var zoom = dest[1];
  7905. if (!(_typeof(zoom) === "object" && typeof zoom.name === "string")) {
  7906. return false;
  7907. }
  7908. var allowNull = true;
  7909. switch (zoom.name) {
  7910. case "XYZ":
  7911. if (destLength !== 5) {
  7912. return false;
  7913. }
  7914. break;
  7915. case "Fit":
  7916. case "FitB":
  7917. return destLength === 2;
  7918. case "FitH":
  7919. case "FitBH":
  7920. case "FitV":
  7921. case "FitBV":
  7922. if (destLength !== 3) {
  7923. return false;
  7924. }
  7925. break;
  7926. case "FitR":
  7927. if (destLength !== 6) {
  7928. return false;
  7929. }
  7930. allowNull = false;
  7931. break;
  7932. default:
  7933. return false;
  7934. }
  7935. for (var i = 2; i < destLength; i++) {
  7936. var param = dest[i];
  7937. if (!(typeof param === "number" || allowNull && param === null)) {
  7938. return false;
  7939. }
  7940. }
  7941. return true;
  7942. }
  7943. var SimpleLinkService = /*#__PURE__*/function () {
  7944. function SimpleLinkService() {
  7945. _classCallCheck(this, SimpleLinkService);
  7946. this.externalLinkTarget = null;
  7947. this.externalLinkRel = null;
  7948. this.externalLinkEnabled = true;
  7949. this._ignoreDestinationZoom = false;
  7950. }
  7951. _createClass(SimpleLinkService, [{
  7952. key: "navigateTo",
  7953. value: function navigateTo(dest) {}
  7954. }, {
  7955. key: "getDestinationHash",
  7956. value: function getDestinationHash(dest) {
  7957. return "#";
  7958. }
  7959. }, {
  7960. key: "getAnchorUrl",
  7961. value: function getAnchorUrl(hash) {
  7962. return "#";
  7963. }
  7964. }, {
  7965. key: "setHash",
  7966. value: function setHash(hash) {}
  7967. }, {
  7968. key: "executeNamedAction",
  7969. value: function executeNamedAction(action) {}
  7970. }, {
  7971. key: "cachePageRef",
  7972. value: function cachePageRef(pageNum, pageRef) {}
  7973. }, {
  7974. key: "isPageVisible",
  7975. value: function isPageVisible(pageNumber) {
  7976. return true;
  7977. }
  7978. }, {
  7979. key: "pagesCount",
  7980. get: function get() {
  7981. return 0;
  7982. }
  7983. }, {
  7984. key: "page",
  7985. get: function get() {
  7986. return 0;
  7987. },
  7988. set: function set(value) {}
  7989. }, {
  7990. key: "rotation",
  7991. get: function get() {
  7992. return 0;
  7993. },
  7994. set: function set(value) {}
  7995. }]);
  7996. return SimpleLinkService;
  7997. }();
  7998. exports.SimpleLinkService = SimpleLinkService;
  7999. /***/ }),
  8000. /* 24 */
  8001. /***/ (function(module, exports, __webpack_require__) {
  8002. "use strict";
  8003. Object.defineProperty(exports, "__esModule", {
  8004. value: true
  8005. });
  8006. exports.PDFOutlineViewer = void 0;
  8007. var _pdfjsLib = __webpack_require__(8);
  8008. var _base_tree_viewer = __webpack_require__(16);
  8009. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  8010. function _createForOfIteratorHelper(o, allowArrayLike) { var it; if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = o[Symbol.iterator](); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
  8011. function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
  8012. function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
  8013. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  8014. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  8015. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  8016. function _get(target, property, receiver) { if (typeof Reflect !== "undefined" && Reflect.get) { _get = Reflect.get; } else { _get = function _get(target, property, receiver) { var base = _superPropBase(target, property); if (!base) return; var desc = Object.getOwnPropertyDescriptor(base, property); if (desc.get) { return desc.get.call(receiver); } return desc.value; }; } return _get(target, property, receiver || target); }
  8017. function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
  8018. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  8019. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  8020. function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  8021. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  8022. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  8023. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
  8024. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  8025. var PDFOutlineViewer = /*#__PURE__*/function (_BaseTreeViewer) {
  8026. _inherits(PDFOutlineViewer, _BaseTreeViewer);
  8027. var _super = _createSuper(PDFOutlineViewer);
  8028. function PDFOutlineViewer(options) {
  8029. var _this;
  8030. _classCallCheck(this, PDFOutlineViewer);
  8031. _this = _super.call(this, options);
  8032. _this.linkService = options.linkService;
  8033. _this.eventBus._on("toggleoutlinetree", _this._toggleAllTreeItems.bind(_assertThisInitialized(_this)));
  8034. return _this;
  8035. }
  8036. _createClass(PDFOutlineViewer, [{
  8037. key: "reset",
  8038. value: function reset() {
  8039. _get(_getPrototypeOf(PDFOutlineViewer.prototype), "reset", this).call(this);
  8040. this._outline = null;
  8041. }
  8042. }, {
  8043. key: "_dispatchEvent",
  8044. value: function _dispatchEvent(outlineCount) {
  8045. this.eventBus.dispatch("outlineloaded", {
  8046. source: this,
  8047. outlineCount: outlineCount
  8048. });
  8049. }
  8050. }, {
  8051. key: "_bindLink",
  8052. value: function _bindLink(element, _ref) {
  8053. var url = _ref.url,
  8054. newWindow = _ref.newWindow,
  8055. dest = _ref.dest;
  8056. var linkService = this.linkService;
  8057. if (url) {
  8058. (0, _pdfjsLib.addLinkAttributes)(element, {
  8059. url: url,
  8060. target: newWindow ? _pdfjsLib.LinkTarget.BLANK : linkService.externalLinkTarget,
  8061. rel: linkService.externalLinkRel,
  8062. enabled: linkService.externalLinkEnabled
  8063. });
  8064. return;
  8065. }
  8066. element.href = linkService.getDestinationHash(dest);
  8067. element.onclick = function () {
  8068. if (dest) {
  8069. linkService.navigateTo(dest);
  8070. }
  8071. return false;
  8072. };
  8073. }
  8074. }, {
  8075. key: "_setStyles",
  8076. value: function _setStyles(element, _ref2) {
  8077. var bold = _ref2.bold,
  8078. italic = _ref2.italic;
  8079. if (bold) {
  8080. element.style.fontWeight = "bold";
  8081. }
  8082. if (italic) {
  8083. element.style.fontStyle = "italic";
  8084. }
  8085. }
  8086. }, {
  8087. key: "_addToggleButton",
  8088. value: function _addToggleButton(div, _ref3) {
  8089. var count = _ref3.count,
  8090. items = _ref3.items;
  8091. var hidden = count < 0 && Math.abs(count) === items.length;
  8092. _get(_getPrototypeOf(PDFOutlineViewer.prototype), "_addToggleButton", this).call(this, div, hidden);
  8093. }
  8094. }, {
  8095. key: "_toggleAllTreeItems",
  8096. value: function _toggleAllTreeItems() {
  8097. if (!this._outline) {
  8098. return;
  8099. }
  8100. _get(_getPrototypeOf(PDFOutlineViewer.prototype), "_toggleAllTreeItems", this).call(this);
  8101. }
  8102. }, {
  8103. key: "render",
  8104. value: function render(_ref4) {
  8105. var outline = _ref4.outline;
  8106. if (this._outline) {
  8107. this.reset();
  8108. }
  8109. this._outline = outline || null;
  8110. if (!outline) {
  8111. this._dispatchEvent(0);
  8112. return;
  8113. }
  8114. var fragment = document.createDocumentFragment();
  8115. var queue = [{
  8116. parent: fragment,
  8117. items: outline
  8118. }];
  8119. var outlineCount = 0,
  8120. hasAnyNesting = false;
  8121. while (queue.length > 0) {
  8122. var levelData = queue.shift();
  8123. var _iterator = _createForOfIteratorHelper(levelData.items),
  8124. _step;
  8125. try {
  8126. for (_iterator.s(); !(_step = _iterator.n()).done;) {
  8127. var item = _step.value;
  8128. var div = document.createElement("div");
  8129. div.className = "treeItem";
  8130. var element = document.createElement("a");
  8131. this._bindLink(element, item);
  8132. this._setStyles(element, item);
  8133. element.textContent = this._normalizeTextContent(item.title);
  8134. div.appendChild(element);
  8135. if (item.items.length > 0) {
  8136. hasAnyNesting = true;
  8137. this._addToggleButton(div, item);
  8138. var itemsDiv = document.createElement("div");
  8139. itemsDiv.className = "treeItems";
  8140. div.appendChild(itemsDiv);
  8141. queue.push({
  8142. parent: itemsDiv,
  8143. items: item.items
  8144. });
  8145. }
  8146. levelData.parent.appendChild(div);
  8147. outlineCount++;
  8148. }
  8149. } catch (err) {
  8150. _iterator.e(err);
  8151. } finally {
  8152. _iterator.f();
  8153. }
  8154. }
  8155. if (hasAnyNesting) {
  8156. this.container.classList.add("treeWithDeepNesting");
  8157. this._lastToggleIsShow = fragment.querySelectorAll(".treeItemsHidden").length === 0;
  8158. }
  8159. this.container.appendChild(fragment);
  8160. this._dispatchEvent(outlineCount);
  8161. }
  8162. }]);
  8163. return PDFOutlineViewer;
  8164. }(_base_tree_viewer.BaseTreeViewer);
  8165. exports.PDFOutlineViewer = PDFOutlineViewer;
  8166. /***/ }),
  8167. /* 25 */
  8168. /***/ (function(module, exports, __webpack_require__) {
  8169. "use strict";
  8170. Object.defineProperty(exports, "__esModule", {
  8171. value: true
  8172. });
  8173. exports.PDFPresentationMode = void 0;
  8174. var _ui_utils = __webpack_require__(5);
  8175. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  8176. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  8177. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  8178. var DELAY_BEFORE_RESETTING_SWITCH_IN_PROGRESS = 1500;
  8179. var DELAY_BEFORE_HIDING_CONTROLS = 3000;
  8180. var ACTIVE_SELECTOR = "pdfPresentationMode";
  8181. var CONTROLS_SELECTOR = "pdfPresentationModeControls";
  8182. var MOUSE_SCROLL_COOLDOWN_TIME = 50;
  8183. var PAGE_SWITCH_THRESHOLD = 0.1;
  8184. var SWIPE_MIN_DISTANCE_THRESHOLD = 50;
  8185. var SWIPE_ANGLE_THRESHOLD = Math.PI / 6;
  8186. var PDFPresentationMode = /*#__PURE__*/function () {
  8187. function PDFPresentationMode(_ref) {
  8188. var _this = this;
  8189. var container = _ref.container,
  8190. pdfViewer = _ref.pdfViewer,
  8191. eventBus = _ref.eventBus,
  8192. _ref$contextMenuItems = _ref.contextMenuItems,
  8193. contextMenuItems = _ref$contextMenuItems === void 0 ? null : _ref$contextMenuItems;
  8194. _classCallCheck(this, PDFPresentationMode);
  8195. this.container = container;
  8196. this.pdfViewer = pdfViewer;
  8197. this.eventBus = eventBus;
  8198. this.active = false;
  8199. this.args = null;
  8200. this.contextMenuOpen = false;
  8201. this.mouseScrollTimeStamp = 0;
  8202. this.mouseScrollDelta = 0;
  8203. this.touchSwipeState = null;
  8204. if (contextMenuItems) {
  8205. contextMenuItems.contextFirstPage.addEventListener("click", function () {
  8206. _this.contextMenuOpen = false;
  8207. _this.eventBus.dispatch("firstpage", {
  8208. source: _this
  8209. });
  8210. });
  8211. contextMenuItems.contextLastPage.addEventListener("click", function () {
  8212. _this.contextMenuOpen = false;
  8213. _this.eventBus.dispatch("lastpage", {
  8214. source: _this
  8215. });
  8216. });
  8217. contextMenuItems.contextPageRotateCw.addEventListener("click", function () {
  8218. _this.contextMenuOpen = false;
  8219. _this.eventBus.dispatch("rotatecw", {
  8220. source: _this
  8221. });
  8222. });
  8223. contextMenuItems.contextPageRotateCcw.addEventListener("click", function () {
  8224. _this.contextMenuOpen = false;
  8225. _this.eventBus.dispatch("rotateccw", {
  8226. source: _this
  8227. });
  8228. });
  8229. }
  8230. }
  8231. _createClass(PDFPresentationMode, [{
  8232. key: "request",
  8233. value: function request() {
  8234. if (this.switchInProgress || this.active || !this.pdfViewer.pagesCount) {
  8235. return false;
  8236. }
  8237. this._addFullscreenChangeListeners();
  8238. this._setSwitchInProgress();
  8239. this._notifyStateChange();
  8240. if (this.container.requestFullscreen) {
  8241. this.container.requestFullscreen();
  8242. } else if (this.container.mozRequestFullScreen) {
  8243. this.container.mozRequestFullScreen();
  8244. } else if (this.container.webkitRequestFullscreen) {
  8245. this.container.webkitRequestFullscreen(Element.ALLOW_KEYBOARD_INPUT);
  8246. } else if (this.container.msRequestFullscreen) {
  8247. this.container.msRequestFullscreen();
  8248. } else {
  8249. return false;
  8250. }
  8251. this.args = {
  8252. page: this.pdfViewer.currentPageNumber,
  8253. previousScale: this.pdfViewer.currentScaleValue
  8254. };
  8255. return true;
  8256. }
  8257. }, {
  8258. key: "_mouseWheel",
  8259. value: function _mouseWheel(evt) {
  8260. if (!this.active) {
  8261. return;
  8262. }
  8263. evt.preventDefault();
  8264. var delta = (0, _ui_utils.normalizeWheelEventDelta)(evt);
  8265. var currentTime = new Date().getTime();
  8266. var storedTime = this.mouseScrollTimeStamp;
  8267. if (currentTime > storedTime && currentTime - storedTime < MOUSE_SCROLL_COOLDOWN_TIME) {
  8268. return;
  8269. }
  8270. if (this.mouseScrollDelta > 0 && delta < 0 || this.mouseScrollDelta < 0 && delta > 0) {
  8271. this._resetMouseScrollState();
  8272. }
  8273. this.mouseScrollDelta += delta;
  8274. if (Math.abs(this.mouseScrollDelta) >= PAGE_SWITCH_THRESHOLD) {
  8275. var totalDelta = this.mouseScrollDelta;
  8276. this._resetMouseScrollState();
  8277. var success = totalDelta > 0 ? this._goToPreviousPage() : this._goToNextPage();
  8278. if (success) {
  8279. this.mouseScrollTimeStamp = currentTime;
  8280. }
  8281. }
  8282. }
  8283. }, {
  8284. key: "_goToPreviousPage",
  8285. value: function _goToPreviousPage() {
  8286. var page = this.pdfViewer.currentPageNumber;
  8287. if (page <= 1) {
  8288. return false;
  8289. }
  8290. this.pdfViewer.currentPageNumber = page - 1;
  8291. return true;
  8292. }
  8293. }, {
  8294. key: "_goToNextPage",
  8295. value: function _goToNextPage() {
  8296. var page = this.pdfViewer.currentPageNumber;
  8297. if (page >= this.pdfViewer.pagesCount) {
  8298. return false;
  8299. }
  8300. this.pdfViewer.currentPageNumber = page + 1;
  8301. return true;
  8302. }
  8303. }, {
  8304. key: "_notifyStateChange",
  8305. value: function _notifyStateChange() {
  8306. this.eventBus.dispatch("presentationmodechanged", {
  8307. source: this,
  8308. active: this.active,
  8309. switchInProgress: !!this.switchInProgress
  8310. });
  8311. }
  8312. }, {
  8313. key: "_setSwitchInProgress",
  8314. value: function _setSwitchInProgress() {
  8315. var _this2 = this;
  8316. if (this.switchInProgress) {
  8317. clearTimeout(this.switchInProgress);
  8318. }
  8319. this.switchInProgress = setTimeout(function () {
  8320. _this2._removeFullscreenChangeListeners();
  8321. delete _this2.switchInProgress;
  8322. _this2._notifyStateChange();
  8323. }, DELAY_BEFORE_RESETTING_SWITCH_IN_PROGRESS);
  8324. }
  8325. }, {
  8326. key: "_resetSwitchInProgress",
  8327. value: function _resetSwitchInProgress() {
  8328. if (this.switchInProgress) {
  8329. clearTimeout(this.switchInProgress);
  8330. delete this.switchInProgress;
  8331. }
  8332. }
  8333. }, {
  8334. key: "_enter",
  8335. value: function _enter() {
  8336. var _this3 = this;
  8337. this.active = true;
  8338. this._resetSwitchInProgress();
  8339. this._notifyStateChange();
  8340. this.container.classList.add(ACTIVE_SELECTOR);
  8341. setTimeout(function () {
  8342. _this3.pdfViewer.currentPageNumber = _this3.args.page;
  8343. _this3.pdfViewer.currentScaleValue = "page-fit";
  8344. }, 0);
  8345. this._addWindowListeners();
  8346. this._showControls();
  8347. this.contextMenuOpen = false;
  8348. this.container.setAttribute("contextmenu", "viewerContextMenu");
  8349. window.getSelection().removeAllRanges();
  8350. }
  8351. }, {
  8352. key: "_exit",
  8353. value: function _exit() {
  8354. var _this4 = this;
  8355. var page = this.pdfViewer.currentPageNumber;
  8356. this.container.classList.remove(ACTIVE_SELECTOR);
  8357. setTimeout(function () {
  8358. _this4.active = false;
  8359. _this4._removeFullscreenChangeListeners();
  8360. _this4._notifyStateChange();
  8361. _this4.pdfViewer.currentScaleValue = _this4.args.previousScale;
  8362. _this4.pdfViewer.currentPageNumber = page;
  8363. _this4.args = null;
  8364. }, 0);
  8365. this._removeWindowListeners();
  8366. this._hideControls();
  8367. this._resetMouseScrollState();
  8368. this.container.removeAttribute("contextmenu");
  8369. this.contextMenuOpen = false;
  8370. }
  8371. }, {
  8372. key: "_mouseDown",
  8373. value: function _mouseDown(evt) {
  8374. if (this.contextMenuOpen) {
  8375. this.contextMenuOpen = false;
  8376. evt.preventDefault();
  8377. return;
  8378. }
  8379. if (evt.button === 0) {
  8380. var isInternalLink = evt.target.href && evt.target.classList.contains("internalLink");
  8381. if (!isInternalLink) {
  8382. evt.preventDefault();
  8383. if (evt.shiftKey) {
  8384. this._goToPreviousPage();
  8385. } else {
  8386. this._goToNextPage();
  8387. }
  8388. }
  8389. }
  8390. }
  8391. }, {
  8392. key: "_contextMenu",
  8393. value: function _contextMenu() {
  8394. this.contextMenuOpen = true;
  8395. }
  8396. }, {
  8397. key: "_showControls",
  8398. value: function _showControls() {
  8399. var _this5 = this;
  8400. if (this.controlsTimeout) {
  8401. clearTimeout(this.controlsTimeout);
  8402. } else {
  8403. this.container.classList.add(CONTROLS_SELECTOR);
  8404. }
  8405. this.controlsTimeout = setTimeout(function () {
  8406. _this5.container.classList.remove(CONTROLS_SELECTOR);
  8407. delete _this5.controlsTimeout;
  8408. }, DELAY_BEFORE_HIDING_CONTROLS);
  8409. }
  8410. }, {
  8411. key: "_hideControls",
  8412. value: function _hideControls() {
  8413. if (!this.controlsTimeout) {
  8414. return;
  8415. }
  8416. clearTimeout(this.controlsTimeout);
  8417. this.container.classList.remove(CONTROLS_SELECTOR);
  8418. delete this.controlsTimeout;
  8419. }
  8420. }, {
  8421. key: "_resetMouseScrollState",
  8422. value: function _resetMouseScrollState() {
  8423. this.mouseScrollTimeStamp = 0;
  8424. this.mouseScrollDelta = 0;
  8425. }
  8426. }, {
  8427. key: "_touchSwipe",
  8428. value: function _touchSwipe(evt) {
  8429. if (!this.active) {
  8430. return;
  8431. }
  8432. if (evt.touches.length > 1) {
  8433. this.touchSwipeState = null;
  8434. return;
  8435. }
  8436. switch (evt.type) {
  8437. case "touchstart":
  8438. this.touchSwipeState = {
  8439. startX: evt.touches[0].pageX,
  8440. startY: evt.touches[0].pageY,
  8441. endX: evt.touches[0].pageX,
  8442. endY: evt.touches[0].pageY
  8443. };
  8444. break;
  8445. case "touchmove":
  8446. if (this.touchSwipeState === null) {
  8447. return;
  8448. }
  8449. this.touchSwipeState.endX = evt.touches[0].pageX;
  8450. this.touchSwipeState.endY = evt.touches[0].pageY;
  8451. evt.preventDefault();
  8452. break;
  8453. case "touchend":
  8454. if (this.touchSwipeState === null) {
  8455. return;
  8456. }
  8457. var delta = 0;
  8458. var dx = this.touchSwipeState.endX - this.touchSwipeState.startX;
  8459. var dy = this.touchSwipeState.endY - this.touchSwipeState.startY;
  8460. var absAngle = Math.abs(Math.atan2(dy, dx));
  8461. if (Math.abs(dx) > SWIPE_MIN_DISTANCE_THRESHOLD && (absAngle <= SWIPE_ANGLE_THRESHOLD || absAngle >= Math.PI - SWIPE_ANGLE_THRESHOLD)) {
  8462. delta = dx;
  8463. } else if (Math.abs(dy) > SWIPE_MIN_DISTANCE_THRESHOLD && Math.abs(absAngle - Math.PI / 2) <= SWIPE_ANGLE_THRESHOLD) {
  8464. delta = dy;
  8465. }
  8466. if (delta > 0) {
  8467. this._goToPreviousPage();
  8468. } else if (delta < 0) {
  8469. this._goToNextPage();
  8470. }
  8471. break;
  8472. }
  8473. }
  8474. }, {
  8475. key: "_addWindowListeners",
  8476. value: function _addWindowListeners() {
  8477. this.showControlsBind = this._showControls.bind(this);
  8478. this.mouseDownBind = this._mouseDown.bind(this);
  8479. this.mouseWheelBind = this._mouseWheel.bind(this);
  8480. this.resetMouseScrollStateBind = this._resetMouseScrollState.bind(this);
  8481. this.contextMenuBind = this._contextMenu.bind(this);
  8482. this.touchSwipeBind = this._touchSwipe.bind(this);
  8483. window.addEventListener("mousemove", this.showControlsBind);
  8484. window.addEventListener("mousedown", this.mouseDownBind);
  8485. window.addEventListener("wheel", this.mouseWheelBind, {
  8486. passive: false
  8487. });
  8488. window.addEventListener("keydown", this.resetMouseScrollStateBind);
  8489. window.addEventListener("contextmenu", this.contextMenuBind);
  8490. window.addEventListener("touchstart", this.touchSwipeBind);
  8491. window.addEventListener("touchmove", this.touchSwipeBind);
  8492. window.addEventListener("touchend", this.touchSwipeBind);
  8493. }
  8494. }, {
  8495. key: "_removeWindowListeners",
  8496. value: function _removeWindowListeners() {
  8497. window.removeEventListener("mousemove", this.showControlsBind);
  8498. window.removeEventListener("mousedown", this.mouseDownBind);
  8499. window.removeEventListener("wheel", this.mouseWheelBind, {
  8500. passive: false
  8501. });
  8502. window.removeEventListener("keydown", this.resetMouseScrollStateBind);
  8503. window.removeEventListener("contextmenu", this.contextMenuBind);
  8504. window.removeEventListener("touchstart", this.touchSwipeBind);
  8505. window.removeEventListener("touchmove", this.touchSwipeBind);
  8506. window.removeEventListener("touchend", this.touchSwipeBind);
  8507. delete this.showControlsBind;
  8508. delete this.mouseDownBind;
  8509. delete this.mouseWheelBind;
  8510. delete this.resetMouseScrollStateBind;
  8511. delete this.contextMenuBind;
  8512. delete this.touchSwipeBind;
  8513. }
  8514. }, {
  8515. key: "_fullscreenChange",
  8516. value: function _fullscreenChange() {
  8517. if (this.isFullscreen) {
  8518. this._enter();
  8519. } else {
  8520. this._exit();
  8521. }
  8522. }
  8523. }, {
  8524. key: "_addFullscreenChangeListeners",
  8525. value: function _addFullscreenChangeListeners() {
  8526. this.fullscreenChangeBind = this._fullscreenChange.bind(this);
  8527. window.addEventListener("fullscreenchange", this.fullscreenChangeBind);
  8528. window.addEventListener("mozfullscreenchange", this.fullscreenChangeBind);
  8529. window.addEventListener("webkitfullscreenchange", this.fullscreenChangeBind);
  8530. window.addEventListener("MSFullscreenChange", this.fullscreenChangeBind);
  8531. }
  8532. }, {
  8533. key: "_removeFullscreenChangeListeners",
  8534. value: function _removeFullscreenChangeListeners() {
  8535. window.removeEventListener("fullscreenchange", this.fullscreenChangeBind);
  8536. window.removeEventListener("mozfullscreenchange", this.fullscreenChangeBind);
  8537. window.removeEventListener("webkitfullscreenchange", this.fullscreenChangeBind);
  8538. window.removeEventListener("MSFullscreenChange", this.fullscreenChangeBind);
  8539. delete this.fullscreenChangeBind;
  8540. }
  8541. }, {
  8542. key: "isFullscreen",
  8543. get: function get() {
  8544. return !!(document.fullscreenElement || document.mozFullScreen || document.webkitIsFullScreen || document.msFullscreenElement);
  8545. }
  8546. }]);
  8547. return PDFPresentationMode;
  8548. }();
  8549. exports.PDFPresentationMode = PDFPresentationMode;
  8550. /***/ }),
  8551. /* 26 */
  8552. /***/ (function(module, exports, __webpack_require__) {
  8553. "use strict";
  8554. Object.defineProperty(exports, "__esModule", {
  8555. value: true
  8556. });
  8557. exports.PDFSidebarResizer = void 0;
  8558. var _ui_utils = __webpack_require__(5);
  8559. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  8560. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  8561. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  8562. var SIDEBAR_WIDTH_VAR = "--sidebar-width";
  8563. var SIDEBAR_MIN_WIDTH = 200;
  8564. var SIDEBAR_RESIZING_CLASS = "sidebarResizing";
  8565. var PDFSidebarResizer = /*#__PURE__*/function () {
  8566. function PDFSidebarResizer(options, eventBus) {
  8567. var _this = this;
  8568. var l10n = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : _ui_utils.NullL10n;
  8569. _classCallCheck(this, PDFSidebarResizer);
  8570. this.enabled = false;
  8571. this.isRTL = false;
  8572. this.sidebarOpen = false;
  8573. this.doc = document.documentElement;
  8574. this._width = null;
  8575. this._outerContainerWidth = null;
  8576. this._boundEvents = Object.create(null);
  8577. this.outerContainer = options.outerContainer;
  8578. this.resizer = options.resizer;
  8579. this.eventBus = eventBus;
  8580. this.l10n = l10n;
  8581. if (typeof CSS === "undefined" || typeof CSS.supports !== "function" || !CSS.supports(SIDEBAR_WIDTH_VAR, "calc(-1 * ".concat(SIDEBAR_MIN_WIDTH, "px)"))) {
  8582. console.warn("PDFSidebarResizer: " + "The browser does not support resizing of the sidebar.");
  8583. return;
  8584. }
  8585. this.enabled = true;
  8586. this.resizer.classList.remove("hidden");
  8587. this.l10n.getDirection().then(function (dir) {
  8588. _this.isRTL = dir === "rtl";
  8589. });
  8590. this._addEventListeners();
  8591. }
  8592. _createClass(PDFSidebarResizer, [{
  8593. key: "_updateWidth",
  8594. value: function _updateWidth() {
  8595. var width = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
  8596. if (!this.enabled) {
  8597. return false;
  8598. }
  8599. var newWidth = (0, _ui_utils.clamp)(width, SIDEBAR_MIN_WIDTH, Math.floor(this.outerContainerWidth / 2));
  8600. if (newWidth === this._width) {
  8601. return false;
  8602. }
  8603. this._width = newWidth;
  8604. this.doc.style.setProperty(SIDEBAR_WIDTH_VAR, "".concat(newWidth, "px"));
  8605. return true;
  8606. }
  8607. }, {
  8608. key: "_mouseMove",
  8609. value: function _mouseMove(evt) {
  8610. var width = evt.clientX;
  8611. if (this.isRTL) {
  8612. width = this.outerContainerWidth - width;
  8613. }
  8614. this._updateWidth(width);
  8615. }
  8616. }, {
  8617. key: "_mouseUp",
  8618. value: function _mouseUp(evt) {
  8619. this.outerContainer.classList.remove(SIDEBAR_RESIZING_CLASS);
  8620. this.eventBus.dispatch("resize", {
  8621. source: this
  8622. });
  8623. var _boundEvents = this._boundEvents;
  8624. window.removeEventListener("mousemove", _boundEvents.mouseMove);
  8625. window.removeEventListener("mouseup", _boundEvents.mouseUp);
  8626. }
  8627. }, {
  8628. key: "_addEventListeners",
  8629. value: function _addEventListeners() {
  8630. var _this2 = this;
  8631. if (!this.enabled) {
  8632. return;
  8633. }
  8634. var _boundEvents = this._boundEvents;
  8635. _boundEvents.mouseMove = this._mouseMove.bind(this);
  8636. _boundEvents.mouseUp = this._mouseUp.bind(this);
  8637. this.resizer.addEventListener("mousedown", function (evt) {
  8638. if (evt.button !== 0) {
  8639. return;
  8640. }
  8641. _this2.outerContainer.classList.add(SIDEBAR_RESIZING_CLASS);
  8642. window.addEventListener("mousemove", _boundEvents.mouseMove);
  8643. window.addEventListener("mouseup", _boundEvents.mouseUp);
  8644. });
  8645. this.eventBus._on("sidebarviewchanged", function (evt) {
  8646. _this2.sidebarOpen = !!(evt && evt.view);
  8647. });
  8648. this.eventBus._on("resize", function (evt) {
  8649. if (!evt || evt.source !== window) {
  8650. return;
  8651. }
  8652. _this2._outerContainerWidth = null;
  8653. if (!_this2._width) {
  8654. return;
  8655. }
  8656. if (!_this2.sidebarOpen) {
  8657. _this2._updateWidth(_this2._width);
  8658. return;
  8659. }
  8660. _this2.outerContainer.classList.add(SIDEBAR_RESIZING_CLASS);
  8661. var updated = _this2._updateWidth(_this2._width);
  8662. Promise.resolve().then(function () {
  8663. _this2.outerContainer.classList.remove(SIDEBAR_RESIZING_CLASS);
  8664. if (updated) {
  8665. _this2.eventBus.dispatch("resize", {
  8666. source: _this2
  8667. });
  8668. }
  8669. });
  8670. });
  8671. }
  8672. }, {
  8673. key: "outerContainerWidth",
  8674. get: function get() {
  8675. if (!this._outerContainerWidth) {
  8676. this._outerContainerWidth = this.outerContainer.clientWidth;
  8677. }
  8678. return this._outerContainerWidth;
  8679. }
  8680. }]);
  8681. return PDFSidebarResizer;
  8682. }();
  8683. exports.PDFSidebarResizer = PDFSidebarResizer;
  8684. /***/ }),
  8685. /* 27 */
  8686. /***/ (function(module, exports, __webpack_require__) {
  8687. "use strict";
  8688. Object.defineProperty(exports, "__esModule", {
  8689. value: true
  8690. });
  8691. exports.PDFThumbnailViewer = void 0;
  8692. var _ui_utils = __webpack_require__(5);
  8693. var _pdf_thumbnail_view = __webpack_require__(28);
  8694. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  8695. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  8696. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  8697. var THUMBNAIL_SCROLL_MARGIN = -19;
  8698. var THUMBNAIL_SELECTED_CLASS = "selected";
  8699. var PDFThumbnailViewer = /*#__PURE__*/function () {
  8700. function PDFThumbnailViewer(_ref) {
  8701. var _this = this;
  8702. var container = _ref.container,
  8703. eventBus = _ref.eventBus,
  8704. linkService = _ref.linkService,
  8705. renderingQueue = _ref.renderingQueue,
  8706. _ref$l10n = _ref.l10n,
  8707. l10n = _ref$l10n === void 0 ? _ui_utils.NullL10n : _ref$l10n;
  8708. _classCallCheck(this, PDFThumbnailViewer);
  8709. this.container = container;
  8710. this.linkService = linkService;
  8711. this.renderingQueue = renderingQueue;
  8712. this.l10n = l10n;
  8713. this.scroll = (0, _ui_utils.watchScroll)(this.container, this._scrollUpdated.bind(this));
  8714. this._resetView();
  8715. eventBus._on("optionalcontentconfigchanged", function () {
  8716. _this._setImageDisabled = true;
  8717. });
  8718. }
  8719. _createClass(PDFThumbnailViewer, [{
  8720. key: "_scrollUpdated",
  8721. value: function _scrollUpdated() {
  8722. this.renderingQueue.renderHighestPriority();
  8723. }
  8724. }, {
  8725. key: "getThumbnail",
  8726. value: function getThumbnail(index) {
  8727. return this._thumbnails[index];
  8728. }
  8729. }, {
  8730. key: "_getVisibleThumbs",
  8731. value: function _getVisibleThumbs() {
  8732. return (0, _ui_utils.getVisibleElements)(this.container, this._thumbnails);
  8733. }
  8734. }, {
  8735. key: "scrollThumbnailIntoView",
  8736. value: function scrollThumbnailIntoView(pageNumber) {
  8737. if (!this.pdfDocument) {
  8738. return;
  8739. }
  8740. var thumbnailView = this._thumbnails[pageNumber - 1];
  8741. if (!thumbnailView) {
  8742. console.error('scrollThumbnailIntoView: Invalid "pageNumber" parameter.');
  8743. return;
  8744. }
  8745. if (pageNumber !== this._currentPageNumber) {
  8746. var prevThumbnailView = this._thumbnails[this._currentPageNumber - 1];
  8747. prevThumbnailView.div.classList.remove(THUMBNAIL_SELECTED_CLASS);
  8748. thumbnailView.div.classList.add(THUMBNAIL_SELECTED_CLASS);
  8749. }
  8750. var visibleThumbs = this._getVisibleThumbs();
  8751. var numVisibleThumbs = visibleThumbs.views.length;
  8752. if (numVisibleThumbs > 0) {
  8753. var first = visibleThumbs.first.id;
  8754. var last = numVisibleThumbs > 1 ? visibleThumbs.last.id : first;
  8755. var shouldScroll = false;
  8756. if (pageNumber <= first || pageNumber >= last) {
  8757. shouldScroll = true;
  8758. } else {
  8759. visibleThumbs.views.some(function (view) {
  8760. if (view.id !== pageNumber) {
  8761. return false;
  8762. }
  8763. shouldScroll = view.percent < 100;
  8764. return true;
  8765. });
  8766. }
  8767. if (shouldScroll) {
  8768. (0, _ui_utils.scrollIntoView)(thumbnailView.div, {
  8769. top: THUMBNAIL_SCROLL_MARGIN
  8770. });
  8771. }
  8772. }
  8773. this._currentPageNumber = pageNumber;
  8774. }
  8775. }, {
  8776. key: "cleanup",
  8777. value: function cleanup() {
  8778. _pdf_thumbnail_view.PDFThumbnailView.cleanup();
  8779. }
  8780. }, {
  8781. key: "_resetView",
  8782. value: function _resetView() {
  8783. this._thumbnails = [];
  8784. this._currentPageNumber = 1;
  8785. this._pageLabels = null;
  8786. this._pagesRotation = 0;
  8787. this._optionalContentConfigPromise = null;
  8788. this._pagesRequests = new WeakMap();
  8789. this._setImageDisabled = false;
  8790. this.container.textContent = "";
  8791. }
  8792. }, {
  8793. key: "setDocument",
  8794. value: function setDocument(pdfDocument) {
  8795. var _this2 = this;
  8796. if (this.pdfDocument) {
  8797. this._cancelRendering();
  8798. this._resetView();
  8799. }
  8800. this.pdfDocument = pdfDocument;
  8801. if (!pdfDocument) {
  8802. return;
  8803. }
  8804. var firstPagePromise = pdfDocument.getPage(1);
  8805. var optionalContentConfigPromise = pdfDocument.getOptionalContentConfig();
  8806. firstPagePromise.then(function (firstPdfPage) {
  8807. _this2._optionalContentConfigPromise = optionalContentConfigPromise;
  8808. var pagesCount = pdfDocument.numPages;
  8809. var viewport = firstPdfPage.getViewport({
  8810. scale: 1
  8811. });
  8812. var checkSetImageDisabled = function checkSetImageDisabled() {
  8813. return _this2._setImageDisabled;
  8814. };
  8815. for (var pageNum = 1; pageNum <= pagesCount; ++pageNum) {
  8816. var thumbnail = new _pdf_thumbnail_view.PDFThumbnailView({
  8817. container: _this2.container,
  8818. id: pageNum,
  8819. defaultViewport: viewport.clone(),
  8820. optionalContentConfigPromise: optionalContentConfigPromise,
  8821. linkService: _this2.linkService,
  8822. renderingQueue: _this2.renderingQueue,
  8823. checkSetImageDisabled: checkSetImageDisabled,
  8824. disableCanvasToImageConversion: false,
  8825. l10n: _this2.l10n
  8826. });
  8827. _this2._thumbnails.push(thumbnail);
  8828. }
  8829. var firstThumbnailView = _this2._thumbnails[0];
  8830. if (firstThumbnailView) {
  8831. firstThumbnailView.setPdfPage(firstPdfPage);
  8832. }
  8833. var thumbnailView = _this2._thumbnails[_this2._currentPageNumber - 1];
  8834. thumbnailView.div.classList.add(THUMBNAIL_SELECTED_CLASS);
  8835. })["catch"](function (reason) {
  8836. console.error("Unable to initialize thumbnail viewer", reason);
  8837. });
  8838. }
  8839. }, {
  8840. key: "_cancelRendering",
  8841. value: function _cancelRendering() {
  8842. for (var i = 0, ii = this._thumbnails.length; i < ii; i++) {
  8843. if (this._thumbnails[i]) {
  8844. this._thumbnails[i].cancelRendering();
  8845. }
  8846. }
  8847. }
  8848. }, {
  8849. key: "setPageLabels",
  8850. value: function setPageLabels(labels) {
  8851. if (!this.pdfDocument) {
  8852. return;
  8853. }
  8854. if (!labels) {
  8855. this._pageLabels = null;
  8856. } else if (!(Array.isArray(labels) && this.pdfDocument.numPages === labels.length)) {
  8857. this._pageLabels = null;
  8858. console.error("PDFThumbnailViewer_setPageLabels: Invalid page labels.");
  8859. } else {
  8860. this._pageLabels = labels;
  8861. }
  8862. for (var i = 0, ii = this._thumbnails.length; i < ii; i++) {
  8863. var label = this._pageLabels && this._pageLabels[i];
  8864. this._thumbnails[i].setPageLabel(label);
  8865. }
  8866. }
  8867. }, {
  8868. key: "_ensurePdfPageLoaded",
  8869. value: function _ensurePdfPageLoaded(thumbView) {
  8870. var _this3 = this;
  8871. if (thumbView.pdfPage) {
  8872. return Promise.resolve(thumbView.pdfPage);
  8873. }
  8874. if (this._pagesRequests.has(thumbView)) {
  8875. return this._pagesRequests.get(thumbView);
  8876. }
  8877. var promise = this.pdfDocument.getPage(thumbView.id).then(function (pdfPage) {
  8878. if (!thumbView.pdfPage) {
  8879. thumbView.setPdfPage(pdfPage);
  8880. }
  8881. _this3._pagesRequests["delete"](thumbView);
  8882. return pdfPage;
  8883. })["catch"](function (reason) {
  8884. console.error("Unable to get page for thumb view", reason);
  8885. _this3._pagesRequests["delete"](thumbView);
  8886. });
  8887. this._pagesRequests.set(thumbView, promise);
  8888. return promise;
  8889. }
  8890. }, {
  8891. key: "forceRendering",
  8892. value: function forceRendering() {
  8893. var _this4 = this;
  8894. var visibleThumbs = this._getVisibleThumbs();
  8895. var thumbView = this.renderingQueue.getHighestPriority(visibleThumbs, this._thumbnails, this.scroll.down);
  8896. if (thumbView) {
  8897. this._ensurePdfPageLoaded(thumbView).then(function () {
  8898. _this4.renderingQueue.renderView(thumbView);
  8899. });
  8900. return true;
  8901. }
  8902. return false;
  8903. }
  8904. }, {
  8905. key: "pagesRotation",
  8906. get: function get() {
  8907. return this._pagesRotation;
  8908. },
  8909. set: function set(rotation) {
  8910. if (!(0, _ui_utils.isValidRotation)(rotation)) {
  8911. throw new Error("Invalid thumbnails rotation angle.");
  8912. }
  8913. if (!this.pdfDocument) {
  8914. return;
  8915. }
  8916. if (this._pagesRotation === rotation) {
  8917. return;
  8918. }
  8919. this._pagesRotation = rotation;
  8920. for (var i = 0, ii = this._thumbnails.length; i < ii; i++) {
  8921. this._thumbnails[i].update(rotation);
  8922. }
  8923. }
  8924. }]);
  8925. return PDFThumbnailViewer;
  8926. }();
  8927. exports.PDFThumbnailViewer = PDFThumbnailViewer;
  8928. /***/ }),
  8929. /* 28 */
  8930. /***/ (function(module, exports, __webpack_require__) {
  8931. "use strict";
  8932. Object.defineProperty(exports, "__esModule", {
  8933. value: true
  8934. });
  8935. exports.PDFThumbnailView = void 0;
  8936. var _pdfjsLib = __webpack_require__(8);
  8937. var _ui_utils = __webpack_require__(5);
  8938. var _pdf_rendering_queue = __webpack_require__(11);
  8939. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  8940. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  8941. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  8942. var MAX_NUM_SCALING_STEPS = 3;
  8943. var THUMBNAIL_CANVAS_BORDER_WIDTH = 1;
  8944. var THUMBNAIL_WIDTH = 98;
  8945. var TempImageFactory = function TempImageFactoryClosure() {
  8946. var tempCanvasCache = null;
  8947. return {
  8948. getCanvas: function getCanvas(width, height) {
  8949. var tempCanvas = tempCanvasCache;
  8950. if (!tempCanvas) {
  8951. tempCanvas = document.createElement("canvas");
  8952. tempCanvasCache = tempCanvas;
  8953. }
  8954. tempCanvas.width = width;
  8955. tempCanvas.height = height;
  8956. tempCanvas.mozOpaque = true;
  8957. var ctx = tempCanvas.getContext("2d", {
  8958. alpha: false
  8959. });
  8960. ctx.save();
  8961. ctx.fillStyle = "rgb(255, 255, 255)";
  8962. ctx.fillRect(0, 0, width, height);
  8963. ctx.restore();
  8964. return tempCanvas;
  8965. },
  8966. destroyCanvas: function destroyCanvas() {
  8967. var tempCanvas = tempCanvasCache;
  8968. if (tempCanvas) {
  8969. tempCanvas.width = 0;
  8970. tempCanvas.height = 0;
  8971. }
  8972. tempCanvasCache = null;
  8973. }
  8974. };
  8975. }();
  8976. var PDFThumbnailView = /*#__PURE__*/function () {
  8977. function PDFThumbnailView(_ref) {
  8978. var container = _ref.container,
  8979. id = _ref.id,
  8980. defaultViewport = _ref.defaultViewport,
  8981. optionalContentConfigPromise = _ref.optionalContentConfigPromise,
  8982. linkService = _ref.linkService,
  8983. renderingQueue = _ref.renderingQueue,
  8984. checkSetImageDisabled = _ref.checkSetImageDisabled,
  8985. _ref$disableCanvasToI = _ref.disableCanvasToImageConversion,
  8986. disableCanvasToImageConversion = _ref$disableCanvasToI === void 0 ? false : _ref$disableCanvasToI,
  8987. _ref$l10n = _ref.l10n,
  8988. l10n = _ref$l10n === void 0 ? _ui_utils.NullL10n : _ref$l10n;
  8989. _classCallCheck(this, PDFThumbnailView);
  8990. this.id = id;
  8991. this.renderingId = "thumbnail" + id;
  8992. this.pageLabel = null;
  8993. this.pdfPage = null;
  8994. this.rotation = 0;
  8995. this.viewport = defaultViewport;
  8996. this.pdfPageRotate = defaultViewport.rotation;
  8997. this._optionalContentConfigPromise = optionalContentConfigPromise || null;
  8998. this.linkService = linkService;
  8999. this.renderingQueue = renderingQueue;
  9000. this.renderTask = null;
  9001. this.renderingState = _pdf_rendering_queue.RenderingStates.INITIAL;
  9002. this.resume = null;
  9003. this._checkSetImageDisabled = checkSetImageDisabled || function () {
  9004. return false;
  9005. };
  9006. this.disableCanvasToImageConversion = disableCanvasToImageConversion;
  9007. this.pageWidth = this.viewport.width;
  9008. this.pageHeight = this.viewport.height;
  9009. this.pageRatio = this.pageWidth / this.pageHeight;
  9010. this.canvasWidth = THUMBNAIL_WIDTH;
  9011. this.canvasHeight = this.canvasWidth / this.pageRatio | 0;
  9012. this.scale = this.canvasWidth / this.pageWidth;
  9013. this.l10n = l10n;
  9014. var anchor = document.createElement("a");
  9015. anchor.href = linkService.getAnchorUrl("#page=" + id);
  9016. this._thumbPageTitle.then(function (msg) {
  9017. anchor.title = msg;
  9018. });
  9019. anchor.onclick = function () {
  9020. linkService.page = id;
  9021. return false;
  9022. };
  9023. this.anchor = anchor;
  9024. var div = document.createElement("div");
  9025. div.className = "thumbnail";
  9026. div.setAttribute("data-page-number", this.id);
  9027. this.div = div;
  9028. var ring = document.createElement("div");
  9029. ring.className = "thumbnailSelectionRing";
  9030. var borderAdjustment = 2 * THUMBNAIL_CANVAS_BORDER_WIDTH;
  9031. ring.style.width = this.canvasWidth + borderAdjustment + "px";
  9032. ring.style.height = this.canvasHeight + borderAdjustment + "px";
  9033. this.ring = ring;
  9034. div.appendChild(ring);
  9035. anchor.appendChild(div);
  9036. container.appendChild(anchor);
  9037. }
  9038. _createClass(PDFThumbnailView, [{
  9039. key: "setPdfPage",
  9040. value: function setPdfPage(pdfPage) {
  9041. this.pdfPage = pdfPage;
  9042. this.pdfPageRotate = pdfPage.rotate;
  9043. var totalRotation = (this.rotation + this.pdfPageRotate) % 360;
  9044. this.viewport = pdfPage.getViewport({
  9045. scale: 1,
  9046. rotation: totalRotation
  9047. });
  9048. this.reset();
  9049. }
  9050. }, {
  9051. key: "reset",
  9052. value: function reset() {
  9053. this.cancelRendering();
  9054. this.renderingState = _pdf_rendering_queue.RenderingStates.INITIAL;
  9055. this.pageWidth = this.viewport.width;
  9056. this.pageHeight = this.viewport.height;
  9057. this.pageRatio = this.pageWidth / this.pageHeight;
  9058. this.canvasHeight = this.canvasWidth / this.pageRatio | 0;
  9059. this.scale = this.canvasWidth / this.pageWidth;
  9060. this.div.removeAttribute("data-loaded");
  9061. var ring = this.ring;
  9062. var childNodes = ring.childNodes;
  9063. for (var i = childNodes.length - 1; i >= 0; i--) {
  9064. ring.removeChild(childNodes[i]);
  9065. }
  9066. var borderAdjustment = 2 * THUMBNAIL_CANVAS_BORDER_WIDTH;
  9067. ring.style.width = this.canvasWidth + borderAdjustment + "px";
  9068. ring.style.height = this.canvasHeight + borderAdjustment + "px";
  9069. if (this.canvas) {
  9070. this.canvas.width = 0;
  9071. this.canvas.height = 0;
  9072. delete this.canvas;
  9073. }
  9074. if (this.image) {
  9075. this.image.removeAttribute("src");
  9076. delete this.image;
  9077. }
  9078. }
  9079. }, {
  9080. key: "update",
  9081. value: function update(rotation) {
  9082. if (typeof rotation !== "undefined") {
  9083. this.rotation = rotation;
  9084. }
  9085. var totalRotation = (this.rotation + this.pdfPageRotate) % 360;
  9086. this.viewport = this.viewport.clone({
  9087. scale: 1,
  9088. rotation: totalRotation
  9089. });
  9090. this.reset();
  9091. }
  9092. }, {
  9093. key: "cancelRendering",
  9094. value: function cancelRendering() {
  9095. if (this.renderTask) {
  9096. this.renderTask.cancel();
  9097. this.renderTask = null;
  9098. }
  9099. this.resume = null;
  9100. }
  9101. }, {
  9102. key: "_getPageDrawContext",
  9103. value: function _getPageDrawContext() {
  9104. var noCtxScale = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  9105. var canvas = document.createElement("canvas");
  9106. this.canvas = canvas;
  9107. canvas.mozOpaque = true;
  9108. var ctx = canvas.getContext("2d", {
  9109. alpha: false
  9110. });
  9111. var outputScale = (0, _ui_utils.getOutputScale)(ctx);
  9112. canvas.width = this.canvasWidth * outputScale.sx | 0;
  9113. canvas.height = this.canvasHeight * outputScale.sy | 0;
  9114. canvas.style.width = this.canvasWidth + "px";
  9115. canvas.style.height = this.canvasHeight + "px";
  9116. if (!noCtxScale && outputScale.scaled) {
  9117. ctx.scale(outputScale.sx, outputScale.sy);
  9118. }
  9119. return ctx;
  9120. }
  9121. }, {
  9122. key: "_convertCanvasToImage",
  9123. value: function _convertCanvasToImage() {
  9124. var _this = this;
  9125. if (!this.canvas) {
  9126. return;
  9127. }
  9128. if (this.renderingState !== _pdf_rendering_queue.RenderingStates.FINISHED) {
  9129. return;
  9130. }
  9131. var className = "thumbnailImage";
  9132. if (this.disableCanvasToImageConversion) {
  9133. this.canvas.className = className;
  9134. this._thumbPageCanvas.then(function (msg) {
  9135. _this.canvas.setAttribute("aria-label", msg);
  9136. });
  9137. this.div.setAttribute("data-loaded", true);
  9138. this.ring.appendChild(this.canvas);
  9139. return;
  9140. }
  9141. var image = document.createElement("img");
  9142. image.className = className;
  9143. this._thumbPageCanvas.then(function (msg) {
  9144. image.setAttribute("aria-label", msg);
  9145. });
  9146. image.style.width = this.canvasWidth + "px";
  9147. image.style.height = this.canvasHeight + "px";
  9148. image.src = this.canvas.toDataURL();
  9149. this.image = image;
  9150. this.div.setAttribute("data-loaded", true);
  9151. this.ring.appendChild(image);
  9152. this.canvas.width = 0;
  9153. this.canvas.height = 0;
  9154. delete this.canvas;
  9155. }
  9156. }, {
  9157. key: "draw",
  9158. value: function draw() {
  9159. var _this2 = this;
  9160. if (this.renderingState !== _pdf_rendering_queue.RenderingStates.INITIAL) {
  9161. console.error("Must be in new state before drawing");
  9162. return Promise.resolve(undefined);
  9163. }
  9164. var pdfPage = this.pdfPage;
  9165. if (!pdfPage) {
  9166. this.renderingState = _pdf_rendering_queue.RenderingStates.FINISHED;
  9167. return Promise.reject(new Error("pdfPage is not loaded"));
  9168. }
  9169. this.renderingState = _pdf_rendering_queue.RenderingStates.RUNNING;
  9170. var renderCapability = (0, _pdfjsLib.createPromiseCapability)();
  9171. var finishRenderTask = function finishRenderTask(error) {
  9172. if (renderTask === _this2.renderTask) {
  9173. _this2.renderTask = null;
  9174. }
  9175. if (error instanceof _pdfjsLib.RenderingCancelledException) {
  9176. renderCapability.resolve(undefined);
  9177. return;
  9178. }
  9179. _this2.renderingState = _pdf_rendering_queue.RenderingStates.FINISHED;
  9180. _this2._convertCanvasToImage();
  9181. if (!error) {
  9182. renderCapability.resolve(undefined);
  9183. } else {
  9184. renderCapability.reject(error);
  9185. }
  9186. };
  9187. var ctx = this._getPageDrawContext();
  9188. var drawViewport = this.viewport.clone({
  9189. scale: this.scale
  9190. });
  9191. var renderContinueCallback = function renderContinueCallback(cont) {
  9192. if (!_this2.renderingQueue.isHighestPriority(_this2)) {
  9193. _this2.renderingState = _pdf_rendering_queue.RenderingStates.PAUSED;
  9194. _this2.resume = function () {
  9195. _this2.renderingState = _pdf_rendering_queue.RenderingStates.RUNNING;
  9196. cont();
  9197. };
  9198. return;
  9199. }
  9200. cont();
  9201. };
  9202. var renderContext = {
  9203. canvasContext: ctx,
  9204. viewport: drawViewport,
  9205. optionalContentConfigPromise: this._optionalContentConfigPromise
  9206. };
  9207. var renderTask = this.renderTask = pdfPage.render(renderContext);
  9208. renderTask.onContinue = renderContinueCallback;
  9209. renderTask.promise.then(function () {
  9210. finishRenderTask(null);
  9211. }, function (error) {
  9212. finishRenderTask(error);
  9213. });
  9214. return renderCapability.promise;
  9215. }
  9216. }, {
  9217. key: "setImage",
  9218. value: function setImage(pageView) {
  9219. if (this._checkSetImageDisabled()) {
  9220. return;
  9221. }
  9222. if (this.renderingState !== _pdf_rendering_queue.RenderingStates.INITIAL) {
  9223. return;
  9224. }
  9225. var img = pageView.canvas;
  9226. if (!img) {
  9227. return;
  9228. }
  9229. if (!this.pdfPage) {
  9230. this.setPdfPage(pageView.pdfPage);
  9231. }
  9232. this.renderingState = _pdf_rendering_queue.RenderingStates.FINISHED;
  9233. var ctx = this._getPageDrawContext(true);
  9234. var canvas = ctx.canvas;
  9235. if (img.width <= 2 * canvas.width) {
  9236. ctx.drawImage(img, 0, 0, img.width, img.height, 0, 0, canvas.width, canvas.height);
  9237. this._convertCanvasToImage();
  9238. return;
  9239. }
  9240. var reducedWidth = canvas.width << MAX_NUM_SCALING_STEPS;
  9241. var reducedHeight = canvas.height << MAX_NUM_SCALING_STEPS;
  9242. var reducedImage = TempImageFactory.getCanvas(reducedWidth, reducedHeight);
  9243. var reducedImageCtx = reducedImage.getContext("2d");
  9244. while (reducedWidth > img.width || reducedHeight > img.height) {
  9245. reducedWidth >>= 1;
  9246. reducedHeight >>= 1;
  9247. }
  9248. reducedImageCtx.drawImage(img, 0, 0, img.width, img.height, 0, 0, reducedWidth, reducedHeight);
  9249. while (reducedWidth > 2 * canvas.width) {
  9250. reducedImageCtx.drawImage(reducedImage, 0, 0, reducedWidth, reducedHeight, 0, 0, reducedWidth >> 1, reducedHeight >> 1);
  9251. reducedWidth >>= 1;
  9252. reducedHeight >>= 1;
  9253. }
  9254. ctx.drawImage(reducedImage, 0, 0, reducedWidth, reducedHeight, 0, 0, canvas.width, canvas.height);
  9255. this._convertCanvasToImage();
  9256. }
  9257. }, {
  9258. key: "setPageLabel",
  9259. value: function setPageLabel(label) {
  9260. var _this3 = this;
  9261. this.pageLabel = typeof label === "string" ? label : null;
  9262. this._thumbPageTitle.then(function (msg) {
  9263. _this3.anchor.title = msg;
  9264. });
  9265. if (this.renderingState !== _pdf_rendering_queue.RenderingStates.FINISHED) {
  9266. return;
  9267. }
  9268. this._thumbPageCanvas.then(function (msg) {
  9269. if (_this3.image) {
  9270. _this3.image.setAttribute("aria-label", msg);
  9271. } else if (_this3.disableCanvasToImageConversion && _this3.canvas) {
  9272. _this3.canvas.setAttribute("aria-label", msg);
  9273. }
  9274. });
  9275. }
  9276. }, {
  9277. key: "_thumbPageTitle",
  9278. get: function get() {
  9279. var _this$pageLabel;
  9280. return this.l10n.get("thumb_page_title", {
  9281. page: (_this$pageLabel = this.pageLabel) != null ? _this$pageLabel : this.id
  9282. }, "Page {{page}}");
  9283. }
  9284. }, {
  9285. key: "_thumbPageCanvas",
  9286. get: function get() {
  9287. var _this$pageLabel2;
  9288. return this.l10n.get("thumb_page_canvas", {
  9289. page: (_this$pageLabel2 = this.pageLabel) != null ? _this$pageLabel2 : this.id
  9290. }, "Thumbnail of Page {{page}}");
  9291. }
  9292. }], [{
  9293. key: "cleanup",
  9294. value: function cleanup() {
  9295. TempImageFactory.destroyCanvas();
  9296. }
  9297. }]);
  9298. return PDFThumbnailView;
  9299. }();
  9300. exports.PDFThumbnailView = PDFThumbnailView;
  9301. /***/ }),
  9302. /* 29 */
  9303. /***/ (function(module, exports, __webpack_require__) {
  9304. "use strict";
  9305. Object.defineProperty(exports, "__esModule", {
  9306. value: true
  9307. });
  9308. exports.PDFViewer = void 0;
  9309. var _base_viewer = __webpack_require__(30);
  9310. var _pdfjsLib = __webpack_require__(8);
  9311. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  9312. function _createForOfIteratorHelper(o, allowArrayLike) { var it; if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = o[Symbol.iterator](); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
  9313. function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
  9314. function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
  9315. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  9316. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  9317. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  9318. function _get(target, property, receiver) { if (typeof Reflect !== "undefined" && Reflect.get) { _get = Reflect.get; } else { _get = function _get(target, property, receiver) { var base = _superPropBase(target, property); if (!base) return; var desc = Object.getOwnPropertyDescriptor(base, property); if (desc.get) { return desc.get.call(receiver); } return desc.value; }; } return _get(target, property, receiver || target); }
  9319. function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
  9320. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  9321. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  9322. function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  9323. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  9324. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  9325. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
  9326. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  9327. var PDFViewer = /*#__PURE__*/function (_BaseViewer) {
  9328. _inherits(PDFViewer, _BaseViewer);
  9329. var _super = _createSuper(PDFViewer);
  9330. function PDFViewer() {
  9331. _classCallCheck(this, PDFViewer);
  9332. return _super.apply(this, arguments);
  9333. }
  9334. _createClass(PDFViewer, [{
  9335. key: "_scrollIntoView",
  9336. value: function _scrollIntoView(_ref) {
  9337. var pageDiv = _ref.pageDiv,
  9338. _ref$pageSpot = _ref.pageSpot,
  9339. pageSpot = _ref$pageSpot === void 0 ? null : _ref$pageSpot,
  9340. _ref$pageNumber = _ref.pageNumber,
  9341. pageNumber = _ref$pageNumber === void 0 ? null : _ref$pageNumber;
  9342. if (!pageSpot && !this.isInPresentationMode) {
  9343. var left = pageDiv.offsetLeft + pageDiv.clientLeft;
  9344. var right = left + pageDiv.clientWidth;
  9345. var _this$container = this.container,
  9346. scrollLeft = _this$container.scrollLeft,
  9347. clientWidth = _this$container.clientWidth;
  9348. if (this._isScrollModeHorizontal || left < scrollLeft || right > scrollLeft + clientWidth) {
  9349. pageSpot = {
  9350. left: 0,
  9351. top: 0
  9352. };
  9353. }
  9354. }
  9355. _get(_getPrototypeOf(PDFViewer.prototype), "_scrollIntoView", this).call(this, {
  9356. pageDiv: pageDiv,
  9357. pageSpot: pageSpot,
  9358. pageNumber: pageNumber
  9359. });
  9360. }
  9361. }, {
  9362. key: "_getVisiblePages",
  9363. value: function _getVisiblePages() {
  9364. if (this.isInPresentationMode) {
  9365. return this._getCurrentVisiblePage();
  9366. }
  9367. return _get(_getPrototypeOf(PDFViewer.prototype), "_getVisiblePages", this).call(this);
  9368. }
  9369. }, {
  9370. key: "_updateHelper",
  9371. value: function _updateHelper(visiblePages) {
  9372. if (this.isInPresentationMode) {
  9373. return;
  9374. }
  9375. var currentId = this._currentPageNumber;
  9376. var stillFullyVisible = false;
  9377. var _iterator = _createForOfIteratorHelper(visiblePages),
  9378. _step;
  9379. try {
  9380. for (_iterator.s(); !(_step = _iterator.n()).done;) {
  9381. var page = _step.value;
  9382. if (page.percent < 100) {
  9383. break;
  9384. }
  9385. if (page.id === currentId) {
  9386. stillFullyVisible = true;
  9387. break;
  9388. }
  9389. }
  9390. } catch (err) {
  9391. _iterator.e(err);
  9392. } finally {
  9393. _iterator.f();
  9394. }
  9395. if (!stillFullyVisible) {
  9396. currentId = visiblePages[0].id;
  9397. }
  9398. this._setCurrentPageNumber(currentId);
  9399. }
  9400. }, {
  9401. key: "_viewerElement",
  9402. get: function get() {
  9403. return (0, _pdfjsLib.shadow)(this, "_viewerElement", this.viewer);
  9404. }
  9405. }]);
  9406. return PDFViewer;
  9407. }(_base_viewer.BaseViewer);
  9408. exports.PDFViewer = PDFViewer;
  9409. /***/ }),
  9410. /* 30 */
  9411. /***/ (function(module, exports, __webpack_require__) {
  9412. "use strict";
  9413. Object.defineProperty(exports, "__esModule", {
  9414. value: true
  9415. });
  9416. exports.BaseViewer = void 0;
  9417. var _ui_utils = __webpack_require__(5);
  9418. var _pdf_rendering_queue = __webpack_require__(11);
  9419. var _annotation_layer_builder = __webpack_require__(31);
  9420. var _pdfjsLib = __webpack_require__(8);
  9421. var _pdf_page_view = __webpack_require__(32);
  9422. var _pdf_link_service = __webpack_require__(23);
  9423. var _text_layer_builder = __webpack_require__(33);
  9424. function _createForOfIteratorHelper(o, allowArrayLike) { var it; if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = o[Symbol.iterator](); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
  9425. function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
  9426. function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
  9427. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  9428. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  9429. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  9430. var DEFAULT_CACHE_SIZE = 10;
  9431. function PDFPageViewBuffer(size) {
  9432. var data = [];
  9433. this.push = function (view) {
  9434. var i = data.indexOf(view);
  9435. if (i >= 0) {
  9436. data.splice(i, 1);
  9437. }
  9438. data.push(view);
  9439. if (data.length > size) {
  9440. data.shift().destroy();
  9441. }
  9442. };
  9443. this.resize = function (newSize, pagesToKeep) {
  9444. size = newSize;
  9445. if (pagesToKeep) {
  9446. var pageIdsToKeep = new Set();
  9447. for (var i = 0, iMax = pagesToKeep.length; i < iMax; ++i) {
  9448. pageIdsToKeep.add(pagesToKeep[i].id);
  9449. }
  9450. (0, _ui_utils.moveToEndOfArray)(data, function (page) {
  9451. return pageIdsToKeep.has(page.id);
  9452. });
  9453. }
  9454. while (data.length > size) {
  9455. data.shift().destroy();
  9456. }
  9457. };
  9458. }
  9459. function isSameScale(oldScale, newScale) {
  9460. if (newScale === oldScale) {
  9461. return true;
  9462. }
  9463. if (Math.abs(newScale - oldScale) < 1e-15) {
  9464. return true;
  9465. }
  9466. return false;
  9467. }
  9468. var BaseViewer = /*#__PURE__*/function () {
  9469. function BaseViewer(options) {
  9470. var _this = this;
  9471. _classCallCheck(this, BaseViewer);
  9472. if (this.constructor === BaseViewer) {
  9473. throw new Error("Cannot initialize BaseViewer.");
  9474. }
  9475. this._name = this.constructor.name;
  9476. this.container = options.container;
  9477. this.viewer = options.viewer || options.container.firstElementChild;
  9478. if (!(this.container instanceof HTMLDivElement && this.viewer instanceof HTMLDivElement)) {
  9479. throw new Error("Invalid `container` and/or `viewer` option.");
  9480. }
  9481. this.eventBus = options.eventBus;
  9482. this.linkService = options.linkService || new _pdf_link_service.SimpleLinkService();
  9483. this.downloadManager = options.downloadManager || null;
  9484. this.findController = options.findController || null;
  9485. this.removePageBorders = options.removePageBorders || false;
  9486. this.textLayerMode = Number.isInteger(options.textLayerMode) ? options.textLayerMode : _ui_utils.TextLayerMode.ENABLE;
  9487. this.imageResourcesPath = options.imageResourcesPath || "";
  9488. this.renderInteractiveForms = typeof options.renderInteractiveForms === "boolean" ? options.renderInteractiveForms : true;
  9489. this.enablePrintAutoRotate = options.enablePrintAutoRotate || false;
  9490. this.renderer = options.renderer || _ui_utils.RendererType.CANVAS;
  9491. this.enableWebGL = options.enableWebGL || false;
  9492. this.useOnlyCssZoom = options.useOnlyCssZoom || false;
  9493. this.maxCanvasPixels = options.maxCanvasPixels;
  9494. this.l10n = options.l10n || _ui_utils.NullL10n;
  9495. this.defaultRenderingQueue = !options.renderingQueue;
  9496. if (this.defaultRenderingQueue) {
  9497. this.renderingQueue = new _pdf_rendering_queue.PDFRenderingQueue();
  9498. this.renderingQueue.setViewer(this);
  9499. } else {
  9500. this.renderingQueue = options.renderingQueue;
  9501. }
  9502. this.scroll = (0, _ui_utils.watchScroll)(this.container, this._scrollUpdate.bind(this));
  9503. this.presentationModeState = _ui_utils.PresentationModeState.UNKNOWN;
  9504. this._onBeforeDraw = this._onAfterDraw = null;
  9505. this._resetView();
  9506. if (this.removePageBorders) {
  9507. this.viewer.classList.add("removePageBorders");
  9508. }
  9509. Promise.resolve().then(function () {
  9510. _this.eventBus.dispatch("baseviewerinit", {
  9511. source: _this
  9512. });
  9513. });
  9514. }
  9515. _createClass(BaseViewer, [{
  9516. key: "getPageView",
  9517. value: function getPageView(index) {
  9518. return this._pages[index];
  9519. }
  9520. }, {
  9521. key: "_setCurrentPageNumber",
  9522. value: function _setCurrentPageNumber(val) {
  9523. var resetCurrentPageView = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  9524. if (this._currentPageNumber === val) {
  9525. if (resetCurrentPageView) {
  9526. this._resetCurrentPageView();
  9527. }
  9528. return true;
  9529. }
  9530. if (!(0 < val && val <= this.pagesCount)) {
  9531. return false;
  9532. }
  9533. this._currentPageNumber = val;
  9534. this.eventBus.dispatch("pagechanging", {
  9535. source: this,
  9536. pageNumber: val,
  9537. pageLabel: this._pageLabels && this._pageLabels[val - 1]
  9538. });
  9539. if (resetCurrentPageView) {
  9540. this._resetCurrentPageView();
  9541. }
  9542. return true;
  9543. }
  9544. }, {
  9545. key: "_onePageRenderedOrForceFetch",
  9546. value: function _onePageRenderedOrForceFetch() {
  9547. if (!this.container.offsetParent || this._getVisiblePages().views.length === 0) {
  9548. return Promise.resolve();
  9549. }
  9550. return this._onePageRenderedCapability.promise;
  9551. }
  9552. }, {
  9553. key: "setDocument",
  9554. value: function setDocument(pdfDocument) {
  9555. var _this2 = this;
  9556. if (this.pdfDocument) {
  9557. this._cancelRendering();
  9558. this._resetView();
  9559. if (this.findController) {
  9560. this.findController.setDocument(null);
  9561. }
  9562. }
  9563. this.pdfDocument = pdfDocument;
  9564. if (!pdfDocument) {
  9565. return;
  9566. }
  9567. var pagesCount = pdfDocument.numPages;
  9568. var firstPagePromise = pdfDocument.getPage(1);
  9569. var annotationStorage = pdfDocument.annotationStorage;
  9570. var optionalContentConfigPromise = pdfDocument.getOptionalContentConfig();
  9571. this._pagesCapability.promise.then(function () {
  9572. _this2.eventBus.dispatch("pagesloaded", {
  9573. source: _this2,
  9574. pagesCount: pagesCount
  9575. });
  9576. });
  9577. this._onBeforeDraw = function (evt) {
  9578. var pageView = _this2._pages[evt.pageNumber - 1];
  9579. if (!pageView) {
  9580. return;
  9581. }
  9582. _this2._buffer.push(pageView);
  9583. };
  9584. this.eventBus._on("pagerender", this._onBeforeDraw);
  9585. this._onAfterDraw = function (evt) {
  9586. if (evt.cssTransform || _this2._onePageRenderedCapability.settled) {
  9587. return;
  9588. }
  9589. _this2._onePageRenderedCapability.resolve();
  9590. _this2.eventBus._off("pagerendered", _this2._onAfterDraw);
  9591. _this2._onAfterDraw = null;
  9592. };
  9593. this.eventBus._on("pagerendered", this._onAfterDraw);
  9594. firstPagePromise.then(function (firstPdfPage) {
  9595. _this2._firstPageCapability.resolve(firstPdfPage);
  9596. _this2._optionalContentConfigPromise = optionalContentConfigPromise;
  9597. var scale = _this2.currentScale;
  9598. var viewport = firstPdfPage.getViewport({
  9599. scale: scale * _ui_utils.CSS_UNITS
  9600. });
  9601. var textLayerFactory = _this2.textLayerMode !== _ui_utils.TextLayerMode.DISABLE ? _this2 : null;
  9602. for (var pageNum = 1; pageNum <= pagesCount; ++pageNum) {
  9603. var pageView = new _pdf_page_view.PDFPageView({
  9604. container: _this2._viewerElement,
  9605. eventBus: _this2.eventBus,
  9606. id: pageNum,
  9607. scale: scale,
  9608. defaultViewport: viewport.clone(),
  9609. annotationStorage: annotationStorage,
  9610. optionalContentConfigPromise: optionalContentConfigPromise,
  9611. renderingQueue: _this2.renderingQueue,
  9612. textLayerFactory: textLayerFactory,
  9613. textLayerMode: _this2.textLayerMode,
  9614. annotationLayerFactory: _this2,
  9615. imageResourcesPath: _this2.imageResourcesPath,
  9616. renderInteractiveForms: _this2.renderInteractiveForms,
  9617. renderer: _this2.renderer,
  9618. enableWebGL: _this2.enableWebGL,
  9619. useOnlyCssZoom: _this2.useOnlyCssZoom,
  9620. maxCanvasPixels: _this2.maxCanvasPixels,
  9621. l10n: _this2.l10n
  9622. });
  9623. _this2._pages.push(pageView);
  9624. }
  9625. var firstPageView = _this2._pages[0];
  9626. if (firstPageView) {
  9627. firstPageView.setPdfPage(firstPdfPage);
  9628. _this2.linkService.cachePageRef(1, firstPdfPage.ref);
  9629. }
  9630. if (_this2._spreadMode !== _ui_utils.SpreadMode.NONE) {
  9631. _this2._updateSpreadMode();
  9632. }
  9633. _this2._onePageRenderedOrForceFetch().then(function () {
  9634. if (_this2.findController) {
  9635. _this2.findController.setDocument(pdfDocument);
  9636. }
  9637. if (pdfDocument.loadingParams.disableAutoFetch || pagesCount > 7500) {
  9638. _this2._pagesCapability.resolve();
  9639. return;
  9640. }
  9641. var getPagesLeft = pagesCount - 1;
  9642. if (getPagesLeft <= 0) {
  9643. _this2._pagesCapability.resolve();
  9644. return;
  9645. }
  9646. var _loop = function _loop(_pageNum) {
  9647. pdfDocument.getPage(_pageNum).then(function (pdfPage) {
  9648. var pageView = _this2._pages[_pageNum - 1];
  9649. if (!pageView.pdfPage) {
  9650. pageView.setPdfPage(pdfPage);
  9651. }
  9652. _this2.linkService.cachePageRef(_pageNum, pdfPage.ref);
  9653. if (--getPagesLeft === 0) {
  9654. _this2._pagesCapability.resolve();
  9655. }
  9656. }, function (reason) {
  9657. console.error("Unable to get page ".concat(_pageNum, " to initialize viewer"), reason);
  9658. if (--getPagesLeft === 0) {
  9659. _this2._pagesCapability.resolve();
  9660. }
  9661. });
  9662. };
  9663. for (var _pageNum = 2; _pageNum <= pagesCount; ++_pageNum) {
  9664. _loop(_pageNum);
  9665. }
  9666. });
  9667. _this2.eventBus.dispatch("pagesinit", {
  9668. source: _this2
  9669. });
  9670. if (_this2.defaultRenderingQueue) {
  9671. _this2.update();
  9672. }
  9673. })["catch"](function (reason) {
  9674. console.error("Unable to initialize viewer", reason);
  9675. });
  9676. }
  9677. }, {
  9678. key: "setPageLabels",
  9679. value: function setPageLabels(labels) {
  9680. if (!this.pdfDocument) {
  9681. return;
  9682. }
  9683. if (!labels) {
  9684. this._pageLabels = null;
  9685. } else if (!(Array.isArray(labels) && this.pdfDocument.numPages === labels.length)) {
  9686. this._pageLabels = null;
  9687. console.error("".concat(this._name, ".setPageLabels: Invalid page labels."));
  9688. } else {
  9689. this._pageLabels = labels;
  9690. }
  9691. for (var i = 0, ii = this._pages.length; i < ii; i++) {
  9692. var pageView = this._pages[i];
  9693. var label = this._pageLabels && this._pageLabels[i];
  9694. pageView.setPageLabel(label);
  9695. }
  9696. }
  9697. }, {
  9698. key: "_resetView",
  9699. value: function _resetView() {
  9700. this._pages = [];
  9701. this._currentPageNumber = 1;
  9702. this._currentScale = _ui_utils.UNKNOWN_SCALE;
  9703. this._currentScaleValue = null;
  9704. this._pageLabels = null;
  9705. this._buffer = new PDFPageViewBuffer(DEFAULT_CACHE_SIZE);
  9706. this._location = null;
  9707. this._pagesRotation = 0;
  9708. this._optionalContentConfigPromise = null;
  9709. this._pagesRequests = new WeakMap();
  9710. this._firstPageCapability = (0, _pdfjsLib.createPromiseCapability)();
  9711. this._onePageRenderedCapability = (0, _pdfjsLib.createPromiseCapability)();
  9712. this._pagesCapability = (0, _pdfjsLib.createPromiseCapability)();
  9713. this._scrollMode = _ui_utils.ScrollMode.VERTICAL;
  9714. this._spreadMode = _ui_utils.SpreadMode.NONE;
  9715. if (this._onBeforeDraw) {
  9716. this.eventBus._off("pagerender", this._onBeforeDraw);
  9717. this._onBeforeDraw = null;
  9718. }
  9719. if (this._onAfterDraw) {
  9720. this.eventBus._off("pagerendered", this._onAfterDraw);
  9721. this._onAfterDraw = null;
  9722. }
  9723. this.viewer.textContent = "";
  9724. this._updateScrollMode();
  9725. }
  9726. }, {
  9727. key: "_scrollUpdate",
  9728. value: function _scrollUpdate() {
  9729. if (this.pagesCount === 0) {
  9730. return;
  9731. }
  9732. this.update();
  9733. }
  9734. }, {
  9735. key: "_scrollIntoView",
  9736. value: function _scrollIntoView(_ref) {
  9737. var pageDiv = _ref.pageDiv,
  9738. _ref$pageSpot = _ref.pageSpot,
  9739. pageSpot = _ref$pageSpot === void 0 ? null : _ref$pageSpot,
  9740. _ref$pageNumber = _ref.pageNumber,
  9741. pageNumber = _ref$pageNumber === void 0 ? null : _ref$pageNumber;
  9742. (0, _ui_utils.scrollIntoView)(pageDiv, pageSpot);
  9743. }
  9744. }, {
  9745. key: "_setScaleUpdatePages",
  9746. value: function _setScaleUpdatePages(newScale, newValue) {
  9747. var noScroll = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  9748. var preset = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
  9749. this._currentScaleValue = newValue.toString();
  9750. if (isSameScale(this._currentScale, newScale)) {
  9751. if (preset) {
  9752. this.eventBus.dispatch("scalechanging", {
  9753. source: this,
  9754. scale: newScale,
  9755. presetValue: newValue
  9756. });
  9757. }
  9758. return;
  9759. }
  9760. for (var i = 0, ii = this._pages.length; i < ii; i++) {
  9761. this._pages[i].update(newScale);
  9762. }
  9763. this._currentScale = newScale;
  9764. if (!noScroll) {
  9765. var page = this._currentPageNumber,
  9766. dest;
  9767. if (this._location && !(this.isInPresentationMode || this.isChangingPresentationMode)) {
  9768. page = this._location.pageNumber;
  9769. dest = [null, {
  9770. name: "XYZ"
  9771. }, this._location.left, this._location.top, null];
  9772. }
  9773. this.scrollPageIntoView({
  9774. pageNumber: page,
  9775. destArray: dest,
  9776. allowNegativeOffset: true
  9777. });
  9778. }
  9779. this.eventBus.dispatch("scalechanging", {
  9780. source: this,
  9781. scale: newScale,
  9782. presetValue: preset ? newValue : undefined
  9783. });
  9784. if (this.defaultRenderingQueue) {
  9785. this.update();
  9786. }
  9787. }
  9788. }, {
  9789. key: "_setScale",
  9790. value: function _setScale(value) {
  9791. var noScroll = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  9792. var scale = parseFloat(value);
  9793. if (scale > 0) {
  9794. this._setScaleUpdatePages(scale, value, noScroll, false);
  9795. } else {
  9796. var currentPage = this._pages[this._currentPageNumber - 1];
  9797. if (!currentPage) {
  9798. return;
  9799. }
  9800. var noPadding = this.isInPresentationMode || this.removePageBorders;
  9801. var hPadding = noPadding ? 0 : _ui_utils.SCROLLBAR_PADDING;
  9802. var vPadding = noPadding ? 0 : _ui_utils.VERTICAL_PADDING;
  9803. if (!noPadding && this._isScrollModeHorizontal) {
  9804. var _ref2 = [vPadding, hPadding];
  9805. hPadding = _ref2[0];
  9806. vPadding = _ref2[1];
  9807. }
  9808. var pageWidthScale = (this.container.clientWidth - hPadding) / currentPage.width * currentPage.scale;
  9809. var pageHeightScale = (this.container.clientHeight - vPadding) / currentPage.height * currentPage.scale;
  9810. switch (value) {
  9811. case "page-actual":
  9812. scale = 1;
  9813. break;
  9814. case "page-width":
  9815. scale = pageWidthScale;
  9816. break;
  9817. case "page-height":
  9818. scale = pageHeightScale;
  9819. break;
  9820. case "page-fit":
  9821. scale = Math.min(pageWidthScale, pageHeightScale);
  9822. break;
  9823. case "auto":
  9824. var horizontalScale = (0, _ui_utils.isPortraitOrientation)(currentPage) ? pageWidthScale : Math.min(pageHeightScale, pageWidthScale);
  9825. scale = Math.min(_ui_utils.MAX_AUTO_SCALE, horizontalScale);
  9826. break;
  9827. default:
  9828. console.error("".concat(this._name, "._setScale: \"").concat(value, "\" is an unknown zoom value."));
  9829. return;
  9830. }
  9831. this._setScaleUpdatePages(scale, value, noScroll, true);
  9832. }
  9833. }
  9834. }, {
  9835. key: "_resetCurrentPageView",
  9836. value: function _resetCurrentPageView() {
  9837. if (this.isInPresentationMode) {
  9838. this._setScale(this._currentScaleValue, true);
  9839. }
  9840. var pageView = this._pages[this._currentPageNumber - 1];
  9841. this._scrollIntoView({
  9842. pageDiv: pageView.div
  9843. });
  9844. }
  9845. }, {
  9846. key: "scrollPageIntoView",
  9847. value: function scrollPageIntoView(_ref3) {
  9848. var pageNumber = _ref3.pageNumber,
  9849. _ref3$destArray = _ref3.destArray,
  9850. destArray = _ref3$destArray === void 0 ? null : _ref3$destArray,
  9851. _ref3$allowNegativeOf = _ref3.allowNegativeOffset,
  9852. allowNegativeOffset = _ref3$allowNegativeOf === void 0 ? false : _ref3$allowNegativeOf,
  9853. _ref3$ignoreDestinati = _ref3.ignoreDestinationZoom,
  9854. ignoreDestinationZoom = _ref3$ignoreDestinati === void 0 ? false : _ref3$ignoreDestinati;
  9855. if (!this.pdfDocument) {
  9856. return;
  9857. }
  9858. var pageView = Number.isInteger(pageNumber) && this._pages[pageNumber - 1];
  9859. if (!pageView) {
  9860. console.error("".concat(this._name, ".scrollPageIntoView: ") + "\"".concat(pageNumber, "\" is not a valid pageNumber parameter."));
  9861. return;
  9862. }
  9863. if (this.isInPresentationMode || !destArray) {
  9864. this._setCurrentPageNumber(pageNumber, true);
  9865. return;
  9866. }
  9867. var x = 0,
  9868. y = 0;
  9869. var width = 0,
  9870. height = 0,
  9871. widthScale,
  9872. heightScale;
  9873. var changeOrientation = pageView.rotation % 180 !== 0;
  9874. var pageWidth = (changeOrientation ? pageView.height : pageView.width) / pageView.scale / _ui_utils.CSS_UNITS;
  9875. var pageHeight = (changeOrientation ? pageView.width : pageView.height) / pageView.scale / _ui_utils.CSS_UNITS;
  9876. var scale = 0;
  9877. switch (destArray[1].name) {
  9878. case "XYZ":
  9879. x = destArray[2];
  9880. y = destArray[3];
  9881. scale = destArray[4];
  9882. x = x !== null ? x : 0;
  9883. y = y !== null ? y : pageHeight;
  9884. break;
  9885. case "Fit":
  9886. case "FitB":
  9887. scale = "page-fit";
  9888. break;
  9889. case "FitH":
  9890. case "FitBH":
  9891. y = destArray[2];
  9892. scale = "page-width";
  9893. if (y === null && this._location) {
  9894. x = this._location.left;
  9895. y = this._location.top;
  9896. }
  9897. break;
  9898. case "FitV":
  9899. case "FitBV":
  9900. x = destArray[2];
  9901. width = pageWidth;
  9902. height = pageHeight;
  9903. scale = "page-height";
  9904. break;
  9905. case "FitR":
  9906. x = destArray[2];
  9907. y = destArray[3];
  9908. width = destArray[4] - x;
  9909. height = destArray[5] - y;
  9910. var hPadding = this.removePageBorders ? 0 : _ui_utils.SCROLLBAR_PADDING;
  9911. var vPadding = this.removePageBorders ? 0 : _ui_utils.VERTICAL_PADDING;
  9912. widthScale = (this.container.clientWidth - hPadding) / width / _ui_utils.CSS_UNITS;
  9913. heightScale = (this.container.clientHeight - vPadding) / height / _ui_utils.CSS_UNITS;
  9914. scale = Math.min(Math.abs(widthScale), Math.abs(heightScale));
  9915. break;
  9916. default:
  9917. console.error("".concat(this._name, ".scrollPageIntoView: ") + "\"".concat(destArray[1].name, "\" is not a valid destination type."));
  9918. return;
  9919. }
  9920. if (!ignoreDestinationZoom) {
  9921. if (scale && scale !== this._currentScale) {
  9922. this.currentScaleValue = scale;
  9923. } else if (this._currentScale === _ui_utils.UNKNOWN_SCALE) {
  9924. this.currentScaleValue = _ui_utils.DEFAULT_SCALE_VALUE;
  9925. }
  9926. }
  9927. if (scale === "page-fit" && !destArray[4]) {
  9928. this._scrollIntoView({
  9929. pageDiv: pageView.div,
  9930. pageNumber: pageNumber
  9931. });
  9932. return;
  9933. }
  9934. var boundingRect = [pageView.viewport.convertToViewportPoint(x, y), pageView.viewport.convertToViewportPoint(x + width, y + height)];
  9935. var left = Math.min(boundingRect[0][0], boundingRect[1][0]);
  9936. var top = Math.min(boundingRect[0][1], boundingRect[1][1]);
  9937. if (!allowNegativeOffset) {
  9938. left = Math.max(left, 0);
  9939. top = Math.max(top, 0);
  9940. }
  9941. this._scrollIntoView({
  9942. pageDiv: pageView.div,
  9943. pageSpot: {
  9944. left: left,
  9945. top: top
  9946. },
  9947. pageNumber: pageNumber
  9948. });
  9949. }
  9950. }, {
  9951. key: "_updateLocation",
  9952. value: function _updateLocation(firstPage) {
  9953. var currentScale = this._currentScale;
  9954. var currentScaleValue = this._currentScaleValue;
  9955. var normalizedScaleValue = parseFloat(currentScaleValue) === currentScale ? Math.round(currentScale * 10000) / 100 : currentScaleValue;
  9956. var pageNumber = firstPage.id;
  9957. var pdfOpenParams = "#page=" + pageNumber;
  9958. pdfOpenParams += "&zoom=" + normalizedScaleValue;
  9959. var currentPageView = this._pages[pageNumber - 1];
  9960. var container = this.container;
  9961. var topLeft = currentPageView.getPagePoint(container.scrollLeft - firstPage.x, container.scrollTop - firstPage.y);
  9962. var intLeft = Math.round(topLeft[0]);
  9963. var intTop = Math.round(topLeft[1]);
  9964. pdfOpenParams += "," + intLeft + "," + intTop;
  9965. this._location = {
  9966. pageNumber: pageNumber,
  9967. scale: normalizedScaleValue,
  9968. top: intTop,
  9969. left: intLeft,
  9970. rotation: this._pagesRotation,
  9971. pdfOpenParams: pdfOpenParams
  9972. };
  9973. }
  9974. }, {
  9975. key: "_updateHelper",
  9976. value: function _updateHelper(visiblePages) {
  9977. throw new Error("Not implemented: _updateHelper");
  9978. }
  9979. }, {
  9980. key: "update",
  9981. value: function update() {
  9982. var visible = this._getVisiblePages();
  9983. var visiblePages = visible.views,
  9984. numVisiblePages = visiblePages.length;
  9985. if (numVisiblePages === 0) {
  9986. return;
  9987. }
  9988. var newCacheSize = Math.max(DEFAULT_CACHE_SIZE, 2 * numVisiblePages + 1);
  9989. this._buffer.resize(newCacheSize, visiblePages);
  9990. this.renderingQueue.renderHighestPriority(visible);
  9991. this._updateHelper(visiblePages);
  9992. this._updateLocation(visible.first);
  9993. this.eventBus.dispatch("updateviewarea", {
  9994. source: this,
  9995. location: this._location
  9996. });
  9997. }
  9998. }, {
  9999. key: "containsElement",
  10000. value: function containsElement(element) {
  10001. return this.container.contains(element);
  10002. }
  10003. }, {
  10004. key: "focus",
  10005. value: function focus() {
  10006. this.container.focus();
  10007. }
  10008. }, {
  10009. key: "_getCurrentVisiblePage",
  10010. value: function _getCurrentVisiblePage() {
  10011. if (!this.pagesCount) {
  10012. return {
  10013. views: []
  10014. };
  10015. }
  10016. var pageView = this._pages[this._currentPageNumber - 1];
  10017. var element = pageView.div;
  10018. var view = {
  10019. id: pageView.id,
  10020. x: element.offsetLeft + element.clientLeft,
  10021. y: element.offsetTop + element.clientTop,
  10022. view: pageView
  10023. };
  10024. return {
  10025. first: view,
  10026. last: view,
  10027. views: [view]
  10028. };
  10029. }
  10030. }, {
  10031. key: "_getVisiblePages",
  10032. value: function _getVisiblePages() {
  10033. return (0, _ui_utils.getVisibleElements)(this.container, this._pages, true, this._isScrollModeHorizontal);
  10034. }
  10035. }, {
  10036. key: "isPageVisible",
  10037. value: function isPageVisible(pageNumber) {
  10038. if (!this.pdfDocument) {
  10039. return false;
  10040. }
  10041. if (pageNumber < 1 || pageNumber > this.pagesCount) {
  10042. console.error("".concat(this._name, ".isPageVisible: \"").concat(pageNumber, "\" is out of bounds."));
  10043. return false;
  10044. }
  10045. return this._getVisiblePages().views.some(function (view) {
  10046. return view.id === pageNumber;
  10047. });
  10048. }
  10049. }, {
  10050. key: "cleanup",
  10051. value: function cleanup() {
  10052. for (var i = 0, ii = this._pages.length; i < ii; i++) {
  10053. if (this._pages[i] && this._pages[i].renderingState !== _pdf_rendering_queue.RenderingStates.FINISHED) {
  10054. this._pages[i].reset();
  10055. }
  10056. }
  10057. }
  10058. }, {
  10059. key: "_cancelRendering",
  10060. value: function _cancelRendering() {
  10061. for (var i = 0, ii = this._pages.length; i < ii; i++) {
  10062. if (this._pages[i]) {
  10063. this._pages[i].cancelRendering();
  10064. }
  10065. }
  10066. }
  10067. }, {
  10068. key: "_ensurePdfPageLoaded",
  10069. value: function _ensurePdfPageLoaded(pageView) {
  10070. var _this3 = this;
  10071. if (pageView.pdfPage) {
  10072. return Promise.resolve(pageView.pdfPage);
  10073. }
  10074. if (this._pagesRequests.has(pageView)) {
  10075. return this._pagesRequests.get(pageView);
  10076. }
  10077. var promise = this.pdfDocument.getPage(pageView.id).then(function (pdfPage) {
  10078. if (!pageView.pdfPage) {
  10079. pageView.setPdfPage(pdfPage);
  10080. }
  10081. _this3._pagesRequests["delete"](pageView);
  10082. return pdfPage;
  10083. })["catch"](function (reason) {
  10084. console.error("Unable to get page for page view", reason);
  10085. _this3._pagesRequests["delete"](pageView);
  10086. });
  10087. this._pagesRequests.set(pageView, promise);
  10088. return promise;
  10089. }
  10090. }, {
  10091. key: "forceRendering",
  10092. value: function forceRendering(currentlyVisiblePages) {
  10093. var _this4 = this;
  10094. var visiblePages = currentlyVisiblePages || this._getVisiblePages();
  10095. var scrollAhead = this._isScrollModeHorizontal ? this.scroll.right : this.scroll.down;
  10096. var pageView = this.renderingQueue.getHighestPriority(visiblePages, this._pages, scrollAhead);
  10097. if (pageView) {
  10098. this._ensurePdfPageLoaded(pageView).then(function () {
  10099. _this4.renderingQueue.renderView(pageView);
  10100. });
  10101. return true;
  10102. }
  10103. return false;
  10104. }
  10105. }, {
  10106. key: "createTextLayerBuilder",
  10107. value: function createTextLayerBuilder(textLayerDiv, pageIndex, viewport) {
  10108. var enhanceTextSelection = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
  10109. var eventBus = arguments.length > 4 ? arguments[4] : undefined;
  10110. return new _text_layer_builder.TextLayerBuilder({
  10111. textLayerDiv: textLayerDiv,
  10112. eventBus: eventBus,
  10113. pageIndex: pageIndex,
  10114. viewport: viewport,
  10115. findController: this.isInPresentationMode ? null : this.findController,
  10116. enhanceTextSelection: this.isInPresentationMode ? false : enhanceTextSelection
  10117. });
  10118. }
  10119. }, {
  10120. key: "createAnnotationLayerBuilder",
  10121. value: function createAnnotationLayerBuilder(pageDiv, pdfPage) {
  10122. var annotationStorage = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
  10123. var imageResourcesPath = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : "";
  10124. var renderInteractiveForms = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
  10125. var l10n = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : _ui_utils.NullL10n;
  10126. return new _annotation_layer_builder.AnnotationLayerBuilder({
  10127. pageDiv: pageDiv,
  10128. pdfPage: pdfPage,
  10129. annotationStorage: annotationStorage,
  10130. imageResourcesPath: imageResourcesPath,
  10131. renderInteractiveForms: renderInteractiveForms,
  10132. linkService: this.linkService,
  10133. downloadManager: this.downloadManager,
  10134. l10n: l10n
  10135. });
  10136. }
  10137. }, {
  10138. key: "getPagesOverview",
  10139. value: function getPagesOverview() {
  10140. var pagesOverview = this._pages.map(function (pageView) {
  10141. var viewport = pageView.pdfPage.getViewport({
  10142. scale: 1
  10143. });
  10144. return {
  10145. width: viewport.width,
  10146. height: viewport.height,
  10147. rotation: viewport.rotation
  10148. };
  10149. });
  10150. if (!this.enablePrintAutoRotate) {
  10151. return pagesOverview;
  10152. }
  10153. return pagesOverview.map(function (size) {
  10154. if ((0, _ui_utils.isPortraitOrientation)(size)) {
  10155. return size;
  10156. }
  10157. return {
  10158. width: size.height,
  10159. height: size.width,
  10160. rotation: (size.rotation + 90) % 360
  10161. };
  10162. });
  10163. }
  10164. }, {
  10165. key: "_updateScrollMode",
  10166. value: function _updateScrollMode() {
  10167. var pageNumber = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
  10168. var scrollMode = this._scrollMode,
  10169. viewer = this.viewer;
  10170. viewer.classList.toggle("scrollHorizontal", scrollMode === _ui_utils.ScrollMode.HORIZONTAL);
  10171. viewer.classList.toggle("scrollWrapped", scrollMode === _ui_utils.ScrollMode.WRAPPED);
  10172. if (!this.pdfDocument || !pageNumber) {
  10173. return;
  10174. }
  10175. if (this._currentScaleValue && isNaN(this._currentScaleValue)) {
  10176. this._setScale(this._currentScaleValue, true);
  10177. }
  10178. this._setCurrentPageNumber(pageNumber, true);
  10179. this.update();
  10180. }
  10181. }, {
  10182. key: "_updateSpreadMode",
  10183. value: function _updateSpreadMode() {
  10184. var pageNumber = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
  10185. if (!this.pdfDocument) {
  10186. return;
  10187. }
  10188. var viewer = this.viewer,
  10189. pages = this._pages;
  10190. viewer.textContent = "";
  10191. if (this._spreadMode === _ui_utils.SpreadMode.NONE) {
  10192. for (var i = 0, iMax = pages.length; i < iMax; ++i) {
  10193. viewer.appendChild(pages[i].div);
  10194. }
  10195. } else {
  10196. var parity = this._spreadMode - 1;
  10197. var spread = null;
  10198. for (var _i = 0, _iMax = pages.length; _i < _iMax; ++_i) {
  10199. if (spread === null) {
  10200. spread = document.createElement("div");
  10201. spread.className = "spread";
  10202. viewer.appendChild(spread);
  10203. } else if (_i % 2 === parity) {
  10204. spread = spread.cloneNode(false);
  10205. viewer.appendChild(spread);
  10206. }
  10207. spread.appendChild(pages[_i].div);
  10208. }
  10209. }
  10210. if (!pageNumber) {
  10211. return;
  10212. }
  10213. this._setCurrentPageNumber(pageNumber, true);
  10214. this.update();
  10215. }
  10216. }, {
  10217. key: "pagesCount",
  10218. get: function get() {
  10219. return this._pages.length;
  10220. }
  10221. }, {
  10222. key: "pageViewsReady",
  10223. get: function get() {
  10224. if (!this._pagesCapability.settled) {
  10225. return false;
  10226. }
  10227. return this._pages.every(function (pageView) {
  10228. return pageView && pageView.pdfPage;
  10229. });
  10230. }
  10231. }, {
  10232. key: "currentPageNumber",
  10233. get: function get() {
  10234. return this._currentPageNumber;
  10235. },
  10236. set: function set(val) {
  10237. if (!Number.isInteger(val)) {
  10238. throw new Error("Invalid page number.");
  10239. }
  10240. if (!this.pdfDocument) {
  10241. return;
  10242. }
  10243. if (!this._setCurrentPageNumber(val, true)) {
  10244. console.error("".concat(this._name, ".currentPageNumber: \"").concat(val, "\" is not a valid page."));
  10245. }
  10246. }
  10247. }, {
  10248. key: "currentPageLabel",
  10249. get: function get() {
  10250. return this._pageLabels && this._pageLabels[this._currentPageNumber - 1];
  10251. },
  10252. set: function set(val) {
  10253. if (!this.pdfDocument) {
  10254. return;
  10255. }
  10256. var page = val | 0;
  10257. if (this._pageLabels) {
  10258. var i = this._pageLabels.indexOf(val);
  10259. if (i >= 0) {
  10260. page = i + 1;
  10261. }
  10262. }
  10263. if (!this._setCurrentPageNumber(page, true)) {
  10264. console.error("".concat(this._name, ".currentPageLabel: \"").concat(val, "\" is not a valid page."));
  10265. }
  10266. }
  10267. }, {
  10268. key: "currentScale",
  10269. get: function get() {
  10270. return this._currentScale !== _ui_utils.UNKNOWN_SCALE ? this._currentScale : _ui_utils.DEFAULT_SCALE;
  10271. },
  10272. set: function set(val) {
  10273. if (isNaN(val)) {
  10274. throw new Error("Invalid numeric scale.");
  10275. }
  10276. if (!this.pdfDocument) {
  10277. return;
  10278. }
  10279. this._setScale(val, false);
  10280. }
  10281. }, {
  10282. key: "currentScaleValue",
  10283. get: function get() {
  10284. return this._currentScaleValue;
  10285. },
  10286. set: function set(val) {
  10287. if (!this.pdfDocument) {
  10288. return;
  10289. }
  10290. this._setScale(val, false);
  10291. }
  10292. }, {
  10293. key: "pagesRotation",
  10294. get: function get() {
  10295. return this._pagesRotation;
  10296. },
  10297. set: function set(rotation) {
  10298. if (!(0, _ui_utils.isValidRotation)(rotation)) {
  10299. throw new Error("Invalid pages rotation angle.");
  10300. }
  10301. if (!this.pdfDocument) {
  10302. return;
  10303. }
  10304. if (this._pagesRotation === rotation) {
  10305. return;
  10306. }
  10307. this._pagesRotation = rotation;
  10308. var pageNumber = this._currentPageNumber;
  10309. for (var i = 0, ii = this._pages.length; i < ii; i++) {
  10310. var pageView = this._pages[i];
  10311. pageView.update(pageView.scale, rotation);
  10312. }
  10313. if (this._currentScaleValue) {
  10314. this._setScale(this._currentScaleValue, true);
  10315. }
  10316. this.eventBus.dispatch("rotationchanging", {
  10317. source: this,
  10318. pagesRotation: rotation,
  10319. pageNumber: pageNumber
  10320. });
  10321. if (this.defaultRenderingQueue) {
  10322. this.update();
  10323. }
  10324. }
  10325. }, {
  10326. key: "firstPagePromise",
  10327. get: function get() {
  10328. return this.pdfDocument ? this._firstPageCapability.promise : null;
  10329. }
  10330. }, {
  10331. key: "onePageRendered",
  10332. get: function get() {
  10333. return this.pdfDocument ? this._onePageRenderedCapability.promise : null;
  10334. }
  10335. }, {
  10336. key: "pagesPromise",
  10337. get: function get() {
  10338. return this.pdfDocument ? this._pagesCapability.promise : null;
  10339. }
  10340. }, {
  10341. key: "_viewerElement",
  10342. get: function get() {
  10343. throw new Error("Not implemented: _viewerElement");
  10344. }
  10345. }, {
  10346. key: "_isScrollModeHorizontal",
  10347. get: function get() {
  10348. return this.isInPresentationMode ? false : this._scrollMode === _ui_utils.ScrollMode.HORIZONTAL;
  10349. }
  10350. }, {
  10351. key: "isInPresentationMode",
  10352. get: function get() {
  10353. return this.presentationModeState === _ui_utils.PresentationModeState.FULLSCREEN;
  10354. }
  10355. }, {
  10356. key: "isChangingPresentationMode",
  10357. get: function get() {
  10358. return this.presentationModeState === _ui_utils.PresentationModeState.CHANGING;
  10359. }
  10360. }, {
  10361. key: "isHorizontalScrollbarEnabled",
  10362. get: function get() {
  10363. return this.isInPresentationMode ? false : this.container.scrollWidth > this.container.clientWidth;
  10364. }
  10365. }, {
  10366. key: "isVerticalScrollbarEnabled",
  10367. get: function get() {
  10368. return this.isInPresentationMode ? false : this.container.scrollHeight > this.container.clientHeight;
  10369. }
  10370. }, {
  10371. key: "hasEqualPageSizes",
  10372. get: function get() {
  10373. var firstPageView = this._pages[0];
  10374. for (var i = 1, ii = this._pages.length; i < ii; ++i) {
  10375. var pageView = this._pages[i];
  10376. if (pageView.width !== firstPageView.width || pageView.height !== firstPageView.height) {
  10377. return false;
  10378. }
  10379. }
  10380. return true;
  10381. }
  10382. }, {
  10383. key: "optionalContentConfigPromise",
  10384. get: function get() {
  10385. if (!this.pdfDocument) {
  10386. return Promise.resolve(null);
  10387. }
  10388. if (!this._optionalContentConfigPromise) {
  10389. return this.pdfDocument.getOptionalContentConfig();
  10390. }
  10391. return this._optionalContentConfigPromise;
  10392. },
  10393. set: function set(promise) {
  10394. if (!(promise instanceof Promise)) {
  10395. throw new Error("Invalid optionalContentConfigPromise: ".concat(promise));
  10396. }
  10397. if (!this.pdfDocument) {
  10398. return;
  10399. }
  10400. if (!this._optionalContentConfigPromise) {
  10401. return;
  10402. }
  10403. this._optionalContentConfigPromise = promise;
  10404. var _iterator = _createForOfIteratorHelper(this._pages),
  10405. _step;
  10406. try {
  10407. for (_iterator.s(); !(_step = _iterator.n()).done;) {
  10408. var pageView = _step.value;
  10409. pageView.update(pageView.scale, pageView.rotation, promise);
  10410. }
  10411. } catch (err) {
  10412. _iterator.e(err);
  10413. } finally {
  10414. _iterator.f();
  10415. }
  10416. this.update();
  10417. this.eventBus.dispatch("optionalcontentconfigchanged", {
  10418. source: this,
  10419. promise: promise
  10420. });
  10421. }
  10422. }, {
  10423. key: "scrollMode",
  10424. get: function get() {
  10425. return this._scrollMode;
  10426. },
  10427. set: function set(mode) {
  10428. if (this._scrollMode === mode) {
  10429. return;
  10430. }
  10431. if (!(0, _ui_utils.isValidScrollMode)(mode)) {
  10432. throw new Error("Invalid scroll mode: ".concat(mode));
  10433. }
  10434. this._scrollMode = mode;
  10435. this.eventBus.dispatch("scrollmodechanged", {
  10436. source: this,
  10437. mode: mode
  10438. });
  10439. this._updateScrollMode(this._currentPageNumber);
  10440. }
  10441. }, {
  10442. key: "spreadMode",
  10443. get: function get() {
  10444. return this._spreadMode;
  10445. },
  10446. set: function set(mode) {
  10447. if (this._spreadMode === mode) {
  10448. return;
  10449. }
  10450. if (!(0, _ui_utils.isValidSpreadMode)(mode)) {
  10451. throw new Error("Invalid spread mode: ".concat(mode));
  10452. }
  10453. this._spreadMode = mode;
  10454. this.eventBus.dispatch("spreadmodechanged", {
  10455. source: this,
  10456. mode: mode
  10457. });
  10458. this._updateSpreadMode(this._currentPageNumber);
  10459. }
  10460. }]);
  10461. return BaseViewer;
  10462. }();
  10463. exports.BaseViewer = BaseViewer;
  10464. /***/ }),
  10465. /* 31 */
  10466. /***/ (function(module, exports, __webpack_require__) {
  10467. "use strict";
  10468. Object.defineProperty(exports, "__esModule", {
  10469. value: true
  10470. });
  10471. exports.DefaultAnnotationLayerFactory = exports.AnnotationLayerBuilder = void 0;
  10472. var _pdfjsLib = __webpack_require__(8);
  10473. var _ui_utils = __webpack_require__(5);
  10474. var _pdf_link_service = __webpack_require__(23);
  10475. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  10476. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  10477. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  10478. var AnnotationLayerBuilder = /*#__PURE__*/function () {
  10479. function AnnotationLayerBuilder(_ref) {
  10480. var pageDiv = _ref.pageDiv,
  10481. pdfPage = _ref.pdfPage,
  10482. linkService = _ref.linkService,
  10483. downloadManager = _ref.downloadManager,
  10484. _ref$annotationStorag = _ref.annotationStorage,
  10485. annotationStorage = _ref$annotationStorag === void 0 ? null : _ref$annotationStorag,
  10486. _ref$imageResourcesPa = _ref.imageResourcesPath,
  10487. imageResourcesPath = _ref$imageResourcesPa === void 0 ? "" : _ref$imageResourcesPa,
  10488. _ref$renderInteractiv = _ref.renderInteractiveForms,
  10489. renderInteractiveForms = _ref$renderInteractiv === void 0 ? true : _ref$renderInteractiv,
  10490. _ref$l10n = _ref.l10n,
  10491. l10n = _ref$l10n === void 0 ? _ui_utils.NullL10n : _ref$l10n;
  10492. _classCallCheck(this, AnnotationLayerBuilder);
  10493. this.pageDiv = pageDiv;
  10494. this.pdfPage = pdfPage;
  10495. this.linkService = linkService;
  10496. this.downloadManager = downloadManager;
  10497. this.imageResourcesPath = imageResourcesPath;
  10498. this.renderInteractiveForms = renderInteractiveForms;
  10499. this.l10n = l10n;
  10500. this.annotationStorage = annotationStorage;
  10501. this.div = null;
  10502. this._cancelled = false;
  10503. }
  10504. _createClass(AnnotationLayerBuilder, [{
  10505. key: "render",
  10506. value: function render(viewport) {
  10507. var _this = this;
  10508. var intent = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "display";
  10509. return this.pdfPage.getAnnotations({
  10510. intent: intent
  10511. }).then(function (annotations) {
  10512. if (_this._cancelled) {
  10513. return;
  10514. }
  10515. if (annotations.length === 0) {
  10516. return;
  10517. }
  10518. var parameters = {
  10519. viewport: viewport.clone({
  10520. dontFlip: true
  10521. }),
  10522. div: _this.div,
  10523. annotations: annotations,
  10524. page: _this.pdfPage,
  10525. imageResourcesPath: _this.imageResourcesPath,
  10526. renderInteractiveForms: _this.renderInteractiveForms,
  10527. linkService: _this.linkService,
  10528. downloadManager: _this.downloadManager,
  10529. annotationStorage: _this.annotationStorage
  10530. };
  10531. if (_this.div) {
  10532. _pdfjsLib.AnnotationLayer.update(parameters);
  10533. } else {
  10534. _this.div = document.createElement("div");
  10535. _this.div.className = "annotationLayer";
  10536. _this.pageDiv.appendChild(_this.div);
  10537. parameters.div = _this.div;
  10538. _pdfjsLib.AnnotationLayer.render(parameters);
  10539. _this.l10n.translate(_this.div);
  10540. }
  10541. });
  10542. }
  10543. }, {
  10544. key: "cancel",
  10545. value: function cancel() {
  10546. this._cancelled = true;
  10547. }
  10548. }, {
  10549. key: "hide",
  10550. value: function hide() {
  10551. if (!this.div) {
  10552. return;
  10553. }
  10554. this.div.setAttribute("hidden", "true");
  10555. }
  10556. }]);
  10557. return AnnotationLayerBuilder;
  10558. }();
  10559. exports.AnnotationLayerBuilder = AnnotationLayerBuilder;
  10560. var DefaultAnnotationLayerFactory = /*#__PURE__*/function () {
  10561. function DefaultAnnotationLayerFactory() {
  10562. _classCallCheck(this, DefaultAnnotationLayerFactory);
  10563. }
  10564. _createClass(DefaultAnnotationLayerFactory, [{
  10565. key: "createAnnotationLayerBuilder",
  10566. value: function createAnnotationLayerBuilder(pageDiv, pdfPage) {
  10567. var annotationStorage = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
  10568. var imageResourcesPath = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : "";
  10569. var renderInteractiveForms = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : true;
  10570. var l10n = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : _ui_utils.NullL10n;
  10571. return new AnnotationLayerBuilder({
  10572. pageDiv: pageDiv,
  10573. pdfPage: pdfPage,
  10574. imageResourcesPath: imageResourcesPath,
  10575. renderInteractiveForms: renderInteractiveForms,
  10576. linkService: new _pdf_link_service.SimpleLinkService(),
  10577. l10n: l10n,
  10578. annotationStorage: annotationStorage
  10579. });
  10580. }
  10581. }]);
  10582. return DefaultAnnotationLayerFactory;
  10583. }();
  10584. exports.DefaultAnnotationLayerFactory = DefaultAnnotationLayerFactory;
  10585. /***/ }),
  10586. /* 32 */
  10587. /***/ (function(module, exports, __webpack_require__) {
  10588. "use strict";
  10589. Object.defineProperty(exports, "__esModule", {
  10590. value: true
  10591. });
  10592. exports.PDFPageView = void 0;
  10593. var _regenerator = _interopRequireDefault(__webpack_require__(2));
  10594. var _ui_utils = __webpack_require__(5);
  10595. var _pdfjsLib = __webpack_require__(8);
  10596. var _pdf_rendering_queue = __webpack_require__(11);
  10597. var _viewer_compatibility = __webpack_require__(7);
  10598. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  10599. function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
  10600. function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
  10601. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  10602. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  10603. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  10604. var MAX_CANVAS_PIXELS = _viewer_compatibility.viewerCompatibilityParams.maxCanvasPixels || 16777216;
  10605. var PDFPageView = /*#__PURE__*/function () {
  10606. function PDFPageView(options) {
  10607. _classCallCheck(this, PDFPageView);
  10608. var container = options.container;
  10609. var defaultViewport = options.defaultViewport;
  10610. this.id = options.id;
  10611. this.renderingId = "page" + this.id;
  10612. this.pdfPage = null;
  10613. this.pageLabel = null;
  10614. this.rotation = 0;
  10615. this.scale = options.scale || _ui_utils.DEFAULT_SCALE;
  10616. this.viewport = defaultViewport;
  10617. this.pdfPageRotate = defaultViewport.rotation;
  10618. this._annotationStorage = options.annotationStorage || null;
  10619. this._optionalContentConfigPromise = options.optionalContentConfigPromise || null;
  10620. this.hasRestrictedScaling = false;
  10621. this.textLayerMode = Number.isInteger(options.textLayerMode) ? options.textLayerMode : _ui_utils.TextLayerMode.ENABLE;
  10622. this.imageResourcesPath = options.imageResourcesPath || "";
  10623. this.renderInteractiveForms = typeof options.renderInteractiveForms === "boolean" ? options.renderInteractiveForms : true;
  10624. this.useOnlyCssZoom = options.useOnlyCssZoom || false;
  10625. this.maxCanvasPixels = options.maxCanvasPixels || MAX_CANVAS_PIXELS;
  10626. this.eventBus = options.eventBus;
  10627. this.renderingQueue = options.renderingQueue;
  10628. this.textLayerFactory = options.textLayerFactory;
  10629. this.annotationLayerFactory = options.annotationLayerFactory;
  10630. this.renderer = options.renderer || _ui_utils.RendererType.CANVAS;
  10631. this.enableWebGL = options.enableWebGL || false;
  10632. this.l10n = options.l10n || _ui_utils.NullL10n;
  10633. this.paintTask = null;
  10634. this.paintedViewportMap = new WeakMap();
  10635. this.renderingState = _pdf_rendering_queue.RenderingStates.INITIAL;
  10636. this.resume = null;
  10637. this.error = null;
  10638. this.annotationLayer = null;
  10639. this.textLayer = null;
  10640. this.zoomLayer = null;
  10641. var div = document.createElement("div");
  10642. div.className = "page";
  10643. div.style.width = Math.floor(this.viewport.width) + "px";
  10644. div.style.height = Math.floor(this.viewport.height) + "px";
  10645. div.setAttribute("data-page-number", this.id);
  10646. this.div = div;
  10647. container.appendChild(div);
  10648. }
  10649. _createClass(PDFPageView, [{
  10650. key: "setPdfPage",
  10651. value: function setPdfPage(pdfPage) {
  10652. this.pdfPage = pdfPage;
  10653. this.pdfPageRotate = pdfPage.rotate;
  10654. var totalRotation = (this.rotation + this.pdfPageRotate) % 360;
  10655. this.viewport = pdfPage.getViewport({
  10656. scale: this.scale * _ui_utils.CSS_UNITS,
  10657. rotation: totalRotation
  10658. });
  10659. this.stats = pdfPage.stats;
  10660. this.reset();
  10661. }
  10662. }, {
  10663. key: "destroy",
  10664. value: function destroy() {
  10665. this.reset();
  10666. if (this.pdfPage) {
  10667. this.pdfPage.cleanup();
  10668. }
  10669. }
  10670. }, {
  10671. key: "_renderAnnotationLayer",
  10672. value: function () {
  10673. var _renderAnnotationLayer2 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
  10674. var error;
  10675. return _regenerator["default"].wrap(function _callee$(_context) {
  10676. while (1) {
  10677. switch (_context.prev = _context.next) {
  10678. case 0:
  10679. error = null;
  10680. _context.prev = 1;
  10681. _context.next = 4;
  10682. return this.annotationLayer.render(this.viewport, "display");
  10683. case 4:
  10684. _context.next = 9;
  10685. break;
  10686. case 6:
  10687. _context.prev = 6;
  10688. _context.t0 = _context["catch"](1);
  10689. error = _context.t0;
  10690. case 9:
  10691. _context.prev = 9;
  10692. this.eventBus.dispatch("annotationlayerrendered", {
  10693. source: this,
  10694. pageNumber: this.id,
  10695. error: error
  10696. });
  10697. return _context.finish(9);
  10698. case 12:
  10699. case "end":
  10700. return _context.stop();
  10701. }
  10702. }
  10703. }, _callee, this, [[1, 6, 9, 12]]);
  10704. }));
  10705. function _renderAnnotationLayer() {
  10706. return _renderAnnotationLayer2.apply(this, arguments);
  10707. }
  10708. return _renderAnnotationLayer;
  10709. }()
  10710. }, {
  10711. key: "_resetZoomLayer",
  10712. value: function _resetZoomLayer() {
  10713. var removeFromDOM = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  10714. if (!this.zoomLayer) {
  10715. return;
  10716. }
  10717. var zoomLayerCanvas = this.zoomLayer.firstChild;
  10718. this.paintedViewportMap["delete"](zoomLayerCanvas);
  10719. zoomLayerCanvas.width = 0;
  10720. zoomLayerCanvas.height = 0;
  10721. if (removeFromDOM) {
  10722. this.zoomLayer.remove();
  10723. }
  10724. this.zoomLayer = null;
  10725. }
  10726. }, {
  10727. key: "reset",
  10728. value: function reset() {
  10729. var keepZoomLayer = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  10730. var keepAnnotations = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  10731. this.cancelRendering(keepAnnotations);
  10732. this.renderingState = _pdf_rendering_queue.RenderingStates.INITIAL;
  10733. var div = this.div;
  10734. div.style.width = Math.floor(this.viewport.width) + "px";
  10735. div.style.height = Math.floor(this.viewport.height) + "px";
  10736. var childNodes = div.childNodes;
  10737. var currentZoomLayerNode = keepZoomLayer && this.zoomLayer || null;
  10738. var currentAnnotationNode = keepAnnotations && this.annotationLayer && this.annotationLayer.div || null;
  10739. for (var i = childNodes.length - 1; i >= 0; i--) {
  10740. var node = childNodes[i];
  10741. if (currentZoomLayerNode === node || currentAnnotationNode === node) {
  10742. continue;
  10743. }
  10744. div.removeChild(node);
  10745. }
  10746. div.removeAttribute("data-loaded");
  10747. if (currentAnnotationNode) {
  10748. this.annotationLayer.hide();
  10749. } else if (this.annotationLayer) {
  10750. this.annotationLayer.cancel();
  10751. this.annotationLayer = null;
  10752. }
  10753. if (!currentZoomLayerNode) {
  10754. if (this.canvas) {
  10755. this.paintedViewportMap["delete"](this.canvas);
  10756. this.canvas.width = 0;
  10757. this.canvas.height = 0;
  10758. delete this.canvas;
  10759. }
  10760. this._resetZoomLayer();
  10761. }
  10762. if (this.svg) {
  10763. this.paintedViewportMap["delete"](this.svg);
  10764. delete this.svg;
  10765. }
  10766. this.loadingIconDiv = document.createElement("div");
  10767. this.loadingIconDiv.className = "loadingIcon";
  10768. div.appendChild(this.loadingIconDiv);
  10769. }
  10770. }, {
  10771. key: "update",
  10772. value: function update(scale, rotation) {
  10773. var optionalContentConfigPromise = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
  10774. this.scale = scale || this.scale;
  10775. if (typeof rotation !== "undefined") {
  10776. this.rotation = rotation;
  10777. }
  10778. if (optionalContentConfigPromise instanceof Promise) {
  10779. this._optionalContentConfigPromise = optionalContentConfigPromise;
  10780. }
  10781. var totalRotation = (this.rotation + this.pdfPageRotate) % 360;
  10782. this.viewport = this.viewport.clone({
  10783. scale: this.scale * _ui_utils.CSS_UNITS,
  10784. rotation: totalRotation
  10785. });
  10786. if (this.svg) {
  10787. this.cssTransform(this.svg, true);
  10788. this.eventBus.dispatch("pagerendered", {
  10789. source: this,
  10790. pageNumber: this.id,
  10791. cssTransform: true,
  10792. timestamp: performance.now()
  10793. });
  10794. return;
  10795. }
  10796. var isScalingRestricted = false;
  10797. if (this.canvas && this.maxCanvasPixels > 0) {
  10798. var outputScale = this.outputScale;
  10799. if ((Math.floor(this.viewport.width) * outputScale.sx | 0) * (Math.floor(this.viewport.height) * outputScale.sy | 0) > this.maxCanvasPixels) {
  10800. isScalingRestricted = true;
  10801. }
  10802. }
  10803. if (this.canvas) {
  10804. if (this.useOnlyCssZoom || this.hasRestrictedScaling && isScalingRestricted) {
  10805. this.cssTransform(this.canvas, true);
  10806. this.eventBus.dispatch("pagerendered", {
  10807. source: this,
  10808. pageNumber: this.id,
  10809. cssTransform: true,
  10810. timestamp: performance.now()
  10811. });
  10812. return;
  10813. }
  10814. if (!this.zoomLayer && !this.canvas.hasAttribute("hidden")) {
  10815. this.zoomLayer = this.canvas.parentNode;
  10816. this.zoomLayer.style.position = "absolute";
  10817. }
  10818. }
  10819. if (this.zoomLayer) {
  10820. this.cssTransform(this.zoomLayer.firstChild);
  10821. }
  10822. this.reset(true, true);
  10823. }
  10824. }, {
  10825. key: "cancelRendering",
  10826. value: function cancelRendering() {
  10827. var keepAnnotations = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  10828. if (this.paintTask) {
  10829. this.paintTask.cancel();
  10830. this.paintTask = null;
  10831. }
  10832. this.resume = null;
  10833. if (this.textLayer) {
  10834. this.textLayer.cancel();
  10835. this.textLayer = null;
  10836. }
  10837. if (!keepAnnotations && this.annotationLayer) {
  10838. this.annotationLayer.cancel();
  10839. this.annotationLayer = null;
  10840. }
  10841. }
  10842. }, {
  10843. key: "cssTransform",
  10844. value: function cssTransform(target) {
  10845. var redrawAnnotations = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  10846. var width = this.viewport.width;
  10847. var height = this.viewport.height;
  10848. var div = this.div;
  10849. target.style.width = target.parentNode.style.width = div.style.width = Math.floor(width) + "px";
  10850. target.style.height = target.parentNode.style.height = div.style.height = Math.floor(height) + "px";
  10851. var relativeRotation = this.viewport.rotation - this.paintedViewportMap.get(target).rotation;
  10852. var absRotation = Math.abs(relativeRotation);
  10853. var scaleX = 1,
  10854. scaleY = 1;
  10855. if (absRotation === 90 || absRotation === 270) {
  10856. scaleX = height / width;
  10857. scaleY = width / height;
  10858. }
  10859. var cssTransform = "rotate(" + relativeRotation + "deg) " + "scale(" + scaleX + "," + scaleY + ")";
  10860. target.style.transform = cssTransform;
  10861. if (this.textLayer) {
  10862. var textLayerViewport = this.textLayer.viewport;
  10863. var textRelativeRotation = this.viewport.rotation - textLayerViewport.rotation;
  10864. var textAbsRotation = Math.abs(textRelativeRotation);
  10865. var scale = width / textLayerViewport.width;
  10866. if (textAbsRotation === 90 || textAbsRotation === 270) {
  10867. scale = width / textLayerViewport.height;
  10868. }
  10869. var textLayerDiv = this.textLayer.textLayerDiv;
  10870. var transX, transY;
  10871. switch (textAbsRotation) {
  10872. case 0:
  10873. transX = transY = 0;
  10874. break;
  10875. case 90:
  10876. transX = 0;
  10877. transY = "-" + textLayerDiv.style.height;
  10878. break;
  10879. case 180:
  10880. transX = "-" + textLayerDiv.style.width;
  10881. transY = "-" + textLayerDiv.style.height;
  10882. break;
  10883. case 270:
  10884. transX = "-" + textLayerDiv.style.width;
  10885. transY = 0;
  10886. break;
  10887. default:
  10888. console.error("Bad rotation value.");
  10889. break;
  10890. }
  10891. textLayerDiv.style.transform = "rotate(" + textAbsRotation + "deg) " + "scale(" + scale + ", " + scale + ") " + "translate(" + transX + ", " + transY + ")";
  10892. textLayerDiv.style.transformOrigin = "0% 0%";
  10893. }
  10894. if (redrawAnnotations && this.annotationLayer) {
  10895. this._renderAnnotationLayer();
  10896. }
  10897. }
  10898. }, {
  10899. key: "getPagePoint",
  10900. value: function getPagePoint(x, y) {
  10901. return this.viewport.convertToPdfPoint(x, y);
  10902. }
  10903. }, {
  10904. key: "draw",
  10905. value: function draw() {
  10906. var _this = this;
  10907. if (this.renderingState !== _pdf_rendering_queue.RenderingStates.INITIAL) {
  10908. console.error("Must be in new state before drawing");
  10909. this.reset();
  10910. }
  10911. var div = this.div,
  10912. pdfPage = this.pdfPage;
  10913. if (!pdfPage) {
  10914. this.renderingState = _pdf_rendering_queue.RenderingStates.FINISHED;
  10915. if (this.loadingIconDiv) {
  10916. div.removeChild(this.loadingIconDiv);
  10917. delete this.loadingIconDiv;
  10918. }
  10919. return Promise.reject(new Error("pdfPage is not loaded"));
  10920. }
  10921. this.renderingState = _pdf_rendering_queue.RenderingStates.RUNNING;
  10922. var canvasWrapper = document.createElement("div");
  10923. canvasWrapper.style.width = div.style.width;
  10924. canvasWrapper.style.height = div.style.height;
  10925. canvasWrapper.classList.add("canvasWrapper");
  10926. if (this.annotationLayer && this.annotationLayer.div) {
  10927. div.insertBefore(canvasWrapper, this.annotationLayer.div);
  10928. } else {
  10929. div.appendChild(canvasWrapper);
  10930. }
  10931. var textLayer = null;
  10932. if (this.textLayerMode !== _ui_utils.TextLayerMode.DISABLE && this.textLayerFactory) {
  10933. var textLayerDiv = document.createElement("div");
  10934. textLayerDiv.className = "textLayer";
  10935. textLayerDiv.style.width = canvasWrapper.style.width;
  10936. textLayerDiv.style.height = canvasWrapper.style.height;
  10937. if (this.annotationLayer && this.annotationLayer.div) {
  10938. div.insertBefore(textLayerDiv, this.annotationLayer.div);
  10939. } else {
  10940. div.appendChild(textLayerDiv);
  10941. }
  10942. textLayer = this.textLayerFactory.createTextLayerBuilder(textLayerDiv, this.id - 1, this.viewport, this.textLayerMode === _ui_utils.TextLayerMode.ENABLE_ENHANCE, this.eventBus);
  10943. }
  10944. this.textLayer = textLayer;
  10945. var renderContinueCallback = null;
  10946. if (this.renderingQueue) {
  10947. renderContinueCallback = function renderContinueCallback(cont) {
  10948. if (!_this.renderingQueue.isHighestPriority(_this)) {
  10949. _this.renderingState = _pdf_rendering_queue.RenderingStates.PAUSED;
  10950. _this.resume = function () {
  10951. _this.renderingState = _pdf_rendering_queue.RenderingStates.RUNNING;
  10952. cont();
  10953. };
  10954. return;
  10955. }
  10956. cont();
  10957. };
  10958. }
  10959. var finishPaintTask = /*#__PURE__*/function () {
  10960. var _ref = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee2(error) {
  10961. return _regenerator["default"].wrap(function _callee2$(_context2) {
  10962. while (1) {
  10963. switch (_context2.prev = _context2.next) {
  10964. case 0:
  10965. if (paintTask === _this.paintTask) {
  10966. _this.paintTask = null;
  10967. }
  10968. if (!(error instanceof _pdfjsLib.RenderingCancelledException)) {
  10969. _context2.next = 4;
  10970. break;
  10971. }
  10972. _this.error = null;
  10973. return _context2.abrupt("return");
  10974. case 4:
  10975. _this.renderingState = _pdf_rendering_queue.RenderingStates.FINISHED;
  10976. if (_this.loadingIconDiv) {
  10977. div.removeChild(_this.loadingIconDiv);
  10978. delete _this.loadingIconDiv;
  10979. }
  10980. _this._resetZoomLayer(true);
  10981. _this.error = error;
  10982. _this.stats = pdfPage.stats;
  10983. _this.eventBus.dispatch("pagerendered", {
  10984. source: _this,
  10985. pageNumber: _this.id,
  10986. cssTransform: false,
  10987. timestamp: performance.now()
  10988. });
  10989. if (!error) {
  10990. _context2.next = 12;
  10991. break;
  10992. }
  10993. throw error;
  10994. case 12:
  10995. case "end":
  10996. return _context2.stop();
  10997. }
  10998. }
  10999. }, _callee2);
  11000. }));
  11001. return function finishPaintTask(_x) {
  11002. return _ref.apply(this, arguments);
  11003. };
  11004. }();
  11005. var paintTask = this.renderer === _ui_utils.RendererType.SVG ? this.paintOnSvg(canvasWrapper) : this.paintOnCanvas(canvasWrapper);
  11006. paintTask.onRenderContinue = renderContinueCallback;
  11007. this.paintTask = paintTask;
  11008. var resultPromise = paintTask.promise.then(function () {
  11009. return finishPaintTask(null).then(function () {
  11010. if (textLayer) {
  11011. var readableStream = pdfPage.streamTextContent({
  11012. normalizeWhitespace: true
  11013. });
  11014. textLayer.setTextContentStream(readableStream);
  11015. textLayer.render();
  11016. }
  11017. });
  11018. }, function (reason) {
  11019. return finishPaintTask(reason);
  11020. });
  11021. if (this.annotationLayerFactory) {
  11022. if (!this.annotationLayer) {
  11023. this.annotationLayer = this.annotationLayerFactory.createAnnotationLayerBuilder(div, pdfPage, this._annotationStorage, this.imageResourcesPath, this.renderInteractiveForms, this.l10n);
  11024. }
  11025. this._renderAnnotationLayer();
  11026. }
  11027. div.setAttribute("data-loaded", true);
  11028. this.eventBus.dispatch("pagerender", {
  11029. source: this,
  11030. pageNumber: this.id
  11031. });
  11032. return resultPromise;
  11033. }
  11034. }, {
  11035. key: "paintOnCanvas",
  11036. value: function paintOnCanvas(canvasWrapper) {
  11037. var renderCapability = (0, _pdfjsLib.createPromiseCapability)();
  11038. var result = {
  11039. promise: renderCapability.promise,
  11040. onRenderContinue: function onRenderContinue(cont) {
  11041. cont();
  11042. },
  11043. cancel: function cancel() {
  11044. renderTask.cancel();
  11045. }
  11046. };
  11047. var viewport = this.viewport;
  11048. var canvas = document.createElement("canvas");
  11049. this.l10n.get("page_canvas", {
  11050. page: this.id
  11051. }, "Page {{page}}").then(function (msg) {
  11052. canvas.setAttribute("aria-label", msg);
  11053. });
  11054. canvas.setAttribute("hidden", "hidden");
  11055. var isCanvasHidden = true;
  11056. var showCanvas = function showCanvas() {
  11057. if (isCanvasHidden) {
  11058. canvas.removeAttribute("hidden");
  11059. isCanvasHidden = false;
  11060. }
  11061. };
  11062. canvasWrapper.appendChild(canvas);
  11063. this.canvas = canvas;
  11064. canvas.mozOpaque = true;
  11065. var ctx = canvas.getContext("2d", {
  11066. alpha: false
  11067. });
  11068. var outputScale = (0, _ui_utils.getOutputScale)(ctx);
  11069. this.outputScale = outputScale;
  11070. if (this.useOnlyCssZoom) {
  11071. var actualSizeViewport = viewport.clone({
  11072. scale: _ui_utils.CSS_UNITS
  11073. });
  11074. outputScale.sx *= actualSizeViewport.width / viewport.width;
  11075. outputScale.sy *= actualSizeViewport.height / viewport.height;
  11076. outputScale.scaled = true;
  11077. }
  11078. if (this.maxCanvasPixels > 0) {
  11079. var pixelsInViewport = viewport.width * viewport.height;
  11080. var maxScale = Math.sqrt(this.maxCanvasPixels / pixelsInViewport);
  11081. if (outputScale.sx > maxScale || outputScale.sy > maxScale) {
  11082. outputScale.sx = maxScale;
  11083. outputScale.sy = maxScale;
  11084. outputScale.scaled = true;
  11085. this.hasRestrictedScaling = true;
  11086. } else {
  11087. this.hasRestrictedScaling = false;
  11088. }
  11089. }
  11090. var sfx = (0, _ui_utils.approximateFraction)(outputScale.sx);
  11091. var sfy = (0, _ui_utils.approximateFraction)(outputScale.sy);
  11092. canvas.width = (0, _ui_utils.roundToDivide)(viewport.width * outputScale.sx, sfx[0]);
  11093. canvas.height = (0, _ui_utils.roundToDivide)(viewport.height * outputScale.sy, sfy[0]);
  11094. canvas.style.width = (0, _ui_utils.roundToDivide)(viewport.width, sfx[1]) + "px";
  11095. canvas.style.height = (0, _ui_utils.roundToDivide)(viewport.height, sfy[1]) + "px";
  11096. this.paintedViewportMap.set(canvas, viewport);
  11097. var transform = !outputScale.scaled ? null : [outputScale.sx, 0, 0, outputScale.sy, 0, 0];
  11098. var renderContext = {
  11099. canvasContext: ctx,
  11100. transform: transform,
  11101. viewport: this.viewport,
  11102. enableWebGL: this.enableWebGL,
  11103. renderInteractiveForms: this.renderInteractiveForms,
  11104. optionalContentConfigPromise: this._optionalContentConfigPromise
  11105. };
  11106. var renderTask = this.pdfPage.render(renderContext);
  11107. renderTask.onContinue = function (cont) {
  11108. showCanvas();
  11109. if (result.onRenderContinue) {
  11110. result.onRenderContinue(cont);
  11111. } else {
  11112. cont();
  11113. }
  11114. };
  11115. renderTask.promise.then(function () {
  11116. showCanvas();
  11117. renderCapability.resolve(undefined);
  11118. }, function (error) {
  11119. showCanvas();
  11120. renderCapability.reject(error);
  11121. });
  11122. return result;
  11123. }
  11124. }, {
  11125. key: "paintOnSvg",
  11126. value: function paintOnSvg(wrapper) {
  11127. var _this2 = this;
  11128. var cancelled = false;
  11129. var ensureNotCancelled = function ensureNotCancelled() {
  11130. if (cancelled) {
  11131. throw new _pdfjsLib.RenderingCancelledException("Rendering cancelled, page ".concat(_this2.id), "svg");
  11132. }
  11133. };
  11134. var pdfPage = this.pdfPage;
  11135. var actualSizeViewport = this.viewport.clone({
  11136. scale: _ui_utils.CSS_UNITS
  11137. });
  11138. var promise = pdfPage.getOperatorList().then(function (opList) {
  11139. ensureNotCancelled();
  11140. var svgGfx = new _pdfjsLib.SVGGraphics(pdfPage.commonObjs, pdfPage.objs);
  11141. return svgGfx.getSVG(opList, actualSizeViewport).then(function (svg) {
  11142. ensureNotCancelled();
  11143. _this2.svg = svg;
  11144. _this2.paintedViewportMap.set(svg, actualSizeViewport);
  11145. svg.style.width = wrapper.style.width;
  11146. svg.style.height = wrapper.style.height;
  11147. _this2.renderingState = _pdf_rendering_queue.RenderingStates.FINISHED;
  11148. wrapper.appendChild(svg);
  11149. });
  11150. });
  11151. return {
  11152. promise: promise,
  11153. onRenderContinue: function onRenderContinue(cont) {
  11154. cont();
  11155. },
  11156. cancel: function cancel() {
  11157. cancelled = true;
  11158. }
  11159. };
  11160. }
  11161. }, {
  11162. key: "setPageLabel",
  11163. value: function setPageLabel(label) {
  11164. this.pageLabel = typeof label === "string" ? label : null;
  11165. if (this.pageLabel !== null) {
  11166. this.div.setAttribute("data-page-label", this.pageLabel);
  11167. } else {
  11168. this.div.removeAttribute("data-page-label");
  11169. }
  11170. }
  11171. }, {
  11172. key: "width",
  11173. get: function get() {
  11174. return this.viewport.width;
  11175. }
  11176. }, {
  11177. key: "height",
  11178. get: function get() {
  11179. return this.viewport.height;
  11180. }
  11181. }]);
  11182. return PDFPageView;
  11183. }();
  11184. exports.PDFPageView = PDFPageView;
  11185. /***/ }),
  11186. /* 33 */
  11187. /***/ (function(module, exports, __webpack_require__) {
  11188. "use strict";
  11189. Object.defineProperty(exports, "__esModule", {
  11190. value: true
  11191. });
  11192. exports.DefaultTextLayerFactory = exports.TextLayerBuilder = void 0;
  11193. var _pdfjsLib = __webpack_require__(8);
  11194. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  11195. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  11196. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  11197. var EXPAND_DIVS_TIMEOUT = 300;
  11198. var TextLayerBuilder = /*#__PURE__*/function () {
  11199. function TextLayerBuilder(_ref) {
  11200. var textLayerDiv = _ref.textLayerDiv,
  11201. eventBus = _ref.eventBus,
  11202. pageIndex = _ref.pageIndex,
  11203. viewport = _ref.viewport,
  11204. _ref$findController = _ref.findController,
  11205. findController = _ref$findController === void 0 ? null : _ref$findController,
  11206. _ref$enhanceTextSelec = _ref.enhanceTextSelection,
  11207. enhanceTextSelection = _ref$enhanceTextSelec === void 0 ? false : _ref$enhanceTextSelec;
  11208. _classCallCheck(this, TextLayerBuilder);
  11209. this.textLayerDiv = textLayerDiv;
  11210. this.eventBus = eventBus;
  11211. this.textContent = null;
  11212. this.textContentItemsStr = [];
  11213. this.textContentStream = null;
  11214. this.renderingDone = false;
  11215. this.pageIdx = pageIndex;
  11216. this.pageNumber = this.pageIdx + 1;
  11217. this.matches = [];
  11218. this.viewport = viewport;
  11219. this.textDivs = [];
  11220. this.findController = findController;
  11221. this.textLayerRenderTask = null;
  11222. this.enhanceTextSelection = enhanceTextSelection;
  11223. this._onUpdateTextLayerMatches = null;
  11224. this._bindMouse();
  11225. }
  11226. _createClass(TextLayerBuilder, [{
  11227. key: "_finishRendering",
  11228. value: function _finishRendering() {
  11229. this.renderingDone = true;
  11230. if (!this.enhanceTextSelection) {
  11231. var endOfContent = document.createElement("div");
  11232. endOfContent.className = "endOfContent";
  11233. this.textLayerDiv.appendChild(endOfContent);
  11234. }
  11235. this.eventBus.dispatch("textlayerrendered", {
  11236. source: this,
  11237. pageNumber: this.pageNumber,
  11238. numTextDivs: this.textDivs.length
  11239. });
  11240. }
  11241. }, {
  11242. key: "render",
  11243. value: function render() {
  11244. var _this = this;
  11245. var timeout = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
  11246. if (!(this.textContent || this.textContentStream) || this.renderingDone) {
  11247. return;
  11248. }
  11249. this.cancel();
  11250. this.textDivs = [];
  11251. var textLayerFrag = document.createDocumentFragment();
  11252. this.textLayerRenderTask = (0, _pdfjsLib.renderTextLayer)({
  11253. textContent: this.textContent,
  11254. textContentStream: this.textContentStream,
  11255. container: textLayerFrag,
  11256. viewport: this.viewport,
  11257. textDivs: this.textDivs,
  11258. textContentItemsStr: this.textContentItemsStr,
  11259. timeout: timeout,
  11260. enhanceTextSelection: this.enhanceTextSelection
  11261. });
  11262. this.textLayerRenderTask.promise.then(function () {
  11263. _this.textLayerDiv.appendChild(textLayerFrag);
  11264. _this._finishRendering();
  11265. _this._updateMatches();
  11266. }, function (reason) {});
  11267. if (!this._onUpdateTextLayerMatches) {
  11268. this._onUpdateTextLayerMatches = function (evt) {
  11269. if (evt.pageIndex === _this.pageIdx || evt.pageIndex === -1) {
  11270. _this._updateMatches();
  11271. }
  11272. };
  11273. this.eventBus._on("updatetextlayermatches", this._onUpdateTextLayerMatches);
  11274. }
  11275. }
  11276. }, {
  11277. key: "cancel",
  11278. value: function cancel() {
  11279. if (this.textLayerRenderTask) {
  11280. this.textLayerRenderTask.cancel();
  11281. this.textLayerRenderTask = null;
  11282. }
  11283. if (this._onUpdateTextLayerMatches) {
  11284. this.eventBus._off("updatetextlayermatches", this._onUpdateTextLayerMatches);
  11285. this._onUpdateTextLayerMatches = null;
  11286. }
  11287. }
  11288. }, {
  11289. key: "setTextContentStream",
  11290. value: function setTextContentStream(readableStream) {
  11291. this.cancel();
  11292. this.textContentStream = readableStream;
  11293. }
  11294. }, {
  11295. key: "setTextContent",
  11296. value: function setTextContent(textContent) {
  11297. this.cancel();
  11298. this.textContent = textContent;
  11299. }
  11300. }, {
  11301. key: "_convertMatches",
  11302. value: function _convertMatches(matches, matchesLength) {
  11303. if (!matches) {
  11304. return [];
  11305. }
  11306. var findController = this.findController,
  11307. textContentItemsStr = this.textContentItemsStr;
  11308. var i = 0,
  11309. iIndex = 0;
  11310. var end = textContentItemsStr.length - 1;
  11311. var queryLen = findController.state.query.length;
  11312. var result = [];
  11313. for (var m = 0, mm = matches.length; m < mm; m++) {
  11314. var matchIdx = matches[m];
  11315. while (i !== end && matchIdx >= iIndex + textContentItemsStr[i].length) {
  11316. iIndex += textContentItemsStr[i].length;
  11317. i++;
  11318. }
  11319. if (i === textContentItemsStr.length) {
  11320. console.error("Could not find a matching mapping");
  11321. }
  11322. var match = {
  11323. begin: {
  11324. divIdx: i,
  11325. offset: matchIdx - iIndex
  11326. }
  11327. };
  11328. if (matchesLength) {
  11329. matchIdx += matchesLength[m];
  11330. } else {
  11331. matchIdx += queryLen;
  11332. }
  11333. while (i !== end && matchIdx > iIndex + textContentItemsStr[i].length) {
  11334. iIndex += textContentItemsStr[i].length;
  11335. i++;
  11336. }
  11337. match.end = {
  11338. divIdx: i,
  11339. offset: matchIdx - iIndex
  11340. };
  11341. result.push(match);
  11342. }
  11343. return result;
  11344. }
  11345. }, {
  11346. key: "_renderMatches",
  11347. value: function _renderMatches(matches) {
  11348. if (matches.length === 0) {
  11349. return;
  11350. }
  11351. var findController = this.findController,
  11352. pageIdx = this.pageIdx,
  11353. textContentItemsStr = this.textContentItemsStr,
  11354. textDivs = this.textDivs;
  11355. var isSelectedPage = pageIdx === findController.selected.pageIdx;
  11356. var selectedMatchIdx = findController.selected.matchIdx;
  11357. var highlightAll = findController.state.highlightAll;
  11358. var prevEnd = null;
  11359. var infinity = {
  11360. divIdx: -1,
  11361. offset: undefined
  11362. };
  11363. function beginText(begin, className) {
  11364. var divIdx = begin.divIdx;
  11365. textDivs[divIdx].textContent = "";
  11366. appendTextToDiv(divIdx, 0, begin.offset, className);
  11367. }
  11368. function appendTextToDiv(divIdx, fromOffset, toOffset, className) {
  11369. var div = textDivs[divIdx];
  11370. var content = textContentItemsStr[divIdx].substring(fromOffset, toOffset);
  11371. var node = document.createTextNode(content);
  11372. if (className) {
  11373. var span = document.createElement("span");
  11374. span.className = className;
  11375. span.appendChild(node);
  11376. div.appendChild(span);
  11377. return;
  11378. }
  11379. div.appendChild(node);
  11380. }
  11381. var i0 = selectedMatchIdx,
  11382. i1 = i0 + 1;
  11383. if (highlightAll) {
  11384. i0 = 0;
  11385. i1 = matches.length;
  11386. } else if (!isSelectedPage) {
  11387. return;
  11388. }
  11389. for (var i = i0; i < i1; i++) {
  11390. var match = matches[i];
  11391. var begin = match.begin;
  11392. var end = match.end;
  11393. var isSelected = isSelectedPage && i === selectedMatchIdx;
  11394. var highlightSuffix = isSelected ? " selected" : "";
  11395. if (isSelected) {
  11396. findController.scrollMatchIntoView({
  11397. element: textDivs[begin.divIdx],
  11398. pageIndex: pageIdx,
  11399. matchIndex: selectedMatchIdx
  11400. });
  11401. }
  11402. if (!prevEnd || begin.divIdx !== prevEnd.divIdx) {
  11403. if (prevEnd !== null) {
  11404. appendTextToDiv(prevEnd.divIdx, prevEnd.offset, infinity.offset);
  11405. }
  11406. beginText(begin);
  11407. } else {
  11408. appendTextToDiv(prevEnd.divIdx, prevEnd.offset, begin.offset);
  11409. }
  11410. if (begin.divIdx === end.divIdx) {
  11411. appendTextToDiv(begin.divIdx, begin.offset, end.offset, "highlight" + highlightSuffix);
  11412. } else {
  11413. appendTextToDiv(begin.divIdx, begin.offset, infinity.offset, "highlight begin" + highlightSuffix);
  11414. for (var n0 = begin.divIdx + 1, n1 = end.divIdx; n0 < n1; n0++) {
  11415. textDivs[n0].className = "highlight middle" + highlightSuffix;
  11416. }
  11417. beginText(end, "highlight end" + highlightSuffix);
  11418. }
  11419. prevEnd = end;
  11420. }
  11421. if (prevEnd) {
  11422. appendTextToDiv(prevEnd.divIdx, prevEnd.offset, infinity.offset);
  11423. }
  11424. }
  11425. }, {
  11426. key: "_updateMatches",
  11427. value: function _updateMatches() {
  11428. if (!this.renderingDone) {
  11429. return;
  11430. }
  11431. var findController = this.findController,
  11432. matches = this.matches,
  11433. pageIdx = this.pageIdx,
  11434. textContentItemsStr = this.textContentItemsStr,
  11435. textDivs = this.textDivs;
  11436. var clearedUntilDivIdx = -1;
  11437. for (var i = 0, ii = matches.length; i < ii; i++) {
  11438. var match = matches[i];
  11439. var begin = Math.max(clearedUntilDivIdx, match.begin.divIdx);
  11440. for (var n = begin, end = match.end.divIdx; n <= end; n++) {
  11441. var div = textDivs[n];
  11442. div.textContent = textContentItemsStr[n];
  11443. div.className = "";
  11444. }
  11445. clearedUntilDivIdx = match.end.divIdx + 1;
  11446. }
  11447. if (!findController || !findController.highlightMatches) {
  11448. return;
  11449. }
  11450. var pageMatches = findController.pageMatches[pageIdx] || null;
  11451. var pageMatchesLength = findController.pageMatchesLength[pageIdx] || null;
  11452. this.matches = this._convertMatches(pageMatches, pageMatchesLength);
  11453. this._renderMatches(this.matches);
  11454. }
  11455. }, {
  11456. key: "_bindMouse",
  11457. value: function _bindMouse() {
  11458. var _this2 = this;
  11459. var div = this.textLayerDiv;
  11460. var expandDivsTimer = null;
  11461. div.addEventListener("mousedown", function (evt) {
  11462. if (_this2.enhanceTextSelection && _this2.textLayerRenderTask) {
  11463. _this2.textLayerRenderTask.expandTextDivs(true);
  11464. if (expandDivsTimer) {
  11465. clearTimeout(expandDivsTimer);
  11466. expandDivsTimer = null;
  11467. }
  11468. return;
  11469. }
  11470. var end = div.querySelector(".endOfContent");
  11471. if (!end) {
  11472. return;
  11473. }
  11474. var adjustTop = evt.target !== div;
  11475. adjustTop = adjustTop && window.getComputedStyle(end).getPropertyValue("-moz-user-select") !== "none";
  11476. if (adjustTop) {
  11477. var divBounds = div.getBoundingClientRect();
  11478. var r = Math.max(0, (evt.pageY - divBounds.top) / divBounds.height);
  11479. end.style.top = (r * 100).toFixed(2) + "%";
  11480. }
  11481. end.classList.add("active");
  11482. });
  11483. div.addEventListener("mouseup", function () {
  11484. if (_this2.enhanceTextSelection && _this2.textLayerRenderTask) {
  11485. expandDivsTimer = setTimeout(function () {
  11486. if (_this2.textLayerRenderTask) {
  11487. _this2.textLayerRenderTask.expandTextDivs(false);
  11488. }
  11489. expandDivsTimer = null;
  11490. }, EXPAND_DIVS_TIMEOUT);
  11491. return;
  11492. }
  11493. var end = div.querySelector(".endOfContent");
  11494. if (!end) {
  11495. return;
  11496. }
  11497. end.style.top = "";
  11498. end.classList.remove("active");
  11499. });
  11500. }
  11501. }]);
  11502. return TextLayerBuilder;
  11503. }();
  11504. exports.TextLayerBuilder = TextLayerBuilder;
  11505. var DefaultTextLayerFactory = /*#__PURE__*/function () {
  11506. function DefaultTextLayerFactory() {
  11507. _classCallCheck(this, DefaultTextLayerFactory);
  11508. }
  11509. _createClass(DefaultTextLayerFactory, [{
  11510. key: "createTextLayerBuilder",
  11511. value: function createTextLayerBuilder(textLayerDiv, pageIndex, viewport) {
  11512. var enhanceTextSelection = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
  11513. var eventBus = arguments.length > 4 ? arguments[4] : undefined;
  11514. return new TextLayerBuilder({
  11515. textLayerDiv: textLayerDiv,
  11516. pageIndex: pageIndex,
  11517. viewport: viewport,
  11518. enhanceTextSelection: enhanceTextSelection,
  11519. eventBus: eventBus
  11520. });
  11521. }
  11522. }]);
  11523. return DefaultTextLayerFactory;
  11524. }();
  11525. exports.DefaultTextLayerFactory = DefaultTextLayerFactory;
  11526. /***/ }),
  11527. /* 34 */
  11528. /***/ (function(module, exports, __webpack_require__) {
  11529. "use strict";
  11530. Object.defineProperty(exports, "__esModule", {
  11531. value: true
  11532. });
  11533. exports.SecondaryToolbar = void 0;
  11534. var _ui_utils = __webpack_require__(5);
  11535. var _pdf_cursor_tools = __webpack_require__(9);
  11536. var _pdf_single_page_viewer = __webpack_require__(35);
  11537. function _createForOfIteratorHelper(o, allowArrayLike) { var it; if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = o[Symbol.iterator](); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
  11538. function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
  11539. function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
  11540. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  11541. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  11542. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  11543. var SecondaryToolbar = /*#__PURE__*/function () {
  11544. function SecondaryToolbar(options, mainContainer, eventBus) {
  11545. var _this = this;
  11546. _classCallCheck(this, SecondaryToolbar);
  11547. this.toolbar = options.toolbar;
  11548. this.toggleButton = options.toggleButton;
  11549. this.toolbarButtonContainer = options.toolbarButtonContainer;
  11550. this.buttons = [{
  11551. element: options.presentationModeButton,
  11552. eventName: "presentationmode",
  11553. close: true
  11554. }, {
  11555. element: options.openFileButton,
  11556. eventName: "openfile",
  11557. close: true
  11558. }, {
  11559. element: options.printButton,
  11560. eventName: "print",
  11561. close: true
  11562. }, {
  11563. element: options.downloadButton,
  11564. eventName: "download",
  11565. close: true
  11566. }, {
  11567. element: options.viewBookmarkButton,
  11568. eventName: null,
  11569. close: true
  11570. }, {
  11571. element: options.firstPageButton,
  11572. eventName: "firstpage",
  11573. close: true
  11574. }, {
  11575. element: options.lastPageButton,
  11576. eventName: "lastpage",
  11577. close: true
  11578. }, {
  11579. element: options.pageRotateCwButton,
  11580. eventName: "rotatecw",
  11581. close: false
  11582. }, {
  11583. element: options.pageRotateCcwButton,
  11584. eventName: "rotateccw",
  11585. close: false
  11586. }, {
  11587. element: options.cursorSelectToolButton,
  11588. eventName: "switchcursortool",
  11589. eventDetails: {
  11590. tool: _pdf_cursor_tools.CursorTool.SELECT
  11591. },
  11592. close: true
  11593. }, {
  11594. element: options.cursorHandToolButton,
  11595. eventName: "switchcursortool",
  11596. eventDetails: {
  11597. tool: _pdf_cursor_tools.CursorTool.HAND
  11598. },
  11599. close: true
  11600. }, {
  11601. element: options.scrollVerticalButton,
  11602. eventName: "switchscrollmode",
  11603. eventDetails: {
  11604. mode: _ui_utils.ScrollMode.VERTICAL
  11605. },
  11606. close: true
  11607. }, {
  11608. element: options.scrollHorizontalButton,
  11609. eventName: "switchscrollmode",
  11610. eventDetails: {
  11611. mode: _ui_utils.ScrollMode.HORIZONTAL
  11612. },
  11613. close: true
  11614. }, {
  11615. element: options.scrollWrappedButton,
  11616. eventName: "switchscrollmode",
  11617. eventDetails: {
  11618. mode: _ui_utils.ScrollMode.WRAPPED
  11619. },
  11620. close: true
  11621. }, {
  11622. element: options.spreadNoneButton,
  11623. eventName: "switchspreadmode",
  11624. eventDetails: {
  11625. mode: _ui_utils.SpreadMode.NONE
  11626. },
  11627. close: true
  11628. }, {
  11629. element: options.spreadOddButton,
  11630. eventName: "switchspreadmode",
  11631. eventDetails: {
  11632. mode: _ui_utils.SpreadMode.ODD
  11633. },
  11634. close: true
  11635. }, {
  11636. element: options.spreadEvenButton,
  11637. eventName: "switchspreadmode",
  11638. eventDetails: {
  11639. mode: _ui_utils.SpreadMode.EVEN
  11640. },
  11641. close: true
  11642. }, {
  11643. element: options.documentPropertiesButton,
  11644. eventName: "documentproperties",
  11645. close: true
  11646. }];
  11647. this.items = {
  11648. firstPage: options.firstPageButton,
  11649. lastPage: options.lastPageButton,
  11650. pageRotateCw: options.pageRotateCwButton,
  11651. pageRotateCcw: options.pageRotateCcwButton
  11652. };
  11653. this.mainContainer = mainContainer;
  11654. this.eventBus = eventBus;
  11655. this.opened = false;
  11656. this.containerHeight = null;
  11657. this.previousContainerHeight = null;
  11658. this.reset();
  11659. this._bindClickListeners();
  11660. this._bindCursorToolsListener(options);
  11661. this._bindScrollModeListener(options);
  11662. this._bindSpreadModeListener(options);
  11663. this.eventBus._on("resize", this._setMaxHeight.bind(this));
  11664. this.eventBus._on("baseviewerinit", function (evt) {
  11665. if (evt.source instanceof _pdf_single_page_viewer.PDFSinglePageViewer) {
  11666. _this.toolbarButtonContainer.classList.add("hiddenScrollModeButtons", "hiddenSpreadModeButtons");
  11667. } else {
  11668. _this.toolbarButtonContainer.classList.remove("hiddenScrollModeButtons", "hiddenSpreadModeButtons");
  11669. }
  11670. });
  11671. }
  11672. _createClass(SecondaryToolbar, [{
  11673. key: "setPageNumber",
  11674. value: function setPageNumber(pageNumber) {
  11675. this.pageNumber = pageNumber;
  11676. this._updateUIState();
  11677. }
  11678. }, {
  11679. key: "setPagesCount",
  11680. value: function setPagesCount(pagesCount) {
  11681. this.pagesCount = pagesCount;
  11682. this._updateUIState();
  11683. }
  11684. }, {
  11685. key: "reset",
  11686. value: function reset() {
  11687. this.pageNumber = 0;
  11688. this.pagesCount = 0;
  11689. this._updateUIState();
  11690. this.eventBus.dispatch("secondarytoolbarreset", {
  11691. source: this
  11692. });
  11693. }
  11694. }, {
  11695. key: "_updateUIState",
  11696. value: function _updateUIState() {
  11697. this.items.firstPage.disabled = this.pageNumber <= 1;
  11698. this.items.lastPage.disabled = this.pageNumber >= this.pagesCount;
  11699. this.items.pageRotateCw.disabled = this.pagesCount === 0;
  11700. this.items.pageRotateCcw.disabled = this.pagesCount === 0;
  11701. }
  11702. }, {
  11703. key: "_bindClickListeners",
  11704. value: function _bindClickListeners() {
  11705. var _this2 = this;
  11706. this.toggleButton.addEventListener("click", this.toggle.bind(this));
  11707. var _iterator = _createForOfIteratorHelper(this.buttons),
  11708. _step;
  11709. try {
  11710. var _loop = function _loop() {
  11711. var _step$value = _step.value,
  11712. element = _step$value.element,
  11713. eventName = _step$value.eventName,
  11714. close = _step$value.close,
  11715. eventDetails = _step$value.eventDetails;
  11716. element.addEventListener("click", function (evt) {
  11717. if (eventName !== null) {
  11718. var details = {
  11719. source: _this2
  11720. };
  11721. for (var property in eventDetails) {
  11722. details[property] = eventDetails[property];
  11723. }
  11724. _this2.eventBus.dispatch(eventName, details);
  11725. }
  11726. if (close) {
  11727. _this2.close();
  11728. }
  11729. });
  11730. };
  11731. for (_iterator.s(); !(_step = _iterator.n()).done;) {
  11732. _loop();
  11733. }
  11734. } catch (err) {
  11735. _iterator.e(err);
  11736. } finally {
  11737. _iterator.f();
  11738. }
  11739. }
  11740. }, {
  11741. key: "_bindCursorToolsListener",
  11742. value: function _bindCursorToolsListener(buttons) {
  11743. this.eventBus._on("cursortoolchanged", function (_ref) {
  11744. var tool = _ref.tool;
  11745. buttons.cursorSelectToolButton.classList.toggle("toggled", tool === _pdf_cursor_tools.CursorTool.SELECT);
  11746. buttons.cursorHandToolButton.classList.toggle("toggled", tool === _pdf_cursor_tools.CursorTool.HAND);
  11747. });
  11748. }
  11749. }, {
  11750. key: "_bindScrollModeListener",
  11751. value: function _bindScrollModeListener(buttons) {
  11752. var _this3 = this;
  11753. function scrollModeChanged(_ref2) {
  11754. var mode = _ref2.mode;
  11755. buttons.scrollVerticalButton.classList.toggle("toggled", mode === _ui_utils.ScrollMode.VERTICAL);
  11756. buttons.scrollHorizontalButton.classList.toggle("toggled", mode === _ui_utils.ScrollMode.HORIZONTAL);
  11757. buttons.scrollWrappedButton.classList.toggle("toggled", mode === _ui_utils.ScrollMode.WRAPPED);
  11758. var isScrollModeHorizontal = mode === _ui_utils.ScrollMode.HORIZONTAL;
  11759. buttons.spreadNoneButton.disabled = isScrollModeHorizontal;
  11760. buttons.spreadOddButton.disabled = isScrollModeHorizontal;
  11761. buttons.spreadEvenButton.disabled = isScrollModeHorizontal;
  11762. }
  11763. this.eventBus._on("scrollmodechanged", scrollModeChanged);
  11764. this.eventBus._on("secondarytoolbarreset", function (evt) {
  11765. if (evt.source === _this3) {
  11766. scrollModeChanged({
  11767. mode: _ui_utils.ScrollMode.VERTICAL
  11768. });
  11769. }
  11770. });
  11771. }
  11772. }, {
  11773. key: "_bindSpreadModeListener",
  11774. value: function _bindSpreadModeListener(buttons) {
  11775. var _this4 = this;
  11776. function spreadModeChanged(_ref3) {
  11777. var mode = _ref3.mode;
  11778. buttons.spreadNoneButton.classList.toggle("toggled", mode === _ui_utils.SpreadMode.NONE);
  11779. buttons.spreadOddButton.classList.toggle("toggled", mode === _ui_utils.SpreadMode.ODD);
  11780. buttons.spreadEvenButton.classList.toggle("toggled", mode === _ui_utils.SpreadMode.EVEN);
  11781. }
  11782. this.eventBus._on("spreadmodechanged", spreadModeChanged);
  11783. this.eventBus._on("secondarytoolbarreset", function (evt) {
  11784. if (evt.source === _this4) {
  11785. spreadModeChanged({
  11786. mode: _ui_utils.SpreadMode.NONE
  11787. });
  11788. }
  11789. });
  11790. }
  11791. }, {
  11792. key: "open",
  11793. value: function open() {
  11794. if (this.opened) {
  11795. return;
  11796. }
  11797. this.opened = true;
  11798. this._setMaxHeight();
  11799. this.toggleButton.classList.add("toggled");
  11800. this.toolbar.classList.remove("hidden");
  11801. }
  11802. }, {
  11803. key: "close",
  11804. value: function close() {
  11805. if (!this.opened) {
  11806. return;
  11807. }
  11808. this.opened = false;
  11809. this.toolbar.classList.add("hidden");
  11810. this.toggleButton.classList.remove("toggled");
  11811. }
  11812. }, {
  11813. key: "toggle",
  11814. value: function toggle() {
  11815. if (this.opened) {
  11816. this.close();
  11817. } else {
  11818. this.open();
  11819. }
  11820. }
  11821. }, {
  11822. key: "_setMaxHeight",
  11823. value: function _setMaxHeight() {
  11824. if (!this.opened) {
  11825. return;
  11826. }
  11827. this.containerHeight = this.mainContainer.clientHeight;
  11828. if (this.containerHeight === this.previousContainerHeight) {
  11829. return;
  11830. }
  11831. this.toolbarButtonContainer.style.maxHeight = "".concat(this.containerHeight - _ui_utils.SCROLLBAR_PADDING, "px");
  11832. this.previousContainerHeight = this.containerHeight;
  11833. }
  11834. }, {
  11835. key: "isOpen",
  11836. get: function get() {
  11837. return this.opened;
  11838. }
  11839. }]);
  11840. return SecondaryToolbar;
  11841. }();
  11842. exports.SecondaryToolbar = SecondaryToolbar;
  11843. /***/ }),
  11844. /* 35 */
  11845. /***/ (function(module, exports, __webpack_require__) {
  11846. "use strict";
  11847. Object.defineProperty(exports, "__esModule", {
  11848. value: true
  11849. });
  11850. exports.PDFSinglePageViewer = void 0;
  11851. var _base_viewer = __webpack_require__(30);
  11852. var _pdfjsLib = __webpack_require__(8);
  11853. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  11854. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  11855. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  11856. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  11857. function _get(target, property, receiver) { if (typeof Reflect !== "undefined" && Reflect.get) { _get = Reflect.get; } else { _get = function _get(target, property, receiver) { var base = _superPropBase(target, property); if (!base) return; var desc = Object.getOwnPropertyDescriptor(base, property); if (desc.get) { return desc.get.call(receiver); } return desc.value; }; } return _get(target, property, receiver || target); }
  11858. function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
  11859. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  11860. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  11861. function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  11862. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  11863. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  11864. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
  11865. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  11866. var PDFSinglePageViewer = /*#__PURE__*/function (_BaseViewer) {
  11867. _inherits(PDFSinglePageViewer, _BaseViewer);
  11868. var _super = _createSuper(PDFSinglePageViewer);
  11869. function PDFSinglePageViewer(options) {
  11870. var _this;
  11871. _classCallCheck(this, PDFSinglePageViewer);
  11872. _this = _super.call(this, options);
  11873. _this.eventBus._on("pagesinit", function (evt) {
  11874. _this._ensurePageViewVisible();
  11875. });
  11876. return _this;
  11877. }
  11878. _createClass(PDFSinglePageViewer, [{
  11879. key: "_resetView",
  11880. value: function _resetView() {
  11881. _get(_getPrototypeOf(PDFSinglePageViewer.prototype), "_resetView", this).call(this);
  11882. this._previousPageNumber = 1;
  11883. this._shadowViewer = document.createDocumentFragment();
  11884. this._updateScrollDown = null;
  11885. }
  11886. }, {
  11887. key: "_ensurePageViewVisible",
  11888. value: function _ensurePageViewVisible() {
  11889. var pageView = this._pages[this._currentPageNumber - 1];
  11890. var previousPageView = this._pages[this._previousPageNumber - 1];
  11891. var viewerNodes = this.viewer.childNodes;
  11892. switch (viewerNodes.length) {
  11893. case 0:
  11894. this.viewer.appendChild(pageView.div);
  11895. break;
  11896. case 1:
  11897. if (viewerNodes[0] !== previousPageView.div) {
  11898. throw new Error("_ensurePageViewVisible: Unexpected previously visible page.");
  11899. }
  11900. if (pageView === previousPageView) {
  11901. break;
  11902. }
  11903. this._shadowViewer.appendChild(previousPageView.div);
  11904. this.viewer.appendChild(pageView.div);
  11905. this.container.scrollTop = 0;
  11906. break;
  11907. default:
  11908. throw new Error("_ensurePageViewVisible: Only one page should be visible at a time.");
  11909. }
  11910. this._previousPageNumber = this._currentPageNumber;
  11911. }
  11912. }, {
  11913. key: "_scrollUpdate",
  11914. value: function _scrollUpdate() {
  11915. if (this._updateScrollDown) {
  11916. this._updateScrollDown();
  11917. }
  11918. _get(_getPrototypeOf(PDFSinglePageViewer.prototype), "_scrollUpdate", this).call(this);
  11919. }
  11920. }, {
  11921. key: "_scrollIntoView",
  11922. value: function _scrollIntoView(_ref) {
  11923. var _this2 = this;
  11924. var pageDiv = _ref.pageDiv,
  11925. _ref$pageSpot = _ref.pageSpot,
  11926. pageSpot = _ref$pageSpot === void 0 ? null : _ref$pageSpot,
  11927. _ref$pageNumber = _ref.pageNumber,
  11928. pageNumber = _ref$pageNumber === void 0 ? null : _ref$pageNumber;
  11929. if (pageNumber) {
  11930. this._setCurrentPageNumber(pageNumber);
  11931. }
  11932. var scrolledDown = this._currentPageNumber >= this._previousPageNumber;
  11933. this._ensurePageViewVisible();
  11934. this.update();
  11935. _get(_getPrototypeOf(PDFSinglePageViewer.prototype), "_scrollIntoView", this).call(this, {
  11936. pageDiv: pageDiv,
  11937. pageSpot: pageSpot,
  11938. pageNumber: pageNumber
  11939. });
  11940. this._updateScrollDown = function () {
  11941. _this2.scroll.down = scrolledDown;
  11942. _this2._updateScrollDown = null;
  11943. };
  11944. }
  11945. }, {
  11946. key: "_getVisiblePages",
  11947. value: function _getVisiblePages() {
  11948. return this._getCurrentVisiblePage();
  11949. }
  11950. }, {
  11951. key: "_updateHelper",
  11952. value: function _updateHelper(visiblePages) {}
  11953. }, {
  11954. key: "_updateScrollMode",
  11955. value: function _updateScrollMode() {}
  11956. }, {
  11957. key: "_updateSpreadMode",
  11958. value: function _updateSpreadMode() {}
  11959. }, {
  11960. key: "_viewerElement",
  11961. get: function get() {
  11962. return (0, _pdfjsLib.shadow)(this, "_viewerElement", this._shadowViewer);
  11963. }
  11964. }, {
  11965. key: "_isScrollModeHorizontal",
  11966. get: function get() {
  11967. return (0, _pdfjsLib.shadow)(this, "_isScrollModeHorizontal", false);
  11968. }
  11969. }]);
  11970. return PDFSinglePageViewer;
  11971. }(_base_viewer.BaseViewer);
  11972. exports.PDFSinglePageViewer = PDFSinglePageViewer;
  11973. /***/ }),
  11974. /* 36 */
  11975. /***/ (function(module, exports, __webpack_require__) {
  11976. "use strict";
  11977. Object.defineProperty(exports, "__esModule", {
  11978. value: true
  11979. });
  11980. exports.Toolbar = void 0;
  11981. var _regenerator = _interopRequireDefault(__webpack_require__(2));
  11982. var _ui_utils = __webpack_require__(5);
  11983. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  11984. function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
  11985. function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
  11986. function _createForOfIteratorHelper(o, allowArrayLike) { var it; if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = o[Symbol.iterator](); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
  11987. function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
  11988. function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
  11989. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  11990. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  11991. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  11992. var PAGE_NUMBER_LOADING_INDICATOR = "visiblePageIsLoading";
  11993. var SCALE_SELECT_CONTAINER_WIDTH = 140;
  11994. var SCALE_SELECT_WIDTH = 162;
  11995. var Toolbar = /*#__PURE__*/function () {
  11996. function Toolbar(options, eventBus) {
  11997. var l10n = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : _ui_utils.NullL10n;
  11998. _classCallCheck(this, Toolbar);
  11999. this.toolbar = options.container;
  12000. this.eventBus = eventBus;
  12001. this.l10n = l10n;
  12002. this.buttons = [{
  12003. element: options.previous,
  12004. eventName: "previouspage"
  12005. }, {
  12006. element: options.next,
  12007. eventName: "nextpage"
  12008. }, {
  12009. element: options.zoomIn,
  12010. eventName: "zoomin"
  12011. }, {
  12012. element: options.zoomOut,
  12013. eventName: "zoomout"
  12014. }, {
  12015. element: options.openFile,
  12016. eventName: "openfile"
  12017. }, {
  12018. element: options.print,
  12019. eventName: "print"
  12020. }, {
  12021. element: options.presentationModeButton,
  12022. eventName: "presentationmode"
  12023. }, {
  12024. element: options.download,
  12025. eventName: "download"
  12026. }, {
  12027. element: options.viewBookmark,
  12028. eventName: null
  12029. }];
  12030. this.items = {
  12031. numPages: options.numPages,
  12032. pageNumber: options.pageNumber,
  12033. scaleSelectContainer: options.scaleSelectContainer,
  12034. scaleSelect: options.scaleSelect,
  12035. customScaleOption: options.customScaleOption,
  12036. previous: options.previous,
  12037. next: options.next,
  12038. zoomIn: options.zoomIn,
  12039. zoomOut: options.zoomOut
  12040. };
  12041. this._wasLocalized = false;
  12042. this.reset();
  12043. this._bindListeners();
  12044. }
  12045. _createClass(Toolbar, [{
  12046. key: "setPageNumber",
  12047. value: function setPageNumber(pageNumber, pageLabel) {
  12048. this.pageNumber = pageNumber;
  12049. this.pageLabel = pageLabel;
  12050. this._updateUIState(false);
  12051. }
  12052. }, {
  12053. key: "setPagesCount",
  12054. value: function setPagesCount(pagesCount, hasPageLabels) {
  12055. this.pagesCount = pagesCount;
  12056. this.hasPageLabels = hasPageLabels;
  12057. this._updateUIState(true);
  12058. }
  12059. }, {
  12060. key: "setPageScale",
  12061. value: function setPageScale(pageScaleValue, pageScale) {
  12062. this.pageScaleValue = (pageScaleValue || pageScale).toString();
  12063. this.pageScale = pageScale;
  12064. this._updateUIState(false);
  12065. }
  12066. }, {
  12067. key: "reset",
  12068. value: function reset() {
  12069. this.pageNumber = 0;
  12070. this.pageLabel = null;
  12071. this.hasPageLabels = false;
  12072. this.pagesCount = 0;
  12073. this.pageScaleValue = _ui_utils.DEFAULT_SCALE_VALUE;
  12074. this.pageScale = _ui_utils.DEFAULT_SCALE;
  12075. this._updateUIState(true);
  12076. this.updateLoadingIndicatorState();
  12077. }
  12078. }, {
  12079. key: "_bindListeners",
  12080. value: function _bindListeners() {
  12081. var _this = this;
  12082. var _this$items = this.items,
  12083. pageNumber = _this$items.pageNumber,
  12084. scaleSelect = _this$items.scaleSelect;
  12085. var self = this;
  12086. var _iterator = _createForOfIteratorHelper(this.buttons),
  12087. _step;
  12088. try {
  12089. var _loop = function _loop() {
  12090. var _step$value = _step.value,
  12091. element = _step$value.element,
  12092. eventName = _step$value.eventName;
  12093. element.addEventListener("click", function (evt) {
  12094. if (eventName !== null) {
  12095. _this.eventBus.dispatch(eventName, {
  12096. source: _this
  12097. });
  12098. }
  12099. });
  12100. };
  12101. for (_iterator.s(); !(_step = _iterator.n()).done;) {
  12102. _loop();
  12103. }
  12104. } catch (err) {
  12105. _iterator.e(err);
  12106. } finally {
  12107. _iterator.f();
  12108. }
  12109. pageNumber.addEventListener("click", function () {
  12110. this.select();
  12111. });
  12112. pageNumber.addEventListener("change", function () {
  12113. self.eventBus.dispatch("pagenumberchanged", {
  12114. source: self,
  12115. value: this.value
  12116. });
  12117. });
  12118. scaleSelect.addEventListener("change", function () {
  12119. if (this.value === "custom") {
  12120. return;
  12121. }
  12122. self.eventBus.dispatch("scalechanged", {
  12123. source: self,
  12124. value: this.value
  12125. });
  12126. });
  12127. scaleSelect.oncontextmenu = _ui_utils.noContextMenuHandler;
  12128. this.eventBus._on("localized", function () {
  12129. _this._wasLocalized = true;
  12130. _this._adjustScaleWidth();
  12131. _this._updateUIState(true);
  12132. });
  12133. }
  12134. }, {
  12135. key: "_updateUIState",
  12136. value: function _updateUIState() {
  12137. var resetNumPages = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  12138. if (!this._wasLocalized) {
  12139. return;
  12140. }
  12141. var pageNumber = this.pageNumber,
  12142. pagesCount = this.pagesCount,
  12143. pageScaleValue = this.pageScaleValue,
  12144. pageScale = this.pageScale,
  12145. items = this.items;
  12146. if (resetNumPages) {
  12147. if (this.hasPageLabels) {
  12148. items.pageNumber.type = "text";
  12149. } else {
  12150. items.pageNumber.type = "number";
  12151. this.l10n.get("of_pages", {
  12152. pagesCount: pagesCount
  12153. }, "of {{pagesCount}}").then(function (msg) {
  12154. items.numPages.textContent = msg;
  12155. });
  12156. }
  12157. items.pageNumber.max = pagesCount;
  12158. }
  12159. if (this.hasPageLabels) {
  12160. items.pageNumber.value = this.pageLabel;
  12161. this.l10n.get("page_of_pages", {
  12162. pageNumber: pageNumber,
  12163. pagesCount: pagesCount
  12164. }, "({{pageNumber}} of {{pagesCount}})").then(function (msg) {
  12165. items.numPages.textContent = msg;
  12166. });
  12167. } else {
  12168. items.pageNumber.value = pageNumber;
  12169. }
  12170. items.previous.disabled = pageNumber <= 1;
  12171. items.next.disabled = pageNumber >= pagesCount;
  12172. items.zoomOut.disabled = pageScale <= _ui_utils.MIN_SCALE;
  12173. items.zoomIn.disabled = pageScale >= _ui_utils.MAX_SCALE;
  12174. var customScale = Math.round(pageScale * 10000) / 100;
  12175. this.l10n.get("page_scale_percent", {
  12176. scale: customScale
  12177. }, "{{scale}}%").then(function (msg) {
  12178. var predefinedValueFound = false;
  12179. var _iterator2 = _createForOfIteratorHelper(items.scaleSelect.options),
  12180. _step2;
  12181. try {
  12182. for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
  12183. var option = _step2.value;
  12184. if (option.value !== pageScaleValue) {
  12185. option.selected = false;
  12186. continue;
  12187. }
  12188. option.selected = true;
  12189. predefinedValueFound = true;
  12190. }
  12191. } catch (err) {
  12192. _iterator2.e(err);
  12193. } finally {
  12194. _iterator2.f();
  12195. }
  12196. if (!predefinedValueFound) {
  12197. items.customScaleOption.textContent = msg;
  12198. items.customScaleOption.selected = true;
  12199. }
  12200. });
  12201. }
  12202. }, {
  12203. key: "updateLoadingIndicatorState",
  12204. value: function updateLoadingIndicatorState() {
  12205. var loading = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  12206. var pageNumberInput = this.items.pageNumber;
  12207. pageNumberInput.classList.toggle(PAGE_NUMBER_LOADING_INDICATOR, loading);
  12208. }
  12209. }, {
  12210. key: "_adjustScaleWidth",
  12211. value: function () {
  12212. var _adjustScaleWidth2 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
  12213. var items, l10n, predefinedValuesPromise, canvas, ctx, _getComputedStyle, fontSize, fontFamily, maxWidth, _iterator3, _step3, predefinedValue, _ctx$measureText, width, overflow;
  12214. return _regenerator["default"].wrap(function _callee$(_context) {
  12215. while (1) {
  12216. switch (_context.prev = _context.next) {
  12217. case 0:
  12218. items = this.items, l10n = this.l10n;
  12219. predefinedValuesPromise = Promise.all([l10n.get("page_scale_auto", null, "Automatic Zoom"), l10n.get("page_scale_actual", null, "Actual Size"), l10n.get("page_scale_fit", null, "Page Fit"), l10n.get("page_scale_width", null, "Page Width")]);
  12220. canvas = document.createElement("canvas");
  12221. canvas.mozOpaque = true;
  12222. ctx = canvas.getContext("2d", {
  12223. alpha: false
  12224. });
  12225. _context.next = 7;
  12226. return _ui_utils.animationStarted;
  12227. case 7:
  12228. _getComputedStyle = getComputedStyle(items.scaleSelect), fontSize = _getComputedStyle.fontSize, fontFamily = _getComputedStyle.fontFamily;
  12229. ctx.font = "".concat(fontSize, " ").concat(fontFamily);
  12230. maxWidth = 0;
  12231. _context.t0 = _createForOfIteratorHelper;
  12232. _context.next = 13;
  12233. return predefinedValuesPromise;
  12234. case 13:
  12235. _context.t1 = _context.sent;
  12236. _iterator3 = (0, _context.t0)(_context.t1);
  12237. try {
  12238. for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
  12239. predefinedValue = _step3.value;
  12240. _ctx$measureText = ctx.measureText(predefinedValue), width = _ctx$measureText.width;
  12241. if (width > maxWidth) {
  12242. maxWidth = width;
  12243. }
  12244. }
  12245. } catch (err) {
  12246. _iterator3.e(err);
  12247. } finally {
  12248. _iterator3.f();
  12249. }
  12250. overflow = SCALE_SELECT_WIDTH - SCALE_SELECT_CONTAINER_WIDTH;
  12251. maxWidth += 2 * overflow;
  12252. if (maxWidth > SCALE_SELECT_CONTAINER_WIDTH) {
  12253. items.scaleSelect.style.width = "".concat(maxWidth + overflow, "px");
  12254. items.scaleSelectContainer.style.width = "".concat(maxWidth, "px");
  12255. }
  12256. canvas.width = 0;
  12257. canvas.height = 0;
  12258. canvas = ctx = null;
  12259. case 22:
  12260. case "end":
  12261. return _context.stop();
  12262. }
  12263. }
  12264. }, _callee, this);
  12265. }));
  12266. function _adjustScaleWidth() {
  12267. return _adjustScaleWidth2.apply(this, arguments);
  12268. }
  12269. return _adjustScaleWidth;
  12270. }()
  12271. }]);
  12272. return Toolbar;
  12273. }();
  12274. exports.Toolbar = Toolbar;
  12275. /***/ }),
  12276. /* 37 */
  12277. /***/ (function(module, exports, __webpack_require__) {
  12278. "use strict";
  12279. Object.defineProperty(exports, "__esModule", {
  12280. value: true
  12281. });
  12282. exports.ViewHistory = void 0;
  12283. var _regenerator = _interopRequireDefault(__webpack_require__(2));
  12284. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  12285. function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
  12286. function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
  12287. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  12288. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  12289. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  12290. var DEFAULT_VIEW_HISTORY_CACHE_SIZE = 20;
  12291. var ViewHistory = /*#__PURE__*/function () {
  12292. function ViewHistory(fingerprint) {
  12293. var _this = this;
  12294. var cacheSize = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : DEFAULT_VIEW_HISTORY_CACHE_SIZE;
  12295. _classCallCheck(this, ViewHistory);
  12296. this.fingerprint = fingerprint;
  12297. this.cacheSize = cacheSize;
  12298. this._initializedPromise = this._readFromStorage().then(function (databaseStr) {
  12299. var database = JSON.parse(databaseStr || "{}");
  12300. var index = -1;
  12301. if (!Array.isArray(database.files)) {
  12302. database.files = [];
  12303. } else {
  12304. while (database.files.length >= _this.cacheSize) {
  12305. database.files.shift();
  12306. }
  12307. for (var i = 0, ii = database.files.length; i < ii; i++) {
  12308. var branch = database.files[i];
  12309. if (branch.fingerprint === _this.fingerprint) {
  12310. index = i;
  12311. break;
  12312. }
  12313. }
  12314. }
  12315. if (index === -1) {
  12316. index = database.files.push({
  12317. fingerprint: _this.fingerprint
  12318. }) - 1;
  12319. }
  12320. _this.file = database.files[index];
  12321. _this.database = database;
  12322. });
  12323. }
  12324. _createClass(ViewHistory, [{
  12325. key: "_writeToStorage",
  12326. value: function () {
  12327. var _writeToStorage2 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
  12328. var databaseStr;
  12329. return _regenerator["default"].wrap(function _callee$(_context) {
  12330. while (1) {
  12331. switch (_context.prev = _context.next) {
  12332. case 0:
  12333. databaseStr = JSON.stringify(this.database);
  12334. localStorage.setItem("pdfjs.history", databaseStr);
  12335. case 2:
  12336. case "end":
  12337. return _context.stop();
  12338. }
  12339. }
  12340. }, _callee, this);
  12341. }));
  12342. function _writeToStorage() {
  12343. return _writeToStorage2.apply(this, arguments);
  12344. }
  12345. return _writeToStorage;
  12346. }()
  12347. }, {
  12348. key: "_readFromStorage",
  12349. value: function () {
  12350. var _readFromStorage2 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee2() {
  12351. return _regenerator["default"].wrap(function _callee2$(_context2) {
  12352. while (1) {
  12353. switch (_context2.prev = _context2.next) {
  12354. case 0:
  12355. return _context2.abrupt("return", localStorage.getItem("pdfjs.history"));
  12356. case 1:
  12357. case "end":
  12358. return _context2.stop();
  12359. }
  12360. }
  12361. }, _callee2);
  12362. }));
  12363. function _readFromStorage() {
  12364. return _readFromStorage2.apply(this, arguments);
  12365. }
  12366. return _readFromStorage;
  12367. }()
  12368. }, {
  12369. key: "set",
  12370. value: function () {
  12371. var _set = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee3(name, val) {
  12372. return _regenerator["default"].wrap(function _callee3$(_context3) {
  12373. while (1) {
  12374. switch (_context3.prev = _context3.next) {
  12375. case 0:
  12376. _context3.next = 2;
  12377. return this._initializedPromise;
  12378. case 2:
  12379. this.file[name] = val;
  12380. return _context3.abrupt("return", this._writeToStorage());
  12381. case 4:
  12382. case "end":
  12383. return _context3.stop();
  12384. }
  12385. }
  12386. }, _callee3, this);
  12387. }));
  12388. function set(_x, _x2) {
  12389. return _set.apply(this, arguments);
  12390. }
  12391. return set;
  12392. }()
  12393. }, {
  12394. key: "setMultiple",
  12395. value: function () {
  12396. var _setMultiple = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee4(properties) {
  12397. var name;
  12398. return _regenerator["default"].wrap(function _callee4$(_context4) {
  12399. while (1) {
  12400. switch (_context4.prev = _context4.next) {
  12401. case 0:
  12402. _context4.next = 2;
  12403. return this._initializedPromise;
  12404. case 2:
  12405. for (name in properties) {
  12406. this.file[name] = properties[name];
  12407. }
  12408. return _context4.abrupt("return", this._writeToStorage());
  12409. case 4:
  12410. case "end":
  12411. return _context4.stop();
  12412. }
  12413. }
  12414. }, _callee4, this);
  12415. }));
  12416. function setMultiple(_x3) {
  12417. return _setMultiple.apply(this, arguments);
  12418. }
  12419. return setMultiple;
  12420. }()
  12421. }, {
  12422. key: "get",
  12423. value: function () {
  12424. var _get = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee5(name, defaultValue) {
  12425. var val;
  12426. return _regenerator["default"].wrap(function _callee5$(_context5) {
  12427. while (1) {
  12428. switch (_context5.prev = _context5.next) {
  12429. case 0:
  12430. _context5.next = 2;
  12431. return this._initializedPromise;
  12432. case 2:
  12433. val = this.file[name];
  12434. return _context5.abrupt("return", val !== undefined ? val : defaultValue);
  12435. case 4:
  12436. case "end":
  12437. return _context5.stop();
  12438. }
  12439. }
  12440. }, _callee5, this);
  12441. }));
  12442. function get(_x4, _x5) {
  12443. return _get.apply(this, arguments);
  12444. }
  12445. return get;
  12446. }()
  12447. }, {
  12448. key: "getMultiple",
  12449. value: function () {
  12450. var _getMultiple = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee6(properties) {
  12451. var values, name, val;
  12452. return _regenerator["default"].wrap(function _callee6$(_context6) {
  12453. while (1) {
  12454. switch (_context6.prev = _context6.next) {
  12455. case 0:
  12456. _context6.next = 2;
  12457. return this._initializedPromise;
  12458. case 2:
  12459. values = Object.create(null);
  12460. for (name in properties) {
  12461. val = this.file[name];
  12462. values[name] = val !== undefined ? val : properties[name];
  12463. }
  12464. return _context6.abrupt("return", values);
  12465. case 5:
  12466. case "end":
  12467. return _context6.stop();
  12468. }
  12469. }
  12470. }, _callee6, this);
  12471. }));
  12472. function getMultiple(_x6) {
  12473. return _getMultiple.apply(this, arguments);
  12474. }
  12475. return getMultiple;
  12476. }()
  12477. }]);
  12478. return ViewHistory;
  12479. }();
  12480. exports.ViewHistory = ViewHistory;
  12481. /***/ }),
  12482. /* 38 */
  12483. /***/ (function(module, exports, __webpack_require__) {
  12484. "use strict";
  12485. Object.defineProperty(exports, "__esModule", {
  12486. value: true
  12487. });
  12488. exports.GenericCom = void 0;
  12489. var _regenerator = _interopRequireDefault(__webpack_require__(2));
  12490. var _app = __webpack_require__(1);
  12491. var _preferences = __webpack_require__(39);
  12492. var _download_manager = __webpack_require__(40);
  12493. var _genericl10n = __webpack_require__(41);
  12494. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  12495. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  12496. function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
  12497. function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
  12498. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  12499. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  12500. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  12501. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  12502. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  12503. function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  12504. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  12505. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  12506. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
  12507. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  12508. ;
  12509. var GenericCom = {};
  12510. exports.GenericCom = GenericCom;
  12511. var GenericPreferences = /*#__PURE__*/function (_BasePreferences) {
  12512. _inherits(GenericPreferences, _BasePreferences);
  12513. var _super = _createSuper(GenericPreferences);
  12514. function GenericPreferences() {
  12515. _classCallCheck(this, GenericPreferences);
  12516. return _super.apply(this, arguments);
  12517. }
  12518. _createClass(GenericPreferences, [{
  12519. key: "_writeToStorage",
  12520. value: function () {
  12521. var _writeToStorage2 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee(prefObj) {
  12522. return _regenerator["default"].wrap(function _callee$(_context) {
  12523. while (1) {
  12524. switch (_context.prev = _context.next) {
  12525. case 0:
  12526. localStorage.setItem("pdfjs.preferences", JSON.stringify(prefObj));
  12527. case 1:
  12528. case "end":
  12529. return _context.stop();
  12530. }
  12531. }
  12532. }, _callee);
  12533. }));
  12534. function _writeToStorage(_x) {
  12535. return _writeToStorage2.apply(this, arguments);
  12536. }
  12537. return _writeToStorage;
  12538. }()
  12539. }, {
  12540. key: "_readFromStorage",
  12541. value: function () {
  12542. var _readFromStorage2 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee2(prefObj) {
  12543. return _regenerator["default"].wrap(function _callee2$(_context2) {
  12544. while (1) {
  12545. switch (_context2.prev = _context2.next) {
  12546. case 0:
  12547. return _context2.abrupt("return", JSON.parse(localStorage.getItem("pdfjs.preferences")));
  12548. case 1:
  12549. case "end":
  12550. return _context2.stop();
  12551. }
  12552. }
  12553. }, _callee2);
  12554. }));
  12555. function _readFromStorage(_x2) {
  12556. return _readFromStorage2.apply(this, arguments);
  12557. }
  12558. return _readFromStorage;
  12559. }()
  12560. }]);
  12561. return GenericPreferences;
  12562. }(_preferences.BasePreferences);
  12563. var GenericExternalServices = /*#__PURE__*/function (_DefaultExternalServi) {
  12564. _inherits(GenericExternalServices, _DefaultExternalServi);
  12565. var _super2 = _createSuper(GenericExternalServices);
  12566. function GenericExternalServices() {
  12567. _classCallCheck(this, GenericExternalServices);
  12568. return _super2.apply(this, arguments);
  12569. }
  12570. _createClass(GenericExternalServices, null, [{
  12571. key: "createDownloadManager",
  12572. value: function createDownloadManager(options) {
  12573. return new _download_manager.DownloadManager(options);
  12574. }
  12575. }, {
  12576. key: "createPreferences",
  12577. value: function createPreferences() {
  12578. return new GenericPreferences();
  12579. }
  12580. }, {
  12581. key: "createL10n",
  12582. value: function createL10n(_ref) {
  12583. var _ref$locale = _ref.locale,
  12584. locale = _ref$locale === void 0 ? "en-US" : _ref$locale;
  12585. return new _genericl10n.GenericL10n(locale);
  12586. }
  12587. }]);
  12588. return GenericExternalServices;
  12589. }(_app.DefaultExternalServices);
  12590. _app.PDFViewerApplication.externalServices = GenericExternalServices;
  12591. /***/ }),
  12592. /* 39 */
  12593. /***/ (function(module, exports, __webpack_require__) {
  12594. "use strict";
  12595. Object.defineProperty(exports, "__esModule", {
  12596. value: true
  12597. });
  12598. exports.BasePreferences = void 0;
  12599. var _regenerator = _interopRequireDefault(__webpack_require__(2));
  12600. var _app_options = __webpack_require__(6);
  12601. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  12602. function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
  12603. function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
  12604. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  12605. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  12606. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  12607. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  12608. var defaultPreferences = null;
  12609. function getDefaultPreferences() {
  12610. if (!defaultPreferences) {
  12611. defaultPreferences = Promise.resolve({
  12612. "cursorToolOnLoad": 0,
  12613. "defaultZoomValue": "",
  12614. "disablePageLabels": false,
  12615. "enablePermissions": false,
  12616. "enablePrintAutoRotate": false,
  12617. "enableWebGL": false,
  12618. "externalLinkTarget": 0,
  12619. "historyUpdateUrl": false,
  12620. "ignoreDestinationZoom": false,
  12621. "pdfBugEnabled": false,
  12622. "renderer": "canvas",
  12623. "renderInteractiveForms": true,
  12624. "sidebarViewOnLoad": -1,
  12625. "scrollModeOnLoad": -1,
  12626. "spreadModeOnLoad": -1,
  12627. "textLayerMode": 1,
  12628. "useOnlyCssZoom": false,
  12629. "viewOnLoad": 0,
  12630. "disableAutoFetch": false,
  12631. "disableFontFace": false,
  12632. "disableRange": false,
  12633. "disableStream": false
  12634. });
  12635. }
  12636. return defaultPreferences;
  12637. }
  12638. var BasePreferences = /*#__PURE__*/function () {
  12639. function BasePreferences() {
  12640. var _this = this;
  12641. _classCallCheck(this, BasePreferences);
  12642. if (this.constructor === BasePreferences) {
  12643. throw new Error("Cannot initialize BasePreferences.");
  12644. }
  12645. this.prefs = null;
  12646. this._initializedPromise = getDefaultPreferences().then(function (defaults) {
  12647. Object.defineProperty(_this, "defaults", {
  12648. value: Object.freeze(defaults),
  12649. writable: false,
  12650. enumerable: true,
  12651. configurable: false
  12652. });
  12653. _this.prefs = Object.assign(Object.create(null), defaults);
  12654. return _this._readFromStorage(defaults);
  12655. }).then(function (prefs) {
  12656. if (!prefs) {
  12657. return;
  12658. }
  12659. for (var name in prefs) {
  12660. var defaultValue = _this.defaults[name],
  12661. prefValue = prefs[name];
  12662. if (defaultValue === undefined || _typeof(prefValue) !== _typeof(defaultValue)) {
  12663. continue;
  12664. }
  12665. _this.prefs[name] = prefValue;
  12666. }
  12667. });
  12668. }
  12669. _createClass(BasePreferences, [{
  12670. key: "_writeToStorage",
  12671. value: function () {
  12672. var _writeToStorage2 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee(prefObj) {
  12673. return _regenerator["default"].wrap(function _callee$(_context) {
  12674. while (1) {
  12675. switch (_context.prev = _context.next) {
  12676. case 0:
  12677. throw new Error("Not implemented: _writeToStorage");
  12678. case 1:
  12679. case "end":
  12680. return _context.stop();
  12681. }
  12682. }
  12683. }, _callee);
  12684. }));
  12685. function _writeToStorage(_x) {
  12686. return _writeToStorage2.apply(this, arguments);
  12687. }
  12688. return _writeToStorage;
  12689. }()
  12690. }, {
  12691. key: "_readFromStorage",
  12692. value: function () {
  12693. var _readFromStorage2 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee2(prefObj) {
  12694. return _regenerator["default"].wrap(function _callee2$(_context2) {
  12695. while (1) {
  12696. switch (_context2.prev = _context2.next) {
  12697. case 0:
  12698. throw new Error("Not implemented: _readFromStorage");
  12699. case 1:
  12700. case "end":
  12701. return _context2.stop();
  12702. }
  12703. }
  12704. }, _callee2);
  12705. }));
  12706. function _readFromStorage(_x2) {
  12707. return _readFromStorage2.apply(this, arguments);
  12708. }
  12709. return _readFromStorage;
  12710. }()
  12711. }, {
  12712. key: "reset",
  12713. value: function () {
  12714. var _reset = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee3() {
  12715. return _regenerator["default"].wrap(function _callee3$(_context3) {
  12716. while (1) {
  12717. switch (_context3.prev = _context3.next) {
  12718. case 0:
  12719. _context3.next = 2;
  12720. return this._initializedPromise;
  12721. case 2:
  12722. this.prefs = Object.assign(Object.create(null), this.defaults);
  12723. return _context3.abrupt("return", this._writeToStorage(this.defaults));
  12724. case 4:
  12725. case "end":
  12726. return _context3.stop();
  12727. }
  12728. }
  12729. }, _callee3, this);
  12730. }));
  12731. function reset() {
  12732. return _reset.apply(this, arguments);
  12733. }
  12734. return reset;
  12735. }()
  12736. }, {
  12737. key: "set",
  12738. value: function () {
  12739. var _set = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee4(name, value) {
  12740. var defaultValue, valueType, defaultType;
  12741. return _regenerator["default"].wrap(function _callee4$(_context4) {
  12742. while (1) {
  12743. switch (_context4.prev = _context4.next) {
  12744. case 0:
  12745. _context4.next = 2;
  12746. return this._initializedPromise;
  12747. case 2:
  12748. defaultValue = this.defaults[name];
  12749. if (!(defaultValue === undefined)) {
  12750. _context4.next = 7;
  12751. break;
  12752. }
  12753. throw new Error("Set preference: \"".concat(name, "\" is undefined."));
  12754. case 7:
  12755. if (!(value === undefined)) {
  12756. _context4.next = 9;
  12757. break;
  12758. }
  12759. throw new Error("Set preference: no value is specified.");
  12760. case 9:
  12761. valueType = _typeof(value);
  12762. defaultType = _typeof(defaultValue);
  12763. if (!(valueType !== defaultType)) {
  12764. _context4.next = 19;
  12765. break;
  12766. }
  12767. if (!(valueType === "number" && defaultType === "string")) {
  12768. _context4.next = 16;
  12769. break;
  12770. }
  12771. value = value.toString();
  12772. _context4.next = 17;
  12773. break;
  12774. case 16:
  12775. throw new Error("Set preference: \"".concat(value, "\" is a ").concat(valueType, ", ") + "expected a ".concat(defaultType, "."));
  12776. case 17:
  12777. _context4.next = 21;
  12778. break;
  12779. case 19:
  12780. if (!(valueType === "number" && !Number.isInteger(value))) {
  12781. _context4.next = 21;
  12782. break;
  12783. }
  12784. throw new Error("Set preference: \"".concat(value, "\" must be an integer."));
  12785. case 21:
  12786. this.prefs[name] = value;
  12787. return _context4.abrupt("return", this._writeToStorage(this.prefs));
  12788. case 23:
  12789. case "end":
  12790. return _context4.stop();
  12791. }
  12792. }
  12793. }, _callee4, this);
  12794. }));
  12795. function set(_x3, _x4) {
  12796. return _set.apply(this, arguments);
  12797. }
  12798. return set;
  12799. }()
  12800. }, {
  12801. key: "get",
  12802. value: function () {
  12803. var _get = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee5(name) {
  12804. var defaultValue, prefValue;
  12805. return _regenerator["default"].wrap(function _callee5$(_context5) {
  12806. while (1) {
  12807. switch (_context5.prev = _context5.next) {
  12808. case 0:
  12809. _context5.next = 2;
  12810. return this._initializedPromise;
  12811. case 2:
  12812. defaultValue = this.defaults[name];
  12813. if (!(defaultValue === undefined)) {
  12814. _context5.next = 7;
  12815. break;
  12816. }
  12817. throw new Error("Get preference: \"".concat(name, "\" is undefined."));
  12818. case 7:
  12819. prefValue = this.prefs[name];
  12820. if (!(prefValue !== undefined)) {
  12821. _context5.next = 10;
  12822. break;
  12823. }
  12824. return _context5.abrupt("return", prefValue);
  12825. case 10:
  12826. return _context5.abrupt("return", defaultValue);
  12827. case 11:
  12828. case "end":
  12829. return _context5.stop();
  12830. }
  12831. }
  12832. }, _callee5, this);
  12833. }));
  12834. function get(_x5) {
  12835. return _get.apply(this, arguments);
  12836. }
  12837. return get;
  12838. }()
  12839. }, {
  12840. key: "getAll",
  12841. value: function () {
  12842. var _getAll = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee6() {
  12843. return _regenerator["default"].wrap(function _callee6$(_context6) {
  12844. while (1) {
  12845. switch (_context6.prev = _context6.next) {
  12846. case 0:
  12847. _context6.next = 2;
  12848. return this._initializedPromise;
  12849. case 2:
  12850. return _context6.abrupt("return", Object.assign(Object.create(null), this.defaults, this.prefs));
  12851. case 3:
  12852. case "end":
  12853. return _context6.stop();
  12854. }
  12855. }
  12856. }, _callee6, this);
  12857. }));
  12858. function getAll() {
  12859. return _getAll.apply(this, arguments);
  12860. }
  12861. return getAll;
  12862. }()
  12863. }]);
  12864. return BasePreferences;
  12865. }();
  12866. exports.BasePreferences = BasePreferences;
  12867. /***/ }),
  12868. /* 40 */
  12869. /***/ (function(module, exports, __webpack_require__) {
  12870. "use strict";
  12871. Object.defineProperty(exports, "__esModule", {
  12872. value: true
  12873. });
  12874. exports.DownloadManager = void 0;
  12875. var _pdfjsLib = __webpack_require__(8);
  12876. var _viewer_compatibility = __webpack_require__(7);
  12877. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  12878. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  12879. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  12880. ;
  12881. function _download(blobUrl, filename) {
  12882. var a = document.createElement("a");
  12883. if (!a.click) {
  12884. throw new Error('DownloadManager: "a.click()" is not supported.');
  12885. }
  12886. a.href = blobUrl;
  12887. a.target = "_parent";
  12888. if ("download" in a) {
  12889. a.download = filename;
  12890. }
  12891. (document.body || document.documentElement).appendChild(a);
  12892. a.click();
  12893. a.remove();
  12894. }
  12895. var DownloadManager = /*#__PURE__*/function () {
  12896. function DownloadManager() {
  12897. _classCallCheck(this, DownloadManager);
  12898. }
  12899. _createClass(DownloadManager, [{
  12900. key: "downloadUrl",
  12901. value: function downloadUrl(url, filename) {
  12902. if (!(0, _pdfjsLib.createValidAbsoluteUrl)(url, "http://example.com")) {
  12903. return;
  12904. }
  12905. _download(url + "#pdfjs.action=download", filename);
  12906. }
  12907. }, {
  12908. key: "downloadData",
  12909. value: function downloadData(data, filename, contentType) {
  12910. if (navigator.msSaveBlob) {
  12911. navigator.msSaveBlob(new Blob([data], {
  12912. type: contentType
  12913. }), filename);
  12914. return;
  12915. }
  12916. var blobUrl = (0, _pdfjsLib.createObjectURL)(data, contentType, _viewer_compatibility.viewerCompatibilityParams.disableCreateObjectURL);
  12917. _download(blobUrl, filename);
  12918. }
  12919. }, {
  12920. key: "download",
  12921. value: function download(blob, url, filename) {
  12922. var sourceEventType = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : "download";
  12923. if (navigator.msSaveBlob) {
  12924. if (!navigator.msSaveBlob(blob, filename)) {
  12925. this.downloadUrl(url, filename);
  12926. }
  12927. return;
  12928. }
  12929. if (_viewer_compatibility.viewerCompatibilityParams.disableCreateObjectURL) {
  12930. this.downloadUrl(url, filename);
  12931. return;
  12932. }
  12933. var blobUrl = URL.createObjectURL(blob);
  12934. _download(blobUrl, filename);
  12935. }
  12936. }]);
  12937. return DownloadManager;
  12938. }();
  12939. exports.DownloadManager = DownloadManager;
  12940. /***/ }),
  12941. /* 41 */
  12942. /***/ (function(module, exports, __webpack_require__) {
  12943. "use strict";
  12944. Object.defineProperty(exports, "__esModule", {
  12945. value: true
  12946. });
  12947. exports.GenericL10n = void 0;
  12948. var _regenerator = _interopRequireDefault(__webpack_require__(2));
  12949. __webpack_require__(42);
  12950. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  12951. function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
  12952. function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
  12953. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  12954. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  12955. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  12956. var webL10n = document.webL10n;
  12957. var GenericL10n = /*#__PURE__*/function () {
  12958. function GenericL10n(lang) {
  12959. _classCallCheck(this, GenericL10n);
  12960. this._lang = lang;
  12961. this._ready = new Promise(function (resolve, reject) {
  12962. webL10n.setLanguage(lang, function () {
  12963. resolve(webL10n);
  12964. });
  12965. });
  12966. }
  12967. _createClass(GenericL10n, [{
  12968. key: "getLanguage",
  12969. value: function () {
  12970. var _getLanguage = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
  12971. var l10n;
  12972. return _regenerator["default"].wrap(function _callee$(_context) {
  12973. while (1) {
  12974. switch (_context.prev = _context.next) {
  12975. case 0:
  12976. _context.next = 2;
  12977. return this._ready;
  12978. case 2:
  12979. l10n = _context.sent;
  12980. return _context.abrupt("return", l10n.getLanguage());
  12981. case 4:
  12982. case "end":
  12983. return _context.stop();
  12984. }
  12985. }
  12986. }, _callee, this);
  12987. }));
  12988. function getLanguage() {
  12989. return _getLanguage.apply(this, arguments);
  12990. }
  12991. return getLanguage;
  12992. }()
  12993. }, {
  12994. key: "getDirection",
  12995. value: function () {
  12996. var _getDirection = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee2() {
  12997. var l10n;
  12998. return _regenerator["default"].wrap(function _callee2$(_context2) {
  12999. while (1) {
  13000. switch (_context2.prev = _context2.next) {
  13001. case 0:
  13002. _context2.next = 2;
  13003. return this._ready;
  13004. case 2:
  13005. l10n = _context2.sent;
  13006. return _context2.abrupt("return", l10n.getDirection());
  13007. case 4:
  13008. case "end":
  13009. return _context2.stop();
  13010. }
  13011. }
  13012. }, _callee2, this);
  13013. }));
  13014. function getDirection() {
  13015. return _getDirection.apply(this, arguments);
  13016. }
  13017. return getDirection;
  13018. }()
  13019. }, {
  13020. key: "get",
  13021. value: function () {
  13022. var _get = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee3(property, args, fallback) {
  13023. var l10n;
  13024. return _regenerator["default"].wrap(function _callee3$(_context3) {
  13025. while (1) {
  13026. switch (_context3.prev = _context3.next) {
  13027. case 0:
  13028. _context3.next = 2;
  13029. return this._ready;
  13030. case 2:
  13031. l10n = _context3.sent;
  13032. return _context3.abrupt("return", l10n.get(property, args, fallback));
  13033. case 4:
  13034. case "end":
  13035. return _context3.stop();
  13036. }
  13037. }
  13038. }, _callee3, this);
  13039. }));
  13040. function get(_x, _x2, _x3) {
  13041. return _get.apply(this, arguments);
  13042. }
  13043. return get;
  13044. }()
  13045. }, {
  13046. key: "translate",
  13047. value: function () {
  13048. var _translate = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee4(element) {
  13049. var l10n;
  13050. return _regenerator["default"].wrap(function _callee4$(_context4) {
  13051. while (1) {
  13052. switch (_context4.prev = _context4.next) {
  13053. case 0:
  13054. _context4.next = 2;
  13055. return this._ready;
  13056. case 2:
  13057. l10n = _context4.sent;
  13058. return _context4.abrupt("return", l10n.translate(element));
  13059. case 4:
  13060. case "end":
  13061. return _context4.stop();
  13062. }
  13063. }
  13064. }, _callee4, this);
  13065. }));
  13066. function translate(_x4) {
  13067. return _translate.apply(this, arguments);
  13068. }
  13069. return translate;
  13070. }()
  13071. }]);
  13072. return GenericL10n;
  13073. }();
  13074. exports.GenericL10n = GenericL10n;
  13075. /***/ }),
  13076. /* 42 */
  13077. /***/ (function(module, exports, __webpack_require__) {
  13078. "use strict";
  13079. document.webL10n = function (window, document, undefined) {
  13080. var gL10nData = {};
  13081. var gTextData = '';
  13082. var gTextProp = 'textContent';
  13083. var gLanguage = '';
  13084. var gMacros = {};
  13085. var gReadyState = 'loading';
  13086. var gAsyncResourceLoading = true;
  13087. function getL10nResourceLinks() {
  13088. return document.querySelectorAll('link[type="application/l10n"]');
  13089. }
  13090. function getL10nDictionary() {
  13091. var script = document.querySelector('script[type="application/l10n"]');
  13092. return script ? JSON.parse(script.innerHTML) : null;
  13093. }
  13094. function getTranslatableChildren(element) {
  13095. return element ? element.querySelectorAll('*[data-l10n-id]') : [];
  13096. }
  13097. function getL10nAttributes(element) {
  13098. if (!element) return {};
  13099. var l10nId = element.getAttribute('data-l10n-id');
  13100. var l10nArgs = element.getAttribute('data-l10n-args');
  13101. var args = {};
  13102. if (l10nArgs) {
  13103. try {
  13104. args = JSON.parse(l10nArgs);
  13105. } catch (e) {
  13106. console.warn('could not parse arguments for #' + l10nId);
  13107. }
  13108. }
  13109. return {
  13110. id: l10nId,
  13111. args: args
  13112. };
  13113. }
  13114. function xhrLoadText(url, onSuccess, onFailure) {
  13115. onSuccess = onSuccess || function _onSuccess(data) {};
  13116. onFailure = onFailure || function _onFailure() {};
  13117. var xhr = new XMLHttpRequest();
  13118. xhr.open('GET', url, gAsyncResourceLoading);
  13119. if (xhr.overrideMimeType) {
  13120. xhr.overrideMimeType('text/plain; charset=utf-8');
  13121. }
  13122. xhr.onreadystatechange = function () {
  13123. if (xhr.readyState == 4) {
  13124. if (xhr.status == 200 || xhr.status === 0) {
  13125. onSuccess(xhr.responseText);
  13126. } else {
  13127. onFailure();
  13128. }
  13129. }
  13130. };
  13131. xhr.onerror = onFailure;
  13132. xhr.ontimeout = onFailure;
  13133. try {
  13134. xhr.send(null);
  13135. } catch (e) {
  13136. onFailure();
  13137. }
  13138. }
  13139. function parseResource(href, lang, successCallback, failureCallback) {
  13140. var baseURL = href.replace(/[^\/]*$/, '') || './';
  13141. function evalString(text) {
  13142. if (text.lastIndexOf('\\') < 0) return text;
  13143. return text.replace(/\\\\/g, '\\').replace(/\\n/g, '\n').replace(/\\r/g, '\r').replace(/\\t/g, '\t').replace(/\\b/g, '\b').replace(/\\f/g, '\f').replace(/\\{/g, '{').replace(/\\}/g, '}').replace(/\\"/g, '"').replace(/\\'/g, "'");
  13144. }
  13145. function parseProperties(text, parsedPropertiesCallback) {
  13146. var dictionary = {};
  13147. var reBlank = /^\s*|\s*$/;
  13148. var reComment = /^\s*#|^\s*$/;
  13149. var reSection = /^\s*\[(.*)\]\s*$/;
  13150. var reImport = /^\s*@import\s+url\((.*)\)\s*$/i;
  13151. var reSplit = /^([^=\s]*)\s*=\s*(.+)$/;
  13152. function parseRawLines(rawText, extendedSyntax, parsedRawLinesCallback) {
  13153. var entries = rawText.replace(reBlank, '').split(/[\r\n]+/);
  13154. var currentLang = '*';
  13155. var genericLang = lang.split('-', 1)[0];
  13156. var skipLang = false;
  13157. var match = '';
  13158. function nextEntry() {
  13159. while (true) {
  13160. if (!entries.length) {
  13161. parsedRawLinesCallback();
  13162. return;
  13163. }
  13164. var line = entries.shift();
  13165. if (reComment.test(line)) continue;
  13166. if (extendedSyntax) {
  13167. match = reSection.exec(line);
  13168. if (match) {
  13169. currentLang = match[1].toLowerCase();
  13170. skipLang = currentLang !== '*' && currentLang !== lang && currentLang !== genericLang;
  13171. continue;
  13172. } else if (skipLang) {
  13173. continue;
  13174. }
  13175. match = reImport.exec(line);
  13176. if (match) {
  13177. loadImport(baseURL + match[1], nextEntry);
  13178. return;
  13179. }
  13180. }
  13181. var tmp = line.match(reSplit);
  13182. if (tmp && tmp.length == 3) {
  13183. dictionary[tmp[1]] = evalString(tmp[2]);
  13184. }
  13185. }
  13186. }
  13187. nextEntry();
  13188. }
  13189. function loadImport(url, callback) {
  13190. xhrLoadText(url, function (content) {
  13191. parseRawLines(content, false, callback);
  13192. }, function () {
  13193. console.warn(url + ' not found.');
  13194. callback();
  13195. });
  13196. }
  13197. parseRawLines(text, true, function () {
  13198. parsedPropertiesCallback(dictionary);
  13199. });
  13200. }
  13201. xhrLoadText(href, function (response) {
  13202. gTextData += response;
  13203. parseProperties(response, function (data) {
  13204. for (var key in data) {
  13205. var id,
  13206. prop,
  13207. index = key.lastIndexOf('.');
  13208. if (index > 0) {
  13209. id = key.substring(0, index);
  13210. prop = key.substring(index + 1);
  13211. } else {
  13212. id = key;
  13213. prop = gTextProp;
  13214. }
  13215. if (!gL10nData[id]) {
  13216. gL10nData[id] = {};
  13217. }
  13218. gL10nData[id][prop] = data[key];
  13219. }
  13220. if (successCallback) {
  13221. successCallback();
  13222. }
  13223. });
  13224. }, failureCallback);
  13225. }
  13226. function loadLocale(lang, callback) {
  13227. if (lang) {
  13228. lang = lang.toLowerCase();
  13229. }
  13230. callback = callback || function _callback() {};
  13231. clear();
  13232. gLanguage = lang;
  13233. var langLinks = getL10nResourceLinks();
  13234. var langCount = langLinks.length;
  13235. if (langCount === 0) {
  13236. var dict = getL10nDictionary();
  13237. if (dict && dict.locales && dict.default_locale) {
  13238. console.log('using the embedded JSON directory, early way out');
  13239. gL10nData = dict.locales[lang];
  13240. if (!gL10nData) {
  13241. var defaultLocale = dict.default_locale.toLowerCase();
  13242. for (var anyCaseLang in dict.locales) {
  13243. anyCaseLang = anyCaseLang.toLowerCase();
  13244. if (anyCaseLang === lang) {
  13245. gL10nData = dict.locales[lang];
  13246. break;
  13247. } else if (anyCaseLang === defaultLocale) {
  13248. gL10nData = dict.locales[defaultLocale];
  13249. }
  13250. }
  13251. }
  13252. callback();
  13253. } else {
  13254. console.log('no resource to load, early way out');
  13255. }
  13256. gReadyState = 'complete';
  13257. return;
  13258. }
  13259. var onResourceLoaded = null;
  13260. var gResourceCount = 0;
  13261. onResourceLoaded = function onResourceLoaded() {
  13262. gResourceCount++;
  13263. if (gResourceCount >= langCount) {
  13264. callback();
  13265. gReadyState = 'complete';
  13266. }
  13267. };
  13268. function L10nResourceLink(link) {
  13269. var href = link.href;
  13270. this.load = function (lang, callback) {
  13271. parseResource(href, lang, callback, function () {
  13272. console.warn(href + ' not found.');
  13273. console.warn('"' + lang + '" resource not found');
  13274. gLanguage = '';
  13275. callback();
  13276. });
  13277. };
  13278. }
  13279. for (var i = 0; i < langCount; i++) {
  13280. var resource = new L10nResourceLink(langLinks[i]);
  13281. resource.load(lang, onResourceLoaded);
  13282. }
  13283. }
  13284. function clear() {
  13285. gL10nData = {};
  13286. gTextData = '';
  13287. gLanguage = '';
  13288. }
  13289. function getPluralRules(lang) {
  13290. var locales2rules = {
  13291. 'af': 3,
  13292. 'ak': 4,
  13293. 'am': 4,
  13294. 'ar': 1,
  13295. 'asa': 3,
  13296. 'az': 0,
  13297. 'be': 11,
  13298. 'bem': 3,
  13299. 'bez': 3,
  13300. 'bg': 3,
  13301. 'bh': 4,
  13302. 'bm': 0,
  13303. 'bn': 3,
  13304. 'bo': 0,
  13305. 'br': 20,
  13306. 'brx': 3,
  13307. 'bs': 11,
  13308. 'ca': 3,
  13309. 'cgg': 3,
  13310. 'chr': 3,
  13311. 'cs': 12,
  13312. 'cy': 17,
  13313. 'da': 3,
  13314. 'de': 3,
  13315. 'dv': 3,
  13316. 'dz': 0,
  13317. 'ee': 3,
  13318. 'el': 3,
  13319. 'en': 3,
  13320. 'eo': 3,
  13321. 'es': 3,
  13322. 'et': 3,
  13323. 'eu': 3,
  13324. 'fa': 0,
  13325. 'ff': 5,
  13326. 'fi': 3,
  13327. 'fil': 4,
  13328. 'fo': 3,
  13329. 'fr': 5,
  13330. 'fur': 3,
  13331. 'fy': 3,
  13332. 'ga': 8,
  13333. 'gd': 24,
  13334. 'gl': 3,
  13335. 'gsw': 3,
  13336. 'gu': 3,
  13337. 'guw': 4,
  13338. 'gv': 23,
  13339. 'ha': 3,
  13340. 'haw': 3,
  13341. 'he': 2,
  13342. 'hi': 4,
  13343. 'hr': 11,
  13344. 'hu': 0,
  13345. 'id': 0,
  13346. 'ig': 0,
  13347. 'ii': 0,
  13348. 'is': 3,
  13349. 'it': 3,
  13350. 'iu': 7,
  13351. 'ja': 0,
  13352. 'jmc': 3,
  13353. 'jv': 0,
  13354. 'ka': 0,
  13355. 'kab': 5,
  13356. 'kaj': 3,
  13357. 'kcg': 3,
  13358. 'kde': 0,
  13359. 'kea': 0,
  13360. 'kk': 3,
  13361. 'kl': 3,
  13362. 'km': 0,
  13363. 'kn': 0,
  13364. 'ko': 0,
  13365. 'ksb': 3,
  13366. 'ksh': 21,
  13367. 'ku': 3,
  13368. 'kw': 7,
  13369. 'lag': 18,
  13370. 'lb': 3,
  13371. 'lg': 3,
  13372. 'ln': 4,
  13373. 'lo': 0,
  13374. 'lt': 10,
  13375. 'lv': 6,
  13376. 'mas': 3,
  13377. 'mg': 4,
  13378. 'mk': 16,
  13379. 'ml': 3,
  13380. 'mn': 3,
  13381. 'mo': 9,
  13382. 'mr': 3,
  13383. 'ms': 0,
  13384. 'mt': 15,
  13385. 'my': 0,
  13386. 'nah': 3,
  13387. 'naq': 7,
  13388. 'nb': 3,
  13389. 'nd': 3,
  13390. 'ne': 3,
  13391. 'nl': 3,
  13392. 'nn': 3,
  13393. 'no': 3,
  13394. 'nr': 3,
  13395. 'nso': 4,
  13396. 'ny': 3,
  13397. 'nyn': 3,
  13398. 'om': 3,
  13399. 'or': 3,
  13400. 'pa': 3,
  13401. 'pap': 3,
  13402. 'pl': 13,
  13403. 'ps': 3,
  13404. 'pt': 3,
  13405. 'rm': 3,
  13406. 'ro': 9,
  13407. 'rof': 3,
  13408. 'ru': 11,
  13409. 'rwk': 3,
  13410. 'sah': 0,
  13411. 'saq': 3,
  13412. 'se': 7,
  13413. 'seh': 3,
  13414. 'ses': 0,
  13415. 'sg': 0,
  13416. 'sh': 11,
  13417. 'shi': 19,
  13418. 'sk': 12,
  13419. 'sl': 14,
  13420. 'sma': 7,
  13421. 'smi': 7,
  13422. 'smj': 7,
  13423. 'smn': 7,
  13424. 'sms': 7,
  13425. 'sn': 3,
  13426. 'so': 3,
  13427. 'sq': 3,
  13428. 'sr': 11,
  13429. 'ss': 3,
  13430. 'ssy': 3,
  13431. 'st': 3,
  13432. 'sv': 3,
  13433. 'sw': 3,
  13434. 'syr': 3,
  13435. 'ta': 3,
  13436. 'te': 3,
  13437. 'teo': 3,
  13438. 'th': 0,
  13439. 'ti': 4,
  13440. 'tig': 3,
  13441. 'tk': 3,
  13442. 'tl': 4,
  13443. 'tn': 3,
  13444. 'to': 0,
  13445. 'tr': 0,
  13446. 'ts': 3,
  13447. 'tzm': 22,
  13448. 'uk': 11,
  13449. 'ur': 3,
  13450. 've': 3,
  13451. 'vi': 0,
  13452. 'vun': 3,
  13453. 'wa': 4,
  13454. 'wae': 3,
  13455. 'wo': 0,
  13456. 'xh': 3,
  13457. 'xog': 3,
  13458. 'yo': 0,
  13459. 'zh': 0,
  13460. 'zu': 3
  13461. };
  13462. function isIn(n, list) {
  13463. return list.indexOf(n) !== -1;
  13464. }
  13465. function isBetween(n, start, end) {
  13466. return start <= n && n <= end;
  13467. }
  13468. var pluralRules = {
  13469. '0': function _(n) {
  13470. return 'other';
  13471. },
  13472. '1': function _(n) {
  13473. if (isBetween(n % 100, 3, 10)) return 'few';
  13474. if (n === 0) return 'zero';
  13475. if (isBetween(n % 100, 11, 99)) return 'many';
  13476. if (n == 2) return 'two';
  13477. if (n == 1) return 'one';
  13478. return 'other';
  13479. },
  13480. '2': function _(n) {
  13481. if (n !== 0 && n % 10 === 0) return 'many';
  13482. if (n == 2) return 'two';
  13483. if (n == 1) return 'one';
  13484. return 'other';
  13485. },
  13486. '3': function _(n) {
  13487. if (n == 1) return 'one';
  13488. return 'other';
  13489. },
  13490. '4': function _(n) {
  13491. if (isBetween(n, 0, 1)) return 'one';
  13492. return 'other';
  13493. },
  13494. '5': function _(n) {
  13495. if (isBetween(n, 0, 2) && n != 2) return 'one';
  13496. return 'other';
  13497. },
  13498. '6': function _(n) {
  13499. if (n === 0) return 'zero';
  13500. if (n % 10 == 1 && n % 100 != 11) return 'one';
  13501. return 'other';
  13502. },
  13503. '7': function _(n) {
  13504. if (n == 2) return 'two';
  13505. if (n == 1) return 'one';
  13506. return 'other';
  13507. },
  13508. '8': function _(n) {
  13509. if (isBetween(n, 3, 6)) return 'few';
  13510. if (isBetween(n, 7, 10)) return 'many';
  13511. if (n == 2) return 'two';
  13512. if (n == 1) return 'one';
  13513. return 'other';
  13514. },
  13515. '9': function _(n) {
  13516. if (n === 0 || n != 1 && isBetween(n % 100, 1, 19)) return 'few';
  13517. if (n == 1) return 'one';
  13518. return 'other';
  13519. },
  13520. '10': function _(n) {
  13521. if (isBetween(n % 10, 2, 9) && !isBetween(n % 100, 11, 19)) return 'few';
  13522. if (n % 10 == 1 && !isBetween(n % 100, 11, 19)) return 'one';
  13523. return 'other';
  13524. },
  13525. '11': function _(n) {
  13526. if (isBetween(n % 10, 2, 4) && !isBetween(n % 100, 12, 14)) return 'few';
  13527. if (n % 10 === 0 || isBetween(n % 10, 5, 9) || isBetween(n % 100, 11, 14)) return 'many';
  13528. if (n % 10 == 1 && n % 100 != 11) return 'one';
  13529. return 'other';
  13530. },
  13531. '12': function _(n) {
  13532. if (isBetween(n, 2, 4)) return 'few';
  13533. if (n == 1) return 'one';
  13534. return 'other';
  13535. },
  13536. '13': function _(n) {
  13537. if (isBetween(n % 10, 2, 4) && !isBetween(n % 100, 12, 14)) return 'few';
  13538. if (n != 1 && isBetween(n % 10, 0, 1) || isBetween(n % 10, 5, 9) || isBetween(n % 100, 12, 14)) return 'many';
  13539. if (n == 1) return 'one';
  13540. return 'other';
  13541. },
  13542. '14': function _(n) {
  13543. if (isBetween(n % 100, 3, 4)) return 'few';
  13544. if (n % 100 == 2) return 'two';
  13545. if (n % 100 == 1) return 'one';
  13546. return 'other';
  13547. },
  13548. '15': function _(n) {
  13549. if (n === 0 || isBetween(n % 100, 2, 10)) return 'few';
  13550. if (isBetween(n % 100, 11, 19)) return 'many';
  13551. if (n == 1) return 'one';
  13552. return 'other';
  13553. },
  13554. '16': function _(n) {
  13555. if (n % 10 == 1 && n != 11) return 'one';
  13556. return 'other';
  13557. },
  13558. '17': function _(n) {
  13559. if (n == 3) return 'few';
  13560. if (n === 0) return 'zero';
  13561. if (n == 6) return 'many';
  13562. if (n == 2) return 'two';
  13563. if (n == 1) return 'one';
  13564. return 'other';
  13565. },
  13566. '18': function _(n) {
  13567. if (n === 0) return 'zero';
  13568. if (isBetween(n, 0, 2) && n !== 0 && n != 2) return 'one';
  13569. return 'other';
  13570. },
  13571. '19': function _(n) {
  13572. if (isBetween(n, 2, 10)) return 'few';
  13573. if (isBetween(n, 0, 1)) return 'one';
  13574. return 'other';
  13575. },
  13576. '20': function _(n) {
  13577. if ((isBetween(n % 10, 3, 4) || n % 10 == 9) && !(isBetween(n % 100, 10, 19) || isBetween(n % 100, 70, 79) || isBetween(n % 100, 90, 99))) return 'few';
  13578. if (n % 1000000 === 0 && n !== 0) return 'many';
  13579. if (n % 10 == 2 && !isIn(n % 100, [12, 72, 92])) return 'two';
  13580. if (n % 10 == 1 && !isIn(n % 100, [11, 71, 91])) return 'one';
  13581. return 'other';
  13582. },
  13583. '21': function _(n) {
  13584. if (n === 0) return 'zero';
  13585. if (n == 1) return 'one';
  13586. return 'other';
  13587. },
  13588. '22': function _(n) {
  13589. if (isBetween(n, 0, 1) || isBetween(n, 11, 99)) return 'one';
  13590. return 'other';
  13591. },
  13592. '23': function _(n) {
  13593. if (isBetween(n % 10, 1, 2) || n % 20 === 0) return 'one';
  13594. return 'other';
  13595. },
  13596. '24': function _(n) {
  13597. if (isBetween(n, 3, 10) || isBetween(n, 13, 19)) return 'few';
  13598. if (isIn(n, [2, 12])) return 'two';
  13599. if (isIn(n, [1, 11])) return 'one';
  13600. return 'other';
  13601. }
  13602. };
  13603. var index = locales2rules[lang.replace(/-.*$/, '')];
  13604. if (!(index in pluralRules)) {
  13605. console.warn('plural form unknown for [' + lang + ']');
  13606. return function () {
  13607. return 'other';
  13608. };
  13609. }
  13610. return pluralRules[index];
  13611. }
  13612. gMacros.plural = function (str, param, key, prop) {
  13613. var n = parseFloat(param);
  13614. if (isNaN(n)) return str;
  13615. if (prop != gTextProp) return str;
  13616. if (!gMacros._pluralRules) {
  13617. gMacros._pluralRules = getPluralRules(gLanguage);
  13618. }
  13619. var index = '[' + gMacros._pluralRules(n) + ']';
  13620. if (n === 0 && key + '[zero]' in gL10nData) {
  13621. str = gL10nData[key + '[zero]'][prop];
  13622. } else if (n == 1 && key + '[one]' in gL10nData) {
  13623. str = gL10nData[key + '[one]'][prop];
  13624. } else if (n == 2 && key + '[two]' in gL10nData) {
  13625. str = gL10nData[key + '[two]'][prop];
  13626. } else if (key + index in gL10nData) {
  13627. str = gL10nData[key + index][prop];
  13628. } else if (key + '[other]' in gL10nData) {
  13629. str = gL10nData[key + '[other]'][prop];
  13630. }
  13631. return str;
  13632. };
  13633. function getL10nData(key, args, fallback) {
  13634. var data = gL10nData[key];
  13635. if (!data) {
  13636. console.warn('#' + key + ' is undefined.');
  13637. if (!fallback) {
  13638. return null;
  13639. }
  13640. data = fallback;
  13641. }
  13642. var rv = {};
  13643. for (var prop in data) {
  13644. var str = data[prop];
  13645. str = substIndexes(str, args, key, prop);
  13646. str = substArguments(str, args, key);
  13647. rv[prop] = str;
  13648. }
  13649. return rv;
  13650. }
  13651. function substIndexes(str, args, key, prop) {
  13652. var reIndex = /\{\[\s*([a-zA-Z]+)\(([a-zA-Z]+)\)\s*\]\}/;
  13653. var reMatch = reIndex.exec(str);
  13654. if (!reMatch || !reMatch.length) return str;
  13655. var macroName = reMatch[1];
  13656. var paramName = reMatch[2];
  13657. var param;
  13658. if (args && paramName in args) {
  13659. param = args[paramName];
  13660. } else if (paramName in gL10nData) {
  13661. param = gL10nData[paramName];
  13662. }
  13663. if (macroName in gMacros) {
  13664. var macro = gMacros[macroName];
  13665. str = macro(str, param, key, prop);
  13666. }
  13667. return str;
  13668. }
  13669. function substArguments(str, args, key) {
  13670. var reArgs = /\{\{\s*(.+?)\s*\}\}/g;
  13671. return str.replace(reArgs, function (matched_text, arg) {
  13672. if (args && arg in args) {
  13673. return args[arg];
  13674. }
  13675. if (arg in gL10nData) {
  13676. return gL10nData[arg];
  13677. }
  13678. console.log('argument {{' + arg + '}} for #' + key + ' is undefined.');
  13679. return matched_text;
  13680. });
  13681. }
  13682. function translateElement(element) {
  13683. var l10n = getL10nAttributes(element);
  13684. if (!l10n.id) return;
  13685. var data = getL10nData(l10n.id, l10n.args);
  13686. if (!data) {
  13687. console.warn('#' + l10n.id + ' is undefined.');
  13688. return;
  13689. }
  13690. if (data[gTextProp]) {
  13691. if (getChildElementCount(element) === 0) {
  13692. element[gTextProp] = data[gTextProp];
  13693. } else {
  13694. var children = element.childNodes;
  13695. var found = false;
  13696. for (var i = 0, l = children.length; i < l; i++) {
  13697. if (children[i].nodeType === 3 && /\S/.test(children[i].nodeValue)) {
  13698. if (found) {
  13699. children[i].nodeValue = '';
  13700. } else {
  13701. children[i].nodeValue = data[gTextProp];
  13702. found = true;
  13703. }
  13704. }
  13705. }
  13706. if (!found) {
  13707. var textNode = document.createTextNode(data[gTextProp]);
  13708. element.insertBefore(textNode, element.firstChild);
  13709. }
  13710. }
  13711. delete data[gTextProp];
  13712. }
  13713. for (var k in data) {
  13714. element[k] = data[k];
  13715. }
  13716. }
  13717. function getChildElementCount(element) {
  13718. if (element.children) {
  13719. return element.children.length;
  13720. }
  13721. if (typeof element.childElementCount !== 'undefined') {
  13722. return element.childElementCount;
  13723. }
  13724. var count = 0;
  13725. for (var i = 0; i < element.childNodes.length; i++) {
  13726. count += element.nodeType === 1 ? 1 : 0;
  13727. }
  13728. return count;
  13729. }
  13730. function translateFragment(element) {
  13731. element = element || document.documentElement;
  13732. var children = getTranslatableChildren(element);
  13733. var elementCount = children.length;
  13734. for (var i = 0; i < elementCount; i++) {
  13735. translateElement(children[i]);
  13736. }
  13737. translateElement(element);
  13738. }
  13739. return {
  13740. get: function get(key, args, fallbackString) {
  13741. var index = key.lastIndexOf('.');
  13742. var prop = gTextProp;
  13743. if (index > 0) {
  13744. prop = key.substring(index + 1);
  13745. key = key.substring(0, index);
  13746. }
  13747. var fallback;
  13748. if (fallbackString) {
  13749. fallback = {};
  13750. fallback[prop] = fallbackString;
  13751. }
  13752. var data = getL10nData(key, args, fallback);
  13753. if (data && prop in data) {
  13754. return data[prop];
  13755. }
  13756. return '{{' + key + '}}';
  13757. },
  13758. getData: function getData() {
  13759. return gL10nData;
  13760. },
  13761. getText: function getText() {
  13762. return gTextData;
  13763. },
  13764. getLanguage: function getLanguage() {
  13765. return gLanguage;
  13766. },
  13767. setLanguage: function setLanguage(lang, callback) {
  13768. loadLocale(lang, function () {
  13769. if (callback) callback();
  13770. });
  13771. },
  13772. getDirection: function getDirection() {
  13773. var rtlList = ['ar', 'he', 'fa', 'ps', 'ur'];
  13774. var shortCode = gLanguage.split('-', 1)[0];
  13775. return rtlList.indexOf(shortCode) >= 0 ? 'rtl' : 'ltr';
  13776. },
  13777. translate: translateFragment,
  13778. getReadyState: function getReadyState() {
  13779. return gReadyState;
  13780. },
  13781. ready: function ready(callback) {
  13782. if (!callback) {
  13783. return;
  13784. } else if (gReadyState == 'complete' || gReadyState == 'interactive') {
  13785. window.setTimeout(function () {
  13786. callback();
  13787. });
  13788. } else if (document.addEventListener) {
  13789. document.addEventListener('localized', function once() {
  13790. document.removeEventListener('localized', once);
  13791. callback();
  13792. });
  13793. }
  13794. }
  13795. };
  13796. }(window, document);
  13797. /***/ }),
  13798. /* 43 */
  13799. /***/ (function(module, exports, __webpack_require__) {
  13800. "use strict";
  13801. Object.defineProperty(exports, "__esModule", {
  13802. value: true
  13803. });
  13804. exports.PDFPrintService = PDFPrintService;
  13805. var _ui_utils = __webpack_require__(5);
  13806. var _app = __webpack_require__(1);
  13807. var _viewer_compatibility = __webpack_require__(7);
  13808. var activeService = null;
  13809. var overlayManager = null;
  13810. function renderPage(activeServiceOnEntry, pdfDocument, pageNumber, size, printResolution, optionalContentConfigPromise) {
  13811. var scratchCanvas = activeService.scratchCanvas;
  13812. var PRINT_UNITS = printResolution / 72.0;
  13813. scratchCanvas.width = Math.floor(size.width * PRINT_UNITS);
  13814. scratchCanvas.height = Math.floor(size.height * PRINT_UNITS);
  13815. var width = Math.floor(size.width * _ui_utils.CSS_UNITS) + "px";
  13816. var height = Math.floor(size.height * _ui_utils.CSS_UNITS) + "px";
  13817. var ctx = scratchCanvas.getContext("2d");
  13818. ctx.save();
  13819. ctx.fillStyle = "rgb(255, 255, 255)";
  13820. ctx.fillRect(0, 0, scratchCanvas.width, scratchCanvas.height);
  13821. ctx.restore();
  13822. return pdfDocument.getPage(pageNumber).then(function (pdfPage) {
  13823. var renderContext = {
  13824. canvasContext: ctx,
  13825. transform: [PRINT_UNITS, 0, 0, PRINT_UNITS, 0, 0],
  13826. viewport: pdfPage.getViewport({
  13827. scale: 1,
  13828. rotation: size.rotation
  13829. }),
  13830. intent: "print",
  13831. annotationStorage: pdfDocument.annotationStorage,
  13832. optionalContentConfigPromise: optionalContentConfigPromise
  13833. };
  13834. return pdfPage.render(renderContext).promise;
  13835. }).then(function () {
  13836. return {
  13837. width: width,
  13838. height: height
  13839. };
  13840. });
  13841. }
  13842. function PDFPrintService(pdfDocument, pagesOverview, printContainer, printResolution) {
  13843. var optionalContentConfigPromise = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : null;
  13844. var l10n = arguments.length > 5 ? arguments[5] : undefined;
  13845. this.pdfDocument = pdfDocument;
  13846. this.pagesOverview = pagesOverview;
  13847. this.printContainer = printContainer;
  13848. this._printResolution = printResolution || 150;
  13849. this._optionalContentConfigPromise = optionalContentConfigPromise || pdfDocument.getOptionalContentConfig();
  13850. this.l10n = l10n || _ui_utils.NullL10n;
  13851. this.currentPage = -1;
  13852. this.scratchCanvas = document.createElement("canvas");
  13853. }
  13854. PDFPrintService.prototype = {
  13855. layout: function layout() {
  13856. this.throwIfInactive();
  13857. var body = document.querySelector("body");
  13858. body.setAttribute("data-pdfjsprinting", true);
  13859. var hasEqualPageSizes = this.pagesOverview.every(function (size) {
  13860. return size.width === this.pagesOverview[0].width && size.height === this.pagesOverview[0].height;
  13861. }, this);
  13862. if (!hasEqualPageSizes) {
  13863. console.warn("Not all pages have the same size. The printed " + "result may be incorrect!");
  13864. }
  13865. this.pageStyleSheet = document.createElement("style");
  13866. var pageSize = this.pagesOverview[0];
  13867. this.pageStyleSheet.textContent = "@supports ((size:A4) and (size:1pt 1pt)) {" + "@page { size: " + pageSize.width + "pt " + pageSize.height + "pt;}" + "}";
  13868. body.appendChild(this.pageStyleSheet);
  13869. },
  13870. destroy: function destroy() {
  13871. if (activeService !== this) {
  13872. return;
  13873. }
  13874. this.printContainer.textContent = "";
  13875. var body = document.querySelector("body");
  13876. body.removeAttribute("data-pdfjsprinting");
  13877. if (this.pageStyleSheet) {
  13878. this.pageStyleSheet.remove();
  13879. this.pageStyleSheet = null;
  13880. }
  13881. this.scratchCanvas.width = this.scratchCanvas.height = 0;
  13882. this.scratchCanvas = null;
  13883. activeService = null;
  13884. ensureOverlay().then(function () {
  13885. if (overlayManager.active !== "printServiceOverlay") {
  13886. return;
  13887. }
  13888. overlayManager.close("printServiceOverlay");
  13889. });
  13890. },
  13891. renderPages: function renderPages() {
  13892. var _this = this;
  13893. var pageCount = this.pagesOverview.length;
  13894. var renderNextPage = function renderNextPage(resolve, reject) {
  13895. _this.throwIfInactive();
  13896. if (++_this.currentPage >= pageCount) {
  13897. renderProgress(pageCount, pageCount, _this.l10n);
  13898. resolve();
  13899. return;
  13900. }
  13901. var index = _this.currentPage;
  13902. renderProgress(index, pageCount, _this.l10n);
  13903. renderPage(_this, _this.pdfDocument, index + 1, _this.pagesOverview[index], _this._printResolution, _this._optionalContentConfigPromise).then(_this.useRenderedPage.bind(_this)).then(function () {
  13904. renderNextPage(resolve, reject);
  13905. }, reject);
  13906. };
  13907. return new Promise(renderNextPage);
  13908. },
  13909. useRenderedPage: function useRenderedPage(printItem) {
  13910. this.throwIfInactive();
  13911. var img = document.createElement("img");
  13912. img.style.width = printItem.width;
  13913. img.style.height = printItem.height;
  13914. var scratchCanvas = this.scratchCanvas;
  13915. if ("toBlob" in scratchCanvas && !_viewer_compatibility.viewerCompatibilityParams.disableCreateObjectURL) {
  13916. scratchCanvas.toBlob(function (blob) {
  13917. img.src = URL.createObjectURL(blob);
  13918. });
  13919. } else {
  13920. img.src = scratchCanvas.toDataURL();
  13921. }
  13922. var wrapper = document.createElement("div");
  13923. wrapper.appendChild(img);
  13924. this.printContainer.appendChild(wrapper);
  13925. return new Promise(function (resolve, reject) {
  13926. img.onload = resolve;
  13927. img.onerror = reject;
  13928. });
  13929. },
  13930. performPrint: function performPrint() {
  13931. var _this2 = this;
  13932. this.throwIfInactive();
  13933. return new Promise(function (resolve) {
  13934. setTimeout(function () {
  13935. if (!_this2.active) {
  13936. resolve();
  13937. return;
  13938. }
  13939. print.call(window);
  13940. setTimeout(resolve, 20);
  13941. }, 0);
  13942. });
  13943. },
  13944. get active() {
  13945. return this === activeService;
  13946. },
  13947. throwIfInactive: function throwIfInactive() {
  13948. if (!this.active) {
  13949. throw new Error("This print request was cancelled or completed.");
  13950. }
  13951. }
  13952. };
  13953. var print = window.print;
  13954. window.print = function () {
  13955. if (activeService) {
  13956. console.warn("Ignored window.print() because of a pending print job.");
  13957. return;
  13958. }
  13959. ensureOverlay().then(function () {
  13960. if (activeService) {
  13961. overlayManager.open("printServiceOverlay");
  13962. }
  13963. });
  13964. try {
  13965. dispatchEvent("beforeprint");
  13966. } finally {
  13967. if (!activeService) {
  13968. console.error("Expected print service to be initialized.");
  13969. ensureOverlay().then(function () {
  13970. if (overlayManager.active === "printServiceOverlay") {
  13971. overlayManager.close("printServiceOverlay");
  13972. }
  13973. });
  13974. return;
  13975. }
  13976. var activeServiceOnEntry = activeService;
  13977. activeService.renderPages().then(function () {
  13978. return activeServiceOnEntry.performPrint();
  13979. })["catch"](function () {}).then(function () {
  13980. if (activeServiceOnEntry.active) {
  13981. abort();
  13982. }
  13983. });
  13984. }
  13985. };
  13986. function dispatchEvent(eventType) {
  13987. var event = document.createEvent("CustomEvent");
  13988. event.initCustomEvent(eventType, false, false, "custom");
  13989. window.dispatchEvent(event);
  13990. }
  13991. function abort() {
  13992. if (activeService) {
  13993. activeService.destroy();
  13994. dispatchEvent("afterprint");
  13995. }
  13996. }
  13997. function renderProgress(index, total, l10n) {
  13998. var progressContainer = document.getElementById("printServiceOverlay");
  13999. var progress = Math.round(100 * index / total);
  14000. var progressBar = progressContainer.querySelector("progress");
  14001. var progressPerc = progressContainer.querySelector(".relative-progress");
  14002. progressBar.value = progress;
  14003. l10n.get("print_progress_percent", {
  14004. progress: progress
  14005. }, progress + "%").then(function (msg) {
  14006. progressPerc.textContent = msg;
  14007. });
  14008. }
  14009. window.addEventListener("keydown", function (event) {
  14010. if (event.keyCode === 80 && (event.ctrlKey || event.metaKey) && !event.altKey && (!event.shiftKey || window.chrome || window.opera)) {
  14011. window.print();
  14012. event.preventDefault();
  14013. if (event.stopImmediatePropagation) {
  14014. event.stopImmediatePropagation();
  14015. } else {
  14016. event.stopPropagation();
  14017. }
  14018. }
  14019. }, true);
  14020. if ("onbeforeprint" in window) {
  14021. var stopPropagationIfNeeded = function stopPropagationIfNeeded(event) {
  14022. if (event.detail !== "custom" && event.stopImmediatePropagation) {
  14023. event.stopImmediatePropagation();
  14024. }
  14025. };
  14026. window.addEventListener("beforeprint", stopPropagationIfNeeded);
  14027. window.addEventListener("afterprint", stopPropagationIfNeeded);
  14028. }
  14029. var overlayPromise;
  14030. function ensureOverlay() {
  14031. if (!overlayPromise) {
  14032. overlayManager = _app.PDFViewerApplication.overlayManager;
  14033. if (!overlayManager) {
  14034. throw new Error("The overlay manager has not yet been initialized.");
  14035. }
  14036. overlayPromise = overlayManager.register("printServiceOverlay", document.getElementById("printServiceOverlay"), abort, true);
  14037. document.getElementById("printCancel").onclick = abort;
  14038. }
  14039. return overlayPromise;
  14040. }
  14041. _app.PDFPrintServiceFactory.instance = {
  14042. supportsPrinting: true,
  14043. createPrintService: function createPrintService(pdfDocument, pagesOverview, printContainer, printResolution, optionalContentConfigPromise, l10n) {
  14044. if (activeService) {
  14045. throw new Error("The print service is created and active.");
  14046. }
  14047. activeService = new PDFPrintService(pdfDocument, pagesOverview, printContainer, printResolution, optionalContentConfigPromise, l10n);
  14048. return activeService;
  14049. }
  14050. };
  14051. /***/ })
  14052. /******/ ]);
  14053. //# sourceMappingURL=viewer.js.map