pdf_viewer.js 173 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303
  1. /**
  2. * @licstart The following is the entire license notice for the
  3. * Javascript code in this page
  4. *
  5. * Copyright 2017 Mozilla Foundation
  6. *
  7. * Licensed under the Apache License, Version 2.0 (the "License");
  8. * you may not use this file except in compliance with the License.
  9. * You may obtain a copy of the License at
  10. *
  11. * http://www.apache.org/licenses/LICENSE-2.0
  12. *
  13. * Unless required by applicable law or agreed to in writing, software
  14. * distributed under the License is distributed on an "AS IS" BASIS,
  15. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  16. * See the License for the specific language governing permissions and
  17. * limitations under the License.
  18. *
  19. * @licend The above is the entire license notice for the
  20. * Javascript code in this page
  21. */
  22. (function webpackUniversalModuleDefinition(root, factory) {
  23. if(typeof exports === 'object' && typeof module === 'object')
  24. module.exports = factory();
  25. else if(typeof define === 'function' && define.amd)
  26. define("pdfjs-dist/web/pdf_viewer", [], factory);
  27. else if(typeof exports === 'object')
  28. exports["pdfjs-dist/web/pdf_viewer"] = factory();
  29. else
  30. root["pdfjs-dist/web/pdf_viewer"] = root.pdfjsViewer = factory();
  31. })(typeof self !== 'undefined' ? self : this, function() {
  32. return /******/ (function(modules) { // webpackBootstrap
  33. /******/ // The module cache
  34. /******/ var installedModules = {};
  35. /******/
  36. /******/ // The require function
  37. /******/ function __w_pdfjs_require__(moduleId) {
  38. /******/
  39. /******/ // Check if module is in cache
  40. /******/ if(installedModules[moduleId]) {
  41. /******/ return installedModules[moduleId].exports;
  42. /******/ }
  43. /******/ // Create a new module (and put it into the cache)
  44. /******/ var module = installedModules[moduleId] = {
  45. /******/ i: moduleId,
  46. /******/ l: false,
  47. /******/ exports: {}
  48. /******/ };
  49. /******/
  50. /******/ // Execute the module function
  51. /******/ modules[moduleId].call(module.exports, module, module.exports, __w_pdfjs_require__);
  52. /******/
  53. /******/ // Flag the module as loaded
  54. /******/ module.l = true;
  55. /******/
  56. /******/ // Return the exports of the module
  57. /******/ return module.exports;
  58. /******/ }
  59. /******/
  60. /******/
  61. /******/ // expose the modules object (__webpack_modules__)
  62. /******/ __w_pdfjs_require__.m = modules;
  63. /******/
  64. /******/ // expose the module cache
  65. /******/ __w_pdfjs_require__.c = installedModules;
  66. /******/
  67. /******/ // define getter function for harmony exports
  68. /******/ __w_pdfjs_require__.d = function(exports, name, getter) {
  69. /******/ if(!__w_pdfjs_require__.o(exports, name)) {
  70. /******/ Object.defineProperty(exports, name, {
  71. /******/ configurable: false,
  72. /******/ enumerable: true,
  73. /******/ get: getter
  74. /******/ });
  75. /******/ }
  76. /******/ };
  77. /******/
  78. /******/ // getDefaultExport function for compatibility with non-harmony modules
  79. /******/ __w_pdfjs_require__.n = function(module) {
  80. /******/ var getter = module && module.__esModule ?
  81. /******/ function getDefault() { return module['default']; } :
  82. /******/ function getModuleExports() { return module; };
  83. /******/ __w_pdfjs_require__.d(getter, 'a', getter);
  84. /******/ return getter;
  85. /******/ };
  86. /******/
  87. /******/ // Object.prototype.hasOwnProperty.call
  88. /******/ __w_pdfjs_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
  89. /******/
  90. /******/ // __webpack_public_path__
  91. /******/ __w_pdfjs_require__.p = "";
  92. /******/
  93. /******/ // Load entry module and return exports
  94. /******/ return __w_pdfjs_require__(__w_pdfjs_require__.s = 9);
  95. /******/ })
  96. /************************************************************************/
  97. /******/ ([
  98. /* 0 */
  99. /***/ (function(module, exports, __w_pdfjs_require__) {
  100. "use strict";
  101. Object.defineProperty(exports, "__esModule", {
  102. value: true
  103. });
  104. exports.waitOnEventOrTimeout = exports.WaitOnType = exports.animationStarted = exports.normalizeWheelEventDelta = exports.binarySearchFirstItem = exports.watchScroll = exports.scrollIntoView = exports.getOutputScale = exports.approximateFraction = exports.getPageSizeInches = exports.roundToDivide = exports.getVisibleElements = exports.parseQueryString = exports.noContextMenuHandler = exports.getPDFFileNameFromURL = exports.ProgressBar = exports.EventBus = exports.NullL10n = exports.TextLayerMode = exports.RendererType = exports.PresentationModeState = exports.cloneObj = exports.isFileSchema = exports.isPortraitOrientation = exports.isValidRotation = 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 = undefined;
  105. var _createClass = function () { 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); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  106. var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
  107. var _slicedToArray = function () { function sliceIterator(arr, i) { 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"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }();
  108. var _pdfjsLib = __w_pdfjs_require__(1);
  109. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  110. var CSS_UNITS = 96.0 / 72.0;
  111. var DEFAULT_SCALE_VALUE = 'auto';
  112. var DEFAULT_SCALE = 1.0;
  113. var MIN_SCALE = 0.10;
  114. var MAX_SCALE = 10.0;
  115. var UNKNOWN_SCALE = 0;
  116. var MAX_AUTO_SCALE = 1.25;
  117. var SCROLLBAR_PADDING = 40;
  118. var VERTICAL_PADDING = 5;
  119. var PresentationModeState = {
  120. UNKNOWN: 0,
  121. NORMAL: 1,
  122. CHANGING: 2,
  123. FULLSCREEN: 3
  124. };
  125. var RendererType = {
  126. CANVAS: 'canvas',
  127. SVG: 'svg'
  128. };
  129. var TextLayerMode = {
  130. DISABLE: 0,
  131. ENABLE: 1,
  132. ENABLE_ENHANCE: 2
  133. };
  134. function formatL10nValue(text, args) {
  135. if (!args) {
  136. return text;
  137. }
  138. return text.replace(/\{\{\s*(\w+)\s*\}\}/g, function (all, name) {
  139. return name in args ? args[name] : '{{' + name + '}}';
  140. });
  141. }
  142. var NullL10n = {
  143. getLanguage: function getLanguage() {
  144. return Promise.resolve('en-us');
  145. },
  146. getDirection: function getDirection() {
  147. return Promise.resolve('ltr');
  148. },
  149. get: function get(property, args, fallback) {
  150. return Promise.resolve(formatL10nValue(fallback, args));
  151. },
  152. translate: function translate(element) {
  153. return Promise.resolve();
  154. }
  155. };
  156. function getOutputScale(ctx) {
  157. var devicePixelRatio = window.devicePixelRatio || 1;
  158. var backingStoreRatio = ctx.webkitBackingStorePixelRatio || ctx.mozBackingStorePixelRatio || ctx.msBackingStorePixelRatio || ctx.oBackingStorePixelRatio || ctx.backingStorePixelRatio || 1;
  159. var pixelRatio = devicePixelRatio / backingStoreRatio;
  160. return {
  161. sx: pixelRatio,
  162. sy: pixelRatio,
  163. scaled: pixelRatio !== 1
  164. };
  165. }
  166. function scrollIntoView(element, spot) {
  167. var skipOverflowHiddenElements = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  168. var parent = element.offsetParent;
  169. if (!parent) {
  170. console.error('offsetParent is not set -- cannot scroll');
  171. return;
  172. }
  173. var offsetY = element.offsetTop + element.clientTop;
  174. var offsetX = element.offsetLeft + element.clientLeft;
  175. while (parent.clientHeight === parent.scrollHeight || skipOverflowHiddenElements && getComputedStyle(parent).overflow === 'hidden') {
  176. if (parent.dataset._scaleY) {
  177. offsetY /= parent.dataset._scaleY;
  178. offsetX /= parent.dataset._scaleX;
  179. }
  180. offsetY += parent.offsetTop;
  181. offsetX += parent.offsetLeft;
  182. parent = parent.offsetParent;
  183. if (!parent) {
  184. return;
  185. }
  186. }
  187. if (spot) {
  188. if (spot.top !== undefined) {
  189. offsetY += spot.top;
  190. }
  191. if (spot.left !== undefined) {
  192. offsetX += spot.left;
  193. parent.scrollLeft = offsetX;
  194. }
  195. }
  196. parent.scrollTop = offsetY;
  197. }
  198. function watchScroll(viewAreaElement, callback) {
  199. var debounceScroll = function debounceScroll(evt) {
  200. if (rAF) {
  201. return;
  202. }
  203. rAF = window.requestAnimationFrame(function viewAreaElementScrolled() {
  204. rAF = null;
  205. var currentY = viewAreaElement.scrollTop;
  206. var lastY = state.lastY;
  207. if (currentY !== lastY) {
  208. state.down = currentY > lastY;
  209. }
  210. state.lastY = currentY;
  211. callback(state);
  212. });
  213. };
  214. var state = {
  215. down: true,
  216. lastY: viewAreaElement.scrollTop,
  217. _eventHandler: debounceScroll
  218. };
  219. var rAF = null;
  220. viewAreaElement.addEventListener('scroll', debounceScroll, true);
  221. return state;
  222. }
  223. function parseQueryString(query) {
  224. var parts = query.split('&');
  225. var params = Object.create(null);
  226. for (var i = 0, ii = parts.length; i < ii; ++i) {
  227. var param = parts[i].split('=');
  228. var key = param[0].toLowerCase();
  229. var value = param.length > 1 ? param[1] : null;
  230. params[decodeURIComponent(key)] = decodeURIComponent(value);
  231. }
  232. return params;
  233. }
  234. function binarySearchFirstItem(items, condition) {
  235. var minIndex = 0;
  236. var maxIndex = items.length - 1;
  237. if (items.length === 0 || !condition(items[maxIndex])) {
  238. return items.length;
  239. }
  240. if (condition(items[minIndex])) {
  241. return minIndex;
  242. }
  243. while (minIndex < maxIndex) {
  244. var currentIndex = minIndex + maxIndex >> 1;
  245. var currentItem = items[currentIndex];
  246. if (condition(currentItem)) {
  247. maxIndex = currentIndex;
  248. } else {
  249. minIndex = currentIndex + 1;
  250. }
  251. }
  252. return minIndex;
  253. }
  254. function approximateFraction(x) {
  255. if (Math.floor(x) === x) {
  256. return [x, 1];
  257. }
  258. var xinv = 1 / x;
  259. var limit = 8;
  260. if (xinv > limit) {
  261. return [1, limit];
  262. } else if (Math.floor(xinv) === xinv) {
  263. return [1, xinv];
  264. }
  265. var x_ = x > 1 ? xinv : x;
  266. var a = 0,
  267. b = 1,
  268. c = 1,
  269. d = 1;
  270. while (true) {
  271. var p = a + c,
  272. q = b + d;
  273. if (q > limit) {
  274. break;
  275. }
  276. if (x_ <= p / q) {
  277. c = p;
  278. d = q;
  279. } else {
  280. a = p;
  281. b = q;
  282. }
  283. }
  284. var result = void 0;
  285. if (x_ - a / b < c / d - x_) {
  286. result = x_ === x ? [a, b] : [b, a];
  287. } else {
  288. result = x_ === x ? [c, d] : [d, c];
  289. }
  290. return result;
  291. }
  292. function roundToDivide(x, div) {
  293. var r = x % div;
  294. return r === 0 ? x : Math.round(x - r + div);
  295. }
  296. function getPageSizeInches(_ref) {
  297. var view = _ref.view,
  298. userUnit = _ref.userUnit,
  299. rotate = _ref.rotate;
  300. var _view = _slicedToArray(view, 4),
  301. x1 = _view[0],
  302. y1 = _view[1],
  303. x2 = _view[2],
  304. y2 = _view[3];
  305. var changeOrientation = rotate % 180 !== 0;
  306. var width = (x2 - x1) / 72 * userUnit;
  307. var height = (y2 - y1) / 72 * userUnit;
  308. return {
  309. width: changeOrientation ? height : width,
  310. height: changeOrientation ? width : height
  311. };
  312. }
  313. function getVisibleElements(scrollEl, views) {
  314. var sortByVisibility = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  315. var top = scrollEl.scrollTop,
  316. bottom = top + scrollEl.clientHeight;
  317. var left = scrollEl.scrollLeft,
  318. right = left + scrollEl.clientWidth;
  319. function isElementBottomBelowViewTop(view) {
  320. var element = view.div;
  321. var elementBottom = element.offsetTop + element.clientTop + element.clientHeight;
  322. return elementBottom > top;
  323. }
  324. var visible = [],
  325. view = void 0,
  326. element = void 0;
  327. var currentHeight = void 0,
  328. viewHeight = void 0,
  329. hiddenHeight = void 0,
  330. percentHeight = void 0;
  331. var currentWidth = void 0,
  332. viewWidth = void 0;
  333. var firstVisibleElementInd = views.length === 0 ? 0 : binarySearchFirstItem(views, isElementBottomBelowViewTop);
  334. for (var i = firstVisibleElementInd, ii = views.length; i < ii; i++) {
  335. view = views[i];
  336. element = view.div;
  337. currentHeight = element.offsetTop + element.clientTop;
  338. viewHeight = element.clientHeight;
  339. if (currentHeight > bottom) {
  340. break;
  341. }
  342. currentWidth = element.offsetLeft + element.clientLeft;
  343. viewWidth = element.clientWidth;
  344. if (currentWidth + viewWidth < left || currentWidth > right) {
  345. continue;
  346. }
  347. hiddenHeight = Math.max(0, top - currentHeight) + Math.max(0, currentHeight + viewHeight - bottom);
  348. percentHeight = (viewHeight - hiddenHeight) * 100 / viewHeight | 0;
  349. visible.push({
  350. id: view.id,
  351. x: currentWidth,
  352. y: currentHeight,
  353. view: view,
  354. percent: percentHeight
  355. });
  356. }
  357. var first = visible[0];
  358. var last = visible[visible.length - 1];
  359. if (sortByVisibility) {
  360. visible.sort(function (a, b) {
  361. var pc = a.percent - b.percent;
  362. if (Math.abs(pc) > 0.001) {
  363. return -pc;
  364. }
  365. return a.id - b.id;
  366. });
  367. }
  368. return {
  369. first: first,
  370. last: last,
  371. views: visible
  372. };
  373. }
  374. function noContextMenuHandler(evt) {
  375. evt.preventDefault();
  376. }
  377. function isFileSchema(url) {
  378. var i = 0,
  379. ii = url.length;
  380. while (i < ii && url[i].trim() === '') {
  381. i++;
  382. }
  383. return url.substr(i, 7).toLowerCase() === 'file://';
  384. }
  385. function isDataSchema(url) {
  386. var i = 0,
  387. ii = url.length;
  388. while (i < ii && url[i].trim() === '') {
  389. i++;
  390. }
  391. return url.substr(i, 5).toLowerCase() === 'data:';
  392. }
  393. function getPDFFileNameFromURL(url) {
  394. var defaultFilename = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'document.pdf';
  395. if (isDataSchema(url)) {
  396. console.warn('getPDFFileNameFromURL: ' + 'ignoring "data:" URL for performance reasons.');
  397. return defaultFilename;
  398. }
  399. var reURI = /^(?:(?:[^:]+:)?\/\/[^\/]+)?([^?#]*)(\?[^#]*)?(#.*)?$/;
  400. var reFilename = /[^\/?#=]+\.pdf\b(?!.*\.pdf\b)/i;
  401. var splitURI = reURI.exec(url);
  402. var suggestedFilename = reFilename.exec(splitURI[1]) || reFilename.exec(splitURI[2]) || reFilename.exec(splitURI[3]);
  403. if (suggestedFilename) {
  404. suggestedFilename = suggestedFilename[0];
  405. if (suggestedFilename.includes('%')) {
  406. try {
  407. suggestedFilename = reFilename.exec(decodeURIComponent(suggestedFilename))[0];
  408. } catch (ex) {}
  409. }
  410. }
  411. return suggestedFilename || defaultFilename;
  412. }
  413. function normalizeWheelEventDelta(evt) {
  414. var delta = Math.sqrt(evt.deltaX * evt.deltaX + evt.deltaY * evt.deltaY);
  415. var angle = Math.atan2(evt.deltaY, evt.deltaX);
  416. if (-0.25 * Math.PI < angle && angle < 0.75 * Math.PI) {
  417. delta = -delta;
  418. }
  419. var MOUSE_DOM_DELTA_PIXEL_MODE = 0;
  420. var MOUSE_DOM_DELTA_LINE_MODE = 1;
  421. var MOUSE_PIXELS_PER_LINE = 30;
  422. var MOUSE_LINES_PER_PAGE = 30;
  423. if (evt.deltaMode === MOUSE_DOM_DELTA_PIXEL_MODE) {
  424. delta /= MOUSE_PIXELS_PER_LINE * MOUSE_LINES_PER_PAGE;
  425. } else if (evt.deltaMode === MOUSE_DOM_DELTA_LINE_MODE) {
  426. delta /= MOUSE_LINES_PER_PAGE;
  427. }
  428. return delta;
  429. }
  430. function isValidRotation(angle) {
  431. return Number.isInteger(angle) && angle % 90 === 0;
  432. }
  433. function isPortraitOrientation(size) {
  434. return size.width <= size.height;
  435. }
  436. function cloneObj(obj) {
  437. var result = Object.create(null);
  438. for (var i in obj) {
  439. if (Object.prototype.hasOwnProperty.call(obj, i)) {
  440. result[i] = obj[i];
  441. }
  442. }
  443. return result;
  444. }
  445. var WaitOnType = {
  446. EVENT: 'event',
  447. TIMEOUT: 'timeout'
  448. };
  449. function waitOnEventOrTimeout(_ref2) {
  450. var target = _ref2.target,
  451. name = _ref2.name,
  452. _ref2$delay = _ref2.delay,
  453. delay = _ref2$delay === undefined ? 0 : _ref2$delay;
  454. if ((typeof target === 'undefined' ? 'undefined' : _typeof(target)) !== 'object' || !(name && typeof name === 'string') || !(Number.isInteger(delay) && delay >= 0)) {
  455. return Promise.reject(new Error('waitOnEventOrTimeout - invalid parameters.'));
  456. }
  457. var capability = (0, _pdfjsLib.createPromiseCapability)();
  458. function handler(type) {
  459. if (target instanceof EventBus) {
  460. target.off(name, eventHandler);
  461. } else {
  462. target.removeEventListener(name, eventHandler);
  463. }
  464. if (timeout) {
  465. clearTimeout(timeout);
  466. }
  467. capability.resolve(type);
  468. }
  469. var eventHandler = handler.bind(null, WaitOnType.EVENT);
  470. if (target instanceof EventBus) {
  471. target.on(name, eventHandler);
  472. } else {
  473. target.addEventListener(name, eventHandler);
  474. }
  475. var timeoutHandler = handler.bind(null, WaitOnType.TIMEOUT);
  476. var timeout = setTimeout(timeoutHandler, delay);
  477. return capability.promise;
  478. }
  479. var animationStarted = new Promise(function (resolve) {
  480. window.requestAnimationFrame(resolve);
  481. });
  482. var EventBus = function () {
  483. function EventBus() {
  484. _classCallCheck(this, EventBus);
  485. this._listeners = Object.create(null);
  486. }
  487. _createClass(EventBus, [{
  488. key: 'on',
  489. value: function on(eventName, listener) {
  490. var eventListeners = this._listeners[eventName];
  491. if (!eventListeners) {
  492. eventListeners = [];
  493. this._listeners[eventName] = eventListeners;
  494. }
  495. eventListeners.push(listener);
  496. }
  497. }, {
  498. key: 'off',
  499. value: function off(eventName, listener) {
  500. var eventListeners = this._listeners[eventName];
  501. var i = void 0;
  502. if (!eventListeners || (i = eventListeners.indexOf(listener)) < 0) {
  503. return;
  504. }
  505. eventListeners.splice(i, 1);
  506. }
  507. }, {
  508. key: 'dispatch',
  509. value: function dispatch(eventName) {
  510. var eventListeners = this._listeners[eventName];
  511. if (!eventListeners || eventListeners.length === 0) {
  512. return;
  513. }
  514. var args = Array.prototype.slice.call(arguments, 1);
  515. eventListeners.slice(0).forEach(function (listener) {
  516. listener.apply(null, args);
  517. });
  518. }
  519. }]);
  520. return EventBus;
  521. }();
  522. function clamp(v, min, max) {
  523. return Math.min(Math.max(v, min), max);
  524. }
  525. var ProgressBar = function () {
  526. function ProgressBar(id) {
  527. var _ref3 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
  528. height = _ref3.height,
  529. width = _ref3.width,
  530. units = _ref3.units;
  531. _classCallCheck(this, ProgressBar);
  532. this.visible = true;
  533. this.div = document.querySelector(id + ' .progress');
  534. this.bar = this.div.parentNode;
  535. this.height = height || 100;
  536. this.width = width || 100;
  537. this.units = units || '%';
  538. this.div.style.height = this.height + this.units;
  539. this.percent = 0;
  540. }
  541. _createClass(ProgressBar, [{
  542. key: '_updateBar',
  543. value: function _updateBar() {
  544. if (this._indeterminate) {
  545. this.div.classList.add('indeterminate');
  546. this.div.style.width = this.width + this.units;
  547. return;
  548. }
  549. this.div.classList.remove('indeterminate');
  550. var progressSize = this.width * this._percent / 100;
  551. this.div.style.width = progressSize + this.units;
  552. }
  553. }, {
  554. key: 'setWidth',
  555. value: function setWidth(viewer) {
  556. if (!viewer) {
  557. return;
  558. }
  559. var container = viewer.parentNode;
  560. var scrollbarWidth = container.offsetWidth - viewer.offsetWidth;
  561. if (scrollbarWidth > 0) {
  562. this.bar.setAttribute('style', 'width: calc(100% - ' + scrollbarWidth + 'px);');
  563. }
  564. }
  565. }, {
  566. key: 'hide',
  567. value: function hide() {
  568. if (!this.visible) {
  569. return;
  570. }
  571. this.visible = false;
  572. this.bar.classList.add('hidden');
  573. document.body.classList.remove('loadingInProgress');
  574. }
  575. }, {
  576. key: 'show',
  577. value: function show() {
  578. if (this.visible) {
  579. return;
  580. }
  581. this.visible = true;
  582. document.body.classList.add('loadingInProgress');
  583. this.bar.classList.remove('hidden');
  584. }
  585. }, {
  586. key: 'percent',
  587. get: function get() {
  588. return this._percent;
  589. },
  590. set: function set(val) {
  591. this._indeterminate = isNaN(val);
  592. this._percent = clamp(val, 0, 100);
  593. this._updateBar();
  594. }
  595. }]);
  596. return ProgressBar;
  597. }();
  598. exports.CSS_UNITS = CSS_UNITS;
  599. exports.DEFAULT_SCALE_VALUE = DEFAULT_SCALE_VALUE;
  600. exports.DEFAULT_SCALE = DEFAULT_SCALE;
  601. exports.MIN_SCALE = MIN_SCALE;
  602. exports.MAX_SCALE = MAX_SCALE;
  603. exports.UNKNOWN_SCALE = UNKNOWN_SCALE;
  604. exports.MAX_AUTO_SCALE = MAX_AUTO_SCALE;
  605. exports.SCROLLBAR_PADDING = SCROLLBAR_PADDING;
  606. exports.VERTICAL_PADDING = VERTICAL_PADDING;
  607. exports.isValidRotation = isValidRotation;
  608. exports.isPortraitOrientation = isPortraitOrientation;
  609. exports.isFileSchema = isFileSchema;
  610. exports.cloneObj = cloneObj;
  611. exports.PresentationModeState = PresentationModeState;
  612. exports.RendererType = RendererType;
  613. exports.TextLayerMode = TextLayerMode;
  614. exports.NullL10n = NullL10n;
  615. exports.EventBus = EventBus;
  616. exports.ProgressBar = ProgressBar;
  617. exports.getPDFFileNameFromURL = getPDFFileNameFromURL;
  618. exports.noContextMenuHandler = noContextMenuHandler;
  619. exports.parseQueryString = parseQueryString;
  620. exports.getVisibleElements = getVisibleElements;
  621. exports.roundToDivide = roundToDivide;
  622. exports.getPageSizeInches = getPageSizeInches;
  623. exports.approximateFraction = approximateFraction;
  624. exports.getOutputScale = getOutputScale;
  625. exports.scrollIntoView = scrollIntoView;
  626. exports.watchScroll = watchScroll;
  627. exports.binarySearchFirstItem = binarySearchFirstItem;
  628. exports.normalizeWheelEventDelta = normalizeWheelEventDelta;
  629. exports.animationStarted = animationStarted;
  630. exports.WaitOnType = WaitOnType;
  631. exports.waitOnEventOrTimeout = waitOnEventOrTimeout;
  632. /***/ }),
  633. /* 1 */
  634. /***/ (function(module, exports, __w_pdfjs_require__) {
  635. "use strict";
  636. var pdfjsLib = void 0;
  637. if (typeof window !== 'undefined' && window['pdfjs-dist/build/pdf']) {
  638. pdfjsLib = window['pdfjs-dist/build/pdf'];
  639. } else {
  640. pdfjsLib = require('../build/pdf.js');
  641. }
  642. module.exports = pdfjsLib;
  643. /***/ }),
  644. /* 2 */
  645. /***/ (function(module, exports, __w_pdfjs_require__) {
  646. "use strict";
  647. Object.defineProperty(exports, "__esModule", {
  648. value: true
  649. });
  650. exports.getGlobalEventBus = exports.attachDOMEventsToEventBus = undefined;
  651. var _ui_utils = __w_pdfjs_require__(0);
  652. function attachDOMEventsToEventBus(eventBus) {
  653. eventBus.on('documentload', function () {
  654. var event = document.createEvent('CustomEvent');
  655. event.initCustomEvent('documentload', true, true, {});
  656. window.dispatchEvent(event);
  657. });
  658. eventBus.on('pagerendered', function (evt) {
  659. var event = document.createEvent('CustomEvent');
  660. event.initCustomEvent('pagerendered', true, true, {
  661. pageNumber: evt.pageNumber,
  662. cssTransform: evt.cssTransform
  663. });
  664. evt.source.div.dispatchEvent(event);
  665. });
  666. eventBus.on('textlayerrendered', function (evt) {
  667. var event = document.createEvent('CustomEvent');
  668. event.initCustomEvent('textlayerrendered', true, true, { pageNumber: evt.pageNumber });
  669. evt.source.textLayerDiv.dispatchEvent(event);
  670. });
  671. eventBus.on('pagechange', function (evt) {
  672. var event = document.createEvent('UIEvents');
  673. event.initUIEvent('pagechange', true, true, window, 0);
  674. event.pageNumber = evt.pageNumber;
  675. evt.source.container.dispatchEvent(event);
  676. });
  677. eventBus.on('pagesinit', function (evt) {
  678. var event = document.createEvent('CustomEvent');
  679. event.initCustomEvent('pagesinit', true, true, null);
  680. evt.source.container.dispatchEvent(event);
  681. });
  682. eventBus.on('pagesloaded', function (evt) {
  683. var event = document.createEvent('CustomEvent');
  684. event.initCustomEvent('pagesloaded', true, true, { pagesCount: evt.pagesCount });
  685. evt.source.container.dispatchEvent(event);
  686. });
  687. eventBus.on('scalechange', function (evt) {
  688. var event = document.createEvent('UIEvents');
  689. event.initUIEvent('scalechange', true, true, window, 0);
  690. event.scale = evt.scale;
  691. event.presetValue = evt.presetValue;
  692. evt.source.container.dispatchEvent(event);
  693. });
  694. eventBus.on('updateviewarea', function (evt) {
  695. var event = document.createEvent('UIEvents');
  696. event.initUIEvent('updateviewarea', true, true, window, 0);
  697. event.location = evt.location;
  698. evt.source.container.dispatchEvent(event);
  699. });
  700. eventBus.on('find', function (evt) {
  701. if (evt.source === window) {
  702. return;
  703. }
  704. var event = document.createEvent('CustomEvent');
  705. event.initCustomEvent('find' + evt.type, true, true, {
  706. query: evt.query,
  707. phraseSearch: evt.phraseSearch,
  708. caseSensitive: evt.caseSensitive,
  709. highlightAll: evt.highlightAll,
  710. findPrevious: evt.findPrevious
  711. });
  712. window.dispatchEvent(event);
  713. });
  714. eventBus.on('attachmentsloaded', function (evt) {
  715. var event = document.createEvent('CustomEvent');
  716. event.initCustomEvent('attachmentsloaded', true, true, { attachmentsCount: evt.attachmentsCount });
  717. evt.source.container.dispatchEvent(event);
  718. });
  719. eventBus.on('sidebarviewchanged', function (evt) {
  720. var event = document.createEvent('CustomEvent');
  721. event.initCustomEvent('sidebarviewchanged', true, true, { view: evt.view });
  722. evt.source.outerContainer.dispatchEvent(event);
  723. });
  724. eventBus.on('pagemode', function (evt) {
  725. var event = document.createEvent('CustomEvent');
  726. event.initCustomEvent('pagemode', true, true, { mode: evt.mode });
  727. evt.source.pdfViewer.container.dispatchEvent(event);
  728. });
  729. eventBus.on('namedaction', function (evt) {
  730. var event = document.createEvent('CustomEvent');
  731. event.initCustomEvent('namedaction', true, true, { action: evt.action });
  732. evt.source.pdfViewer.container.dispatchEvent(event);
  733. });
  734. eventBus.on('presentationmodechanged', function (evt) {
  735. var event = document.createEvent('CustomEvent');
  736. event.initCustomEvent('presentationmodechanged', true, true, {
  737. active: evt.active,
  738. switchInProgress: evt.switchInProgress
  739. });
  740. window.dispatchEvent(event);
  741. });
  742. eventBus.on('outlineloaded', function (evt) {
  743. var event = document.createEvent('CustomEvent');
  744. event.initCustomEvent('outlineloaded', true, true, { outlineCount: evt.outlineCount });
  745. evt.source.container.dispatchEvent(event);
  746. });
  747. }
  748. var globalEventBus = null;
  749. function getGlobalEventBus() {
  750. if (globalEventBus) {
  751. return globalEventBus;
  752. }
  753. globalEventBus = new _ui_utils.EventBus();
  754. attachDOMEventsToEventBus(globalEventBus);
  755. return globalEventBus;
  756. }
  757. exports.attachDOMEventsToEventBus = attachDOMEventsToEventBus;
  758. exports.getGlobalEventBus = getGlobalEventBus;
  759. /***/ }),
  760. /* 3 */
  761. /***/ (function(module, exports, __w_pdfjs_require__) {
  762. "use strict";
  763. Object.defineProperty(exports, "__esModule", {
  764. value: true
  765. });
  766. exports.SimpleLinkService = exports.PDFLinkService = undefined;
  767. var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
  768. var _createClass = function () { 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); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  769. var _dom_events = __w_pdfjs_require__(2);
  770. var _ui_utils = __w_pdfjs_require__(0);
  771. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  772. var PDFLinkService = function () {
  773. function PDFLinkService() {
  774. var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
  775. eventBus = _ref.eventBus,
  776. _ref$externalLinkTarg = _ref.externalLinkTarget,
  777. externalLinkTarget = _ref$externalLinkTarg === undefined ? null : _ref$externalLinkTarg,
  778. _ref$externalLinkRel = _ref.externalLinkRel,
  779. externalLinkRel = _ref$externalLinkRel === undefined ? null : _ref$externalLinkRel;
  780. _classCallCheck(this, PDFLinkService);
  781. this.eventBus = eventBus || (0, _dom_events.getGlobalEventBus)();
  782. this.externalLinkTarget = externalLinkTarget;
  783. this.externalLinkRel = externalLinkRel;
  784. this.baseUrl = null;
  785. this.pdfDocument = null;
  786. this.pdfViewer = null;
  787. this.pdfHistory = null;
  788. this._pagesRefCache = null;
  789. }
  790. _createClass(PDFLinkService, [{
  791. key: 'setDocument',
  792. value: function setDocument(pdfDocument, baseUrl) {
  793. this.baseUrl = baseUrl;
  794. this.pdfDocument = pdfDocument;
  795. this._pagesRefCache = Object.create(null);
  796. }
  797. }, {
  798. key: 'setViewer',
  799. value: function setViewer(pdfViewer) {
  800. this.pdfViewer = pdfViewer;
  801. }
  802. }, {
  803. key: 'setHistory',
  804. value: function setHistory(pdfHistory) {
  805. this.pdfHistory = pdfHistory;
  806. }
  807. }, {
  808. key: 'navigateTo',
  809. value: function navigateTo(dest) {
  810. var _this = this;
  811. var goToDestination = function goToDestination(_ref2) {
  812. var namedDest = _ref2.namedDest,
  813. explicitDest = _ref2.explicitDest;
  814. var destRef = explicitDest[0],
  815. pageNumber = void 0;
  816. if (destRef instanceof Object) {
  817. pageNumber = _this._cachedPageNumber(destRef);
  818. if (pageNumber === null) {
  819. _this.pdfDocument.getPageIndex(destRef).then(function (pageIndex) {
  820. _this.cachePageRef(pageIndex + 1, destRef);
  821. goToDestination({
  822. namedDest: namedDest,
  823. explicitDest: explicitDest
  824. });
  825. }).catch(function () {
  826. console.error('PDFLinkService.navigateTo: "' + destRef + '" is not ' + ('a valid page reference, for dest="' + dest + '".'));
  827. });
  828. return;
  829. }
  830. } else if (Number.isInteger(destRef)) {
  831. pageNumber = destRef + 1;
  832. } else {
  833. console.error('PDFLinkService.navigateTo: "' + destRef + '" is not ' + ('a valid destination reference, for dest="' + dest + '".'));
  834. return;
  835. }
  836. if (!pageNumber || pageNumber < 1 || pageNumber > _this.pagesCount) {
  837. console.error('PDFLinkService.navigateTo: "' + pageNumber + '" is not ' + ('a valid page number, for dest="' + dest + '".'));
  838. return;
  839. }
  840. if (_this.pdfHistory) {
  841. _this.pdfHistory.pushCurrentPosition();
  842. _this.pdfHistory.push({
  843. namedDest: namedDest,
  844. explicitDest: explicitDest,
  845. pageNumber: pageNumber
  846. });
  847. }
  848. _this.pdfViewer.scrollPageIntoView({
  849. pageNumber: pageNumber,
  850. destArray: explicitDest
  851. });
  852. };
  853. new Promise(function (resolve, reject) {
  854. if (typeof dest === 'string') {
  855. _this.pdfDocument.getDestination(dest).then(function (destArray) {
  856. resolve({
  857. namedDest: dest,
  858. explicitDest: destArray
  859. });
  860. });
  861. return;
  862. }
  863. resolve({
  864. namedDest: '',
  865. explicitDest: dest
  866. });
  867. }).then(function (data) {
  868. if (!(data.explicitDest instanceof Array)) {
  869. console.error('PDFLinkService.navigateTo: "' + data.explicitDest + '" is' + (' not a valid destination array, for dest="' + dest + '".'));
  870. return;
  871. }
  872. goToDestination(data);
  873. });
  874. }
  875. }, {
  876. key: 'getDestinationHash',
  877. value: function getDestinationHash(dest) {
  878. if (typeof dest === 'string') {
  879. return this.getAnchorUrl('#' + escape(dest));
  880. }
  881. if (dest instanceof Array) {
  882. var str = JSON.stringify(dest);
  883. return this.getAnchorUrl('#' + escape(str));
  884. }
  885. return this.getAnchorUrl('');
  886. }
  887. }, {
  888. key: 'getAnchorUrl',
  889. value: function getAnchorUrl(anchor) {
  890. return (this.baseUrl || '') + anchor;
  891. }
  892. }, {
  893. key: 'setHash',
  894. value: function setHash(hash) {
  895. var pageNumber = void 0,
  896. dest = void 0;
  897. if (hash.includes('=')) {
  898. var params = (0, _ui_utils.parseQueryString)(hash);
  899. if ('search' in params) {
  900. this.eventBus.dispatch('findfromurlhash', {
  901. source: this,
  902. query: params['search'].replace(/"/g, ''),
  903. phraseSearch: params['phrase'] === 'true'
  904. });
  905. }
  906. if ('nameddest' in params) {
  907. this.navigateTo(params.nameddest);
  908. return;
  909. }
  910. if ('page' in params) {
  911. pageNumber = params.page | 0 || 1;
  912. }
  913. if ('zoom' in params) {
  914. var zoomArgs = params.zoom.split(',');
  915. var zoomArg = zoomArgs[0];
  916. var zoomArgNumber = parseFloat(zoomArg);
  917. if (!zoomArg.includes('Fit')) {
  918. dest = [null, { name: 'XYZ' }, zoomArgs.length > 1 ? zoomArgs[1] | 0 : null, zoomArgs.length > 2 ? zoomArgs[2] | 0 : null, zoomArgNumber ? zoomArgNumber / 100 : zoomArg];
  919. } else {
  920. if (zoomArg === 'Fit' || zoomArg === 'FitB') {
  921. dest = [null, { name: zoomArg }];
  922. } else if (zoomArg === 'FitH' || zoomArg === 'FitBH' || zoomArg === 'FitV' || zoomArg === 'FitBV') {
  923. dest = [null, { name: zoomArg }, zoomArgs.length > 1 ? zoomArgs[1] | 0 : null];
  924. } else if (zoomArg === 'FitR') {
  925. if (zoomArgs.length !== 5) {
  926. console.error('PDFLinkService.setHash: Not enough parameters for "FitR".');
  927. } else {
  928. dest = [null, { name: zoomArg }, zoomArgs[1] | 0, zoomArgs[2] | 0, zoomArgs[3] | 0, zoomArgs[4] | 0];
  929. }
  930. } else {
  931. console.error('PDFLinkService.setHash: "' + zoomArg + '" is not ' + 'a valid zoom value.');
  932. }
  933. }
  934. }
  935. if (dest) {
  936. this.pdfViewer.scrollPageIntoView({
  937. pageNumber: pageNumber || this.page,
  938. destArray: dest,
  939. allowNegativeOffset: true
  940. });
  941. } else if (pageNumber) {
  942. this.page = pageNumber;
  943. }
  944. if ('pagemode' in params) {
  945. this.eventBus.dispatch('pagemode', {
  946. source: this,
  947. mode: params.pagemode
  948. });
  949. }
  950. } else {
  951. dest = unescape(hash);
  952. try {
  953. dest = JSON.parse(dest);
  954. if (!(dest instanceof Array)) {
  955. dest = dest.toString();
  956. }
  957. } catch (ex) {}
  958. if (typeof dest === 'string' || isValidExplicitDestination(dest)) {
  959. this.navigateTo(dest);
  960. return;
  961. }
  962. console.error('PDFLinkService.setHash: "' + unescape(hash) + '" is not ' + 'a valid destination.');
  963. }
  964. }
  965. }, {
  966. key: 'executeNamedAction',
  967. value: function executeNamedAction(action) {
  968. switch (action) {
  969. case 'GoBack':
  970. if (this.pdfHistory) {
  971. this.pdfHistory.back();
  972. }
  973. break;
  974. case 'GoForward':
  975. if (this.pdfHistory) {
  976. this.pdfHistory.forward();
  977. }
  978. break;
  979. case 'NextPage':
  980. if (this.page < this.pagesCount) {
  981. this.page++;
  982. }
  983. break;
  984. case 'PrevPage':
  985. if (this.page > 1) {
  986. this.page--;
  987. }
  988. break;
  989. case 'LastPage':
  990. this.page = this.pagesCount;
  991. break;
  992. case 'FirstPage':
  993. this.page = 1;
  994. break;
  995. default:
  996. break;
  997. }
  998. this.eventBus.dispatch('namedaction', {
  999. source: this,
  1000. action: action
  1001. });
  1002. }
  1003. }, {
  1004. key: 'onFileAttachmentAnnotation',
  1005. value: function onFileAttachmentAnnotation(_ref3) {
  1006. var id = _ref3.id,
  1007. filename = _ref3.filename,
  1008. content = _ref3.content;
  1009. this.eventBus.dispatch('fileattachmentannotation', {
  1010. source: this,
  1011. id: id,
  1012. filename: filename,
  1013. content: content
  1014. });
  1015. }
  1016. }, {
  1017. key: 'cachePageRef',
  1018. value: function cachePageRef(pageNum, pageRef) {
  1019. if (!pageRef) {
  1020. return;
  1021. }
  1022. var refStr = pageRef.num + ' ' + pageRef.gen + ' R';
  1023. this._pagesRefCache[refStr] = pageNum;
  1024. }
  1025. }, {
  1026. key: '_cachedPageNumber',
  1027. value: function _cachedPageNumber(pageRef) {
  1028. var refStr = pageRef.num + ' ' + pageRef.gen + ' R';
  1029. return this._pagesRefCache && this._pagesRefCache[refStr] || null;
  1030. }
  1031. }, {
  1032. key: 'pagesCount',
  1033. get: function get() {
  1034. return this.pdfDocument ? this.pdfDocument.numPages : 0;
  1035. }
  1036. }, {
  1037. key: 'page',
  1038. get: function get() {
  1039. return this.pdfViewer.currentPageNumber;
  1040. },
  1041. set: function set(value) {
  1042. this.pdfViewer.currentPageNumber = value;
  1043. }
  1044. }, {
  1045. key: 'rotation',
  1046. get: function get() {
  1047. return this.pdfViewer.pagesRotation;
  1048. },
  1049. set: function set(value) {
  1050. this.pdfViewer.pagesRotation = value;
  1051. }
  1052. }]);
  1053. return PDFLinkService;
  1054. }();
  1055. function isValidExplicitDestination(dest) {
  1056. if (!(dest instanceof Array)) {
  1057. return false;
  1058. }
  1059. var destLength = dest.length,
  1060. allowNull = true;
  1061. if (destLength < 2) {
  1062. return false;
  1063. }
  1064. var page = dest[0];
  1065. if (!((typeof page === 'undefined' ? 'undefined' : _typeof(page)) === 'object' && Number.isInteger(page.num) && Number.isInteger(page.gen)) && !(Number.isInteger(page) && page >= 0)) {
  1066. return false;
  1067. }
  1068. var zoom = dest[1];
  1069. if (!((typeof zoom === 'undefined' ? 'undefined' : _typeof(zoom)) === 'object' && typeof zoom.name === 'string')) {
  1070. return false;
  1071. }
  1072. switch (zoom.name) {
  1073. case 'XYZ':
  1074. if (destLength !== 5) {
  1075. return false;
  1076. }
  1077. break;
  1078. case 'Fit':
  1079. case 'FitB':
  1080. return destLength === 2;
  1081. case 'FitH':
  1082. case 'FitBH':
  1083. case 'FitV':
  1084. case 'FitBV':
  1085. if (destLength !== 3) {
  1086. return false;
  1087. }
  1088. break;
  1089. case 'FitR':
  1090. if (destLength !== 6) {
  1091. return false;
  1092. }
  1093. allowNull = false;
  1094. break;
  1095. default:
  1096. return false;
  1097. }
  1098. for (var i = 2; i < destLength; i++) {
  1099. var param = dest[i];
  1100. if (!(typeof param === 'number' || allowNull && param === null)) {
  1101. return false;
  1102. }
  1103. }
  1104. return true;
  1105. }
  1106. var SimpleLinkService = function () {
  1107. function SimpleLinkService() {
  1108. _classCallCheck(this, SimpleLinkService);
  1109. this.externalLinkTarget = null;
  1110. this.externalLinkRel = null;
  1111. }
  1112. _createClass(SimpleLinkService, [{
  1113. key: 'navigateTo',
  1114. value: function navigateTo(dest) {}
  1115. }, {
  1116. key: 'getDestinationHash',
  1117. value: function getDestinationHash(dest) {
  1118. return '#';
  1119. }
  1120. }, {
  1121. key: 'getAnchorUrl',
  1122. value: function getAnchorUrl(hash) {
  1123. return '#';
  1124. }
  1125. }, {
  1126. key: 'setHash',
  1127. value: function setHash(hash) {}
  1128. }, {
  1129. key: 'executeNamedAction',
  1130. value: function executeNamedAction(action) {}
  1131. }, {
  1132. key: 'onFileAttachmentAnnotation',
  1133. value: function onFileAttachmentAnnotation(_ref4) {
  1134. var id = _ref4.id,
  1135. filename = _ref4.filename,
  1136. content = _ref4.content;
  1137. }
  1138. }, {
  1139. key: 'cachePageRef',
  1140. value: function cachePageRef(pageNum, pageRef) {}
  1141. }, {
  1142. key: 'page',
  1143. get: function get() {
  1144. return 0;
  1145. },
  1146. set: function set(value) {}
  1147. }, {
  1148. key: 'rotation',
  1149. get: function get() {
  1150. return 0;
  1151. },
  1152. set: function set(value) {}
  1153. }]);
  1154. return SimpleLinkService;
  1155. }();
  1156. exports.PDFLinkService = PDFLinkService;
  1157. exports.SimpleLinkService = SimpleLinkService;
  1158. /***/ }),
  1159. /* 4 */
  1160. /***/ (function(module, exports, __w_pdfjs_require__) {
  1161. "use strict";
  1162. Object.defineProperty(exports, "__esModule", {
  1163. value: true
  1164. });
  1165. exports.DefaultAnnotationLayerFactory = exports.AnnotationLayerBuilder = undefined;
  1166. var _createClass = function () { 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); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  1167. var _pdfjsLib = __w_pdfjs_require__(1);
  1168. var _ui_utils = __w_pdfjs_require__(0);
  1169. var _pdf_link_service = __w_pdfjs_require__(3);
  1170. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  1171. var AnnotationLayerBuilder = function () {
  1172. function AnnotationLayerBuilder(_ref) {
  1173. var pageDiv = _ref.pageDiv,
  1174. pdfPage = _ref.pdfPage,
  1175. linkService = _ref.linkService,
  1176. downloadManager = _ref.downloadManager,
  1177. _ref$imageResourcesPa = _ref.imageResourcesPath,
  1178. imageResourcesPath = _ref$imageResourcesPa === undefined ? '' : _ref$imageResourcesPa,
  1179. _ref$renderInteractiv = _ref.renderInteractiveForms,
  1180. renderInteractiveForms = _ref$renderInteractiv === undefined ? false : _ref$renderInteractiv,
  1181. _ref$l10n = _ref.l10n,
  1182. l10n = _ref$l10n === undefined ? _ui_utils.NullL10n : _ref$l10n;
  1183. _classCallCheck(this, AnnotationLayerBuilder);
  1184. this.pageDiv = pageDiv;
  1185. this.pdfPage = pdfPage;
  1186. this.linkService = linkService;
  1187. this.downloadManager = downloadManager;
  1188. this.imageResourcesPath = imageResourcesPath;
  1189. this.renderInteractiveForms = renderInteractiveForms;
  1190. this.l10n = l10n;
  1191. this.div = null;
  1192. this._cancelled = false;
  1193. }
  1194. _createClass(AnnotationLayerBuilder, [{
  1195. key: 'render',
  1196. value: function render(viewport) {
  1197. var _this = this;
  1198. var intent = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'display';
  1199. this.pdfPage.getAnnotations({ intent: intent }).then(function (annotations) {
  1200. if (_this._cancelled) {
  1201. return;
  1202. }
  1203. var parameters = {
  1204. viewport: viewport.clone({ dontFlip: true }),
  1205. div: _this.div,
  1206. annotations: annotations,
  1207. page: _this.pdfPage,
  1208. imageResourcesPath: _this.imageResourcesPath,
  1209. renderInteractiveForms: _this.renderInteractiveForms,
  1210. linkService: _this.linkService,
  1211. downloadManager: _this.downloadManager
  1212. };
  1213. if (_this.div) {
  1214. _pdfjsLib.AnnotationLayer.update(parameters);
  1215. } else {
  1216. if (annotations.length === 0) {
  1217. return;
  1218. }
  1219. _this.div = document.createElement('div');
  1220. _this.div.className = 'annotationLayer';
  1221. _this.pageDiv.appendChild(_this.div);
  1222. parameters.div = _this.div;
  1223. _pdfjsLib.AnnotationLayer.render(parameters);
  1224. _this.l10n.translate(_this.div);
  1225. }
  1226. });
  1227. }
  1228. }, {
  1229. key: 'cancel',
  1230. value: function cancel() {
  1231. this._cancelled = true;
  1232. }
  1233. }, {
  1234. key: 'hide',
  1235. value: function hide() {
  1236. if (!this.div) {
  1237. return;
  1238. }
  1239. this.div.setAttribute('hidden', 'true');
  1240. }
  1241. }]);
  1242. return AnnotationLayerBuilder;
  1243. }();
  1244. var DefaultAnnotationLayerFactory = function () {
  1245. function DefaultAnnotationLayerFactory() {
  1246. _classCallCheck(this, DefaultAnnotationLayerFactory);
  1247. }
  1248. _createClass(DefaultAnnotationLayerFactory, [{
  1249. key: 'createAnnotationLayerBuilder',
  1250. value: function createAnnotationLayerBuilder(pageDiv, pdfPage) {
  1251. var imageResourcesPath = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
  1252. var renderInteractiveForms = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
  1253. var l10n = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : _ui_utils.NullL10n;
  1254. return new AnnotationLayerBuilder({
  1255. pageDiv: pageDiv,
  1256. pdfPage: pdfPage,
  1257. imageResourcesPath: imageResourcesPath,
  1258. renderInteractiveForms: renderInteractiveForms,
  1259. linkService: new _pdf_link_service.SimpleLinkService(),
  1260. l10n: l10n
  1261. });
  1262. }
  1263. }]);
  1264. return DefaultAnnotationLayerFactory;
  1265. }();
  1266. exports.AnnotationLayerBuilder = AnnotationLayerBuilder;
  1267. exports.DefaultAnnotationLayerFactory = DefaultAnnotationLayerFactory;
  1268. /***/ }),
  1269. /* 5 */
  1270. /***/ (function(module, exports, __w_pdfjs_require__) {
  1271. "use strict";
  1272. Object.defineProperty(exports, "__esModule", {
  1273. value: true
  1274. });
  1275. exports.DefaultTextLayerFactory = exports.TextLayerBuilder = undefined;
  1276. var _createClass = function () { 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); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  1277. var _dom_events = __w_pdfjs_require__(2);
  1278. var _pdfjsLib = __w_pdfjs_require__(1);
  1279. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  1280. var EXPAND_DIVS_TIMEOUT = 300;
  1281. var TextLayerBuilder = function () {
  1282. function TextLayerBuilder(_ref) {
  1283. var textLayerDiv = _ref.textLayerDiv,
  1284. eventBus = _ref.eventBus,
  1285. pageIndex = _ref.pageIndex,
  1286. viewport = _ref.viewport,
  1287. _ref$findController = _ref.findController,
  1288. findController = _ref$findController === undefined ? null : _ref$findController,
  1289. _ref$enhanceTextSelec = _ref.enhanceTextSelection,
  1290. enhanceTextSelection = _ref$enhanceTextSelec === undefined ? false : _ref$enhanceTextSelec;
  1291. _classCallCheck(this, TextLayerBuilder);
  1292. this.textLayerDiv = textLayerDiv;
  1293. this.eventBus = eventBus || (0, _dom_events.getGlobalEventBus)();
  1294. this.textContent = null;
  1295. this.textContentItemsStr = [];
  1296. this.textContentStream = null;
  1297. this.renderingDone = false;
  1298. this.pageIdx = pageIndex;
  1299. this.pageNumber = this.pageIdx + 1;
  1300. this.matches = [];
  1301. this.viewport = viewport;
  1302. this.textDivs = [];
  1303. this.findController = findController;
  1304. this.textLayerRenderTask = null;
  1305. this.enhanceTextSelection = enhanceTextSelection;
  1306. this._bindMouse();
  1307. }
  1308. _createClass(TextLayerBuilder, [{
  1309. key: '_finishRendering',
  1310. value: function _finishRendering() {
  1311. this.renderingDone = true;
  1312. if (!this.enhanceTextSelection) {
  1313. var endOfContent = document.createElement('div');
  1314. endOfContent.className = 'endOfContent';
  1315. this.textLayerDiv.appendChild(endOfContent);
  1316. }
  1317. this.eventBus.dispatch('textlayerrendered', {
  1318. source: this,
  1319. pageNumber: this.pageNumber,
  1320. numTextDivs: this.textDivs.length
  1321. });
  1322. }
  1323. }, {
  1324. key: 'render',
  1325. value: function render() {
  1326. var _this = this;
  1327. var timeout = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
  1328. if (!(this.textContent || this.textContentStream) || this.renderingDone) {
  1329. return;
  1330. }
  1331. this.cancel();
  1332. this.textDivs = [];
  1333. var textLayerFrag = document.createDocumentFragment();
  1334. this.textLayerRenderTask = (0, _pdfjsLib.renderTextLayer)({
  1335. textContent: this.textContent,
  1336. textContentStream: this.textContentStream,
  1337. container: textLayerFrag,
  1338. viewport: this.viewport,
  1339. textDivs: this.textDivs,
  1340. textContentItemsStr: this.textContentItemsStr,
  1341. timeout: timeout,
  1342. enhanceTextSelection: this.enhanceTextSelection
  1343. });
  1344. this.textLayerRenderTask.promise.then(function () {
  1345. _this.textLayerDiv.appendChild(textLayerFrag);
  1346. _this._finishRendering();
  1347. _this.updateMatches();
  1348. }, function (reason) {});
  1349. }
  1350. }, {
  1351. key: 'cancel',
  1352. value: function cancel() {
  1353. if (this.textLayerRenderTask) {
  1354. this.textLayerRenderTask.cancel();
  1355. this.textLayerRenderTask = null;
  1356. }
  1357. }
  1358. }, {
  1359. key: 'setTextContentStream',
  1360. value: function setTextContentStream(readableStream) {
  1361. this.cancel();
  1362. this.textContentStream = readableStream;
  1363. }
  1364. }, {
  1365. key: 'setTextContent',
  1366. value: function setTextContent(textContent) {
  1367. this.cancel();
  1368. this.textContent = textContent;
  1369. }
  1370. }, {
  1371. key: 'convertMatches',
  1372. value: function convertMatches(matches, matchesLength) {
  1373. var i = 0;
  1374. var iIndex = 0;
  1375. var textContentItemsStr = this.textContentItemsStr;
  1376. var end = textContentItemsStr.length - 1;
  1377. var queryLen = this.findController === null ? 0 : this.findController.state.query.length;
  1378. var ret = [];
  1379. if (!matches) {
  1380. return ret;
  1381. }
  1382. for (var m = 0, len = matches.length; m < len; m++) {
  1383. var matchIdx = matches[m];
  1384. while (i !== end && matchIdx >= iIndex + textContentItemsStr[i].length) {
  1385. iIndex += textContentItemsStr[i].length;
  1386. i++;
  1387. }
  1388. if (i === textContentItemsStr.length) {
  1389. console.error('Could not find a matching mapping');
  1390. }
  1391. var match = {
  1392. begin: {
  1393. divIdx: i,
  1394. offset: matchIdx - iIndex
  1395. }
  1396. };
  1397. if (matchesLength) {
  1398. matchIdx += matchesLength[m];
  1399. } else {
  1400. matchIdx += queryLen;
  1401. }
  1402. while (i !== end && matchIdx > iIndex + textContentItemsStr[i].length) {
  1403. iIndex += textContentItemsStr[i].length;
  1404. i++;
  1405. }
  1406. match.end = {
  1407. divIdx: i,
  1408. offset: matchIdx - iIndex
  1409. };
  1410. ret.push(match);
  1411. }
  1412. return ret;
  1413. }
  1414. }, {
  1415. key: 'renderMatches',
  1416. value: function renderMatches(matches) {
  1417. if (matches.length === 0) {
  1418. return;
  1419. }
  1420. var textContentItemsStr = this.textContentItemsStr;
  1421. var textDivs = this.textDivs;
  1422. var prevEnd = null;
  1423. var pageIdx = this.pageIdx;
  1424. var isSelectedPage = this.findController === null ? false : pageIdx === this.findController.selected.pageIdx;
  1425. var selectedMatchIdx = this.findController === null ? -1 : this.findController.selected.matchIdx;
  1426. var highlightAll = this.findController === null ? false : this.findController.state.highlightAll;
  1427. var infinity = {
  1428. divIdx: -1,
  1429. offset: undefined
  1430. };
  1431. function beginText(begin, className) {
  1432. var divIdx = begin.divIdx;
  1433. textDivs[divIdx].textContent = '';
  1434. appendTextToDiv(divIdx, 0, begin.offset, className);
  1435. }
  1436. function appendTextToDiv(divIdx, fromOffset, toOffset, className) {
  1437. var div = textDivs[divIdx];
  1438. var content = textContentItemsStr[divIdx].substring(fromOffset, toOffset);
  1439. var node = document.createTextNode(content);
  1440. if (className) {
  1441. var span = document.createElement('span');
  1442. span.className = className;
  1443. span.appendChild(node);
  1444. div.appendChild(span);
  1445. return;
  1446. }
  1447. div.appendChild(node);
  1448. }
  1449. var i0 = selectedMatchIdx,
  1450. i1 = i0 + 1;
  1451. if (highlightAll) {
  1452. i0 = 0;
  1453. i1 = matches.length;
  1454. } else if (!isSelectedPage) {
  1455. return;
  1456. }
  1457. for (var i = i0; i < i1; i++) {
  1458. var match = matches[i];
  1459. var begin = match.begin;
  1460. var end = match.end;
  1461. var isSelected = isSelectedPage && i === selectedMatchIdx;
  1462. var highlightSuffix = isSelected ? ' selected' : '';
  1463. if (this.findController) {
  1464. this.findController.updateMatchPosition(pageIdx, i, textDivs, begin.divIdx);
  1465. }
  1466. if (!prevEnd || begin.divIdx !== prevEnd.divIdx) {
  1467. if (prevEnd !== null) {
  1468. appendTextToDiv(prevEnd.divIdx, prevEnd.offset, infinity.offset);
  1469. }
  1470. beginText(begin);
  1471. } else {
  1472. appendTextToDiv(prevEnd.divIdx, prevEnd.offset, begin.offset);
  1473. }
  1474. if (begin.divIdx === end.divIdx) {
  1475. appendTextToDiv(begin.divIdx, begin.offset, end.offset, 'highlight' + highlightSuffix);
  1476. } else {
  1477. appendTextToDiv(begin.divIdx, begin.offset, infinity.offset, 'highlight begin' + highlightSuffix);
  1478. for (var n0 = begin.divIdx + 1, n1 = end.divIdx; n0 < n1; n0++) {
  1479. textDivs[n0].className = 'highlight middle' + highlightSuffix;
  1480. }
  1481. beginText(end, 'highlight end' + highlightSuffix);
  1482. }
  1483. prevEnd = end;
  1484. }
  1485. if (prevEnd) {
  1486. appendTextToDiv(prevEnd.divIdx, prevEnd.offset, infinity.offset);
  1487. }
  1488. }
  1489. }, {
  1490. key: 'updateMatches',
  1491. value: function updateMatches() {
  1492. if (!this.renderingDone) {
  1493. return;
  1494. }
  1495. var matches = this.matches;
  1496. var textDivs = this.textDivs;
  1497. var textContentItemsStr = this.textContentItemsStr;
  1498. var clearedUntilDivIdx = -1;
  1499. for (var i = 0, len = matches.length; i < len; i++) {
  1500. var match = matches[i];
  1501. var begin = Math.max(clearedUntilDivIdx, match.begin.divIdx);
  1502. for (var n = begin, end = match.end.divIdx; n <= end; n++) {
  1503. var div = textDivs[n];
  1504. div.textContent = textContentItemsStr[n];
  1505. div.className = '';
  1506. }
  1507. clearedUntilDivIdx = match.end.divIdx + 1;
  1508. }
  1509. if (this.findController === null || !this.findController.active) {
  1510. return;
  1511. }
  1512. var pageMatches = void 0,
  1513. pageMatchesLength = void 0;
  1514. if (this.findController !== null) {
  1515. pageMatches = this.findController.pageMatches[this.pageIdx] || null;
  1516. pageMatchesLength = this.findController.pageMatchesLength ? this.findController.pageMatchesLength[this.pageIdx] || null : null;
  1517. }
  1518. this.matches = this.convertMatches(pageMatches, pageMatchesLength);
  1519. this.renderMatches(this.matches);
  1520. }
  1521. }, {
  1522. key: '_bindMouse',
  1523. value: function _bindMouse() {
  1524. var _this2 = this;
  1525. var div = this.textLayerDiv;
  1526. var expandDivsTimer = null;
  1527. div.addEventListener('mousedown', function (evt) {
  1528. if (_this2.enhanceTextSelection && _this2.textLayerRenderTask) {
  1529. _this2.textLayerRenderTask.expandTextDivs(true);
  1530. if (expandDivsTimer) {
  1531. clearTimeout(expandDivsTimer);
  1532. expandDivsTimer = null;
  1533. }
  1534. return;
  1535. }
  1536. var end = div.querySelector('.endOfContent');
  1537. if (!end) {
  1538. return;
  1539. }
  1540. var adjustTop = evt.target !== div;
  1541. adjustTop = adjustTop && window.getComputedStyle(end).getPropertyValue('-moz-user-select') !== 'none';
  1542. if (adjustTop) {
  1543. var divBounds = div.getBoundingClientRect();
  1544. var r = Math.max(0, (evt.pageY - divBounds.top) / divBounds.height);
  1545. end.style.top = (r * 100).toFixed(2) + '%';
  1546. }
  1547. end.classList.add('active');
  1548. });
  1549. div.addEventListener('mouseup', function () {
  1550. if (_this2.enhanceTextSelection && _this2.textLayerRenderTask) {
  1551. expandDivsTimer = setTimeout(function () {
  1552. if (_this2.textLayerRenderTask) {
  1553. _this2.textLayerRenderTask.expandTextDivs(false);
  1554. }
  1555. expandDivsTimer = null;
  1556. }, EXPAND_DIVS_TIMEOUT);
  1557. return;
  1558. }
  1559. var end = div.querySelector('.endOfContent');
  1560. if (!end) {
  1561. return;
  1562. }
  1563. end.style.top = '';
  1564. end.classList.remove('active');
  1565. });
  1566. }
  1567. }]);
  1568. return TextLayerBuilder;
  1569. }();
  1570. var DefaultTextLayerFactory = function () {
  1571. function DefaultTextLayerFactory() {
  1572. _classCallCheck(this, DefaultTextLayerFactory);
  1573. }
  1574. _createClass(DefaultTextLayerFactory, [{
  1575. key: 'createTextLayerBuilder',
  1576. value: function createTextLayerBuilder(textLayerDiv, pageIndex, viewport) {
  1577. var enhanceTextSelection = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
  1578. return new TextLayerBuilder({
  1579. textLayerDiv: textLayerDiv,
  1580. pageIndex: pageIndex,
  1581. viewport: viewport,
  1582. enhanceTextSelection: enhanceTextSelection
  1583. });
  1584. }
  1585. }]);
  1586. return DefaultTextLayerFactory;
  1587. }();
  1588. exports.TextLayerBuilder = TextLayerBuilder;
  1589. exports.DefaultTextLayerFactory = DefaultTextLayerFactory;
  1590. /***/ }),
  1591. /* 6 */
  1592. /***/ (function(module, exports, __w_pdfjs_require__) {
  1593. "use strict";
  1594. Object.defineProperty(exports, "__esModule", {
  1595. value: true
  1596. });
  1597. exports.PDFPageView = undefined;
  1598. var _createClass = function () { 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); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  1599. var _ui_utils = __w_pdfjs_require__(0);
  1600. var _pdfjsLib = __w_pdfjs_require__(1);
  1601. var _dom_events = __w_pdfjs_require__(2);
  1602. var _pdf_rendering_queue = __w_pdfjs_require__(7);
  1603. var _viewer_compatibility = __w_pdfjs_require__(15);
  1604. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  1605. var MAX_CANVAS_PIXELS = _viewer_compatibility.viewerCompatibilityParams.maxCanvasPixels || 16777216;
  1606. var PDFPageView = function () {
  1607. function PDFPageView(options) {
  1608. _classCallCheck(this, PDFPageView);
  1609. var container = options.container;
  1610. var defaultViewport = options.defaultViewport;
  1611. this.id = options.id;
  1612. this.renderingId = 'page' + this.id;
  1613. this.pdfPage = null;
  1614. this.pageLabel = null;
  1615. this.rotation = 0;
  1616. this.scale = options.scale || _ui_utils.DEFAULT_SCALE;
  1617. this.viewport = defaultViewport;
  1618. this.pdfPageRotate = defaultViewport.rotation;
  1619. this.hasRestrictedScaling = false;
  1620. this.textLayerMode = Number.isInteger(options.textLayerMode) ? options.textLayerMode : _ui_utils.TextLayerMode.ENABLE;
  1621. this.imageResourcesPath = options.imageResourcesPath || '';
  1622. this.renderInteractiveForms = options.renderInteractiveForms || false;
  1623. this.useOnlyCssZoom = options.useOnlyCssZoom || false;
  1624. this.maxCanvasPixels = options.maxCanvasPixels || MAX_CANVAS_PIXELS;
  1625. this.eventBus = options.eventBus || (0, _dom_events.getGlobalEventBus)();
  1626. this.renderingQueue = options.renderingQueue;
  1627. this.textLayerFactory = options.textLayerFactory;
  1628. this.annotationLayerFactory = options.annotationLayerFactory;
  1629. this.renderer = options.renderer || _ui_utils.RendererType.CANVAS;
  1630. this.enableWebGL = options.enableWebGL || false;
  1631. this.l10n = options.l10n || _ui_utils.NullL10n;
  1632. this.paintTask = null;
  1633. this.paintedViewportMap = new WeakMap();
  1634. this.renderingState = _pdf_rendering_queue.RenderingStates.INITIAL;
  1635. this.resume = null;
  1636. this.error = null;
  1637. this.onBeforeDraw = null;
  1638. this.onAfterDraw = null;
  1639. this.annotationLayer = null;
  1640. this.textLayer = null;
  1641. this.zoomLayer = null;
  1642. var div = document.createElement('div');
  1643. div.className = 'page';
  1644. div.style.width = Math.floor(this.viewport.width) + 'px';
  1645. div.style.height = Math.floor(this.viewport.height) + 'px';
  1646. div.setAttribute('data-page-number', this.id);
  1647. this.div = div;
  1648. container.appendChild(div);
  1649. }
  1650. _createClass(PDFPageView, [{
  1651. key: 'setPdfPage',
  1652. value: function setPdfPage(pdfPage) {
  1653. this.pdfPage = pdfPage;
  1654. this.pdfPageRotate = pdfPage.rotate;
  1655. var totalRotation = (this.rotation + this.pdfPageRotate) % 360;
  1656. this.viewport = pdfPage.getViewport(this.scale * _ui_utils.CSS_UNITS, totalRotation);
  1657. this.stats = pdfPage.stats;
  1658. this.reset();
  1659. }
  1660. }, {
  1661. key: 'destroy',
  1662. value: function destroy() {
  1663. this.reset();
  1664. if (this.pdfPage) {
  1665. this.pdfPage.cleanup();
  1666. }
  1667. }
  1668. }, {
  1669. key: '_resetZoomLayer',
  1670. value: function _resetZoomLayer() {
  1671. var removeFromDOM = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  1672. if (!this.zoomLayer) {
  1673. return;
  1674. }
  1675. var zoomLayerCanvas = this.zoomLayer.firstChild;
  1676. this.paintedViewportMap.delete(zoomLayerCanvas);
  1677. zoomLayerCanvas.width = 0;
  1678. zoomLayerCanvas.height = 0;
  1679. if (removeFromDOM) {
  1680. this.zoomLayer.remove();
  1681. }
  1682. this.zoomLayer = null;
  1683. }
  1684. }, {
  1685. key: 'reset',
  1686. value: function reset() {
  1687. var keepZoomLayer = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  1688. var keepAnnotations = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  1689. this.cancelRendering(keepAnnotations);
  1690. var div = this.div;
  1691. div.style.width = Math.floor(this.viewport.width) + 'px';
  1692. div.style.height = Math.floor(this.viewport.height) + 'px';
  1693. var childNodes = div.childNodes;
  1694. var currentZoomLayerNode = keepZoomLayer && this.zoomLayer || null;
  1695. var currentAnnotationNode = keepAnnotations && this.annotationLayer && this.annotationLayer.div || null;
  1696. for (var i = childNodes.length - 1; i >= 0; i--) {
  1697. var node = childNodes[i];
  1698. if (currentZoomLayerNode === node || currentAnnotationNode === node) {
  1699. continue;
  1700. }
  1701. div.removeChild(node);
  1702. }
  1703. div.removeAttribute('data-loaded');
  1704. if (currentAnnotationNode) {
  1705. this.annotationLayer.hide();
  1706. } else if (this.annotationLayer) {
  1707. this.annotationLayer.cancel();
  1708. this.annotationLayer = null;
  1709. }
  1710. if (!currentZoomLayerNode) {
  1711. if (this.canvas) {
  1712. this.paintedViewportMap.delete(this.canvas);
  1713. this.canvas.width = 0;
  1714. this.canvas.height = 0;
  1715. delete this.canvas;
  1716. }
  1717. this._resetZoomLayer();
  1718. }
  1719. if (this.svg) {
  1720. this.paintedViewportMap.delete(this.svg);
  1721. delete this.svg;
  1722. }
  1723. this.loadingIconDiv = document.createElement('div');
  1724. this.loadingIconDiv.className = 'loadingIcon';
  1725. div.appendChild(this.loadingIconDiv);
  1726. }
  1727. }, {
  1728. key: 'update',
  1729. value: function update(scale, rotation) {
  1730. this.scale = scale || this.scale;
  1731. if (typeof rotation !== 'undefined') {
  1732. this.rotation = rotation;
  1733. }
  1734. var totalRotation = (this.rotation + this.pdfPageRotate) % 360;
  1735. this.viewport = this.viewport.clone({
  1736. scale: this.scale * _ui_utils.CSS_UNITS,
  1737. rotation: totalRotation
  1738. });
  1739. if (this.svg) {
  1740. this.cssTransform(this.svg, true);
  1741. this.eventBus.dispatch('pagerendered', {
  1742. source: this,
  1743. pageNumber: this.id,
  1744. cssTransform: true
  1745. });
  1746. return;
  1747. }
  1748. var isScalingRestricted = false;
  1749. if (this.canvas && this.maxCanvasPixels > 0) {
  1750. var outputScale = this.outputScale;
  1751. if ((Math.floor(this.viewport.width) * outputScale.sx | 0) * (Math.floor(this.viewport.height) * outputScale.sy | 0) > this.maxCanvasPixels) {
  1752. isScalingRestricted = true;
  1753. }
  1754. }
  1755. if (this.canvas) {
  1756. if (this.useOnlyCssZoom || this.hasRestrictedScaling && isScalingRestricted) {
  1757. this.cssTransform(this.canvas, true);
  1758. this.eventBus.dispatch('pagerendered', {
  1759. source: this,
  1760. pageNumber: this.id,
  1761. cssTransform: true
  1762. });
  1763. return;
  1764. }
  1765. if (!this.zoomLayer && !this.canvas.hasAttribute('hidden')) {
  1766. this.zoomLayer = this.canvas.parentNode;
  1767. this.zoomLayer.style.position = 'absolute';
  1768. }
  1769. }
  1770. if (this.zoomLayer) {
  1771. this.cssTransform(this.zoomLayer.firstChild);
  1772. }
  1773. this.reset(true, true);
  1774. }
  1775. }, {
  1776. key: 'cancelRendering',
  1777. value: function cancelRendering() {
  1778. var keepAnnotations = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  1779. if (this.paintTask) {
  1780. this.paintTask.cancel();
  1781. this.paintTask = null;
  1782. }
  1783. this.renderingState = _pdf_rendering_queue.RenderingStates.INITIAL;
  1784. this.resume = null;
  1785. if (this.textLayer) {
  1786. this.textLayer.cancel();
  1787. this.textLayer = null;
  1788. }
  1789. if (!keepAnnotations && this.annotationLayer) {
  1790. this.annotationLayer.cancel();
  1791. this.annotationLayer = null;
  1792. }
  1793. }
  1794. }, {
  1795. key: 'cssTransform',
  1796. value: function cssTransform(target) {
  1797. var redrawAnnotations = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  1798. var width = this.viewport.width;
  1799. var height = this.viewport.height;
  1800. var div = this.div;
  1801. target.style.width = target.parentNode.style.width = div.style.width = Math.floor(width) + 'px';
  1802. target.style.height = target.parentNode.style.height = div.style.height = Math.floor(height) + 'px';
  1803. var relativeRotation = this.viewport.rotation - this.paintedViewportMap.get(target).rotation;
  1804. var absRotation = Math.abs(relativeRotation);
  1805. var scaleX = 1,
  1806. scaleY = 1;
  1807. if (absRotation === 90 || absRotation === 270) {
  1808. scaleX = height / width;
  1809. scaleY = width / height;
  1810. }
  1811. var cssTransform = 'rotate(' + relativeRotation + 'deg) ' + 'scale(' + scaleX + ',' + scaleY + ')';
  1812. target.style.transform = cssTransform;
  1813. if (this.textLayer) {
  1814. var textLayerViewport = this.textLayer.viewport;
  1815. var textRelativeRotation = this.viewport.rotation - textLayerViewport.rotation;
  1816. var textAbsRotation = Math.abs(textRelativeRotation);
  1817. var scale = width / textLayerViewport.width;
  1818. if (textAbsRotation === 90 || textAbsRotation === 270) {
  1819. scale = width / textLayerViewport.height;
  1820. }
  1821. var textLayerDiv = this.textLayer.textLayerDiv;
  1822. var transX = void 0,
  1823. transY = void 0;
  1824. switch (textAbsRotation) {
  1825. case 0:
  1826. transX = transY = 0;
  1827. break;
  1828. case 90:
  1829. transX = 0;
  1830. transY = '-' + textLayerDiv.style.height;
  1831. break;
  1832. case 180:
  1833. transX = '-' + textLayerDiv.style.width;
  1834. transY = '-' + textLayerDiv.style.height;
  1835. break;
  1836. case 270:
  1837. transX = '-' + textLayerDiv.style.width;
  1838. transY = 0;
  1839. break;
  1840. default:
  1841. console.error('Bad rotation value.');
  1842. break;
  1843. }
  1844. textLayerDiv.style.transform = 'rotate(' + textAbsRotation + 'deg) ' + 'scale(' + scale + ', ' + scale + ') ' + 'translate(' + transX + ', ' + transY + ')';
  1845. textLayerDiv.style.transformOrigin = '0% 0%';
  1846. }
  1847. if (redrawAnnotations && this.annotationLayer) {
  1848. this.annotationLayer.render(this.viewport, 'display');
  1849. }
  1850. }
  1851. }, {
  1852. key: 'getPagePoint',
  1853. value: function getPagePoint(x, y) {
  1854. return this.viewport.convertToPdfPoint(x, y);
  1855. }
  1856. }, {
  1857. key: 'draw',
  1858. value: function draw() {
  1859. var _this = this;
  1860. if (this.renderingState !== _pdf_rendering_queue.RenderingStates.INITIAL) {
  1861. console.error('Must be in new state before drawing');
  1862. this.reset();
  1863. }
  1864. if (!this.pdfPage) {
  1865. this.renderingState = _pdf_rendering_queue.RenderingStates.FINISHED;
  1866. return Promise.reject(new Error('Page is not loaded'));
  1867. }
  1868. this.renderingState = _pdf_rendering_queue.RenderingStates.RUNNING;
  1869. var pdfPage = this.pdfPage;
  1870. var div = this.div;
  1871. var canvasWrapper = document.createElement('div');
  1872. canvasWrapper.style.width = div.style.width;
  1873. canvasWrapper.style.height = div.style.height;
  1874. canvasWrapper.classList.add('canvasWrapper');
  1875. if (this.annotationLayer && this.annotationLayer.div) {
  1876. div.insertBefore(canvasWrapper, this.annotationLayer.div);
  1877. } else {
  1878. div.appendChild(canvasWrapper);
  1879. }
  1880. var textLayer = null;
  1881. if (this.textLayerMode !== _ui_utils.TextLayerMode.DISABLE && this.textLayerFactory) {
  1882. var textLayerDiv = document.createElement('div');
  1883. textLayerDiv.className = 'textLayer';
  1884. textLayerDiv.style.width = canvasWrapper.style.width;
  1885. textLayerDiv.style.height = canvasWrapper.style.height;
  1886. if (this.annotationLayer && this.annotationLayer.div) {
  1887. div.insertBefore(textLayerDiv, this.annotationLayer.div);
  1888. } else {
  1889. div.appendChild(textLayerDiv);
  1890. }
  1891. textLayer = this.textLayerFactory.createTextLayerBuilder(textLayerDiv, this.id - 1, this.viewport, this.textLayerMode === _ui_utils.TextLayerMode.ENABLE_ENHANCE);
  1892. }
  1893. this.textLayer = textLayer;
  1894. var renderContinueCallback = null;
  1895. if (this.renderingQueue) {
  1896. renderContinueCallback = function renderContinueCallback(cont) {
  1897. if (!_this.renderingQueue.isHighestPriority(_this)) {
  1898. _this.renderingState = _pdf_rendering_queue.RenderingStates.PAUSED;
  1899. _this.resume = function () {
  1900. _this.renderingState = _pdf_rendering_queue.RenderingStates.RUNNING;
  1901. cont();
  1902. };
  1903. return;
  1904. }
  1905. cont();
  1906. };
  1907. }
  1908. var finishPaintTask = function finishPaintTask(error) {
  1909. if (paintTask === _this.paintTask) {
  1910. _this.paintTask = null;
  1911. }
  1912. if (error instanceof _pdfjsLib.RenderingCancelledException) {
  1913. _this.error = null;
  1914. return Promise.resolve(undefined);
  1915. }
  1916. _this.renderingState = _pdf_rendering_queue.RenderingStates.FINISHED;
  1917. if (_this.loadingIconDiv) {
  1918. div.removeChild(_this.loadingIconDiv);
  1919. delete _this.loadingIconDiv;
  1920. }
  1921. _this._resetZoomLayer(true);
  1922. _this.error = error;
  1923. _this.stats = pdfPage.stats;
  1924. if (_this.onAfterDraw) {
  1925. _this.onAfterDraw();
  1926. }
  1927. _this.eventBus.dispatch('pagerendered', {
  1928. source: _this,
  1929. pageNumber: _this.id,
  1930. cssTransform: false
  1931. });
  1932. if (error) {
  1933. return Promise.reject(error);
  1934. }
  1935. return Promise.resolve(undefined);
  1936. };
  1937. var paintTask = this.renderer === _ui_utils.RendererType.SVG ? this.paintOnSvg(canvasWrapper) : this.paintOnCanvas(canvasWrapper);
  1938. paintTask.onRenderContinue = renderContinueCallback;
  1939. this.paintTask = paintTask;
  1940. var resultPromise = paintTask.promise.then(function () {
  1941. return finishPaintTask(null).then(function () {
  1942. if (textLayer) {
  1943. var readableStream = pdfPage.streamTextContent({ normalizeWhitespace: true });
  1944. textLayer.setTextContentStream(readableStream);
  1945. textLayer.render();
  1946. }
  1947. });
  1948. }, function (reason) {
  1949. return finishPaintTask(reason);
  1950. });
  1951. if (this.annotationLayerFactory) {
  1952. if (!this.annotationLayer) {
  1953. this.annotationLayer = this.annotationLayerFactory.createAnnotationLayerBuilder(div, pdfPage, this.imageResourcesPath, this.renderInteractiveForms, this.l10n);
  1954. }
  1955. this.annotationLayer.render(this.viewport, 'display');
  1956. }
  1957. div.setAttribute('data-loaded', true);
  1958. if (this.onBeforeDraw) {
  1959. this.onBeforeDraw();
  1960. }
  1961. return resultPromise;
  1962. }
  1963. }, {
  1964. key: 'paintOnCanvas',
  1965. value: function paintOnCanvas(canvasWrapper) {
  1966. var renderCapability = (0, _pdfjsLib.createPromiseCapability)();
  1967. var result = {
  1968. promise: renderCapability.promise,
  1969. onRenderContinue: function onRenderContinue(cont) {
  1970. cont();
  1971. },
  1972. cancel: function cancel() {
  1973. renderTask.cancel();
  1974. }
  1975. };
  1976. var viewport = this.viewport;
  1977. var canvas = document.createElement('canvas');
  1978. canvas.id = this.renderingId;
  1979. canvas.setAttribute('hidden', 'hidden');
  1980. var isCanvasHidden = true;
  1981. var showCanvas = function showCanvas() {
  1982. if (isCanvasHidden) {
  1983. canvas.removeAttribute('hidden');
  1984. isCanvasHidden = false;
  1985. }
  1986. };
  1987. canvasWrapper.appendChild(canvas);
  1988. this.canvas = canvas;
  1989. canvas.mozOpaque = true;
  1990. var ctx = canvas.getContext('2d', { alpha: false });
  1991. var outputScale = (0, _ui_utils.getOutputScale)(ctx);
  1992. this.outputScale = outputScale;
  1993. if (this.useOnlyCssZoom) {
  1994. var actualSizeViewport = viewport.clone({ scale: _ui_utils.CSS_UNITS });
  1995. outputScale.sx *= actualSizeViewport.width / viewport.width;
  1996. outputScale.sy *= actualSizeViewport.height / viewport.height;
  1997. outputScale.scaled = true;
  1998. }
  1999. if (this.maxCanvasPixels > 0) {
  2000. var pixelsInViewport = viewport.width * viewport.height;
  2001. var maxScale = Math.sqrt(this.maxCanvasPixels / pixelsInViewport);
  2002. if (outputScale.sx > maxScale || outputScale.sy > maxScale) {
  2003. outputScale.sx = maxScale;
  2004. outputScale.sy = maxScale;
  2005. outputScale.scaled = true;
  2006. this.hasRestrictedScaling = true;
  2007. } else {
  2008. this.hasRestrictedScaling = false;
  2009. }
  2010. }
  2011. var sfx = (0, _ui_utils.approximateFraction)(outputScale.sx);
  2012. var sfy = (0, _ui_utils.approximateFraction)(outputScale.sy);
  2013. canvas.width = (0, _ui_utils.roundToDivide)(viewport.width * outputScale.sx, sfx[0]);
  2014. canvas.height = (0, _ui_utils.roundToDivide)(viewport.height * outputScale.sy, sfy[0]);
  2015. canvas.style.width = (0, _ui_utils.roundToDivide)(viewport.width, sfx[1]) + 'px';
  2016. canvas.style.height = (0, _ui_utils.roundToDivide)(viewport.height, sfy[1]) + 'px';
  2017. this.paintedViewportMap.set(canvas, viewport);
  2018. var transform = !outputScale.scaled ? null : [outputScale.sx, 0, 0, outputScale.sy, 0, 0];
  2019. var renderContext = {
  2020. canvasContext: ctx,
  2021. transform: transform,
  2022. viewport: this.viewport,
  2023. enableWebGL: this.enableWebGL,
  2024. renderInteractiveForms: this.renderInteractiveForms
  2025. };
  2026. var renderTask = this.pdfPage.render(renderContext);
  2027. renderTask.onContinue = function (cont) {
  2028. showCanvas();
  2029. if (result.onRenderContinue) {
  2030. result.onRenderContinue(cont);
  2031. } else {
  2032. cont();
  2033. }
  2034. };
  2035. renderTask.promise.then(function () {
  2036. showCanvas();
  2037. renderCapability.resolve(undefined);
  2038. }, function (error) {
  2039. showCanvas();
  2040. renderCapability.reject(error);
  2041. });
  2042. return result;
  2043. }
  2044. }, {
  2045. key: 'paintOnSvg',
  2046. value: function paintOnSvg(wrapper) {
  2047. var _this2 = this;
  2048. var cancelled = false;
  2049. var ensureNotCancelled = function ensureNotCancelled() {
  2050. if (cancelled) {
  2051. throw new _pdfjsLib.RenderingCancelledException('Rendering cancelled, page ' + _this2.id, 'svg');
  2052. }
  2053. };
  2054. var pdfPage = this.pdfPage;
  2055. var actualSizeViewport = this.viewport.clone({ scale: _ui_utils.CSS_UNITS });
  2056. var promise = pdfPage.getOperatorList().then(function (opList) {
  2057. ensureNotCancelled();
  2058. var svgGfx = new _pdfjsLib.SVGGraphics(pdfPage.commonObjs, pdfPage.objs);
  2059. return svgGfx.getSVG(opList, actualSizeViewport).then(function (svg) {
  2060. ensureNotCancelled();
  2061. _this2.svg = svg;
  2062. _this2.paintedViewportMap.set(svg, actualSizeViewport);
  2063. svg.style.width = wrapper.style.width;
  2064. svg.style.height = wrapper.style.height;
  2065. _this2.renderingState = _pdf_rendering_queue.RenderingStates.FINISHED;
  2066. wrapper.appendChild(svg);
  2067. });
  2068. });
  2069. return {
  2070. promise: promise,
  2071. onRenderContinue: function onRenderContinue(cont) {
  2072. cont();
  2073. },
  2074. cancel: function cancel() {
  2075. cancelled = true;
  2076. }
  2077. };
  2078. }
  2079. }, {
  2080. key: 'setPageLabel',
  2081. value: function setPageLabel(label) {
  2082. this.pageLabel = typeof label === 'string' ? label : null;
  2083. if (this.pageLabel !== null) {
  2084. this.div.setAttribute('data-page-label', this.pageLabel);
  2085. } else {
  2086. this.div.removeAttribute('data-page-label');
  2087. }
  2088. }
  2089. }, {
  2090. key: 'width',
  2091. get: function get() {
  2092. return this.viewport.width;
  2093. }
  2094. }, {
  2095. key: 'height',
  2096. get: function get() {
  2097. return this.viewport.height;
  2098. }
  2099. }]);
  2100. return PDFPageView;
  2101. }();
  2102. exports.PDFPageView = PDFPageView;
  2103. /***/ }),
  2104. /* 7 */
  2105. /***/ (function(module, exports, __w_pdfjs_require__) {
  2106. "use strict";
  2107. Object.defineProperty(exports, "__esModule", {
  2108. value: true
  2109. });
  2110. var _createClass = function () { 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); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  2111. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  2112. var CLEANUP_TIMEOUT = 30000;
  2113. var RenderingStates = {
  2114. INITIAL: 0,
  2115. RUNNING: 1,
  2116. PAUSED: 2,
  2117. FINISHED: 3
  2118. };
  2119. var PDFRenderingQueue = function () {
  2120. function PDFRenderingQueue() {
  2121. _classCallCheck(this, PDFRenderingQueue);
  2122. this.pdfViewer = null;
  2123. this.pdfThumbnailViewer = null;
  2124. this.onIdle = null;
  2125. this.highestPriorityPage = null;
  2126. this.idleTimeout = null;
  2127. this.printing = false;
  2128. this.isThumbnailViewEnabled = false;
  2129. }
  2130. _createClass(PDFRenderingQueue, [{
  2131. key: "setViewer",
  2132. value: function setViewer(pdfViewer) {
  2133. this.pdfViewer = pdfViewer;
  2134. }
  2135. }, {
  2136. key: "setThumbnailViewer",
  2137. value: function setThumbnailViewer(pdfThumbnailViewer) {
  2138. this.pdfThumbnailViewer = pdfThumbnailViewer;
  2139. }
  2140. }, {
  2141. key: "isHighestPriority",
  2142. value: function isHighestPriority(view) {
  2143. return this.highestPriorityPage === view.renderingId;
  2144. }
  2145. }, {
  2146. key: "renderHighestPriority",
  2147. value: function renderHighestPriority(currentlyVisiblePages) {
  2148. if (this.idleTimeout) {
  2149. clearTimeout(this.idleTimeout);
  2150. this.idleTimeout = null;
  2151. }
  2152. if (this.pdfViewer.forceRendering(currentlyVisiblePages)) {
  2153. return;
  2154. }
  2155. if (this.pdfThumbnailViewer && this.isThumbnailViewEnabled) {
  2156. if (this.pdfThumbnailViewer.forceRendering()) {
  2157. return;
  2158. }
  2159. }
  2160. if (this.printing) {
  2161. return;
  2162. }
  2163. if (this.onIdle) {
  2164. this.idleTimeout = setTimeout(this.onIdle.bind(this), CLEANUP_TIMEOUT);
  2165. }
  2166. }
  2167. }, {
  2168. key: "getHighestPriority",
  2169. value: function getHighestPriority(visible, views, scrolledDown) {
  2170. var visibleViews = visible.views;
  2171. var numVisible = visibleViews.length;
  2172. if (numVisible === 0) {
  2173. return false;
  2174. }
  2175. for (var i = 0; i < numVisible; ++i) {
  2176. var view = visibleViews[i].view;
  2177. if (!this.isViewFinished(view)) {
  2178. return view;
  2179. }
  2180. }
  2181. if (scrolledDown) {
  2182. var nextPageIndex = visible.last.id;
  2183. if (views[nextPageIndex] && !this.isViewFinished(views[nextPageIndex])) {
  2184. return views[nextPageIndex];
  2185. }
  2186. } else {
  2187. var previousPageIndex = visible.first.id - 2;
  2188. if (views[previousPageIndex] && !this.isViewFinished(views[previousPageIndex])) {
  2189. return views[previousPageIndex];
  2190. }
  2191. }
  2192. return null;
  2193. }
  2194. }, {
  2195. key: "isViewFinished",
  2196. value: function isViewFinished(view) {
  2197. return view.renderingState === RenderingStates.FINISHED;
  2198. }
  2199. }, {
  2200. key: "renderView",
  2201. value: function renderView(view) {
  2202. var _this = this;
  2203. switch (view.renderingState) {
  2204. case RenderingStates.FINISHED:
  2205. return false;
  2206. case RenderingStates.PAUSED:
  2207. this.highestPriorityPage = view.renderingId;
  2208. view.resume();
  2209. break;
  2210. case RenderingStates.RUNNING:
  2211. this.highestPriorityPage = view.renderingId;
  2212. break;
  2213. case RenderingStates.INITIAL:
  2214. this.highestPriorityPage = view.renderingId;
  2215. var continueRendering = function continueRendering() {
  2216. _this.renderHighestPriority();
  2217. };
  2218. view.draw().then(continueRendering, continueRendering);
  2219. break;
  2220. }
  2221. return true;
  2222. }
  2223. }]);
  2224. return PDFRenderingQueue;
  2225. }();
  2226. exports.RenderingStates = RenderingStates;
  2227. exports.PDFRenderingQueue = PDFRenderingQueue;
  2228. /***/ }),
  2229. /* 8 */
  2230. /***/ (function(module, exports, __w_pdfjs_require__) {
  2231. "use strict";
  2232. Object.defineProperty(exports, "__esModule", {
  2233. value: true
  2234. });
  2235. exports.BaseViewer = undefined;
  2236. var _createClass = function () { 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); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  2237. var _ui_utils = __w_pdfjs_require__(0);
  2238. var _pdf_rendering_queue = __w_pdfjs_require__(7);
  2239. var _annotation_layer_builder = __w_pdfjs_require__(4);
  2240. var _pdfjsLib = __w_pdfjs_require__(1);
  2241. var _dom_events = __w_pdfjs_require__(2);
  2242. var _pdf_page_view = __w_pdfjs_require__(6);
  2243. var _pdf_link_service = __w_pdfjs_require__(3);
  2244. var _text_layer_builder = __w_pdfjs_require__(5);
  2245. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  2246. var DEFAULT_CACHE_SIZE = 10;
  2247. function PDFPageViewBuffer(size) {
  2248. var data = [];
  2249. this.push = function (view) {
  2250. var i = data.indexOf(view);
  2251. if (i >= 0) {
  2252. data.splice(i, 1);
  2253. }
  2254. data.push(view);
  2255. if (data.length > size) {
  2256. data.shift().destroy();
  2257. }
  2258. };
  2259. this.resize = function (newSize) {
  2260. size = newSize;
  2261. while (data.length > size) {
  2262. data.shift().destroy();
  2263. }
  2264. };
  2265. }
  2266. function isSameScale(oldScale, newScale) {
  2267. if (newScale === oldScale) {
  2268. return true;
  2269. }
  2270. if (Math.abs(newScale - oldScale) < 1e-15) {
  2271. return true;
  2272. }
  2273. return false;
  2274. }
  2275. var BaseViewer = function () {
  2276. function BaseViewer(options) {
  2277. _classCallCheck(this, BaseViewer);
  2278. if (this.constructor === BaseViewer) {
  2279. throw new Error('Cannot initialize BaseViewer.');
  2280. }
  2281. this._name = this.constructor.name;
  2282. this.container = options.container;
  2283. this.viewer = options.viewer || options.container.firstElementChild;
  2284. this.eventBus = options.eventBus || (0, _dom_events.getGlobalEventBus)();
  2285. this.linkService = options.linkService || new _pdf_link_service.SimpleLinkService();
  2286. this.downloadManager = options.downloadManager || null;
  2287. this.removePageBorders = options.removePageBorders || false;
  2288. this.textLayerMode = Number.isInteger(options.textLayerMode) ? options.textLayerMode : _ui_utils.TextLayerMode.ENABLE;
  2289. this.enhanceTextSelection = options.enhanceTextSelection || false;
  2290. this.imageResourcesPath = options.imageResourcesPath || '';
  2291. this.renderInteractiveForms = options.renderInteractiveForms || false;
  2292. this.enablePrintAutoRotate = options.enablePrintAutoRotate || false;
  2293. this.renderer = options.renderer || _ui_utils.RendererType.CANVAS;
  2294. this.enableWebGL = options.enableWebGL || false;
  2295. this.useOnlyCssZoom = options.useOnlyCssZoom || false;
  2296. this.maxCanvasPixels = options.maxCanvasPixels;
  2297. this.l10n = options.l10n || _ui_utils.NullL10n;
  2298. this.defaultRenderingQueue = !options.renderingQueue;
  2299. if (this.defaultRenderingQueue) {
  2300. this.renderingQueue = new _pdf_rendering_queue.PDFRenderingQueue();
  2301. this.renderingQueue.setViewer(this);
  2302. } else {
  2303. this.renderingQueue = options.renderingQueue;
  2304. }
  2305. this.scroll = (0, _ui_utils.watchScroll)(this.container, this._scrollUpdate.bind(this));
  2306. this.presentationModeState = _ui_utils.PresentationModeState.UNKNOWN;
  2307. this._resetView();
  2308. if (this.removePageBorders) {
  2309. this.viewer.classList.add('removePageBorders');
  2310. }
  2311. }
  2312. _createClass(BaseViewer, [{
  2313. key: 'getPageView',
  2314. value: function getPageView(index) {
  2315. return this._pages[index];
  2316. }
  2317. }, {
  2318. key: '_setCurrentPageNumber',
  2319. value: function _setCurrentPageNumber(val) {
  2320. var resetCurrentPageView = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  2321. if (this._currentPageNumber === val) {
  2322. if (resetCurrentPageView) {
  2323. this._resetCurrentPageView();
  2324. }
  2325. return;
  2326. }
  2327. if (!(0 < val && val <= this.pagesCount)) {
  2328. console.error(this._name + '._setCurrentPageNumber: "' + val + '" is out of bounds.');
  2329. return;
  2330. }
  2331. var arg = {
  2332. source: this,
  2333. pageNumber: val,
  2334. pageLabel: this._pageLabels && this._pageLabels[val - 1]
  2335. };
  2336. this._currentPageNumber = val;
  2337. this.eventBus.dispatch('pagechanging', arg);
  2338. this.eventBus.dispatch('pagechange', arg);
  2339. if (resetCurrentPageView) {
  2340. this._resetCurrentPageView();
  2341. }
  2342. }
  2343. }, {
  2344. key: 'setDocument',
  2345. value: function setDocument(pdfDocument) {
  2346. var _this = this;
  2347. if (this.pdfDocument) {
  2348. this._cancelRendering();
  2349. this._resetView();
  2350. }
  2351. this.pdfDocument = pdfDocument;
  2352. if (!pdfDocument) {
  2353. return;
  2354. }
  2355. var pagesCount = pdfDocument.numPages;
  2356. var pagesCapability = (0, _pdfjsLib.createPromiseCapability)();
  2357. this.pagesPromise = pagesCapability.promise;
  2358. pagesCapability.promise.then(function () {
  2359. _this._pageViewsReady = true;
  2360. _this.eventBus.dispatch('pagesloaded', {
  2361. source: _this,
  2362. pagesCount: pagesCount
  2363. });
  2364. });
  2365. var isOnePageRenderedResolved = false;
  2366. var onePageRenderedCapability = (0, _pdfjsLib.createPromiseCapability)();
  2367. this.onePageRendered = onePageRenderedCapability.promise;
  2368. var bindOnAfterAndBeforeDraw = function bindOnAfterAndBeforeDraw(pageView) {
  2369. pageView.onBeforeDraw = function () {
  2370. _this._buffer.push(pageView);
  2371. };
  2372. pageView.onAfterDraw = function () {
  2373. if (!isOnePageRenderedResolved) {
  2374. isOnePageRenderedResolved = true;
  2375. onePageRenderedCapability.resolve();
  2376. }
  2377. };
  2378. };
  2379. var firstPagePromise = pdfDocument.getPage(1);
  2380. this.firstPagePromise = firstPagePromise;
  2381. firstPagePromise.then(function (pdfPage) {
  2382. var scale = _this.currentScale;
  2383. var viewport = pdfPage.getViewport(scale * _ui_utils.CSS_UNITS);
  2384. for (var pageNum = 1; pageNum <= pagesCount; ++pageNum) {
  2385. var textLayerFactory = null;
  2386. if (_this.textLayerMode !== _ui_utils.TextLayerMode.DISABLE) {
  2387. textLayerFactory = _this;
  2388. }
  2389. var pageView = new _pdf_page_view.PDFPageView({
  2390. container: _this._setDocumentViewerElement,
  2391. eventBus: _this.eventBus,
  2392. id: pageNum,
  2393. scale: scale,
  2394. defaultViewport: viewport.clone(),
  2395. renderingQueue: _this.renderingQueue,
  2396. textLayerFactory: textLayerFactory,
  2397. textLayerMode: _this.textLayerMode,
  2398. annotationLayerFactory: _this,
  2399. imageResourcesPath: _this.imageResourcesPath,
  2400. renderInteractiveForms: _this.renderInteractiveForms,
  2401. renderer: _this.renderer,
  2402. enableWebGL: _this.enableWebGL,
  2403. useOnlyCssZoom: _this.useOnlyCssZoom,
  2404. maxCanvasPixels: _this.maxCanvasPixels,
  2405. l10n: _this.l10n
  2406. });
  2407. bindOnAfterAndBeforeDraw(pageView);
  2408. _this._pages.push(pageView);
  2409. }
  2410. onePageRenderedCapability.promise.then(function () {
  2411. if (pdfDocument.loadingParams['disableAutoFetch']) {
  2412. pagesCapability.resolve();
  2413. return;
  2414. }
  2415. var getPagesLeft = pagesCount;
  2416. var _loop = function _loop(_pageNum) {
  2417. pdfDocument.getPage(_pageNum).then(function (pdfPage) {
  2418. var pageView = _this._pages[_pageNum - 1];
  2419. if (!pageView.pdfPage) {
  2420. pageView.setPdfPage(pdfPage);
  2421. }
  2422. _this.linkService.cachePageRef(_pageNum, pdfPage.ref);
  2423. if (--getPagesLeft === 0) {
  2424. pagesCapability.resolve();
  2425. }
  2426. }, function (reason) {
  2427. console.error('Unable to get page ' + _pageNum + ' to initialize viewer', reason);
  2428. if (--getPagesLeft === 0) {
  2429. pagesCapability.resolve();
  2430. }
  2431. });
  2432. };
  2433. for (var _pageNum = 1; _pageNum <= pagesCount; ++_pageNum) {
  2434. _loop(_pageNum);
  2435. }
  2436. });
  2437. _this.eventBus.dispatch('pagesinit', { source: _this });
  2438. if (_this.defaultRenderingQueue) {
  2439. _this.update();
  2440. }
  2441. if (_this.findController) {
  2442. _this.findController.resolveFirstPage();
  2443. }
  2444. }).catch(function (reason) {
  2445. console.error('Unable to initialize viewer', reason);
  2446. });
  2447. }
  2448. }, {
  2449. key: 'setPageLabels',
  2450. value: function setPageLabels(labels) {
  2451. if (!this.pdfDocument) {
  2452. return;
  2453. }
  2454. if (!labels) {
  2455. this._pageLabels = null;
  2456. } else if (!(labels instanceof Array && this.pdfDocument.numPages === labels.length)) {
  2457. this._pageLabels = null;
  2458. console.error(this._name + '.setPageLabels: Invalid page labels.');
  2459. } else {
  2460. this._pageLabels = labels;
  2461. }
  2462. for (var i = 0, ii = this._pages.length; i < ii; i++) {
  2463. var pageView = this._pages[i];
  2464. var label = this._pageLabels && this._pageLabels[i];
  2465. pageView.setPageLabel(label);
  2466. }
  2467. }
  2468. }, {
  2469. key: '_resetView',
  2470. value: function _resetView() {
  2471. this._pages = [];
  2472. this._currentPageNumber = 1;
  2473. this._currentScale = _ui_utils.UNKNOWN_SCALE;
  2474. this._currentScaleValue = null;
  2475. this._pageLabels = null;
  2476. this._buffer = new PDFPageViewBuffer(DEFAULT_CACHE_SIZE);
  2477. this._location = null;
  2478. this._pagesRotation = 0;
  2479. this._pagesRequests = [];
  2480. this._pageViewsReady = false;
  2481. this.viewer.textContent = '';
  2482. }
  2483. }, {
  2484. key: '_scrollUpdate',
  2485. value: function _scrollUpdate() {
  2486. if (this.pagesCount === 0) {
  2487. return;
  2488. }
  2489. this.update();
  2490. }
  2491. }, {
  2492. key: '_scrollIntoView',
  2493. value: function _scrollIntoView(_ref) {
  2494. var pageDiv = _ref.pageDiv,
  2495. _ref$pageSpot = _ref.pageSpot,
  2496. pageSpot = _ref$pageSpot === undefined ? null : _ref$pageSpot,
  2497. _ref$pageNumber = _ref.pageNumber,
  2498. pageNumber = _ref$pageNumber === undefined ? null : _ref$pageNumber;
  2499. throw new Error('Not implemented: _scrollIntoView');
  2500. }
  2501. }, {
  2502. key: '_setScaleDispatchEvent',
  2503. value: function _setScaleDispatchEvent(newScale, newValue) {
  2504. var preset = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  2505. var arg = {
  2506. source: this,
  2507. scale: newScale,
  2508. presetValue: preset ? newValue : undefined
  2509. };
  2510. this.eventBus.dispatch('scalechanging', arg);
  2511. this.eventBus.dispatch('scalechange', arg);
  2512. }
  2513. }, {
  2514. key: '_setScaleUpdatePages',
  2515. value: function _setScaleUpdatePages(newScale, newValue) {
  2516. var noScroll = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  2517. var preset = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
  2518. this._currentScaleValue = newValue.toString();
  2519. if (isSameScale(this._currentScale, newScale)) {
  2520. if (preset) {
  2521. this._setScaleDispatchEvent(newScale, newValue, true);
  2522. }
  2523. return;
  2524. }
  2525. for (var i = 0, ii = this._pages.length; i < ii; i++) {
  2526. this._pages[i].update(newScale);
  2527. }
  2528. this._currentScale = newScale;
  2529. if (!noScroll) {
  2530. var page = this._currentPageNumber,
  2531. dest = void 0;
  2532. if (this._location && !(this.isInPresentationMode || this.isChangingPresentationMode)) {
  2533. page = this._location.pageNumber;
  2534. dest = [null, { name: 'XYZ' }, this._location.left, this._location.top, null];
  2535. }
  2536. this.scrollPageIntoView({
  2537. pageNumber: page,
  2538. destArray: dest,
  2539. allowNegativeOffset: true
  2540. });
  2541. }
  2542. this._setScaleDispatchEvent(newScale, newValue, preset);
  2543. if (this.defaultRenderingQueue) {
  2544. this.update();
  2545. }
  2546. }
  2547. }, {
  2548. key: '_setScale',
  2549. value: function _setScale(value) {
  2550. var noScroll = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  2551. var scale = parseFloat(value);
  2552. if (scale > 0) {
  2553. this._setScaleUpdatePages(scale, value, noScroll, false);
  2554. } else {
  2555. var currentPage = this._pages[this._currentPageNumber - 1];
  2556. if (!currentPage) {
  2557. return;
  2558. }
  2559. var hPadding = this.isInPresentationMode || this.removePageBorders ? 0 : _ui_utils.SCROLLBAR_PADDING;
  2560. var vPadding = this.isInPresentationMode || this.removePageBorders ? 0 : _ui_utils.VERTICAL_PADDING;
  2561. var pageWidthScale = (this.container.clientWidth - hPadding) / currentPage.width * currentPage.scale;
  2562. var pageHeightScale = (this.container.clientHeight - vPadding) / currentPage.height * currentPage.scale;
  2563. switch (value) {
  2564. case 'page-actual':
  2565. scale = 1;
  2566. break;
  2567. case 'page-width':
  2568. scale = pageWidthScale;
  2569. break;
  2570. case 'page-height':
  2571. scale = pageHeightScale;
  2572. break;
  2573. case 'page-fit':
  2574. scale = Math.min(pageWidthScale, pageHeightScale);
  2575. break;
  2576. case 'auto':
  2577. var horizontalScale = (0, _ui_utils.isPortraitOrientation)(currentPage) ? pageWidthScale : Math.min(pageHeightScale, pageWidthScale);
  2578. scale = Math.min(_ui_utils.MAX_AUTO_SCALE, horizontalScale);
  2579. break;
  2580. default:
  2581. console.error(this._name + '._setScale: "' + value + '" is an unknown zoom value.');
  2582. return;
  2583. }
  2584. this._setScaleUpdatePages(scale, value, noScroll, true);
  2585. }
  2586. }
  2587. }, {
  2588. key: '_resetCurrentPageView',
  2589. value: function _resetCurrentPageView() {
  2590. if (this.isInPresentationMode) {
  2591. this._setScale(this._currentScaleValue, true);
  2592. }
  2593. var pageView = this._pages[this._currentPageNumber - 1];
  2594. this._scrollIntoView({ pageDiv: pageView.div });
  2595. }
  2596. }, {
  2597. key: 'scrollPageIntoView',
  2598. value: function scrollPageIntoView(params) {
  2599. if (!this.pdfDocument) {
  2600. return;
  2601. }
  2602. var pageNumber = params.pageNumber || 0;
  2603. var dest = params.destArray || null;
  2604. var allowNegativeOffset = params.allowNegativeOffset || false;
  2605. if (this.isInPresentationMode || !dest) {
  2606. this._setCurrentPageNumber(pageNumber, true);
  2607. return;
  2608. }
  2609. var pageView = this._pages[pageNumber - 1];
  2610. if (!pageView) {
  2611. console.error(this._name + '.scrollPageIntoView: Invalid "pageNumber" parameter.');
  2612. return;
  2613. }
  2614. var x = 0,
  2615. y = 0;
  2616. var width = 0,
  2617. height = 0,
  2618. widthScale = void 0,
  2619. heightScale = void 0;
  2620. var changeOrientation = pageView.rotation % 180 === 0 ? false : true;
  2621. var pageWidth = (changeOrientation ? pageView.height : pageView.width) / pageView.scale / _ui_utils.CSS_UNITS;
  2622. var pageHeight = (changeOrientation ? pageView.width : pageView.height) / pageView.scale / _ui_utils.CSS_UNITS;
  2623. var scale = 0;
  2624. switch (dest[1].name) {
  2625. case 'XYZ':
  2626. x = dest[2];
  2627. y = dest[3];
  2628. scale = dest[4];
  2629. x = x !== null ? x : 0;
  2630. y = y !== null ? y : pageHeight;
  2631. break;
  2632. case 'Fit':
  2633. case 'FitB':
  2634. scale = 'page-fit';
  2635. break;
  2636. case 'FitH':
  2637. case 'FitBH':
  2638. y = dest[2];
  2639. scale = 'page-width';
  2640. if (y === null && this._location) {
  2641. x = this._location.left;
  2642. y = this._location.top;
  2643. }
  2644. break;
  2645. case 'FitV':
  2646. case 'FitBV':
  2647. x = dest[2];
  2648. width = pageWidth;
  2649. height = pageHeight;
  2650. scale = 'page-height';
  2651. break;
  2652. case 'FitR':
  2653. x = dest[2];
  2654. y = dest[3];
  2655. width = dest[4] - x;
  2656. height = dest[5] - y;
  2657. var hPadding = this.removePageBorders ? 0 : _ui_utils.SCROLLBAR_PADDING;
  2658. var vPadding = this.removePageBorders ? 0 : _ui_utils.VERTICAL_PADDING;
  2659. widthScale = (this.container.clientWidth - hPadding) / width / _ui_utils.CSS_UNITS;
  2660. heightScale = (this.container.clientHeight - vPadding) / height / _ui_utils.CSS_UNITS;
  2661. scale = Math.min(Math.abs(widthScale), Math.abs(heightScale));
  2662. break;
  2663. default:
  2664. console.error(this._name + '.scrollPageIntoView: "' + dest[1].name + '" ' + 'is not a valid destination type.');
  2665. return;
  2666. }
  2667. if (scale && scale !== this._currentScale) {
  2668. this.currentScaleValue = scale;
  2669. } else if (this._currentScale === _ui_utils.UNKNOWN_SCALE) {
  2670. this.currentScaleValue = _ui_utils.DEFAULT_SCALE_VALUE;
  2671. }
  2672. if (scale === 'page-fit' && !dest[4]) {
  2673. this._scrollIntoView({
  2674. pageDiv: pageView.div,
  2675. pageNumber: pageNumber
  2676. });
  2677. return;
  2678. }
  2679. var boundingRect = [pageView.viewport.convertToViewportPoint(x, y), pageView.viewport.convertToViewportPoint(x + width, y + height)];
  2680. var left = Math.min(boundingRect[0][0], boundingRect[1][0]);
  2681. var top = Math.min(boundingRect[0][1], boundingRect[1][1]);
  2682. if (!allowNegativeOffset) {
  2683. left = Math.max(left, 0);
  2684. top = Math.max(top, 0);
  2685. }
  2686. this._scrollIntoView({
  2687. pageDiv: pageView.div,
  2688. pageSpot: {
  2689. left: left,
  2690. top: top
  2691. },
  2692. pageNumber: pageNumber
  2693. });
  2694. }
  2695. }, {
  2696. key: '_resizeBuffer',
  2697. value: function _resizeBuffer(numVisiblePages) {
  2698. var suggestedCacheSize = Math.max(DEFAULT_CACHE_SIZE, 2 * numVisiblePages + 1);
  2699. this._buffer.resize(suggestedCacheSize);
  2700. }
  2701. }, {
  2702. key: '_updateLocation',
  2703. value: function _updateLocation(firstPage) {
  2704. var currentScale = this._currentScale;
  2705. var currentScaleValue = this._currentScaleValue;
  2706. var normalizedScaleValue = parseFloat(currentScaleValue) === currentScale ? Math.round(currentScale * 10000) / 100 : currentScaleValue;
  2707. var pageNumber = firstPage.id;
  2708. var pdfOpenParams = '#page=' + pageNumber;
  2709. pdfOpenParams += '&zoom=' + normalizedScaleValue;
  2710. var currentPageView = this._pages[pageNumber - 1];
  2711. var container = this.container;
  2712. var topLeft = currentPageView.getPagePoint(container.scrollLeft - firstPage.x, container.scrollTop - firstPage.y);
  2713. var intLeft = Math.round(topLeft[0]);
  2714. var intTop = Math.round(topLeft[1]);
  2715. pdfOpenParams += ',' + intLeft + ',' + intTop;
  2716. this._location = {
  2717. pageNumber: pageNumber,
  2718. scale: normalizedScaleValue,
  2719. top: intTop,
  2720. left: intLeft,
  2721. rotation: this._pagesRotation,
  2722. pdfOpenParams: pdfOpenParams
  2723. };
  2724. }
  2725. }, {
  2726. key: 'update',
  2727. value: function update() {
  2728. throw new Error('Not implemented: update');
  2729. }
  2730. }, {
  2731. key: 'containsElement',
  2732. value: function containsElement(element) {
  2733. return this.container.contains(element);
  2734. }
  2735. }, {
  2736. key: 'focus',
  2737. value: function focus() {
  2738. this.container.focus();
  2739. }
  2740. }, {
  2741. key: '_getVisiblePages',
  2742. value: function _getVisiblePages() {
  2743. throw new Error('Not implemented: _getVisiblePages');
  2744. }
  2745. }, {
  2746. key: 'cleanup',
  2747. value: function cleanup() {
  2748. for (var i = 0, ii = this._pages.length; i < ii; i++) {
  2749. if (this._pages[i] && this._pages[i].renderingState !== _pdf_rendering_queue.RenderingStates.FINISHED) {
  2750. this._pages[i].reset();
  2751. }
  2752. }
  2753. }
  2754. }, {
  2755. key: '_cancelRendering',
  2756. value: function _cancelRendering() {
  2757. for (var i = 0, ii = this._pages.length; i < ii; i++) {
  2758. if (this._pages[i]) {
  2759. this._pages[i].cancelRendering();
  2760. }
  2761. }
  2762. }
  2763. }, {
  2764. key: '_ensurePdfPageLoaded',
  2765. value: function _ensurePdfPageLoaded(pageView) {
  2766. var _this2 = this;
  2767. if (pageView.pdfPage) {
  2768. return Promise.resolve(pageView.pdfPage);
  2769. }
  2770. var pageNumber = pageView.id;
  2771. if (this._pagesRequests[pageNumber]) {
  2772. return this._pagesRequests[pageNumber];
  2773. }
  2774. var promise = this.pdfDocument.getPage(pageNumber).then(function (pdfPage) {
  2775. if (!pageView.pdfPage) {
  2776. pageView.setPdfPage(pdfPage);
  2777. }
  2778. _this2._pagesRequests[pageNumber] = null;
  2779. return pdfPage;
  2780. }).catch(function (reason) {
  2781. console.error('Unable to get page for page view', reason);
  2782. _this2._pagesRequests[pageNumber] = null;
  2783. });
  2784. this._pagesRequests[pageNumber] = promise;
  2785. return promise;
  2786. }
  2787. }, {
  2788. key: 'forceRendering',
  2789. value: function forceRendering(currentlyVisiblePages) {
  2790. var _this3 = this;
  2791. var visiblePages = currentlyVisiblePages || this._getVisiblePages();
  2792. var pageView = this.renderingQueue.getHighestPriority(visiblePages, this._pages, this.scroll.down);
  2793. if (pageView) {
  2794. this._ensurePdfPageLoaded(pageView).then(function () {
  2795. _this3.renderingQueue.renderView(pageView);
  2796. });
  2797. return true;
  2798. }
  2799. return false;
  2800. }
  2801. }, {
  2802. key: 'getPageTextContent',
  2803. value: function getPageTextContent(pageIndex) {
  2804. return this.pdfDocument.getPage(pageIndex + 1).then(function (page) {
  2805. return page.getTextContent({ normalizeWhitespace: true });
  2806. });
  2807. }
  2808. }, {
  2809. key: 'createTextLayerBuilder',
  2810. value: function createTextLayerBuilder(textLayerDiv, pageIndex, viewport) {
  2811. var enhanceTextSelection = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
  2812. return new _text_layer_builder.TextLayerBuilder({
  2813. textLayerDiv: textLayerDiv,
  2814. eventBus: this.eventBus,
  2815. pageIndex: pageIndex,
  2816. viewport: viewport,
  2817. findController: this.isInPresentationMode ? null : this.findController,
  2818. enhanceTextSelection: this.isInPresentationMode ? false : enhanceTextSelection
  2819. });
  2820. }
  2821. }, {
  2822. key: 'createAnnotationLayerBuilder',
  2823. value: function createAnnotationLayerBuilder(pageDiv, pdfPage) {
  2824. var imageResourcesPath = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
  2825. var renderInteractiveForms = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
  2826. var l10n = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : _ui_utils.NullL10n;
  2827. return new _annotation_layer_builder.AnnotationLayerBuilder({
  2828. pageDiv: pageDiv,
  2829. pdfPage: pdfPage,
  2830. imageResourcesPath: imageResourcesPath,
  2831. renderInteractiveForms: renderInteractiveForms,
  2832. linkService: this.linkService,
  2833. downloadManager: this.downloadManager,
  2834. l10n: l10n
  2835. });
  2836. }
  2837. }, {
  2838. key: 'setFindController',
  2839. value: function setFindController(findController) {
  2840. this.findController = findController;
  2841. }
  2842. }, {
  2843. key: 'getPagesOverview',
  2844. value: function getPagesOverview() {
  2845. var pagesOverview = this._pages.map(function (pageView) {
  2846. var viewport = pageView.pdfPage.getViewport(1);
  2847. return {
  2848. width: viewport.width,
  2849. height: viewport.height,
  2850. rotation: viewport.rotation
  2851. };
  2852. });
  2853. if (!this.enablePrintAutoRotate) {
  2854. return pagesOverview;
  2855. }
  2856. var isFirstPagePortrait = (0, _ui_utils.isPortraitOrientation)(pagesOverview[0]);
  2857. return pagesOverview.map(function (size) {
  2858. if (isFirstPagePortrait === (0, _ui_utils.isPortraitOrientation)(size)) {
  2859. return size;
  2860. }
  2861. return {
  2862. width: size.height,
  2863. height: size.width,
  2864. rotation: (size.rotation + 90) % 360
  2865. };
  2866. });
  2867. }
  2868. }, {
  2869. key: 'pagesCount',
  2870. get: function get() {
  2871. return this._pages.length;
  2872. }
  2873. }, {
  2874. key: 'pageViewsReady',
  2875. get: function get() {
  2876. return this._pageViewsReady;
  2877. }
  2878. }, {
  2879. key: 'currentPageNumber',
  2880. get: function get() {
  2881. return this._currentPageNumber;
  2882. },
  2883. set: function set(val) {
  2884. if (!Number.isInteger(val)) {
  2885. throw new Error('Invalid page number.');
  2886. }
  2887. if (!this.pdfDocument) {
  2888. return;
  2889. }
  2890. this._setCurrentPageNumber(val, true);
  2891. }
  2892. }, {
  2893. key: 'currentPageLabel',
  2894. get: function get() {
  2895. return this._pageLabels && this._pageLabels[this._currentPageNumber - 1];
  2896. },
  2897. set: function set(val) {
  2898. var pageNumber = val | 0;
  2899. if (this._pageLabels) {
  2900. var i = this._pageLabels.indexOf(val);
  2901. if (i >= 0) {
  2902. pageNumber = i + 1;
  2903. }
  2904. }
  2905. this.currentPageNumber = pageNumber;
  2906. }
  2907. }, {
  2908. key: 'currentScale',
  2909. get: function get() {
  2910. return this._currentScale !== _ui_utils.UNKNOWN_SCALE ? this._currentScale : _ui_utils.DEFAULT_SCALE;
  2911. },
  2912. set: function set(val) {
  2913. if (isNaN(val)) {
  2914. throw new Error('Invalid numeric scale');
  2915. }
  2916. if (!this.pdfDocument) {
  2917. return;
  2918. }
  2919. this._setScale(val, false);
  2920. }
  2921. }, {
  2922. key: 'currentScaleValue',
  2923. get: function get() {
  2924. return this._currentScaleValue;
  2925. },
  2926. set: function set(val) {
  2927. if (!this.pdfDocument) {
  2928. return;
  2929. }
  2930. this._setScale(val, false);
  2931. }
  2932. }, {
  2933. key: 'pagesRotation',
  2934. get: function get() {
  2935. return this._pagesRotation;
  2936. },
  2937. set: function set(rotation) {
  2938. if (!(0, _ui_utils.isValidRotation)(rotation)) {
  2939. throw new Error('Invalid pages rotation angle.');
  2940. }
  2941. if (!this.pdfDocument) {
  2942. return;
  2943. }
  2944. if (this._pagesRotation === rotation) {
  2945. return;
  2946. }
  2947. this._pagesRotation = rotation;
  2948. var pageNumber = this._currentPageNumber;
  2949. for (var i = 0, ii = this._pages.length; i < ii; i++) {
  2950. var pageView = this._pages[i];
  2951. pageView.update(pageView.scale, rotation);
  2952. }
  2953. if (this._currentScaleValue) {
  2954. this._setScale(this._currentScaleValue, true);
  2955. }
  2956. this.eventBus.dispatch('rotationchanging', {
  2957. source: this,
  2958. pagesRotation: rotation,
  2959. pageNumber: pageNumber
  2960. });
  2961. if (this.defaultRenderingQueue) {
  2962. this.update();
  2963. }
  2964. }
  2965. }, {
  2966. key: '_setDocumentViewerElement',
  2967. get: function get() {
  2968. throw new Error('Not implemented: _setDocumentViewerElement');
  2969. }
  2970. }, {
  2971. key: 'isInPresentationMode',
  2972. get: function get() {
  2973. return this.presentationModeState === _ui_utils.PresentationModeState.FULLSCREEN;
  2974. }
  2975. }, {
  2976. key: 'isChangingPresentationMode',
  2977. get: function get() {
  2978. return this.presentationModeState === _ui_utils.PresentationModeState.CHANGING;
  2979. }
  2980. }, {
  2981. key: 'isHorizontalScrollbarEnabled',
  2982. get: function get() {
  2983. return this.isInPresentationMode ? false : this.container.scrollWidth > this.container.clientWidth;
  2984. }
  2985. }, {
  2986. key: 'hasEqualPageSizes',
  2987. get: function get() {
  2988. var firstPageView = this._pages[0];
  2989. for (var i = 1, ii = this._pages.length; i < ii; ++i) {
  2990. var pageView = this._pages[i];
  2991. if (pageView.width !== firstPageView.width || pageView.height !== firstPageView.height) {
  2992. return false;
  2993. }
  2994. }
  2995. return true;
  2996. }
  2997. }]);
  2998. return BaseViewer;
  2999. }();
  3000. exports.BaseViewer = BaseViewer;
  3001. /***/ }),
  3002. /* 9 */
  3003. /***/ (function(module, exports, __w_pdfjs_require__) {
  3004. "use strict";
  3005. Object.defineProperty(exports, "__esModule", {
  3006. value: true
  3007. });
  3008. exports.NullL10n = exports.GenericL10n = exports.ProgressBar = exports.DownloadManager = exports.EventBus = exports.PDFFindController = exports.PDFHistory = exports.DefaultAnnotationLayerFactory = exports.AnnotationLayerBuilder = exports.DefaultTextLayerFactory = exports.TextLayerBuilder = exports.SimpleLinkService = exports.PDFLinkService = exports.PDFPageView = exports.PDFSinglePageViewer = exports.PDFViewer = undefined;
  3009. var _annotation_layer_builder = __w_pdfjs_require__(4);
  3010. var _text_layer_builder = __w_pdfjs_require__(5);
  3011. var _ui_utils = __w_pdfjs_require__(0);
  3012. var _pdf_link_service = __w_pdfjs_require__(3);
  3013. var _download_manager = __w_pdfjs_require__(10);
  3014. var _genericl10n = __w_pdfjs_require__(11);
  3015. var _pdf_find_controller = __w_pdfjs_require__(13);
  3016. var _pdf_history = __w_pdfjs_require__(14);
  3017. var _pdf_page_view = __w_pdfjs_require__(6);
  3018. var _pdf_single_page_viewer = __w_pdfjs_require__(16);
  3019. var _pdf_viewer = __w_pdfjs_require__(17);
  3020. var pdfjsVersion = '2.0.478';
  3021. var pdfjsBuild = 'e8cf7fd5';
  3022. exports.PDFViewer = _pdf_viewer.PDFViewer;
  3023. exports.PDFSinglePageViewer = _pdf_single_page_viewer.PDFSinglePageViewer;
  3024. exports.PDFPageView = _pdf_page_view.PDFPageView;
  3025. exports.PDFLinkService = _pdf_link_service.PDFLinkService;
  3026. exports.SimpleLinkService = _pdf_link_service.SimpleLinkService;
  3027. exports.TextLayerBuilder = _text_layer_builder.TextLayerBuilder;
  3028. exports.DefaultTextLayerFactory = _text_layer_builder.DefaultTextLayerFactory;
  3029. exports.AnnotationLayerBuilder = _annotation_layer_builder.AnnotationLayerBuilder;
  3030. exports.DefaultAnnotationLayerFactory = _annotation_layer_builder.DefaultAnnotationLayerFactory;
  3031. exports.PDFHistory = _pdf_history.PDFHistory;
  3032. exports.PDFFindController = _pdf_find_controller.PDFFindController;
  3033. exports.EventBus = _ui_utils.EventBus;
  3034. exports.DownloadManager = _download_manager.DownloadManager;
  3035. exports.ProgressBar = _ui_utils.ProgressBar;
  3036. exports.GenericL10n = _genericl10n.GenericL10n;
  3037. exports.NullL10n = _ui_utils.NullL10n;
  3038. /***/ }),
  3039. /* 10 */
  3040. /***/ (function(module, exports, __w_pdfjs_require__) {
  3041. "use strict";
  3042. Object.defineProperty(exports, "__esModule", {
  3043. value: true
  3044. });
  3045. exports.DownloadManager = undefined;
  3046. var _createClass = function () { 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); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  3047. var _pdfjsLib = __w_pdfjs_require__(1);
  3048. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  3049. ;
  3050. var DISABLE_CREATE_OBJECT_URL = _pdfjsLib.apiCompatibilityParams.disableCreateObjectURL || false;
  3051. function _download(blobUrl, filename) {
  3052. var a = document.createElement('a');
  3053. if (!a.click) {
  3054. throw new Error('DownloadManager: "a.click()" is not supported.');
  3055. }
  3056. a.href = blobUrl;
  3057. a.target = '_parent';
  3058. if ('download' in a) {
  3059. a.download = filename;
  3060. }
  3061. (document.body || document.documentElement).appendChild(a);
  3062. a.click();
  3063. a.remove();
  3064. }
  3065. var DownloadManager = function () {
  3066. function DownloadManager(_ref) {
  3067. var _ref$disableCreateObj = _ref.disableCreateObjectURL,
  3068. disableCreateObjectURL = _ref$disableCreateObj === undefined ? DISABLE_CREATE_OBJECT_URL : _ref$disableCreateObj;
  3069. _classCallCheck(this, DownloadManager);
  3070. this.disableCreateObjectURL = disableCreateObjectURL;
  3071. }
  3072. _createClass(DownloadManager, [{
  3073. key: 'downloadUrl',
  3074. value: function downloadUrl(url, filename) {
  3075. if (!(0, _pdfjsLib.createValidAbsoluteUrl)(url, 'http://example.com')) {
  3076. return;
  3077. }
  3078. _download(url + '#pdfjs.action=download', filename);
  3079. }
  3080. }, {
  3081. key: 'downloadData',
  3082. value: function downloadData(data, filename, contentType) {
  3083. if (navigator.msSaveBlob) {
  3084. return navigator.msSaveBlob(new Blob([data], { type: contentType }), filename);
  3085. }
  3086. var blobUrl = (0, _pdfjsLib.createObjectURL)(data, contentType, this.disableCreateObjectURL);
  3087. _download(blobUrl, filename);
  3088. }
  3089. }, {
  3090. key: 'download',
  3091. value: function download(blob, url, filename) {
  3092. if (navigator.msSaveBlob) {
  3093. if (!navigator.msSaveBlob(blob, filename)) {
  3094. this.downloadUrl(url, filename);
  3095. }
  3096. return;
  3097. }
  3098. if (this.disableCreateObjectURL) {
  3099. this.downloadUrl(url, filename);
  3100. return;
  3101. }
  3102. var blobUrl = URL.createObjectURL(blob);
  3103. _download(blobUrl, filename);
  3104. }
  3105. }]);
  3106. return DownloadManager;
  3107. }();
  3108. exports.DownloadManager = DownloadManager;
  3109. /***/ }),
  3110. /* 11 */
  3111. /***/ (function(module, exports, __w_pdfjs_require__) {
  3112. "use strict";
  3113. Object.defineProperty(exports, "__esModule", {
  3114. value: true
  3115. });
  3116. exports.GenericL10n = undefined;
  3117. var _createClass = function () { 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); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  3118. __w_pdfjs_require__(12);
  3119. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  3120. var webL10n = document.webL10n;
  3121. var GenericL10n = function () {
  3122. function GenericL10n(lang) {
  3123. _classCallCheck(this, GenericL10n);
  3124. this._lang = lang;
  3125. this._ready = new Promise(function (resolve, reject) {
  3126. webL10n.setLanguage(lang, function () {
  3127. resolve(webL10n);
  3128. });
  3129. });
  3130. }
  3131. _createClass(GenericL10n, [{
  3132. key: 'getLanguage',
  3133. value: function getLanguage() {
  3134. return this._ready.then(function (l10n) {
  3135. return l10n.getLanguage();
  3136. });
  3137. }
  3138. }, {
  3139. key: 'getDirection',
  3140. value: function getDirection() {
  3141. return this._ready.then(function (l10n) {
  3142. return l10n.getDirection();
  3143. });
  3144. }
  3145. }, {
  3146. key: 'get',
  3147. value: function get(property, args, fallback) {
  3148. return this._ready.then(function (l10n) {
  3149. return l10n.get(property, args, fallback);
  3150. });
  3151. }
  3152. }, {
  3153. key: 'translate',
  3154. value: function translate(element) {
  3155. return this._ready.then(function (l10n) {
  3156. return l10n.translate(element);
  3157. });
  3158. }
  3159. }]);
  3160. return GenericL10n;
  3161. }();
  3162. exports.GenericL10n = GenericL10n;
  3163. /***/ }),
  3164. /* 12 */
  3165. /***/ (function(module, exports, __w_pdfjs_require__) {
  3166. "use strict";
  3167. document.webL10n = function (window, document, undefined) {
  3168. var gL10nData = {};
  3169. var gTextData = '';
  3170. var gTextProp = 'textContent';
  3171. var gLanguage = '';
  3172. var gMacros = {};
  3173. var gReadyState = 'loading';
  3174. var gAsyncResourceLoading = true;
  3175. function getL10nResourceLinks() {
  3176. return document.querySelectorAll('link[type="application/l10n"]');
  3177. }
  3178. function getL10nDictionary() {
  3179. var script = document.querySelector('script[type="application/l10n"]');
  3180. return script ? JSON.parse(script.innerHTML) : null;
  3181. }
  3182. function getTranslatableChildren(element) {
  3183. return element ? element.querySelectorAll('*[data-l10n-id]') : [];
  3184. }
  3185. function getL10nAttributes(element) {
  3186. if (!element) return {};
  3187. var l10nId = element.getAttribute('data-l10n-id');
  3188. var l10nArgs = element.getAttribute('data-l10n-args');
  3189. var args = {};
  3190. if (l10nArgs) {
  3191. try {
  3192. args = JSON.parse(l10nArgs);
  3193. } catch (e) {
  3194. console.warn('could not parse arguments for #' + l10nId);
  3195. }
  3196. }
  3197. return {
  3198. id: l10nId,
  3199. args: args
  3200. };
  3201. }
  3202. function fireL10nReadyEvent(lang) {
  3203. var evtObject = document.createEvent('Event');
  3204. evtObject.initEvent('localized', true, false);
  3205. evtObject.language = lang;
  3206. document.dispatchEvent(evtObject);
  3207. }
  3208. function xhrLoadText(url, onSuccess, onFailure) {
  3209. onSuccess = onSuccess || function _onSuccess(data) {};
  3210. onFailure = onFailure || function _onFailure() {};
  3211. var xhr = new XMLHttpRequest();
  3212. xhr.open('GET', url, gAsyncResourceLoading);
  3213. if (xhr.overrideMimeType) {
  3214. xhr.overrideMimeType('text/plain; charset=utf-8');
  3215. }
  3216. xhr.onreadystatechange = function () {
  3217. if (xhr.readyState == 4) {
  3218. if (xhr.status == 200 || xhr.status === 0) {
  3219. onSuccess(xhr.responseText);
  3220. } else {
  3221. onFailure();
  3222. }
  3223. }
  3224. };
  3225. xhr.onerror = onFailure;
  3226. xhr.ontimeout = onFailure;
  3227. try {
  3228. xhr.send(null);
  3229. } catch (e) {
  3230. onFailure();
  3231. }
  3232. }
  3233. function parseResource(href, lang, successCallback, failureCallback) {
  3234. var baseURL = href.replace(/[^\/]*$/, '') || './';
  3235. function evalString(text) {
  3236. if (text.lastIndexOf('\\') < 0) return text;
  3237. 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, "'");
  3238. }
  3239. function parseProperties(text, parsedPropertiesCallback) {
  3240. var dictionary = {};
  3241. var reBlank = /^\s*|\s*$/;
  3242. var reComment = /^\s*#|^\s*$/;
  3243. var reSection = /^\s*\[(.*)\]\s*$/;
  3244. var reImport = /^\s*@import\s+url\((.*)\)\s*$/i;
  3245. var reSplit = /^([^=\s]*)\s*=\s*(.+)$/;
  3246. function parseRawLines(rawText, extendedSyntax, parsedRawLinesCallback) {
  3247. var entries = rawText.replace(reBlank, '').split(/[\r\n]+/);
  3248. var currentLang = '*';
  3249. var genericLang = lang.split('-', 1)[0];
  3250. var skipLang = false;
  3251. var match = '';
  3252. function nextEntry() {
  3253. while (true) {
  3254. if (!entries.length) {
  3255. parsedRawLinesCallback();
  3256. return;
  3257. }
  3258. var line = entries.shift();
  3259. if (reComment.test(line)) continue;
  3260. if (extendedSyntax) {
  3261. match = reSection.exec(line);
  3262. if (match) {
  3263. currentLang = match[1].toLowerCase();
  3264. skipLang = currentLang !== '*' && currentLang !== lang && currentLang !== genericLang;
  3265. continue;
  3266. } else if (skipLang) {
  3267. continue;
  3268. }
  3269. match = reImport.exec(line);
  3270. if (match) {
  3271. loadImport(baseURL + match[1], nextEntry);
  3272. return;
  3273. }
  3274. }
  3275. var tmp = line.match(reSplit);
  3276. if (tmp && tmp.length == 3) {
  3277. dictionary[tmp[1]] = evalString(tmp[2]);
  3278. }
  3279. }
  3280. }
  3281. nextEntry();
  3282. }
  3283. function loadImport(url, callback) {
  3284. xhrLoadText(url, function (content) {
  3285. parseRawLines(content, false, callback);
  3286. }, function () {
  3287. console.warn(url + ' not found.');
  3288. callback();
  3289. });
  3290. }
  3291. parseRawLines(text, true, function () {
  3292. parsedPropertiesCallback(dictionary);
  3293. });
  3294. }
  3295. xhrLoadText(href, function (response) {
  3296. gTextData += response;
  3297. parseProperties(response, function (data) {
  3298. for (var key in data) {
  3299. var id,
  3300. prop,
  3301. index = key.lastIndexOf('.');
  3302. if (index > 0) {
  3303. id = key.substring(0, index);
  3304. prop = key.substr(index + 1);
  3305. } else {
  3306. id = key;
  3307. prop = gTextProp;
  3308. }
  3309. if (!gL10nData[id]) {
  3310. gL10nData[id] = {};
  3311. }
  3312. gL10nData[id][prop] = data[key];
  3313. }
  3314. if (successCallback) {
  3315. successCallback();
  3316. }
  3317. });
  3318. }, failureCallback);
  3319. }
  3320. function loadLocale(lang, callback) {
  3321. if (lang) {
  3322. lang = lang.toLowerCase();
  3323. }
  3324. callback = callback || function _callback() {};
  3325. clear();
  3326. gLanguage = lang;
  3327. var langLinks = getL10nResourceLinks();
  3328. var langCount = langLinks.length;
  3329. if (langCount === 0) {
  3330. var dict = getL10nDictionary();
  3331. if (dict && dict.locales && dict.default_locale) {
  3332. console.log('using the embedded JSON directory, early way out');
  3333. gL10nData = dict.locales[lang];
  3334. if (!gL10nData) {
  3335. var defaultLocale = dict.default_locale.toLowerCase();
  3336. for (var anyCaseLang in dict.locales) {
  3337. anyCaseLang = anyCaseLang.toLowerCase();
  3338. if (anyCaseLang === lang) {
  3339. gL10nData = dict.locales[lang];
  3340. break;
  3341. } else if (anyCaseLang === defaultLocale) {
  3342. gL10nData = dict.locales[defaultLocale];
  3343. }
  3344. }
  3345. }
  3346. callback();
  3347. } else {
  3348. console.log('no resource to load, early way out');
  3349. }
  3350. fireL10nReadyEvent(lang);
  3351. gReadyState = 'complete';
  3352. return;
  3353. }
  3354. var onResourceLoaded = null;
  3355. var gResourceCount = 0;
  3356. onResourceLoaded = function onResourceLoaded() {
  3357. gResourceCount++;
  3358. if (gResourceCount >= langCount) {
  3359. callback();
  3360. fireL10nReadyEvent(lang);
  3361. gReadyState = 'complete';
  3362. }
  3363. };
  3364. function L10nResourceLink(link) {
  3365. var href = link.href;
  3366. this.load = function (lang, callback) {
  3367. parseResource(href, lang, callback, function () {
  3368. console.warn(href + ' not found.');
  3369. console.warn('"' + lang + '" resource not found');
  3370. gLanguage = '';
  3371. callback();
  3372. });
  3373. };
  3374. }
  3375. for (var i = 0; i < langCount; i++) {
  3376. var resource = new L10nResourceLink(langLinks[i]);
  3377. resource.load(lang, onResourceLoaded);
  3378. }
  3379. }
  3380. function clear() {
  3381. gL10nData = {};
  3382. gTextData = '';
  3383. gLanguage = '';
  3384. }
  3385. function getPluralRules(lang) {
  3386. var locales2rules = {
  3387. 'af': 3,
  3388. 'ak': 4,
  3389. 'am': 4,
  3390. 'ar': 1,
  3391. 'asa': 3,
  3392. 'az': 0,
  3393. 'be': 11,
  3394. 'bem': 3,
  3395. 'bez': 3,
  3396. 'bg': 3,
  3397. 'bh': 4,
  3398. 'bm': 0,
  3399. 'bn': 3,
  3400. 'bo': 0,
  3401. 'br': 20,
  3402. 'brx': 3,
  3403. 'bs': 11,
  3404. 'ca': 3,
  3405. 'cgg': 3,
  3406. 'chr': 3,
  3407. 'cs': 12,
  3408. 'cy': 17,
  3409. 'da': 3,
  3410. 'de': 3,
  3411. 'dv': 3,
  3412. 'dz': 0,
  3413. 'ee': 3,
  3414. 'el': 3,
  3415. 'en': 3,
  3416. 'eo': 3,
  3417. 'es': 3,
  3418. 'et': 3,
  3419. 'eu': 3,
  3420. 'fa': 0,
  3421. 'ff': 5,
  3422. 'fi': 3,
  3423. 'fil': 4,
  3424. 'fo': 3,
  3425. 'fr': 5,
  3426. 'fur': 3,
  3427. 'fy': 3,
  3428. 'ga': 8,
  3429. 'gd': 24,
  3430. 'gl': 3,
  3431. 'gsw': 3,
  3432. 'gu': 3,
  3433. 'guw': 4,
  3434. 'gv': 23,
  3435. 'ha': 3,
  3436. 'haw': 3,
  3437. 'he': 2,
  3438. 'hi': 4,
  3439. 'hr': 11,
  3440. 'hu': 0,
  3441. 'id': 0,
  3442. 'ig': 0,
  3443. 'ii': 0,
  3444. 'is': 3,
  3445. 'it': 3,
  3446. 'iu': 7,
  3447. 'ja': 0,
  3448. 'jmc': 3,
  3449. 'jv': 0,
  3450. 'ka': 0,
  3451. 'kab': 5,
  3452. 'kaj': 3,
  3453. 'kcg': 3,
  3454. 'kde': 0,
  3455. 'kea': 0,
  3456. 'kk': 3,
  3457. 'kl': 3,
  3458. 'km': 0,
  3459. 'kn': 0,
  3460. 'ko': 0,
  3461. 'ksb': 3,
  3462. 'ksh': 21,
  3463. 'ku': 3,
  3464. 'kw': 7,
  3465. 'lag': 18,
  3466. 'lb': 3,
  3467. 'lg': 3,
  3468. 'ln': 4,
  3469. 'lo': 0,
  3470. 'lt': 10,
  3471. 'lv': 6,
  3472. 'mas': 3,
  3473. 'mg': 4,
  3474. 'mk': 16,
  3475. 'ml': 3,
  3476. 'mn': 3,
  3477. 'mo': 9,
  3478. 'mr': 3,
  3479. 'ms': 0,
  3480. 'mt': 15,
  3481. 'my': 0,
  3482. 'nah': 3,
  3483. 'naq': 7,
  3484. 'nb': 3,
  3485. 'nd': 3,
  3486. 'ne': 3,
  3487. 'nl': 3,
  3488. 'nn': 3,
  3489. 'no': 3,
  3490. 'nr': 3,
  3491. 'nso': 4,
  3492. 'ny': 3,
  3493. 'nyn': 3,
  3494. 'om': 3,
  3495. 'or': 3,
  3496. 'pa': 3,
  3497. 'pap': 3,
  3498. 'pl': 13,
  3499. 'ps': 3,
  3500. 'pt': 3,
  3501. 'rm': 3,
  3502. 'ro': 9,
  3503. 'rof': 3,
  3504. 'ru': 11,
  3505. 'rwk': 3,
  3506. 'sah': 0,
  3507. 'saq': 3,
  3508. 'se': 7,
  3509. 'seh': 3,
  3510. 'ses': 0,
  3511. 'sg': 0,
  3512. 'sh': 11,
  3513. 'shi': 19,
  3514. 'sk': 12,
  3515. 'sl': 14,
  3516. 'sma': 7,
  3517. 'smi': 7,
  3518. 'smj': 7,
  3519. 'smn': 7,
  3520. 'sms': 7,
  3521. 'sn': 3,
  3522. 'so': 3,
  3523. 'sq': 3,
  3524. 'sr': 11,
  3525. 'ss': 3,
  3526. 'ssy': 3,
  3527. 'st': 3,
  3528. 'sv': 3,
  3529. 'sw': 3,
  3530. 'syr': 3,
  3531. 'ta': 3,
  3532. 'te': 3,
  3533. 'teo': 3,
  3534. 'th': 0,
  3535. 'ti': 4,
  3536. 'tig': 3,
  3537. 'tk': 3,
  3538. 'tl': 4,
  3539. 'tn': 3,
  3540. 'to': 0,
  3541. 'tr': 0,
  3542. 'ts': 3,
  3543. 'tzm': 22,
  3544. 'uk': 11,
  3545. 'ur': 3,
  3546. 've': 3,
  3547. 'vi': 0,
  3548. 'vun': 3,
  3549. 'wa': 4,
  3550. 'wae': 3,
  3551. 'wo': 0,
  3552. 'xh': 3,
  3553. 'xog': 3,
  3554. 'yo': 0,
  3555. 'zh': 0,
  3556. 'zu': 3
  3557. };
  3558. function isIn(n, list) {
  3559. return list.indexOf(n) !== -1;
  3560. }
  3561. function isBetween(n, start, end) {
  3562. return start <= n && n <= end;
  3563. }
  3564. var pluralRules = {
  3565. '0': function _(n) {
  3566. return 'other';
  3567. },
  3568. '1': function _(n) {
  3569. if (isBetween(n % 100, 3, 10)) return 'few';
  3570. if (n === 0) return 'zero';
  3571. if (isBetween(n % 100, 11, 99)) return 'many';
  3572. if (n == 2) return 'two';
  3573. if (n == 1) return 'one';
  3574. return 'other';
  3575. },
  3576. '2': function _(n) {
  3577. if (n !== 0 && n % 10 === 0) return 'many';
  3578. if (n == 2) return 'two';
  3579. if (n == 1) return 'one';
  3580. return 'other';
  3581. },
  3582. '3': function _(n) {
  3583. if (n == 1) return 'one';
  3584. return 'other';
  3585. },
  3586. '4': function _(n) {
  3587. if (isBetween(n, 0, 1)) return 'one';
  3588. return 'other';
  3589. },
  3590. '5': function _(n) {
  3591. if (isBetween(n, 0, 2) && n != 2) return 'one';
  3592. return 'other';
  3593. },
  3594. '6': function _(n) {
  3595. if (n === 0) return 'zero';
  3596. if (n % 10 == 1 && n % 100 != 11) return 'one';
  3597. return 'other';
  3598. },
  3599. '7': function _(n) {
  3600. if (n == 2) return 'two';
  3601. if (n == 1) return 'one';
  3602. return 'other';
  3603. },
  3604. '8': function _(n) {
  3605. if (isBetween(n, 3, 6)) return 'few';
  3606. if (isBetween(n, 7, 10)) return 'many';
  3607. if (n == 2) return 'two';
  3608. if (n == 1) return 'one';
  3609. return 'other';
  3610. },
  3611. '9': function _(n) {
  3612. if (n === 0 || n != 1 && isBetween(n % 100, 1, 19)) return 'few';
  3613. if (n == 1) return 'one';
  3614. return 'other';
  3615. },
  3616. '10': function _(n) {
  3617. if (isBetween(n % 10, 2, 9) && !isBetween(n % 100, 11, 19)) return 'few';
  3618. if (n % 10 == 1 && !isBetween(n % 100, 11, 19)) return 'one';
  3619. return 'other';
  3620. },
  3621. '11': function _(n) {
  3622. if (isBetween(n % 10, 2, 4) && !isBetween(n % 100, 12, 14)) return 'few';
  3623. if (n % 10 === 0 || isBetween(n % 10, 5, 9) || isBetween(n % 100, 11, 14)) return 'many';
  3624. if (n % 10 == 1 && n % 100 != 11) return 'one';
  3625. return 'other';
  3626. },
  3627. '12': function _(n) {
  3628. if (isBetween(n, 2, 4)) return 'few';
  3629. if (n == 1) return 'one';
  3630. return 'other';
  3631. },
  3632. '13': function _(n) {
  3633. if (isBetween(n % 10, 2, 4) && !isBetween(n % 100, 12, 14)) return 'few';
  3634. if (n != 1 && isBetween(n % 10, 0, 1) || isBetween(n % 10, 5, 9) || isBetween(n % 100, 12, 14)) return 'many';
  3635. if (n == 1) return 'one';
  3636. return 'other';
  3637. },
  3638. '14': function _(n) {
  3639. if (isBetween(n % 100, 3, 4)) return 'few';
  3640. if (n % 100 == 2) return 'two';
  3641. if (n % 100 == 1) return 'one';
  3642. return 'other';
  3643. },
  3644. '15': function _(n) {
  3645. if (n === 0 || isBetween(n % 100, 2, 10)) return 'few';
  3646. if (isBetween(n % 100, 11, 19)) return 'many';
  3647. if (n == 1) return 'one';
  3648. return 'other';
  3649. },
  3650. '16': function _(n) {
  3651. if (n % 10 == 1 && n != 11) return 'one';
  3652. return 'other';
  3653. },
  3654. '17': function _(n) {
  3655. if (n == 3) return 'few';
  3656. if (n === 0) return 'zero';
  3657. if (n == 6) return 'many';
  3658. if (n == 2) return 'two';
  3659. if (n == 1) return 'one';
  3660. return 'other';
  3661. },
  3662. '18': function _(n) {
  3663. if (n === 0) return 'zero';
  3664. if (isBetween(n, 0, 2) && n !== 0 && n != 2) return 'one';
  3665. return 'other';
  3666. },
  3667. '19': function _(n) {
  3668. if (isBetween(n, 2, 10)) return 'few';
  3669. if (isBetween(n, 0, 1)) return 'one';
  3670. return 'other';
  3671. },
  3672. '20': function _(n) {
  3673. 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';
  3674. if (n % 1000000 === 0 && n !== 0) return 'many';
  3675. if (n % 10 == 2 && !isIn(n % 100, [12, 72, 92])) return 'two';
  3676. if (n % 10 == 1 && !isIn(n % 100, [11, 71, 91])) return 'one';
  3677. return 'other';
  3678. },
  3679. '21': function _(n) {
  3680. if (n === 0) return 'zero';
  3681. if (n == 1) return 'one';
  3682. return 'other';
  3683. },
  3684. '22': function _(n) {
  3685. if (isBetween(n, 0, 1) || isBetween(n, 11, 99)) return 'one';
  3686. return 'other';
  3687. },
  3688. '23': function _(n) {
  3689. if (isBetween(n % 10, 1, 2) || n % 20 === 0) return 'one';
  3690. return 'other';
  3691. },
  3692. '24': function _(n) {
  3693. if (isBetween(n, 3, 10) || isBetween(n, 13, 19)) return 'few';
  3694. if (isIn(n, [2, 12])) return 'two';
  3695. if (isIn(n, [1, 11])) return 'one';
  3696. return 'other';
  3697. }
  3698. };
  3699. var index = locales2rules[lang.replace(/-.*$/, '')];
  3700. if (!(index in pluralRules)) {
  3701. console.warn('plural form unknown for [' + lang + ']');
  3702. return function () {
  3703. return 'other';
  3704. };
  3705. }
  3706. return pluralRules[index];
  3707. }
  3708. gMacros.plural = function (str, param, key, prop) {
  3709. var n = parseFloat(param);
  3710. if (isNaN(n)) return str;
  3711. if (prop != gTextProp) return str;
  3712. if (!gMacros._pluralRules) {
  3713. gMacros._pluralRules = getPluralRules(gLanguage);
  3714. }
  3715. var index = '[' + gMacros._pluralRules(n) + ']';
  3716. if (n === 0 && key + '[zero]' in gL10nData) {
  3717. str = gL10nData[key + '[zero]'][prop];
  3718. } else if (n == 1 && key + '[one]' in gL10nData) {
  3719. str = gL10nData[key + '[one]'][prop];
  3720. } else if (n == 2 && key + '[two]' in gL10nData) {
  3721. str = gL10nData[key + '[two]'][prop];
  3722. } else if (key + index in gL10nData) {
  3723. str = gL10nData[key + index][prop];
  3724. } else if (key + '[other]' in gL10nData) {
  3725. str = gL10nData[key + '[other]'][prop];
  3726. }
  3727. return str;
  3728. };
  3729. function getL10nData(key, args, fallback) {
  3730. var data = gL10nData[key];
  3731. if (!data) {
  3732. console.warn('#' + key + ' is undefined.');
  3733. if (!fallback) {
  3734. return null;
  3735. }
  3736. data = fallback;
  3737. }
  3738. var rv = {};
  3739. for (var prop in data) {
  3740. var str = data[prop];
  3741. str = substIndexes(str, args, key, prop);
  3742. str = substArguments(str, args, key);
  3743. rv[prop] = str;
  3744. }
  3745. return rv;
  3746. }
  3747. function substIndexes(str, args, key, prop) {
  3748. var reIndex = /\{\[\s*([a-zA-Z]+)\(([a-zA-Z]+)\)\s*\]\}/;
  3749. var reMatch = reIndex.exec(str);
  3750. if (!reMatch || !reMatch.length) return str;
  3751. var macroName = reMatch[1];
  3752. var paramName = reMatch[2];
  3753. var param;
  3754. if (args && paramName in args) {
  3755. param = args[paramName];
  3756. } else if (paramName in gL10nData) {
  3757. param = gL10nData[paramName];
  3758. }
  3759. if (macroName in gMacros) {
  3760. var macro = gMacros[macroName];
  3761. str = macro(str, param, key, prop);
  3762. }
  3763. return str;
  3764. }
  3765. function substArguments(str, args, key) {
  3766. var reArgs = /\{\{\s*(.+?)\s*\}\}/g;
  3767. return str.replace(reArgs, function (matched_text, arg) {
  3768. if (args && arg in args) {
  3769. return args[arg];
  3770. }
  3771. if (arg in gL10nData) {
  3772. return gL10nData[arg];
  3773. }
  3774. console.log('argument {{' + arg + '}} for #' + key + ' is undefined.');
  3775. return matched_text;
  3776. });
  3777. }
  3778. function translateElement(element) {
  3779. var l10n = getL10nAttributes(element);
  3780. if (!l10n.id) return;
  3781. var data = getL10nData(l10n.id, l10n.args);
  3782. if (!data) {
  3783. console.warn('#' + l10n.id + ' is undefined.');
  3784. return;
  3785. }
  3786. if (data[gTextProp]) {
  3787. if (getChildElementCount(element) === 0) {
  3788. element[gTextProp] = data[gTextProp];
  3789. } else {
  3790. var children = element.childNodes;
  3791. var found = false;
  3792. for (var i = 0, l = children.length; i < l; i++) {
  3793. if (children[i].nodeType === 3 && /\S/.test(children[i].nodeValue)) {
  3794. if (found) {
  3795. children[i].nodeValue = '';
  3796. } else {
  3797. children[i].nodeValue = data[gTextProp];
  3798. found = true;
  3799. }
  3800. }
  3801. }
  3802. if (!found) {
  3803. var textNode = document.createTextNode(data[gTextProp]);
  3804. element.insertBefore(textNode, element.firstChild);
  3805. }
  3806. }
  3807. delete data[gTextProp];
  3808. }
  3809. for (var k in data) {
  3810. element[k] = data[k];
  3811. }
  3812. }
  3813. function getChildElementCount(element) {
  3814. if (element.children) {
  3815. return element.children.length;
  3816. }
  3817. if (typeof element.childElementCount !== 'undefined') {
  3818. return element.childElementCount;
  3819. }
  3820. var count = 0;
  3821. for (var i = 0; i < element.childNodes.length; i++) {
  3822. count += element.nodeType === 1 ? 1 : 0;
  3823. }
  3824. return count;
  3825. }
  3826. function translateFragment(element) {
  3827. element = element || document.documentElement;
  3828. var children = getTranslatableChildren(element);
  3829. var elementCount = children.length;
  3830. for (var i = 0; i < elementCount; i++) {
  3831. translateElement(children[i]);
  3832. }
  3833. translateElement(element);
  3834. }
  3835. return {
  3836. get: function get(key, args, fallbackString) {
  3837. var index = key.lastIndexOf('.');
  3838. var prop = gTextProp;
  3839. if (index > 0) {
  3840. prop = key.substr(index + 1);
  3841. key = key.substring(0, index);
  3842. }
  3843. var fallback;
  3844. if (fallbackString) {
  3845. fallback = {};
  3846. fallback[prop] = fallbackString;
  3847. }
  3848. var data = getL10nData(key, args, fallback);
  3849. if (data && prop in data) {
  3850. return data[prop];
  3851. }
  3852. return '{{' + key + '}}';
  3853. },
  3854. getData: function getData() {
  3855. return gL10nData;
  3856. },
  3857. getText: function getText() {
  3858. return gTextData;
  3859. },
  3860. getLanguage: function getLanguage() {
  3861. return gLanguage;
  3862. },
  3863. setLanguage: function setLanguage(lang, callback) {
  3864. loadLocale(lang, function () {
  3865. if (callback) callback();
  3866. });
  3867. },
  3868. getDirection: function getDirection() {
  3869. var rtlList = ['ar', 'he', 'fa', 'ps', 'ur'];
  3870. var shortCode = gLanguage.split('-', 1)[0];
  3871. return rtlList.indexOf(shortCode) >= 0 ? 'rtl' : 'ltr';
  3872. },
  3873. translate: translateFragment,
  3874. getReadyState: function getReadyState() {
  3875. return gReadyState;
  3876. },
  3877. ready: function ready(callback) {
  3878. if (!callback) {
  3879. return;
  3880. } else if (gReadyState == 'complete' || gReadyState == 'interactive') {
  3881. window.setTimeout(function () {
  3882. callback();
  3883. });
  3884. } else if (document.addEventListener) {
  3885. document.addEventListener('localized', function once() {
  3886. document.removeEventListener('localized', once);
  3887. callback();
  3888. });
  3889. }
  3890. }
  3891. };
  3892. }(window, document);
  3893. /***/ }),
  3894. /* 13 */
  3895. /***/ (function(module, exports, __w_pdfjs_require__) {
  3896. "use strict";
  3897. Object.defineProperty(exports, "__esModule", {
  3898. value: true
  3899. });
  3900. exports.PDFFindController = exports.FindState = undefined;
  3901. var _createClass = function () { 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); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  3902. var _pdfjsLib = __w_pdfjs_require__(1);
  3903. var _ui_utils = __w_pdfjs_require__(0);
  3904. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  3905. var FindState = {
  3906. FOUND: 0,
  3907. NOT_FOUND: 1,
  3908. WRAPPED: 2,
  3909. PENDING: 3
  3910. };
  3911. var FIND_SCROLL_OFFSET_TOP = -50;
  3912. var FIND_SCROLL_OFFSET_LEFT = -400;
  3913. var FIND_TIMEOUT = 250;
  3914. var CHARACTERS_TO_NORMALIZE = {
  3915. '\u2018': '\'',
  3916. '\u2019': '\'',
  3917. '\u201A': '\'',
  3918. '\u201B': '\'',
  3919. '\u201C': '"',
  3920. '\u201D': '"',
  3921. '\u201E': '"',
  3922. '\u201F': '"',
  3923. '\xBC': '1/4',
  3924. '\xBD': '1/2',
  3925. '\xBE': '3/4'
  3926. };
  3927. var PDFFindController = function () {
  3928. function PDFFindController(_ref) {
  3929. var pdfViewer = _ref.pdfViewer;
  3930. _classCallCheck(this, PDFFindController);
  3931. this.pdfViewer = pdfViewer;
  3932. this.onUpdateResultsCount = null;
  3933. this.onUpdateState = null;
  3934. this.reset();
  3935. var replace = Object.keys(CHARACTERS_TO_NORMALIZE).join('');
  3936. this.normalizationRegex = new RegExp('[' + replace + ']', 'g');
  3937. }
  3938. _createClass(PDFFindController, [{
  3939. key: 'reset',
  3940. value: function reset() {
  3941. var _this = this;
  3942. this.startedTextExtraction = false;
  3943. this.extractTextPromises = [];
  3944. this.pendingFindMatches = Object.create(null);
  3945. this.active = false;
  3946. this.pageContents = [];
  3947. this.pageMatches = [];
  3948. this.pageMatchesLength = null;
  3949. this.matchCount = 0;
  3950. this.selected = {
  3951. pageIdx: -1,
  3952. matchIdx: -1
  3953. };
  3954. this.offset = {
  3955. pageIdx: null,
  3956. matchIdx: null
  3957. };
  3958. this.pagesToSearch = null;
  3959. this.resumePageIdx = null;
  3960. this.state = null;
  3961. this.dirtyMatch = false;
  3962. this.findTimeout = null;
  3963. this._firstPagePromise = new Promise(function (resolve) {
  3964. _this.resolveFirstPage = resolve;
  3965. });
  3966. }
  3967. }, {
  3968. key: 'executeCommand',
  3969. value: function executeCommand(cmd, state) {
  3970. var _this2 = this;
  3971. if (this.state === null || cmd !== 'findagain') {
  3972. this.dirtyMatch = true;
  3973. }
  3974. this.state = state;
  3975. this._updateUIState(FindState.PENDING);
  3976. this._firstPagePromise.then(function () {
  3977. _this2._extractText();
  3978. clearTimeout(_this2.findTimeout);
  3979. if (cmd === 'find') {
  3980. _this2.findTimeout = setTimeout(_this2._nextMatch.bind(_this2), FIND_TIMEOUT);
  3981. } else {
  3982. _this2._nextMatch();
  3983. }
  3984. });
  3985. }
  3986. }, {
  3987. key: 'updateMatchPosition',
  3988. value: function updateMatchPosition(pageIndex, matchIndex, elements, beginIdx) {
  3989. if (this.selected.matchIdx === matchIndex && this.selected.pageIdx === pageIndex) {
  3990. var spot = {
  3991. top: FIND_SCROLL_OFFSET_TOP,
  3992. left: FIND_SCROLL_OFFSET_LEFT
  3993. };
  3994. (0, _ui_utils.scrollIntoView)(elements[beginIdx], spot, true);
  3995. }
  3996. }
  3997. }, {
  3998. key: '_normalize',
  3999. value: function _normalize(text) {
  4000. return text.replace(this.normalizationRegex, function (ch) {
  4001. return CHARACTERS_TO_NORMALIZE[ch];
  4002. });
  4003. }
  4004. }, {
  4005. key: '_prepareMatches',
  4006. value: function _prepareMatches(matchesWithLength, matches, matchesLength) {
  4007. function isSubTerm(matchesWithLength, currentIndex) {
  4008. var currentElem = matchesWithLength[currentIndex];
  4009. var nextElem = matchesWithLength[currentIndex + 1];
  4010. if (currentIndex < matchesWithLength.length - 1 && currentElem.match === nextElem.match) {
  4011. currentElem.skipped = true;
  4012. return true;
  4013. }
  4014. for (var i = currentIndex - 1; i >= 0; i--) {
  4015. var prevElem = matchesWithLength[i];
  4016. if (prevElem.skipped) {
  4017. continue;
  4018. }
  4019. if (prevElem.match + prevElem.matchLength < currentElem.match) {
  4020. break;
  4021. }
  4022. if (prevElem.match + prevElem.matchLength >= currentElem.match + currentElem.matchLength) {
  4023. currentElem.skipped = true;
  4024. return true;
  4025. }
  4026. }
  4027. return false;
  4028. }
  4029. matchesWithLength.sort(function (a, b) {
  4030. return a.match === b.match ? a.matchLength - b.matchLength : a.match - b.match;
  4031. });
  4032. for (var i = 0, len = matchesWithLength.length; i < len; i++) {
  4033. if (isSubTerm(matchesWithLength, i)) {
  4034. continue;
  4035. }
  4036. matches.push(matchesWithLength[i].match);
  4037. matchesLength.push(matchesWithLength[i].matchLength);
  4038. }
  4039. }
  4040. }, {
  4041. key: '_calculatePhraseMatch',
  4042. value: function _calculatePhraseMatch(query, pageIndex, pageContent) {
  4043. var matches = [];
  4044. var queryLen = query.length;
  4045. var matchIdx = -queryLen;
  4046. while (true) {
  4047. matchIdx = pageContent.indexOf(query, matchIdx + queryLen);
  4048. if (matchIdx === -1) {
  4049. break;
  4050. }
  4051. matches.push(matchIdx);
  4052. }
  4053. this.pageMatches[pageIndex] = matches;
  4054. }
  4055. }, {
  4056. key: '_calculateWordMatch',
  4057. value: function _calculateWordMatch(query, pageIndex, pageContent) {
  4058. var matchesWithLength = [];
  4059. var queryArray = query.match(/\S+/g);
  4060. for (var i = 0, len = queryArray.length; i < len; i++) {
  4061. var subquery = queryArray[i];
  4062. var subqueryLen = subquery.length;
  4063. var matchIdx = -subqueryLen;
  4064. while (true) {
  4065. matchIdx = pageContent.indexOf(subquery, matchIdx + subqueryLen);
  4066. if (matchIdx === -1) {
  4067. break;
  4068. }
  4069. matchesWithLength.push({
  4070. match: matchIdx,
  4071. matchLength: subqueryLen,
  4072. skipped: false
  4073. });
  4074. }
  4075. }
  4076. if (!this.pageMatchesLength) {
  4077. this.pageMatchesLength = [];
  4078. }
  4079. this.pageMatchesLength[pageIndex] = [];
  4080. this.pageMatches[pageIndex] = [];
  4081. this._prepareMatches(matchesWithLength, this.pageMatches[pageIndex], this.pageMatchesLength[pageIndex]);
  4082. }
  4083. }, {
  4084. key: '_calculateMatch',
  4085. value: function _calculateMatch(pageIndex) {
  4086. var pageContent = this._normalize(this.pageContents[pageIndex]);
  4087. var query = this._normalize(this.state.query);
  4088. var caseSensitive = this.state.caseSensitive;
  4089. var phraseSearch = this.state.phraseSearch;
  4090. var queryLen = query.length;
  4091. if (queryLen === 0) {
  4092. return;
  4093. }
  4094. if (!caseSensitive) {
  4095. pageContent = pageContent.toLowerCase();
  4096. query = query.toLowerCase();
  4097. }
  4098. if (phraseSearch) {
  4099. this._calculatePhraseMatch(query, pageIndex, pageContent);
  4100. } else {
  4101. this._calculateWordMatch(query, pageIndex, pageContent);
  4102. }
  4103. this._updatePage(pageIndex);
  4104. if (this.resumePageIdx === pageIndex) {
  4105. this.resumePageIdx = null;
  4106. this._nextPageMatch();
  4107. }
  4108. if (this.pageMatches[pageIndex].length > 0) {
  4109. this.matchCount += this.pageMatches[pageIndex].length;
  4110. this._updateUIResultsCount();
  4111. }
  4112. }
  4113. }, {
  4114. key: '_extractText',
  4115. value: function _extractText() {
  4116. var _this3 = this;
  4117. if (this.startedTextExtraction) {
  4118. return;
  4119. }
  4120. this.startedTextExtraction = true;
  4121. this.pageContents.length = 0;
  4122. var promise = Promise.resolve();
  4123. var _loop = function _loop(i, ii) {
  4124. var extractTextCapability = (0, _pdfjsLib.createPromiseCapability)();
  4125. _this3.extractTextPromises[i] = extractTextCapability.promise;
  4126. promise = promise.then(function () {
  4127. return _this3.pdfViewer.getPageTextContent(i).then(function (textContent) {
  4128. var textItems = textContent.items;
  4129. var strBuf = [];
  4130. for (var j = 0, jj = textItems.length; j < jj; j++) {
  4131. strBuf.push(textItems[j].str);
  4132. }
  4133. _this3.pageContents[i] = strBuf.join('');
  4134. extractTextCapability.resolve(i);
  4135. }, function (reason) {
  4136. console.error('Unable to get page ' + (i + 1) + ' text content', reason);
  4137. _this3.pageContents[i] = '';
  4138. extractTextCapability.resolve(i);
  4139. });
  4140. });
  4141. };
  4142. for (var i = 0, ii = this.pdfViewer.pagesCount; i < ii; i++) {
  4143. _loop(i, ii);
  4144. }
  4145. }
  4146. }, {
  4147. key: '_updatePage',
  4148. value: function _updatePage(index) {
  4149. if (this.selected.pageIdx === index) {
  4150. this.pdfViewer.currentPageNumber = index + 1;
  4151. }
  4152. var page = this.pdfViewer.getPageView(index);
  4153. if (page.textLayer) {
  4154. page.textLayer.updateMatches();
  4155. }
  4156. }
  4157. }, {
  4158. key: '_nextMatch',
  4159. value: function _nextMatch() {
  4160. var _this4 = this;
  4161. var previous = this.state.findPrevious;
  4162. var currentPageIndex = this.pdfViewer.currentPageNumber - 1;
  4163. var numPages = this.pdfViewer.pagesCount;
  4164. this.active = true;
  4165. if (this.dirtyMatch) {
  4166. this.dirtyMatch = false;
  4167. this.selected.pageIdx = this.selected.matchIdx = -1;
  4168. this.offset.pageIdx = currentPageIndex;
  4169. this.offset.matchIdx = null;
  4170. this.hadMatch = false;
  4171. this.resumePageIdx = null;
  4172. this.pageMatches = [];
  4173. this.matchCount = 0;
  4174. this.pageMatchesLength = null;
  4175. for (var i = 0; i < numPages; i++) {
  4176. this._updatePage(i);
  4177. if (!(i in this.pendingFindMatches)) {
  4178. this.pendingFindMatches[i] = true;
  4179. this.extractTextPromises[i].then(function (pageIdx) {
  4180. delete _this4.pendingFindMatches[pageIdx];
  4181. _this4._calculateMatch(pageIdx);
  4182. });
  4183. }
  4184. }
  4185. }
  4186. if (this.state.query === '') {
  4187. this._updateUIState(FindState.FOUND);
  4188. return;
  4189. }
  4190. if (this.resumePageIdx) {
  4191. return;
  4192. }
  4193. var offset = this.offset;
  4194. this.pagesToSearch = numPages;
  4195. if (offset.matchIdx !== null) {
  4196. var numPageMatches = this.pageMatches[offset.pageIdx].length;
  4197. if (!previous && offset.matchIdx + 1 < numPageMatches || previous && offset.matchIdx > 0) {
  4198. this.hadMatch = true;
  4199. offset.matchIdx = previous ? offset.matchIdx - 1 : offset.matchIdx + 1;
  4200. this._updateMatch(true);
  4201. return;
  4202. }
  4203. this._advanceOffsetPage(previous);
  4204. }
  4205. this._nextPageMatch();
  4206. }
  4207. }, {
  4208. key: '_matchesReady',
  4209. value: function _matchesReady(matches) {
  4210. var offset = this.offset;
  4211. var numMatches = matches.length;
  4212. var previous = this.state.findPrevious;
  4213. if (numMatches) {
  4214. this.hadMatch = true;
  4215. offset.matchIdx = previous ? numMatches - 1 : 0;
  4216. this._updateMatch(true);
  4217. return true;
  4218. }
  4219. this._advanceOffsetPage(previous);
  4220. if (offset.wrapped) {
  4221. offset.matchIdx = null;
  4222. if (this.pagesToSearch < 0) {
  4223. this._updateMatch(false);
  4224. return true;
  4225. }
  4226. }
  4227. return false;
  4228. }
  4229. }, {
  4230. key: '_nextPageMatch',
  4231. value: function _nextPageMatch() {
  4232. if (this.resumePageIdx !== null) {
  4233. console.error('There can only be one pending page.');
  4234. }
  4235. var matches = null;
  4236. do {
  4237. var pageIdx = this.offset.pageIdx;
  4238. matches = this.pageMatches[pageIdx];
  4239. if (!matches) {
  4240. this.resumePageIdx = pageIdx;
  4241. break;
  4242. }
  4243. } while (!this._matchesReady(matches));
  4244. }
  4245. }, {
  4246. key: '_advanceOffsetPage',
  4247. value: function _advanceOffsetPage(previous) {
  4248. var offset = this.offset;
  4249. var numPages = this.extractTextPromises.length;
  4250. offset.pageIdx = previous ? offset.pageIdx - 1 : offset.pageIdx + 1;
  4251. offset.matchIdx = null;
  4252. this.pagesToSearch--;
  4253. if (offset.pageIdx >= numPages || offset.pageIdx < 0) {
  4254. offset.pageIdx = previous ? numPages - 1 : 0;
  4255. offset.wrapped = true;
  4256. }
  4257. }
  4258. }, {
  4259. key: '_updateMatch',
  4260. value: function _updateMatch() {
  4261. var found = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  4262. var state = FindState.NOT_FOUND;
  4263. var wrapped = this.offset.wrapped;
  4264. this.offset.wrapped = false;
  4265. if (found) {
  4266. var previousPage = this.selected.pageIdx;
  4267. this.selected.pageIdx = this.offset.pageIdx;
  4268. this.selected.matchIdx = this.offset.matchIdx;
  4269. state = wrapped ? FindState.WRAPPED : FindState.FOUND;
  4270. if (previousPage !== -1 && previousPage !== this.selected.pageIdx) {
  4271. this._updatePage(previousPage);
  4272. }
  4273. }
  4274. this._updateUIState(state, this.state.findPrevious);
  4275. if (this.selected.pageIdx !== -1) {
  4276. this._updatePage(this.selected.pageIdx);
  4277. }
  4278. }
  4279. }, {
  4280. key: '_updateUIResultsCount',
  4281. value: function _updateUIResultsCount() {
  4282. if (this.onUpdateResultsCount) {
  4283. this.onUpdateResultsCount(this.matchCount);
  4284. }
  4285. }
  4286. }, {
  4287. key: '_updateUIState',
  4288. value: function _updateUIState(state, previous) {
  4289. if (this.onUpdateState) {
  4290. this.onUpdateState(state, previous, this.matchCount);
  4291. }
  4292. }
  4293. }]);
  4294. return PDFFindController;
  4295. }();
  4296. exports.FindState = FindState;
  4297. exports.PDFFindController = PDFFindController;
  4298. /***/ }),
  4299. /* 14 */
  4300. /***/ (function(module, exports, __w_pdfjs_require__) {
  4301. "use strict";
  4302. Object.defineProperty(exports, "__esModule", {
  4303. value: true
  4304. });
  4305. exports.isDestArraysEqual = exports.isDestHashesEqual = exports.PDFHistory = undefined;
  4306. var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
  4307. var _createClass = function () { 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); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  4308. var _ui_utils = __w_pdfjs_require__(0);
  4309. var _dom_events = __w_pdfjs_require__(2);
  4310. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  4311. var HASH_CHANGE_TIMEOUT = 1000;
  4312. var POSITION_UPDATED_THRESHOLD = 50;
  4313. var UPDATE_VIEWAREA_TIMEOUT = 1000;
  4314. function getCurrentHash() {
  4315. return document.location.hash;
  4316. }
  4317. function parseCurrentHash(linkService) {
  4318. var hash = unescape(getCurrentHash()).substring(1);
  4319. var params = (0, _ui_utils.parseQueryString)(hash);
  4320. var page = params.page | 0;
  4321. if (!(Number.isInteger(page) && page > 0 && page <= linkService.pagesCount)) {
  4322. page = null;
  4323. }
  4324. return {
  4325. hash: hash,
  4326. page: page,
  4327. rotation: linkService.rotation
  4328. };
  4329. }
  4330. var PDFHistory = function () {
  4331. function PDFHistory(_ref) {
  4332. var _this = this;
  4333. var linkService = _ref.linkService,
  4334. eventBus = _ref.eventBus;
  4335. _classCallCheck(this, PDFHistory);
  4336. this.linkService = linkService;
  4337. this.eventBus = eventBus || (0, _dom_events.getGlobalEventBus)();
  4338. this.initialized = false;
  4339. this.initialBookmark = null;
  4340. this.initialRotation = null;
  4341. this._boundEvents = Object.create(null);
  4342. this._isViewerInPresentationMode = false;
  4343. this._isPagesLoaded = false;
  4344. this.eventBus.on('presentationmodechanged', function (evt) {
  4345. _this._isViewerInPresentationMode = evt.active || evt.switchInProgress;
  4346. });
  4347. this.eventBus.on('pagesloaded', function (evt) {
  4348. _this._isPagesLoaded = !!evt.pagesCount;
  4349. });
  4350. }
  4351. _createClass(PDFHistory, [{
  4352. key: 'initialize',
  4353. value: function initialize(fingerprint) {
  4354. var resetHistory = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  4355. if (!fingerprint || typeof fingerprint !== 'string') {
  4356. console.error('PDFHistory.initialize: The "fingerprint" must be a non-empty string.');
  4357. return;
  4358. }
  4359. var reInitialized = this.initialized && this.fingerprint !== fingerprint;
  4360. this.fingerprint = fingerprint;
  4361. if (!this.initialized) {
  4362. this._bindEvents();
  4363. }
  4364. var state = window.history.state;
  4365. this.initialized = true;
  4366. this.initialBookmark = null;
  4367. this.initialRotation = null;
  4368. this._popStateInProgress = false;
  4369. this._blockHashChange = 0;
  4370. this._currentHash = getCurrentHash();
  4371. this._numPositionUpdates = 0;
  4372. this._uid = this._maxUid = 0;
  4373. this._destination = null;
  4374. this._position = null;
  4375. if (!this._isValidState(state) || resetHistory) {
  4376. var _parseCurrentHash = parseCurrentHash(this.linkService),
  4377. hash = _parseCurrentHash.hash,
  4378. page = _parseCurrentHash.page,
  4379. rotation = _parseCurrentHash.rotation;
  4380. if (!hash || reInitialized || resetHistory) {
  4381. this._pushOrReplaceState(null, true);
  4382. return;
  4383. }
  4384. this._pushOrReplaceState({
  4385. hash: hash,
  4386. page: page,
  4387. rotation: rotation
  4388. }, true);
  4389. return;
  4390. }
  4391. var destination = state.destination;
  4392. this._updateInternalState(destination, state.uid, true);
  4393. if (this._uid > this._maxUid) {
  4394. this._maxUid = this._uid;
  4395. }
  4396. if (destination.rotation !== undefined) {
  4397. this.initialRotation = destination.rotation;
  4398. }
  4399. if (destination.dest) {
  4400. this.initialBookmark = JSON.stringify(destination.dest);
  4401. this._destination.page = null;
  4402. } else if (destination.hash) {
  4403. this.initialBookmark = destination.hash;
  4404. } else if (destination.page) {
  4405. this.initialBookmark = 'page=' + destination.page;
  4406. }
  4407. }
  4408. }, {
  4409. key: 'push',
  4410. value: function push(_ref2) {
  4411. var _this2 = this;
  4412. var namedDest = _ref2.namedDest,
  4413. explicitDest = _ref2.explicitDest,
  4414. pageNumber = _ref2.pageNumber;
  4415. if (!this.initialized) {
  4416. return;
  4417. }
  4418. if (namedDest && typeof namedDest !== 'string' || !(explicitDest instanceof Array) || !(Number.isInteger(pageNumber) && pageNumber > 0 && pageNumber <= this.linkService.pagesCount)) {
  4419. console.error('PDFHistory.push: Invalid parameters.');
  4420. return;
  4421. }
  4422. var hash = namedDest || JSON.stringify(explicitDest);
  4423. if (!hash) {
  4424. return;
  4425. }
  4426. var forceReplace = false;
  4427. if (this._destination && (isDestHashesEqual(this._destination.hash, hash) || isDestArraysEqual(this._destination.dest, explicitDest))) {
  4428. if (this._destination.page) {
  4429. return;
  4430. }
  4431. forceReplace = true;
  4432. }
  4433. if (this._popStateInProgress && !forceReplace) {
  4434. return;
  4435. }
  4436. this._pushOrReplaceState({
  4437. dest: explicitDest,
  4438. hash: hash,
  4439. page: pageNumber,
  4440. rotation: this.linkService.rotation
  4441. }, forceReplace);
  4442. if (!this._popStateInProgress) {
  4443. this._popStateInProgress = true;
  4444. Promise.resolve().then(function () {
  4445. _this2._popStateInProgress = false;
  4446. });
  4447. }
  4448. }
  4449. }, {
  4450. key: 'pushCurrentPosition',
  4451. value: function pushCurrentPosition() {
  4452. if (!this.initialized || this._popStateInProgress) {
  4453. return;
  4454. }
  4455. this._tryPushCurrentPosition();
  4456. }
  4457. }, {
  4458. key: 'back',
  4459. value: function back() {
  4460. if (!this.initialized || this._popStateInProgress) {
  4461. return;
  4462. }
  4463. var state = window.history.state;
  4464. if (this._isValidState(state) && state.uid > 0) {
  4465. window.history.back();
  4466. }
  4467. }
  4468. }, {
  4469. key: 'forward',
  4470. value: function forward() {
  4471. if (!this.initialized || this._popStateInProgress) {
  4472. return;
  4473. }
  4474. var state = window.history.state;
  4475. if (this._isValidState(state) && state.uid < this._maxUid) {
  4476. window.history.forward();
  4477. }
  4478. }
  4479. }, {
  4480. key: '_pushOrReplaceState',
  4481. value: function _pushOrReplaceState(destination) {
  4482. var forceReplace = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  4483. var shouldReplace = forceReplace || !this._destination;
  4484. var newState = {
  4485. fingerprint: this.fingerprint,
  4486. uid: shouldReplace ? this._uid : this._uid + 1,
  4487. destination: destination
  4488. };
  4489. this._updateInternalState(destination, newState.uid);
  4490. if (shouldReplace) {
  4491. window.history.replaceState(newState, '');
  4492. } else {
  4493. this._maxUid = this._uid;
  4494. window.history.pushState(newState, '');
  4495. }
  4496. }
  4497. }, {
  4498. key: '_tryPushCurrentPosition',
  4499. value: function _tryPushCurrentPosition() {
  4500. var temporary = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  4501. if (!this._position) {
  4502. return;
  4503. }
  4504. var position = this._position;
  4505. if (temporary) {
  4506. position = (0, _ui_utils.cloneObj)(this._position);
  4507. position.temporary = true;
  4508. }
  4509. if (!this._destination) {
  4510. this._pushOrReplaceState(position);
  4511. return;
  4512. }
  4513. if (this._destination.temporary) {
  4514. this._pushOrReplaceState(position, true);
  4515. return;
  4516. }
  4517. if (this._destination.hash === position.hash) {
  4518. return;
  4519. }
  4520. if (!this._destination.page && (POSITION_UPDATED_THRESHOLD <= 0 || this._numPositionUpdates <= POSITION_UPDATED_THRESHOLD)) {
  4521. return;
  4522. }
  4523. var forceReplace = false;
  4524. if (this._destination.page === position.first || this._destination.page === position.page) {
  4525. if (this._destination.dest || !this._destination.first) {
  4526. return;
  4527. }
  4528. forceReplace = true;
  4529. }
  4530. this._pushOrReplaceState(position, forceReplace);
  4531. }
  4532. }, {
  4533. key: '_isValidState',
  4534. value: function _isValidState(state) {
  4535. if (!state) {
  4536. return false;
  4537. }
  4538. if (state.fingerprint !== this.fingerprint) {
  4539. return false;
  4540. }
  4541. if (!Number.isInteger(state.uid) || state.uid < 0) {
  4542. return false;
  4543. }
  4544. if (state.destination === null || _typeof(state.destination) !== 'object') {
  4545. return false;
  4546. }
  4547. return true;
  4548. }
  4549. }, {
  4550. key: '_updateInternalState',
  4551. value: function _updateInternalState(destination, uid) {
  4552. var removeTemporary = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  4553. if (this._updateViewareaTimeout) {
  4554. clearTimeout(this._updateViewareaTimeout);
  4555. this._updateViewareaTimeout = null;
  4556. }
  4557. if (removeTemporary && destination && destination.temporary) {
  4558. delete destination.temporary;
  4559. }
  4560. this._destination = destination;
  4561. this._uid = uid;
  4562. this._numPositionUpdates = 0;
  4563. }
  4564. }, {
  4565. key: '_updateViewarea',
  4566. value: function _updateViewarea(_ref3) {
  4567. var _this3 = this;
  4568. var location = _ref3.location;
  4569. if (this._updateViewareaTimeout) {
  4570. clearTimeout(this._updateViewareaTimeout);
  4571. this._updateViewareaTimeout = null;
  4572. }
  4573. this._position = {
  4574. hash: this._isViewerInPresentationMode ? 'page=' + location.pageNumber : location.pdfOpenParams.substring(1),
  4575. page: this.linkService.page,
  4576. first: location.pageNumber,
  4577. rotation: location.rotation
  4578. };
  4579. if (this._popStateInProgress) {
  4580. return;
  4581. }
  4582. if (POSITION_UPDATED_THRESHOLD > 0 && this._isPagesLoaded && this._destination && !this._destination.page) {
  4583. this._numPositionUpdates++;
  4584. }
  4585. if (UPDATE_VIEWAREA_TIMEOUT > 0) {
  4586. this._updateViewareaTimeout = setTimeout(function () {
  4587. if (!_this3._popStateInProgress) {
  4588. _this3._tryPushCurrentPosition(true);
  4589. }
  4590. _this3._updateViewareaTimeout = null;
  4591. }, UPDATE_VIEWAREA_TIMEOUT);
  4592. }
  4593. }
  4594. }, {
  4595. key: '_popState',
  4596. value: function _popState(_ref4) {
  4597. var _this4 = this;
  4598. var state = _ref4.state;
  4599. var newHash = getCurrentHash(),
  4600. hashChanged = this._currentHash !== newHash;
  4601. this._currentHash = newHash;
  4602. if (!state || false) {
  4603. this._uid++;
  4604. var _parseCurrentHash2 = parseCurrentHash(this.linkService),
  4605. hash = _parseCurrentHash2.hash,
  4606. page = _parseCurrentHash2.page,
  4607. rotation = _parseCurrentHash2.rotation;
  4608. this._pushOrReplaceState({
  4609. hash: hash,
  4610. page: page,
  4611. rotation: rotation
  4612. }, true);
  4613. return;
  4614. }
  4615. if (!this._isValidState(state)) {
  4616. return;
  4617. }
  4618. this._popStateInProgress = true;
  4619. if (hashChanged) {
  4620. this._blockHashChange++;
  4621. (0, _ui_utils.waitOnEventOrTimeout)({
  4622. target: window,
  4623. name: 'hashchange',
  4624. delay: HASH_CHANGE_TIMEOUT
  4625. }).then(function () {
  4626. _this4._blockHashChange--;
  4627. });
  4628. }
  4629. var destination = state.destination;
  4630. this._updateInternalState(destination, state.uid, true);
  4631. if (this._uid > this._maxUid) {
  4632. this._maxUid = this._uid;
  4633. }
  4634. if ((0, _ui_utils.isValidRotation)(destination.rotation)) {
  4635. this.linkService.rotation = destination.rotation;
  4636. }
  4637. if (destination.dest) {
  4638. this.linkService.navigateTo(destination.dest);
  4639. } else if (destination.hash) {
  4640. this.linkService.setHash(destination.hash);
  4641. } else if (destination.page) {
  4642. this.linkService.page = destination.page;
  4643. }
  4644. Promise.resolve().then(function () {
  4645. _this4._popStateInProgress = false;
  4646. });
  4647. }
  4648. }, {
  4649. key: '_bindEvents',
  4650. value: function _bindEvents() {
  4651. var _this5 = this;
  4652. var _boundEvents = this._boundEvents,
  4653. eventBus = this.eventBus;
  4654. _boundEvents.updateViewarea = this._updateViewarea.bind(this);
  4655. _boundEvents.popState = this._popState.bind(this);
  4656. _boundEvents.pageHide = function (evt) {
  4657. if (!_this5._destination || _this5._destination.temporary) {
  4658. _this5._tryPushCurrentPosition();
  4659. }
  4660. };
  4661. eventBus.on('updateviewarea', _boundEvents.updateViewarea);
  4662. window.addEventListener('popstate', _boundEvents.popState);
  4663. window.addEventListener('pagehide', _boundEvents.pageHide);
  4664. }
  4665. }, {
  4666. key: 'popStateInProgress',
  4667. get: function get() {
  4668. return this.initialized && (this._popStateInProgress || this._blockHashChange > 0);
  4669. }
  4670. }]);
  4671. return PDFHistory;
  4672. }();
  4673. function isDestHashesEqual(destHash, pushHash) {
  4674. if (typeof destHash !== 'string' || typeof pushHash !== 'string') {
  4675. return false;
  4676. }
  4677. if (destHash === pushHash) {
  4678. return true;
  4679. }
  4680. var _parseQueryString = (0, _ui_utils.parseQueryString)(destHash),
  4681. nameddest = _parseQueryString.nameddest;
  4682. if (nameddest === pushHash) {
  4683. return true;
  4684. }
  4685. return false;
  4686. }
  4687. function isDestArraysEqual(firstDest, secondDest) {
  4688. function isEntryEqual(first, second) {
  4689. if ((typeof first === 'undefined' ? 'undefined' : _typeof(first)) !== (typeof second === 'undefined' ? 'undefined' : _typeof(second))) {
  4690. return false;
  4691. }
  4692. if (first instanceof Array || second instanceof Array) {
  4693. return false;
  4694. }
  4695. if (first !== null && (typeof first === 'undefined' ? 'undefined' : _typeof(first)) === 'object' && second !== null) {
  4696. if (Object.keys(first).length !== Object.keys(second).length) {
  4697. return false;
  4698. }
  4699. for (var key in first) {
  4700. if (!isEntryEqual(first[key], second[key])) {
  4701. return false;
  4702. }
  4703. }
  4704. return true;
  4705. }
  4706. return first === second || Number.isNaN(first) && Number.isNaN(second);
  4707. }
  4708. if (!(firstDest instanceof Array && secondDest instanceof Array)) {
  4709. return false;
  4710. }
  4711. if (firstDest.length !== secondDest.length) {
  4712. return false;
  4713. }
  4714. for (var i = 0, ii = firstDest.length; i < ii; i++) {
  4715. if (!isEntryEqual(firstDest[i], secondDest[i])) {
  4716. return false;
  4717. }
  4718. }
  4719. return true;
  4720. }
  4721. exports.PDFHistory = PDFHistory;
  4722. exports.isDestHashesEqual = isDestHashesEqual;
  4723. exports.isDestArraysEqual = isDestArraysEqual;
  4724. /***/ }),
  4725. /* 15 */
  4726. /***/ (function(module, exports, __w_pdfjs_require__) {
  4727. "use strict";
  4728. Object.defineProperty(exports, "__esModule", {
  4729. value: true
  4730. });
  4731. var compatibilityParams = Object.create(null);
  4732. {
  4733. var userAgent = typeof navigator !== 'undefined' && navigator.userAgent || '';
  4734. var isAndroid = /Android/.test(userAgent);
  4735. var isIE = /Trident/.test(userAgent);
  4736. var isIOS = /\b(iPad|iPhone|iPod)(?=;)/.test(userAgent);
  4737. (function checkFullscreenSupport() {
  4738. if (isIE && window.parent !== window) {
  4739. compatibilityParams.disableFullscreen = true;
  4740. }
  4741. })();
  4742. (function checkCanvasSizeLimitation() {
  4743. if (isIOS || isAndroid) {
  4744. compatibilityParams.maxCanvasPixels = 5242880;
  4745. }
  4746. })();
  4747. }
  4748. var viewerCompatibilityParams = Object.freeze(compatibilityParams);
  4749. exports.viewerCompatibilityParams = viewerCompatibilityParams;
  4750. /***/ }),
  4751. /* 16 */
  4752. /***/ (function(module, exports, __w_pdfjs_require__) {
  4753. "use strict";
  4754. Object.defineProperty(exports, "__esModule", {
  4755. value: true
  4756. });
  4757. exports.PDFSinglePageViewer = undefined;
  4758. var _createClass = function () { 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); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  4759. var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } };
  4760. var _base_viewer = __w_pdfjs_require__(8);
  4761. var _ui_utils = __w_pdfjs_require__(0);
  4762. var _pdfjsLib = __w_pdfjs_require__(1);
  4763. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  4764. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  4765. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  4766. var PDFSinglePageViewer = function (_BaseViewer) {
  4767. _inherits(PDFSinglePageViewer, _BaseViewer);
  4768. function PDFSinglePageViewer(options) {
  4769. _classCallCheck(this, PDFSinglePageViewer);
  4770. var _this = _possibleConstructorReturn(this, (PDFSinglePageViewer.__proto__ || Object.getPrototypeOf(PDFSinglePageViewer)).call(this, options));
  4771. _this.eventBus.on('pagesinit', function (evt) {
  4772. _this._ensurePageViewVisible();
  4773. });
  4774. return _this;
  4775. }
  4776. _createClass(PDFSinglePageViewer, [{
  4777. key: '_resetView',
  4778. value: function _resetView() {
  4779. _get(PDFSinglePageViewer.prototype.__proto__ || Object.getPrototypeOf(PDFSinglePageViewer.prototype), '_resetView', this).call(this);
  4780. this._previousPageNumber = 1;
  4781. this._shadowViewer = document.createDocumentFragment();
  4782. }
  4783. }, {
  4784. key: '_ensurePageViewVisible',
  4785. value: function _ensurePageViewVisible() {
  4786. var pageView = this._pages[this._currentPageNumber - 1];
  4787. var previousPageView = this._pages[this._previousPageNumber - 1];
  4788. var viewerNodes = this.viewer.childNodes;
  4789. switch (viewerNodes.length) {
  4790. case 0:
  4791. this.viewer.appendChild(pageView.div);
  4792. break;
  4793. case 1:
  4794. if (viewerNodes[0] !== previousPageView.div) {
  4795. throw new Error('_ensurePageViewVisible: Unexpected previously visible page.');
  4796. }
  4797. if (pageView === previousPageView) {
  4798. break;
  4799. }
  4800. this._shadowViewer.appendChild(previousPageView.div);
  4801. this.viewer.appendChild(pageView.div);
  4802. this.container.scrollTop = 0;
  4803. break;
  4804. default:
  4805. throw new Error('_ensurePageViewVisible: Only one page should be visible at a time.');
  4806. }
  4807. this._previousPageNumber = this._currentPageNumber;
  4808. }
  4809. }, {
  4810. key: '_scrollUpdate',
  4811. value: function _scrollUpdate() {
  4812. if (this._updateScrollDown) {
  4813. this._updateScrollDown();
  4814. }
  4815. _get(PDFSinglePageViewer.prototype.__proto__ || Object.getPrototypeOf(PDFSinglePageViewer.prototype), '_scrollUpdate', this).call(this);
  4816. }
  4817. }, {
  4818. key: '_scrollIntoView',
  4819. value: function _scrollIntoView(_ref) {
  4820. var _this2 = this;
  4821. var pageDiv = _ref.pageDiv,
  4822. _ref$pageSpot = _ref.pageSpot,
  4823. pageSpot = _ref$pageSpot === undefined ? null : _ref$pageSpot,
  4824. _ref$pageNumber = _ref.pageNumber,
  4825. pageNumber = _ref$pageNumber === undefined ? null : _ref$pageNumber;
  4826. if (pageNumber) {
  4827. this._setCurrentPageNumber(pageNumber);
  4828. }
  4829. var scrolledDown = this._currentPageNumber >= this._previousPageNumber;
  4830. var previousLocation = this._location;
  4831. this._ensurePageViewVisible();
  4832. (0, _ui_utils.scrollIntoView)(pageDiv, pageSpot);
  4833. this._updateScrollDown = function () {
  4834. _this2.scroll.down = scrolledDown;
  4835. delete _this2._updateScrollDown;
  4836. };
  4837. setTimeout(function () {
  4838. if (_this2._location === previousLocation) {
  4839. if (_this2._updateScrollDown) {
  4840. _this2._updateScrollDown();
  4841. }
  4842. _this2.update();
  4843. }
  4844. }, 0);
  4845. }
  4846. }, {
  4847. key: '_getVisiblePages',
  4848. value: function _getVisiblePages() {
  4849. if (!this.pagesCount) {
  4850. return { views: [] };
  4851. }
  4852. var pageView = this._pages[this._currentPageNumber - 1];
  4853. var element = pageView.div;
  4854. var view = {
  4855. id: pageView.id,
  4856. x: element.offsetLeft + element.clientLeft,
  4857. y: element.offsetTop + element.clientTop,
  4858. view: pageView
  4859. };
  4860. return {
  4861. first: view,
  4862. last: view,
  4863. views: [view]
  4864. };
  4865. }
  4866. }, {
  4867. key: 'update',
  4868. value: function update() {
  4869. var visible = this._getVisiblePages();
  4870. var visiblePages = visible.views,
  4871. numVisiblePages = visiblePages.length;
  4872. if (numVisiblePages === 0) {
  4873. return;
  4874. }
  4875. this._resizeBuffer(numVisiblePages);
  4876. this.renderingQueue.renderHighestPriority(visible);
  4877. this._updateLocation(visible.first);
  4878. this.eventBus.dispatch('updateviewarea', {
  4879. source: this,
  4880. location: this._location
  4881. });
  4882. }
  4883. }, {
  4884. key: '_setDocumentViewerElement',
  4885. get: function get() {
  4886. return (0, _pdfjsLib.shadow)(this, '_setDocumentViewerElement', this._shadowViewer);
  4887. }
  4888. }]);
  4889. return PDFSinglePageViewer;
  4890. }(_base_viewer.BaseViewer);
  4891. exports.PDFSinglePageViewer = PDFSinglePageViewer;
  4892. /***/ }),
  4893. /* 17 */
  4894. /***/ (function(module, exports, __w_pdfjs_require__) {
  4895. "use strict";
  4896. Object.defineProperty(exports, "__esModule", {
  4897. value: true
  4898. });
  4899. exports.PDFViewer = undefined;
  4900. var _createClass = function () { 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); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  4901. var _ui_utils = __w_pdfjs_require__(0);
  4902. var _base_viewer = __w_pdfjs_require__(8);
  4903. var _pdfjsLib = __w_pdfjs_require__(1);
  4904. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  4905. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  4906. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  4907. var PDFViewer = function (_BaseViewer) {
  4908. _inherits(PDFViewer, _BaseViewer);
  4909. function PDFViewer() {
  4910. _classCallCheck(this, PDFViewer);
  4911. return _possibleConstructorReturn(this, (PDFViewer.__proto__ || Object.getPrototypeOf(PDFViewer)).apply(this, arguments));
  4912. }
  4913. _createClass(PDFViewer, [{
  4914. key: '_scrollIntoView',
  4915. value: function _scrollIntoView(_ref) {
  4916. var pageDiv = _ref.pageDiv,
  4917. _ref$pageSpot = _ref.pageSpot,
  4918. pageSpot = _ref$pageSpot === undefined ? null : _ref$pageSpot;
  4919. (0, _ui_utils.scrollIntoView)(pageDiv, pageSpot);
  4920. }
  4921. }, {
  4922. key: '_getVisiblePages',
  4923. value: function _getVisiblePages() {
  4924. if (!this.isInPresentationMode) {
  4925. return (0, _ui_utils.getVisibleElements)(this.container, this._pages, true);
  4926. }
  4927. var currentPage = this._pages[this._currentPageNumber - 1];
  4928. var visible = [{
  4929. id: currentPage.id,
  4930. view: currentPage
  4931. }];
  4932. return {
  4933. first: currentPage,
  4934. last: currentPage,
  4935. views: visible
  4936. };
  4937. }
  4938. }, {
  4939. key: 'update',
  4940. value: function update() {
  4941. var visible = this._getVisiblePages();
  4942. var visiblePages = visible.views,
  4943. numVisiblePages = visiblePages.length;
  4944. if (numVisiblePages === 0) {
  4945. return;
  4946. }
  4947. this._resizeBuffer(numVisiblePages);
  4948. this.renderingQueue.renderHighestPriority(visible);
  4949. var currentId = this._currentPageNumber;
  4950. var stillFullyVisible = false;
  4951. for (var i = 0; i < numVisiblePages; ++i) {
  4952. var page = visiblePages[i];
  4953. if (page.percent < 100) {
  4954. break;
  4955. }
  4956. if (page.id === currentId) {
  4957. stillFullyVisible = true;
  4958. break;
  4959. }
  4960. }
  4961. if (!stillFullyVisible) {
  4962. currentId = visiblePages[0].id;
  4963. }
  4964. if (!this.isInPresentationMode) {
  4965. this._setCurrentPageNumber(currentId);
  4966. }
  4967. this._updateLocation(visible.first);
  4968. this.eventBus.dispatch('updateviewarea', {
  4969. source: this,
  4970. location: this._location
  4971. });
  4972. }
  4973. }, {
  4974. key: '_setDocumentViewerElement',
  4975. get: function get() {
  4976. return (0, _pdfjsLib.shadow)(this, '_setDocumentViewerElement', this.viewer);
  4977. }
  4978. }]);
  4979. return PDFViewer;
  4980. }(_base_viewer.BaseViewer);
  4981. exports.PDFViewer = PDFViewer;
  4982. /***/ })
  4983. /******/ ]);
  4984. });
  4985. //# sourceMappingURL=pdf_viewer.js.map