pdf_viewer.js 172 KB

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