pdf.js 573 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395
  1. /* Copyright 2017 Mozilla Foundation
  2. *
  3. * Licensed under the Apache License, Version 2.0 (the "License");
  4. * you may not use this file except in compliance with the License.
  5. * You may obtain a copy of the License at
  6. *
  7. * http://www.apache.org/licenses/LICENSE-2.0
  8. *
  9. * Unless required by applicable law or agreed to in writing, software
  10. * distributed under the License is distributed on an "AS IS" BASIS,
  11. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. * See the License for the specific language governing permissions and
  13. * limitations under the License.
  14. */
  15. (function webpackUniversalModuleDefinition(root, factory) {
  16. if(typeof exports === 'object' && typeof module === 'object')
  17. module.exports = factory();
  18. else if(typeof define === 'function' && define.amd)
  19. define("pdfjs-dist/build/pdf", [], factory);
  20. else if(typeof exports === 'object')
  21. exports["pdfjs-dist/build/pdf"] = factory();
  22. else
  23. root["pdfjs-dist/build/pdf"] = root.pdfjsDistBuildPdf = factory();
  24. })(this, function() {
  25. return /******/ (function(modules) { // webpackBootstrap
  26. /******/ // The module cache
  27. /******/ var installedModules = {};
  28. /******/
  29. /******/ // The require function
  30. /******/ function __w_pdfjs_require__(moduleId) {
  31. /******/
  32. /******/ // Check if module is in cache
  33. /******/ if(installedModules[moduleId]) {
  34. /******/ return installedModules[moduleId].exports;
  35. /******/ }
  36. /******/ // Create a new module (and put it into the cache)
  37. /******/ var module = installedModules[moduleId] = {
  38. /******/ i: moduleId,
  39. /******/ l: false,
  40. /******/ exports: {}
  41. /******/ };
  42. /******/
  43. /******/ // Execute the module function
  44. /******/ modules[moduleId].call(module.exports, module, module.exports, __w_pdfjs_require__);
  45. /******/
  46. /******/ // Flag the module as loaded
  47. /******/ module.l = true;
  48. /******/
  49. /******/ // Return the exports of the module
  50. /******/ return module.exports;
  51. /******/ }
  52. /******/
  53. /******/
  54. /******/ // expose the modules object (__webpack_modules__)
  55. /******/ __w_pdfjs_require__.m = modules;
  56. /******/
  57. /******/ // expose the module cache
  58. /******/ __w_pdfjs_require__.c = installedModules;
  59. /******/
  60. /******/ // identity function for calling harmony imports with the correct context
  61. /******/ __w_pdfjs_require__.i = function(value) { return value; };
  62. /******/
  63. /******/ // define getter function for harmony exports
  64. /******/ __w_pdfjs_require__.d = function(exports, name, getter) {
  65. /******/ if(!__w_pdfjs_require__.o(exports, name)) {
  66. /******/ Object.defineProperty(exports, name, {
  67. /******/ configurable: false,
  68. /******/ enumerable: true,
  69. /******/ get: getter
  70. /******/ });
  71. /******/ }
  72. /******/ };
  73. /******/
  74. /******/ // getDefaultExport function for compatibility with non-harmony modules
  75. /******/ __w_pdfjs_require__.n = function(module) {
  76. /******/ var getter = module && module.__esModule ?
  77. /******/ function getDefault() { return module['default']; } :
  78. /******/ function getModuleExports() { return module; };
  79. /******/ __w_pdfjs_require__.d(getter, 'a', getter);
  80. /******/ return getter;
  81. /******/ };
  82. /******/
  83. /******/ // Object.prototype.hasOwnProperty.call
  84. /******/ __w_pdfjs_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
  85. /******/
  86. /******/ // __webpack_public_path__
  87. /******/ __w_pdfjs_require__.p = "";
  88. /******/
  89. /******/ // Load entry module and return exports
  90. /******/ return __w_pdfjs_require__(__w_pdfjs_require__.s = 86);
  91. /******/ })
  92. /************************************************************************/
  93. /******/ ([
  94. /* 0 */
  95. /***/ (function(module, exports, __w_pdfjs_require__) {
  96. "use strict";
  97. Object.defineProperty(exports, "__esModule", {
  98. value: true
  99. });
  100. exports.unreachable = exports.warn = exports.utf8StringToString = exports.stringToUTF8String = exports.stringToPDFString = exports.stringToBytes = exports.string32 = exports.shadow = exports.setVerbosityLevel = exports.ReadableStream = exports.removeNullCharacters = exports.readUint32 = exports.readUint16 = exports.readInt8 = exports.log2 = exports.loadJpegStream = exports.isEvalSupported = exports.isLittleEndian = exports.createValidAbsoluteUrl = exports.isSameOrigin = exports.isNodeJS = exports.isSpace = exports.isString = exports.isNum = exports.isInt = exports.isEmptyObj = exports.isBool = exports.isArrayBuffer = exports.isArray = exports.info = exports.getVerbosityLevel = exports.getLookupTableFactory = exports.deprecated = exports.createObjectURL = exports.createPromiseCapability = exports.createBlob = exports.bytesToString = exports.assert = exports.arraysToBytes = exports.arrayByteLength = exports.FormatError = exports.XRefParseException = exports.Util = exports.UnknownErrorException = exports.UnexpectedResponseException = exports.TextRenderingMode = exports.StreamType = exports.StatTimer = exports.PasswordResponses = exports.PasswordException = exports.PageViewport = exports.NotImplementedException = exports.NativeImageDecoding = exports.MissingPDFException = exports.MissingDataException = exports.MessageHandler = exports.InvalidPDFException = exports.AbortException = exports.CMapCompressionType = exports.ImageKind = exports.FontType = exports.AnnotationType = exports.AnnotationFlag = exports.AnnotationFieldFlag = exports.AnnotationBorderStyleType = exports.UNSUPPORTED_FEATURES = exports.VERBOSITY_LEVELS = exports.OPS = exports.IDENTITY_MATRIX = exports.FONT_IDENTITY_MATRIX = undefined;
  101. 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; };
  102. __w_pdfjs_require__(87);
  103. var _streams_polyfill = __w_pdfjs_require__(88);
  104. var FONT_IDENTITY_MATRIX = [0.001, 0, 0, 0.001, 0, 0];
  105. var NativeImageDecoding = {
  106. NONE: 'none',
  107. DECODE: 'decode',
  108. DISPLAY: 'display'
  109. };
  110. var TextRenderingMode = {
  111. FILL: 0,
  112. STROKE: 1,
  113. FILL_STROKE: 2,
  114. INVISIBLE: 3,
  115. FILL_ADD_TO_PATH: 4,
  116. STROKE_ADD_TO_PATH: 5,
  117. FILL_STROKE_ADD_TO_PATH: 6,
  118. ADD_TO_PATH: 7,
  119. FILL_STROKE_MASK: 3,
  120. ADD_TO_PATH_FLAG: 4
  121. };
  122. var ImageKind = {
  123. GRAYSCALE_1BPP: 1,
  124. RGB_24BPP: 2,
  125. RGBA_32BPP: 3
  126. };
  127. var AnnotationType = {
  128. TEXT: 1,
  129. LINK: 2,
  130. FREETEXT: 3,
  131. LINE: 4,
  132. SQUARE: 5,
  133. CIRCLE: 6,
  134. POLYGON: 7,
  135. POLYLINE: 8,
  136. HIGHLIGHT: 9,
  137. UNDERLINE: 10,
  138. SQUIGGLY: 11,
  139. STRIKEOUT: 12,
  140. STAMP: 13,
  141. CARET: 14,
  142. INK: 15,
  143. POPUP: 16,
  144. FILEATTACHMENT: 17,
  145. SOUND: 18,
  146. MOVIE: 19,
  147. WIDGET: 20,
  148. SCREEN: 21,
  149. PRINTERMARK: 22,
  150. TRAPNET: 23,
  151. WATERMARK: 24,
  152. THREED: 25,
  153. REDACT: 26
  154. };
  155. var AnnotationFlag = {
  156. INVISIBLE: 0x01,
  157. HIDDEN: 0x02,
  158. PRINT: 0x04,
  159. NOZOOM: 0x08,
  160. NOROTATE: 0x10,
  161. NOVIEW: 0x20,
  162. READONLY: 0x40,
  163. LOCKED: 0x80,
  164. TOGGLENOVIEW: 0x100,
  165. LOCKEDCONTENTS: 0x200
  166. };
  167. var AnnotationFieldFlag = {
  168. READONLY: 0x0000001,
  169. REQUIRED: 0x0000002,
  170. NOEXPORT: 0x0000004,
  171. MULTILINE: 0x0001000,
  172. PASSWORD: 0x0002000,
  173. NOTOGGLETOOFF: 0x0004000,
  174. RADIO: 0x0008000,
  175. PUSHBUTTON: 0x0010000,
  176. COMBO: 0x0020000,
  177. EDIT: 0x0040000,
  178. SORT: 0x0080000,
  179. FILESELECT: 0x0100000,
  180. MULTISELECT: 0x0200000,
  181. DONOTSPELLCHECK: 0x0400000,
  182. DONOTSCROLL: 0x0800000,
  183. COMB: 0x1000000,
  184. RICHTEXT: 0x2000000,
  185. RADIOSINUNISON: 0x2000000,
  186. COMMITONSELCHANGE: 0x4000000
  187. };
  188. var AnnotationBorderStyleType = {
  189. SOLID: 1,
  190. DASHED: 2,
  191. BEVELED: 3,
  192. INSET: 4,
  193. UNDERLINE: 5
  194. };
  195. var StreamType = {
  196. UNKNOWN: 0,
  197. FLATE: 1,
  198. LZW: 2,
  199. DCT: 3,
  200. JPX: 4,
  201. JBIG: 5,
  202. A85: 6,
  203. AHX: 7,
  204. CCF: 8,
  205. RL: 9
  206. };
  207. var FontType = {
  208. UNKNOWN: 0,
  209. TYPE1: 1,
  210. TYPE1C: 2,
  211. CIDFONTTYPE0: 3,
  212. CIDFONTTYPE0C: 4,
  213. TRUETYPE: 5,
  214. CIDFONTTYPE2: 6,
  215. TYPE3: 7,
  216. OPENTYPE: 8,
  217. TYPE0: 9,
  218. MMTYPE1: 10
  219. };
  220. var VERBOSITY_LEVELS = {
  221. errors: 0,
  222. warnings: 1,
  223. infos: 5
  224. };
  225. var CMapCompressionType = {
  226. NONE: 0,
  227. BINARY: 1,
  228. STREAM: 2
  229. };
  230. var OPS = {
  231. dependency: 1,
  232. setLineWidth: 2,
  233. setLineCap: 3,
  234. setLineJoin: 4,
  235. setMiterLimit: 5,
  236. setDash: 6,
  237. setRenderingIntent: 7,
  238. setFlatness: 8,
  239. setGState: 9,
  240. save: 10,
  241. restore: 11,
  242. transform: 12,
  243. moveTo: 13,
  244. lineTo: 14,
  245. curveTo: 15,
  246. curveTo2: 16,
  247. curveTo3: 17,
  248. closePath: 18,
  249. rectangle: 19,
  250. stroke: 20,
  251. closeStroke: 21,
  252. fill: 22,
  253. eoFill: 23,
  254. fillStroke: 24,
  255. eoFillStroke: 25,
  256. closeFillStroke: 26,
  257. closeEOFillStroke: 27,
  258. endPath: 28,
  259. clip: 29,
  260. eoClip: 30,
  261. beginText: 31,
  262. endText: 32,
  263. setCharSpacing: 33,
  264. setWordSpacing: 34,
  265. setHScale: 35,
  266. setLeading: 36,
  267. setFont: 37,
  268. setTextRenderingMode: 38,
  269. setTextRise: 39,
  270. moveText: 40,
  271. setLeadingMoveText: 41,
  272. setTextMatrix: 42,
  273. nextLine: 43,
  274. showText: 44,
  275. showSpacedText: 45,
  276. nextLineShowText: 46,
  277. nextLineSetSpacingShowText: 47,
  278. setCharWidth: 48,
  279. setCharWidthAndBounds: 49,
  280. setStrokeColorSpace: 50,
  281. setFillColorSpace: 51,
  282. setStrokeColor: 52,
  283. setStrokeColorN: 53,
  284. setFillColor: 54,
  285. setFillColorN: 55,
  286. setStrokeGray: 56,
  287. setFillGray: 57,
  288. setStrokeRGBColor: 58,
  289. setFillRGBColor: 59,
  290. setStrokeCMYKColor: 60,
  291. setFillCMYKColor: 61,
  292. shadingFill: 62,
  293. beginInlineImage: 63,
  294. beginImageData: 64,
  295. endInlineImage: 65,
  296. paintXObject: 66,
  297. markPoint: 67,
  298. markPointProps: 68,
  299. beginMarkedContent: 69,
  300. beginMarkedContentProps: 70,
  301. endMarkedContent: 71,
  302. beginCompat: 72,
  303. endCompat: 73,
  304. paintFormXObjectBegin: 74,
  305. paintFormXObjectEnd: 75,
  306. beginGroup: 76,
  307. endGroup: 77,
  308. beginAnnotations: 78,
  309. endAnnotations: 79,
  310. beginAnnotation: 80,
  311. endAnnotation: 81,
  312. paintJpegXObject: 82,
  313. paintImageMaskXObject: 83,
  314. paintImageMaskXObjectGroup: 84,
  315. paintImageXObject: 85,
  316. paintInlineImageXObject: 86,
  317. paintInlineImageXObjectGroup: 87,
  318. paintImageXObjectRepeat: 88,
  319. paintImageMaskXObjectRepeat: 89,
  320. paintSolidColorImageMask: 90,
  321. constructPath: 91
  322. };
  323. var verbosity = VERBOSITY_LEVELS.warnings;
  324. function setVerbosityLevel(level) {
  325. verbosity = level;
  326. }
  327. function getVerbosityLevel() {
  328. return verbosity;
  329. }
  330. function info(msg) {
  331. if (verbosity >= VERBOSITY_LEVELS.infos) {
  332. console.log('Info: ' + msg);
  333. }
  334. }
  335. function warn(msg) {
  336. if (verbosity >= VERBOSITY_LEVELS.warnings) {
  337. console.log('Warning: ' + msg);
  338. }
  339. }
  340. function deprecated(details) {
  341. console.log('Deprecated API usage: ' + details);
  342. }
  343. function unreachable(msg) {
  344. throw new Error(msg);
  345. }
  346. function assert(cond, msg) {
  347. if (!cond) {
  348. unreachable(msg);
  349. }
  350. }
  351. var UNSUPPORTED_FEATURES = {
  352. unknown: 'unknown',
  353. forms: 'forms',
  354. javaScript: 'javaScript',
  355. smask: 'smask',
  356. shadingPattern: 'shadingPattern',
  357. font: 'font'
  358. };
  359. function isSameOrigin(baseUrl, otherUrl) {
  360. try {
  361. var base = new URL(baseUrl);
  362. if (!base.origin || base.origin === 'null') {
  363. return false;
  364. }
  365. } catch (e) {
  366. return false;
  367. }
  368. var other = new URL(otherUrl, base);
  369. return base.origin === other.origin;
  370. }
  371. function isValidProtocol(url) {
  372. if (!url) {
  373. return false;
  374. }
  375. switch (url.protocol) {
  376. case 'http:':
  377. case 'https:':
  378. case 'ftp:':
  379. case 'mailto:':
  380. case 'tel:':
  381. return true;
  382. default:
  383. return false;
  384. }
  385. }
  386. function createValidAbsoluteUrl(url, baseUrl) {
  387. if (!url) {
  388. return null;
  389. }
  390. try {
  391. var absoluteUrl = baseUrl ? new URL(url, baseUrl) : new URL(url);
  392. if (isValidProtocol(absoluteUrl)) {
  393. return absoluteUrl;
  394. }
  395. } catch (ex) {}
  396. return null;
  397. }
  398. function shadow(obj, prop, value) {
  399. Object.defineProperty(obj, prop, {
  400. value: value,
  401. enumerable: true,
  402. configurable: true,
  403. writable: false
  404. });
  405. return value;
  406. }
  407. function getLookupTableFactory(initializer) {
  408. var lookup;
  409. return function () {
  410. if (initializer) {
  411. lookup = Object.create(null);
  412. initializer(lookup);
  413. initializer = null;
  414. }
  415. return lookup;
  416. };
  417. }
  418. var PasswordResponses = {
  419. NEED_PASSWORD: 1,
  420. INCORRECT_PASSWORD: 2
  421. };
  422. var PasswordException = function PasswordExceptionClosure() {
  423. function PasswordException(msg, code) {
  424. this.name = 'PasswordException';
  425. this.message = msg;
  426. this.code = code;
  427. }
  428. PasswordException.prototype = new Error();
  429. PasswordException.constructor = PasswordException;
  430. return PasswordException;
  431. }();
  432. var UnknownErrorException = function UnknownErrorExceptionClosure() {
  433. function UnknownErrorException(msg, details) {
  434. this.name = 'UnknownErrorException';
  435. this.message = msg;
  436. this.details = details;
  437. }
  438. UnknownErrorException.prototype = new Error();
  439. UnknownErrorException.constructor = UnknownErrorException;
  440. return UnknownErrorException;
  441. }();
  442. var InvalidPDFException = function InvalidPDFExceptionClosure() {
  443. function InvalidPDFException(msg) {
  444. this.name = 'InvalidPDFException';
  445. this.message = msg;
  446. }
  447. InvalidPDFException.prototype = new Error();
  448. InvalidPDFException.constructor = InvalidPDFException;
  449. return InvalidPDFException;
  450. }();
  451. var MissingPDFException = function MissingPDFExceptionClosure() {
  452. function MissingPDFException(msg) {
  453. this.name = 'MissingPDFException';
  454. this.message = msg;
  455. }
  456. MissingPDFException.prototype = new Error();
  457. MissingPDFException.constructor = MissingPDFException;
  458. return MissingPDFException;
  459. }();
  460. var UnexpectedResponseException = function UnexpectedResponseExceptionClosure() {
  461. function UnexpectedResponseException(msg, status) {
  462. this.name = 'UnexpectedResponseException';
  463. this.message = msg;
  464. this.status = status;
  465. }
  466. UnexpectedResponseException.prototype = new Error();
  467. UnexpectedResponseException.constructor = UnexpectedResponseException;
  468. return UnexpectedResponseException;
  469. }();
  470. var NotImplementedException = function NotImplementedExceptionClosure() {
  471. function NotImplementedException(msg) {
  472. this.message = msg;
  473. }
  474. NotImplementedException.prototype = new Error();
  475. NotImplementedException.prototype.name = 'NotImplementedException';
  476. NotImplementedException.constructor = NotImplementedException;
  477. return NotImplementedException;
  478. }();
  479. var MissingDataException = function MissingDataExceptionClosure() {
  480. function MissingDataException(begin, end) {
  481. this.begin = begin;
  482. this.end = end;
  483. this.message = 'Missing data [' + begin + ', ' + end + ')';
  484. }
  485. MissingDataException.prototype = new Error();
  486. MissingDataException.prototype.name = 'MissingDataException';
  487. MissingDataException.constructor = MissingDataException;
  488. return MissingDataException;
  489. }();
  490. var XRefParseException = function XRefParseExceptionClosure() {
  491. function XRefParseException(msg) {
  492. this.message = msg;
  493. }
  494. XRefParseException.prototype = new Error();
  495. XRefParseException.prototype.name = 'XRefParseException';
  496. XRefParseException.constructor = XRefParseException;
  497. return XRefParseException;
  498. }();
  499. var FormatError = function FormatErrorClosure() {
  500. function FormatError(msg) {
  501. this.message = msg;
  502. }
  503. FormatError.prototype = new Error();
  504. FormatError.prototype.name = 'FormatError';
  505. FormatError.constructor = FormatError;
  506. return FormatError;
  507. }();
  508. var AbortException = function AbortExceptionClosure() {
  509. function AbortException(msg) {
  510. this.name = 'AbortException';
  511. this.message = msg;
  512. }
  513. AbortException.prototype = new Error();
  514. AbortException.constructor = AbortException;
  515. return AbortException;
  516. }();
  517. var NullCharactersRegExp = /\x00/g;
  518. function removeNullCharacters(str) {
  519. if (typeof str !== 'string') {
  520. warn('The argument for removeNullCharacters must be a string.');
  521. return str;
  522. }
  523. return str.replace(NullCharactersRegExp, '');
  524. }
  525. function bytesToString(bytes) {
  526. assert(bytes !== null && (typeof bytes === 'undefined' ? 'undefined' : _typeof(bytes)) === 'object' && bytes.length !== undefined, 'Invalid argument for bytesToString');
  527. var length = bytes.length;
  528. var MAX_ARGUMENT_COUNT = 8192;
  529. if (length < MAX_ARGUMENT_COUNT) {
  530. return String.fromCharCode.apply(null, bytes);
  531. }
  532. var strBuf = [];
  533. for (var i = 0; i < length; i += MAX_ARGUMENT_COUNT) {
  534. var chunkEnd = Math.min(i + MAX_ARGUMENT_COUNT, length);
  535. var chunk = bytes.subarray(i, chunkEnd);
  536. strBuf.push(String.fromCharCode.apply(null, chunk));
  537. }
  538. return strBuf.join('');
  539. }
  540. function stringToBytes(str) {
  541. assert(typeof str === 'string', 'Invalid argument for stringToBytes');
  542. var length = str.length;
  543. var bytes = new Uint8Array(length);
  544. for (var i = 0; i < length; ++i) {
  545. bytes[i] = str.charCodeAt(i) & 0xFF;
  546. }
  547. return bytes;
  548. }
  549. function arrayByteLength(arr) {
  550. if (arr.length !== undefined) {
  551. return arr.length;
  552. }
  553. assert(arr.byteLength !== undefined);
  554. return arr.byteLength;
  555. }
  556. function arraysToBytes(arr) {
  557. if (arr.length === 1 && arr[0] instanceof Uint8Array) {
  558. return arr[0];
  559. }
  560. var resultLength = 0;
  561. var i,
  562. ii = arr.length;
  563. var item, itemLength;
  564. for (i = 0; i < ii; i++) {
  565. item = arr[i];
  566. itemLength = arrayByteLength(item);
  567. resultLength += itemLength;
  568. }
  569. var pos = 0;
  570. var data = new Uint8Array(resultLength);
  571. for (i = 0; i < ii; i++) {
  572. item = arr[i];
  573. if (!(item instanceof Uint8Array)) {
  574. if (typeof item === 'string') {
  575. item = stringToBytes(item);
  576. } else {
  577. item = new Uint8Array(item);
  578. }
  579. }
  580. itemLength = item.byteLength;
  581. data.set(item, pos);
  582. pos += itemLength;
  583. }
  584. return data;
  585. }
  586. function string32(value) {
  587. return String.fromCharCode(value >> 24 & 0xff, value >> 16 & 0xff, value >> 8 & 0xff, value & 0xff);
  588. }
  589. function log2(x) {
  590. var n = 1,
  591. i = 0;
  592. while (x > n) {
  593. n <<= 1;
  594. i++;
  595. }
  596. return i;
  597. }
  598. function readInt8(data, start) {
  599. return data[start] << 24 >> 24;
  600. }
  601. function readUint16(data, offset) {
  602. return data[offset] << 8 | data[offset + 1];
  603. }
  604. function readUint32(data, offset) {
  605. return (data[offset] << 24 | data[offset + 1] << 16 | data[offset + 2] << 8 | data[offset + 3]) >>> 0;
  606. }
  607. function isLittleEndian() {
  608. var buffer8 = new Uint8Array(4);
  609. buffer8[0] = 1;
  610. var view32 = new Uint32Array(buffer8.buffer, 0, 1);
  611. return view32[0] === 1;
  612. }
  613. function isEvalSupported() {
  614. try {
  615. new Function('');
  616. return true;
  617. } catch (e) {
  618. return false;
  619. }
  620. }
  621. var IDENTITY_MATRIX = [1, 0, 0, 1, 0, 0];
  622. var Util = function UtilClosure() {
  623. function Util() {}
  624. var rgbBuf = ['rgb(', 0, ',', 0, ',', 0, ')'];
  625. Util.makeCssRgb = function Util_makeCssRgb(r, g, b) {
  626. rgbBuf[1] = r;
  627. rgbBuf[3] = g;
  628. rgbBuf[5] = b;
  629. return rgbBuf.join('');
  630. };
  631. Util.transform = function Util_transform(m1, m2) {
  632. return [m1[0] * m2[0] + m1[2] * m2[1], m1[1] * m2[0] + m1[3] * m2[1], m1[0] * m2[2] + m1[2] * m2[3], m1[1] * m2[2] + m1[3] * m2[3], m1[0] * m2[4] + m1[2] * m2[5] + m1[4], m1[1] * m2[4] + m1[3] * m2[5] + m1[5]];
  633. };
  634. Util.applyTransform = function Util_applyTransform(p, m) {
  635. var xt = p[0] * m[0] + p[1] * m[2] + m[4];
  636. var yt = p[0] * m[1] + p[1] * m[3] + m[5];
  637. return [xt, yt];
  638. };
  639. Util.applyInverseTransform = function Util_applyInverseTransform(p, m) {
  640. var d = m[0] * m[3] - m[1] * m[2];
  641. var xt = (p[0] * m[3] - p[1] * m[2] + m[2] * m[5] - m[4] * m[3]) / d;
  642. var yt = (-p[0] * m[1] + p[1] * m[0] + m[4] * m[1] - m[5] * m[0]) / d;
  643. return [xt, yt];
  644. };
  645. Util.getAxialAlignedBoundingBox = function Util_getAxialAlignedBoundingBox(r, m) {
  646. var p1 = Util.applyTransform(r, m);
  647. var p2 = Util.applyTransform(r.slice(2, 4), m);
  648. var p3 = Util.applyTransform([r[0], r[3]], m);
  649. var p4 = Util.applyTransform([r[2], r[1]], m);
  650. return [Math.min(p1[0], p2[0], p3[0], p4[0]), Math.min(p1[1], p2[1], p3[1], p4[1]), Math.max(p1[0], p2[0], p3[0], p4[0]), Math.max(p1[1], p2[1], p3[1], p4[1])];
  651. };
  652. Util.inverseTransform = function Util_inverseTransform(m) {
  653. var d = m[0] * m[3] - m[1] * m[2];
  654. return [m[3] / d, -m[1] / d, -m[2] / d, m[0] / d, (m[2] * m[5] - m[4] * m[3]) / d, (m[4] * m[1] - m[5] * m[0]) / d];
  655. };
  656. Util.apply3dTransform = function Util_apply3dTransform(m, v) {
  657. return [m[0] * v[0] + m[1] * v[1] + m[2] * v[2], m[3] * v[0] + m[4] * v[1] + m[5] * v[2], m[6] * v[0] + m[7] * v[1] + m[8] * v[2]];
  658. };
  659. Util.singularValueDecompose2dScale = function Util_singularValueDecompose2dScale(m) {
  660. var transpose = [m[0], m[2], m[1], m[3]];
  661. var a = m[0] * transpose[0] + m[1] * transpose[2];
  662. var b = m[0] * transpose[1] + m[1] * transpose[3];
  663. var c = m[2] * transpose[0] + m[3] * transpose[2];
  664. var d = m[2] * transpose[1] + m[3] * transpose[3];
  665. var first = (a + d) / 2;
  666. var second = Math.sqrt((a + d) * (a + d) - 4 * (a * d - c * b)) / 2;
  667. var sx = first + second || 1;
  668. var sy = first - second || 1;
  669. return [Math.sqrt(sx), Math.sqrt(sy)];
  670. };
  671. Util.normalizeRect = function Util_normalizeRect(rect) {
  672. var r = rect.slice(0);
  673. if (rect[0] > rect[2]) {
  674. r[0] = rect[2];
  675. r[2] = rect[0];
  676. }
  677. if (rect[1] > rect[3]) {
  678. r[1] = rect[3];
  679. r[3] = rect[1];
  680. }
  681. return r;
  682. };
  683. Util.intersect = function Util_intersect(rect1, rect2) {
  684. function compare(a, b) {
  685. return a - b;
  686. }
  687. var orderedX = [rect1[0], rect1[2], rect2[0], rect2[2]].sort(compare),
  688. orderedY = [rect1[1], rect1[3], rect2[1], rect2[3]].sort(compare),
  689. result = [];
  690. rect1 = Util.normalizeRect(rect1);
  691. rect2 = Util.normalizeRect(rect2);
  692. if (orderedX[0] === rect1[0] && orderedX[1] === rect2[0] || orderedX[0] === rect2[0] && orderedX[1] === rect1[0]) {
  693. result[0] = orderedX[1];
  694. result[2] = orderedX[2];
  695. } else {
  696. return false;
  697. }
  698. if (orderedY[0] === rect1[1] && orderedY[1] === rect2[1] || orderedY[0] === rect2[1] && orderedY[1] === rect1[1]) {
  699. result[1] = orderedY[1];
  700. result[3] = orderedY[2];
  701. } else {
  702. return false;
  703. }
  704. return result;
  705. };
  706. Util.sign = function Util_sign(num) {
  707. return num < 0 ? -1 : 1;
  708. };
  709. var ROMAN_NUMBER_MAP = ['', 'C', 'CC', 'CCC', 'CD', 'D', 'DC', 'DCC', 'DCCC', 'CM', '', 'X', 'XX', 'XXX', 'XL', 'L', 'LX', 'LXX', 'LXXX', 'XC', '', 'I', 'II', 'III', 'IV', 'V', 'VI', 'VII', 'VIII', 'IX'];
  710. Util.toRoman = function Util_toRoman(number, lowerCase) {
  711. assert(isInt(number) && number > 0, 'The number should be a positive integer.');
  712. var pos,
  713. romanBuf = [];
  714. while (number >= 1000) {
  715. number -= 1000;
  716. romanBuf.push('M');
  717. }
  718. pos = number / 100 | 0;
  719. number %= 100;
  720. romanBuf.push(ROMAN_NUMBER_MAP[pos]);
  721. pos = number / 10 | 0;
  722. number %= 10;
  723. romanBuf.push(ROMAN_NUMBER_MAP[10 + pos]);
  724. romanBuf.push(ROMAN_NUMBER_MAP[20 + number]);
  725. var romanStr = romanBuf.join('');
  726. return lowerCase ? romanStr.toLowerCase() : romanStr;
  727. };
  728. Util.appendToArray = function Util_appendToArray(arr1, arr2) {
  729. Array.prototype.push.apply(arr1, arr2);
  730. };
  731. Util.prependToArray = function Util_prependToArray(arr1, arr2) {
  732. Array.prototype.unshift.apply(arr1, arr2);
  733. };
  734. Util.extendObj = function extendObj(obj1, obj2) {
  735. for (var key in obj2) {
  736. obj1[key] = obj2[key];
  737. }
  738. };
  739. Util.getInheritableProperty = function Util_getInheritableProperty(dict, name, getArray) {
  740. while (dict && !dict.has(name)) {
  741. dict = dict.get('Parent');
  742. }
  743. if (!dict) {
  744. return null;
  745. }
  746. return getArray ? dict.getArray(name) : dict.get(name);
  747. };
  748. Util.inherit = function Util_inherit(sub, base, prototype) {
  749. sub.prototype = Object.create(base.prototype);
  750. sub.prototype.constructor = sub;
  751. for (var prop in prototype) {
  752. sub.prototype[prop] = prototype[prop];
  753. }
  754. };
  755. Util.loadScript = function Util_loadScript(src, callback) {
  756. var script = document.createElement('script');
  757. var loaded = false;
  758. script.setAttribute('src', src);
  759. if (callback) {
  760. script.onload = function () {
  761. if (!loaded) {
  762. callback();
  763. }
  764. loaded = true;
  765. };
  766. }
  767. document.getElementsByTagName('head')[0].appendChild(script);
  768. };
  769. return Util;
  770. }();
  771. var PageViewport = function PageViewportClosure() {
  772. function PageViewport(viewBox, scale, rotation, offsetX, offsetY, dontFlip) {
  773. this.viewBox = viewBox;
  774. this.scale = scale;
  775. this.rotation = rotation;
  776. this.offsetX = offsetX;
  777. this.offsetY = offsetY;
  778. var centerX = (viewBox[2] + viewBox[0]) / 2;
  779. var centerY = (viewBox[3] + viewBox[1]) / 2;
  780. var rotateA, rotateB, rotateC, rotateD;
  781. rotation = rotation % 360;
  782. rotation = rotation < 0 ? rotation + 360 : rotation;
  783. switch (rotation) {
  784. case 180:
  785. rotateA = -1;
  786. rotateB = 0;
  787. rotateC = 0;
  788. rotateD = 1;
  789. break;
  790. case 90:
  791. rotateA = 0;
  792. rotateB = 1;
  793. rotateC = 1;
  794. rotateD = 0;
  795. break;
  796. case 270:
  797. rotateA = 0;
  798. rotateB = -1;
  799. rotateC = -1;
  800. rotateD = 0;
  801. break;
  802. default:
  803. rotateA = 1;
  804. rotateB = 0;
  805. rotateC = 0;
  806. rotateD = -1;
  807. break;
  808. }
  809. if (dontFlip) {
  810. rotateC = -rotateC;
  811. rotateD = -rotateD;
  812. }
  813. var offsetCanvasX, offsetCanvasY;
  814. var width, height;
  815. if (rotateA === 0) {
  816. offsetCanvasX = Math.abs(centerY - viewBox[1]) * scale + offsetX;
  817. offsetCanvasY = Math.abs(centerX - viewBox[0]) * scale + offsetY;
  818. width = Math.abs(viewBox[3] - viewBox[1]) * scale;
  819. height = Math.abs(viewBox[2] - viewBox[0]) * scale;
  820. } else {
  821. offsetCanvasX = Math.abs(centerX - viewBox[0]) * scale + offsetX;
  822. offsetCanvasY = Math.abs(centerY - viewBox[1]) * scale + offsetY;
  823. width = Math.abs(viewBox[2] - viewBox[0]) * scale;
  824. height = Math.abs(viewBox[3] - viewBox[1]) * scale;
  825. }
  826. this.transform = [rotateA * scale, rotateB * scale, rotateC * scale, rotateD * scale, offsetCanvasX - rotateA * scale * centerX - rotateC * scale * centerY, offsetCanvasY - rotateB * scale * centerX - rotateD * scale * centerY];
  827. this.width = width;
  828. this.height = height;
  829. this.fontScale = scale;
  830. }
  831. PageViewport.prototype = {
  832. clone: function PageViewPort_clone(args) {
  833. args = args || {};
  834. var scale = 'scale' in args ? args.scale : this.scale;
  835. var rotation = 'rotation' in args ? args.rotation : this.rotation;
  836. return new PageViewport(this.viewBox.slice(), scale, rotation, this.offsetX, this.offsetY, args.dontFlip);
  837. },
  838. convertToViewportPoint: function PageViewport_convertToViewportPoint(x, y) {
  839. return Util.applyTransform([x, y], this.transform);
  840. },
  841. convertToViewportRectangle: function PageViewport_convertToViewportRectangle(rect) {
  842. var tl = Util.applyTransform([rect[0], rect[1]], this.transform);
  843. var br = Util.applyTransform([rect[2], rect[3]], this.transform);
  844. return [tl[0], tl[1], br[0], br[1]];
  845. },
  846. convertToPdfPoint: function PageViewport_convertToPdfPoint(x, y) {
  847. return Util.applyInverseTransform([x, y], this.transform);
  848. }
  849. };
  850. return PageViewport;
  851. }();
  852. var PDFStringTranslateTable = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x2D8, 0x2C7, 0x2C6, 0x2D9, 0x2DD, 0x2DB, 0x2DA, 0x2DC, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x2022, 0x2020, 0x2021, 0x2026, 0x2014, 0x2013, 0x192, 0x2044, 0x2039, 0x203A, 0x2212, 0x2030, 0x201E, 0x201C, 0x201D, 0x2018, 0x2019, 0x201A, 0x2122, 0xFB01, 0xFB02, 0x141, 0x152, 0x160, 0x178, 0x17D, 0x131, 0x142, 0x153, 0x161, 0x17E, 0, 0x20AC];
  853. function stringToPDFString(str) {
  854. var i,
  855. n = str.length,
  856. strBuf = [];
  857. if (str[0] === '\xFE' && str[1] === '\xFF') {
  858. for (i = 2; i < n; i += 2) {
  859. strBuf.push(String.fromCharCode(str.charCodeAt(i) << 8 | str.charCodeAt(i + 1)));
  860. }
  861. } else {
  862. for (i = 0; i < n; ++i) {
  863. var code = PDFStringTranslateTable[str.charCodeAt(i)];
  864. strBuf.push(code ? String.fromCharCode(code) : str.charAt(i));
  865. }
  866. }
  867. return strBuf.join('');
  868. }
  869. function stringToUTF8String(str) {
  870. return decodeURIComponent(escape(str));
  871. }
  872. function utf8StringToString(str) {
  873. return unescape(encodeURIComponent(str));
  874. }
  875. function isEmptyObj(obj) {
  876. for (var key in obj) {
  877. return false;
  878. }
  879. return true;
  880. }
  881. function isBool(v) {
  882. return typeof v === 'boolean';
  883. }
  884. function isInt(v) {
  885. return typeof v === 'number' && (v | 0) === v;
  886. }
  887. function isNum(v) {
  888. return typeof v === 'number';
  889. }
  890. function isString(v) {
  891. return typeof v === 'string';
  892. }
  893. function isArray(v) {
  894. return v instanceof Array;
  895. }
  896. function isArrayBuffer(v) {
  897. return (typeof v === 'undefined' ? 'undefined' : _typeof(v)) === 'object' && v !== null && v.byteLength !== undefined;
  898. }
  899. function isSpace(ch) {
  900. return ch === 0x20 || ch === 0x09 || ch === 0x0D || ch === 0x0A;
  901. }
  902. function isNodeJS() {
  903. return (typeof process === 'undefined' ? 'undefined' : _typeof(process)) === 'object' && process + '' === '[object process]';
  904. }
  905. function createPromiseCapability() {
  906. var capability = {};
  907. capability.promise = new Promise(function (resolve, reject) {
  908. capability.resolve = resolve;
  909. capability.reject = reject;
  910. });
  911. return capability;
  912. }
  913. var StatTimer = function StatTimerClosure() {
  914. function rpad(str, pad, length) {
  915. while (str.length < length) {
  916. str += pad;
  917. }
  918. return str;
  919. }
  920. function StatTimer() {
  921. this.started = Object.create(null);
  922. this.times = [];
  923. this.enabled = true;
  924. }
  925. StatTimer.prototype = {
  926. time: function StatTimer_time(name) {
  927. if (!this.enabled) {
  928. return;
  929. }
  930. if (name in this.started) {
  931. warn('Timer is already running for ' + name);
  932. }
  933. this.started[name] = Date.now();
  934. },
  935. timeEnd: function StatTimer_timeEnd(name) {
  936. if (!this.enabled) {
  937. return;
  938. }
  939. if (!(name in this.started)) {
  940. warn('Timer has not been started for ' + name);
  941. }
  942. this.times.push({
  943. 'name': name,
  944. 'start': this.started[name],
  945. 'end': Date.now()
  946. });
  947. delete this.started[name];
  948. },
  949. toString: function StatTimer_toString() {
  950. var i, ii;
  951. var times = this.times;
  952. var out = '';
  953. var longest = 0;
  954. for (i = 0, ii = times.length; i < ii; ++i) {
  955. var name = times[i]['name'];
  956. if (name.length > longest) {
  957. longest = name.length;
  958. }
  959. }
  960. for (i = 0, ii = times.length; i < ii; ++i) {
  961. var span = times[i];
  962. var duration = span.end - span.start;
  963. out += rpad(span['name'], ' ', longest) + ' ' + duration + 'ms\n';
  964. }
  965. return out;
  966. }
  967. };
  968. return StatTimer;
  969. }();
  970. var createBlob = function createBlob(data, contentType) {
  971. if (typeof Blob !== 'undefined') {
  972. return new Blob([data], { type: contentType });
  973. }
  974. throw new Error('The "Blob" constructor is not supported.');
  975. };
  976. var createObjectURL = function createObjectURLClosure() {
  977. var digits = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
  978. return function createObjectURL(data, contentType) {
  979. var forceDataSchema = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  980. if (!forceDataSchema && URL.createObjectURL) {
  981. var blob = createBlob(data, contentType);
  982. return URL.createObjectURL(blob);
  983. }
  984. var buffer = 'data:' + contentType + ';base64,';
  985. for (var i = 0, ii = data.length; i < ii; i += 3) {
  986. var b1 = data[i] & 0xFF;
  987. var b2 = data[i + 1] & 0xFF;
  988. var b3 = data[i + 2] & 0xFF;
  989. var d1 = b1 >> 2,
  990. d2 = (b1 & 3) << 4 | b2 >> 4;
  991. var d3 = i + 1 < ii ? (b2 & 0xF) << 2 | b3 >> 6 : 64;
  992. var d4 = i + 2 < ii ? b3 & 0x3F : 64;
  993. buffer += digits[d1] + digits[d2] + digits[d3] + digits[d4];
  994. }
  995. return buffer;
  996. };
  997. }();
  998. function resolveCall(fn, args) {
  999. var thisArg = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
  1000. if (!fn) {
  1001. return Promise.resolve(undefined);
  1002. }
  1003. return new Promise(function (resolve, reject) {
  1004. resolve(fn.apply(thisArg, args));
  1005. });
  1006. }
  1007. function wrapReason(reason) {
  1008. if ((typeof reason === 'undefined' ? 'undefined' : _typeof(reason)) !== 'object') {
  1009. return reason;
  1010. }
  1011. switch (reason.name) {
  1012. case 'AbortException':
  1013. return new AbortException(reason.message);
  1014. case 'MissingPDFException':
  1015. return new MissingPDFException(reason.message);
  1016. case 'UnexpectedResponseException':
  1017. return new UnexpectedResponseException(reason.message, reason.status);
  1018. default:
  1019. return new UnknownErrorException(reason.message, reason.details);
  1020. }
  1021. }
  1022. function resolveOrReject(capability, success, reason) {
  1023. if (success) {
  1024. capability.resolve();
  1025. } else {
  1026. capability.reject(reason);
  1027. }
  1028. }
  1029. function finalize(promise) {
  1030. return Promise.resolve(promise).catch(function () {});
  1031. }
  1032. function MessageHandler(sourceName, targetName, comObj) {
  1033. var _this = this;
  1034. this.sourceName = sourceName;
  1035. this.targetName = targetName;
  1036. this.comObj = comObj;
  1037. this.callbackId = 1;
  1038. this.streamId = 1;
  1039. this.postMessageTransfers = true;
  1040. this.streamSinks = Object.create(null);
  1041. this.streamControllers = Object.create(null);
  1042. var callbacksCapabilities = this.callbacksCapabilities = Object.create(null);
  1043. var ah = this.actionHandler = Object.create(null);
  1044. this._onComObjOnMessage = function (event) {
  1045. var data = event.data;
  1046. if (data.targetName !== _this.sourceName) {
  1047. return;
  1048. }
  1049. if (data.stream) {
  1050. _this._processStreamMessage(data);
  1051. } else if (data.isReply) {
  1052. var callbackId = data.callbackId;
  1053. if (data.callbackId in callbacksCapabilities) {
  1054. var callback = callbacksCapabilities[callbackId];
  1055. delete callbacksCapabilities[callbackId];
  1056. if ('error' in data) {
  1057. callback.reject(wrapReason(data.error));
  1058. } else {
  1059. callback.resolve(data.data);
  1060. }
  1061. } else {
  1062. throw new Error('Cannot resolve callback ' + callbackId);
  1063. }
  1064. } else if (data.action in ah) {
  1065. var action = ah[data.action];
  1066. if (data.callbackId) {
  1067. var _sourceName = _this.sourceName;
  1068. var _targetName = data.sourceName;
  1069. Promise.resolve().then(function () {
  1070. return action[0].call(action[1], data.data);
  1071. }).then(function (result) {
  1072. comObj.postMessage({
  1073. sourceName: _sourceName,
  1074. targetName: _targetName,
  1075. isReply: true,
  1076. callbackId: data.callbackId,
  1077. data: result
  1078. });
  1079. }, function (reason) {
  1080. if (reason instanceof Error) {
  1081. reason = reason + '';
  1082. }
  1083. comObj.postMessage({
  1084. sourceName: _sourceName,
  1085. targetName: _targetName,
  1086. isReply: true,
  1087. callbackId: data.callbackId,
  1088. error: reason
  1089. });
  1090. });
  1091. } else if (data.streamId) {
  1092. _this._createStreamSink(data);
  1093. } else {
  1094. action[0].call(action[1], data.data);
  1095. }
  1096. } else {
  1097. throw new Error('Unknown action from worker: ' + data.action);
  1098. }
  1099. };
  1100. comObj.addEventListener('message', this._onComObjOnMessage);
  1101. }
  1102. MessageHandler.prototype = {
  1103. on: function on(actionName, handler, scope) {
  1104. var ah = this.actionHandler;
  1105. if (ah[actionName]) {
  1106. throw new Error('There is already an actionName called "' + actionName + '"');
  1107. }
  1108. ah[actionName] = [handler, scope];
  1109. },
  1110. send: function send(actionName, data, transfers) {
  1111. var message = {
  1112. sourceName: this.sourceName,
  1113. targetName: this.targetName,
  1114. action: actionName,
  1115. data: data
  1116. };
  1117. this.postMessage(message, transfers);
  1118. },
  1119. sendWithPromise: function sendWithPromise(actionName, data, transfers) {
  1120. var callbackId = this.callbackId++;
  1121. var message = {
  1122. sourceName: this.sourceName,
  1123. targetName: this.targetName,
  1124. action: actionName,
  1125. data: data,
  1126. callbackId: callbackId
  1127. };
  1128. var capability = createPromiseCapability();
  1129. this.callbacksCapabilities[callbackId] = capability;
  1130. try {
  1131. this.postMessage(message, transfers);
  1132. } catch (e) {
  1133. capability.reject(e);
  1134. }
  1135. return capability.promise;
  1136. },
  1137. sendWithStream: function sendWithStream(actionName, data, queueingStrategy, transfers) {
  1138. var _this2 = this;
  1139. var streamId = this.streamId++;
  1140. var sourceName = this.sourceName;
  1141. var targetName = this.targetName;
  1142. return new _streams_polyfill.ReadableStream({
  1143. start: function start(controller) {
  1144. var startCapability = createPromiseCapability();
  1145. _this2.streamControllers[streamId] = {
  1146. controller: controller,
  1147. startCall: startCapability,
  1148. isClosed: false
  1149. };
  1150. _this2.postMessage({
  1151. sourceName: sourceName,
  1152. targetName: targetName,
  1153. action: actionName,
  1154. streamId: streamId,
  1155. data: data,
  1156. desiredSize: controller.desiredSize
  1157. });
  1158. return startCapability.promise;
  1159. },
  1160. pull: function pull(controller) {
  1161. var pullCapability = createPromiseCapability();
  1162. _this2.streamControllers[streamId].pullCall = pullCapability;
  1163. _this2.postMessage({
  1164. sourceName: sourceName,
  1165. targetName: targetName,
  1166. stream: 'pull',
  1167. streamId: streamId,
  1168. desiredSize: controller.desiredSize
  1169. });
  1170. return pullCapability.promise;
  1171. },
  1172. cancel: function cancel(reason) {
  1173. var cancelCapability = createPromiseCapability();
  1174. _this2.streamControllers[streamId].cancelCall = cancelCapability;
  1175. _this2.streamControllers[streamId].isClosed = true;
  1176. _this2.postMessage({
  1177. sourceName: sourceName,
  1178. targetName: targetName,
  1179. stream: 'cancel',
  1180. reason: reason,
  1181. streamId: streamId
  1182. });
  1183. return cancelCapability.promise;
  1184. }
  1185. }, queueingStrategy);
  1186. },
  1187. _createStreamSink: function _createStreamSink(data) {
  1188. var _this3 = this;
  1189. var self = this;
  1190. var action = this.actionHandler[data.action];
  1191. var streamId = data.streamId;
  1192. var desiredSize = data.desiredSize;
  1193. var sourceName = this.sourceName;
  1194. var targetName = data.sourceName;
  1195. var capability = createPromiseCapability();
  1196. var sendStreamRequest = function sendStreamRequest(_ref) {
  1197. var stream = _ref.stream,
  1198. chunk = _ref.chunk,
  1199. transfers = _ref.transfers,
  1200. success = _ref.success,
  1201. reason = _ref.reason;
  1202. _this3.postMessage({
  1203. sourceName: sourceName,
  1204. targetName: targetName,
  1205. stream: stream,
  1206. streamId: streamId,
  1207. chunk: chunk,
  1208. success: success,
  1209. reason: reason
  1210. }, transfers);
  1211. };
  1212. var streamSink = {
  1213. enqueue: function enqueue(chunk) {
  1214. var size = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
  1215. var transfers = arguments[2];
  1216. if (this.isCancelled) {
  1217. return;
  1218. }
  1219. var lastDesiredSize = this.desiredSize;
  1220. this.desiredSize -= size;
  1221. if (lastDesiredSize > 0 && this.desiredSize <= 0) {
  1222. this.sinkCapability = createPromiseCapability();
  1223. this.ready = this.sinkCapability.promise;
  1224. }
  1225. sendStreamRequest({
  1226. stream: 'enqueue',
  1227. chunk: chunk,
  1228. transfers: transfers
  1229. });
  1230. },
  1231. close: function close() {
  1232. if (this.isCancelled) {
  1233. return;
  1234. }
  1235. this.isCancelled = true;
  1236. sendStreamRequest({ stream: 'close' });
  1237. delete self.streamSinks[streamId];
  1238. },
  1239. error: function error(reason) {
  1240. if (this.isCancelled) {
  1241. return;
  1242. }
  1243. this.isCancelled = true;
  1244. sendStreamRequest({
  1245. stream: 'error',
  1246. reason: reason
  1247. });
  1248. },
  1249. sinkCapability: capability,
  1250. onPull: null,
  1251. onCancel: null,
  1252. isCancelled: false,
  1253. desiredSize: desiredSize,
  1254. ready: null
  1255. };
  1256. streamSink.sinkCapability.resolve();
  1257. streamSink.ready = streamSink.sinkCapability.promise;
  1258. this.streamSinks[streamId] = streamSink;
  1259. resolveCall(action[0], [data.data, streamSink], action[1]).then(function () {
  1260. sendStreamRequest({
  1261. stream: 'start_complete',
  1262. success: true
  1263. });
  1264. }, function (reason) {
  1265. sendStreamRequest({
  1266. stream: 'start_complete',
  1267. success: false,
  1268. reason: reason
  1269. });
  1270. });
  1271. },
  1272. _processStreamMessage: function _processStreamMessage(data) {
  1273. var _this4 = this;
  1274. var sourceName = this.sourceName;
  1275. var targetName = data.sourceName;
  1276. var streamId = data.streamId;
  1277. var sendStreamResponse = function sendStreamResponse(_ref2) {
  1278. var stream = _ref2.stream,
  1279. success = _ref2.success,
  1280. reason = _ref2.reason;
  1281. _this4.comObj.postMessage({
  1282. sourceName: sourceName,
  1283. targetName: targetName,
  1284. stream: stream,
  1285. success: success,
  1286. streamId: streamId,
  1287. reason: reason
  1288. });
  1289. };
  1290. var deleteStreamController = function deleteStreamController() {
  1291. Promise.all([_this4.streamControllers[data.streamId].startCall, _this4.streamControllers[data.streamId].pullCall, _this4.streamControllers[data.streamId].cancelCall].map(function (capability) {
  1292. return capability && finalize(capability.promise);
  1293. })).then(function () {
  1294. delete _this4.streamControllers[data.streamId];
  1295. });
  1296. };
  1297. switch (data.stream) {
  1298. case 'start_complete':
  1299. resolveOrReject(this.streamControllers[data.streamId].startCall, data.success, wrapReason(data.reason));
  1300. break;
  1301. case 'pull_complete':
  1302. resolveOrReject(this.streamControllers[data.streamId].pullCall, data.success, wrapReason(data.reason));
  1303. break;
  1304. case 'pull':
  1305. if (!this.streamSinks[data.streamId]) {
  1306. sendStreamResponse({
  1307. stream: 'pull_complete',
  1308. success: true
  1309. });
  1310. break;
  1311. }
  1312. if (this.streamSinks[data.streamId].desiredSize <= 0 && data.desiredSize > 0) {
  1313. this.streamSinks[data.streamId].sinkCapability.resolve();
  1314. }
  1315. this.streamSinks[data.streamId].desiredSize = data.desiredSize;
  1316. resolveCall(this.streamSinks[data.streamId].onPull).then(function () {
  1317. sendStreamResponse({
  1318. stream: 'pull_complete',
  1319. success: true
  1320. });
  1321. }, function (reason) {
  1322. sendStreamResponse({
  1323. stream: 'pull_complete',
  1324. success: false,
  1325. reason: reason
  1326. });
  1327. });
  1328. break;
  1329. case 'enqueue':
  1330. assert(this.streamControllers[data.streamId], 'enqueue should have stream controller');
  1331. if (!this.streamControllers[data.streamId].isClosed) {
  1332. this.streamControllers[data.streamId].controller.enqueue(data.chunk);
  1333. }
  1334. break;
  1335. case 'close':
  1336. assert(this.streamControllers[data.streamId], 'close should have stream controller');
  1337. if (this.streamControllers[data.streamId].isClosed) {
  1338. break;
  1339. }
  1340. this.streamControllers[data.streamId].isClosed = true;
  1341. this.streamControllers[data.streamId].controller.close();
  1342. deleteStreamController();
  1343. break;
  1344. case 'error':
  1345. assert(this.streamControllers[data.streamId], 'error should have stream controller');
  1346. this.streamControllers[data.streamId].controller.error(wrapReason(data.reason));
  1347. deleteStreamController();
  1348. break;
  1349. case 'cancel_complete':
  1350. resolveOrReject(this.streamControllers[data.streamId].cancelCall, data.success, wrapReason(data.reason));
  1351. deleteStreamController();
  1352. break;
  1353. case 'cancel':
  1354. if (!this.streamSinks[data.streamId]) {
  1355. break;
  1356. }
  1357. resolveCall(this.streamSinks[data.streamId].onCancel, [wrapReason(data.reason)]).then(function () {
  1358. sendStreamResponse({
  1359. stream: 'cancel_complete',
  1360. success: true
  1361. });
  1362. }, function (reason) {
  1363. sendStreamResponse({
  1364. stream: 'cancel_complete',
  1365. success: false,
  1366. reason: reason
  1367. });
  1368. });
  1369. this.streamSinks[data.streamId].sinkCapability.reject(wrapReason(data.reason));
  1370. this.streamSinks[data.streamId].isCancelled = true;
  1371. delete this.streamSinks[data.streamId];
  1372. break;
  1373. default:
  1374. throw new Error('Unexpected stream case');
  1375. }
  1376. },
  1377. postMessage: function postMessage(message, transfers) {
  1378. if (transfers && this.postMessageTransfers) {
  1379. this.comObj.postMessage(message, transfers);
  1380. } else {
  1381. this.comObj.postMessage(message);
  1382. }
  1383. },
  1384. destroy: function destroy() {
  1385. this.comObj.removeEventListener('message', this._onComObjOnMessage);
  1386. }
  1387. };
  1388. function loadJpegStream(id, imageUrl, objs) {
  1389. var img = new Image();
  1390. img.onload = function loadJpegStream_onloadClosure() {
  1391. objs.resolve(id, img);
  1392. };
  1393. img.onerror = function loadJpegStream_onerrorClosure() {
  1394. objs.resolve(id, null);
  1395. warn('Error during JPEG image loading');
  1396. };
  1397. img.src = imageUrl;
  1398. }
  1399. exports.FONT_IDENTITY_MATRIX = FONT_IDENTITY_MATRIX;
  1400. exports.IDENTITY_MATRIX = IDENTITY_MATRIX;
  1401. exports.OPS = OPS;
  1402. exports.VERBOSITY_LEVELS = VERBOSITY_LEVELS;
  1403. exports.UNSUPPORTED_FEATURES = UNSUPPORTED_FEATURES;
  1404. exports.AnnotationBorderStyleType = AnnotationBorderStyleType;
  1405. exports.AnnotationFieldFlag = AnnotationFieldFlag;
  1406. exports.AnnotationFlag = AnnotationFlag;
  1407. exports.AnnotationType = AnnotationType;
  1408. exports.FontType = FontType;
  1409. exports.ImageKind = ImageKind;
  1410. exports.CMapCompressionType = CMapCompressionType;
  1411. exports.AbortException = AbortException;
  1412. exports.InvalidPDFException = InvalidPDFException;
  1413. exports.MessageHandler = MessageHandler;
  1414. exports.MissingDataException = MissingDataException;
  1415. exports.MissingPDFException = MissingPDFException;
  1416. exports.NativeImageDecoding = NativeImageDecoding;
  1417. exports.NotImplementedException = NotImplementedException;
  1418. exports.PageViewport = PageViewport;
  1419. exports.PasswordException = PasswordException;
  1420. exports.PasswordResponses = PasswordResponses;
  1421. exports.StatTimer = StatTimer;
  1422. exports.StreamType = StreamType;
  1423. exports.TextRenderingMode = TextRenderingMode;
  1424. exports.UnexpectedResponseException = UnexpectedResponseException;
  1425. exports.UnknownErrorException = UnknownErrorException;
  1426. exports.Util = Util;
  1427. exports.XRefParseException = XRefParseException;
  1428. exports.FormatError = FormatError;
  1429. exports.arrayByteLength = arrayByteLength;
  1430. exports.arraysToBytes = arraysToBytes;
  1431. exports.assert = assert;
  1432. exports.bytesToString = bytesToString;
  1433. exports.createBlob = createBlob;
  1434. exports.createPromiseCapability = createPromiseCapability;
  1435. exports.createObjectURL = createObjectURL;
  1436. exports.deprecated = deprecated;
  1437. exports.getLookupTableFactory = getLookupTableFactory;
  1438. exports.getVerbosityLevel = getVerbosityLevel;
  1439. exports.info = info;
  1440. exports.isArray = isArray;
  1441. exports.isArrayBuffer = isArrayBuffer;
  1442. exports.isBool = isBool;
  1443. exports.isEmptyObj = isEmptyObj;
  1444. exports.isInt = isInt;
  1445. exports.isNum = isNum;
  1446. exports.isString = isString;
  1447. exports.isSpace = isSpace;
  1448. exports.isNodeJS = isNodeJS;
  1449. exports.isSameOrigin = isSameOrigin;
  1450. exports.createValidAbsoluteUrl = createValidAbsoluteUrl;
  1451. exports.isLittleEndian = isLittleEndian;
  1452. exports.isEvalSupported = isEvalSupported;
  1453. exports.loadJpegStream = loadJpegStream;
  1454. exports.log2 = log2;
  1455. exports.readInt8 = readInt8;
  1456. exports.readUint16 = readUint16;
  1457. exports.readUint32 = readUint32;
  1458. exports.removeNullCharacters = removeNullCharacters;
  1459. exports.ReadableStream = _streams_polyfill.ReadableStream;
  1460. exports.setVerbosityLevel = setVerbosityLevel;
  1461. exports.shadow = shadow;
  1462. exports.string32 = string32;
  1463. exports.stringToBytes = stringToBytes;
  1464. exports.stringToPDFString = stringToPDFString;
  1465. exports.stringToUTF8String = stringToUTF8String;
  1466. exports.utf8StringToString = utf8StringToString;
  1467. exports.warn = warn;
  1468. exports.unreachable = unreachable;
  1469. /***/ }),
  1470. /* 1 */
  1471. /***/ (function(module, exports, __w_pdfjs_require__) {
  1472. "use strict";
  1473. var store = __w_pdfjs_require__(48)('wks');
  1474. var uid = __w_pdfjs_require__(13);
  1475. var _Symbol = __w_pdfjs_require__(2).Symbol;
  1476. var USE_SYMBOL = typeof _Symbol == 'function';
  1477. var $exports = module.exports = function (name) {
  1478. return store[name] || (store[name] = USE_SYMBOL && _Symbol[name] || (USE_SYMBOL ? _Symbol : uid)('Symbol.' + name));
  1479. };
  1480. $exports.store = store;
  1481. /***/ }),
  1482. /* 2 */
  1483. /***/ (function(module, exports, __w_pdfjs_require__) {
  1484. "use strict";
  1485. var global = module.exports = typeof window != 'undefined' && window.Math == Math ? window : typeof self != 'undefined' && self.Math == Math ? self : Function('return this')();
  1486. if (typeof __g == 'number') __g = global;
  1487. /***/ }),
  1488. /* 3 */
  1489. /***/ (function(module, exports, __w_pdfjs_require__) {
  1490. "use strict";
  1491. module.exports = !__w_pdfjs_require__(17)(function () {
  1492. return Object.defineProperty({}, 'a', {
  1493. get: function get() {
  1494. return 7;
  1495. }
  1496. }).a != 7;
  1497. });
  1498. /***/ }),
  1499. /* 4 */
  1500. /***/ (function(module, exports, __w_pdfjs_require__) {
  1501. "use strict";
  1502. var dP = __w_pdfjs_require__(8);
  1503. var createDesc = __w_pdfjs_require__(18);
  1504. module.exports = __w_pdfjs_require__(3) ? function (object, key, value) {
  1505. return dP.f(object, key, createDesc(1, value));
  1506. } : function (object, key, value) {
  1507. object[key] = value;
  1508. return object;
  1509. };
  1510. /***/ }),
  1511. /* 5 */
  1512. /***/ (function(module, exports, __w_pdfjs_require__) {
  1513. "use strict";
  1514. var hasOwnProperty = {}.hasOwnProperty;
  1515. module.exports = function (it, key) {
  1516. return hasOwnProperty.call(it, key);
  1517. };
  1518. /***/ }),
  1519. /* 6 */
  1520. /***/ (function(module, exports, __w_pdfjs_require__) {
  1521. "use strict";
  1522. var toInteger = __w_pdfjs_require__(11);
  1523. var min = Math.min;
  1524. module.exports = function (it) {
  1525. return it > 0 ? min(toInteger(it), 0x1fffffffffffff) : 0;
  1526. };
  1527. /***/ }),
  1528. /* 7 */
  1529. /***/ (function(module, exports, __w_pdfjs_require__) {
  1530. "use strict";
  1531. Object.defineProperty(exports, "__esModule", {
  1532. value: true
  1533. });
  1534. exports.DOMCMapReaderFactory = exports.DOMCanvasFactory = exports.DEFAULT_LINK_REL = exports.getDefaultSetting = exports.LinkTarget = exports.getFilenameFromUrl = exports.isValidUrl = exports.isExternalLinkTargetSet = exports.addLinkAttributes = exports.RenderingCancelledException = exports.CustomStyle = undefined;
  1535. 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; }; }();
  1536. var _util = __w_pdfjs_require__(0);
  1537. var _global_scope = __w_pdfjs_require__(14);
  1538. var _global_scope2 = _interopRequireDefault(_global_scope);
  1539. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  1540. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  1541. var DEFAULT_LINK_REL = 'noopener noreferrer nofollow';
  1542. var DOMCanvasFactory = function () {
  1543. function DOMCanvasFactory() {
  1544. _classCallCheck(this, DOMCanvasFactory);
  1545. }
  1546. _createClass(DOMCanvasFactory, [{
  1547. key: 'create',
  1548. value: function create(width, height) {
  1549. if (width <= 0 || height <= 0) {
  1550. throw new Error('invalid canvas size');
  1551. }
  1552. var canvas = document.createElement('canvas');
  1553. var context = canvas.getContext('2d');
  1554. canvas.width = width;
  1555. canvas.height = height;
  1556. return {
  1557. canvas: canvas,
  1558. context: context
  1559. };
  1560. }
  1561. }, {
  1562. key: 'reset',
  1563. value: function reset(canvasAndContext, width, height) {
  1564. if (!canvasAndContext.canvas) {
  1565. throw new Error('canvas is not specified');
  1566. }
  1567. if (width <= 0 || height <= 0) {
  1568. throw new Error('invalid canvas size');
  1569. }
  1570. canvasAndContext.canvas.width = width;
  1571. canvasAndContext.canvas.height = height;
  1572. }
  1573. }, {
  1574. key: 'destroy',
  1575. value: function destroy(canvasAndContext) {
  1576. if (!canvasAndContext.canvas) {
  1577. throw new Error('canvas is not specified');
  1578. }
  1579. canvasAndContext.canvas.width = 0;
  1580. canvasAndContext.canvas.height = 0;
  1581. canvasAndContext.canvas = null;
  1582. canvasAndContext.context = null;
  1583. }
  1584. }]);
  1585. return DOMCanvasFactory;
  1586. }();
  1587. var DOMCMapReaderFactory = function () {
  1588. function DOMCMapReaderFactory(_ref) {
  1589. var _ref$baseUrl = _ref.baseUrl,
  1590. baseUrl = _ref$baseUrl === undefined ? null : _ref$baseUrl,
  1591. _ref$isCompressed = _ref.isCompressed,
  1592. isCompressed = _ref$isCompressed === undefined ? false : _ref$isCompressed;
  1593. _classCallCheck(this, DOMCMapReaderFactory);
  1594. this.baseUrl = baseUrl;
  1595. this.isCompressed = isCompressed;
  1596. }
  1597. _createClass(DOMCMapReaderFactory, [{
  1598. key: 'fetch',
  1599. value: function fetch(_ref2) {
  1600. var _this = this;
  1601. var name = _ref2.name;
  1602. if (!name) {
  1603. return Promise.reject(new Error('CMap name must be specified.'));
  1604. }
  1605. return new Promise(function (resolve, reject) {
  1606. var url = _this.baseUrl + name + (_this.isCompressed ? '.bcmap' : '');
  1607. var request = new XMLHttpRequest();
  1608. request.open('GET', url, true);
  1609. if (_this.isCompressed) {
  1610. request.responseType = 'arraybuffer';
  1611. }
  1612. request.onreadystatechange = function () {
  1613. if (request.readyState !== XMLHttpRequest.DONE) {
  1614. return;
  1615. }
  1616. if (request.status === 200 || request.status === 0) {
  1617. var data = void 0;
  1618. if (_this.isCompressed && request.response) {
  1619. data = new Uint8Array(request.response);
  1620. } else if (!_this.isCompressed && request.responseText) {
  1621. data = (0, _util.stringToBytes)(request.responseText);
  1622. }
  1623. if (data) {
  1624. resolve({
  1625. cMapData: data,
  1626. compressionType: _this.isCompressed ? _util.CMapCompressionType.BINARY : _util.CMapCompressionType.NONE
  1627. });
  1628. return;
  1629. }
  1630. }
  1631. reject(new Error('Unable to load ' + (_this.isCompressed ? 'binary ' : '') + 'CMap at: ' + url));
  1632. };
  1633. request.send(null);
  1634. });
  1635. }
  1636. }]);
  1637. return DOMCMapReaderFactory;
  1638. }();
  1639. var CustomStyle = function CustomStyleClosure() {
  1640. var prefixes = ['ms', 'Moz', 'Webkit', 'O'];
  1641. var _cache = Object.create(null);
  1642. function CustomStyle() {}
  1643. CustomStyle.getProp = function get(propName, element) {
  1644. if (arguments.length === 1 && typeof _cache[propName] === 'string') {
  1645. return _cache[propName];
  1646. }
  1647. element = element || document.documentElement;
  1648. var style = element.style,
  1649. prefixed,
  1650. uPropName;
  1651. if (typeof style[propName] === 'string') {
  1652. return _cache[propName] = propName;
  1653. }
  1654. uPropName = propName.charAt(0).toUpperCase() + propName.slice(1);
  1655. for (var i = 0, l = prefixes.length; i < l; i++) {
  1656. prefixed = prefixes[i] + uPropName;
  1657. if (typeof style[prefixed] === 'string') {
  1658. return _cache[propName] = prefixed;
  1659. }
  1660. }
  1661. return _cache[propName] = 'undefined';
  1662. };
  1663. CustomStyle.setProp = function set(propName, element, str) {
  1664. var prop = this.getProp(propName);
  1665. if (prop !== 'undefined') {
  1666. element.style[prop] = str;
  1667. }
  1668. };
  1669. return CustomStyle;
  1670. }();
  1671. var RenderingCancelledException = function RenderingCancelledException() {
  1672. function RenderingCancelledException(msg, type) {
  1673. this.message = msg;
  1674. this.type = type;
  1675. }
  1676. RenderingCancelledException.prototype = new Error();
  1677. RenderingCancelledException.prototype.name = 'RenderingCancelledException';
  1678. RenderingCancelledException.constructor = RenderingCancelledException;
  1679. return RenderingCancelledException;
  1680. }();
  1681. var LinkTarget = {
  1682. NONE: 0,
  1683. SELF: 1,
  1684. BLANK: 2,
  1685. PARENT: 3,
  1686. TOP: 4
  1687. };
  1688. var LinkTargetStringMap = ['', '_self', '_blank', '_parent', '_top'];
  1689. function addLinkAttributes(link, params) {
  1690. var url = params && params.url;
  1691. link.href = link.title = url ? (0, _util.removeNullCharacters)(url) : '';
  1692. if (url) {
  1693. var target = params.target;
  1694. if (typeof target === 'undefined') {
  1695. target = getDefaultSetting('externalLinkTarget');
  1696. }
  1697. link.target = LinkTargetStringMap[target];
  1698. var rel = params.rel;
  1699. if (typeof rel === 'undefined') {
  1700. rel = getDefaultSetting('externalLinkRel');
  1701. }
  1702. link.rel = rel;
  1703. }
  1704. }
  1705. function getFilenameFromUrl(url) {
  1706. var anchor = url.indexOf('#');
  1707. var query = url.indexOf('?');
  1708. var end = Math.min(anchor > 0 ? anchor : url.length, query > 0 ? query : url.length);
  1709. return url.substring(url.lastIndexOf('/', end) + 1, end);
  1710. }
  1711. function getDefaultSetting(id) {
  1712. var globalSettings = _global_scope2.default.PDFJS;
  1713. switch (id) {
  1714. case 'pdfBug':
  1715. return globalSettings ? globalSettings.pdfBug : false;
  1716. case 'disableAutoFetch':
  1717. return globalSettings ? globalSettings.disableAutoFetch : false;
  1718. case 'disableStream':
  1719. return globalSettings ? globalSettings.disableStream : false;
  1720. case 'disableRange':
  1721. return globalSettings ? globalSettings.disableRange : false;
  1722. case 'disableFontFace':
  1723. return globalSettings ? globalSettings.disableFontFace : false;
  1724. case 'disableCreateObjectURL':
  1725. return globalSettings ? globalSettings.disableCreateObjectURL : false;
  1726. case 'disableWebGL':
  1727. return globalSettings ? globalSettings.disableWebGL : true;
  1728. case 'cMapUrl':
  1729. return globalSettings ? globalSettings.cMapUrl : null;
  1730. case 'cMapPacked':
  1731. return globalSettings ? globalSettings.cMapPacked : false;
  1732. case 'postMessageTransfers':
  1733. return globalSettings ? globalSettings.postMessageTransfers : true;
  1734. case 'workerPort':
  1735. return globalSettings ? globalSettings.workerPort : null;
  1736. case 'workerSrc':
  1737. return globalSettings ? globalSettings.workerSrc : null;
  1738. case 'disableWorker':
  1739. return globalSettings ? globalSettings.disableWorker : false;
  1740. case 'maxImageSize':
  1741. return globalSettings ? globalSettings.maxImageSize : -1;
  1742. case 'imageResourcesPath':
  1743. return globalSettings ? globalSettings.imageResourcesPath : '';
  1744. case 'isEvalSupported':
  1745. return globalSettings ? globalSettings.isEvalSupported : true;
  1746. case 'externalLinkTarget':
  1747. if (!globalSettings) {
  1748. return LinkTarget.NONE;
  1749. }
  1750. switch (globalSettings.externalLinkTarget) {
  1751. case LinkTarget.NONE:
  1752. case LinkTarget.SELF:
  1753. case LinkTarget.BLANK:
  1754. case LinkTarget.PARENT:
  1755. case LinkTarget.TOP:
  1756. return globalSettings.externalLinkTarget;
  1757. }
  1758. (0, _util.warn)('PDFJS.externalLinkTarget is invalid: ' + globalSettings.externalLinkTarget);
  1759. globalSettings.externalLinkTarget = LinkTarget.NONE;
  1760. return LinkTarget.NONE;
  1761. case 'externalLinkRel':
  1762. return globalSettings ? globalSettings.externalLinkRel : DEFAULT_LINK_REL;
  1763. case 'enableStats':
  1764. return !!(globalSettings && globalSettings.enableStats);
  1765. case 'pdfjsNext':
  1766. return !!(globalSettings && globalSettings.pdfjsNext);
  1767. default:
  1768. throw new Error('Unknown default setting: ' + id);
  1769. }
  1770. }
  1771. function isExternalLinkTargetSet() {
  1772. var externalLinkTarget = getDefaultSetting('externalLinkTarget');
  1773. switch (externalLinkTarget) {
  1774. case LinkTarget.NONE:
  1775. return false;
  1776. case LinkTarget.SELF:
  1777. case LinkTarget.BLANK:
  1778. case LinkTarget.PARENT:
  1779. case LinkTarget.TOP:
  1780. return true;
  1781. }
  1782. }
  1783. function isValidUrl(url, allowRelative) {
  1784. (0, _util.deprecated)('isValidUrl(), please use createValidAbsoluteUrl() instead.');
  1785. var baseUrl = allowRelative ? 'http://example.com' : null;
  1786. return (0, _util.createValidAbsoluteUrl)(url, baseUrl) !== null;
  1787. }
  1788. exports.CustomStyle = CustomStyle;
  1789. exports.RenderingCancelledException = RenderingCancelledException;
  1790. exports.addLinkAttributes = addLinkAttributes;
  1791. exports.isExternalLinkTargetSet = isExternalLinkTargetSet;
  1792. exports.isValidUrl = isValidUrl;
  1793. exports.getFilenameFromUrl = getFilenameFromUrl;
  1794. exports.LinkTarget = LinkTarget;
  1795. exports.getDefaultSetting = getDefaultSetting;
  1796. exports.DEFAULT_LINK_REL = DEFAULT_LINK_REL;
  1797. exports.DOMCanvasFactory = DOMCanvasFactory;
  1798. exports.DOMCMapReaderFactory = DOMCMapReaderFactory;
  1799. /***/ }),
  1800. /* 8 */
  1801. /***/ (function(module, exports, __w_pdfjs_require__) {
  1802. "use strict";
  1803. var anObject = __w_pdfjs_require__(15);
  1804. var IE8_DOM_DEFINE = __w_pdfjs_require__(41);
  1805. var toPrimitive = __w_pdfjs_require__(28);
  1806. var dP = Object.defineProperty;
  1807. exports.f = __w_pdfjs_require__(3) ? Object.defineProperty : function defineProperty(O, P, Attributes) {
  1808. anObject(O);
  1809. P = toPrimitive(P, true);
  1810. anObject(Attributes);
  1811. if (IE8_DOM_DEFINE) try {
  1812. return dP(O, P, Attributes);
  1813. } catch (e) {}
  1814. if ('get' in Attributes || 'set' in Attributes) throw TypeError('Accessors not supported!');
  1815. if ('value' in Attributes) O[P] = Attributes.value;
  1816. return O;
  1817. };
  1818. /***/ }),
  1819. /* 9 */
  1820. /***/ (function(module, exports, __w_pdfjs_require__) {
  1821. "use strict";
  1822. 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; };
  1823. module.exports = function (it) {
  1824. return (typeof it === 'undefined' ? 'undefined' : _typeof(it)) === 'object' ? it !== null : typeof it === 'function';
  1825. };
  1826. /***/ }),
  1827. /* 10 */
  1828. /***/ (function(module, exports, __w_pdfjs_require__) {
  1829. "use strict";
  1830. module.exports = {};
  1831. /***/ }),
  1832. /* 11 */
  1833. /***/ (function(module, exports, __w_pdfjs_require__) {
  1834. "use strict";
  1835. var ceil = Math.ceil;
  1836. var floor = Math.floor;
  1837. module.exports = function (it) {
  1838. return isNaN(it = +it) ? 0 : (it > 0 ? floor : ceil)(it);
  1839. };
  1840. /***/ }),
  1841. /* 12 */
  1842. /***/ (function(module, exports, __w_pdfjs_require__) {
  1843. "use strict";
  1844. var defined = __w_pdfjs_require__(38);
  1845. module.exports = function (it) {
  1846. return Object(defined(it));
  1847. };
  1848. /***/ }),
  1849. /* 13 */
  1850. /***/ (function(module, exports, __w_pdfjs_require__) {
  1851. "use strict";
  1852. var id = 0;
  1853. var px = Math.random();
  1854. module.exports = function (key) {
  1855. return 'Symbol('.concat(key === undefined ? '' : key, ')_', (++id + px).toString(36));
  1856. };
  1857. /***/ }),
  1858. /* 14 */
  1859. /***/ (function(module, exports, __w_pdfjs_require__) {
  1860. "use strict";
  1861. module.exports = typeof window !== 'undefined' && window.Math === Math ? window : typeof global !== 'undefined' && global.Math === Math ? global : typeof self !== 'undefined' && self.Math === Math ? self : {};
  1862. /***/ }),
  1863. /* 15 */
  1864. /***/ (function(module, exports, __w_pdfjs_require__) {
  1865. "use strict";
  1866. var isObject = __w_pdfjs_require__(9);
  1867. module.exports = function (it) {
  1868. if (!isObject(it)) throw TypeError(it + ' is not an object!');
  1869. return it;
  1870. };
  1871. /***/ }),
  1872. /* 16 */
  1873. /***/ (function(module, exports, __w_pdfjs_require__) {
  1874. "use strict";
  1875. var core = module.exports = { version: '2.5.0' };
  1876. if (typeof __e == 'number') __e = core;
  1877. /***/ }),
  1878. /* 17 */
  1879. /***/ (function(module, exports, __w_pdfjs_require__) {
  1880. "use strict";
  1881. module.exports = function (exec) {
  1882. try {
  1883. return !!exec();
  1884. } catch (e) {
  1885. return true;
  1886. }
  1887. };
  1888. /***/ }),
  1889. /* 18 */
  1890. /***/ (function(module, exports, __w_pdfjs_require__) {
  1891. "use strict";
  1892. module.exports = function (bitmap, value) {
  1893. return {
  1894. enumerable: !(bitmap & 1),
  1895. configurable: !(bitmap & 2),
  1896. writable: !(bitmap & 4),
  1897. value: value
  1898. };
  1899. };
  1900. /***/ }),
  1901. /* 19 */
  1902. /***/ (function(module, exports, __w_pdfjs_require__) {
  1903. "use strict";
  1904. var toInteger = __w_pdfjs_require__(11);
  1905. var max = Math.max;
  1906. var min = Math.min;
  1907. module.exports = function (index, length) {
  1908. index = toInteger(index);
  1909. return index < 0 ? max(index + length, 0) : min(index, length);
  1910. };
  1911. /***/ }),
  1912. /* 20 */
  1913. /***/ (function(module, exports, __w_pdfjs_require__) {
  1914. "use strict";
  1915. var IObject = __w_pdfjs_require__(42);
  1916. var defined = __w_pdfjs_require__(38);
  1917. module.exports = function (it) {
  1918. return IObject(defined(it));
  1919. };
  1920. /***/ }),
  1921. /* 21 */
  1922. /***/ (function(module, exports, __w_pdfjs_require__) {
  1923. "use strict";
  1924. var toString = {}.toString;
  1925. module.exports = function (it) {
  1926. return toString.call(it).slice(8, -1);
  1927. };
  1928. /***/ }),
  1929. /* 22 */
  1930. /***/ (function(module, exports, __w_pdfjs_require__) {
  1931. "use strict";
  1932. var aFunction = __w_pdfjs_require__(33);
  1933. module.exports = function (fn, that, length) {
  1934. aFunction(fn);
  1935. if (that === undefined) return fn;
  1936. switch (length) {
  1937. case 1:
  1938. return function (a) {
  1939. return fn.call(that, a);
  1940. };
  1941. case 2:
  1942. return function (a, b) {
  1943. return fn.call(that, a, b);
  1944. };
  1945. case 3:
  1946. return function (a, b, c) {
  1947. return fn.call(that, a, b, c);
  1948. };
  1949. }
  1950. return function () {
  1951. return fn.apply(that, arguments);
  1952. };
  1953. };
  1954. /***/ }),
  1955. /* 23 */
  1956. /***/ (function(module, exports, __w_pdfjs_require__) {
  1957. "use strict";
  1958. module.exports = 'constructor,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,toLocaleString,toString,valueOf'.split(',');
  1959. /***/ }),
  1960. /* 24 */
  1961. /***/ (function(module, exports, __w_pdfjs_require__) {
  1962. "use strict";
  1963. module.exports = false;
  1964. /***/ }),
  1965. /* 25 */
  1966. /***/ (function(module, exports, __w_pdfjs_require__) {
  1967. "use strict";
  1968. var global = __w_pdfjs_require__(2);
  1969. var hide = __w_pdfjs_require__(4);
  1970. var has = __w_pdfjs_require__(5);
  1971. var SRC = __w_pdfjs_require__(13)('src');
  1972. var TO_STRING = 'toString';
  1973. var $toString = Function[TO_STRING];
  1974. var TPL = ('' + $toString).split(TO_STRING);
  1975. __w_pdfjs_require__(16).inspectSource = function (it) {
  1976. return $toString.call(it);
  1977. };
  1978. (module.exports = function (O, key, val, safe) {
  1979. var isFunction = typeof val == 'function';
  1980. if (isFunction) has(val, 'name') || hide(val, 'name', key);
  1981. if (O[key] === val) return;
  1982. if (isFunction) has(val, SRC) || hide(val, SRC, O[key] ? '' + O[key] : TPL.join(String(key)));
  1983. if (O === global) {
  1984. O[key] = val;
  1985. } else if (!safe) {
  1986. delete O[key];
  1987. hide(O, key, val);
  1988. } else if (O[key]) {
  1989. O[key] = val;
  1990. } else {
  1991. hide(O, key, val);
  1992. }
  1993. })(Function.prototype, TO_STRING, function toString() {
  1994. return typeof this == 'function' && this[SRC] || $toString.call(this);
  1995. });
  1996. /***/ }),
  1997. /* 26 */
  1998. /***/ (function(module, exports, __w_pdfjs_require__) {
  1999. "use strict";
  2000. var def = __w_pdfjs_require__(8).f;
  2001. var has = __w_pdfjs_require__(5);
  2002. var TAG = __w_pdfjs_require__(1)('toStringTag');
  2003. module.exports = function (it, tag, stat) {
  2004. if (it && !has(it = stat ? it : it.prototype, TAG)) def(it, TAG, {
  2005. configurable: true,
  2006. value: tag
  2007. });
  2008. };
  2009. /***/ }),
  2010. /* 27 */
  2011. /***/ (function(module, exports, __w_pdfjs_require__) {
  2012. "use strict";
  2013. var shared = __w_pdfjs_require__(48)('keys');
  2014. var uid = __w_pdfjs_require__(13);
  2015. module.exports = function (key) {
  2016. return shared[key] || (shared[key] = uid(key));
  2017. };
  2018. /***/ }),
  2019. /* 28 */
  2020. /***/ (function(module, exports, __w_pdfjs_require__) {
  2021. "use strict";
  2022. var isObject = __w_pdfjs_require__(9);
  2023. module.exports = function (it, S) {
  2024. if (!isObject(it)) return it;
  2025. var fn, val;
  2026. if (S && typeof (fn = it.toString) == 'function' && !isObject(val = fn.call(it))) return val;
  2027. if (typeof (fn = it.valueOf) == 'function' && !isObject(val = fn.call(it))) return val;
  2028. if (!S && typeof (fn = it.toString) == 'function' && !isObject(val = fn.call(it))) return val;
  2029. throw TypeError("Can't convert object to primitive value");
  2030. };
  2031. /***/ }),
  2032. /* 29 */
  2033. /***/ (function(module, exports, __w_pdfjs_require__) {
  2034. "use strict";
  2035. Object.defineProperty(exports, "__esModule", {
  2036. value: true
  2037. });
  2038. exports.AnnotationLayer = undefined;
  2039. var _dom_utils = __w_pdfjs_require__(7);
  2040. var _util = __w_pdfjs_require__(0);
  2041. function AnnotationElementFactory() {}
  2042. AnnotationElementFactory.prototype = {
  2043. create: function AnnotationElementFactory_create(parameters) {
  2044. var subtype = parameters.data.annotationType;
  2045. switch (subtype) {
  2046. case _util.AnnotationType.LINK:
  2047. return new LinkAnnotationElement(parameters);
  2048. case _util.AnnotationType.TEXT:
  2049. return new TextAnnotationElement(parameters);
  2050. case _util.AnnotationType.WIDGET:
  2051. var fieldType = parameters.data.fieldType;
  2052. switch (fieldType) {
  2053. case 'Tx':
  2054. return new TextWidgetAnnotationElement(parameters);
  2055. case 'Btn':
  2056. if (parameters.data.radioButton) {
  2057. return new RadioButtonWidgetAnnotationElement(parameters);
  2058. } else if (parameters.data.checkBox) {
  2059. return new CheckboxWidgetAnnotationElement(parameters);
  2060. }
  2061. (0, _util.warn)('Unimplemented button widget annotation: pushbutton');
  2062. break;
  2063. case 'Ch':
  2064. return new ChoiceWidgetAnnotationElement(parameters);
  2065. }
  2066. return new WidgetAnnotationElement(parameters);
  2067. case _util.AnnotationType.POPUP:
  2068. return new PopupAnnotationElement(parameters);
  2069. case _util.AnnotationType.LINE:
  2070. return new LineAnnotationElement(parameters);
  2071. case _util.AnnotationType.HIGHLIGHT:
  2072. return new HighlightAnnotationElement(parameters);
  2073. case _util.AnnotationType.UNDERLINE:
  2074. return new UnderlineAnnotationElement(parameters);
  2075. case _util.AnnotationType.SQUIGGLY:
  2076. return new SquigglyAnnotationElement(parameters);
  2077. case _util.AnnotationType.STRIKEOUT:
  2078. return new StrikeOutAnnotationElement(parameters);
  2079. case _util.AnnotationType.FILEATTACHMENT:
  2080. return new FileAttachmentAnnotationElement(parameters);
  2081. default:
  2082. return new AnnotationElement(parameters);
  2083. }
  2084. }
  2085. };
  2086. var AnnotationElement = function AnnotationElementClosure() {
  2087. function AnnotationElement(parameters, isRenderable, ignoreBorder) {
  2088. this.isRenderable = isRenderable || false;
  2089. this.data = parameters.data;
  2090. this.layer = parameters.layer;
  2091. this.page = parameters.page;
  2092. this.viewport = parameters.viewport;
  2093. this.linkService = parameters.linkService;
  2094. this.downloadManager = parameters.downloadManager;
  2095. this.imageResourcesPath = parameters.imageResourcesPath;
  2096. this.renderInteractiveForms = parameters.renderInteractiveForms;
  2097. if (isRenderable) {
  2098. this.container = this._createContainer(ignoreBorder);
  2099. }
  2100. }
  2101. AnnotationElement.prototype = {
  2102. _createContainer: function AnnotationElement_createContainer(ignoreBorder) {
  2103. var data = this.data,
  2104. page = this.page,
  2105. viewport = this.viewport;
  2106. var container = document.createElement('section');
  2107. var width = data.rect[2] - data.rect[0];
  2108. var height = data.rect[3] - data.rect[1];
  2109. container.setAttribute('data-annotation-id', data.id);
  2110. var rect = _util.Util.normalizeRect([data.rect[0], page.view[3] - data.rect[1] + page.view[1], data.rect[2], page.view[3] - data.rect[3] + page.view[1]]);
  2111. _dom_utils.CustomStyle.setProp('transform', container, 'matrix(' + viewport.transform.join(',') + ')');
  2112. _dom_utils.CustomStyle.setProp('transformOrigin', container, -rect[0] + 'px ' + -rect[1] + 'px');
  2113. if (!ignoreBorder && data.borderStyle.width > 0) {
  2114. container.style.borderWidth = data.borderStyle.width + 'px';
  2115. if (data.borderStyle.style !== _util.AnnotationBorderStyleType.UNDERLINE) {
  2116. width = width - 2 * data.borderStyle.width;
  2117. height = height - 2 * data.borderStyle.width;
  2118. }
  2119. var horizontalRadius = data.borderStyle.horizontalCornerRadius;
  2120. var verticalRadius = data.borderStyle.verticalCornerRadius;
  2121. if (horizontalRadius > 0 || verticalRadius > 0) {
  2122. var radius = horizontalRadius + 'px / ' + verticalRadius + 'px';
  2123. _dom_utils.CustomStyle.setProp('borderRadius', container, radius);
  2124. }
  2125. switch (data.borderStyle.style) {
  2126. case _util.AnnotationBorderStyleType.SOLID:
  2127. container.style.borderStyle = 'solid';
  2128. break;
  2129. case _util.AnnotationBorderStyleType.DASHED:
  2130. container.style.borderStyle = 'dashed';
  2131. break;
  2132. case _util.AnnotationBorderStyleType.BEVELED:
  2133. (0, _util.warn)('Unimplemented border style: beveled');
  2134. break;
  2135. case _util.AnnotationBorderStyleType.INSET:
  2136. (0, _util.warn)('Unimplemented border style: inset');
  2137. break;
  2138. case _util.AnnotationBorderStyleType.UNDERLINE:
  2139. container.style.borderBottomStyle = 'solid';
  2140. break;
  2141. default:
  2142. break;
  2143. }
  2144. if (data.color) {
  2145. container.style.borderColor = _util.Util.makeCssRgb(data.color[0] | 0, data.color[1] | 0, data.color[2] | 0);
  2146. } else {
  2147. container.style.borderWidth = 0;
  2148. }
  2149. }
  2150. container.style.left = rect[0] + 'px';
  2151. container.style.top = rect[1] + 'px';
  2152. container.style.width = width + 'px';
  2153. container.style.height = height + 'px';
  2154. return container;
  2155. },
  2156. _createPopup: function AnnotationElement_createPopup(container, trigger, data) {
  2157. if (!trigger) {
  2158. trigger = document.createElement('div');
  2159. trigger.style.height = container.style.height;
  2160. trigger.style.width = container.style.width;
  2161. container.appendChild(trigger);
  2162. }
  2163. var popupElement = new PopupElement({
  2164. container: container,
  2165. trigger: trigger,
  2166. color: data.color,
  2167. title: data.title,
  2168. contents: data.contents,
  2169. hideWrapper: true
  2170. });
  2171. var popup = popupElement.render();
  2172. popup.style.left = container.style.width;
  2173. container.appendChild(popup);
  2174. },
  2175. render: function AnnotationElement_render() {
  2176. throw new Error('Abstract method AnnotationElement.render called');
  2177. }
  2178. };
  2179. return AnnotationElement;
  2180. }();
  2181. var LinkAnnotationElement = function LinkAnnotationElementClosure() {
  2182. function LinkAnnotationElement(parameters) {
  2183. AnnotationElement.call(this, parameters, true);
  2184. }
  2185. _util.Util.inherit(LinkAnnotationElement, AnnotationElement, {
  2186. render: function LinkAnnotationElement_render() {
  2187. this.container.className = 'linkAnnotation';
  2188. var link = document.createElement('a');
  2189. (0, _dom_utils.addLinkAttributes)(link, {
  2190. url: this.data.url,
  2191. target: this.data.newWindow ? _dom_utils.LinkTarget.BLANK : undefined
  2192. });
  2193. if (!this.data.url) {
  2194. if (this.data.action) {
  2195. this._bindNamedAction(link, this.data.action);
  2196. } else {
  2197. this._bindLink(link, this.data.dest);
  2198. }
  2199. }
  2200. this.container.appendChild(link);
  2201. return this.container;
  2202. },
  2203. _bindLink: function _bindLink(link, destination) {
  2204. var _this = this;
  2205. link.href = this.linkService.getDestinationHash(destination);
  2206. link.onclick = function () {
  2207. if (destination) {
  2208. _this.linkService.navigateTo(destination);
  2209. }
  2210. return false;
  2211. };
  2212. if (destination) {
  2213. link.className = 'internalLink';
  2214. }
  2215. },
  2216. _bindNamedAction: function _bindNamedAction(link, action) {
  2217. var _this2 = this;
  2218. link.href = this.linkService.getAnchorUrl('');
  2219. link.onclick = function () {
  2220. _this2.linkService.executeNamedAction(action);
  2221. return false;
  2222. };
  2223. link.className = 'internalLink';
  2224. }
  2225. });
  2226. return LinkAnnotationElement;
  2227. }();
  2228. var TextAnnotationElement = function TextAnnotationElementClosure() {
  2229. function TextAnnotationElement(parameters) {
  2230. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  2231. AnnotationElement.call(this, parameters, isRenderable);
  2232. }
  2233. _util.Util.inherit(TextAnnotationElement, AnnotationElement, {
  2234. render: function TextAnnotationElement_render() {
  2235. this.container.className = 'textAnnotation';
  2236. var image = document.createElement('img');
  2237. image.style.height = this.container.style.height;
  2238. image.style.width = this.container.style.width;
  2239. image.src = this.imageResourcesPath + 'annotation-' + this.data.name.toLowerCase() + '.svg';
  2240. image.alt = '[{{type}} Annotation]';
  2241. image.dataset.l10nId = 'text_annotation_type';
  2242. image.dataset.l10nArgs = JSON.stringify({ type: this.data.name });
  2243. if (!this.data.hasPopup) {
  2244. this._createPopup(this.container, image, this.data);
  2245. }
  2246. this.container.appendChild(image);
  2247. return this.container;
  2248. }
  2249. });
  2250. return TextAnnotationElement;
  2251. }();
  2252. var WidgetAnnotationElement = function WidgetAnnotationElementClosure() {
  2253. function WidgetAnnotationElement(parameters, isRenderable) {
  2254. AnnotationElement.call(this, parameters, isRenderable);
  2255. }
  2256. _util.Util.inherit(WidgetAnnotationElement, AnnotationElement, {
  2257. render: function WidgetAnnotationElement_render() {
  2258. return this.container;
  2259. }
  2260. });
  2261. return WidgetAnnotationElement;
  2262. }();
  2263. var TextWidgetAnnotationElement = function TextWidgetAnnotationElementClosure() {
  2264. var TEXT_ALIGNMENT = ['left', 'center', 'right'];
  2265. function TextWidgetAnnotationElement(parameters) {
  2266. var isRenderable = parameters.renderInteractiveForms || !parameters.data.hasAppearance && !!parameters.data.fieldValue;
  2267. WidgetAnnotationElement.call(this, parameters, isRenderable);
  2268. }
  2269. _util.Util.inherit(TextWidgetAnnotationElement, WidgetAnnotationElement, {
  2270. render: function TextWidgetAnnotationElement_render() {
  2271. this.container.className = 'textWidgetAnnotation';
  2272. var element = null;
  2273. if (this.renderInteractiveForms) {
  2274. if (this.data.multiLine) {
  2275. element = document.createElement('textarea');
  2276. element.textContent = this.data.fieldValue;
  2277. } else {
  2278. element = document.createElement('input');
  2279. element.type = 'text';
  2280. element.setAttribute('value', this.data.fieldValue);
  2281. }
  2282. element.disabled = this.data.readOnly;
  2283. if (this.data.maxLen !== null) {
  2284. element.maxLength = this.data.maxLen;
  2285. }
  2286. if (this.data.comb) {
  2287. var fieldWidth = this.data.rect[2] - this.data.rect[0];
  2288. var combWidth = fieldWidth / this.data.maxLen;
  2289. element.classList.add('comb');
  2290. element.style.letterSpacing = 'calc(' + combWidth + 'px - 1ch)';
  2291. }
  2292. } else {
  2293. element = document.createElement('div');
  2294. element.textContent = this.data.fieldValue;
  2295. element.style.verticalAlign = 'middle';
  2296. element.style.display = 'table-cell';
  2297. var font = null;
  2298. if (this.data.fontRefName) {
  2299. font = this.page.commonObjs.getData(this.data.fontRefName);
  2300. }
  2301. this._setTextStyle(element, font);
  2302. }
  2303. if (this.data.textAlignment !== null) {
  2304. element.style.textAlign = TEXT_ALIGNMENT[this.data.textAlignment];
  2305. }
  2306. this.container.appendChild(element);
  2307. return this.container;
  2308. },
  2309. _setTextStyle: function TextWidgetAnnotationElement_setTextStyle(element, font) {
  2310. var style = element.style;
  2311. style.fontSize = this.data.fontSize + 'px';
  2312. style.direction = this.data.fontDirection < 0 ? 'rtl' : 'ltr';
  2313. if (!font) {
  2314. return;
  2315. }
  2316. style.fontWeight = font.black ? font.bold ? '900' : 'bold' : font.bold ? 'bold' : 'normal';
  2317. style.fontStyle = font.italic ? 'italic' : 'normal';
  2318. var fontFamily = font.loadedName ? '"' + font.loadedName + '", ' : '';
  2319. var fallbackName = font.fallbackName || 'Helvetica, sans-serif';
  2320. style.fontFamily = fontFamily + fallbackName;
  2321. }
  2322. });
  2323. return TextWidgetAnnotationElement;
  2324. }();
  2325. var CheckboxWidgetAnnotationElement = function CheckboxWidgetAnnotationElementClosure() {
  2326. function CheckboxWidgetAnnotationElement(parameters) {
  2327. WidgetAnnotationElement.call(this, parameters, parameters.renderInteractiveForms);
  2328. }
  2329. _util.Util.inherit(CheckboxWidgetAnnotationElement, WidgetAnnotationElement, {
  2330. render: function CheckboxWidgetAnnotationElement_render() {
  2331. this.container.className = 'buttonWidgetAnnotation checkBox';
  2332. var element = document.createElement('input');
  2333. element.disabled = this.data.readOnly;
  2334. element.type = 'checkbox';
  2335. if (this.data.fieldValue && this.data.fieldValue !== 'Off') {
  2336. element.setAttribute('checked', true);
  2337. }
  2338. this.container.appendChild(element);
  2339. return this.container;
  2340. }
  2341. });
  2342. return CheckboxWidgetAnnotationElement;
  2343. }();
  2344. var RadioButtonWidgetAnnotationElement = function RadioButtonWidgetAnnotationElementClosure() {
  2345. function RadioButtonWidgetAnnotationElement(parameters) {
  2346. WidgetAnnotationElement.call(this, parameters, parameters.renderInteractiveForms);
  2347. }
  2348. _util.Util.inherit(RadioButtonWidgetAnnotationElement, WidgetAnnotationElement, {
  2349. render: function RadioButtonWidgetAnnotationElement_render() {
  2350. this.container.className = 'buttonWidgetAnnotation radioButton';
  2351. var element = document.createElement('input');
  2352. element.disabled = this.data.readOnly;
  2353. element.type = 'radio';
  2354. element.name = this.data.fieldName;
  2355. if (this.data.fieldValue === this.data.buttonValue) {
  2356. element.setAttribute('checked', true);
  2357. }
  2358. this.container.appendChild(element);
  2359. return this.container;
  2360. }
  2361. });
  2362. return RadioButtonWidgetAnnotationElement;
  2363. }();
  2364. var ChoiceWidgetAnnotationElement = function ChoiceWidgetAnnotationElementClosure() {
  2365. function ChoiceWidgetAnnotationElement(parameters) {
  2366. WidgetAnnotationElement.call(this, parameters, parameters.renderInteractiveForms);
  2367. }
  2368. _util.Util.inherit(ChoiceWidgetAnnotationElement, WidgetAnnotationElement, {
  2369. render: function ChoiceWidgetAnnotationElement_render() {
  2370. this.container.className = 'choiceWidgetAnnotation';
  2371. var selectElement = document.createElement('select');
  2372. selectElement.disabled = this.data.readOnly;
  2373. if (!this.data.combo) {
  2374. selectElement.size = this.data.options.length;
  2375. if (this.data.multiSelect) {
  2376. selectElement.multiple = true;
  2377. }
  2378. }
  2379. for (var i = 0, ii = this.data.options.length; i < ii; i++) {
  2380. var option = this.data.options[i];
  2381. var optionElement = document.createElement('option');
  2382. optionElement.textContent = option.displayValue;
  2383. optionElement.value = option.exportValue;
  2384. if (this.data.fieldValue.indexOf(option.displayValue) >= 0) {
  2385. optionElement.setAttribute('selected', true);
  2386. }
  2387. selectElement.appendChild(optionElement);
  2388. }
  2389. this.container.appendChild(selectElement);
  2390. return this.container;
  2391. }
  2392. });
  2393. return ChoiceWidgetAnnotationElement;
  2394. }();
  2395. var PopupAnnotationElement = function PopupAnnotationElementClosure() {
  2396. var IGNORE_TYPES = ['Line'];
  2397. function PopupAnnotationElement(parameters) {
  2398. var isRenderable = !!(parameters.data.title || parameters.data.contents);
  2399. AnnotationElement.call(this, parameters, isRenderable);
  2400. }
  2401. _util.Util.inherit(PopupAnnotationElement, AnnotationElement, {
  2402. render: function PopupAnnotationElement_render() {
  2403. this.container.className = 'popupAnnotation';
  2404. if (IGNORE_TYPES.indexOf(this.data.parentType) >= 0) {
  2405. return this.container;
  2406. }
  2407. var selector = '[data-annotation-id="' + this.data.parentId + '"]';
  2408. var parentElement = this.layer.querySelector(selector);
  2409. if (!parentElement) {
  2410. return this.container;
  2411. }
  2412. var popup = new PopupElement({
  2413. container: this.container,
  2414. trigger: parentElement,
  2415. color: this.data.color,
  2416. title: this.data.title,
  2417. contents: this.data.contents
  2418. });
  2419. var parentLeft = parseFloat(parentElement.style.left);
  2420. var parentWidth = parseFloat(parentElement.style.width);
  2421. _dom_utils.CustomStyle.setProp('transformOrigin', this.container, -(parentLeft + parentWidth) + 'px -' + parentElement.style.top);
  2422. this.container.style.left = parentLeft + parentWidth + 'px';
  2423. this.container.appendChild(popup.render());
  2424. return this.container;
  2425. }
  2426. });
  2427. return PopupAnnotationElement;
  2428. }();
  2429. var PopupElement = function PopupElementClosure() {
  2430. var BACKGROUND_ENLIGHT = 0.7;
  2431. function PopupElement(parameters) {
  2432. this.container = parameters.container;
  2433. this.trigger = parameters.trigger;
  2434. this.color = parameters.color;
  2435. this.title = parameters.title;
  2436. this.contents = parameters.contents;
  2437. this.hideWrapper = parameters.hideWrapper || false;
  2438. this.pinned = false;
  2439. }
  2440. PopupElement.prototype = {
  2441. render: function PopupElement_render() {
  2442. var wrapper = document.createElement('div');
  2443. wrapper.className = 'popupWrapper';
  2444. this.hideElement = this.hideWrapper ? wrapper : this.container;
  2445. this.hideElement.setAttribute('hidden', true);
  2446. var popup = document.createElement('div');
  2447. popup.className = 'popup';
  2448. var color = this.color;
  2449. if (color) {
  2450. var r = BACKGROUND_ENLIGHT * (255 - color[0]) + color[0];
  2451. var g = BACKGROUND_ENLIGHT * (255 - color[1]) + color[1];
  2452. var b = BACKGROUND_ENLIGHT * (255 - color[2]) + color[2];
  2453. popup.style.backgroundColor = _util.Util.makeCssRgb(r | 0, g | 0, b | 0);
  2454. }
  2455. var contents = this._formatContents(this.contents);
  2456. var title = document.createElement('h1');
  2457. title.textContent = this.title;
  2458. this.trigger.addEventListener('click', this._toggle.bind(this));
  2459. this.trigger.addEventListener('mouseover', this._show.bind(this, false));
  2460. this.trigger.addEventListener('mouseout', this._hide.bind(this, false));
  2461. popup.addEventListener('click', this._hide.bind(this, true));
  2462. popup.appendChild(title);
  2463. popup.appendChild(contents);
  2464. wrapper.appendChild(popup);
  2465. return wrapper;
  2466. },
  2467. _formatContents: function PopupElement_formatContents(contents) {
  2468. var p = document.createElement('p');
  2469. var lines = contents.split(/(?:\r\n?|\n)/);
  2470. for (var i = 0, ii = lines.length; i < ii; ++i) {
  2471. var line = lines[i];
  2472. p.appendChild(document.createTextNode(line));
  2473. if (i < ii - 1) {
  2474. p.appendChild(document.createElement('br'));
  2475. }
  2476. }
  2477. return p;
  2478. },
  2479. _toggle: function PopupElement_toggle() {
  2480. if (this.pinned) {
  2481. this._hide(true);
  2482. } else {
  2483. this._show(true);
  2484. }
  2485. },
  2486. _show: function PopupElement_show(pin) {
  2487. if (pin) {
  2488. this.pinned = true;
  2489. }
  2490. if (this.hideElement.hasAttribute('hidden')) {
  2491. this.hideElement.removeAttribute('hidden');
  2492. this.container.style.zIndex += 1;
  2493. }
  2494. },
  2495. _hide: function PopupElement_hide(unpin) {
  2496. if (unpin) {
  2497. this.pinned = false;
  2498. }
  2499. if (!this.hideElement.hasAttribute('hidden') && !this.pinned) {
  2500. this.hideElement.setAttribute('hidden', true);
  2501. this.container.style.zIndex -= 1;
  2502. }
  2503. }
  2504. };
  2505. return PopupElement;
  2506. }();
  2507. var LineAnnotationElement = function LineAnnotationElementClosure() {
  2508. var SVG_NS = 'http://www.w3.org/2000/svg';
  2509. function LineAnnotationElement(parameters) {
  2510. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  2511. AnnotationElement.call(this, parameters, isRenderable, true);
  2512. }
  2513. _util.Util.inherit(LineAnnotationElement, AnnotationElement, {
  2514. render: function LineAnnotationElement_render() {
  2515. this.container.className = 'lineAnnotation';
  2516. var data = this.data;
  2517. var width = data.rect[2] - data.rect[0];
  2518. var height = data.rect[3] - data.rect[1];
  2519. var svg = document.createElementNS(SVG_NS, 'svg:svg');
  2520. svg.setAttributeNS(null, 'version', '1.1');
  2521. svg.setAttributeNS(null, 'width', width + 'px');
  2522. svg.setAttributeNS(null, 'height', height + 'px');
  2523. svg.setAttributeNS(null, 'preserveAspectRatio', 'none');
  2524. svg.setAttributeNS(null, 'viewBox', '0 0 ' + width + ' ' + height);
  2525. var line = document.createElementNS(SVG_NS, 'svg:line');
  2526. line.setAttributeNS(null, 'x1', data.rect[2] - data.lineCoordinates[0]);
  2527. line.setAttributeNS(null, 'y1', data.rect[3] - data.lineCoordinates[1]);
  2528. line.setAttributeNS(null, 'x2', data.rect[2] - data.lineCoordinates[2]);
  2529. line.setAttributeNS(null, 'y2', data.rect[3] - data.lineCoordinates[3]);
  2530. line.setAttributeNS(null, 'stroke-width', data.borderStyle.width);
  2531. line.setAttributeNS(null, 'stroke', 'transparent');
  2532. svg.appendChild(line);
  2533. this.container.append(svg);
  2534. this._createPopup(this.container, line, this.data);
  2535. return this.container;
  2536. }
  2537. });
  2538. return LineAnnotationElement;
  2539. }();
  2540. var HighlightAnnotationElement = function HighlightAnnotationElementClosure() {
  2541. function HighlightAnnotationElement(parameters) {
  2542. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  2543. AnnotationElement.call(this, parameters, isRenderable, true);
  2544. }
  2545. _util.Util.inherit(HighlightAnnotationElement, AnnotationElement, {
  2546. render: function HighlightAnnotationElement_render() {
  2547. this.container.className = 'highlightAnnotation';
  2548. if (!this.data.hasPopup) {
  2549. this._createPopup(this.container, null, this.data);
  2550. }
  2551. return this.container;
  2552. }
  2553. });
  2554. return HighlightAnnotationElement;
  2555. }();
  2556. var UnderlineAnnotationElement = function UnderlineAnnotationElementClosure() {
  2557. function UnderlineAnnotationElement(parameters) {
  2558. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  2559. AnnotationElement.call(this, parameters, isRenderable, true);
  2560. }
  2561. _util.Util.inherit(UnderlineAnnotationElement, AnnotationElement, {
  2562. render: function UnderlineAnnotationElement_render() {
  2563. this.container.className = 'underlineAnnotation';
  2564. if (!this.data.hasPopup) {
  2565. this._createPopup(this.container, null, this.data);
  2566. }
  2567. return this.container;
  2568. }
  2569. });
  2570. return UnderlineAnnotationElement;
  2571. }();
  2572. var SquigglyAnnotationElement = function SquigglyAnnotationElementClosure() {
  2573. function SquigglyAnnotationElement(parameters) {
  2574. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  2575. AnnotationElement.call(this, parameters, isRenderable, true);
  2576. }
  2577. _util.Util.inherit(SquigglyAnnotationElement, AnnotationElement, {
  2578. render: function SquigglyAnnotationElement_render() {
  2579. this.container.className = 'squigglyAnnotation';
  2580. if (!this.data.hasPopup) {
  2581. this._createPopup(this.container, null, this.data);
  2582. }
  2583. return this.container;
  2584. }
  2585. });
  2586. return SquigglyAnnotationElement;
  2587. }();
  2588. var StrikeOutAnnotationElement = function StrikeOutAnnotationElementClosure() {
  2589. function StrikeOutAnnotationElement(parameters) {
  2590. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  2591. AnnotationElement.call(this, parameters, isRenderable, true);
  2592. }
  2593. _util.Util.inherit(StrikeOutAnnotationElement, AnnotationElement, {
  2594. render: function StrikeOutAnnotationElement_render() {
  2595. this.container.className = 'strikeoutAnnotation';
  2596. if (!this.data.hasPopup) {
  2597. this._createPopup(this.container, null, this.data);
  2598. }
  2599. return this.container;
  2600. }
  2601. });
  2602. return StrikeOutAnnotationElement;
  2603. }();
  2604. var FileAttachmentAnnotationElement = function FileAttachmentAnnotationElementClosure() {
  2605. function FileAttachmentAnnotationElement(parameters) {
  2606. AnnotationElement.call(this, parameters, true);
  2607. var file = this.data.file;
  2608. this.filename = (0, _dom_utils.getFilenameFromUrl)(file.filename);
  2609. this.content = file.content;
  2610. this.linkService.onFileAttachmentAnnotation({
  2611. id: (0, _util.stringToPDFString)(file.filename),
  2612. filename: file.filename,
  2613. content: file.content
  2614. });
  2615. }
  2616. _util.Util.inherit(FileAttachmentAnnotationElement, AnnotationElement, {
  2617. render: function FileAttachmentAnnotationElement_render() {
  2618. this.container.className = 'fileAttachmentAnnotation';
  2619. var trigger = document.createElement('div');
  2620. trigger.style.height = this.container.style.height;
  2621. trigger.style.width = this.container.style.width;
  2622. trigger.addEventListener('dblclick', this._download.bind(this));
  2623. if (!this.data.hasPopup && (this.data.title || this.data.contents)) {
  2624. this._createPopup(this.container, trigger, this.data);
  2625. }
  2626. this.container.appendChild(trigger);
  2627. return this.container;
  2628. },
  2629. _download: function FileAttachmentAnnotationElement_download() {
  2630. if (!this.downloadManager) {
  2631. (0, _util.warn)('Download cannot be started due to unavailable download manager');
  2632. return;
  2633. }
  2634. this.downloadManager.downloadData(this.content, this.filename, '');
  2635. }
  2636. });
  2637. return FileAttachmentAnnotationElement;
  2638. }();
  2639. var AnnotationLayer = function AnnotationLayerClosure() {
  2640. return {
  2641. render: function AnnotationLayer_render(parameters) {
  2642. var annotationElementFactory = new AnnotationElementFactory();
  2643. for (var i = 0, ii = parameters.annotations.length; i < ii; i++) {
  2644. var data = parameters.annotations[i];
  2645. if (!data) {
  2646. continue;
  2647. }
  2648. var element = annotationElementFactory.create({
  2649. data: data,
  2650. layer: parameters.div,
  2651. page: parameters.page,
  2652. viewport: parameters.viewport,
  2653. linkService: parameters.linkService,
  2654. downloadManager: parameters.downloadManager,
  2655. imageResourcesPath: parameters.imageResourcesPath || (0, _dom_utils.getDefaultSetting)('imageResourcesPath'),
  2656. renderInteractiveForms: parameters.renderInteractiveForms || false
  2657. });
  2658. if (element.isRenderable) {
  2659. parameters.div.appendChild(element.render());
  2660. }
  2661. }
  2662. },
  2663. update: function AnnotationLayer_update(parameters) {
  2664. for (var i = 0, ii = parameters.annotations.length; i < ii; i++) {
  2665. var data = parameters.annotations[i];
  2666. var element = parameters.div.querySelector('[data-annotation-id="' + data.id + '"]');
  2667. if (element) {
  2668. _dom_utils.CustomStyle.setProp('transform', element, 'matrix(' + parameters.viewport.transform.join(',') + ')');
  2669. }
  2670. }
  2671. parameters.div.removeAttribute('hidden');
  2672. }
  2673. };
  2674. }();
  2675. exports.AnnotationLayer = AnnotationLayer;
  2676. /***/ }),
  2677. /* 30 */
  2678. /***/ (function(module, exports, __w_pdfjs_require__) {
  2679. "use strict";
  2680. Object.defineProperty(exports, "__esModule", {
  2681. value: true
  2682. });
  2683. exports.build = exports.version = exports._UnsupportedManager = exports.setPDFNetworkStreamClass = exports.PDFPageProxy = exports.PDFDocumentProxy = exports.PDFWorker = exports.PDFDataRangeTransport = exports.LoopbackPort = exports.getDocument = undefined;
  2684. 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; }; }();
  2685. 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; };
  2686. var _util = __w_pdfjs_require__(0);
  2687. var _dom_utils = __w_pdfjs_require__(7);
  2688. var _font_loader = __w_pdfjs_require__(83);
  2689. var _canvas = __w_pdfjs_require__(82);
  2690. var _global_scope = __w_pdfjs_require__(14);
  2691. var _global_scope2 = _interopRequireDefault(_global_scope);
  2692. var _metadata = __w_pdfjs_require__(51);
  2693. var _transport_stream = __w_pdfjs_require__(85);
  2694. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  2695. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  2696. var DEFAULT_RANGE_CHUNK_SIZE = 65536;
  2697. var isWorkerDisabled = false;
  2698. var workerSrc;
  2699. var isPostMessageTransfersDisabled = false;
  2700. var pdfjsFilePath = typeof document !== 'undefined' && document.currentScript ? document.currentScript.src : null;
  2701. var fakeWorkerFilesLoader = null;
  2702. var useRequireEnsure = false;
  2703. {
  2704. if (typeof window === 'undefined') {
  2705. isWorkerDisabled = true;
  2706. if (typeof require.ensure === 'undefined') {
  2707. require.ensure = require('node-ensure');
  2708. }
  2709. useRequireEnsure = true;
  2710. } else if (typeof require !== 'undefined' && typeof require.ensure === 'function') {
  2711. useRequireEnsure = true;
  2712. }
  2713. if (typeof requirejs !== 'undefined' && requirejs.toUrl) {
  2714. workerSrc = requirejs.toUrl('pdfjs-dist/build/pdf.worker.js');
  2715. }
  2716. var dynamicLoaderSupported = typeof requirejs !== 'undefined' && requirejs.load;
  2717. fakeWorkerFilesLoader = useRequireEnsure ? function (callback) {
  2718. require.ensure([], function () {
  2719. var worker;
  2720. worker = require('./pdf.worker.js');
  2721. callback(worker.WorkerMessageHandler);
  2722. });
  2723. } : dynamicLoaderSupported ? function (callback) {
  2724. requirejs(['pdfjs-dist/build/pdf.worker'], function (worker) {
  2725. callback(worker.WorkerMessageHandler);
  2726. });
  2727. } : null;
  2728. }
  2729. var PDFNetworkStream;
  2730. function setPDFNetworkStreamClass(cls) {
  2731. PDFNetworkStream = cls;
  2732. }
  2733. function getDocument(src, pdfDataRangeTransport, passwordCallback, progressCallback) {
  2734. var task = new PDFDocumentLoadingTask();
  2735. if (arguments.length > 1) {
  2736. (0, _util.deprecated)('getDocument is called with pdfDataRangeTransport, ' + 'passwordCallback or progressCallback argument');
  2737. }
  2738. if (pdfDataRangeTransport) {
  2739. if (!(pdfDataRangeTransport instanceof PDFDataRangeTransport)) {
  2740. pdfDataRangeTransport = Object.create(pdfDataRangeTransport);
  2741. pdfDataRangeTransport.length = src.length;
  2742. pdfDataRangeTransport.initialData = src.initialData;
  2743. if (!pdfDataRangeTransport.abort) {
  2744. pdfDataRangeTransport.abort = function () {};
  2745. }
  2746. }
  2747. src = Object.create(src);
  2748. src.range = pdfDataRangeTransport;
  2749. }
  2750. task.onPassword = passwordCallback || null;
  2751. task.onProgress = progressCallback || null;
  2752. var source;
  2753. if (typeof src === 'string') {
  2754. source = { url: src };
  2755. } else if ((0, _util.isArrayBuffer)(src)) {
  2756. source = { data: src };
  2757. } else if (src instanceof PDFDataRangeTransport) {
  2758. source = { range: src };
  2759. } else {
  2760. if ((typeof src === 'undefined' ? 'undefined' : _typeof(src)) !== 'object') {
  2761. throw new Error('Invalid parameter in getDocument, ' + 'need either Uint8Array, string or a parameter object');
  2762. }
  2763. if (!src.url && !src.data && !src.range) {
  2764. throw new Error('Invalid parameter object: need either .data, .range or .url');
  2765. }
  2766. source = src;
  2767. }
  2768. var params = {};
  2769. var rangeTransport = null;
  2770. var worker = null;
  2771. var CMapReaderFactory = _dom_utils.DOMCMapReaderFactory;
  2772. for (var key in source) {
  2773. if (key === 'url' && typeof window !== 'undefined') {
  2774. params[key] = new URL(source[key], window.location).href;
  2775. continue;
  2776. } else if (key === 'range') {
  2777. rangeTransport = source[key];
  2778. continue;
  2779. } else if (key === 'worker') {
  2780. worker = source[key];
  2781. continue;
  2782. } else if (key === 'data' && !(source[key] instanceof Uint8Array)) {
  2783. var pdfBytes = source[key];
  2784. if (typeof pdfBytes === 'string') {
  2785. params[key] = (0, _util.stringToBytes)(pdfBytes);
  2786. } else if ((typeof pdfBytes === 'undefined' ? 'undefined' : _typeof(pdfBytes)) === 'object' && pdfBytes !== null && !isNaN(pdfBytes.length)) {
  2787. params[key] = new Uint8Array(pdfBytes);
  2788. } else if ((0, _util.isArrayBuffer)(pdfBytes)) {
  2789. params[key] = new Uint8Array(pdfBytes);
  2790. } else {
  2791. throw new Error('Invalid PDF binary data: either typed array, ' + 'string or array-like object is expected in the ' + 'data property.');
  2792. }
  2793. continue;
  2794. } else if (key === 'CMapReaderFactory') {
  2795. CMapReaderFactory = source[key];
  2796. continue;
  2797. }
  2798. params[key] = source[key];
  2799. }
  2800. params.rangeChunkSize = params.rangeChunkSize || DEFAULT_RANGE_CHUNK_SIZE;
  2801. params.ignoreErrors = params.stopAtErrors !== true;
  2802. if (params.disableNativeImageDecoder !== undefined) {
  2803. (0, _util.deprecated)('parameter disableNativeImageDecoder, ' + 'use nativeImageDecoderSupport instead');
  2804. }
  2805. params.nativeImageDecoderSupport = params.nativeImageDecoderSupport || (params.disableNativeImageDecoder === true ? _util.NativeImageDecoding.NONE : _util.NativeImageDecoding.DECODE);
  2806. if (params.nativeImageDecoderSupport !== _util.NativeImageDecoding.DECODE && params.nativeImageDecoderSupport !== _util.NativeImageDecoding.NONE && params.nativeImageDecoderSupport !== _util.NativeImageDecoding.DISPLAY) {
  2807. (0, _util.warn)('Invalid parameter nativeImageDecoderSupport: ' + 'need a state of enum {NativeImageDecoding}');
  2808. params.nativeImageDecoderSupport = _util.NativeImageDecoding.DECODE;
  2809. }
  2810. if (!worker) {
  2811. var workerPort = (0, _dom_utils.getDefaultSetting)('workerPort');
  2812. worker = workerPort ? PDFWorker.fromPort(workerPort) : new PDFWorker();
  2813. task._worker = worker;
  2814. }
  2815. var docId = task.docId;
  2816. worker.promise.then(function () {
  2817. if (task.destroyed) {
  2818. throw new Error('Loading aborted');
  2819. }
  2820. return _fetchDocument(worker, params, rangeTransport, docId).then(function (workerId) {
  2821. if (task.destroyed) {
  2822. throw new Error('Loading aborted');
  2823. }
  2824. var networkStream = void 0;
  2825. if (rangeTransport) {
  2826. networkStream = new _transport_stream.PDFDataTransportStream(params, rangeTransport);
  2827. } else if (!params.data) {
  2828. networkStream = new PDFNetworkStream({
  2829. source: params,
  2830. disableRange: (0, _dom_utils.getDefaultSetting)('disableRange')
  2831. });
  2832. }
  2833. var messageHandler = new _util.MessageHandler(docId, workerId, worker.port);
  2834. messageHandler.postMessageTransfers = worker.postMessageTransfers;
  2835. var transport = new WorkerTransport(messageHandler, task, networkStream, CMapReaderFactory);
  2836. task._transport = transport;
  2837. messageHandler.send('Ready', null);
  2838. });
  2839. }).catch(task._capability.reject);
  2840. return task;
  2841. }
  2842. function _fetchDocument(worker, source, pdfDataRangeTransport, docId) {
  2843. if (worker.destroyed) {
  2844. return Promise.reject(new Error('Worker was destroyed'));
  2845. }
  2846. source.disableAutoFetch = (0, _dom_utils.getDefaultSetting)('disableAutoFetch');
  2847. source.disableStream = (0, _dom_utils.getDefaultSetting)('disableStream');
  2848. source.chunkedViewerLoading = !!pdfDataRangeTransport;
  2849. if (pdfDataRangeTransport) {
  2850. source.length = pdfDataRangeTransport.length;
  2851. source.initialData = pdfDataRangeTransport.initialData;
  2852. }
  2853. return worker.messageHandler.sendWithPromise('GetDocRequest', {
  2854. docId: docId,
  2855. source: {
  2856. data: source.data,
  2857. url: source.url,
  2858. password: source.password,
  2859. disableAutoFetch: source.disableAutoFetch,
  2860. rangeChunkSize: source.rangeChunkSize,
  2861. length: source.length
  2862. },
  2863. maxImageSize: (0, _dom_utils.getDefaultSetting)('maxImageSize'),
  2864. disableFontFace: (0, _dom_utils.getDefaultSetting)('disableFontFace'),
  2865. disableCreateObjectURL: (0, _dom_utils.getDefaultSetting)('disableCreateObjectURL'),
  2866. postMessageTransfers: (0, _dom_utils.getDefaultSetting)('postMessageTransfers') && !isPostMessageTransfersDisabled,
  2867. docBaseUrl: source.docBaseUrl,
  2868. nativeImageDecoderSupport: source.nativeImageDecoderSupport,
  2869. ignoreErrors: source.ignoreErrors
  2870. }).then(function (workerId) {
  2871. if (worker.destroyed) {
  2872. throw new Error('Worker was destroyed');
  2873. }
  2874. return workerId;
  2875. });
  2876. }
  2877. var PDFDocumentLoadingTask = function PDFDocumentLoadingTaskClosure() {
  2878. var nextDocumentId = 0;
  2879. function PDFDocumentLoadingTask() {
  2880. this._capability = (0, _util.createPromiseCapability)();
  2881. this._transport = null;
  2882. this._worker = null;
  2883. this.docId = 'd' + nextDocumentId++;
  2884. this.destroyed = false;
  2885. this.onPassword = null;
  2886. this.onProgress = null;
  2887. this.onUnsupportedFeature = null;
  2888. }
  2889. PDFDocumentLoadingTask.prototype = {
  2890. get promise() {
  2891. return this._capability.promise;
  2892. },
  2893. destroy: function destroy() {
  2894. var _this = this;
  2895. this.destroyed = true;
  2896. var transportDestroyed = !this._transport ? Promise.resolve() : this._transport.destroy();
  2897. return transportDestroyed.then(function () {
  2898. _this._transport = null;
  2899. if (_this._worker) {
  2900. _this._worker.destroy();
  2901. _this._worker = null;
  2902. }
  2903. });
  2904. },
  2905. then: function PDFDocumentLoadingTask_then(onFulfilled, onRejected) {
  2906. return this.promise.then.apply(this.promise, arguments);
  2907. }
  2908. };
  2909. return PDFDocumentLoadingTask;
  2910. }();
  2911. var PDFDataRangeTransport = function pdfDataRangeTransportClosure() {
  2912. function PDFDataRangeTransport(length, initialData) {
  2913. this.length = length;
  2914. this.initialData = initialData;
  2915. this._rangeListeners = [];
  2916. this._progressListeners = [];
  2917. this._progressiveReadListeners = [];
  2918. this._readyCapability = (0, _util.createPromiseCapability)();
  2919. }
  2920. PDFDataRangeTransport.prototype = {
  2921. addRangeListener: function PDFDataRangeTransport_addRangeListener(listener) {
  2922. this._rangeListeners.push(listener);
  2923. },
  2924. addProgressListener: function PDFDataRangeTransport_addProgressListener(listener) {
  2925. this._progressListeners.push(listener);
  2926. },
  2927. addProgressiveReadListener: function PDFDataRangeTransport_addProgressiveReadListener(listener) {
  2928. this._progressiveReadListeners.push(listener);
  2929. },
  2930. onDataRange: function PDFDataRangeTransport_onDataRange(begin, chunk) {
  2931. var listeners = this._rangeListeners;
  2932. for (var i = 0, n = listeners.length; i < n; ++i) {
  2933. listeners[i](begin, chunk);
  2934. }
  2935. },
  2936. onDataProgress: function PDFDataRangeTransport_onDataProgress(loaded) {
  2937. var _this2 = this;
  2938. this._readyCapability.promise.then(function () {
  2939. var listeners = _this2._progressListeners;
  2940. for (var i = 0, n = listeners.length; i < n; ++i) {
  2941. listeners[i](loaded);
  2942. }
  2943. });
  2944. },
  2945. onDataProgressiveRead: function PDFDataRangeTransport_onDataProgress(chunk) {
  2946. var _this3 = this;
  2947. this._readyCapability.promise.then(function () {
  2948. var listeners = _this3._progressiveReadListeners;
  2949. for (var i = 0, n = listeners.length; i < n; ++i) {
  2950. listeners[i](chunk);
  2951. }
  2952. });
  2953. },
  2954. transportReady: function PDFDataRangeTransport_transportReady() {
  2955. this._readyCapability.resolve();
  2956. },
  2957. requestDataRange: function PDFDataRangeTransport_requestDataRange(begin, end) {
  2958. throw new Error('Abstract method PDFDataRangeTransport.requestDataRange');
  2959. },
  2960. abort: function PDFDataRangeTransport_abort() {}
  2961. };
  2962. return PDFDataRangeTransport;
  2963. }();
  2964. var PDFDocumentProxy = function PDFDocumentProxyClosure() {
  2965. function PDFDocumentProxy(pdfInfo, transport, loadingTask) {
  2966. this.pdfInfo = pdfInfo;
  2967. this.transport = transport;
  2968. this.loadingTask = loadingTask;
  2969. }
  2970. PDFDocumentProxy.prototype = {
  2971. get numPages() {
  2972. return this.pdfInfo.numPages;
  2973. },
  2974. get fingerprint() {
  2975. return this.pdfInfo.fingerprint;
  2976. },
  2977. getPage: function PDFDocumentProxy_getPage(pageNumber) {
  2978. return this.transport.getPage(pageNumber);
  2979. },
  2980. getPageIndex: function PDFDocumentProxy_getPageIndex(ref) {
  2981. return this.transport.getPageIndex(ref);
  2982. },
  2983. getDestinations: function PDFDocumentProxy_getDestinations() {
  2984. return this.transport.getDestinations();
  2985. },
  2986. getDestination: function PDFDocumentProxy_getDestination(id) {
  2987. return this.transport.getDestination(id);
  2988. },
  2989. getPageLabels: function PDFDocumentProxy_getPageLabels() {
  2990. return this.transport.getPageLabels();
  2991. },
  2992. getPageMode: function getPageMode() {
  2993. return this.transport.getPageMode();
  2994. },
  2995. getAttachments: function PDFDocumentProxy_getAttachments() {
  2996. return this.transport.getAttachments();
  2997. },
  2998. getJavaScript: function PDFDocumentProxy_getJavaScript() {
  2999. return this.transport.getJavaScript();
  3000. },
  3001. getOutline: function PDFDocumentProxy_getOutline() {
  3002. return this.transport.getOutline();
  3003. },
  3004. getMetadata: function PDFDocumentProxy_getMetadata() {
  3005. return this.transport.getMetadata();
  3006. },
  3007. getData: function PDFDocumentProxy_getData() {
  3008. return this.transport.getData();
  3009. },
  3010. getDownloadInfo: function PDFDocumentProxy_getDownloadInfo() {
  3011. return this.transport.downloadInfoCapability.promise;
  3012. },
  3013. getStats: function PDFDocumentProxy_getStats() {
  3014. return this.transport.getStats();
  3015. },
  3016. cleanup: function PDFDocumentProxy_cleanup() {
  3017. this.transport.startCleanup();
  3018. },
  3019. destroy: function PDFDocumentProxy_destroy() {
  3020. return this.loadingTask.destroy();
  3021. }
  3022. };
  3023. return PDFDocumentProxy;
  3024. }();
  3025. var PDFPageProxy = function PDFPageProxyClosure() {
  3026. function PDFPageProxy(pageIndex, pageInfo, transport) {
  3027. this.pageIndex = pageIndex;
  3028. this.pageInfo = pageInfo;
  3029. this.transport = transport;
  3030. this.stats = new _util.StatTimer();
  3031. this.stats.enabled = (0, _dom_utils.getDefaultSetting)('enableStats');
  3032. this.commonObjs = transport.commonObjs;
  3033. this.objs = new PDFObjects();
  3034. this.cleanupAfterRender = false;
  3035. this.pendingCleanup = false;
  3036. this.intentStates = Object.create(null);
  3037. this.destroyed = false;
  3038. }
  3039. PDFPageProxy.prototype = {
  3040. get pageNumber() {
  3041. return this.pageIndex + 1;
  3042. },
  3043. get rotate() {
  3044. return this.pageInfo.rotate;
  3045. },
  3046. get ref() {
  3047. return this.pageInfo.ref;
  3048. },
  3049. get userUnit() {
  3050. return this.pageInfo.userUnit;
  3051. },
  3052. get view() {
  3053. return this.pageInfo.view;
  3054. },
  3055. getViewport: function PDFPageProxy_getViewport(scale, rotate) {
  3056. if (arguments.length < 2) {
  3057. rotate = this.rotate;
  3058. }
  3059. return new _util.PageViewport(this.view, scale, rotate, 0, 0);
  3060. },
  3061. getAnnotations: function PDFPageProxy_getAnnotations(params) {
  3062. var intent = params && params.intent || null;
  3063. if (!this.annotationsPromise || this.annotationsIntent !== intent) {
  3064. this.annotationsPromise = this.transport.getAnnotations(this.pageIndex, intent);
  3065. this.annotationsIntent = intent;
  3066. }
  3067. return this.annotationsPromise;
  3068. },
  3069. render: function PDFPageProxy_render(params) {
  3070. var _this4 = this;
  3071. var stats = this.stats;
  3072. stats.time('Overall');
  3073. this.pendingCleanup = false;
  3074. var renderingIntent = params.intent === 'print' ? 'print' : 'display';
  3075. var canvasFactory = params.canvasFactory || new _dom_utils.DOMCanvasFactory();
  3076. if (!this.intentStates[renderingIntent]) {
  3077. this.intentStates[renderingIntent] = Object.create(null);
  3078. }
  3079. var intentState = this.intentStates[renderingIntent];
  3080. if (!intentState.displayReadyCapability) {
  3081. intentState.receivingOperatorList = true;
  3082. intentState.displayReadyCapability = (0, _util.createPromiseCapability)();
  3083. intentState.operatorList = {
  3084. fnArray: [],
  3085. argsArray: [],
  3086. lastChunk: false
  3087. };
  3088. this.stats.time('Page Request');
  3089. this.transport.messageHandler.send('RenderPageRequest', {
  3090. pageIndex: this.pageNumber - 1,
  3091. intent: renderingIntent,
  3092. renderInteractiveForms: params.renderInteractiveForms === true
  3093. });
  3094. }
  3095. var complete = function complete(error) {
  3096. var i = intentState.renderTasks.indexOf(internalRenderTask);
  3097. if (i >= 0) {
  3098. intentState.renderTasks.splice(i, 1);
  3099. }
  3100. if (_this4.cleanupAfterRender) {
  3101. _this4.pendingCleanup = true;
  3102. }
  3103. _this4._tryCleanup();
  3104. if (error) {
  3105. internalRenderTask.capability.reject(error);
  3106. } else {
  3107. internalRenderTask.capability.resolve();
  3108. }
  3109. stats.timeEnd('Rendering');
  3110. stats.timeEnd('Overall');
  3111. };
  3112. var internalRenderTask = new InternalRenderTask(complete, params, this.objs, this.commonObjs, intentState.operatorList, this.pageNumber, canvasFactory);
  3113. internalRenderTask.useRequestAnimationFrame = renderingIntent !== 'print';
  3114. if (!intentState.renderTasks) {
  3115. intentState.renderTasks = [];
  3116. }
  3117. intentState.renderTasks.push(internalRenderTask);
  3118. var renderTask = internalRenderTask.task;
  3119. if (params.continueCallback) {
  3120. (0, _util.deprecated)('render is used with continueCallback parameter');
  3121. renderTask.onContinue = params.continueCallback;
  3122. }
  3123. intentState.displayReadyCapability.promise.then(function (transparency) {
  3124. if (_this4.pendingCleanup) {
  3125. complete();
  3126. return;
  3127. }
  3128. stats.time('Rendering');
  3129. internalRenderTask.initializeGraphics(transparency);
  3130. internalRenderTask.operatorListChanged();
  3131. }).catch(complete);
  3132. return renderTask;
  3133. },
  3134. getOperatorList: function PDFPageProxy_getOperatorList() {
  3135. function operatorListChanged() {
  3136. if (intentState.operatorList.lastChunk) {
  3137. intentState.opListReadCapability.resolve(intentState.operatorList);
  3138. var i = intentState.renderTasks.indexOf(opListTask);
  3139. if (i >= 0) {
  3140. intentState.renderTasks.splice(i, 1);
  3141. }
  3142. }
  3143. }
  3144. var renderingIntent = 'oplist';
  3145. if (!this.intentStates[renderingIntent]) {
  3146. this.intentStates[renderingIntent] = Object.create(null);
  3147. }
  3148. var intentState = this.intentStates[renderingIntent];
  3149. var opListTask;
  3150. if (!intentState.opListReadCapability) {
  3151. opListTask = {};
  3152. opListTask.operatorListChanged = operatorListChanged;
  3153. intentState.receivingOperatorList = true;
  3154. intentState.opListReadCapability = (0, _util.createPromiseCapability)();
  3155. intentState.renderTasks = [];
  3156. intentState.renderTasks.push(opListTask);
  3157. intentState.operatorList = {
  3158. fnArray: [],
  3159. argsArray: [],
  3160. lastChunk: false
  3161. };
  3162. this.transport.messageHandler.send('RenderPageRequest', {
  3163. pageIndex: this.pageIndex,
  3164. intent: renderingIntent
  3165. });
  3166. }
  3167. return intentState.opListReadCapability.promise;
  3168. },
  3169. streamTextContent: function streamTextContent() {
  3170. var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  3171. var TEXT_CONTENT_CHUNK_SIZE = 100;
  3172. return this.transport.messageHandler.sendWithStream('GetTextContent', {
  3173. pageIndex: this.pageNumber - 1,
  3174. normalizeWhitespace: params.normalizeWhitespace === true,
  3175. combineTextItems: params.disableCombineTextItems !== true
  3176. }, {
  3177. highWaterMark: TEXT_CONTENT_CHUNK_SIZE,
  3178. size: function size(textContent) {
  3179. return textContent.items.length;
  3180. }
  3181. });
  3182. },
  3183. getTextContent: function PDFPageProxy_getTextContent(params) {
  3184. params = params || {};
  3185. var readableStream = this.streamTextContent(params);
  3186. return new Promise(function (resolve, reject) {
  3187. function pump() {
  3188. reader.read().then(function (_ref) {
  3189. var value = _ref.value,
  3190. done = _ref.done;
  3191. if (done) {
  3192. resolve(textContent);
  3193. return;
  3194. }
  3195. _util.Util.extendObj(textContent.styles, value.styles);
  3196. _util.Util.appendToArray(textContent.items, value.items);
  3197. pump();
  3198. }, reject);
  3199. }
  3200. var reader = readableStream.getReader();
  3201. var textContent = {
  3202. items: [],
  3203. styles: Object.create(null)
  3204. };
  3205. pump();
  3206. });
  3207. },
  3208. _destroy: function PDFPageProxy_destroy() {
  3209. this.destroyed = true;
  3210. this.transport.pageCache[this.pageIndex] = null;
  3211. var waitOn = [];
  3212. Object.keys(this.intentStates).forEach(function (intent) {
  3213. if (intent === 'oplist') {
  3214. return;
  3215. }
  3216. var intentState = this.intentStates[intent];
  3217. intentState.renderTasks.forEach(function (renderTask) {
  3218. var renderCompleted = renderTask.capability.promise.catch(function () {});
  3219. waitOn.push(renderCompleted);
  3220. renderTask.cancel();
  3221. });
  3222. }, this);
  3223. this.objs.clear();
  3224. this.annotationsPromise = null;
  3225. this.pendingCleanup = false;
  3226. return Promise.all(waitOn);
  3227. },
  3228. destroy: function destroy() {
  3229. (0, _util.deprecated)('page destroy method, use cleanup() instead');
  3230. this.cleanup();
  3231. },
  3232. cleanup: function PDFPageProxy_cleanup() {
  3233. this.pendingCleanup = true;
  3234. this._tryCleanup();
  3235. },
  3236. _tryCleanup: function PDFPageProxy_tryCleanup() {
  3237. if (!this.pendingCleanup || Object.keys(this.intentStates).some(function (intent) {
  3238. var intentState = this.intentStates[intent];
  3239. return intentState.renderTasks.length !== 0 || intentState.receivingOperatorList;
  3240. }, this)) {
  3241. return;
  3242. }
  3243. Object.keys(this.intentStates).forEach(function (intent) {
  3244. delete this.intentStates[intent];
  3245. }, this);
  3246. this.objs.clear();
  3247. this.annotationsPromise = null;
  3248. this.pendingCleanup = false;
  3249. },
  3250. _startRenderPage: function PDFPageProxy_startRenderPage(transparency, intent) {
  3251. var intentState = this.intentStates[intent];
  3252. if (intentState.displayReadyCapability) {
  3253. intentState.displayReadyCapability.resolve(transparency);
  3254. }
  3255. },
  3256. _renderPageChunk: function PDFPageProxy_renderPageChunk(operatorListChunk, intent) {
  3257. var intentState = this.intentStates[intent];
  3258. var i, ii;
  3259. for (i = 0, ii = operatorListChunk.length; i < ii; i++) {
  3260. intentState.operatorList.fnArray.push(operatorListChunk.fnArray[i]);
  3261. intentState.operatorList.argsArray.push(operatorListChunk.argsArray[i]);
  3262. }
  3263. intentState.operatorList.lastChunk = operatorListChunk.lastChunk;
  3264. for (i = 0; i < intentState.renderTasks.length; i++) {
  3265. intentState.renderTasks[i].operatorListChanged();
  3266. }
  3267. if (operatorListChunk.lastChunk) {
  3268. intentState.receivingOperatorList = false;
  3269. this._tryCleanup();
  3270. }
  3271. }
  3272. };
  3273. return PDFPageProxy;
  3274. }();
  3275. var LoopbackPort = function () {
  3276. function LoopbackPort(defer) {
  3277. _classCallCheck(this, LoopbackPort);
  3278. this._listeners = [];
  3279. this._defer = defer;
  3280. this._deferred = Promise.resolve(undefined);
  3281. }
  3282. _createClass(LoopbackPort, [{
  3283. key: 'postMessage',
  3284. value: function postMessage(obj, transfers) {
  3285. var _this5 = this;
  3286. function cloneValue(value) {
  3287. if ((typeof value === 'undefined' ? 'undefined' : _typeof(value)) !== 'object' || value === null) {
  3288. return value;
  3289. }
  3290. if (cloned.has(value)) {
  3291. return cloned.get(value);
  3292. }
  3293. var result;
  3294. var buffer;
  3295. if ((buffer = value.buffer) && (0, _util.isArrayBuffer)(buffer)) {
  3296. var transferable = transfers && transfers.indexOf(buffer) >= 0;
  3297. if (value === buffer) {
  3298. result = value;
  3299. } else if (transferable) {
  3300. result = new value.constructor(buffer, value.byteOffset, value.byteLength);
  3301. } else {
  3302. result = new value.constructor(value);
  3303. }
  3304. cloned.set(value, result);
  3305. return result;
  3306. }
  3307. result = Array.isArray(value) ? [] : {};
  3308. cloned.set(value, result);
  3309. for (var i in value) {
  3310. var desc,
  3311. p = value;
  3312. while (!(desc = Object.getOwnPropertyDescriptor(p, i))) {
  3313. p = Object.getPrototypeOf(p);
  3314. }
  3315. if (typeof desc.value === 'undefined' || typeof desc.value === 'function') {
  3316. continue;
  3317. }
  3318. result[i] = cloneValue(desc.value);
  3319. }
  3320. return result;
  3321. }
  3322. if (!this._defer) {
  3323. this._listeners.forEach(function (listener) {
  3324. listener.call(this, { data: obj });
  3325. }, this);
  3326. return;
  3327. }
  3328. var cloned = new WeakMap();
  3329. var e = { data: cloneValue(obj) };
  3330. this._deferred.then(function () {
  3331. _this5._listeners.forEach(function (listener) {
  3332. listener.call(this, e);
  3333. }, _this5);
  3334. });
  3335. }
  3336. }, {
  3337. key: 'addEventListener',
  3338. value: function addEventListener(name, listener) {
  3339. this._listeners.push(listener);
  3340. }
  3341. }, {
  3342. key: 'removeEventListener',
  3343. value: function removeEventListener(name, listener) {
  3344. var i = this._listeners.indexOf(listener);
  3345. this._listeners.splice(i, 1);
  3346. }
  3347. }, {
  3348. key: 'terminate',
  3349. value: function terminate() {
  3350. this._listeners = [];
  3351. }
  3352. }]);
  3353. return LoopbackPort;
  3354. }();
  3355. var PDFWorker = function PDFWorkerClosure() {
  3356. var nextFakeWorkerId = 0;
  3357. function getWorkerSrc() {
  3358. if (typeof workerSrc !== 'undefined') {
  3359. return workerSrc;
  3360. }
  3361. if ((0, _dom_utils.getDefaultSetting)('workerSrc')) {
  3362. return (0, _dom_utils.getDefaultSetting)('workerSrc');
  3363. }
  3364. if (pdfjsFilePath) {
  3365. return pdfjsFilePath.replace(/(\.(?:min\.)?js)(\?.*)?$/i, '.worker$1$2');
  3366. }
  3367. throw new Error('No PDFJS.workerSrc specified');
  3368. }
  3369. var fakeWorkerFilesLoadedCapability = void 0;
  3370. function setupFakeWorkerGlobal() {
  3371. var WorkerMessageHandler;
  3372. if (fakeWorkerFilesLoadedCapability) {
  3373. return fakeWorkerFilesLoadedCapability.promise;
  3374. }
  3375. fakeWorkerFilesLoadedCapability = (0, _util.createPromiseCapability)();
  3376. var loader = fakeWorkerFilesLoader || function (callback) {
  3377. _util.Util.loadScript(getWorkerSrc(), function () {
  3378. callback(window.pdfjsDistBuildPdfWorker.WorkerMessageHandler);
  3379. });
  3380. };
  3381. loader(fakeWorkerFilesLoadedCapability.resolve);
  3382. return fakeWorkerFilesLoadedCapability.promise;
  3383. }
  3384. function createCDNWrapper(url) {
  3385. var wrapper = 'importScripts(\'' + url + '\');';
  3386. return URL.createObjectURL(new Blob([wrapper]));
  3387. }
  3388. var pdfWorkerPorts = new WeakMap();
  3389. function PDFWorker(name, port) {
  3390. if (port && pdfWorkerPorts.has(port)) {
  3391. throw new Error('Cannot use more than one PDFWorker per port');
  3392. }
  3393. this.name = name;
  3394. this.destroyed = false;
  3395. this.postMessageTransfers = true;
  3396. this._readyCapability = (0, _util.createPromiseCapability)();
  3397. this._port = null;
  3398. this._webWorker = null;
  3399. this._messageHandler = null;
  3400. if (port) {
  3401. pdfWorkerPorts.set(port, this);
  3402. this._initializeFromPort(port);
  3403. return;
  3404. }
  3405. this._initialize();
  3406. }
  3407. PDFWorker.prototype = {
  3408. get promise() {
  3409. return this._readyCapability.promise;
  3410. },
  3411. get port() {
  3412. return this._port;
  3413. },
  3414. get messageHandler() {
  3415. return this._messageHandler;
  3416. },
  3417. _initializeFromPort: function PDFWorker_initializeFromPort(port) {
  3418. this._port = port;
  3419. this._messageHandler = new _util.MessageHandler('main', 'worker', port);
  3420. this._messageHandler.on('ready', function () {});
  3421. this._readyCapability.resolve();
  3422. },
  3423. _initialize: function PDFWorker_initialize() {
  3424. var _this6 = this;
  3425. if (!isWorkerDisabled && !(0, _dom_utils.getDefaultSetting)('disableWorker') && typeof Worker !== 'undefined') {
  3426. var workerSrc = getWorkerSrc();
  3427. try {
  3428. if (!(0, _util.isSameOrigin)(window.location.href, workerSrc)) {
  3429. workerSrc = createCDNWrapper(new URL(workerSrc, window.location).href);
  3430. }
  3431. var worker = new Worker(workerSrc);
  3432. var messageHandler = new _util.MessageHandler('main', 'worker', worker);
  3433. var terminateEarly = function terminateEarly() {
  3434. worker.removeEventListener('error', onWorkerError);
  3435. messageHandler.destroy();
  3436. worker.terminate();
  3437. if (_this6.destroyed) {
  3438. _this6._readyCapability.reject(new Error('Worker was destroyed'));
  3439. } else {
  3440. _this6._setupFakeWorker();
  3441. }
  3442. };
  3443. var onWorkerError = function onWorkerError() {
  3444. if (!_this6._webWorker) {
  3445. terminateEarly();
  3446. }
  3447. };
  3448. worker.addEventListener('error', onWorkerError);
  3449. messageHandler.on('test', function (data) {
  3450. worker.removeEventListener('error', onWorkerError);
  3451. if (_this6.destroyed) {
  3452. terminateEarly();
  3453. return;
  3454. }
  3455. var supportTypedArray = data && data.supportTypedArray;
  3456. if (supportTypedArray) {
  3457. _this6._messageHandler = messageHandler;
  3458. _this6._port = worker;
  3459. _this6._webWorker = worker;
  3460. if (!data.supportTransfers) {
  3461. _this6.postMessageTransfers = false;
  3462. isPostMessageTransfersDisabled = true;
  3463. }
  3464. _this6._readyCapability.resolve();
  3465. messageHandler.send('configure', { verbosity: (0, _util.getVerbosityLevel)() });
  3466. } else {
  3467. _this6._setupFakeWorker();
  3468. messageHandler.destroy();
  3469. worker.terminate();
  3470. }
  3471. });
  3472. messageHandler.on('console_log', function (data) {
  3473. console.log.apply(console, data);
  3474. });
  3475. messageHandler.on('console_error', function (data) {
  3476. console.error.apply(console, data);
  3477. });
  3478. messageHandler.on('ready', function (data) {
  3479. worker.removeEventListener('error', onWorkerError);
  3480. if (_this6.destroyed) {
  3481. terminateEarly();
  3482. return;
  3483. }
  3484. try {
  3485. sendTest();
  3486. } catch (e) {
  3487. _this6._setupFakeWorker();
  3488. }
  3489. });
  3490. var sendTest = function sendTest() {
  3491. var postMessageTransfers = (0, _dom_utils.getDefaultSetting)('postMessageTransfers') && !isPostMessageTransfersDisabled;
  3492. var testObj = new Uint8Array([postMessageTransfers ? 255 : 0]);
  3493. try {
  3494. messageHandler.send('test', testObj, [testObj.buffer]);
  3495. } catch (ex) {
  3496. (0, _util.info)('Cannot use postMessage transfers');
  3497. testObj[0] = 0;
  3498. messageHandler.send('test', testObj);
  3499. }
  3500. };
  3501. sendTest();
  3502. return;
  3503. } catch (e) {
  3504. (0, _util.info)('The worker has been disabled.');
  3505. }
  3506. }
  3507. this._setupFakeWorker();
  3508. },
  3509. _setupFakeWorker: function PDFWorker_setupFakeWorker() {
  3510. var _this7 = this;
  3511. if (!isWorkerDisabled && !(0, _dom_utils.getDefaultSetting)('disableWorker')) {
  3512. (0, _util.warn)('Setting up fake worker.');
  3513. isWorkerDisabled = true;
  3514. }
  3515. setupFakeWorkerGlobal().then(function (WorkerMessageHandler) {
  3516. if (_this7.destroyed) {
  3517. _this7._readyCapability.reject(new Error('Worker was destroyed'));
  3518. return;
  3519. }
  3520. var isTypedArraysPresent = Uint8Array !== Float32Array;
  3521. var port = new LoopbackPort(isTypedArraysPresent);
  3522. _this7._port = port;
  3523. var id = 'fake' + nextFakeWorkerId++;
  3524. var workerHandler = new _util.MessageHandler(id + '_worker', id, port);
  3525. WorkerMessageHandler.setup(workerHandler, port);
  3526. var messageHandler = new _util.MessageHandler(id, id + '_worker', port);
  3527. _this7._messageHandler = messageHandler;
  3528. _this7._readyCapability.resolve();
  3529. });
  3530. },
  3531. destroy: function PDFWorker_destroy() {
  3532. this.destroyed = true;
  3533. if (this._webWorker) {
  3534. this._webWorker.terminate();
  3535. this._webWorker = null;
  3536. }
  3537. pdfWorkerPorts.delete(this._port);
  3538. this._port = null;
  3539. if (this._messageHandler) {
  3540. this._messageHandler.destroy();
  3541. this._messageHandler = null;
  3542. }
  3543. }
  3544. };
  3545. PDFWorker.fromPort = function (port) {
  3546. if (pdfWorkerPorts.has(port)) {
  3547. return pdfWorkerPorts.get(port);
  3548. }
  3549. return new PDFWorker(null, port);
  3550. };
  3551. return PDFWorker;
  3552. }();
  3553. var WorkerTransport = function WorkerTransportClosure() {
  3554. function WorkerTransport(messageHandler, loadingTask, networkStream, CMapReaderFactory) {
  3555. this.messageHandler = messageHandler;
  3556. this.loadingTask = loadingTask;
  3557. this.commonObjs = new PDFObjects();
  3558. this.fontLoader = new _font_loader.FontLoader(loadingTask.docId);
  3559. this.CMapReaderFactory = new CMapReaderFactory({
  3560. baseUrl: (0, _dom_utils.getDefaultSetting)('cMapUrl'),
  3561. isCompressed: (0, _dom_utils.getDefaultSetting)('cMapPacked')
  3562. });
  3563. this.destroyed = false;
  3564. this.destroyCapability = null;
  3565. this._passwordCapability = null;
  3566. this._networkStream = networkStream;
  3567. this._fullReader = null;
  3568. this._lastProgress = null;
  3569. this.pageCache = [];
  3570. this.pagePromises = [];
  3571. this.downloadInfoCapability = (0, _util.createPromiseCapability)();
  3572. this.setupMessageHandler();
  3573. }
  3574. WorkerTransport.prototype = {
  3575. destroy: function WorkerTransport_destroy() {
  3576. var _this8 = this;
  3577. if (this.destroyCapability) {
  3578. return this.destroyCapability.promise;
  3579. }
  3580. this.destroyed = true;
  3581. this.destroyCapability = (0, _util.createPromiseCapability)();
  3582. if (this._passwordCapability) {
  3583. this._passwordCapability.reject(new Error('Worker was destroyed during onPassword callback'));
  3584. }
  3585. var waitOn = [];
  3586. this.pageCache.forEach(function (page) {
  3587. if (page) {
  3588. waitOn.push(page._destroy());
  3589. }
  3590. });
  3591. this.pageCache = [];
  3592. this.pagePromises = [];
  3593. var terminated = this.messageHandler.sendWithPromise('Terminate', null);
  3594. waitOn.push(terminated);
  3595. Promise.all(waitOn).then(function () {
  3596. _this8.fontLoader.clear();
  3597. if (_this8._networkStream) {
  3598. _this8._networkStream.cancelAllRequests();
  3599. }
  3600. if (_this8.messageHandler) {
  3601. _this8.messageHandler.destroy();
  3602. _this8.messageHandler = null;
  3603. }
  3604. _this8.destroyCapability.resolve();
  3605. }, this.destroyCapability.reject);
  3606. return this.destroyCapability.promise;
  3607. },
  3608. setupMessageHandler: function WorkerTransport_setupMessageHandler() {
  3609. var messageHandler = this.messageHandler;
  3610. var loadingTask = this.loadingTask;
  3611. messageHandler.on('GetReader', function (data, sink) {
  3612. var _this9 = this;
  3613. (0, _util.assert)(this._networkStream);
  3614. this._fullReader = this._networkStream.getFullReader();
  3615. this._fullReader.onProgress = function (evt) {
  3616. _this9._lastProgress = {
  3617. loaded: evt.loaded,
  3618. total: evt.total
  3619. };
  3620. };
  3621. sink.onPull = function () {
  3622. _this9._fullReader.read().then(function (_ref2) {
  3623. var value = _ref2.value,
  3624. done = _ref2.done;
  3625. if (done) {
  3626. sink.close();
  3627. return;
  3628. }
  3629. (0, _util.assert)((0, _util.isArrayBuffer)(value));
  3630. sink.enqueue(new Uint8Array(value), 1, [value]);
  3631. }).catch(function (reason) {
  3632. sink.error(reason);
  3633. });
  3634. };
  3635. sink.onCancel = function (reason) {
  3636. _this9._fullReader.cancel(reason);
  3637. };
  3638. }, this);
  3639. messageHandler.on('ReaderHeadersReady', function (data) {
  3640. var _this10 = this;
  3641. var headersCapability = (0, _util.createPromiseCapability)();
  3642. var fullReader = this._fullReader;
  3643. fullReader.headersReady.then(function () {
  3644. if (!fullReader.isStreamingSupported || !fullReader.isRangeSupported) {
  3645. if (_this10._lastProgress) {
  3646. var _loadingTask = _this10.loadingTask;
  3647. if (_loadingTask.onProgress) {
  3648. _loadingTask.onProgress(_this10._lastProgress);
  3649. }
  3650. }
  3651. fullReader.onProgress = function (evt) {
  3652. var loadingTask = _this10.loadingTask;
  3653. if (loadingTask.onProgress) {
  3654. loadingTask.onProgress({
  3655. loaded: evt.loaded,
  3656. total: evt.total
  3657. });
  3658. }
  3659. };
  3660. }
  3661. headersCapability.resolve({
  3662. isStreamingSupported: fullReader.isStreamingSupported,
  3663. isRangeSupported: fullReader.isRangeSupported,
  3664. contentLength: fullReader.contentLength
  3665. });
  3666. }, headersCapability.reject);
  3667. return headersCapability.promise;
  3668. }, this);
  3669. messageHandler.on('GetRangeReader', function (data, sink) {
  3670. (0, _util.assert)(this._networkStream);
  3671. var _rangeReader = this._networkStream.getRangeReader(data.begin, data.end);
  3672. sink.onPull = function () {
  3673. _rangeReader.read().then(function (_ref3) {
  3674. var value = _ref3.value,
  3675. done = _ref3.done;
  3676. if (done) {
  3677. sink.close();
  3678. return;
  3679. }
  3680. (0, _util.assert)((0, _util.isArrayBuffer)(value));
  3681. sink.enqueue(new Uint8Array(value), 1, [value]);
  3682. }).catch(function (reason) {
  3683. sink.error(reason);
  3684. });
  3685. };
  3686. sink.onCancel = function (reason) {
  3687. _rangeReader.cancel(reason);
  3688. };
  3689. }, this);
  3690. messageHandler.on('GetDoc', function transportDoc(data) {
  3691. var pdfInfo = data.pdfInfo;
  3692. this.numPages = data.pdfInfo.numPages;
  3693. var loadingTask = this.loadingTask;
  3694. var pdfDocument = new PDFDocumentProxy(pdfInfo, this, loadingTask);
  3695. this.pdfDocument = pdfDocument;
  3696. loadingTask._capability.resolve(pdfDocument);
  3697. }, this);
  3698. messageHandler.on('PasswordRequest', function transportPasswordRequest(exception) {
  3699. var _this11 = this;
  3700. this._passwordCapability = (0, _util.createPromiseCapability)();
  3701. if (loadingTask.onPassword) {
  3702. var updatePassword = function updatePassword(password) {
  3703. _this11._passwordCapability.resolve({ password: password });
  3704. };
  3705. loadingTask.onPassword(updatePassword, exception.code);
  3706. } else {
  3707. this._passwordCapability.reject(new _util.PasswordException(exception.message, exception.code));
  3708. }
  3709. return this._passwordCapability.promise;
  3710. }, this);
  3711. messageHandler.on('PasswordException', function transportPasswordException(exception) {
  3712. loadingTask._capability.reject(new _util.PasswordException(exception.message, exception.code));
  3713. }, this);
  3714. messageHandler.on('InvalidPDF', function transportInvalidPDF(exception) {
  3715. this.loadingTask._capability.reject(new _util.InvalidPDFException(exception.message));
  3716. }, this);
  3717. messageHandler.on('MissingPDF', function transportMissingPDF(exception) {
  3718. this.loadingTask._capability.reject(new _util.MissingPDFException(exception.message));
  3719. }, this);
  3720. messageHandler.on('UnexpectedResponse', function transportUnexpectedResponse(exception) {
  3721. this.loadingTask._capability.reject(new _util.UnexpectedResponseException(exception.message, exception.status));
  3722. }, this);
  3723. messageHandler.on('UnknownError', function transportUnknownError(exception) {
  3724. this.loadingTask._capability.reject(new _util.UnknownErrorException(exception.message, exception.details));
  3725. }, this);
  3726. messageHandler.on('DataLoaded', function transportPage(data) {
  3727. this.downloadInfoCapability.resolve(data);
  3728. }, this);
  3729. messageHandler.on('PDFManagerReady', function transportPage(data) {}, this);
  3730. messageHandler.on('StartRenderPage', function transportRender(data) {
  3731. if (this.destroyed) {
  3732. return;
  3733. }
  3734. var page = this.pageCache[data.pageIndex];
  3735. page.stats.timeEnd('Page Request');
  3736. page._startRenderPage(data.transparency, data.intent);
  3737. }, this);
  3738. messageHandler.on('RenderPageChunk', function transportRender(data) {
  3739. if (this.destroyed) {
  3740. return;
  3741. }
  3742. var page = this.pageCache[data.pageIndex];
  3743. page._renderPageChunk(data.operatorList, data.intent);
  3744. }, this);
  3745. messageHandler.on('commonobj', function transportObj(data) {
  3746. var _this12 = this;
  3747. if (this.destroyed) {
  3748. return;
  3749. }
  3750. var id = data[0];
  3751. var type = data[1];
  3752. if (this.commonObjs.hasData(id)) {
  3753. return;
  3754. }
  3755. switch (type) {
  3756. case 'Font':
  3757. var exportedData = data[2];
  3758. if ('error' in exportedData) {
  3759. var exportedError = exportedData.error;
  3760. (0, _util.warn)('Error during font loading: ' + exportedError);
  3761. this.commonObjs.resolve(id, exportedError);
  3762. break;
  3763. }
  3764. var fontRegistry = null;
  3765. if ((0, _dom_utils.getDefaultSetting)('pdfBug') && _global_scope2.default.FontInspector && _global_scope2.default['FontInspector'].enabled) {
  3766. fontRegistry = {
  3767. registerFont: function registerFont(font, url) {
  3768. _global_scope2.default['FontInspector'].fontAdded(font, url);
  3769. }
  3770. };
  3771. }
  3772. var font = new _font_loader.FontFaceObject(exportedData, {
  3773. isEvalSuported: (0, _dom_utils.getDefaultSetting)('isEvalSupported'),
  3774. disableFontFace: (0, _dom_utils.getDefaultSetting)('disableFontFace'),
  3775. fontRegistry: fontRegistry
  3776. });
  3777. var fontReady = function fontReady(fontObjs) {
  3778. _this12.commonObjs.resolve(id, font);
  3779. };
  3780. this.fontLoader.bind([font], fontReady);
  3781. break;
  3782. case 'FontPath':
  3783. this.commonObjs.resolve(id, data[2]);
  3784. break;
  3785. default:
  3786. throw new Error('Got unknown common object type ' + type);
  3787. }
  3788. }, this);
  3789. messageHandler.on('obj', function transportObj(data) {
  3790. if (this.destroyed) {
  3791. return;
  3792. }
  3793. var id = data[0];
  3794. var pageIndex = data[1];
  3795. var type = data[2];
  3796. var pageProxy = this.pageCache[pageIndex];
  3797. var imageData;
  3798. if (pageProxy.objs.hasData(id)) {
  3799. return;
  3800. }
  3801. switch (type) {
  3802. case 'JpegStream':
  3803. imageData = data[3];
  3804. (0, _util.loadJpegStream)(id, imageData, pageProxy.objs);
  3805. break;
  3806. case 'Image':
  3807. imageData = data[3];
  3808. pageProxy.objs.resolve(id, imageData);
  3809. var MAX_IMAGE_SIZE_TO_STORE = 8000000;
  3810. if (imageData && 'data' in imageData && imageData.data.length > MAX_IMAGE_SIZE_TO_STORE) {
  3811. pageProxy.cleanupAfterRender = true;
  3812. }
  3813. break;
  3814. default:
  3815. throw new Error('Got unknown object type ' + type);
  3816. }
  3817. }, this);
  3818. messageHandler.on('DocProgress', function transportDocProgress(data) {
  3819. if (this.destroyed) {
  3820. return;
  3821. }
  3822. var loadingTask = this.loadingTask;
  3823. if (loadingTask.onProgress) {
  3824. loadingTask.onProgress({
  3825. loaded: data.loaded,
  3826. total: data.total
  3827. });
  3828. }
  3829. }, this);
  3830. messageHandler.on('PageError', function transportError(data) {
  3831. if (this.destroyed) {
  3832. return;
  3833. }
  3834. var page = this.pageCache[data.pageNum - 1];
  3835. var intentState = page.intentStates[data.intent];
  3836. if (intentState.displayReadyCapability) {
  3837. intentState.displayReadyCapability.reject(data.error);
  3838. } else {
  3839. throw new Error(data.error);
  3840. }
  3841. if (intentState.operatorList) {
  3842. intentState.operatorList.lastChunk = true;
  3843. for (var i = 0; i < intentState.renderTasks.length; i++) {
  3844. intentState.renderTasks[i].operatorListChanged();
  3845. }
  3846. }
  3847. }, this);
  3848. messageHandler.on('UnsupportedFeature', function transportUnsupportedFeature(data) {
  3849. if (this.destroyed) {
  3850. return;
  3851. }
  3852. var featureId = data.featureId;
  3853. var loadingTask = this.loadingTask;
  3854. if (loadingTask.onUnsupportedFeature) {
  3855. loadingTask.onUnsupportedFeature(featureId);
  3856. }
  3857. _UnsupportedManager.notify(featureId);
  3858. }, this);
  3859. messageHandler.on('JpegDecode', function (data) {
  3860. if (this.destroyed) {
  3861. return Promise.reject(new Error('Worker was destroyed'));
  3862. }
  3863. if (typeof document === 'undefined') {
  3864. return Promise.reject(new Error('"document" is not defined.'));
  3865. }
  3866. var imageUrl = data[0];
  3867. var components = data[1];
  3868. if (components !== 3 && components !== 1) {
  3869. return Promise.reject(new Error('Only 3 components or 1 component can be returned'));
  3870. }
  3871. return new Promise(function (resolve, reject) {
  3872. var img = new Image();
  3873. img.onload = function () {
  3874. var width = img.width;
  3875. var height = img.height;
  3876. var size = width * height;
  3877. var rgbaLength = size * 4;
  3878. var buf = new Uint8Array(size * components);
  3879. var tmpCanvas = document.createElement('canvas');
  3880. tmpCanvas.width = width;
  3881. tmpCanvas.height = height;
  3882. var tmpCtx = tmpCanvas.getContext('2d');
  3883. tmpCtx.drawImage(img, 0, 0);
  3884. var data = tmpCtx.getImageData(0, 0, width, height).data;
  3885. var i, j;
  3886. if (components === 3) {
  3887. for (i = 0, j = 0; i < rgbaLength; i += 4, j += 3) {
  3888. buf[j] = data[i];
  3889. buf[j + 1] = data[i + 1];
  3890. buf[j + 2] = data[i + 2];
  3891. }
  3892. } else if (components === 1) {
  3893. for (i = 0, j = 0; i < rgbaLength; i += 4, j++) {
  3894. buf[j] = data[i];
  3895. }
  3896. }
  3897. resolve({
  3898. data: buf,
  3899. width: width,
  3900. height: height
  3901. });
  3902. };
  3903. img.onerror = function () {
  3904. reject(new Error('JpegDecode failed to load image'));
  3905. };
  3906. img.src = imageUrl;
  3907. });
  3908. }, this);
  3909. messageHandler.on('FetchBuiltInCMap', function (data) {
  3910. if (this.destroyed) {
  3911. return Promise.reject(new Error('Worker was destroyed'));
  3912. }
  3913. return this.CMapReaderFactory.fetch({ name: data.name });
  3914. }, this);
  3915. },
  3916. getData: function WorkerTransport_getData() {
  3917. return this.messageHandler.sendWithPromise('GetData', null);
  3918. },
  3919. getPage: function WorkerTransport_getPage(pageNumber, capability) {
  3920. var _this13 = this;
  3921. if (!(0, _util.isInt)(pageNumber) || pageNumber <= 0 || pageNumber > this.numPages) {
  3922. return Promise.reject(new Error('Invalid page request'));
  3923. }
  3924. var pageIndex = pageNumber - 1;
  3925. if (pageIndex in this.pagePromises) {
  3926. return this.pagePromises[pageIndex];
  3927. }
  3928. var promise = this.messageHandler.sendWithPromise('GetPage', { pageIndex: pageIndex }).then(function (pageInfo) {
  3929. if (_this13.destroyed) {
  3930. throw new Error('Transport destroyed');
  3931. }
  3932. var page = new PDFPageProxy(pageIndex, pageInfo, _this13);
  3933. _this13.pageCache[pageIndex] = page;
  3934. return page;
  3935. });
  3936. this.pagePromises[pageIndex] = promise;
  3937. return promise;
  3938. },
  3939. getPageIndex: function WorkerTransport_getPageIndexByRef(ref) {
  3940. return this.messageHandler.sendWithPromise('GetPageIndex', { ref: ref }).catch(function (reason) {
  3941. return Promise.reject(new Error(reason));
  3942. });
  3943. },
  3944. getAnnotations: function WorkerTransport_getAnnotations(pageIndex, intent) {
  3945. return this.messageHandler.sendWithPromise('GetAnnotations', {
  3946. pageIndex: pageIndex,
  3947. intent: intent
  3948. });
  3949. },
  3950. getDestinations: function WorkerTransport_getDestinations() {
  3951. return this.messageHandler.sendWithPromise('GetDestinations', null);
  3952. },
  3953. getDestination: function WorkerTransport_getDestination(id) {
  3954. return this.messageHandler.sendWithPromise('GetDestination', { id: id });
  3955. },
  3956. getPageLabels: function WorkerTransport_getPageLabels() {
  3957. return this.messageHandler.sendWithPromise('GetPageLabels', null);
  3958. },
  3959. getPageMode: function getPageMode() {
  3960. return this.messageHandler.sendWithPromise('GetPageMode', null);
  3961. },
  3962. getAttachments: function WorkerTransport_getAttachments() {
  3963. return this.messageHandler.sendWithPromise('GetAttachments', null);
  3964. },
  3965. getJavaScript: function WorkerTransport_getJavaScript() {
  3966. return this.messageHandler.sendWithPromise('GetJavaScript', null);
  3967. },
  3968. getOutline: function WorkerTransport_getOutline() {
  3969. return this.messageHandler.sendWithPromise('GetOutline', null);
  3970. },
  3971. getMetadata: function WorkerTransport_getMetadata() {
  3972. return this.messageHandler.sendWithPromise('GetMetadata', null).then(function transportMetadata(results) {
  3973. return {
  3974. info: results[0],
  3975. metadata: results[1] ? new _metadata.Metadata(results[1]) : null
  3976. };
  3977. });
  3978. },
  3979. getStats: function WorkerTransport_getStats() {
  3980. return this.messageHandler.sendWithPromise('GetStats', null);
  3981. },
  3982. startCleanup: function WorkerTransport_startCleanup() {
  3983. var _this14 = this;
  3984. this.messageHandler.sendWithPromise('Cleanup', null).then(function () {
  3985. for (var i = 0, ii = _this14.pageCache.length; i < ii; i++) {
  3986. var page = _this14.pageCache[i];
  3987. if (page) {
  3988. page.cleanup();
  3989. }
  3990. }
  3991. _this14.commonObjs.clear();
  3992. _this14.fontLoader.clear();
  3993. });
  3994. }
  3995. };
  3996. return WorkerTransport;
  3997. }();
  3998. var PDFObjects = function PDFObjectsClosure() {
  3999. function PDFObjects() {
  4000. this.objs = Object.create(null);
  4001. }
  4002. PDFObjects.prototype = {
  4003. ensureObj: function PDFObjects_ensureObj(objId) {
  4004. if (this.objs[objId]) {
  4005. return this.objs[objId];
  4006. }
  4007. var obj = {
  4008. capability: (0, _util.createPromiseCapability)(),
  4009. data: null,
  4010. resolved: false
  4011. };
  4012. this.objs[objId] = obj;
  4013. return obj;
  4014. },
  4015. get: function PDFObjects_get(objId, callback) {
  4016. if (callback) {
  4017. this.ensureObj(objId).capability.promise.then(callback);
  4018. return null;
  4019. }
  4020. var obj = this.objs[objId];
  4021. if (!obj || !obj.resolved) {
  4022. throw new Error('Requesting object that isn\'t resolved yet ' + objId);
  4023. }
  4024. return obj.data;
  4025. },
  4026. resolve: function PDFObjects_resolve(objId, data) {
  4027. var obj = this.ensureObj(objId);
  4028. obj.resolved = true;
  4029. obj.data = data;
  4030. obj.capability.resolve(data);
  4031. },
  4032. isResolved: function PDFObjects_isResolved(objId) {
  4033. var objs = this.objs;
  4034. if (!objs[objId]) {
  4035. return false;
  4036. }
  4037. return objs[objId].resolved;
  4038. },
  4039. hasData: function PDFObjects_hasData(objId) {
  4040. return this.isResolved(objId);
  4041. },
  4042. getData: function PDFObjects_getData(objId) {
  4043. var objs = this.objs;
  4044. if (!objs[objId] || !objs[objId].resolved) {
  4045. return null;
  4046. }
  4047. return objs[objId].data;
  4048. },
  4049. clear: function PDFObjects_clear() {
  4050. this.objs = Object.create(null);
  4051. }
  4052. };
  4053. return PDFObjects;
  4054. }();
  4055. var RenderTask = function RenderTaskClosure() {
  4056. function RenderTask(internalRenderTask) {
  4057. this._internalRenderTask = internalRenderTask;
  4058. this.onContinue = null;
  4059. }
  4060. RenderTask.prototype = {
  4061. get promise() {
  4062. return this._internalRenderTask.capability.promise;
  4063. },
  4064. cancel: function RenderTask_cancel() {
  4065. this._internalRenderTask.cancel();
  4066. },
  4067. then: function RenderTask_then(onFulfilled, onRejected) {
  4068. return this.promise.then.apply(this.promise, arguments);
  4069. }
  4070. };
  4071. return RenderTask;
  4072. }();
  4073. var InternalRenderTask = function InternalRenderTaskClosure() {
  4074. var canvasInRendering = new WeakMap();
  4075. function InternalRenderTask(callback, params, objs, commonObjs, operatorList, pageNumber, canvasFactory) {
  4076. this.callback = callback;
  4077. this.params = params;
  4078. this.objs = objs;
  4079. this.commonObjs = commonObjs;
  4080. this.operatorListIdx = null;
  4081. this.operatorList = operatorList;
  4082. this.pageNumber = pageNumber;
  4083. this.canvasFactory = canvasFactory;
  4084. this.running = false;
  4085. this.graphicsReadyCallback = null;
  4086. this.graphicsReady = false;
  4087. this.useRequestAnimationFrame = false;
  4088. this.cancelled = false;
  4089. this.capability = (0, _util.createPromiseCapability)();
  4090. this.task = new RenderTask(this);
  4091. this._continueBound = this._continue.bind(this);
  4092. this._scheduleNextBound = this._scheduleNext.bind(this);
  4093. this._nextBound = this._next.bind(this);
  4094. this._canvas = params.canvasContext.canvas;
  4095. }
  4096. InternalRenderTask.prototype = {
  4097. initializeGraphics: function InternalRenderTask_initializeGraphics(transparency) {
  4098. if (this._canvas) {
  4099. if (canvasInRendering.has(this._canvas)) {
  4100. throw new Error('Cannot use the same canvas during multiple render() operations. ' + 'Use different canvas or ensure previous operations were ' + 'cancelled or completed.');
  4101. }
  4102. canvasInRendering.set(this._canvas, this);
  4103. }
  4104. if (this.cancelled) {
  4105. return;
  4106. }
  4107. if ((0, _dom_utils.getDefaultSetting)('pdfBug') && _global_scope2.default.StepperManager && _global_scope2.default.StepperManager.enabled) {
  4108. this.stepper = _global_scope2.default.StepperManager.create(this.pageNumber - 1);
  4109. this.stepper.init(this.operatorList);
  4110. this.stepper.nextBreakPoint = this.stepper.getNextBreakPoint();
  4111. }
  4112. var params = this.params;
  4113. this.gfx = new _canvas.CanvasGraphics(params.canvasContext, this.commonObjs, this.objs, this.canvasFactory, params.imageLayer);
  4114. this.gfx.beginDrawing({
  4115. transform: params.transform,
  4116. viewport: params.viewport,
  4117. transparency: transparency,
  4118. background: params.background
  4119. });
  4120. this.operatorListIdx = 0;
  4121. this.graphicsReady = true;
  4122. if (this.graphicsReadyCallback) {
  4123. this.graphicsReadyCallback();
  4124. }
  4125. },
  4126. cancel: function InternalRenderTask_cancel() {
  4127. this.running = false;
  4128. this.cancelled = true;
  4129. if (this._canvas) {
  4130. canvasInRendering.delete(this._canvas);
  4131. }
  4132. if ((0, _dom_utils.getDefaultSetting)('pdfjsNext')) {
  4133. this.callback(new _dom_utils.RenderingCancelledException('Rendering cancelled, page ' + this.pageNumber, 'canvas'));
  4134. } else {
  4135. this.callback('cancelled');
  4136. }
  4137. },
  4138. operatorListChanged: function InternalRenderTask_operatorListChanged() {
  4139. if (!this.graphicsReady) {
  4140. if (!this.graphicsReadyCallback) {
  4141. this.graphicsReadyCallback = this._continueBound;
  4142. }
  4143. return;
  4144. }
  4145. if (this.stepper) {
  4146. this.stepper.updateOperatorList(this.operatorList);
  4147. }
  4148. if (this.running) {
  4149. return;
  4150. }
  4151. this._continue();
  4152. },
  4153. _continue: function InternalRenderTask__continue() {
  4154. this.running = true;
  4155. if (this.cancelled) {
  4156. return;
  4157. }
  4158. if (this.task.onContinue) {
  4159. this.task.onContinue(this._scheduleNextBound);
  4160. } else {
  4161. this._scheduleNext();
  4162. }
  4163. },
  4164. _scheduleNext: function InternalRenderTask__scheduleNext() {
  4165. if (this.useRequestAnimationFrame && typeof window !== 'undefined') {
  4166. window.requestAnimationFrame(this._nextBound);
  4167. } else {
  4168. Promise.resolve(undefined).then(this._nextBound);
  4169. }
  4170. },
  4171. _next: function InternalRenderTask__next() {
  4172. if (this.cancelled) {
  4173. return;
  4174. }
  4175. this.operatorListIdx = this.gfx.executeOperatorList(this.operatorList, this.operatorListIdx, this._continueBound, this.stepper);
  4176. if (this.operatorListIdx === this.operatorList.argsArray.length) {
  4177. this.running = false;
  4178. if (this.operatorList.lastChunk) {
  4179. this.gfx.endDrawing();
  4180. if (this._canvas) {
  4181. canvasInRendering.delete(this._canvas);
  4182. }
  4183. this.callback();
  4184. }
  4185. }
  4186. }
  4187. };
  4188. return InternalRenderTask;
  4189. }();
  4190. var _UnsupportedManager = function UnsupportedManagerClosure() {
  4191. var listeners = [];
  4192. return {
  4193. listen: function listen(cb) {
  4194. (0, _util.deprecated)('Global UnsupportedManager.listen is used: ' + ' use PDFDocumentLoadingTask.onUnsupportedFeature instead');
  4195. listeners.push(cb);
  4196. },
  4197. notify: function notify(featureId) {
  4198. for (var i = 0, ii = listeners.length; i < ii; i++) {
  4199. listeners[i](featureId);
  4200. }
  4201. }
  4202. };
  4203. }();
  4204. var version, build;
  4205. {
  4206. exports.version = version = '1.9.478';
  4207. exports.build = build = '798e46da';
  4208. }
  4209. exports.getDocument = getDocument;
  4210. exports.LoopbackPort = LoopbackPort;
  4211. exports.PDFDataRangeTransport = PDFDataRangeTransport;
  4212. exports.PDFWorker = PDFWorker;
  4213. exports.PDFDocumentProxy = PDFDocumentProxy;
  4214. exports.PDFPageProxy = PDFPageProxy;
  4215. exports.setPDFNetworkStreamClass = setPDFNetworkStreamClass;
  4216. exports._UnsupportedManager = _UnsupportedManager;
  4217. exports.version = version;
  4218. exports.build = build;
  4219. /***/ }),
  4220. /* 31 */
  4221. /***/ (function(module, exports, __w_pdfjs_require__) {
  4222. "use strict";
  4223. Object.defineProperty(exports, "__esModule", {
  4224. value: true
  4225. });
  4226. exports.SVGGraphics = undefined;
  4227. var _util = __w_pdfjs_require__(0);
  4228. var SVGGraphics = function SVGGraphics() {
  4229. throw new Error('Not implemented: SVGGraphics');
  4230. };
  4231. {
  4232. var SVG_DEFAULTS = {
  4233. fontStyle: 'normal',
  4234. fontWeight: 'normal',
  4235. fillColor: '#000000'
  4236. };
  4237. var convertImgDataToPng = function convertImgDataToPngClosure() {
  4238. var PNG_HEADER = new Uint8Array([0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a]);
  4239. var CHUNK_WRAPPER_SIZE = 12;
  4240. var crcTable = new Int32Array(256);
  4241. for (var i = 0; i < 256; i++) {
  4242. var c = i;
  4243. for (var h = 0; h < 8; h++) {
  4244. if (c & 1) {
  4245. c = 0xedB88320 ^ c >> 1 & 0x7fffffff;
  4246. } else {
  4247. c = c >> 1 & 0x7fffffff;
  4248. }
  4249. }
  4250. crcTable[i] = c;
  4251. }
  4252. function crc32(data, start, end) {
  4253. var crc = -1;
  4254. for (var i = start; i < end; i++) {
  4255. var a = (crc ^ data[i]) & 0xff;
  4256. var b = crcTable[a];
  4257. crc = crc >>> 8 ^ b;
  4258. }
  4259. return crc ^ -1;
  4260. }
  4261. function writePngChunk(type, body, data, offset) {
  4262. var p = offset;
  4263. var len = body.length;
  4264. data[p] = len >> 24 & 0xff;
  4265. data[p + 1] = len >> 16 & 0xff;
  4266. data[p + 2] = len >> 8 & 0xff;
  4267. data[p + 3] = len & 0xff;
  4268. p += 4;
  4269. data[p] = type.charCodeAt(0) & 0xff;
  4270. data[p + 1] = type.charCodeAt(1) & 0xff;
  4271. data[p + 2] = type.charCodeAt(2) & 0xff;
  4272. data[p + 3] = type.charCodeAt(3) & 0xff;
  4273. p += 4;
  4274. data.set(body, p);
  4275. p += body.length;
  4276. var crc = crc32(data, offset + 4, p);
  4277. data[p] = crc >> 24 & 0xff;
  4278. data[p + 1] = crc >> 16 & 0xff;
  4279. data[p + 2] = crc >> 8 & 0xff;
  4280. data[p + 3] = crc & 0xff;
  4281. }
  4282. function adler32(data, start, end) {
  4283. var a = 1;
  4284. var b = 0;
  4285. for (var i = start; i < end; ++i) {
  4286. a = (a + (data[i] & 0xff)) % 65521;
  4287. b = (b + a) % 65521;
  4288. }
  4289. return b << 16 | a;
  4290. }
  4291. function deflateSync(literals) {
  4292. if (!(0, _util.isNodeJS)()) {
  4293. return deflateSyncUncompressed(literals);
  4294. }
  4295. try {
  4296. var input;
  4297. if (parseInt(process.versions.node) >= 8) {
  4298. input = literals;
  4299. } else {
  4300. input = new Buffer(literals);
  4301. }
  4302. var output = require('zlib').deflateSync(input, { level: 9 });
  4303. return output instanceof Uint8Array ? output : new Uint8Array(output);
  4304. } catch (e) {
  4305. (0, _util.warn)('Not compressing PNG because zlib.deflateSync is unavailable: ' + e);
  4306. }
  4307. return deflateSyncUncompressed(literals);
  4308. }
  4309. function deflateSyncUncompressed(literals) {
  4310. var len = literals.length;
  4311. var maxBlockLength = 0xFFFF;
  4312. var deflateBlocks = Math.ceil(len / maxBlockLength);
  4313. var idat = new Uint8Array(2 + len + deflateBlocks * 5 + 4);
  4314. var pi = 0;
  4315. idat[pi++] = 0x78;
  4316. idat[pi++] = 0x9c;
  4317. var pos = 0;
  4318. while (len > maxBlockLength) {
  4319. idat[pi++] = 0x00;
  4320. idat[pi++] = 0xff;
  4321. idat[pi++] = 0xff;
  4322. idat[pi++] = 0x00;
  4323. idat[pi++] = 0x00;
  4324. idat.set(literals.subarray(pos, pos + maxBlockLength), pi);
  4325. pi += maxBlockLength;
  4326. pos += maxBlockLength;
  4327. len -= maxBlockLength;
  4328. }
  4329. idat[pi++] = 0x01;
  4330. idat[pi++] = len & 0xff;
  4331. idat[pi++] = len >> 8 & 0xff;
  4332. idat[pi++] = ~len & 0xffff & 0xff;
  4333. idat[pi++] = (~len & 0xffff) >> 8 & 0xff;
  4334. idat.set(literals.subarray(pos), pi);
  4335. pi += literals.length - pos;
  4336. var adler = adler32(literals, 0, literals.length);
  4337. idat[pi++] = adler >> 24 & 0xff;
  4338. idat[pi++] = adler >> 16 & 0xff;
  4339. idat[pi++] = adler >> 8 & 0xff;
  4340. idat[pi++] = adler & 0xff;
  4341. return idat;
  4342. }
  4343. function encode(imgData, kind, forceDataSchema) {
  4344. var width = imgData.width;
  4345. var height = imgData.height;
  4346. var bitDepth, colorType, lineSize;
  4347. var bytes = imgData.data;
  4348. switch (kind) {
  4349. case _util.ImageKind.GRAYSCALE_1BPP:
  4350. colorType = 0;
  4351. bitDepth = 1;
  4352. lineSize = width + 7 >> 3;
  4353. break;
  4354. case _util.ImageKind.RGB_24BPP:
  4355. colorType = 2;
  4356. bitDepth = 8;
  4357. lineSize = width * 3;
  4358. break;
  4359. case _util.ImageKind.RGBA_32BPP:
  4360. colorType = 6;
  4361. bitDepth = 8;
  4362. lineSize = width * 4;
  4363. break;
  4364. default:
  4365. throw new Error('invalid format');
  4366. }
  4367. var literals = new Uint8Array((1 + lineSize) * height);
  4368. var offsetLiterals = 0,
  4369. offsetBytes = 0;
  4370. var y, i;
  4371. for (y = 0; y < height; ++y) {
  4372. literals[offsetLiterals++] = 0;
  4373. literals.set(bytes.subarray(offsetBytes, offsetBytes + lineSize), offsetLiterals);
  4374. offsetBytes += lineSize;
  4375. offsetLiterals += lineSize;
  4376. }
  4377. if (kind === _util.ImageKind.GRAYSCALE_1BPP) {
  4378. offsetLiterals = 0;
  4379. for (y = 0; y < height; y++) {
  4380. offsetLiterals++;
  4381. for (i = 0; i < lineSize; i++) {
  4382. literals[offsetLiterals++] ^= 0xFF;
  4383. }
  4384. }
  4385. }
  4386. var ihdr = new Uint8Array([width >> 24 & 0xff, width >> 16 & 0xff, width >> 8 & 0xff, width & 0xff, height >> 24 & 0xff, height >> 16 & 0xff, height >> 8 & 0xff, height & 0xff, bitDepth, colorType, 0x00, 0x00, 0x00]);
  4387. var idat = deflateSync(literals);
  4388. var pngLength = PNG_HEADER.length + CHUNK_WRAPPER_SIZE * 3 + ihdr.length + idat.length;
  4389. var data = new Uint8Array(pngLength);
  4390. var offset = 0;
  4391. data.set(PNG_HEADER, offset);
  4392. offset += PNG_HEADER.length;
  4393. writePngChunk('IHDR', ihdr, data, offset);
  4394. offset += CHUNK_WRAPPER_SIZE + ihdr.length;
  4395. writePngChunk('IDATA', idat, data, offset);
  4396. offset += CHUNK_WRAPPER_SIZE + idat.length;
  4397. writePngChunk('IEND', new Uint8Array(0), data, offset);
  4398. return (0, _util.createObjectURL)(data, 'image/png', forceDataSchema);
  4399. }
  4400. return function convertImgDataToPng(imgData, forceDataSchema) {
  4401. var kind = imgData.kind === undefined ? _util.ImageKind.GRAYSCALE_1BPP : imgData.kind;
  4402. return encode(imgData, kind, forceDataSchema);
  4403. };
  4404. }();
  4405. var SVGExtraState = function SVGExtraStateClosure() {
  4406. function SVGExtraState() {
  4407. this.fontSizeScale = 1;
  4408. this.fontWeight = SVG_DEFAULTS.fontWeight;
  4409. this.fontSize = 0;
  4410. this.textMatrix = _util.IDENTITY_MATRIX;
  4411. this.fontMatrix = _util.FONT_IDENTITY_MATRIX;
  4412. this.leading = 0;
  4413. this.x = 0;
  4414. this.y = 0;
  4415. this.lineX = 0;
  4416. this.lineY = 0;
  4417. this.charSpacing = 0;
  4418. this.wordSpacing = 0;
  4419. this.textHScale = 1;
  4420. this.textRise = 0;
  4421. this.fillColor = SVG_DEFAULTS.fillColor;
  4422. this.strokeColor = '#000000';
  4423. this.fillAlpha = 1;
  4424. this.strokeAlpha = 1;
  4425. this.lineWidth = 1;
  4426. this.lineJoin = '';
  4427. this.lineCap = '';
  4428. this.miterLimit = 0;
  4429. this.dashArray = [];
  4430. this.dashPhase = 0;
  4431. this.dependencies = [];
  4432. this.activeClipUrl = null;
  4433. this.clipGroup = null;
  4434. this.maskId = '';
  4435. }
  4436. SVGExtraState.prototype = {
  4437. clone: function SVGExtraState_clone() {
  4438. return Object.create(this);
  4439. },
  4440. setCurrentPoint: function SVGExtraState_setCurrentPoint(x, y) {
  4441. this.x = x;
  4442. this.y = y;
  4443. }
  4444. };
  4445. return SVGExtraState;
  4446. }();
  4447. exports.SVGGraphics = SVGGraphics = function SVGGraphicsClosure() {
  4448. function opListToTree(opList) {
  4449. var opTree = [];
  4450. var tmp = [];
  4451. var opListLen = opList.length;
  4452. for (var x = 0; x < opListLen; x++) {
  4453. if (opList[x].fn === 'save') {
  4454. opTree.push({
  4455. 'fnId': 92,
  4456. 'fn': 'group',
  4457. 'items': []
  4458. });
  4459. tmp.push(opTree);
  4460. opTree = opTree[opTree.length - 1].items;
  4461. continue;
  4462. }
  4463. if (opList[x].fn === 'restore') {
  4464. opTree = tmp.pop();
  4465. } else {
  4466. opTree.push(opList[x]);
  4467. }
  4468. }
  4469. return opTree;
  4470. }
  4471. function pf(value) {
  4472. if (value === (value | 0)) {
  4473. return value.toString();
  4474. }
  4475. var s = value.toFixed(10);
  4476. var i = s.length - 1;
  4477. if (s[i] !== '0') {
  4478. return s;
  4479. }
  4480. do {
  4481. i--;
  4482. } while (s[i] === '0');
  4483. return s.substr(0, s[i] === '.' ? i : i + 1);
  4484. }
  4485. function pm(m) {
  4486. if (m[4] === 0 && m[5] === 0) {
  4487. if (m[1] === 0 && m[2] === 0) {
  4488. if (m[0] === 1 && m[3] === 1) {
  4489. return '';
  4490. }
  4491. return 'scale(' + pf(m[0]) + ' ' + pf(m[3]) + ')';
  4492. }
  4493. if (m[0] === m[3] && m[1] === -m[2]) {
  4494. var a = Math.acos(m[0]) * 180 / Math.PI;
  4495. return 'rotate(' + pf(a) + ')';
  4496. }
  4497. } else {
  4498. if (m[0] === 1 && m[1] === 0 && m[2] === 0 && m[3] === 1) {
  4499. return 'translate(' + pf(m[4]) + ' ' + pf(m[5]) + ')';
  4500. }
  4501. }
  4502. return 'matrix(' + pf(m[0]) + ' ' + pf(m[1]) + ' ' + pf(m[2]) + ' ' + pf(m[3]) + ' ' + pf(m[4]) + ' ' + pf(m[5]) + ')';
  4503. }
  4504. function SVGGraphics(commonObjs, objs, forceDataSchema) {
  4505. this.current = new SVGExtraState();
  4506. this.transformMatrix = _util.IDENTITY_MATRIX;
  4507. this.transformStack = [];
  4508. this.extraStack = [];
  4509. this.commonObjs = commonObjs;
  4510. this.objs = objs;
  4511. this.pendingClip = null;
  4512. this.pendingEOFill = false;
  4513. this.embedFonts = false;
  4514. this.embeddedFonts = Object.create(null);
  4515. this.cssStyle = null;
  4516. this.forceDataSchema = !!forceDataSchema;
  4517. }
  4518. var NS = 'http://www.w3.org/2000/svg';
  4519. var XML_NS = 'http://www.w3.org/XML/1998/namespace';
  4520. var XLINK_NS = 'http://www.w3.org/1999/xlink';
  4521. var LINE_CAP_STYLES = ['butt', 'round', 'square'];
  4522. var LINE_JOIN_STYLES = ['miter', 'round', 'bevel'];
  4523. var clipCount = 0;
  4524. var maskCount = 0;
  4525. SVGGraphics.prototype = {
  4526. save: function SVGGraphics_save() {
  4527. this.transformStack.push(this.transformMatrix);
  4528. var old = this.current;
  4529. this.extraStack.push(old);
  4530. this.current = old.clone();
  4531. },
  4532. restore: function SVGGraphics_restore() {
  4533. this.transformMatrix = this.transformStack.pop();
  4534. this.current = this.extraStack.pop();
  4535. this.pendingClip = null;
  4536. this.tgrp = null;
  4537. },
  4538. group: function SVGGraphics_group(items) {
  4539. this.save();
  4540. this.executeOpTree(items);
  4541. this.restore();
  4542. },
  4543. loadDependencies: function SVGGraphics_loadDependencies(operatorList) {
  4544. var _this = this;
  4545. var fnArray = operatorList.fnArray;
  4546. var fnArrayLen = fnArray.length;
  4547. var argsArray = operatorList.argsArray;
  4548. for (var i = 0; i < fnArrayLen; i++) {
  4549. if (_util.OPS.dependency === fnArray[i]) {
  4550. var deps = argsArray[i];
  4551. for (var n = 0, nn = deps.length; n < nn; n++) {
  4552. var obj = deps[n];
  4553. var common = obj.substring(0, 2) === 'g_';
  4554. var promise;
  4555. if (common) {
  4556. promise = new Promise(function (resolve) {
  4557. _this.commonObjs.get(obj, resolve);
  4558. });
  4559. } else {
  4560. promise = new Promise(function (resolve) {
  4561. _this.objs.get(obj, resolve);
  4562. });
  4563. }
  4564. this.current.dependencies.push(promise);
  4565. }
  4566. }
  4567. }
  4568. return Promise.all(this.current.dependencies);
  4569. },
  4570. transform: function SVGGraphics_transform(a, b, c, d, e, f) {
  4571. var transformMatrix = [a, b, c, d, e, f];
  4572. this.transformMatrix = _util.Util.transform(this.transformMatrix, transformMatrix);
  4573. this.tgrp = null;
  4574. },
  4575. getSVG: function SVGGraphics_getSVG(operatorList, viewport) {
  4576. var _this2 = this;
  4577. this.viewport = viewport;
  4578. var svgElement = this._initialize(viewport);
  4579. return this.loadDependencies(operatorList).then(function () {
  4580. _this2.transformMatrix = _util.IDENTITY_MATRIX;
  4581. var opTree = _this2.convertOpList(operatorList);
  4582. _this2.executeOpTree(opTree);
  4583. return svgElement;
  4584. });
  4585. },
  4586. convertOpList: function SVGGraphics_convertOpList(operatorList) {
  4587. var argsArray = operatorList.argsArray;
  4588. var fnArray = operatorList.fnArray;
  4589. var fnArrayLen = fnArray.length;
  4590. var REVOPS = [];
  4591. var opList = [];
  4592. for (var op in _util.OPS) {
  4593. REVOPS[_util.OPS[op]] = op;
  4594. }
  4595. for (var x = 0; x < fnArrayLen; x++) {
  4596. var fnId = fnArray[x];
  4597. opList.push({
  4598. 'fnId': fnId,
  4599. 'fn': REVOPS[fnId],
  4600. 'args': argsArray[x]
  4601. });
  4602. }
  4603. return opListToTree(opList);
  4604. },
  4605. executeOpTree: function SVGGraphics_executeOpTree(opTree) {
  4606. var opTreeLen = opTree.length;
  4607. for (var x = 0; x < opTreeLen; x++) {
  4608. var fn = opTree[x].fn;
  4609. var fnId = opTree[x].fnId;
  4610. var args = opTree[x].args;
  4611. switch (fnId | 0) {
  4612. case _util.OPS.beginText:
  4613. this.beginText();
  4614. break;
  4615. case _util.OPS.setLeading:
  4616. this.setLeading(args);
  4617. break;
  4618. case _util.OPS.setLeadingMoveText:
  4619. this.setLeadingMoveText(args[0], args[1]);
  4620. break;
  4621. case _util.OPS.setFont:
  4622. this.setFont(args);
  4623. break;
  4624. case _util.OPS.showText:
  4625. this.showText(args[0]);
  4626. break;
  4627. case _util.OPS.showSpacedText:
  4628. this.showText(args[0]);
  4629. break;
  4630. case _util.OPS.endText:
  4631. this.endText();
  4632. break;
  4633. case _util.OPS.moveText:
  4634. this.moveText(args[0], args[1]);
  4635. break;
  4636. case _util.OPS.setCharSpacing:
  4637. this.setCharSpacing(args[0]);
  4638. break;
  4639. case _util.OPS.setWordSpacing:
  4640. this.setWordSpacing(args[0]);
  4641. break;
  4642. case _util.OPS.setHScale:
  4643. this.setHScale(args[0]);
  4644. break;
  4645. case _util.OPS.setTextMatrix:
  4646. this.setTextMatrix(args[0], args[1], args[2], args[3], args[4], args[5]);
  4647. break;
  4648. case _util.OPS.setLineWidth:
  4649. this.setLineWidth(args[0]);
  4650. break;
  4651. case _util.OPS.setLineJoin:
  4652. this.setLineJoin(args[0]);
  4653. break;
  4654. case _util.OPS.setLineCap:
  4655. this.setLineCap(args[0]);
  4656. break;
  4657. case _util.OPS.setMiterLimit:
  4658. this.setMiterLimit(args[0]);
  4659. break;
  4660. case _util.OPS.setFillRGBColor:
  4661. this.setFillRGBColor(args[0], args[1], args[2]);
  4662. break;
  4663. case _util.OPS.setStrokeRGBColor:
  4664. this.setStrokeRGBColor(args[0], args[1], args[2]);
  4665. break;
  4666. case _util.OPS.setDash:
  4667. this.setDash(args[0], args[1]);
  4668. break;
  4669. case _util.OPS.setGState:
  4670. this.setGState(args[0]);
  4671. break;
  4672. case _util.OPS.fill:
  4673. this.fill();
  4674. break;
  4675. case _util.OPS.eoFill:
  4676. this.eoFill();
  4677. break;
  4678. case _util.OPS.stroke:
  4679. this.stroke();
  4680. break;
  4681. case _util.OPS.fillStroke:
  4682. this.fillStroke();
  4683. break;
  4684. case _util.OPS.eoFillStroke:
  4685. this.eoFillStroke();
  4686. break;
  4687. case _util.OPS.clip:
  4688. this.clip('nonzero');
  4689. break;
  4690. case _util.OPS.eoClip:
  4691. this.clip('evenodd');
  4692. break;
  4693. case _util.OPS.paintSolidColorImageMask:
  4694. this.paintSolidColorImageMask();
  4695. break;
  4696. case _util.OPS.paintJpegXObject:
  4697. this.paintJpegXObject(args[0], args[1], args[2]);
  4698. break;
  4699. case _util.OPS.paintImageXObject:
  4700. this.paintImageXObject(args[0]);
  4701. break;
  4702. case _util.OPS.paintInlineImageXObject:
  4703. this.paintInlineImageXObject(args[0]);
  4704. break;
  4705. case _util.OPS.paintImageMaskXObject:
  4706. this.paintImageMaskXObject(args[0]);
  4707. break;
  4708. case _util.OPS.paintFormXObjectBegin:
  4709. this.paintFormXObjectBegin(args[0], args[1]);
  4710. break;
  4711. case _util.OPS.paintFormXObjectEnd:
  4712. this.paintFormXObjectEnd();
  4713. break;
  4714. case _util.OPS.closePath:
  4715. this.closePath();
  4716. break;
  4717. case _util.OPS.closeStroke:
  4718. this.closeStroke();
  4719. break;
  4720. case _util.OPS.closeFillStroke:
  4721. this.closeFillStroke();
  4722. break;
  4723. case _util.OPS.nextLine:
  4724. this.nextLine();
  4725. break;
  4726. case _util.OPS.transform:
  4727. this.transform(args[0], args[1], args[2], args[3], args[4], args[5]);
  4728. break;
  4729. case _util.OPS.constructPath:
  4730. this.constructPath(args[0], args[1]);
  4731. break;
  4732. case _util.OPS.endPath:
  4733. this.endPath();
  4734. break;
  4735. case 92:
  4736. this.group(opTree[x].items);
  4737. break;
  4738. default:
  4739. (0, _util.warn)('Unimplemented operator ' + fn);
  4740. break;
  4741. }
  4742. }
  4743. },
  4744. setWordSpacing: function SVGGraphics_setWordSpacing(wordSpacing) {
  4745. this.current.wordSpacing = wordSpacing;
  4746. },
  4747. setCharSpacing: function SVGGraphics_setCharSpacing(charSpacing) {
  4748. this.current.charSpacing = charSpacing;
  4749. },
  4750. nextLine: function SVGGraphics_nextLine() {
  4751. this.moveText(0, this.current.leading);
  4752. },
  4753. setTextMatrix: function SVGGraphics_setTextMatrix(a, b, c, d, e, f) {
  4754. var current = this.current;
  4755. this.current.textMatrix = this.current.lineMatrix = [a, b, c, d, e, f];
  4756. this.current.x = this.current.lineX = 0;
  4757. this.current.y = this.current.lineY = 0;
  4758. current.xcoords = [];
  4759. current.tspan = document.createElementNS(NS, 'svg:tspan');
  4760. current.tspan.setAttributeNS(null, 'font-family', current.fontFamily);
  4761. current.tspan.setAttributeNS(null, 'font-size', pf(current.fontSize) + 'px');
  4762. current.tspan.setAttributeNS(null, 'y', pf(-current.y));
  4763. current.txtElement = document.createElementNS(NS, 'svg:text');
  4764. current.txtElement.appendChild(current.tspan);
  4765. },
  4766. beginText: function SVGGraphics_beginText() {
  4767. this.current.x = this.current.lineX = 0;
  4768. this.current.y = this.current.lineY = 0;
  4769. this.current.textMatrix = _util.IDENTITY_MATRIX;
  4770. this.current.lineMatrix = _util.IDENTITY_MATRIX;
  4771. this.current.tspan = document.createElementNS(NS, 'svg:tspan');
  4772. this.current.txtElement = document.createElementNS(NS, 'svg:text');
  4773. this.current.txtgrp = document.createElementNS(NS, 'svg:g');
  4774. this.current.xcoords = [];
  4775. },
  4776. moveText: function SVGGraphics_moveText(x, y) {
  4777. var current = this.current;
  4778. this.current.x = this.current.lineX += x;
  4779. this.current.y = this.current.lineY += y;
  4780. current.xcoords = [];
  4781. current.tspan = document.createElementNS(NS, 'svg:tspan');
  4782. current.tspan.setAttributeNS(null, 'font-family', current.fontFamily);
  4783. current.tspan.setAttributeNS(null, 'font-size', pf(current.fontSize) + 'px');
  4784. current.tspan.setAttributeNS(null, 'y', pf(-current.y));
  4785. },
  4786. showText: function SVGGraphics_showText(glyphs) {
  4787. var current = this.current;
  4788. var font = current.font;
  4789. var fontSize = current.fontSize;
  4790. if (fontSize === 0) {
  4791. return;
  4792. }
  4793. var charSpacing = current.charSpacing;
  4794. var wordSpacing = current.wordSpacing;
  4795. var fontDirection = current.fontDirection;
  4796. var textHScale = current.textHScale * fontDirection;
  4797. var glyphsLength = glyphs.length;
  4798. var vertical = font.vertical;
  4799. var widthAdvanceScale = fontSize * current.fontMatrix[0];
  4800. var x = 0,
  4801. i;
  4802. for (i = 0; i < glyphsLength; ++i) {
  4803. var glyph = glyphs[i];
  4804. if (glyph === null) {
  4805. x += fontDirection * wordSpacing;
  4806. continue;
  4807. } else if ((0, _util.isNum)(glyph)) {
  4808. x += -glyph * fontSize * 0.001;
  4809. continue;
  4810. }
  4811. var width = glyph.width;
  4812. var character = glyph.fontChar;
  4813. var spacing = (glyph.isSpace ? wordSpacing : 0) + charSpacing;
  4814. var charWidth = width * widthAdvanceScale + spacing * fontDirection;
  4815. if (!glyph.isInFont && !font.missingFile) {
  4816. x += charWidth;
  4817. continue;
  4818. }
  4819. current.xcoords.push(current.x + x * textHScale);
  4820. current.tspan.textContent += character;
  4821. x += charWidth;
  4822. }
  4823. if (vertical) {
  4824. current.y -= x * textHScale;
  4825. } else {
  4826. current.x += x * textHScale;
  4827. }
  4828. current.tspan.setAttributeNS(null, 'x', current.xcoords.map(pf).join(' '));
  4829. current.tspan.setAttributeNS(null, 'y', pf(-current.y));
  4830. current.tspan.setAttributeNS(null, 'font-family', current.fontFamily);
  4831. current.tspan.setAttributeNS(null, 'font-size', pf(current.fontSize) + 'px');
  4832. if (current.fontStyle !== SVG_DEFAULTS.fontStyle) {
  4833. current.tspan.setAttributeNS(null, 'font-style', current.fontStyle);
  4834. }
  4835. if (current.fontWeight !== SVG_DEFAULTS.fontWeight) {
  4836. current.tspan.setAttributeNS(null, 'font-weight', current.fontWeight);
  4837. }
  4838. if (current.fillColor !== SVG_DEFAULTS.fillColor) {
  4839. current.tspan.setAttributeNS(null, 'fill', current.fillColor);
  4840. }
  4841. current.txtElement.setAttributeNS(null, 'transform', pm(current.textMatrix) + ' scale(1, -1)');
  4842. current.txtElement.setAttributeNS(XML_NS, 'xml:space', 'preserve');
  4843. current.txtElement.appendChild(current.tspan);
  4844. current.txtgrp.appendChild(current.txtElement);
  4845. this._ensureTransformGroup().appendChild(current.txtElement);
  4846. },
  4847. setLeadingMoveText: function SVGGraphics_setLeadingMoveText(x, y) {
  4848. this.setLeading(-y);
  4849. this.moveText(x, y);
  4850. },
  4851. addFontStyle: function SVGGraphics_addFontStyle(fontObj) {
  4852. if (!this.cssStyle) {
  4853. this.cssStyle = document.createElementNS(NS, 'svg:style');
  4854. this.cssStyle.setAttributeNS(null, 'type', 'text/css');
  4855. this.defs.appendChild(this.cssStyle);
  4856. }
  4857. var url = (0, _util.createObjectURL)(fontObj.data, fontObj.mimetype, this.forceDataSchema);
  4858. this.cssStyle.textContent += '@font-face { font-family: "' + fontObj.loadedName + '";' + ' src: url(' + url + '); }\n';
  4859. },
  4860. setFont: function SVGGraphics_setFont(details) {
  4861. var current = this.current;
  4862. var fontObj = this.commonObjs.get(details[0]);
  4863. var size = details[1];
  4864. this.current.font = fontObj;
  4865. if (this.embedFonts && fontObj.data && !this.embeddedFonts[fontObj.loadedName]) {
  4866. this.addFontStyle(fontObj);
  4867. this.embeddedFonts[fontObj.loadedName] = fontObj;
  4868. }
  4869. current.fontMatrix = fontObj.fontMatrix ? fontObj.fontMatrix : _util.FONT_IDENTITY_MATRIX;
  4870. var bold = fontObj.black ? fontObj.bold ? 'bolder' : 'bold' : fontObj.bold ? 'bold' : 'normal';
  4871. var italic = fontObj.italic ? 'italic' : 'normal';
  4872. if (size < 0) {
  4873. size = -size;
  4874. current.fontDirection = -1;
  4875. } else {
  4876. current.fontDirection = 1;
  4877. }
  4878. current.fontSize = size;
  4879. current.fontFamily = fontObj.loadedName;
  4880. current.fontWeight = bold;
  4881. current.fontStyle = italic;
  4882. current.tspan = document.createElementNS(NS, 'svg:tspan');
  4883. current.tspan.setAttributeNS(null, 'y', pf(-current.y));
  4884. current.xcoords = [];
  4885. },
  4886. endText: function SVGGraphics_endText() {},
  4887. setLineWidth: function SVGGraphics_setLineWidth(width) {
  4888. this.current.lineWidth = width;
  4889. },
  4890. setLineCap: function SVGGraphics_setLineCap(style) {
  4891. this.current.lineCap = LINE_CAP_STYLES[style];
  4892. },
  4893. setLineJoin: function SVGGraphics_setLineJoin(style) {
  4894. this.current.lineJoin = LINE_JOIN_STYLES[style];
  4895. },
  4896. setMiterLimit: function SVGGraphics_setMiterLimit(limit) {
  4897. this.current.miterLimit = limit;
  4898. },
  4899. setStrokeAlpha: function SVGGraphics_setStrokeAlpha(strokeAlpha) {
  4900. this.current.strokeAlpha = strokeAlpha;
  4901. },
  4902. setStrokeRGBColor: function SVGGraphics_setStrokeRGBColor(r, g, b) {
  4903. var color = _util.Util.makeCssRgb(r, g, b);
  4904. this.current.strokeColor = color;
  4905. },
  4906. setFillAlpha: function SVGGraphics_setFillAlpha(fillAlpha) {
  4907. this.current.fillAlpha = fillAlpha;
  4908. },
  4909. setFillRGBColor: function SVGGraphics_setFillRGBColor(r, g, b) {
  4910. var color = _util.Util.makeCssRgb(r, g, b);
  4911. this.current.fillColor = color;
  4912. this.current.tspan = document.createElementNS(NS, 'svg:tspan');
  4913. this.current.xcoords = [];
  4914. },
  4915. setDash: function SVGGraphics_setDash(dashArray, dashPhase) {
  4916. this.current.dashArray = dashArray;
  4917. this.current.dashPhase = dashPhase;
  4918. },
  4919. constructPath: function SVGGraphics_constructPath(ops, args) {
  4920. var current = this.current;
  4921. var x = current.x,
  4922. y = current.y;
  4923. current.path = document.createElementNS(NS, 'svg:path');
  4924. var d = [];
  4925. var opLength = ops.length;
  4926. for (var i = 0, j = 0; i < opLength; i++) {
  4927. switch (ops[i] | 0) {
  4928. case _util.OPS.rectangle:
  4929. x = args[j++];
  4930. y = args[j++];
  4931. var width = args[j++];
  4932. var height = args[j++];
  4933. var xw = x + width;
  4934. var yh = y + height;
  4935. d.push('M', pf(x), pf(y), 'L', pf(xw), pf(y), 'L', pf(xw), pf(yh), 'L', pf(x), pf(yh), 'Z');
  4936. break;
  4937. case _util.OPS.moveTo:
  4938. x = args[j++];
  4939. y = args[j++];
  4940. d.push('M', pf(x), pf(y));
  4941. break;
  4942. case _util.OPS.lineTo:
  4943. x = args[j++];
  4944. y = args[j++];
  4945. d.push('L', pf(x), pf(y));
  4946. break;
  4947. case _util.OPS.curveTo:
  4948. x = args[j + 4];
  4949. y = args[j + 5];
  4950. d.push('C', pf(args[j]), pf(args[j + 1]), pf(args[j + 2]), pf(args[j + 3]), pf(x), pf(y));
  4951. j += 6;
  4952. break;
  4953. case _util.OPS.curveTo2:
  4954. x = args[j + 2];
  4955. y = args[j + 3];
  4956. d.push('C', pf(x), pf(y), pf(args[j]), pf(args[j + 1]), pf(args[j + 2]), pf(args[j + 3]));
  4957. j += 4;
  4958. break;
  4959. case _util.OPS.curveTo3:
  4960. x = args[j + 2];
  4961. y = args[j + 3];
  4962. d.push('C', pf(args[j]), pf(args[j + 1]), pf(x), pf(y), pf(x), pf(y));
  4963. j += 4;
  4964. break;
  4965. case _util.OPS.closePath:
  4966. d.push('Z');
  4967. break;
  4968. }
  4969. }
  4970. current.path.setAttributeNS(null, 'd', d.join(' '));
  4971. current.path.setAttributeNS(null, 'fill', 'none');
  4972. this._ensureTransformGroup().appendChild(current.path);
  4973. current.element = current.path;
  4974. current.setCurrentPoint(x, y);
  4975. },
  4976. endPath: function SVGGraphics_endPath() {
  4977. if (!this.pendingClip) {
  4978. return;
  4979. }
  4980. var current = this.current;
  4981. var clipId = 'clippath' + clipCount;
  4982. clipCount++;
  4983. var clipPath = document.createElementNS(NS, 'svg:clipPath');
  4984. clipPath.setAttributeNS(null, 'id', clipId);
  4985. clipPath.setAttributeNS(null, 'transform', pm(this.transformMatrix));
  4986. var clipElement = current.element.cloneNode();
  4987. if (this.pendingClip === 'evenodd') {
  4988. clipElement.setAttributeNS(null, 'clip-rule', 'evenodd');
  4989. } else {
  4990. clipElement.setAttributeNS(null, 'clip-rule', 'nonzero');
  4991. }
  4992. this.pendingClip = null;
  4993. clipPath.appendChild(clipElement);
  4994. this.defs.appendChild(clipPath);
  4995. if (current.activeClipUrl) {
  4996. current.clipGroup = null;
  4997. this.extraStack.forEach(function (prev) {
  4998. prev.clipGroup = null;
  4999. });
  5000. }
  5001. current.activeClipUrl = 'url(#' + clipId + ')';
  5002. this.tgrp = null;
  5003. },
  5004. clip: function SVGGraphics_clip(type) {
  5005. this.pendingClip = type;
  5006. },
  5007. closePath: function SVGGraphics_closePath() {
  5008. var current = this.current;
  5009. var d = current.path.getAttributeNS(null, 'd');
  5010. d += 'Z';
  5011. current.path.setAttributeNS(null, 'd', d);
  5012. },
  5013. setLeading: function SVGGraphics_setLeading(leading) {
  5014. this.current.leading = -leading;
  5015. },
  5016. setTextRise: function SVGGraphics_setTextRise(textRise) {
  5017. this.current.textRise = textRise;
  5018. },
  5019. setHScale: function SVGGraphics_setHScale(scale) {
  5020. this.current.textHScale = scale / 100;
  5021. },
  5022. setGState: function SVGGraphics_setGState(states) {
  5023. for (var i = 0, ii = states.length; i < ii; i++) {
  5024. var state = states[i];
  5025. var key = state[0];
  5026. var value = state[1];
  5027. switch (key) {
  5028. case 'LW':
  5029. this.setLineWidth(value);
  5030. break;
  5031. case 'LC':
  5032. this.setLineCap(value);
  5033. break;
  5034. case 'LJ':
  5035. this.setLineJoin(value);
  5036. break;
  5037. case 'ML':
  5038. this.setMiterLimit(value);
  5039. break;
  5040. case 'D':
  5041. this.setDash(value[0], value[1]);
  5042. break;
  5043. case 'Font':
  5044. this.setFont(value);
  5045. break;
  5046. case 'CA':
  5047. this.setStrokeAlpha(value);
  5048. break;
  5049. case 'ca':
  5050. this.setFillAlpha(value);
  5051. break;
  5052. default:
  5053. (0, _util.warn)('Unimplemented graphic state ' + key);
  5054. break;
  5055. }
  5056. }
  5057. },
  5058. fill: function SVGGraphics_fill() {
  5059. var current = this.current;
  5060. current.element.setAttributeNS(null, 'fill', current.fillColor);
  5061. current.element.setAttributeNS(null, 'fill-opacity', current.fillAlpha);
  5062. },
  5063. stroke: function SVGGraphics_stroke() {
  5064. var current = this.current;
  5065. current.element.setAttributeNS(null, 'stroke', current.strokeColor);
  5066. current.element.setAttributeNS(null, 'stroke-opacity', current.strokeAlpha);
  5067. current.element.setAttributeNS(null, 'stroke-miterlimit', pf(current.miterLimit));
  5068. current.element.setAttributeNS(null, 'stroke-linecap', current.lineCap);
  5069. current.element.setAttributeNS(null, 'stroke-linejoin', current.lineJoin);
  5070. current.element.setAttributeNS(null, 'stroke-width', pf(current.lineWidth) + 'px');
  5071. current.element.setAttributeNS(null, 'stroke-dasharray', current.dashArray.map(pf).join(' '));
  5072. current.element.setAttributeNS(null, 'stroke-dashoffset', pf(current.dashPhase) + 'px');
  5073. current.element.setAttributeNS(null, 'fill', 'none');
  5074. },
  5075. eoFill: function SVGGraphics_eoFill() {
  5076. this.current.element.setAttributeNS(null, 'fill-rule', 'evenodd');
  5077. this.fill();
  5078. },
  5079. fillStroke: function SVGGraphics_fillStroke() {
  5080. this.stroke();
  5081. this.fill();
  5082. },
  5083. eoFillStroke: function SVGGraphics_eoFillStroke() {
  5084. this.current.element.setAttributeNS(null, 'fill-rule', 'evenodd');
  5085. this.fillStroke();
  5086. },
  5087. closeStroke: function SVGGraphics_closeStroke() {
  5088. this.closePath();
  5089. this.stroke();
  5090. },
  5091. closeFillStroke: function SVGGraphics_closeFillStroke() {
  5092. this.closePath();
  5093. this.fillStroke();
  5094. },
  5095. paintSolidColorImageMask: function SVGGraphics_paintSolidColorImageMask() {
  5096. var current = this.current;
  5097. var rect = document.createElementNS(NS, 'svg:rect');
  5098. rect.setAttributeNS(null, 'x', '0');
  5099. rect.setAttributeNS(null, 'y', '0');
  5100. rect.setAttributeNS(null, 'width', '1px');
  5101. rect.setAttributeNS(null, 'height', '1px');
  5102. rect.setAttributeNS(null, 'fill', current.fillColor);
  5103. this._ensureTransformGroup().appendChild(rect);
  5104. },
  5105. paintJpegXObject: function SVGGraphics_paintJpegXObject(objId, w, h) {
  5106. var imgObj = this.objs.get(objId);
  5107. var imgEl = document.createElementNS(NS, 'svg:image');
  5108. imgEl.setAttributeNS(XLINK_NS, 'xlink:href', imgObj.src);
  5109. imgEl.setAttributeNS(null, 'width', pf(w));
  5110. imgEl.setAttributeNS(null, 'height', pf(h));
  5111. imgEl.setAttributeNS(null, 'x', '0');
  5112. imgEl.setAttributeNS(null, 'y', pf(-h));
  5113. imgEl.setAttributeNS(null, 'transform', 'scale(' + pf(1 / w) + ' ' + pf(-1 / h) + ')');
  5114. this._ensureTransformGroup().appendChild(imgEl);
  5115. },
  5116. paintImageXObject: function SVGGraphics_paintImageXObject(objId) {
  5117. var imgData = this.objs.get(objId);
  5118. if (!imgData) {
  5119. (0, _util.warn)('Dependent image isn\'t ready yet');
  5120. return;
  5121. }
  5122. this.paintInlineImageXObject(imgData);
  5123. },
  5124. paintInlineImageXObject: function SVGGraphics_paintInlineImageXObject(imgData, mask) {
  5125. var width = imgData.width;
  5126. var height = imgData.height;
  5127. var imgSrc = convertImgDataToPng(imgData, this.forceDataSchema);
  5128. var cliprect = document.createElementNS(NS, 'svg:rect');
  5129. cliprect.setAttributeNS(null, 'x', '0');
  5130. cliprect.setAttributeNS(null, 'y', '0');
  5131. cliprect.setAttributeNS(null, 'width', pf(width));
  5132. cliprect.setAttributeNS(null, 'height', pf(height));
  5133. this.current.element = cliprect;
  5134. this.clip('nonzero');
  5135. var imgEl = document.createElementNS(NS, 'svg:image');
  5136. imgEl.setAttributeNS(XLINK_NS, 'xlink:href', imgSrc);
  5137. imgEl.setAttributeNS(null, 'x', '0');
  5138. imgEl.setAttributeNS(null, 'y', pf(-height));
  5139. imgEl.setAttributeNS(null, 'width', pf(width) + 'px');
  5140. imgEl.setAttributeNS(null, 'height', pf(height) + 'px');
  5141. imgEl.setAttributeNS(null, 'transform', 'scale(' + pf(1 / width) + ' ' + pf(-1 / height) + ')');
  5142. if (mask) {
  5143. mask.appendChild(imgEl);
  5144. } else {
  5145. this._ensureTransformGroup().appendChild(imgEl);
  5146. }
  5147. },
  5148. paintImageMaskXObject: function SVGGraphics_paintImageMaskXObject(imgData) {
  5149. var current = this.current;
  5150. var width = imgData.width;
  5151. var height = imgData.height;
  5152. var fillColor = current.fillColor;
  5153. current.maskId = 'mask' + maskCount++;
  5154. var mask = document.createElementNS(NS, 'svg:mask');
  5155. mask.setAttributeNS(null, 'id', current.maskId);
  5156. var rect = document.createElementNS(NS, 'svg:rect');
  5157. rect.setAttributeNS(null, 'x', '0');
  5158. rect.setAttributeNS(null, 'y', '0');
  5159. rect.setAttributeNS(null, 'width', pf(width));
  5160. rect.setAttributeNS(null, 'height', pf(height));
  5161. rect.setAttributeNS(null, 'fill', fillColor);
  5162. rect.setAttributeNS(null, 'mask', 'url(#' + current.maskId + ')');
  5163. this.defs.appendChild(mask);
  5164. this._ensureTransformGroup().appendChild(rect);
  5165. this.paintInlineImageXObject(imgData, mask);
  5166. },
  5167. paintFormXObjectBegin: function SVGGraphics_paintFormXObjectBegin(matrix, bbox) {
  5168. if ((0, _util.isArray)(matrix) && matrix.length === 6) {
  5169. this.transform(matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5]);
  5170. }
  5171. if ((0, _util.isArray)(bbox) && bbox.length === 4) {
  5172. var width = bbox[2] - bbox[0];
  5173. var height = bbox[3] - bbox[1];
  5174. var cliprect = document.createElementNS(NS, 'svg:rect');
  5175. cliprect.setAttributeNS(null, 'x', bbox[0]);
  5176. cliprect.setAttributeNS(null, 'y', bbox[1]);
  5177. cliprect.setAttributeNS(null, 'width', pf(width));
  5178. cliprect.setAttributeNS(null, 'height', pf(height));
  5179. this.current.element = cliprect;
  5180. this.clip('nonzero');
  5181. this.endPath();
  5182. }
  5183. },
  5184. paintFormXObjectEnd: function SVGGraphics_paintFormXObjectEnd() {},
  5185. _initialize: function SVGGraphics_initialize(viewport) {
  5186. var svg = document.createElementNS(NS, 'svg:svg');
  5187. svg.setAttributeNS(null, 'version', '1.1');
  5188. svg.setAttributeNS(null, 'width', viewport.width + 'px');
  5189. svg.setAttributeNS(null, 'height', viewport.height + 'px');
  5190. svg.setAttributeNS(null, 'preserveAspectRatio', 'none');
  5191. svg.setAttributeNS(null, 'viewBox', '0 0 ' + viewport.width + ' ' + viewport.height);
  5192. var definitions = document.createElementNS(NS, 'svg:defs');
  5193. svg.appendChild(definitions);
  5194. this.defs = definitions;
  5195. var rootGroup = document.createElementNS(NS, 'svg:g');
  5196. rootGroup.setAttributeNS(null, 'transform', pm(viewport.transform));
  5197. svg.appendChild(rootGroup);
  5198. this.svg = rootGroup;
  5199. return svg;
  5200. },
  5201. _ensureClipGroup: function SVGGraphics_ensureClipGroup() {
  5202. if (!this.current.clipGroup) {
  5203. var clipGroup = document.createElementNS(NS, 'svg:g');
  5204. clipGroup.setAttributeNS(null, 'clip-path', this.current.activeClipUrl);
  5205. this.svg.appendChild(clipGroup);
  5206. this.current.clipGroup = clipGroup;
  5207. }
  5208. return this.current.clipGroup;
  5209. },
  5210. _ensureTransformGroup: function SVGGraphics_ensureTransformGroup() {
  5211. if (!this.tgrp) {
  5212. this.tgrp = document.createElementNS(NS, 'svg:g');
  5213. this.tgrp.setAttributeNS(null, 'transform', pm(this.transformMatrix));
  5214. if (this.current.activeClipUrl) {
  5215. this._ensureClipGroup().appendChild(this.tgrp);
  5216. } else {
  5217. this.svg.appendChild(this.tgrp);
  5218. }
  5219. }
  5220. return this.tgrp;
  5221. }
  5222. };
  5223. return SVGGraphics;
  5224. }();
  5225. }
  5226. exports.SVGGraphics = SVGGraphics;
  5227. /***/ }),
  5228. /* 32 */
  5229. /***/ (function(module, exports, __w_pdfjs_require__) {
  5230. "use strict";
  5231. Object.defineProperty(exports, "__esModule", {
  5232. value: true
  5233. });
  5234. exports.renderTextLayer = undefined;
  5235. var _util = __w_pdfjs_require__(0);
  5236. var _dom_utils = __w_pdfjs_require__(7);
  5237. var renderTextLayer = function renderTextLayerClosure() {
  5238. var MAX_TEXT_DIVS_TO_RENDER = 100000;
  5239. var NonWhitespaceRegexp = /\S/;
  5240. function isAllWhitespace(str) {
  5241. return !NonWhitespaceRegexp.test(str);
  5242. }
  5243. var styleBuf = ['left: ', 0, 'px; top: ', 0, 'px; font-size: ', 0, 'px; font-family: ', '', ';'];
  5244. function appendText(task, geom, styles) {
  5245. var textDiv = document.createElement('div');
  5246. var textDivProperties = {
  5247. style: null,
  5248. angle: 0,
  5249. canvasWidth: 0,
  5250. isWhitespace: false,
  5251. originalTransform: null,
  5252. paddingBottom: 0,
  5253. paddingLeft: 0,
  5254. paddingRight: 0,
  5255. paddingTop: 0,
  5256. scale: 1
  5257. };
  5258. task._textDivs.push(textDiv);
  5259. if (isAllWhitespace(geom.str)) {
  5260. textDivProperties.isWhitespace = true;
  5261. task._textDivProperties.set(textDiv, textDivProperties);
  5262. return;
  5263. }
  5264. var tx = _util.Util.transform(task._viewport.transform, geom.transform);
  5265. var angle = Math.atan2(tx[1], tx[0]);
  5266. var style = styles[geom.fontName];
  5267. if (style.vertical) {
  5268. angle += Math.PI / 2;
  5269. }
  5270. var fontHeight = Math.sqrt(tx[2] * tx[2] + tx[3] * tx[3]);
  5271. var fontAscent = fontHeight;
  5272. if (style.ascent) {
  5273. fontAscent = style.ascent * fontAscent;
  5274. } else if (style.descent) {
  5275. fontAscent = (1 + style.descent) * fontAscent;
  5276. }
  5277. var left;
  5278. var top;
  5279. if (angle === 0) {
  5280. left = tx[4];
  5281. top = tx[5] - fontAscent;
  5282. } else {
  5283. left = tx[4] + fontAscent * Math.sin(angle);
  5284. top = tx[5] - fontAscent * Math.cos(angle);
  5285. }
  5286. styleBuf[1] = left;
  5287. styleBuf[3] = top;
  5288. styleBuf[5] = fontHeight;
  5289. styleBuf[7] = style.fontFamily;
  5290. textDivProperties.style = styleBuf.join('');
  5291. textDiv.setAttribute('style', textDivProperties.style);
  5292. textDiv.textContent = geom.str;
  5293. if ((0, _dom_utils.getDefaultSetting)('pdfBug')) {
  5294. textDiv.dataset.fontName = geom.fontName;
  5295. }
  5296. if (angle !== 0) {
  5297. textDivProperties.angle = angle * (180 / Math.PI);
  5298. }
  5299. if (geom.str.length > 1) {
  5300. if (style.vertical) {
  5301. textDivProperties.canvasWidth = geom.height * task._viewport.scale;
  5302. } else {
  5303. textDivProperties.canvasWidth = geom.width * task._viewport.scale;
  5304. }
  5305. }
  5306. task._textDivProperties.set(textDiv, textDivProperties);
  5307. if (task._textContentStream) {
  5308. task._layoutText(textDiv);
  5309. }
  5310. if (task._enhanceTextSelection) {
  5311. var angleCos = 1,
  5312. angleSin = 0;
  5313. if (angle !== 0) {
  5314. angleCos = Math.cos(angle);
  5315. angleSin = Math.sin(angle);
  5316. }
  5317. var divWidth = (style.vertical ? geom.height : geom.width) * task._viewport.scale;
  5318. var divHeight = fontHeight;
  5319. var m, b;
  5320. if (angle !== 0) {
  5321. m = [angleCos, angleSin, -angleSin, angleCos, left, top];
  5322. b = _util.Util.getAxialAlignedBoundingBox([0, 0, divWidth, divHeight], m);
  5323. } else {
  5324. b = [left, top, left + divWidth, top + divHeight];
  5325. }
  5326. task._bounds.push({
  5327. left: b[0],
  5328. top: b[1],
  5329. right: b[2],
  5330. bottom: b[3],
  5331. div: textDiv,
  5332. size: [divWidth, divHeight],
  5333. m: m
  5334. });
  5335. }
  5336. }
  5337. function render(task) {
  5338. if (task._canceled) {
  5339. return;
  5340. }
  5341. var textDivs = task._textDivs;
  5342. var capability = task._capability;
  5343. var textDivsLength = textDivs.length;
  5344. if (textDivsLength > MAX_TEXT_DIVS_TO_RENDER) {
  5345. task._renderingDone = true;
  5346. capability.resolve();
  5347. return;
  5348. }
  5349. if (!task._textContentStream) {
  5350. for (var i = 0; i < textDivsLength; i++) {
  5351. task._layoutText(textDivs[i]);
  5352. }
  5353. }
  5354. task._renderingDone = true;
  5355. capability.resolve();
  5356. }
  5357. function expand(task) {
  5358. var bounds = task._bounds;
  5359. var viewport = task._viewport;
  5360. var expanded = expandBounds(viewport.width, viewport.height, bounds);
  5361. for (var i = 0; i < expanded.length; i++) {
  5362. var div = bounds[i].div;
  5363. var divProperties = task._textDivProperties.get(div);
  5364. if (divProperties.angle === 0) {
  5365. divProperties.paddingLeft = bounds[i].left - expanded[i].left;
  5366. divProperties.paddingTop = bounds[i].top - expanded[i].top;
  5367. divProperties.paddingRight = expanded[i].right - bounds[i].right;
  5368. divProperties.paddingBottom = expanded[i].bottom - bounds[i].bottom;
  5369. task._textDivProperties.set(div, divProperties);
  5370. continue;
  5371. }
  5372. var e = expanded[i],
  5373. b = bounds[i];
  5374. var m = b.m,
  5375. c = m[0],
  5376. s = m[1];
  5377. var points = [[0, 0], [0, b.size[1]], [b.size[0], 0], b.size];
  5378. var ts = new Float64Array(64);
  5379. points.forEach(function (p, i) {
  5380. var t = _util.Util.applyTransform(p, m);
  5381. ts[i + 0] = c && (e.left - t[0]) / c;
  5382. ts[i + 4] = s && (e.top - t[1]) / s;
  5383. ts[i + 8] = c && (e.right - t[0]) / c;
  5384. ts[i + 12] = s && (e.bottom - t[1]) / s;
  5385. ts[i + 16] = s && (e.left - t[0]) / -s;
  5386. ts[i + 20] = c && (e.top - t[1]) / c;
  5387. ts[i + 24] = s && (e.right - t[0]) / -s;
  5388. ts[i + 28] = c && (e.bottom - t[1]) / c;
  5389. ts[i + 32] = c && (e.left - t[0]) / -c;
  5390. ts[i + 36] = s && (e.top - t[1]) / -s;
  5391. ts[i + 40] = c && (e.right - t[0]) / -c;
  5392. ts[i + 44] = s && (e.bottom - t[1]) / -s;
  5393. ts[i + 48] = s && (e.left - t[0]) / s;
  5394. ts[i + 52] = c && (e.top - t[1]) / -c;
  5395. ts[i + 56] = s && (e.right - t[0]) / s;
  5396. ts[i + 60] = c && (e.bottom - t[1]) / -c;
  5397. });
  5398. var findPositiveMin = function findPositiveMin(ts, offset, count) {
  5399. var result = 0;
  5400. for (var i = 0; i < count; i++) {
  5401. var t = ts[offset++];
  5402. if (t > 0) {
  5403. result = result ? Math.min(t, result) : t;
  5404. }
  5405. }
  5406. return result;
  5407. };
  5408. var boxScale = 1 + Math.min(Math.abs(c), Math.abs(s));
  5409. divProperties.paddingLeft = findPositiveMin(ts, 32, 16) / boxScale;
  5410. divProperties.paddingTop = findPositiveMin(ts, 48, 16) / boxScale;
  5411. divProperties.paddingRight = findPositiveMin(ts, 0, 16) / boxScale;
  5412. divProperties.paddingBottom = findPositiveMin(ts, 16, 16) / boxScale;
  5413. task._textDivProperties.set(div, divProperties);
  5414. }
  5415. }
  5416. function expandBounds(width, height, boxes) {
  5417. var bounds = boxes.map(function (box, i) {
  5418. return {
  5419. x1: box.left,
  5420. y1: box.top,
  5421. x2: box.right,
  5422. y2: box.bottom,
  5423. index: i,
  5424. x1New: undefined,
  5425. x2New: undefined
  5426. };
  5427. });
  5428. expandBoundsLTR(width, bounds);
  5429. var expanded = new Array(boxes.length);
  5430. bounds.forEach(function (b) {
  5431. var i = b.index;
  5432. expanded[i] = {
  5433. left: b.x1New,
  5434. top: 0,
  5435. right: b.x2New,
  5436. bottom: 0
  5437. };
  5438. });
  5439. boxes.map(function (box, i) {
  5440. var e = expanded[i],
  5441. b = bounds[i];
  5442. b.x1 = box.top;
  5443. b.y1 = width - e.right;
  5444. b.x2 = box.bottom;
  5445. b.y2 = width - e.left;
  5446. b.index = i;
  5447. b.x1New = undefined;
  5448. b.x2New = undefined;
  5449. });
  5450. expandBoundsLTR(height, bounds);
  5451. bounds.forEach(function (b) {
  5452. var i = b.index;
  5453. expanded[i].top = b.x1New;
  5454. expanded[i].bottom = b.x2New;
  5455. });
  5456. return expanded;
  5457. }
  5458. function expandBoundsLTR(width, bounds) {
  5459. bounds.sort(function (a, b) {
  5460. return a.x1 - b.x1 || a.index - b.index;
  5461. });
  5462. var fakeBoundary = {
  5463. x1: -Infinity,
  5464. y1: -Infinity,
  5465. x2: 0,
  5466. y2: Infinity,
  5467. index: -1,
  5468. x1New: 0,
  5469. x2New: 0
  5470. };
  5471. var horizon = [{
  5472. start: -Infinity,
  5473. end: Infinity,
  5474. boundary: fakeBoundary
  5475. }];
  5476. bounds.forEach(function (boundary) {
  5477. var i = 0;
  5478. while (i < horizon.length && horizon[i].end <= boundary.y1) {
  5479. i++;
  5480. }
  5481. var j = horizon.length - 1;
  5482. while (j >= 0 && horizon[j].start >= boundary.y2) {
  5483. j--;
  5484. }
  5485. var horizonPart, affectedBoundary;
  5486. var q,
  5487. k,
  5488. maxXNew = -Infinity;
  5489. for (q = i; q <= j; q++) {
  5490. horizonPart = horizon[q];
  5491. affectedBoundary = horizonPart.boundary;
  5492. var xNew;
  5493. if (affectedBoundary.x2 > boundary.x1) {
  5494. xNew = affectedBoundary.index > boundary.index ? affectedBoundary.x1New : boundary.x1;
  5495. } else if (affectedBoundary.x2New === undefined) {
  5496. xNew = (affectedBoundary.x2 + boundary.x1) / 2;
  5497. } else {
  5498. xNew = affectedBoundary.x2New;
  5499. }
  5500. if (xNew > maxXNew) {
  5501. maxXNew = xNew;
  5502. }
  5503. }
  5504. boundary.x1New = maxXNew;
  5505. for (q = i; q <= j; q++) {
  5506. horizonPart = horizon[q];
  5507. affectedBoundary = horizonPart.boundary;
  5508. if (affectedBoundary.x2New === undefined) {
  5509. if (affectedBoundary.x2 > boundary.x1) {
  5510. if (affectedBoundary.index > boundary.index) {
  5511. affectedBoundary.x2New = affectedBoundary.x2;
  5512. }
  5513. } else {
  5514. affectedBoundary.x2New = maxXNew;
  5515. }
  5516. } else if (affectedBoundary.x2New > maxXNew) {
  5517. affectedBoundary.x2New = Math.max(maxXNew, affectedBoundary.x2);
  5518. }
  5519. }
  5520. var changedHorizon = [],
  5521. lastBoundary = null;
  5522. for (q = i; q <= j; q++) {
  5523. horizonPart = horizon[q];
  5524. affectedBoundary = horizonPart.boundary;
  5525. var useBoundary = affectedBoundary.x2 > boundary.x2 ? affectedBoundary : boundary;
  5526. if (lastBoundary === useBoundary) {
  5527. changedHorizon[changedHorizon.length - 1].end = horizonPart.end;
  5528. } else {
  5529. changedHorizon.push({
  5530. start: horizonPart.start,
  5531. end: horizonPart.end,
  5532. boundary: useBoundary
  5533. });
  5534. lastBoundary = useBoundary;
  5535. }
  5536. }
  5537. if (horizon[i].start < boundary.y1) {
  5538. changedHorizon[0].start = boundary.y1;
  5539. changedHorizon.unshift({
  5540. start: horizon[i].start,
  5541. end: boundary.y1,
  5542. boundary: horizon[i].boundary
  5543. });
  5544. }
  5545. if (boundary.y2 < horizon[j].end) {
  5546. changedHorizon[changedHorizon.length - 1].end = boundary.y2;
  5547. changedHorizon.push({
  5548. start: boundary.y2,
  5549. end: horizon[j].end,
  5550. boundary: horizon[j].boundary
  5551. });
  5552. }
  5553. for (q = i; q <= j; q++) {
  5554. horizonPart = horizon[q];
  5555. affectedBoundary = horizonPart.boundary;
  5556. if (affectedBoundary.x2New !== undefined) {
  5557. continue;
  5558. }
  5559. var used = false;
  5560. for (k = i - 1; !used && k >= 0 && horizon[k].start >= affectedBoundary.y1; k--) {
  5561. used = horizon[k].boundary === affectedBoundary;
  5562. }
  5563. for (k = j + 1; !used && k < horizon.length && horizon[k].end <= affectedBoundary.y2; k++) {
  5564. used = horizon[k].boundary === affectedBoundary;
  5565. }
  5566. for (k = 0; !used && k < changedHorizon.length; k++) {
  5567. used = changedHorizon[k].boundary === affectedBoundary;
  5568. }
  5569. if (!used) {
  5570. affectedBoundary.x2New = maxXNew;
  5571. }
  5572. }
  5573. Array.prototype.splice.apply(horizon, [i, j - i + 1].concat(changedHorizon));
  5574. });
  5575. horizon.forEach(function (horizonPart) {
  5576. var affectedBoundary = horizonPart.boundary;
  5577. if (affectedBoundary.x2New === undefined) {
  5578. affectedBoundary.x2New = Math.max(width, affectedBoundary.x2);
  5579. }
  5580. });
  5581. }
  5582. function TextLayerRenderTask(_ref) {
  5583. var textContent = _ref.textContent,
  5584. textContentStream = _ref.textContentStream,
  5585. container = _ref.container,
  5586. viewport = _ref.viewport,
  5587. textDivs = _ref.textDivs,
  5588. textContentItemsStr = _ref.textContentItemsStr,
  5589. enhanceTextSelection = _ref.enhanceTextSelection;
  5590. this._textContent = textContent;
  5591. this._textContentStream = textContentStream;
  5592. this._container = container;
  5593. this._viewport = viewport;
  5594. this._textDivs = textDivs || [];
  5595. this._textContentItemsStr = textContentItemsStr || [];
  5596. this._enhanceTextSelection = !!enhanceTextSelection;
  5597. this._reader = null;
  5598. this._layoutTextLastFontSize = null;
  5599. this._layoutTextLastFontFamily = null;
  5600. this._layoutTextCtx = null;
  5601. this._textDivProperties = new WeakMap();
  5602. this._renderingDone = false;
  5603. this._canceled = false;
  5604. this._capability = (0, _util.createPromiseCapability)();
  5605. this._renderTimer = null;
  5606. this._bounds = [];
  5607. }
  5608. TextLayerRenderTask.prototype = {
  5609. get promise() {
  5610. return this._capability.promise;
  5611. },
  5612. cancel: function TextLayer_cancel() {
  5613. if (this._reader) {
  5614. this._reader.cancel(new _util.AbortException('text layer task cancelled'));
  5615. this._reader = null;
  5616. }
  5617. this._canceled = true;
  5618. if (this._renderTimer !== null) {
  5619. clearTimeout(this._renderTimer);
  5620. this._renderTimer = null;
  5621. }
  5622. this._capability.reject('canceled');
  5623. },
  5624. _processItems: function _processItems(items, styleCache) {
  5625. for (var i = 0, len = items.length; i < len; i++) {
  5626. this._textContentItemsStr.push(items[i].str);
  5627. appendText(this, items[i], styleCache);
  5628. }
  5629. },
  5630. _layoutText: function _layoutText(textDiv) {
  5631. var textLayerFrag = this._container;
  5632. var textDivProperties = this._textDivProperties.get(textDiv);
  5633. if (textDivProperties.isWhitespace) {
  5634. return;
  5635. }
  5636. var fontSize = textDiv.style.fontSize;
  5637. var fontFamily = textDiv.style.fontFamily;
  5638. if (fontSize !== this._layoutTextLastFontSize || fontFamily !== this._layoutTextLastFontFamily) {
  5639. this._layoutTextCtx.font = fontSize + ' ' + fontFamily;
  5640. this._lastFontSize = fontSize;
  5641. this._lastFontFamily = fontFamily;
  5642. }
  5643. var width = this._layoutTextCtx.measureText(textDiv.textContent).width;
  5644. var transform = '';
  5645. if (textDivProperties.canvasWidth !== 0 && width > 0) {
  5646. textDivProperties.scale = textDivProperties.canvasWidth / width;
  5647. transform = 'scaleX(' + textDivProperties.scale + ')';
  5648. }
  5649. if (textDivProperties.angle !== 0) {
  5650. transform = 'rotate(' + textDivProperties.angle + 'deg) ' + transform;
  5651. }
  5652. if (transform !== '') {
  5653. textDivProperties.originalTransform = transform;
  5654. _dom_utils.CustomStyle.setProp('transform', textDiv, transform);
  5655. }
  5656. this._textDivProperties.set(textDiv, textDivProperties);
  5657. textLayerFrag.appendChild(textDiv);
  5658. },
  5659. _render: function TextLayer_render(timeout) {
  5660. var _this = this;
  5661. var capability = (0, _util.createPromiseCapability)();
  5662. var styleCache = Object.create(null);
  5663. var canvas = document.createElement('canvas');
  5664. canvas.mozOpaque = true;
  5665. this._layoutTextCtx = canvas.getContext('2d', { alpha: false });
  5666. if (this._textContent) {
  5667. var textItems = this._textContent.items;
  5668. var textStyles = this._textContent.styles;
  5669. this._processItems(textItems, textStyles);
  5670. capability.resolve();
  5671. } else if (this._textContentStream) {
  5672. var pump = function pump() {
  5673. _this._reader.read().then(function (_ref2) {
  5674. var value = _ref2.value,
  5675. done = _ref2.done;
  5676. if (done) {
  5677. capability.resolve();
  5678. return;
  5679. }
  5680. _util.Util.extendObj(styleCache, value.styles);
  5681. _this._processItems(value.items, styleCache);
  5682. pump();
  5683. }, capability.reject);
  5684. };
  5685. this._reader = this._textContentStream.getReader();
  5686. pump();
  5687. } else {
  5688. throw new Error('Neither "textContent" nor "textContentStream"' + ' parameters specified.');
  5689. }
  5690. capability.promise.then(function () {
  5691. styleCache = null;
  5692. if (!timeout) {
  5693. render(_this);
  5694. } else {
  5695. _this._renderTimer = setTimeout(function () {
  5696. render(_this);
  5697. _this._renderTimer = null;
  5698. }, timeout);
  5699. }
  5700. }, this._capability.reject);
  5701. },
  5702. expandTextDivs: function TextLayer_expandTextDivs(expandDivs) {
  5703. if (!this._enhanceTextSelection || !this._renderingDone) {
  5704. return;
  5705. }
  5706. if (this._bounds !== null) {
  5707. expand(this);
  5708. this._bounds = null;
  5709. }
  5710. for (var i = 0, ii = this._textDivs.length; i < ii; i++) {
  5711. var div = this._textDivs[i];
  5712. var divProperties = this._textDivProperties.get(div);
  5713. if (divProperties.isWhitespace) {
  5714. continue;
  5715. }
  5716. if (expandDivs) {
  5717. var transform = '',
  5718. padding = '';
  5719. if (divProperties.scale !== 1) {
  5720. transform = 'scaleX(' + divProperties.scale + ')';
  5721. }
  5722. if (divProperties.angle !== 0) {
  5723. transform = 'rotate(' + divProperties.angle + 'deg) ' + transform;
  5724. }
  5725. if (divProperties.paddingLeft !== 0) {
  5726. padding += ' padding-left: ' + divProperties.paddingLeft / divProperties.scale + 'px;';
  5727. transform += ' translateX(' + -divProperties.paddingLeft / divProperties.scale + 'px)';
  5728. }
  5729. if (divProperties.paddingTop !== 0) {
  5730. padding += ' padding-top: ' + divProperties.paddingTop + 'px;';
  5731. transform += ' translateY(' + -divProperties.paddingTop + 'px)';
  5732. }
  5733. if (divProperties.paddingRight !== 0) {
  5734. padding += ' padding-right: ' + divProperties.paddingRight / divProperties.scale + 'px;';
  5735. }
  5736. if (divProperties.paddingBottom !== 0) {
  5737. padding += ' padding-bottom: ' + divProperties.paddingBottom + 'px;';
  5738. }
  5739. if (padding !== '') {
  5740. div.setAttribute('style', divProperties.style + padding);
  5741. }
  5742. if (transform !== '') {
  5743. _dom_utils.CustomStyle.setProp('transform', div, transform);
  5744. }
  5745. } else {
  5746. div.style.padding = 0;
  5747. _dom_utils.CustomStyle.setProp('transform', div, divProperties.originalTransform || '');
  5748. }
  5749. }
  5750. }
  5751. };
  5752. function renderTextLayer(renderParameters) {
  5753. var task = new TextLayerRenderTask({
  5754. textContent: renderParameters.textContent,
  5755. textContentStream: renderParameters.textContentStream,
  5756. container: renderParameters.container,
  5757. viewport: renderParameters.viewport,
  5758. textDivs: renderParameters.textDivs,
  5759. textContentItemsStr: renderParameters.textContentItemsStr,
  5760. enhanceTextSelection: renderParameters.enhanceTextSelection
  5761. });
  5762. task._render(renderParameters.timeout);
  5763. return task;
  5764. }
  5765. return renderTextLayer;
  5766. }();
  5767. exports.renderTextLayer = renderTextLayer;
  5768. /***/ }),
  5769. /* 33 */
  5770. /***/ (function(module, exports, __w_pdfjs_require__) {
  5771. "use strict";
  5772. module.exports = function (it) {
  5773. if (typeof it != 'function') throw TypeError(it + ' is not a function!');
  5774. return it;
  5775. };
  5776. /***/ }),
  5777. /* 34 */
  5778. /***/ (function(module, exports, __w_pdfjs_require__) {
  5779. "use strict";
  5780. module.exports = function (it, Constructor, name, forbiddenField) {
  5781. if (!(it instanceof Constructor) || forbiddenField !== undefined && forbiddenField in it) {
  5782. throw TypeError(name + ': incorrect invocation!');
  5783. }
  5784. return it;
  5785. };
  5786. /***/ }),
  5787. /* 35 */
  5788. /***/ (function(module, exports, __w_pdfjs_require__) {
  5789. "use strict";
  5790. var toObject = __w_pdfjs_require__(12);
  5791. var toAbsoluteIndex = __w_pdfjs_require__(19);
  5792. var toLength = __w_pdfjs_require__(6);
  5793. module.exports = function fill(value) {
  5794. var O = toObject(this);
  5795. var length = toLength(O.length);
  5796. var aLen = arguments.length;
  5797. var index = toAbsoluteIndex(aLen > 1 ? arguments[1] : undefined, length);
  5798. var end = aLen > 2 ? arguments[2] : undefined;
  5799. var endPos = end === undefined ? length : toAbsoluteIndex(end, length);
  5800. while (endPos > index) {
  5801. O[index++] = value;
  5802. }return O;
  5803. };
  5804. /***/ }),
  5805. /* 36 */
  5806. /***/ (function(module, exports, __w_pdfjs_require__) {
  5807. "use strict";
  5808. var toIObject = __w_pdfjs_require__(20);
  5809. var toLength = __w_pdfjs_require__(6);
  5810. var toAbsoluteIndex = __w_pdfjs_require__(19);
  5811. module.exports = function (IS_INCLUDES) {
  5812. return function ($this, el, fromIndex) {
  5813. var O = toIObject($this);
  5814. var length = toLength(O.length);
  5815. var index = toAbsoluteIndex(fromIndex, length);
  5816. var value;
  5817. if (IS_INCLUDES && el != el) while (length > index) {
  5818. value = O[index++];
  5819. if (value != value) return true;
  5820. } else for (; length > index; index++) {
  5821. if (IS_INCLUDES || index in O) {
  5822. if (O[index] === el) return IS_INCLUDES || index || 0;
  5823. }
  5824. }return !IS_INCLUDES && -1;
  5825. };
  5826. };
  5827. /***/ }),
  5828. /* 37 */
  5829. /***/ (function(module, exports, __w_pdfjs_require__) {
  5830. "use strict";
  5831. var cof = __w_pdfjs_require__(21);
  5832. var TAG = __w_pdfjs_require__(1)('toStringTag');
  5833. var ARG = cof(function () {
  5834. return arguments;
  5835. }()) == 'Arguments';
  5836. var tryGet = function tryGet(it, key) {
  5837. try {
  5838. return it[key];
  5839. } catch (e) {}
  5840. };
  5841. module.exports = function (it) {
  5842. var O, T, B;
  5843. return it === undefined ? 'Undefined' : it === null ? 'Null' : typeof (T = tryGet(O = Object(it), TAG)) == 'string' ? T : ARG ? cof(O) : (B = cof(O)) == 'Object' && typeof O.callee == 'function' ? 'Arguments' : B;
  5844. };
  5845. /***/ }),
  5846. /* 38 */
  5847. /***/ (function(module, exports, __w_pdfjs_require__) {
  5848. "use strict";
  5849. module.exports = function (it) {
  5850. if (it == undefined) throw TypeError("Can't call method on " + it);
  5851. return it;
  5852. };
  5853. /***/ }),
  5854. /* 39 */
  5855. /***/ (function(module, exports, __w_pdfjs_require__) {
  5856. "use strict";
  5857. var isObject = __w_pdfjs_require__(9);
  5858. var document = __w_pdfjs_require__(2).document;
  5859. var is = isObject(document) && isObject(document.createElement);
  5860. module.exports = function (it) {
  5861. return is ? document.createElement(it) : {};
  5862. };
  5863. /***/ }),
  5864. /* 40 */
  5865. /***/ (function(module, exports, __w_pdfjs_require__) {
  5866. "use strict";
  5867. var global = __w_pdfjs_require__(2);
  5868. var core = __w_pdfjs_require__(16);
  5869. var hide = __w_pdfjs_require__(4);
  5870. var redefine = __w_pdfjs_require__(25);
  5871. var ctx = __w_pdfjs_require__(22);
  5872. var PROTOTYPE = 'prototype';
  5873. var $export = function $export(type, name, source) {
  5874. var IS_FORCED = type & $export.F;
  5875. var IS_GLOBAL = type & $export.G;
  5876. var IS_STATIC = type & $export.S;
  5877. var IS_PROTO = type & $export.P;
  5878. var IS_BIND = type & $export.B;
  5879. var target = IS_GLOBAL ? global : IS_STATIC ? global[name] || (global[name] = {}) : (global[name] || {})[PROTOTYPE];
  5880. var exports = IS_GLOBAL ? core : core[name] || (core[name] = {});
  5881. var expProto = exports[PROTOTYPE] || (exports[PROTOTYPE] = {});
  5882. var key, own, out, exp;
  5883. if (IS_GLOBAL) source = name;
  5884. for (key in source) {
  5885. own = !IS_FORCED && target && target[key] !== undefined;
  5886. out = (own ? target : source)[key];
  5887. exp = IS_BIND && own ? ctx(out, global) : IS_PROTO && typeof out == 'function' ? ctx(Function.call, out) : out;
  5888. if (target) redefine(target, key, out, type & $export.U);
  5889. if (exports[key] != out) hide(exports, key, exp);
  5890. if (IS_PROTO && expProto[key] != out) expProto[key] = out;
  5891. }
  5892. };
  5893. global.core = core;
  5894. $export.F = 1;
  5895. $export.G = 2;
  5896. $export.S = 4;
  5897. $export.P = 8;
  5898. $export.B = 16;
  5899. $export.W = 32;
  5900. $export.U = 64;
  5901. $export.R = 128;
  5902. module.exports = $export;
  5903. /***/ }),
  5904. /* 41 */
  5905. /***/ (function(module, exports, __w_pdfjs_require__) {
  5906. "use strict";
  5907. module.exports = !__w_pdfjs_require__(3) && !__w_pdfjs_require__(17)(function () {
  5908. return Object.defineProperty(__w_pdfjs_require__(39)('div'), 'a', {
  5909. get: function get() {
  5910. return 7;
  5911. }
  5912. }).a != 7;
  5913. });
  5914. /***/ }),
  5915. /* 42 */
  5916. /***/ (function(module, exports, __w_pdfjs_require__) {
  5917. "use strict";
  5918. var cof = __w_pdfjs_require__(21);
  5919. module.exports = Object('z').propertyIsEnumerable(0) ? Object : function (it) {
  5920. return cof(it) == 'String' ? it.split('') : Object(it);
  5921. };
  5922. /***/ }),
  5923. /* 43 */
  5924. /***/ (function(module, exports, __w_pdfjs_require__) {
  5925. "use strict";
  5926. var anObject = __w_pdfjs_require__(15);
  5927. var dPs = __w_pdfjs_require__(71);
  5928. var enumBugKeys = __w_pdfjs_require__(23);
  5929. var IE_PROTO = __w_pdfjs_require__(27)('IE_PROTO');
  5930. var Empty = function Empty() {};
  5931. var PROTOTYPE = 'prototype';
  5932. var _createDict = function createDict() {
  5933. var iframe = __w_pdfjs_require__(39)('iframe');
  5934. var i = enumBugKeys.length;
  5935. var lt = '<';
  5936. var gt = '>';
  5937. var iframeDocument;
  5938. iframe.style.display = 'none';
  5939. __w_pdfjs_require__(64).appendChild(iframe);
  5940. iframe.src = 'javascript:';
  5941. iframeDocument = iframe.contentWindow.document;
  5942. iframeDocument.open();
  5943. iframeDocument.write(lt + 'script' + gt + 'document.F=Object' + lt + '/script' + gt);
  5944. iframeDocument.close();
  5945. _createDict = iframeDocument.F;
  5946. while (i--) {
  5947. delete _createDict[PROTOTYPE][enumBugKeys[i]];
  5948. }return _createDict();
  5949. };
  5950. module.exports = Object.create || function create(O, Properties) {
  5951. var result;
  5952. if (O !== null) {
  5953. Empty[PROTOTYPE] = anObject(O);
  5954. result = new Empty();
  5955. Empty[PROTOTYPE] = null;
  5956. result[IE_PROTO] = O;
  5957. } else result = _createDict();
  5958. return Properties === undefined ? result : dPs(result, Properties);
  5959. };
  5960. /***/ }),
  5961. /* 44 */
  5962. /***/ (function(module, exports, __w_pdfjs_require__) {
  5963. "use strict";
  5964. var $keys = __w_pdfjs_require__(46);
  5965. var hiddenKeys = __w_pdfjs_require__(23).concat('length', 'prototype');
  5966. exports.f = Object.getOwnPropertyNames || function getOwnPropertyNames(O) {
  5967. return $keys(O, hiddenKeys);
  5968. };
  5969. /***/ }),
  5970. /* 45 */
  5971. /***/ (function(module, exports, __w_pdfjs_require__) {
  5972. "use strict";
  5973. var has = __w_pdfjs_require__(5);
  5974. var toObject = __w_pdfjs_require__(12);
  5975. var IE_PROTO = __w_pdfjs_require__(27)('IE_PROTO');
  5976. var ObjectProto = Object.prototype;
  5977. module.exports = Object.getPrototypeOf || function (O) {
  5978. O = toObject(O);
  5979. if (has(O, IE_PROTO)) return O[IE_PROTO];
  5980. if (typeof O.constructor == 'function' && O instanceof O.constructor) {
  5981. return O.constructor.prototype;
  5982. }
  5983. return O instanceof Object ? ObjectProto : null;
  5984. };
  5985. /***/ }),
  5986. /* 46 */
  5987. /***/ (function(module, exports, __w_pdfjs_require__) {
  5988. "use strict";
  5989. var has = __w_pdfjs_require__(5);
  5990. var toIObject = __w_pdfjs_require__(20);
  5991. var arrayIndexOf = __w_pdfjs_require__(36)(false);
  5992. var IE_PROTO = __w_pdfjs_require__(27)('IE_PROTO');
  5993. module.exports = function (object, names) {
  5994. var O = toIObject(object);
  5995. var i = 0;
  5996. var result = [];
  5997. var key;
  5998. for (key in O) {
  5999. if (key != IE_PROTO) has(O, key) && result.push(key);
  6000. }while (names.length > i) {
  6001. if (has(O, key = names[i++])) {
  6002. ~arrayIndexOf(result, key) || result.push(key);
  6003. }
  6004. }return result;
  6005. };
  6006. /***/ }),
  6007. /* 47 */
  6008. /***/ (function(module, exports, __w_pdfjs_require__) {
  6009. "use strict";
  6010. var redefine = __w_pdfjs_require__(25);
  6011. module.exports = function (target, src, safe) {
  6012. for (var key in src) {
  6013. redefine(target, key, src[key], safe);
  6014. }return target;
  6015. };
  6016. /***/ }),
  6017. /* 48 */
  6018. /***/ (function(module, exports, __w_pdfjs_require__) {
  6019. "use strict";
  6020. var global = __w_pdfjs_require__(2);
  6021. var SHARED = '__core-js_shared__';
  6022. var store = global[SHARED] || (global[SHARED] = {});
  6023. module.exports = function (key) {
  6024. return store[key] || (store[key] = {});
  6025. };
  6026. /***/ }),
  6027. /* 49 */
  6028. /***/ (function(module, exports, __w_pdfjs_require__) {
  6029. "use strict";
  6030. var toInteger = __w_pdfjs_require__(11);
  6031. var toLength = __w_pdfjs_require__(6);
  6032. module.exports = function (it) {
  6033. if (it === undefined) return 0;
  6034. var number = toInteger(it);
  6035. var length = toLength(number);
  6036. if (number !== length) throw RangeError('Wrong length!');
  6037. return length;
  6038. };
  6039. /***/ }),
  6040. /* 50 */
  6041. /***/ (function(module, exports, __w_pdfjs_require__) {
  6042. "use strict";
  6043. var global = __w_pdfjs_require__(2);
  6044. var hide = __w_pdfjs_require__(4);
  6045. var uid = __w_pdfjs_require__(13);
  6046. var TYPED = uid('typed_array');
  6047. var VIEW = uid('view');
  6048. var ABV = !!(global.ArrayBuffer && global.DataView);
  6049. var CONSTR = ABV;
  6050. var i = 0;
  6051. var l = 9;
  6052. var Typed;
  6053. var TypedArrayConstructors = 'Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array'.split(',');
  6054. while (i < l) {
  6055. if (Typed = global[TypedArrayConstructors[i++]]) {
  6056. hide(Typed.prototype, TYPED, true);
  6057. hide(Typed.prototype, VIEW, true);
  6058. } else CONSTR = false;
  6059. }
  6060. module.exports = {
  6061. ABV: ABV,
  6062. CONSTR: CONSTR,
  6063. TYPED: TYPED,
  6064. VIEW: VIEW
  6065. };
  6066. /***/ }),
  6067. /* 51 */
  6068. /***/ (function(module, exports, __w_pdfjs_require__) {
  6069. "use strict";
  6070. Object.defineProperty(exports, "__esModule", {
  6071. value: true
  6072. });
  6073. function fixMetadata(meta) {
  6074. return meta.replace(/>\\376\\377([^<]+)/g, function (all, codes) {
  6075. var bytes = codes.replace(/\\([0-3])([0-7])([0-7])/g, function (code, d1, d2, d3) {
  6076. return String.fromCharCode(d1 * 64 + d2 * 8 + d3 * 1);
  6077. });
  6078. var chars = '';
  6079. for (var i = 0; i < bytes.length; i += 2) {
  6080. var code = bytes.charCodeAt(i) * 256 + bytes.charCodeAt(i + 1);
  6081. chars += code >= 32 && code < 127 && code !== 60 && code !== 62 && code !== 38 ? String.fromCharCode(code) : '&#x' + (0x10000 + code).toString(16).substring(1) + ';';
  6082. }
  6083. return '>' + chars;
  6084. });
  6085. }
  6086. function Metadata(meta) {
  6087. if (typeof meta === 'string') {
  6088. meta = fixMetadata(meta);
  6089. var parser = new DOMParser();
  6090. meta = parser.parseFromString(meta, 'application/xml');
  6091. } else if (!(meta instanceof Document)) {
  6092. throw new Error('Metadata: Invalid metadata object');
  6093. }
  6094. this.metaDocument = meta;
  6095. this.metadata = Object.create(null);
  6096. this.parse();
  6097. }
  6098. Metadata.prototype = {
  6099. parse: function Metadata_parse() {
  6100. var doc = this.metaDocument;
  6101. var rdf = doc.documentElement;
  6102. if (rdf.nodeName.toLowerCase() !== 'rdf:rdf') {
  6103. rdf = rdf.firstChild;
  6104. while (rdf && rdf.nodeName.toLowerCase() !== 'rdf:rdf') {
  6105. rdf = rdf.nextSibling;
  6106. }
  6107. }
  6108. var nodeName = rdf ? rdf.nodeName.toLowerCase() : null;
  6109. if (!rdf || nodeName !== 'rdf:rdf' || !rdf.hasChildNodes()) {
  6110. return;
  6111. }
  6112. var children = rdf.childNodes,
  6113. desc,
  6114. entry,
  6115. name,
  6116. i,
  6117. ii,
  6118. length,
  6119. iLength;
  6120. for (i = 0, length = children.length; i < length; i++) {
  6121. desc = children[i];
  6122. if (desc.nodeName.toLowerCase() !== 'rdf:description') {
  6123. continue;
  6124. }
  6125. for (ii = 0, iLength = desc.childNodes.length; ii < iLength; ii++) {
  6126. if (desc.childNodes[ii].nodeName.toLowerCase() !== '#text') {
  6127. entry = desc.childNodes[ii];
  6128. name = entry.nodeName.toLowerCase();
  6129. this.metadata[name] = entry.textContent.trim();
  6130. }
  6131. }
  6132. }
  6133. },
  6134. get: function Metadata_get(name) {
  6135. return this.metadata[name] || null;
  6136. },
  6137. has: function Metadata_has(name) {
  6138. return typeof this.metadata[name] !== 'undefined';
  6139. }
  6140. };
  6141. exports.Metadata = Metadata;
  6142. /***/ }),
  6143. /* 52 */
  6144. /***/ (function(module, exports, __w_pdfjs_require__) {
  6145. "use strict";
  6146. Object.defineProperty(exports, "__esModule", {
  6147. value: true
  6148. });
  6149. exports.validateRangeRequestCapabilities = undefined;
  6150. var _util = __w_pdfjs_require__(0);
  6151. function validateRangeRequestCapabilities(_ref) {
  6152. var getResponseHeader = _ref.getResponseHeader,
  6153. isHttp = _ref.isHttp,
  6154. rangeChunkSize = _ref.rangeChunkSize,
  6155. disableRange = _ref.disableRange;
  6156. (0, _util.assert)(rangeChunkSize > 0);
  6157. var returnValues = {
  6158. allowRangeRequests: false,
  6159. suggestedLength: undefined
  6160. };
  6161. if (disableRange || !isHttp) {
  6162. return returnValues;
  6163. }
  6164. if (getResponseHeader('Accept-Ranges') !== 'bytes') {
  6165. return returnValues;
  6166. }
  6167. var contentEncoding = getResponseHeader('Content-Encoding') || 'identity';
  6168. if (contentEncoding !== 'identity') {
  6169. return returnValues;
  6170. }
  6171. var length = getResponseHeader('Content-Length');
  6172. length = parseInt(length, 10);
  6173. if (!(0, _util.isInt)(length)) {
  6174. return returnValues;
  6175. }
  6176. returnValues.suggestedLength = length;
  6177. if (length <= 2 * rangeChunkSize) {
  6178. return returnValues;
  6179. }
  6180. returnValues.allowRangeRequests = true;
  6181. return returnValues;
  6182. }
  6183. exports.validateRangeRequestCapabilities = validateRangeRequestCapabilities;
  6184. /***/ }),
  6185. /* 53 */
  6186. /***/ (function(module, exports, __w_pdfjs_require__) {
  6187. "use strict";
  6188. Object.defineProperty(exports, "__esModule", {
  6189. value: true
  6190. });
  6191. exports.WebGLUtils = undefined;
  6192. var _dom_utils = __w_pdfjs_require__(7);
  6193. var _util = __w_pdfjs_require__(0);
  6194. var WebGLUtils = function WebGLUtilsClosure() {
  6195. function loadShader(gl, code, shaderType) {
  6196. var shader = gl.createShader(shaderType);
  6197. gl.shaderSource(shader, code);
  6198. gl.compileShader(shader);
  6199. var compiled = gl.getShaderParameter(shader, gl.COMPILE_STATUS);
  6200. if (!compiled) {
  6201. var errorMsg = gl.getShaderInfoLog(shader);
  6202. throw new Error('Error during shader compilation: ' + errorMsg);
  6203. }
  6204. return shader;
  6205. }
  6206. function createVertexShader(gl, code) {
  6207. return loadShader(gl, code, gl.VERTEX_SHADER);
  6208. }
  6209. function createFragmentShader(gl, code) {
  6210. return loadShader(gl, code, gl.FRAGMENT_SHADER);
  6211. }
  6212. function createProgram(gl, shaders) {
  6213. var program = gl.createProgram();
  6214. for (var i = 0, ii = shaders.length; i < ii; ++i) {
  6215. gl.attachShader(program, shaders[i]);
  6216. }
  6217. gl.linkProgram(program);
  6218. var linked = gl.getProgramParameter(program, gl.LINK_STATUS);
  6219. if (!linked) {
  6220. var errorMsg = gl.getProgramInfoLog(program);
  6221. throw new Error('Error during program linking: ' + errorMsg);
  6222. }
  6223. return program;
  6224. }
  6225. function createTexture(gl, image, textureId) {
  6226. gl.activeTexture(textureId);
  6227. var texture = gl.createTexture();
  6228. gl.bindTexture(gl.TEXTURE_2D, texture);
  6229. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
  6230. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
  6231. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);
  6232. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);
  6233. gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, image);
  6234. return texture;
  6235. }
  6236. var currentGL, currentCanvas;
  6237. function generateGL() {
  6238. if (currentGL) {
  6239. return;
  6240. }
  6241. currentCanvas = document.createElement('canvas');
  6242. currentGL = currentCanvas.getContext('webgl', { premultipliedalpha: false });
  6243. }
  6244. var smaskVertexShaderCode = '\
  6245. attribute vec2 a_position; \
  6246. attribute vec2 a_texCoord; \
  6247. \
  6248. uniform vec2 u_resolution; \
  6249. \
  6250. varying vec2 v_texCoord; \
  6251. \
  6252. void main() { \
  6253. vec2 clipSpace = (a_position / u_resolution) * 2.0 - 1.0; \
  6254. gl_Position = vec4(clipSpace * vec2(1, -1), 0, 1); \
  6255. \
  6256. v_texCoord = a_texCoord; \
  6257. } ';
  6258. var smaskFragmentShaderCode = '\
  6259. precision mediump float; \
  6260. \
  6261. uniform vec4 u_backdrop; \
  6262. uniform int u_subtype; \
  6263. uniform sampler2D u_image; \
  6264. uniform sampler2D u_mask; \
  6265. \
  6266. varying vec2 v_texCoord; \
  6267. \
  6268. void main() { \
  6269. vec4 imageColor = texture2D(u_image, v_texCoord); \
  6270. vec4 maskColor = texture2D(u_mask, v_texCoord); \
  6271. if (u_backdrop.a > 0.0) { \
  6272. maskColor.rgb = maskColor.rgb * maskColor.a + \
  6273. u_backdrop.rgb * (1.0 - maskColor.a); \
  6274. } \
  6275. float lum; \
  6276. if (u_subtype == 0) { \
  6277. lum = maskColor.a; \
  6278. } else { \
  6279. lum = maskColor.r * 0.3 + maskColor.g * 0.59 + \
  6280. maskColor.b * 0.11; \
  6281. } \
  6282. imageColor.a *= lum; \
  6283. imageColor.rgb *= imageColor.a; \
  6284. gl_FragColor = imageColor; \
  6285. } ';
  6286. var smaskCache = null;
  6287. function initSmaskGL() {
  6288. var canvas, gl;
  6289. generateGL();
  6290. canvas = currentCanvas;
  6291. currentCanvas = null;
  6292. gl = currentGL;
  6293. currentGL = null;
  6294. var vertexShader = createVertexShader(gl, smaskVertexShaderCode);
  6295. var fragmentShader = createFragmentShader(gl, smaskFragmentShaderCode);
  6296. var program = createProgram(gl, [vertexShader, fragmentShader]);
  6297. gl.useProgram(program);
  6298. var cache = {};
  6299. cache.gl = gl;
  6300. cache.canvas = canvas;
  6301. cache.resolutionLocation = gl.getUniformLocation(program, 'u_resolution');
  6302. cache.positionLocation = gl.getAttribLocation(program, 'a_position');
  6303. cache.backdropLocation = gl.getUniformLocation(program, 'u_backdrop');
  6304. cache.subtypeLocation = gl.getUniformLocation(program, 'u_subtype');
  6305. var texCoordLocation = gl.getAttribLocation(program, 'a_texCoord');
  6306. var texLayerLocation = gl.getUniformLocation(program, 'u_image');
  6307. var texMaskLocation = gl.getUniformLocation(program, 'u_mask');
  6308. var texCoordBuffer = gl.createBuffer();
  6309. gl.bindBuffer(gl.ARRAY_BUFFER, texCoordBuffer);
  6310. gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 1.0, 1.0, 0.0, 1.0, 1.0]), gl.STATIC_DRAW);
  6311. gl.enableVertexAttribArray(texCoordLocation);
  6312. gl.vertexAttribPointer(texCoordLocation, 2, gl.FLOAT, false, 0, 0);
  6313. gl.uniform1i(texLayerLocation, 0);
  6314. gl.uniform1i(texMaskLocation, 1);
  6315. smaskCache = cache;
  6316. }
  6317. function composeSMask(layer, mask, properties) {
  6318. var width = layer.width,
  6319. height = layer.height;
  6320. if (!smaskCache) {
  6321. initSmaskGL();
  6322. }
  6323. var cache = smaskCache,
  6324. canvas = cache.canvas,
  6325. gl = cache.gl;
  6326. canvas.width = width;
  6327. canvas.height = height;
  6328. gl.viewport(0, 0, gl.drawingBufferWidth, gl.drawingBufferHeight);
  6329. gl.uniform2f(cache.resolutionLocation, width, height);
  6330. if (properties.backdrop) {
  6331. gl.uniform4f(cache.resolutionLocation, properties.backdrop[0], properties.backdrop[1], properties.backdrop[2], 1);
  6332. } else {
  6333. gl.uniform4f(cache.resolutionLocation, 0, 0, 0, 0);
  6334. }
  6335. gl.uniform1i(cache.subtypeLocation, properties.subtype === 'Luminosity' ? 1 : 0);
  6336. var texture = createTexture(gl, layer, gl.TEXTURE0);
  6337. var maskTexture = createTexture(gl, mask, gl.TEXTURE1);
  6338. var buffer = gl.createBuffer();
  6339. gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
  6340. gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([0, 0, width, 0, 0, height, 0, height, width, 0, width, height]), gl.STATIC_DRAW);
  6341. gl.enableVertexAttribArray(cache.positionLocation);
  6342. gl.vertexAttribPointer(cache.positionLocation, 2, gl.FLOAT, false, 0, 0);
  6343. gl.clearColor(0, 0, 0, 0);
  6344. gl.enable(gl.BLEND);
  6345. gl.blendFunc(gl.ONE, gl.ONE_MINUS_SRC_ALPHA);
  6346. gl.clear(gl.COLOR_BUFFER_BIT);
  6347. gl.drawArrays(gl.TRIANGLES, 0, 6);
  6348. gl.flush();
  6349. gl.deleteTexture(texture);
  6350. gl.deleteTexture(maskTexture);
  6351. gl.deleteBuffer(buffer);
  6352. return canvas;
  6353. }
  6354. var figuresVertexShaderCode = '\
  6355. attribute vec2 a_position; \
  6356. attribute vec3 a_color; \
  6357. \
  6358. uniform vec2 u_resolution; \
  6359. uniform vec2 u_scale; \
  6360. uniform vec2 u_offset; \
  6361. \
  6362. varying vec4 v_color; \
  6363. \
  6364. void main() { \
  6365. vec2 position = (a_position + u_offset) * u_scale; \
  6366. vec2 clipSpace = (position / u_resolution) * 2.0 - 1.0; \
  6367. gl_Position = vec4(clipSpace * vec2(1, -1), 0, 1); \
  6368. \
  6369. v_color = vec4(a_color / 255.0, 1.0); \
  6370. } ';
  6371. var figuresFragmentShaderCode = '\
  6372. precision mediump float; \
  6373. \
  6374. varying vec4 v_color; \
  6375. \
  6376. void main() { \
  6377. gl_FragColor = v_color; \
  6378. } ';
  6379. var figuresCache = null;
  6380. function initFiguresGL() {
  6381. var canvas, gl;
  6382. generateGL();
  6383. canvas = currentCanvas;
  6384. currentCanvas = null;
  6385. gl = currentGL;
  6386. currentGL = null;
  6387. var vertexShader = createVertexShader(gl, figuresVertexShaderCode);
  6388. var fragmentShader = createFragmentShader(gl, figuresFragmentShaderCode);
  6389. var program = createProgram(gl, [vertexShader, fragmentShader]);
  6390. gl.useProgram(program);
  6391. var cache = {};
  6392. cache.gl = gl;
  6393. cache.canvas = canvas;
  6394. cache.resolutionLocation = gl.getUniformLocation(program, 'u_resolution');
  6395. cache.scaleLocation = gl.getUniformLocation(program, 'u_scale');
  6396. cache.offsetLocation = gl.getUniformLocation(program, 'u_offset');
  6397. cache.positionLocation = gl.getAttribLocation(program, 'a_position');
  6398. cache.colorLocation = gl.getAttribLocation(program, 'a_color');
  6399. figuresCache = cache;
  6400. }
  6401. function drawFigures(width, height, backgroundColor, figures, context) {
  6402. if (!figuresCache) {
  6403. initFiguresGL();
  6404. }
  6405. var cache = figuresCache,
  6406. canvas = cache.canvas,
  6407. gl = cache.gl;
  6408. canvas.width = width;
  6409. canvas.height = height;
  6410. gl.viewport(0, 0, gl.drawingBufferWidth, gl.drawingBufferHeight);
  6411. gl.uniform2f(cache.resolutionLocation, width, height);
  6412. var count = 0;
  6413. var i, ii, rows;
  6414. for (i = 0, ii = figures.length; i < ii; i++) {
  6415. switch (figures[i].type) {
  6416. case 'lattice':
  6417. rows = figures[i].coords.length / figures[i].verticesPerRow | 0;
  6418. count += (rows - 1) * (figures[i].verticesPerRow - 1) * 6;
  6419. break;
  6420. case 'triangles':
  6421. count += figures[i].coords.length;
  6422. break;
  6423. }
  6424. }
  6425. var coords = new Float32Array(count * 2);
  6426. var colors = new Uint8Array(count * 3);
  6427. var coordsMap = context.coords,
  6428. colorsMap = context.colors;
  6429. var pIndex = 0,
  6430. cIndex = 0;
  6431. for (i = 0, ii = figures.length; i < ii; i++) {
  6432. var figure = figures[i],
  6433. ps = figure.coords,
  6434. cs = figure.colors;
  6435. switch (figure.type) {
  6436. case 'lattice':
  6437. var cols = figure.verticesPerRow;
  6438. rows = ps.length / cols | 0;
  6439. for (var row = 1; row < rows; row++) {
  6440. var offset = row * cols + 1;
  6441. for (var col = 1; col < cols; col++, offset++) {
  6442. coords[pIndex] = coordsMap[ps[offset - cols - 1]];
  6443. coords[pIndex + 1] = coordsMap[ps[offset - cols - 1] + 1];
  6444. coords[pIndex + 2] = coordsMap[ps[offset - cols]];
  6445. coords[pIndex + 3] = coordsMap[ps[offset - cols] + 1];
  6446. coords[pIndex + 4] = coordsMap[ps[offset - 1]];
  6447. coords[pIndex + 5] = coordsMap[ps[offset - 1] + 1];
  6448. colors[cIndex] = colorsMap[cs[offset - cols - 1]];
  6449. colors[cIndex + 1] = colorsMap[cs[offset - cols - 1] + 1];
  6450. colors[cIndex + 2] = colorsMap[cs[offset - cols - 1] + 2];
  6451. colors[cIndex + 3] = colorsMap[cs[offset - cols]];
  6452. colors[cIndex + 4] = colorsMap[cs[offset - cols] + 1];
  6453. colors[cIndex + 5] = colorsMap[cs[offset - cols] + 2];
  6454. colors[cIndex + 6] = colorsMap[cs[offset - 1]];
  6455. colors[cIndex + 7] = colorsMap[cs[offset - 1] + 1];
  6456. colors[cIndex + 8] = colorsMap[cs[offset - 1] + 2];
  6457. coords[pIndex + 6] = coords[pIndex + 2];
  6458. coords[pIndex + 7] = coords[pIndex + 3];
  6459. coords[pIndex + 8] = coords[pIndex + 4];
  6460. coords[pIndex + 9] = coords[pIndex + 5];
  6461. coords[pIndex + 10] = coordsMap[ps[offset]];
  6462. coords[pIndex + 11] = coordsMap[ps[offset] + 1];
  6463. colors[cIndex + 9] = colors[cIndex + 3];
  6464. colors[cIndex + 10] = colors[cIndex + 4];
  6465. colors[cIndex + 11] = colors[cIndex + 5];
  6466. colors[cIndex + 12] = colors[cIndex + 6];
  6467. colors[cIndex + 13] = colors[cIndex + 7];
  6468. colors[cIndex + 14] = colors[cIndex + 8];
  6469. colors[cIndex + 15] = colorsMap[cs[offset]];
  6470. colors[cIndex + 16] = colorsMap[cs[offset] + 1];
  6471. colors[cIndex + 17] = colorsMap[cs[offset] + 2];
  6472. pIndex += 12;
  6473. cIndex += 18;
  6474. }
  6475. }
  6476. break;
  6477. case 'triangles':
  6478. for (var j = 0, jj = ps.length; j < jj; j++) {
  6479. coords[pIndex] = coordsMap[ps[j]];
  6480. coords[pIndex + 1] = coordsMap[ps[j] + 1];
  6481. colors[cIndex] = colorsMap[cs[j]];
  6482. colors[cIndex + 1] = colorsMap[cs[j] + 1];
  6483. colors[cIndex + 2] = colorsMap[cs[j] + 2];
  6484. pIndex += 2;
  6485. cIndex += 3;
  6486. }
  6487. break;
  6488. }
  6489. }
  6490. if (backgroundColor) {
  6491. gl.clearColor(backgroundColor[0] / 255, backgroundColor[1] / 255, backgroundColor[2] / 255, 1.0);
  6492. } else {
  6493. gl.clearColor(0, 0, 0, 0);
  6494. }
  6495. gl.clear(gl.COLOR_BUFFER_BIT);
  6496. var coordsBuffer = gl.createBuffer();
  6497. gl.bindBuffer(gl.ARRAY_BUFFER, coordsBuffer);
  6498. gl.bufferData(gl.ARRAY_BUFFER, coords, gl.STATIC_DRAW);
  6499. gl.enableVertexAttribArray(cache.positionLocation);
  6500. gl.vertexAttribPointer(cache.positionLocation, 2, gl.FLOAT, false, 0, 0);
  6501. var colorsBuffer = gl.createBuffer();
  6502. gl.bindBuffer(gl.ARRAY_BUFFER, colorsBuffer);
  6503. gl.bufferData(gl.ARRAY_BUFFER, colors, gl.STATIC_DRAW);
  6504. gl.enableVertexAttribArray(cache.colorLocation);
  6505. gl.vertexAttribPointer(cache.colorLocation, 3, gl.UNSIGNED_BYTE, false, 0, 0);
  6506. gl.uniform2f(cache.scaleLocation, context.scaleX, context.scaleY);
  6507. gl.uniform2f(cache.offsetLocation, context.offsetX, context.offsetY);
  6508. gl.drawArrays(gl.TRIANGLES, 0, count);
  6509. gl.flush();
  6510. gl.deleteBuffer(coordsBuffer);
  6511. gl.deleteBuffer(colorsBuffer);
  6512. return canvas;
  6513. }
  6514. function cleanup() {
  6515. if (smaskCache && smaskCache.canvas) {
  6516. smaskCache.canvas.width = 0;
  6517. smaskCache.canvas.height = 0;
  6518. }
  6519. if (figuresCache && figuresCache.canvas) {
  6520. figuresCache.canvas.width = 0;
  6521. figuresCache.canvas.height = 0;
  6522. }
  6523. smaskCache = null;
  6524. figuresCache = null;
  6525. }
  6526. return {
  6527. get isEnabled() {
  6528. if ((0, _dom_utils.getDefaultSetting)('disableWebGL')) {
  6529. return false;
  6530. }
  6531. var enabled = false;
  6532. try {
  6533. generateGL();
  6534. enabled = !!currentGL;
  6535. } catch (e) {}
  6536. return (0, _util.shadow)(this, 'isEnabled', enabled);
  6537. },
  6538. composeSMask: composeSMask,
  6539. drawFigures: drawFigures,
  6540. clear: cleanup
  6541. };
  6542. }();
  6543. exports.WebGLUtils = WebGLUtils;
  6544. /***/ }),
  6545. /* 54 */
  6546. /***/ (function(module, exports, __w_pdfjs_require__) {
  6547. "use strict";
  6548. Object.defineProperty(exports, "__esModule", {
  6549. value: true
  6550. });
  6551. exports.PDFJS = exports.isWorker = exports.globalScope = undefined;
  6552. var _api = __w_pdfjs_require__(30);
  6553. var _dom_utils = __w_pdfjs_require__(7);
  6554. var _util = __w_pdfjs_require__(0);
  6555. var _annotation_layer = __w_pdfjs_require__(29);
  6556. var _global_scope = __w_pdfjs_require__(14);
  6557. var _global_scope2 = _interopRequireDefault(_global_scope);
  6558. var _metadata = __w_pdfjs_require__(51);
  6559. var _text_layer = __w_pdfjs_require__(32);
  6560. var _svg = __w_pdfjs_require__(31);
  6561. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  6562. var isWorker = typeof window === 'undefined';
  6563. if (!_global_scope2.default.PDFJS) {
  6564. _global_scope2.default.PDFJS = {};
  6565. }
  6566. var PDFJS = _global_scope2.default.PDFJS;
  6567. {
  6568. PDFJS.version = '1.9.478';
  6569. PDFJS.build = '798e46da';
  6570. }
  6571. PDFJS.pdfBug = false;
  6572. if (PDFJS.verbosity !== undefined) {
  6573. (0, _util.setVerbosityLevel)(PDFJS.verbosity);
  6574. }
  6575. delete PDFJS.verbosity;
  6576. Object.defineProperty(PDFJS, 'verbosity', {
  6577. get: function get() {
  6578. return (0, _util.getVerbosityLevel)();
  6579. },
  6580. set: function set(level) {
  6581. (0, _util.setVerbosityLevel)(level);
  6582. },
  6583. enumerable: true,
  6584. configurable: true
  6585. });
  6586. PDFJS.VERBOSITY_LEVELS = _util.VERBOSITY_LEVELS;
  6587. PDFJS.OPS = _util.OPS;
  6588. PDFJS.UNSUPPORTED_FEATURES = _util.UNSUPPORTED_FEATURES;
  6589. PDFJS.isValidUrl = _dom_utils.isValidUrl;
  6590. PDFJS.shadow = _util.shadow;
  6591. PDFJS.createBlob = _util.createBlob;
  6592. PDFJS.createObjectURL = function PDFJS_createObjectURL(data, contentType) {
  6593. return (0, _util.createObjectURL)(data, contentType, PDFJS.disableCreateObjectURL);
  6594. };
  6595. Object.defineProperty(PDFJS, 'isLittleEndian', {
  6596. configurable: true,
  6597. get: function PDFJS_isLittleEndian() {
  6598. return (0, _util.shadow)(PDFJS, 'isLittleEndian', (0, _util.isLittleEndian)());
  6599. }
  6600. });
  6601. PDFJS.removeNullCharacters = _util.removeNullCharacters;
  6602. PDFJS.PasswordResponses = _util.PasswordResponses;
  6603. PDFJS.PasswordException = _util.PasswordException;
  6604. PDFJS.UnknownErrorException = _util.UnknownErrorException;
  6605. PDFJS.InvalidPDFException = _util.InvalidPDFException;
  6606. PDFJS.MissingPDFException = _util.MissingPDFException;
  6607. PDFJS.UnexpectedResponseException = _util.UnexpectedResponseException;
  6608. PDFJS.Util = _util.Util;
  6609. PDFJS.PageViewport = _util.PageViewport;
  6610. PDFJS.createPromiseCapability = _util.createPromiseCapability;
  6611. PDFJS.maxImageSize = PDFJS.maxImageSize === undefined ? -1 : PDFJS.maxImageSize;
  6612. PDFJS.cMapUrl = PDFJS.cMapUrl === undefined ? null : PDFJS.cMapUrl;
  6613. PDFJS.cMapPacked = PDFJS.cMapPacked === undefined ? false : PDFJS.cMapPacked;
  6614. PDFJS.disableFontFace = PDFJS.disableFontFace === undefined ? false : PDFJS.disableFontFace;
  6615. PDFJS.imageResourcesPath = PDFJS.imageResourcesPath === undefined ? '' : PDFJS.imageResourcesPath;
  6616. PDFJS.disableWorker = PDFJS.disableWorker === undefined ? false : PDFJS.disableWorker;
  6617. PDFJS.workerSrc = PDFJS.workerSrc === undefined ? null : PDFJS.workerSrc;
  6618. PDFJS.workerPort = PDFJS.workerPort === undefined ? null : PDFJS.workerPort;
  6619. PDFJS.disableRange = PDFJS.disableRange === undefined ? false : PDFJS.disableRange;
  6620. PDFJS.disableStream = PDFJS.disableStream === undefined ? false : PDFJS.disableStream;
  6621. PDFJS.disableAutoFetch = PDFJS.disableAutoFetch === undefined ? false : PDFJS.disableAutoFetch;
  6622. PDFJS.pdfBug = PDFJS.pdfBug === undefined ? false : PDFJS.pdfBug;
  6623. PDFJS.postMessageTransfers = PDFJS.postMessageTransfers === undefined ? true : PDFJS.postMessageTransfers;
  6624. PDFJS.disableCreateObjectURL = PDFJS.disableCreateObjectURL === undefined ? false : PDFJS.disableCreateObjectURL;
  6625. PDFJS.disableWebGL = PDFJS.disableWebGL === undefined ? true : PDFJS.disableWebGL;
  6626. PDFJS.externalLinkTarget = PDFJS.externalLinkTarget === undefined ? _dom_utils.LinkTarget.NONE : PDFJS.externalLinkTarget;
  6627. PDFJS.externalLinkRel = PDFJS.externalLinkRel === undefined ? _dom_utils.DEFAULT_LINK_REL : PDFJS.externalLinkRel;
  6628. PDFJS.isEvalSupported = PDFJS.isEvalSupported === undefined ? true : PDFJS.isEvalSupported;
  6629. PDFJS.pdfjsNext = PDFJS.pdfjsNext === undefined ? false : PDFJS.pdfjsNext;
  6630. {
  6631. var savedOpenExternalLinksInNewWindow = PDFJS.openExternalLinksInNewWindow;
  6632. delete PDFJS.openExternalLinksInNewWindow;
  6633. Object.defineProperty(PDFJS, 'openExternalLinksInNewWindow', {
  6634. get: function get() {
  6635. return PDFJS.externalLinkTarget === _dom_utils.LinkTarget.BLANK;
  6636. },
  6637. set: function set(value) {
  6638. if (value) {
  6639. (0, _util.deprecated)('PDFJS.openExternalLinksInNewWindow, please use ' + '"PDFJS.externalLinkTarget = PDFJS.LinkTarget.BLANK" instead.');
  6640. }
  6641. if (PDFJS.externalLinkTarget !== _dom_utils.LinkTarget.NONE) {
  6642. (0, _util.warn)('PDFJS.externalLinkTarget is already initialized');
  6643. return;
  6644. }
  6645. PDFJS.externalLinkTarget = value ? _dom_utils.LinkTarget.BLANK : _dom_utils.LinkTarget.NONE;
  6646. },
  6647. enumerable: true,
  6648. configurable: true
  6649. });
  6650. if (savedOpenExternalLinksInNewWindow) {
  6651. PDFJS.openExternalLinksInNewWindow = savedOpenExternalLinksInNewWindow;
  6652. }
  6653. }
  6654. PDFJS.getDocument = _api.getDocument;
  6655. PDFJS.LoopbackPort = _api.LoopbackPort;
  6656. PDFJS.PDFDataRangeTransport = _api.PDFDataRangeTransport;
  6657. PDFJS.PDFWorker = _api.PDFWorker;
  6658. PDFJS.hasCanvasTypedArrays = true;
  6659. PDFJS.CustomStyle = _dom_utils.CustomStyle;
  6660. PDFJS.LinkTarget = _dom_utils.LinkTarget;
  6661. PDFJS.addLinkAttributes = _dom_utils.addLinkAttributes;
  6662. PDFJS.getFilenameFromUrl = _dom_utils.getFilenameFromUrl;
  6663. PDFJS.isExternalLinkTargetSet = _dom_utils.isExternalLinkTargetSet;
  6664. PDFJS.AnnotationLayer = _annotation_layer.AnnotationLayer;
  6665. PDFJS.renderTextLayer = _text_layer.renderTextLayer;
  6666. PDFJS.Metadata = _metadata.Metadata;
  6667. PDFJS.SVGGraphics = _svg.SVGGraphics;
  6668. PDFJS.UnsupportedManager = _api._UnsupportedManager;
  6669. exports.globalScope = _global_scope2.default;
  6670. exports.isWorker = isWorker;
  6671. exports.PDFJS = PDFJS;
  6672. /***/ }),
  6673. /* 55 */
  6674. /***/ (function(module, exports, __w_pdfjs_require__) {
  6675. "use strict";
  6676. Object.defineProperty(exports, "__esModule", {
  6677. value: true
  6678. });
  6679. exports.NetworkManager = exports.PDFNetworkStream = undefined;
  6680. var _util = __w_pdfjs_require__(0);
  6681. var _global_scope = __w_pdfjs_require__(14);
  6682. var _global_scope2 = _interopRequireDefault(_global_scope);
  6683. var _network_utils = __w_pdfjs_require__(52);
  6684. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  6685. ;
  6686. var OK_RESPONSE = 200;
  6687. var PARTIAL_CONTENT_RESPONSE = 206;
  6688. function NetworkManager(url, args) {
  6689. this.url = url;
  6690. args = args || {};
  6691. this.isHttp = /^https?:/i.test(url);
  6692. this.httpHeaders = this.isHttp && args.httpHeaders || {};
  6693. this.withCredentials = args.withCredentials || false;
  6694. this.getXhr = args.getXhr || function NetworkManager_getXhr() {
  6695. return new XMLHttpRequest();
  6696. };
  6697. this.currXhrId = 0;
  6698. this.pendingRequests = Object.create(null);
  6699. this.loadedRequests = Object.create(null);
  6700. }
  6701. function getArrayBuffer(xhr) {
  6702. var data = xhr.response;
  6703. if (typeof data !== 'string') {
  6704. return data;
  6705. }
  6706. var length = data.length;
  6707. var array = new Uint8Array(length);
  6708. for (var i = 0; i < length; i++) {
  6709. array[i] = data.charCodeAt(i) & 0xFF;
  6710. }
  6711. return array.buffer;
  6712. }
  6713. var supportsMozChunked = function supportsMozChunkedClosure() {
  6714. try {
  6715. var x = new XMLHttpRequest();
  6716. x.open('GET', _global_scope2.default.location.href);
  6717. x.responseType = 'moz-chunked-arraybuffer';
  6718. return x.responseType === 'moz-chunked-arraybuffer';
  6719. } catch (e) {
  6720. return false;
  6721. }
  6722. }();
  6723. NetworkManager.prototype = {
  6724. requestRange: function NetworkManager_requestRange(begin, end, listeners) {
  6725. var args = {
  6726. begin: begin,
  6727. end: end
  6728. };
  6729. for (var prop in listeners) {
  6730. args[prop] = listeners[prop];
  6731. }
  6732. return this.request(args);
  6733. },
  6734. requestFull: function NetworkManager_requestFull(listeners) {
  6735. return this.request(listeners);
  6736. },
  6737. request: function NetworkManager_request(args) {
  6738. var xhr = this.getXhr();
  6739. var xhrId = this.currXhrId++;
  6740. var pendingRequest = this.pendingRequests[xhrId] = { xhr: xhr };
  6741. xhr.open('GET', this.url);
  6742. xhr.withCredentials = this.withCredentials;
  6743. for (var property in this.httpHeaders) {
  6744. var value = this.httpHeaders[property];
  6745. if (typeof value === 'undefined') {
  6746. continue;
  6747. }
  6748. xhr.setRequestHeader(property, value);
  6749. }
  6750. if (this.isHttp && 'begin' in args && 'end' in args) {
  6751. var rangeStr = args.begin + '-' + (args.end - 1);
  6752. xhr.setRequestHeader('Range', 'bytes=' + rangeStr);
  6753. pendingRequest.expectedStatus = 206;
  6754. } else {
  6755. pendingRequest.expectedStatus = 200;
  6756. }
  6757. var useMozChunkedLoading = supportsMozChunked && !!args.onProgressiveData;
  6758. if (useMozChunkedLoading) {
  6759. xhr.responseType = 'moz-chunked-arraybuffer';
  6760. pendingRequest.onProgressiveData = args.onProgressiveData;
  6761. pendingRequest.mozChunked = true;
  6762. } else {
  6763. xhr.responseType = 'arraybuffer';
  6764. }
  6765. if (args.onError) {
  6766. xhr.onerror = function (evt) {
  6767. args.onError(xhr.status);
  6768. };
  6769. }
  6770. xhr.onreadystatechange = this.onStateChange.bind(this, xhrId);
  6771. xhr.onprogress = this.onProgress.bind(this, xhrId);
  6772. pendingRequest.onHeadersReceived = args.onHeadersReceived;
  6773. pendingRequest.onDone = args.onDone;
  6774. pendingRequest.onError = args.onError;
  6775. pendingRequest.onProgress = args.onProgress;
  6776. xhr.send(null);
  6777. return xhrId;
  6778. },
  6779. onProgress: function NetworkManager_onProgress(xhrId, evt) {
  6780. var pendingRequest = this.pendingRequests[xhrId];
  6781. if (!pendingRequest) {
  6782. return;
  6783. }
  6784. if (pendingRequest.mozChunked) {
  6785. var chunk = getArrayBuffer(pendingRequest.xhr);
  6786. pendingRequest.onProgressiveData(chunk);
  6787. }
  6788. var onProgress = pendingRequest.onProgress;
  6789. if (onProgress) {
  6790. onProgress(evt);
  6791. }
  6792. },
  6793. onStateChange: function NetworkManager_onStateChange(xhrId, evt) {
  6794. var pendingRequest = this.pendingRequests[xhrId];
  6795. if (!pendingRequest) {
  6796. return;
  6797. }
  6798. var xhr = pendingRequest.xhr;
  6799. if (xhr.readyState >= 2 && pendingRequest.onHeadersReceived) {
  6800. pendingRequest.onHeadersReceived();
  6801. delete pendingRequest.onHeadersReceived;
  6802. }
  6803. if (xhr.readyState !== 4) {
  6804. return;
  6805. }
  6806. if (!(xhrId in this.pendingRequests)) {
  6807. return;
  6808. }
  6809. delete this.pendingRequests[xhrId];
  6810. if (xhr.status === 0 && this.isHttp) {
  6811. if (pendingRequest.onError) {
  6812. pendingRequest.onError(xhr.status);
  6813. }
  6814. return;
  6815. }
  6816. var xhrStatus = xhr.status || OK_RESPONSE;
  6817. var ok_response_on_range_request = xhrStatus === OK_RESPONSE && pendingRequest.expectedStatus === PARTIAL_CONTENT_RESPONSE;
  6818. if (!ok_response_on_range_request && xhrStatus !== pendingRequest.expectedStatus) {
  6819. if (pendingRequest.onError) {
  6820. pendingRequest.onError(xhr.status);
  6821. }
  6822. return;
  6823. }
  6824. this.loadedRequests[xhrId] = true;
  6825. var chunk = getArrayBuffer(xhr);
  6826. if (xhrStatus === PARTIAL_CONTENT_RESPONSE) {
  6827. var rangeHeader = xhr.getResponseHeader('Content-Range');
  6828. var matches = /bytes (\d+)-(\d+)\/(\d+)/.exec(rangeHeader);
  6829. var begin = parseInt(matches[1], 10);
  6830. pendingRequest.onDone({
  6831. begin: begin,
  6832. chunk: chunk
  6833. });
  6834. } else if (pendingRequest.onProgressiveData) {
  6835. pendingRequest.onDone(null);
  6836. } else if (chunk) {
  6837. pendingRequest.onDone({
  6838. begin: 0,
  6839. chunk: chunk
  6840. });
  6841. } else if (pendingRequest.onError) {
  6842. pendingRequest.onError(xhr.status);
  6843. }
  6844. },
  6845. hasPendingRequests: function NetworkManager_hasPendingRequests() {
  6846. for (var xhrId in this.pendingRequests) {
  6847. return true;
  6848. }
  6849. return false;
  6850. },
  6851. getRequestXhr: function NetworkManager_getXhr(xhrId) {
  6852. return this.pendingRequests[xhrId].xhr;
  6853. },
  6854. isStreamingRequest: function NetworkManager_isStreamingRequest(xhrId) {
  6855. return !!this.pendingRequests[xhrId].onProgressiveData;
  6856. },
  6857. isPendingRequest: function NetworkManager_isPendingRequest(xhrId) {
  6858. return xhrId in this.pendingRequests;
  6859. },
  6860. isLoadedRequest: function NetworkManager_isLoadedRequest(xhrId) {
  6861. return xhrId in this.loadedRequests;
  6862. },
  6863. abortAllRequests: function NetworkManager_abortAllRequests() {
  6864. for (var xhrId in this.pendingRequests) {
  6865. this.abortRequest(xhrId | 0);
  6866. }
  6867. },
  6868. abortRequest: function NetworkManager_abortRequest(xhrId) {
  6869. var xhr = this.pendingRequests[xhrId].xhr;
  6870. delete this.pendingRequests[xhrId];
  6871. xhr.abort();
  6872. }
  6873. };
  6874. function PDFNetworkStream(options) {
  6875. this._options = options;
  6876. var source = options.source;
  6877. this._manager = new NetworkManager(source.url, {
  6878. httpHeaders: source.httpHeaders,
  6879. withCredentials: source.withCredentials
  6880. });
  6881. this._rangeChunkSize = source.rangeChunkSize;
  6882. this._fullRequestReader = null;
  6883. this._rangeRequestReaders = [];
  6884. }
  6885. PDFNetworkStream.prototype = {
  6886. _onRangeRequestReaderClosed: function PDFNetworkStream_onRangeRequestReaderClosed(reader) {
  6887. var i = this._rangeRequestReaders.indexOf(reader);
  6888. if (i >= 0) {
  6889. this._rangeRequestReaders.splice(i, 1);
  6890. }
  6891. },
  6892. getFullReader: function PDFNetworkStream_getFullReader() {
  6893. (0, _util.assert)(!this._fullRequestReader);
  6894. this._fullRequestReader = new PDFNetworkStreamFullRequestReader(this._manager, this._options);
  6895. return this._fullRequestReader;
  6896. },
  6897. getRangeReader: function PDFNetworkStream_getRangeReader(begin, end) {
  6898. var reader = new PDFNetworkStreamRangeRequestReader(this._manager, begin, end);
  6899. reader.onClosed = this._onRangeRequestReaderClosed.bind(this);
  6900. this._rangeRequestReaders.push(reader);
  6901. return reader;
  6902. },
  6903. cancelAllRequests: function PDFNetworkStream_cancelAllRequests(reason) {
  6904. if (this._fullRequestReader) {
  6905. this._fullRequestReader.cancel(reason);
  6906. }
  6907. var readers = this._rangeRequestReaders.slice(0);
  6908. readers.forEach(function (reader) {
  6909. reader.cancel(reason);
  6910. });
  6911. }
  6912. };
  6913. function PDFNetworkStreamFullRequestReader(manager, options) {
  6914. this._manager = manager;
  6915. var source = options.source;
  6916. var args = {
  6917. onHeadersReceived: this._onHeadersReceived.bind(this),
  6918. onProgressiveData: source.disableStream ? null : this._onProgressiveData.bind(this),
  6919. onDone: this._onDone.bind(this),
  6920. onError: this._onError.bind(this),
  6921. onProgress: this._onProgress.bind(this)
  6922. };
  6923. this._url = source.url;
  6924. this._fullRequestId = manager.requestFull(args);
  6925. this._headersReceivedCapability = (0, _util.createPromiseCapability)();
  6926. this._disableRange = options.disableRange || false;
  6927. this._contentLength = source.length;
  6928. this._rangeChunkSize = source.rangeChunkSize;
  6929. if (!this._rangeChunkSize && !this._disableRange) {
  6930. this._disableRange = true;
  6931. }
  6932. this._isStreamingSupported = false;
  6933. this._isRangeSupported = false;
  6934. this._cachedChunks = [];
  6935. this._requests = [];
  6936. this._done = false;
  6937. this._storedError = undefined;
  6938. this.onProgress = null;
  6939. }
  6940. PDFNetworkStreamFullRequestReader.prototype = {
  6941. _onHeadersReceived: function PDFNetworkStreamFullRequestReader_onHeadersReceived() {
  6942. var fullRequestXhrId = this._fullRequestId;
  6943. var fullRequestXhr = this._manager.getRequestXhr(fullRequestXhrId);
  6944. var _validateRangeRequest = (0, _network_utils.validateRangeRequestCapabilities)({
  6945. getResponseHeader: function getResponseHeader(name) {
  6946. return fullRequestXhr.getResponseHeader(name);
  6947. },
  6948. isHttp: this._manager.isHttp,
  6949. rangeChunkSize: this._rangeChunkSize,
  6950. disableRange: this._disableRange
  6951. }),
  6952. allowRangeRequests = _validateRangeRequest.allowRangeRequests,
  6953. suggestedLength = _validateRangeRequest.suggestedLength;
  6954. this._contentLength = suggestedLength || this._contentLength;
  6955. if (allowRangeRequests) {
  6956. this._isRangeSupported = true;
  6957. }
  6958. var networkManager = this._manager;
  6959. if (networkManager.isStreamingRequest(fullRequestXhrId)) {
  6960. this._isStreamingSupported = true;
  6961. } else if (this._isRangeSupported) {
  6962. networkManager.abortRequest(fullRequestXhrId);
  6963. }
  6964. this._headersReceivedCapability.resolve();
  6965. },
  6966. _onProgressiveData: function PDFNetworkStreamFullRequestReader_onProgressiveData(chunk) {
  6967. if (this._requests.length > 0) {
  6968. var requestCapability = this._requests.shift();
  6969. requestCapability.resolve({
  6970. value: chunk,
  6971. done: false
  6972. });
  6973. } else {
  6974. this._cachedChunks.push(chunk);
  6975. }
  6976. },
  6977. _onDone: function PDFNetworkStreamFullRequestReader_onDone(args) {
  6978. if (args) {
  6979. this._onProgressiveData(args.chunk);
  6980. }
  6981. this._done = true;
  6982. if (this._cachedChunks.length > 0) {
  6983. return;
  6984. }
  6985. this._requests.forEach(function (requestCapability) {
  6986. requestCapability.resolve({
  6987. value: undefined,
  6988. done: true
  6989. });
  6990. });
  6991. this._requests = [];
  6992. },
  6993. _onError: function PDFNetworkStreamFullRequestReader_onError(status) {
  6994. var url = this._url;
  6995. var exception;
  6996. if (status === 404 || status === 0 && /^file:/.test(url)) {
  6997. exception = new _util.MissingPDFException('Missing PDF "' + url + '".');
  6998. } else {
  6999. exception = new _util.UnexpectedResponseException('Unexpected server response (' + status + ') while retrieving PDF "' + url + '".', status);
  7000. }
  7001. this._storedError = exception;
  7002. this._headersReceivedCapability.reject(exception);
  7003. this._requests.forEach(function (requestCapability) {
  7004. requestCapability.reject(exception);
  7005. });
  7006. this._requests = [];
  7007. this._cachedChunks = [];
  7008. },
  7009. _onProgress: function PDFNetworkStreamFullRequestReader_onProgress(data) {
  7010. if (this.onProgress) {
  7011. this.onProgress({
  7012. loaded: data.loaded,
  7013. total: data.lengthComputable ? data.total : this._contentLength
  7014. });
  7015. }
  7016. },
  7017. get isRangeSupported() {
  7018. return this._isRangeSupported;
  7019. },
  7020. get isStreamingSupported() {
  7021. return this._isStreamingSupported;
  7022. },
  7023. get contentLength() {
  7024. return this._contentLength;
  7025. },
  7026. get headersReady() {
  7027. return this._headersReceivedCapability.promise;
  7028. },
  7029. read: function PDFNetworkStreamFullRequestReader_read() {
  7030. if (this._storedError) {
  7031. return Promise.reject(this._storedError);
  7032. }
  7033. if (this._cachedChunks.length > 0) {
  7034. var chunk = this._cachedChunks.shift();
  7035. return Promise.resolve({
  7036. value: chunk,
  7037. done: false
  7038. });
  7039. }
  7040. if (this._done) {
  7041. return Promise.resolve({
  7042. value: undefined,
  7043. done: true
  7044. });
  7045. }
  7046. var requestCapability = (0, _util.createPromiseCapability)();
  7047. this._requests.push(requestCapability);
  7048. return requestCapability.promise;
  7049. },
  7050. cancel: function PDFNetworkStreamFullRequestReader_cancel(reason) {
  7051. this._done = true;
  7052. this._headersReceivedCapability.reject(reason);
  7053. this._requests.forEach(function (requestCapability) {
  7054. requestCapability.resolve({
  7055. value: undefined,
  7056. done: true
  7057. });
  7058. });
  7059. this._requests = [];
  7060. if (this._manager.isPendingRequest(this._fullRequestId)) {
  7061. this._manager.abortRequest(this._fullRequestId);
  7062. }
  7063. this._fullRequestReader = null;
  7064. }
  7065. };
  7066. function PDFNetworkStreamRangeRequestReader(manager, begin, end) {
  7067. this._manager = manager;
  7068. var args = {
  7069. onDone: this._onDone.bind(this),
  7070. onProgress: this._onProgress.bind(this)
  7071. };
  7072. this._requestId = manager.requestRange(begin, end, args);
  7073. this._requests = [];
  7074. this._queuedChunk = null;
  7075. this._done = false;
  7076. this.onProgress = null;
  7077. this.onClosed = null;
  7078. }
  7079. PDFNetworkStreamRangeRequestReader.prototype = {
  7080. _close: function PDFNetworkStreamRangeRequestReader_close() {
  7081. if (this.onClosed) {
  7082. this.onClosed(this);
  7083. }
  7084. },
  7085. _onDone: function PDFNetworkStreamRangeRequestReader_onDone(data) {
  7086. var chunk = data.chunk;
  7087. if (this._requests.length > 0) {
  7088. var requestCapability = this._requests.shift();
  7089. requestCapability.resolve({
  7090. value: chunk,
  7091. done: false
  7092. });
  7093. } else {
  7094. this._queuedChunk = chunk;
  7095. }
  7096. this._done = true;
  7097. this._requests.forEach(function (requestCapability) {
  7098. requestCapability.resolve({
  7099. value: undefined,
  7100. done: true
  7101. });
  7102. });
  7103. this._requests = [];
  7104. this._close();
  7105. },
  7106. _onProgress: function PDFNetworkStreamRangeRequestReader_onProgress(evt) {
  7107. if (!this.isStreamingSupported && this.onProgress) {
  7108. this.onProgress({ loaded: evt.loaded });
  7109. }
  7110. },
  7111. get isStreamingSupported() {
  7112. return false;
  7113. },
  7114. read: function PDFNetworkStreamRangeRequestReader_read() {
  7115. if (this._queuedChunk !== null) {
  7116. var chunk = this._queuedChunk;
  7117. this._queuedChunk = null;
  7118. return Promise.resolve({
  7119. value: chunk,
  7120. done: false
  7121. });
  7122. }
  7123. if (this._done) {
  7124. return Promise.resolve({
  7125. value: undefined,
  7126. done: true
  7127. });
  7128. }
  7129. var requestCapability = (0, _util.createPromiseCapability)();
  7130. this._requests.push(requestCapability);
  7131. return requestCapability.promise;
  7132. },
  7133. cancel: function PDFNetworkStreamRangeRequestReader_cancel(reason) {
  7134. this._done = true;
  7135. this._requests.forEach(function (requestCapability) {
  7136. requestCapability.resolve({
  7137. value: undefined,
  7138. done: true
  7139. });
  7140. });
  7141. this._requests = [];
  7142. if (this._manager.isPendingRequest(this._requestId)) {
  7143. this._manager.abortRequest(this._requestId);
  7144. }
  7145. this._close();
  7146. }
  7147. };
  7148. exports.PDFNetworkStream = PDFNetworkStream;
  7149. exports.NetworkManager = NetworkManager;
  7150. /***/ }),
  7151. /* 56 */
  7152. /***/ (function(module, exports, __w_pdfjs_require__) {
  7153. "use strict";
  7154. Object.defineProperty(exports, "__esModule", {
  7155. value: true
  7156. });
  7157. exports.PDFNodeStream = undefined;
  7158. 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; }; }();
  7159. var _util = __w_pdfjs_require__(0);
  7160. var _network_utils = __w_pdfjs_require__(52);
  7161. 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; }
  7162. 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; }
  7163. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  7164. var fs = require('fs');
  7165. var http = require('http');
  7166. var https = require('https');
  7167. var url = require('url');
  7168. var PDFNodeStream = function () {
  7169. function PDFNodeStream(options) {
  7170. _classCallCheck(this, PDFNodeStream);
  7171. this.options = options;
  7172. this.source = options.source;
  7173. this.url = url.parse(this.source.url);
  7174. this.isHttp = this.url.protocol === 'http:' || this.url.protocol === 'https:';
  7175. this.isFsUrl = this.url.protocol === 'file:' || !this.url.host;
  7176. this.httpHeaders = this.isHttp && this.source.httpHeaders || {};
  7177. this._fullRequest = null;
  7178. this._rangeRequestReaders = [];
  7179. }
  7180. _createClass(PDFNodeStream, [{
  7181. key: 'getFullReader',
  7182. value: function getFullReader() {
  7183. (0, _util.assert)(!this._fullRequest);
  7184. this._fullRequest = this.isFsUrl ? new PDFNodeStreamFsFullReader(this) : new PDFNodeStreamFullReader(this);
  7185. return this._fullRequest;
  7186. }
  7187. }, {
  7188. key: 'getRangeReader',
  7189. value: function getRangeReader(start, end) {
  7190. var rangeReader = this.isFsUrl ? new PDFNodeStreamFsRangeReader(this, start, end) : new PDFNodeStreamRangeReader(this, start, end);
  7191. this._rangeRequestReaders.push(rangeReader);
  7192. return rangeReader;
  7193. }
  7194. }, {
  7195. key: 'cancelAllRequests',
  7196. value: function cancelAllRequests(reason) {
  7197. if (this._fullRequest) {
  7198. this._fullRequest.cancel(reason);
  7199. }
  7200. var readers = this._rangeRequestReaders.slice(0);
  7201. readers.forEach(function (reader) {
  7202. reader.cancel(reason);
  7203. });
  7204. }
  7205. }]);
  7206. return PDFNodeStream;
  7207. }();
  7208. var BaseFullReader = function () {
  7209. function BaseFullReader(stream) {
  7210. _classCallCheck(this, BaseFullReader);
  7211. this._url = stream.url;
  7212. this._done = false;
  7213. this._errored = false;
  7214. this._reason = null;
  7215. this.onProgress = null;
  7216. this._contentLength = stream.source.length;
  7217. this._loaded = 0;
  7218. this._disableRange = stream.options.disableRange || false;
  7219. this._rangeChunkSize = stream.source.rangeChunkSize;
  7220. if (!this._rangeChunkSize && !this._disableRange) {
  7221. this._disableRange = true;
  7222. }
  7223. this._isStreamingSupported = !stream.source.disableStream;
  7224. this._isRangeSupported = !stream.options.disableRange;
  7225. this._readableStream = null;
  7226. this._readCapability = (0, _util.createPromiseCapability)();
  7227. this._headersCapability = (0, _util.createPromiseCapability)();
  7228. }
  7229. _createClass(BaseFullReader, [{
  7230. key: 'read',
  7231. value: function read() {
  7232. var _this = this;
  7233. return this._readCapability.promise.then(function () {
  7234. if (_this._done) {
  7235. return Promise.resolve({
  7236. value: undefined,
  7237. done: true
  7238. });
  7239. }
  7240. if (_this._errored) {
  7241. return Promise.reject(_this._reason);
  7242. }
  7243. var chunk = _this._readableStream.read();
  7244. if (chunk === null) {
  7245. _this._readCapability = (0, _util.createPromiseCapability)();
  7246. return _this.read();
  7247. }
  7248. _this._loaded += chunk.length;
  7249. if (_this.onProgress) {
  7250. _this.onProgress({
  7251. loaded: _this._loaded,
  7252. total: _this._contentLength
  7253. });
  7254. }
  7255. var buffer = new Uint8Array(chunk).buffer;
  7256. return Promise.resolve({
  7257. value: buffer,
  7258. done: false
  7259. });
  7260. });
  7261. }
  7262. }, {
  7263. key: 'cancel',
  7264. value: function cancel(reason) {
  7265. if (!this._readableStream) {
  7266. this._error(reason);
  7267. return;
  7268. }
  7269. this._readableStream.destroy(reason);
  7270. }
  7271. }, {
  7272. key: '_error',
  7273. value: function _error(reason) {
  7274. this._errored = true;
  7275. this._reason = reason;
  7276. this._readCapability.resolve();
  7277. }
  7278. }, {
  7279. key: '_setReadableStream',
  7280. value: function _setReadableStream(readableStream) {
  7281. var _this2 = this;
  7282. this._readableStream = readableStream;
  7283. readableStream.on('readable', function () {
  7284. _this2._readCapability.resolve();
  7285. });
  7286. readableStream.on('end', function () {
  7287. readableStream.destroy();
  7288. _this2._done = true;
  7289. _this2._readCapability.resolve();
  7290. });
  7291. readableStream.on('error', function (reason) {
  7292. _this2._error(reason);
  7293. });
  7294. if (this._errored) {
  7295. this._readableStream.destroy(this._reason);
  7296. }
  7297. }
  7298. }, {
  7299. key: 'headersReady',
  7300. get: function get() {
  7301. return this._headersCapability.promise;
  7302. }
  7303. }, {
  7304. key: 'contentLength',
  7305. get: function get() {
  7306. return this._contentLength;
  7307. }
  7308. }, {
  7309. key: 'isRangeSupported',
  7310. get: function get() {
  7311. return this._isRangeSupported;
  7312. }
  7313. }, {
  7314. key: 'isStreamingSupported',
  7315. get: function get() {
  7316. return this._isStreamingSupported;
  7317. }
  7318. }]);
  7319. return BaseFullReader;
  7320. }();
  7321. var BaseRangeReader = function () {
  7322. function BaseRangeReader(stream) {
  7323. _classCallCheck(this, BaseRangeReader);
  7324. this._url = stream.url;
  7325. this._done = false;
  7326. this._errored = false;
  7327. this._reason = null;
  7328. this.onProgress = null;
  7329. this._loaded = 0;
  7330. this._readableStream = null;
  7331. this._readCapability = (0, _util.createPromiseCapability)();
  7332. this._isStreamingSupported = !stream.source.disableStream;
  7333. }
  7334. _createClass(BaseRangeReader, [{
  7335. key: 'read',
  7336. value: function read() {
  7337. var _this3 = this;
  7338. return this._readCapability.promise.then(function () {
  7339. if (_this3._done) {
  7340. return Promise.resolve({
  7341. value: undefined,
  7342. done: true
  7343. });
  7344. }
  7345. if (_this3._errored) {
  7346. return Promise.reject(_this3._reason);
  7347. }
  7348. var chunk = _this3._readableStream.read();
  7349. if (chunk === null) {
  7350. _this3._readCapability = (0, _util.createPromiseCapability)();
  7351. return _this3.read();
  7352. }
  7353. _this3._loaded += chunk.length;
  7354. if (_this3.onProgress) {
  7355. _this3.onProgress({ loaded: _this3._loaded });
  7356. }
  7357. var buffer = new Uint8Array(chunk).buffer;
  7358. return Promise.resolve({
  7359. value: buffer,
  7360. done: false
  7361. });
  7362. });
  7363. }
  7364. }, {
  7365. key: 'cancel',
  7366. value: function cancel(reason) {
  7367. if (!this._readableStream) {
  7368. this._error(reason);
  7369. return;
  7370. }
  7371. this._readableStream.destroy(reason);
  7372. }
  7373. }, {
  7374. key: '_error',
  7375. value: function _error(reason) {
  7376. this._errored = true;
  7377. this._reason = reason;
  7378. this._readCapability.resolve();
  7379. }
  7380. }, {
  7381. key: '_setReadableStream',
  7382. value: function _setReadableStream(readableStream) {
  7383. var _this4 = this;
  7384. this._readableStream = readableStream;
  7385. readableStream.on('readable', function () {
  7386. _this4._readCapability.resolve();
  7387. });
  7388. readableStream.on('end', function () {
  7389. readableStream.destroy();
  7390. _this4._done = true;
  7391. _this4._readCapability.resolve();
  7392. });
  7393. readableStream.on('error', function (reason) {
  7394. _this4._error(reason);
  7395. });
  7396. if (this._errored) {
  7397. this._readableStream.destroy(this._reason);
  7398. }
  7399. }
  7400. }, {
  7401. key: 'isStreamingSupported',
  7402. get: function get() {
  7403. return this._isStreamingSupported;
  7404. }
  7405. }]);
  7406. return BaseRangeReader;
  7407. }();
  7408. function createRequestOptions(url, headers) {
  7409. return {
  7410. protocol: url.protocol,
  7411. auth: url.auth,
  7412. host: url.hostname,
  7413. port: url.port,
  7414. path: url.path,
  7415. method: 'GET',
  7416. headers: headers
  7417. };
  7418. }
  7419. var PDFNodeStreamFullReader = function (_BaseFullReader) {
  7420. _inherits(PDFNodeStreamFullReader, _BaseFullReader);
  7421. function PDFNodeStreamFullReader(stream) {
  7422. _classCallCheck(this, PDFNodeStreamFullReader);
  7423. var _this5 = _possibleConstructorReturn(this, (PDFNodeStreamFullReader.__proto__ || Object.getPrototypeOf(PDFNodeStreamFullReader)).call(this, stream));
  7424. var handleResponse = function handleResponse(response) {
  7425. _this5._headersCapability.resolve();
  7426. _this5._setReadableStream(response);
  7427. var _validateRangeRequest = (0, _network_utils.validateRangeRequestCapabilities)({
  7428. getResponseHeader: function getResponseHeader(name) {
  7429. return _this5._readableStream.headers[name.toLowerCase()];
  7430. },
  7431. isHttp: stream.isHttp,
  7432. rangeChunkSize: _this5._rangeChunkSize,
  7433. disableRange: _this5._disableRange
  7434. }),
  7435. allowRangeRequests = _validateRangeRequest.allowRangeRequests,
  7436. suggestedLength = _validateRangeRequest.suggestedLength;
  7437. if (allowRangeRequests) {
  7438. _this5._isRangeSupported = true;
  7439. }
  7440. _this5._contentLength = suggestedLength;
  7441. };
  7442. _this5._request = null;
  7443. if (_this5._url.protocol === 'http:') {
  7444. _this5._request = http.request(createRequestOptions(_this5._url, stream.httpHeaders), handleResponse);
  7445. } else {
  7446. _this5._request = https.request(createRequestOptions(_this5._url, stream.httpHeaders), handleResponse);
  7447. }
  7448. _this5._request.on('error', function (reason) {
  7449. _this5._errored = true;
  7450. _this5._reason = reason;
  7451. _this5._headersCapability.reject(reason);
  7452. });
  7453. _this5._request.end();
  7454. return _this5;
  7455. }
  7456. return PDFNodeStreamFullReader;
  7457. }(BaseFullReader);
  7458. var PDFNodeStreamRangeReader = function (_BaseRangeReader) {
  7459. _inherits(PDFNodeStreamRangeReader, _BaseRangeReader);
  7460. function PDFNodeStreamRangeReader(stream, start, end) {
  7461. _classCallCheck(this, PDFNodeStreamRangeReader);
  7462. var _this6 = _possibleConstructorReturn(this, (PDFNodeStreamRangeReader.__proto__ || Object.getPrototypeOf(PDFNodeStreamRangeReader)).call(this, stream));
  7463. _this6._httpHeaders = {};
  7464. for (var property in stream.httpHeaders) {
  7465. var value = stream.httpHeaders[property];
  7466. if (typeof value === 'undefined') {
  7467. continue;
  7468. }
  7469. _this6._httpHeaders[property] = value;
  7470. }
  7471. _this6._httpHeaders['Range'] = 'bytes=' + start + '-' + (end - 1);
  7472. _this6._request = null;
  7473. if (_this6._url.protocol === 'http:') {
  7474. _this6._request = http.request(createRequestOptions(_this6._url, _this6._httpHeaders), function (response) {
  7475. _this6._setReadableStream(response);
  7476. });
  7477. } else {
  7478. _this6._request = https.request(createRequestOptions(_this6._url, _this6._httpHeaders), function (response) {
  7479. _this6._setReadableStream(response);
  7480. });
  7481. }
  7482. _this6._request.on('error', function (reason) {
  7483. _this6._errored = true;
  7484. _this6._reason = reason;
  7485. });
  7486. _this6._request.end();
  7487. return _this6;
  7488. }
  7489. return PDFNodeStreamRangeReader;
  7490. }(BaseRangeReader);
  7491. var PDFNodeStreamFsFullReader = function (_BaseFullReader2) {
  7492. _inherits(PDFNodeStreamFsFullReader, _BaseFullReader2);
  7493. function PDFNodeStreamFsFullReader(stream) {
  7494. _classCallCheck(this, PDFNodeStreamFsFullReader);
  7495. var _this7 = _possibleConstructorReturn(this, (PDFNodeStreamFsFullReader.__proto__ || Object.getPrototypeOf(PDFNodeStreamFsFullReader)).call(this, stream));
  7496. _this7._setReadableStream(fs.createReadStream(_this7._url.path));
  7497. fs.lstat(_this7._url.path, function (error, stat) {
  7498. if (error) {
  7499. _this7._errored = true;
  7500. _this7._reason = error;
  7501. _this7._headersCapability.reject(error);
  7502. return;
  7503. }
  7504. _this7._contentLength = stat.size;
  7505. _this7._headersCapability.resolve();
  7506. });
  7507. return _this7;
  7508. }
  7509. return PDFNodeStreamFsFullReader;
  7510. }(BaseFullReader);
  7511. var PDFNodeStreamFsRangeReader = function (_BaseRangeReader2) {
  7512. _inherits(PDFNodeStreamFsRangeReader, _BaseRangeReader2);
  7513. function PDFNodeStreamFsRangeReader(stream, start, end) {
  7514. _classCallCheck(this, PDFNodeStreamFsRangeReader);
  7515. var _this8 = _possibleConstructorReturn(this, (PDFNodeStreamFsRangeReader.__proto__ || Object.getPrototypeOf(PDFNodeStreamFsRangeReader)).call(this, stream));
  7516. _this8._setReadableStream(fs.createReadStream(_this8._url.path, {
  7517. start: start,
  7518. end: end - 1
  7519. }));
  7520. return _this8;
  7521. }
  7522. return PDFNodeStreamFsRangeReader;
  7523. }(BaseRangeReader);
  7524. exports.PDFNodeStream = PDFNodeStream;
  7525. /***/ }),
  7526. /* 57 */
  7527. /***/ (function(module, exports, __w_pdfjs_require__) {
  7528. "use strict";
  7529. var _typeof2 = 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; };
  7530. (function (e, a) {
  7531. for (var i in a) {
  7532. e[i] = a[i];
  7533. }
  7534. })(exports, function (modules) {
  7535. var installedModules = {};
  7536. function __w_pdfjs_require__(moduleId) {
  7537. if (installedModules[moduleId]) return installedModules[moduleId].exports;
  7538. var module = installedModules[moduleId] = {
  7539. i: moduleId,
  7540. l: false,
  7541. exports: {}
  7542. };
  7543. modules[moduleId].call(module.exports, module, module.exports, __w_pdfjs_require__);
  7544. module.l = true;
  7545. return module.exports;
  7546. }
  7547. __w_pdfjs_require__.m = modules;
  7548. __w_pdfjs_require__.c = installedModules;
  7549. __w_pdfjs_require__.i = function (value) {
  7550. return value;
  7551. };
  7552. __w_pdfjs_require__.d = function (exports, name, getter) {
  7553. if (!__w_pdfjs_require__.o(exports, name)) {
  7554. Object.defineProperty(exports, name, {
  7555. configurable: false,
  7556. enumerable: true,
  7557. get: getter
  7558. });
  7559. }
  7560. };
  7561. __w_pdfjs_require__.n = function (module) {
  7562. var getter = module && module.__esModule ? function getDefault() {
  7563. return module['default'];
  7564. } : function getModuleExports() {
  7565. return module;
  7566. };
  7567. __w_pdfjs_require__.d(getter, 'a', getter);
  7568. return getter;
  7569. };
  7570. __w_pdfjs_require__.o = function (object, property) {
  7571. return Object.prototype.hasOwnProperty.call(object, property);
  7572. };
  7573. __w_pdfjs_require__.p = "";
  7574. return __w_pdfjs_require__(__w_pdfjs_require__.s = 7);
  7575. }([function (module, exports, __w_pdfjs_require__) {
  7576. "use strict";
  7577. var _typeof = typeof Symbol === "function" && _typeof2(Symbol.iterator) === "symbol" ? function (obj) {
  7578. return typeof obj === 'undefined' ? 'undefined' : _typeof2(obj);
  7579. } : function (obj) {
  7580. return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj === 'undefined' ? 'undefined' : _typeof2(obj);
  7581. };
  7582. var _require = __w_pdfjs_require__(1),
  7583. assert = _require.assert;
  7584. function IsPropertyKey(argument) {
  7585. return typeof argument === 'string' || (typeof argument === 'undefined' ? 'undefined' : _typeof(argument)) === 'symbol';
  7586. }
  7587. exports.typeIsObject = function (x) {
  7588. return (typeof x === 'undefined' ? 'undefined' : _typeof(x)) === 'object' && x !== null || typeof x === 'function';
  7589. };
  7590. exports.createDataProperty = function (o, p, v) {
  7591. assert(exports.typeIsObject(o));
  7592. Object.defineProperty(o, p, {
  7593. value: v,
  7594. writable: true,
  7595. enumerable: true,
  7596. configurable: true
  7597. });
  7598. };
  7599. exports.createArrayFromList = function (elements) {
  7600. return elements.slice();
  7601. };
  7602. exports.ArrayBufferCopy = function (dest, destOffset, src, srcOffset, n) {
  7603. new Uint8Array(dest).set(new Uint8Array(src, srcOffset, n), destOffset);
  7604. };
  7605. exports.CreateIterResultObject = function (value, done) {
  7606. assert(typeof done === 'boolean');
  7607. var obj = {};
  7608. Object.defineProperty(obj, 'value', {
  7609. value: value,
  7610. enumerable: true,
  7611. writable: true,
  7612. configurable: true
  7613. });
  7614. Object.defineProperty(obj, 'done', {
  7615. value: done,
  7616. enumerable: true,
  7617. writable: true,
  7618. configurable: true
  7619. });
  7620. return obj;
  7621. };
  7622. exports.IsFiniteNonNegativeNumber = function (v) {
  7623. if (Number.isNaN(v)) {
  7624. return false;
  7625. }
  7626. if (v === Infinity) {
  7627. return false;
  7628. }
  7629. if (v < 0) {
  7630. return false;
  7631. }
  7632. return true;
  7633. };
  7634. function Call(F, V, args) {
  7635. if (typeof F !== 'function') {
  7636. throw new TypeError('Argument is not a function');
  7637. }
  7638. return Function.prototype.apply.call(F, V, args);
  7639. }
  7640. exports.InvokeOrNoop = function (O, P, args) {
  7641. assert(O !== undefined);
  7642. assert(IsPropertyKey(P));
  7643. assert(Array.isArray(args));
  7644. var method = O[P];
  7645. if (method === undefined) {
  7646. return undefined;
  7647. }
  7648. return Call(method, O, args);
  7649. };
  7650. exports.PromiseInvokeOrNoop = function (O, P, args) {
  7651. assert(O !== undefined);
  7652. assert(IsPropertyKey(P));
  7653. assert(Array.isArray(args));
  7654. try {
  7655. return Promise.resolve(exports.InvokeOrNoop(O, P, args));
  7656. } catch (returnValueE) {
  7657. return Promise.reject(returnValueE);
  7658. }
  7659. };
  7660. exports.PromiseInvokeOrPerformFallback = function (O, P, args, F, argsF) {
  7661. assert(O !== undefined);
  7662. assert(IsPropertyKey(P));
  7663. assert(Array.isArray(args));
  7664. assert(Array.isArray(argsF));
  7665. var method = void 0;
  7666. try {
  7667. method = O[P];
  7668. } catch (methodE) {
  7669. return Promise.reject(methodE);
  7670. }
  7671. if (method === undefined) {
  7672. return F.apply(null, argsF);
  7673. }
  7674. try {
  7675. return Promise.resolve(Call(method, O, args));
  7676. } catch (e) {
  7677. return Promise.reject(e);
  7678. }
  7679. };
  7680. exports.TransferArrayBuffer = function (O) {
  7681. return O.slice();
  7682. };
  7683. exports.ValidateAndNormalizeHighWaterMark = function (highWaterMark) {
  7684. highWaterMark = Number(highWaterMark);
  7685. if (Number.isNaN(highWaterMark) || highWaterMark < 0) {
  7686. throw new RangeError('highWaterMark property of a queuing strategy must be non-negative and non-NaN');
  7687. }
  7688. return highWaterMark;
  7689. };
  7690. exports.ValidateAndNormalizeQueuingStrategy = function (size, highWaterMark) {
  7691. if (size !== undefined && typeof size !== 'function') {
  7692. throw new TypeError('size property of a queuing strategy must be a function');
  7693. }
  7694. highWaterMark = exports.ValidateAndNormalizeHighWaterMark(highWaterMark);
  7695. return {
  7696. size: size,
  7697. highWaterMark: highWaterMark
  7698. };
  7699. };
  7700. }, function (module, exports, __w_pdfjs_require__) {
  7701. "use strict";
  7702. function rethrowAssertionErrorRejection(e) {
  7703. if (e && e.constructor === AssertionError) {
  7704. setTimeout(function () {
  7705. throw e;
  7706. }, 0);
  7707. }
  7708. }
  7709. function AssertionError(message) {
  7710. this.name = 'AssertionError';
  7711. this.message = message || '';
  7712. this.stack = new Error().stack;
  7713. }
  7714. AssertionError.prototype = Object.create(Error.prototype);
  7715. AssertionError.prototype.constructor = AssertionError;
  7716. function assert(value, message) {
  7717. if (!value) {
  7718. throw new AssertionError(message);
  7719. }
  7720. }
  7721. module.exports = {
  7722. rethrowAssertionErrorRejection: rethrowAssertionErrorRejection,
  7723. AssertionError: AssertionError,
  7724. assert: assert
  7725. };
  7726. }, function (module, exports, __w_pdfjs_require__) {
  7727. "use strict";
  7728. var _createClass = function () {
  7729. function defineProperties(target, props) {
  7730. for (var i = 0; i < props.length; i++) {
  7731. var descriptor = props[i];
  7732. descriptor.enumerable = descriptor.enumerable || false;
  7733. descriptor.configurable = true;
  7734. if ("value" in descriptor) descriptor.writable = true;
  7735. Object.defineProperty(target, descriptor.key, descriptor);
  7736. }
  7737. }
  7738. return function (Constructor, protoProps, staticProps) {
  7739. if (protoProps) defineProperties(Constructor.prototype, protoProps);
  7740. if (staticProps) defineProperties(Constructor, staticProps);
  7741. return Constructor;
  7742. };
  7743. }();
  7744. function _classCallCheck(instance, Constructor) {
  7745. if (!(instance instanceof Constructor)) {
  7746. throw new TypeError("Cannot call a class as a function");
  7747. }
  7748. }
  7749. var _require = __w_pdfjs_require__(0),
  7750. InvokeOrNoop = _require.InvokeOrNoop,
  7751. PromiseInvokeOrNoop = _require.PromiseInvokeOrNoop,
  7752. ValidateAndNormalizeQueuingStrategy = _require.ValidateAndNormalizeQueuingStrategy,
  7753. typeIsObject = _require.typeIsObject;
  7754. var _require2 = __w_pdfjs_require__(1),
  7755. assert = _require2.assert,
  7756. rethrowAssertionErrorRejection = _require2.rethrowAssertionErrorRejection;
  7757. var _require3 = __w_pdfjs_require__(3),
  7758. DequeueValue = _require3.DequeueValue,
  7759. EnqueueValueWithSize = _require3.EnqueueValueWithSize,
  7760. PeekQueueValue = _require3.PeekQueueValue,
  7761. ResetQueue = _require3.ResetQueue;
  7762. var WritableStream = function () {
  7763. function WritableStream() {
  7764. var underlyingSink = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  7765. var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
  7766. size = _ref.size,
  7767. _ref$highWaterMark = _ref.highWaterMark,
  7768. highWaterMark = _ref$highWaterMark === undefined ? 1 : _ref$highWaterMark;
  7769. _classCallCheck(this, WritableStream);
  7770. this._state = 'writable';
  7771. this._storedError = undefined;
  7772. this._writer = undefined;
  7773. this._writableStreamController = undefined;
  7774. this._writeRequests = [];
  7775. this._inFlightWriteRequest = undefined;
  7776. this._closeRequest = undefined;
  7777. this._inFlightCloseRequest = undefined;
  7778. this._pendingAbortRequest = undefined;
  7779. this._backpressure = false;
  7780. var type = underlyingSink.type;
  7781. if (type !== undefined) {
  7782. throw new RangeError('Invalid type is specified');
  7783. }
  7784. this._writableStreamController = new WritableStreamDefaultController(this, underlyingSink, size, highWaterMark);
  7785. this._writableStreamController.__startSteps();
  7786. }
  7787. _createClass(WritableStream, [{
  7788. key: 'abort',
  7789. value: function abort(reason) {
  7790. if (IsWritableStream(this) === false) {
  7791. return Promise.reject(streamBrandCheckException('abort'));
  7792. }
  7793. if (IsWritableStreamLocked(this) === true) {
  7794. return Promise.reject(new TypeError('Cannot abort a stream that already has a writer'));
  7795. }
  7796. return WritableStreamAbort(this, reason);
  7797. }
  7798. }, {
  7799. key: 'getWriter',
  7800. value: function getWriter() {
  7801. if (IsWritableStream(this) === false) {
  7802. throw streamBrandCheckException('getWriter');
  7803. }
  7804. return AcquireWritableStreamDefaultWriter(this);
  7805. }
  7806. }, {
  7807. key: 'locked',
  7808. get: function get() {
  7809. if (IsWritableStream(this) === false) {
  7810. throw streamBrandCheckException('locked');
  7811. }
  7812. return IsWritableStreamLocked(this);
  7813. }
  7814. }]);
  7815. return WritableStream;
  7816. }();
  7817. module.exports = {
  7818. AcquireWritableStreamDefaultWriter: AcquireWritableStreamDefaultWriter,
  7819. IsWritableStream: IsWritableStream,
  7820. IsWritableStreamLocked: IsWritableStreamLocked,
  7821. WritableStream: WritableStream,
  7822. WritableStreamAbort: WritableStreamAbort,
  7823. WritableStreamDefaultControllerError: WritableStreamDefaultControllerError,
  7824. WritableStreamDefaultWriterCloseWithErrorPropagation: WritableStreamDefaultWriterCloseWithErrorPropagation,
  7825. WritableStreamDefaultWriterRelease: WritableStreamDefaultWriterRelease,
  7826. WritableStreamDefaultWriterWrite: WritableStreamDefaultWriterWrite,
  7827. WritableStreamCloseQueuedOrInFlight: WritableStreamCloseQueuedOrInFlight
  7828. };
  7829. function AcquireWritableStreamDefaultWriter(stream) {
  7830. return new WritableStreamDefaultWriter(stream);
  7831. }
  7832. function IsWritableStream(x) {
  7833. if (!typeIsObject(x)) {
  7834. return false;
  7835. }
  7836. if (!Object.prototype.hasOwnProperty.call(x, '_writableStreamController')) {
  7837. return false;
  7838. }
  7839. return true;
  7840. }
  7841. function IsWritableStreamLocked(stream) {
  7842. assert(IsWritableStream(stream) === true, 'IsWritableStreamLocked should only be used on known writable streams');
  7843. if (stream._writer === undefined) {
  7844. return false;
  7845. }
  7846. return true;
  7847. }
  7848. function WritableStreamAbort(stream, reason) {
  7849. var state = stream._state;
  7850. if (state === 'closed') {
  7851. return Promise.resolve(undefined);
  7852. }
  7853. if (state === 'errored') {
  7854. return Promise.reject(stream._storedError);
  7855. }
  7856. var error = new TypeError('Requested to abort');
  7857. if (stream._pendingAbortRequest !== undefined) {
  7858. return Promise.reject(error);
  7859. }
  7860. assert(state === 'writable' || state === 'erroring', 'state must be writable or erroring');
  7861. var wasAlreadyErroring = false;
  7862. if (state === 'erroring') {
  7863. wasAlreadyErroring = true;
  7864. reason = undefined;
  7865. }
  7866. var promise = new Promise(function (resolve, reject) {
  7867. stream._pendingAbortRequest = {
  7868. _resolve: resolve,
  7869. _reject: reject,
  7870. _reason: reason,
  7871. _wasAlreadyErroring: wasAlreadyErroring
  7872. };
  7873. });
  7874. if (wasAlreadyErroring === false) {
  7875. WritableStreamStartErroring(stream, error);
  7876. }
  7877. return promise;
  7878. }
  7879. function WritableStreamAddWriteRequest(stream) {
  7880. assert(IsWritableStreamLocked(stream) === true);
  7881. assert(stream._state === 'writable');
  7882. var promise = new Promise(function (resolve, reject) {
  7883. var writeRequest = {
  7884. _resolve: resolve,
  7885. _reject: reject
  7886. };
  7887. stream._writeRequests.push(writeRequest);
  7888. });
  7889. return promise;
  7890. }
  7891. function WritableStreamDealWithRejection(stream, error) {
  7892. var state = stream._state;
  7893. if (state === 'writable') {
  7894. WritableStreamStartErroring(stream, error);
  7895. return;
  7896. }
  7897. assert(state === 'erroring');
  7898. WritableStreamFinishErroring(stream);
  7899. }
  7900. function WritableStreamStartErroring(stream, reason) {
  7901. assert(stream._storedError === undefined, 'stream._storedError === undefined');
  7902. assert(stream._state === 'writable', 'state must be writable');
  7903. var controller = stream._writableStreamController;
  7904. assert(controller !== undefined, 'controller must not be undefined');
  7905. stream._state = 'erroring';
  7906. stream._storedError = reason;
  7907. var writer = stream._writer;
  7908. if (writer !== undefined) {
  7909. WritableStreamDefaultWriterEnsureReadyPromiseRejected(writer, reason);
  7910. }
  7911. if (WritableStreamHasOperationMarkedInFlight(stream) === false && controller._started === true) {
  7912. WritableStreamFinishErroring(stream);
  7913. }
  7914. }
  7915. function WritableStreamFinishErroring(stream) {
  7916. assert(stream._state === 'erroring', 'stream._state === erroring');
  7917. assert(WritableStreamHasOperationMarkedInFlight(stream) === false, 'WritableStreamHasOperationMarkedInFlight(stream) === false');
  7918. stream._state = 'errored';
  7919. stream._writableStreamController.__errorSteps();
  7920. var storedError = stream._storedError;
  7921. for (var i = 0; i < stream._writeRequests.length; i++) {
  7922. var writeRequest = stream._writeRequests[i];
  7923. writeRequest._reject(storedError);
  7924. }
  7925. stream._writeRequests = [];
  7926. if (stream._pendingAbortRequest === undefined) {
  7927. WritableStreamRejectCloseAndClosedPromiseIfNeeded(stream);
  7928. return;
  7929. }
  7930. var abortRequest = stream._pendingAbortRequest;
  7931. stream._pendingAbortRequest = undefined;
  7932. if (abortRequest._wasAlreadyErroring === true) {
  7933. abortRequest._reject(storedError);
  7934. WritableStreamRejectCloseAndClosedPromiseIfNeeded(stream);
  7935. return;
  7936. }
  7937. var promise = stream._writableStreamController.__abortSteps(abortRequest._reason);
  7938. promise.then(function () {
  7939. abortRequest._resolve();
  7940. WritableStreamRejectCloseAndClosedPromiseIfNeeded(stream);
  7941. }, function (reason) {
  7942. abortRequest._reject(reason);
  7943. WritableStreamRejectCloseAndClosedPromiseIfNeeded(stream);
  7944. });
  7945. }
  7946. function WritableStreamFinishInFlightWrite(stream) {
  7947. assert(stream._inFlightWriteRequest !== undefined);
  7948. stream._inFlightWriteRequest._resolve(undefined);
  7949. stream._inFlightWriteRequest = undefined;
  7950. }
  7951. function WritableStreamFinishInFlightWriteWithError(stream, error) {
  7952. assert(stream._inFlightWriteRequest !== undefined);
  7953. stream._inFlightWriteRequest._reject(error);
  7954. stream._inFlightWriteRequest = undefined;
  7955. assert(stream._state === 'writable' || stream._state === 'erroring');
  7956. WritableStreamDealWithRejection(stream, error);
  7957. }
  7958. function WritableStreamFinishInFlightClose(stream) {
  7959. assert(stream._inFlightCloseRequest !== undefined);
  7960. stream._inFlightCloseRequest._resolve(undefined);
  7961. stream._inFlightCloseRequest = undefined;
  7962. var state = stream._state;
  7963. assert(state === 'writable' || state === 'erroring');
  7964. if (state === 'erroring') {
  7965. stream._storedError = undefined;
  7966. if (stream._pendingAbortRequest !== undefined) {
  7967. stream._pendingAbortRequest._resolve();
  7968. stream._pendingAbortRequest = undefined;
  7969. }
  7970. }
  7971. stream._state = 'closed';
  7972. var writer = stream._writer;
  7973. if (writer !== undefined) {
  7974. defaultWriterClosedPromiseResolve(writer);
  7975. }
  7976. assert(stream._pendingAbortRequest === undefined, 'stream._pendingAbortRequest === undefined');
  7977. assert(stream._storedError === undefined, 'stream._storedError === undefined');
  7978. }
  7979. function WritableStreamFinishInFlightCloseWithError(stream, error) {
  7980. assert(stream._inFlightCloseRequest !== undefined);
  7981. stream._inFlightCloseRequest._reject(error);
  7982. stream._inFlightCloseRequest = undefined;
  7983. assert(stream._state === 'writable' || stream._state === 'erroring');
  7984. if (stream._pendingAbortRequest !== undefined) {
  7985. stream._pendingAbortRequest._reject(error);
  7986. stream._pendingAbortRequest = undefined;
  7987. }
  7988. WritableStreamDealWithRejection(stream, error);
  7989. }
  7990. function WritableStreamCloseQueuedOrInFlight(stream) {
  7991. if (stream._closeRequest === undefined && stream._inFlightCloseRequest === undefined) {
  7992. return false;
  7993. }
  7994. return true;
  7995. }
  7996. function WritableStreamHasOperationMarkedInFlight(stream) {
  7997. if (stream._inFlightWriteRequest === undefined && stream._inFlightCloseRequest === undefined) {
  7998. return false;
  7999. }
  8000. return true;
  8001. }
  8002. function WritableStreamMarkCloseRequestInFlight(stream) {
  8003. assert(stream._inFlightCloseRequest === undefined);
  8004. assert(stream._closeRequest !== undefined);
  8005. stream._inFlightCloseRequest = stream._closeRequest;
  8006. stream._closeRequest = undefined;
  8007. }
  8008. function WritableStreamMarkFirstWriteRequestInFlight(stream) {
  8009. assert(stream._inFlightWriteRequest === undefined, 'there must be no pending write request');
  8010. assert(stream._writeRequests.length !== 0, 'writeRequests must not be empty');
  8011. stream._inFlightWriteRequest = stream._writeRequests.shift();
  8012. }
  8013. function WritableStreamRejectCloseAndClosedPromiseIfNeeded(stream) {
  8014. assert(stream._state === 'errored', '_stream_.[[state]] is `"errored"`');
  8015. if (stream._closeRequest !== undefined) {
  8016. assert(stream._inFlightCloseRequest === undefined);
  8017. stream._closeRequest._reject(stream._storedError);
  8018. stream._closeRequest = undefined;
  8019. }
  8020. var writer = stream._writer;
  8021. if (writer !== undefined) {
  8022. defaultWriterClosedPromiseReject(writer, stream._storedError);
  8023. writer._closedPromise.catch(function () {});
  8024. }
  8025. }
  8026. function WritableStreamUpdateBackpressure(stream, backpressure) {
  8027. assert(stream._state === 'writable');
  8028. assert(WritableStreamCloseQueuedOrInFlight(stream) === false);
  8029. var writer = stream._writer;
  8030. if (writer !== undefined && backpressure !== stream._backpressure) {
  8031. if (backpressure === true) {
  8032. defaultWriterReadyPromiseReset(writer);
  8033. } else {
  8034. assert(backpressure === false);
  8035. defaultWriterReadyPromiseResolve(writer);
  8036. }
  8037. }
  8038. stream._backpressure = backpressure;
  8039. }
  8040. var WritableStreamDefaultWriter = function () {
  8041. function WritableStreamDefaultWriter(stream) {
  8042. _classCallCheck(this, WritableStreamDefaultWriter);
  8043. if (IsWritableStream(stream) === false) {
  8044. throw new TypeError('WritableStreamDefaultWriter can only be constructed with a WritableStream instance');
  8045. }
  8046. if (IsWritableStreamLocked(stream) === true) {
  8047. throw new TypeError('This stream has already been locked for exclusive writing by another writer');
  8048. }
  8049. this._ownerWritableStream = stream;
  8050. stream._writer = this;
  8051. var state = stream._state;
  8052. if (state === 'writable') {
  8053. if (WritableStreamCloseQueuedOrInFlight(stream) === false && stream._backpressure === true) {
  8054. defaultWriterReadyPromiseInitialize(this);
  8055. } else {
  8056. defaultWriterReadyPromiseInitializeAsResolved(this);
  8057. }
  8058. defaultWriterClosedPromiseInitialize(this);
  8059. } else if (state === 'erroring') {
  8060. defaultWriterReadyPromiseInitializeAsRejected(this, stream._storedError);
  8061. this._readyPromise.catch(function () {});
  8062. defaultWriterClosedPromiseInitialize(this);
  8063. } else if (state === 'closed') {
  8064. defaultWriterReadyPromiseInitializeAsResolved(this);
  8065. defaultWriterClosedPromiseInitializeAsResolved(this);
  8066. } else {
  8067. assert(state === 'errored', 'state must be errored');
  8068. var storedError = stream._storedError;
  8069. defaultWriterReadyPromiseInitializeAsRejected(this, storedError);
  8070. this._readyPromise.catch(function () {});
  8071. defaultWriterClosedPromiseInitializeAsRejected(this, storedError);
  8072. this._closedPromise.catch(function () {});
  8073. }
  8074. }
  8075. _createClass(WritableStreamDefaultWriter, [{
  8076. key: 'abort',
  8077. value: function abort(reason) {
  8078. if (IsWritableStreamDefaultWriter(this) === false) {
  8079. return Promise.reject(defaultWriterBrandCheckException('abort'));
  8080. }
  8081. if (this._ownerWritableStream === undefined) {
  8082. return Promise.reject(defaultWriterLockException('abort'));
  8083. }
  8084. return WritableStreamDefaultWriterAbort(this, reason);
  8085. }
  8086. }, {
  8087. key: 'close',
  8088. value: function close() {
  8089. if (IsWritableStreamDefaultWriter(this) === false) {
  8090. return Promise.reject(defaultWriterBrandCheckException('close'));
  8091. }
  8092. var stream = this._ownerWritableStream;
  8093. if (stream === undefined) {
  8094. return Promise.reject(defaultWriterLockException('close'));
  8095. }
  8096. if (WritableStreamCloseQueuedOrInFlight(stream) === true) {
  8097. return Promise.reject(new TypeError('cannot close an already-closing stream'));
  8098. }
  8099. return WritableStreamDefaultWriterClose(this);
  8100. }
  8101. }, {
  8102. key: 'releaseLock',
  8103. value: function releaseLock() {
  8104. if (IsWritableStreamDefaultWriter(this) === false) {
  8105. throw defaultWriterBrandCheckException('releaseLock');
  8106. }
  8107. var stream = this._ownerWritableStream;
  8108. if (stream === undefined) {
  8109. return;
  8110. }
  8111. assert(stream._writer !== undefined);
  8112. WritableStreamDefaultWriterRelease(this);
  8113. }
  8114. }, {
  8115. key: 'write',
  8116. value: function write(chunk) {
  8117. if (IsWritableStreamDefaultWriter(this) === false) {
  8118. return Promise.reject(defaultWriterBrandCheckException('write'));
  8119. }
  8120. if (this._ownerWritableStream === undefined) {
  8121. return Promise.reject(defaultWriterLockException('write to'));
  8122. }
  8123. return WritableStreamDefaultWriterWrite(this, chunk);
  8124. }
  8125. }, {
  8126. key: 'closed',
  8127. get: function get() {
  8128. if (IsWritableStreamDefaultWriter(this) === false) {
  8129. return Promise.reject(defaultWriterBrandCheckException('closed'));
  8130. }
  8131. return this._closedPromise;
  8132. }
  8133. }, {
  8134. key: 'desiredSize',
  8135. get: function get() {
  8136. if (IsWritableStreamDefaultWriter(this) === false) {
  8137. throw defaultWriterBrandCheckException('desiredSize');
  8138. }
  8139. if (this._ownerWritableStream === undefined) {
  8140. throw defaultWriterLockException('desiredSize');
  8141. }
  8142. return WritableStreamDefaultWriterGetDesiredSize(this);
  8143. }
  8144. }, {
  8145. key: 'ready',
  8146. get: function get() {
  8147. if (IsWritableStreamDefaultWriter(this) === false) {
  8148. return Promise.reject(defaultWriterBrandCheckException('ready'));
  8149. }
  8150. return this._readyPromise;
  8151. }
  8152. }]);
  8153. return WritableStreamDefaultWriter;
  8154. }();
  8155. function IsWritableStreamDefaultWriter(x) {
  8156. if (!typeIsObject(x)) {
  8157. return false;
  8158. }
  8159. if (!Object.prototype.hasOwnProperty.call(x, '_ownerWritableStream')) {
  8160. return false;
  8161. }
  8162. return true;
  8163. }
  8164. function WritableStreamDefaultWriterAbort(writer, reason) {
  8165. var stream = writer._ownerWritableStream;
  8166. assert(stream !== undefined);
  8167. return WritableStreamAbort(stream, reason);
  8168. }
  8169. function WritableStreamDefaultWriterClose(writer) {
  8170. var stream = writer._ownerWritableStream;
  8171. assert(stream !== undefined);
  8172. var state = stream._state;
  8173. if (state === 'closed' || state === 'errored') {
  8174. return Promise.reject(new TypeError('The stream (in ' + state + ' state) is not in the writable state and cannot be closed'));
  8175. }
  8176. assert(state === 'writable' || state === 'erroring');
  8177. assert(WritableStreamCloseQueuedOrInFlight(stream) === false);
  8178. var promise = new Promise(function (resolve, reject) {
  8179. var closeRequest = {
  8180. _resolve: resolve,
  8181. _reject: reject
  8182. };
  8183. stream._closeRequest = closeRequest;
  8184. });
  8185. if (stream._backpressure === true && state === 'writable') {
  8186. defaultWriterReadyPromiseResolve(writer);
  8187. }
  8188. WritableStreamDefaultControllerClose(stream._writableStreamController);
  8189. return promise;
  8190. }
  8191. function WritableStreamDefaultWriterCloseWithErrorPropagation(writer) {
  8192. var stream = writer._ownerWritableStream;
  8193. assert(stream !== undefined);
  8194. var state = stream._state;
  8195. if (WritableStreamCloseQueuedOrInFlight(stream) === true || state === 'closed') {
  8196. return Promise.resolve();
  8197. }
  8198. if (state === 'errored') {
  8199. return Promise.reject(stream._storedError);
  8200. }
  8201. assert(state === 'writable' || state === 'erroring');
  8202. return WritableStreamDefaultWriterClose(writer);
  8203. }
  8204. function WritableStreamDefaultWriterEnsureClosedPromiseRejected(writer, error) {
  8205. if (writer._closedPromiseState === 'pending') {
  8206. defaultWriterClosedPromiseReject(writer, error);
  8207. } else {
  8208. defaultWriterClosedPromiseResetToRejected(writer, error);
  8209. }
  8210. writer._closedPromise.catch(function () {});
  8211. }
  8212. function WritableStreamDefaultWriterEnsureReadyPromiseRejected(writer, error) {
  8213. if (writer._readyPromiseState === 'pending') {
  8214. defaultWriterReadyPromiseReject(writer, error);
  8215. } else {
  8216. defaultWriterReadyPromiseResetToRejected(writer, error);
  8217. }
  8218. writer._readyPromise.catch(function () {});
  8219. }
  8220. function WritableStreamDefaultWriterGetDesiredSize(writer) {
  8221. var stream = writer._ownerWritableStream;
  8222. var state = stream._state;
  8223. if (state === 'errored' || state === 'erroring') {
  8224. return null;
  8225. }
  8226. if (state === 'closed') {
  8227. return 0;
  8228. }
  8229. return WritableStreamDefaultControllerGetDesiredSize(stream._writableStreamController);
  8230. }
  8231. function WritableStreamDefaultWriterRelease(writer) {
  8232. var stream = writer._ownerWritableStream;
  8233. assert(stream !== undefined);
  8234. assert(stream._writer === writer);
  8235. var releasedError = new TypeError('Writer was released and can no longer be used to monitor the stream\'s closedness');
  8236. WritableStreamDefaultWriterEnsureReadyPromiseRejected(writer, releasedError);
  8237. WritableStreamDefaultWriterEnsureClosedPromiseRejected(writer, releasedError);
  8238. stream._writer = undefined;
  8239. writer._ownerWritableStream = undefined;
  8240. }
  8241. function WritableStreamDefaultWriterWrite(writer, chunk) {
  8242. var stream = writer._ownerWritableStream;
  8243. assert(stream !== undefined);
  8244. var controller = stream._writableStreamController;
  8245. var chunkSize = WritableStreamDefaultControllerGetChunkSize(controller, chunk);
  8246. if (stream !== writer._ownerWritableStream) {
  8247. return Promise.reject(defaultWriterLockException('write to'));
  8248. }
  8249. var state = stream._state;
  8250. if (state === 'errored') {
  8251. return Promise.reject(stream._storedError);
  8252. }
  8253. if (WritableStreamCloseQueuedOrInFlight(stream) === true || state === 'closed') {
  8254. return Promise.reject(new TypeError('The stream is closing or closed and cannot be written to'));
  8255. }
  8256. if (state === 'erroring') {
  8257. return Promise.reject(stream._storedError);
  8258. }
  8259. assert(state === 'writable');
  8260. var promise = WritableStreamAddWriteRequest(stream);
  8261. WritableStreamDefaultControllerWrite(controller, chunk, chunkSize);
  8262. return promise;
  8263. }
  8264. var WritableStreamDefaultController = function () {
  8265. function WritableStreamDefaultController(stream, underlyingSink, size, highWaterMark) {
  8266. _classCallCheck(this, WritableStreamDefaultController);
  8267. if (IsWritableStream(stream) === false) {
  8268. throw new TypeError('WritableStreamDefaultController can only be constructed with a WritableStream instance');
  8269. }
  8270. if (stream._writableStreamController !== undefined) {
  8271. throw new TypeError('WritableStreamDefaultController instances can only be created by the WritableStream constructor');
  8272. }
  8273. this._controlledWritableStream = stream;
  8274. this._underlyingSink = underlyingSink;
  8275. this._queue = undefined;
  8276. this._queueTotalSize = undefined;
  8277. ResetQueue(this);
  8278. this._started = false;
  8279. var normalizedStrategy = ValidateAndNormalizeQueuingStrategy(size, highWaterMark);
  8280. this._strategySize = normalizedStrategy.size;
  8281. this._strategyHWM = normalizedStrategy.highWaterMark;
  8282. var backpressure = WritableStreamDefaultControllerGetBackpressure(this);
  8283. WritableStreamUpdateBackpressure(stream, backpressure);
  8284. }
  8285. _createClass(WritableStreamDefaultController, [{
  8286. key: 'error',
  8287. value: function error(e) {
  8288. if (IsWritableStreamDefaultController(this) === false) {
  8289. throw new TypeError('WritableStreamDefaultController.prototype.error can only be used on a WritableStreamDefaultController');
  8290. }
  8291. var state = this._controlledWritableStream._state;
  8292. if (state !== 'writable') {
  8293. return;
  8294. }
  8295. WritableStreamDefaultControllerError(this, e);
  8296. }
  8297. }, {
  8298. key: '__abortSteps',
  8299. value: function __abortSteps(reason) {
  8300. return PromiseInvokeOrNoop(this._underlyingSink, 'abort', [reason]);
  8301. }
  8302. }, {
  8303. key: '__errorSteps',
  8304. value: function __errorSteps() {
  8305. ResetQueue(this);
  8306. }
  8307. }, {
  8308. key: '__startSteps',
  8309. value: function __startSteps() {
  8310. var _this = this;
  8311. var startResult = InvokeOrNoop(this._underlyingSink, 'start', [this]);
  8312. var stream = this._controlledWritableStream;
  8313. Promise.resolve(startResult).then(function () {
  8314. assert(stream._state === 'writable' || stream._state === 'erroring');
  8315. _this._started = true;
  8316. WritableStreamDefaultControllerAdvanceQueueIfNeeded(_this);
  8317. }, function (r) {
  8318. assert(stream._state === 'writable' || stream._state === 'erroring');
  8319. _this._started = true;
  8320. WritableStreamDealWithRejection(stream, r);
  8321. }).catch(rethrowAssertionErrorRejection);
  8322. }
  8323. }]);
  8324. return WritableStreamDefaultController;
  8325. }();
  8326. function WritableStreamDefaultControllerClose(controller) {
  8327. EnqueueValueWithSize(controller, 'close', 0);
  8328. WritableStreamDefaultControllerAdvanceQueueIfNeeded(controller);
  8329. }
  8330. function WritableStreamDefaultControllerGetChunkSize(controller, chunk) {
  8331. var strategySize = controller._strategySize;
  8332. if (strategySize === undefined) {
  8333. return 1;
  8334. }
  8335. try {
  8336. return strategySize(chunk);
  8337. } catch (chunkSizeE) {
  8338. WritableStreamDefaultControllerErrorIfNeeded(controller, chunkSizeE);
  8339. return 1;
  8340. }
  8341. }
  8342. function WritableStreamDefaultControllerGetDesiredSize(controller) {
  8343. return controller._strategyHWM - controller._queueTotalSize;
  8344. }
  8345. function WritableStreamDefaultControllerWrite(controller, chunk, chunkSize) {
  8346. var writeRecord = { chunk: chunk };
  8347. try {
  8348. EnqueueValueWithSize(controller, writeRecord, chunkSize);
  8349. } catch (enqueueE) {
  8350. WritableStreamDefaultControllerErrorIfNeeded(controller, enqueueE);
  8351. return;
  8352. }
  8353. var stream = controller._controlledWritableStream;
  8354. if (WritableStreamCloseQueuedOrInFlight(stream) === false && stream._state === 'writable') {
  8355. var backpressure = WritableStreamDefaultControllerGetBackpressure(controller);
  8356. WritableStreamUpdateBackpressure(stream, backpressure);
  8357. }
  8358. WritableStreamDefaultControllerAdvanceQueueIfNeeded(controller);
  8359. }
  8360. function IsWritableStreamDefaultController(x) {
  8361. if (!typeIsObject(x)) {
  8362. return false;
  8363. }
  8364. if (!Object.prototype.hasOwnProperty.call(x, '_underlyingSink')) {
  8365. return false;
  8366. }
  8367. return true;
  8368. }
  8369. function WritableStreamDefaultControllerAdvanceQueueIfNeeded(controller) {
  8370. var stream = controller._controlledWritableStream;
  8371. if (controller._started === false) {
  8372. return;
  8373. }
  8374. if (stream._inFlightWriteRequest !== undefined) {
  8375. return;
  8376. }
  8377. var state = stream._state;
  8378. if (state === 'closed' || state === 'errored') {
  8379. return;
  8380. }
  8381. if (state === 'erroring') {
  8382. WritableStreamFinishErroring(stream);
  8383. return;
  8384. }
  8385. if (controller._queue.length === 0) {
  8386. return;
  8387. }
  8388. var writeRecord = PeekQueueValue(controller);
  8389. if (writeRecord === 'close') {
  8390. WritableStreamDefaultControllerProcessClose(controller);
  8391. } else {
  8392. WritableStreamDefaultControllerProcessWrite(controller, writeRecord.chunk);
  8393. }
  8394. }
  8395. function WritableStreamDefaultControllerErrorIfNeeded(controller, error) {
  8396. if (controller._controlledWritableStream._state === 'writable') {
  8397. WritableStreamDefaultControllerError(controller, error);
  8398. }
  8399. }
  8400. function WritableStreamDefaultControllerProcessClose(controller) {
  8401. var stream = controller._controlledWritableStream;
  8402. WritableStreamMarkCloseRequestInFlight(stream);
  8403. DequeueValue(controller);
  8404. assert(controller._queue.length === 0, 'queue must be empty once the final write record is dequeued');
  8405. var sinkClosePromise = PromiseInvokeOrNoop(controller._underlyingSink, 'close', []);
  8406. sinkClosePromise.then(function () {
  8407. WritableStreamFinishInFlightClose(stream);
  8408. }, function (reason) {
  8409. WritableStreamFinishInFlightCloseWithError(stream, reason);
  8410. }).catch(rethrowAssertionErrorRejection);
  8411. }
  8412. function WritableStreamDefaultControllerProcessWrite(controller, chunk) {
  8413. var stream = controller._controlledWritableStream;
  8414. WritableStreamMarkFirstWriteRequestInFlight(stream);
  8415. var sinkWritePromise = PromiseInvokeOrNoop(controller._underlyingSink, 'write', [chunk, controller]);
  8416. sinkWritePromise.then(function () {
  8417. WritableStreamFinishInFlightWrite(stream);
  8418. var state = stream._state;
  8419. assert(state === 'writable' || state === 'erroring');
  8420. DequeueValue(controller);
  8421. if (WritableStreamCloseQueuedOrInFlight(stream) === false && state === 'writable') {
  8422. var backpressure = WritableStreamDefaultControllerGetBackpressure(controller);
  8423. WritableStreamUpdateBackpressure(stream, backpressure);
  8424. }
  8425. WritableStreamDefaultControllerAdvanceQueueIfNeeded(controller);
  8426. }, function (reason) {
  8427. WritableStreamFinishInFlightWriteWithError(stream, reason);
  8428. }).catch(rethrowAssertionErrorRejection);
  8429. }
  8430. function WritableStreamDefaultControllerGetBackpressure(controller) {
  8431. var desiredSize = WritableStreamDefaultControllerGetDesiredSize(controller);
  8432. return desiredSize <= 0;
  8433. }
  8434. function WritableStreamDefaultControllerError(controller, error) {
  8435. var stream = controller._controlledWritableStream;
  8436. assert(stream._state === 'writable');
  8437. WritableStreamStartErroring(stream, error);
  8438. }
  8439. function streamBrandCheckException(name) {
  8440. return new TypeError('WritableStream.prototype.' + name + ' can only be used on a WritableStream');
  8441. }
  8442. function defaultWriterBrandCheckException(name) {
  8443. return new TypeError('WritableStreamDefaultWriter.prototype.' + name + ' can only be used on a WritableStreamDefaultWriter');
  8444. }
  8445. function defaultWriterLockException(name) {
  8446. return new TypeError('Cannot ' + name + ' a stream using a released writer');
  8447. }
  8448. function defaultWriterClosedPromiseInitialize(writer) {
  8449. writer._closedPromise = new Promise(function (resolve, reject) {
  8450. writer._closedPromise_resolve = resolve;
  8451. writer._closedPromise_reject = reject;
  8452. writer._closedPromiseState = 'pending';
  8453. });
  8454. }
  8455. function defaultWriterClosedPromiseInitializeAsRejected(writer, reason) {
  8456. writer._closedPromise = Promise.reject(reason);
  8457. writer._closedPromise_resolve = undefined;
  8458. writer._closedPromise_reject = undefined;
  8459. writer._closedPromiseState = 'rejected';
  8460. }
  8461. function defaultWriterClosedPromiseInitializeAsResolved(writer) {
  8462. writer._closedPromise = Promise.resolve(undefined);
  8463. writer._closedPromise_resolve = undefined;
  8464. writer._closedPromise_reject = undefined;
  8465. writer._closedPromiseState = 'resolved';
  8466. }
  8467. function defaultWriterClosedPromiseReject(writer, reason) {
  8468. assert(writer._closedPromise_resolve !== undefined, 'writer._closedPromise_resolve !== undefined');
  8469. assert(writer._closedPromise_reject !== undefined, 'writer._closedPromise_reject !== undefined');
  8470. assert(writer._closedPromiseState === 'pending', 'writer._closedPromiseState is pending');
  8471. writer._closedPromise_reject(reason);
  8472. writer._closedPromise_resolve = undefined;
  8473. writer._closedPromise_reject = undefined;
  8474. writer._closedPromiseState = 'rejected';
  8475. }
  8476. function defaultWriterClosedPromiseResetToRejected(writer, reason) {
  8477. assert(writer._closedPromise_resolve === undefined, 'writer._closedPromise_resolve === undefined');
  8478. assert(writer._closedPromise_reject === undefined, 'writer._closedPromise_reject === undefined');
  8479. assert(writer._closedPromiseState !== 'pending', 'writer._closedPromiseState is not pending');
  8480. writer._closedPromise = Promise.reject(reason);
  8481. writer._closedPromiseState = 'rejected';
  8482. }
  8483. function defaultWriterClosedPromiseResolve(writer) {
  8484. assert(writer._closedPromise_resolve !== undefined, 'writer._closedPromise_resolve !== undefined');
  8485. assert(writer._closedPromise_reject !== undefined, 'writer._closedPromise_reject !== undefined');
  8486. assert(writer._closedPromiseState === 'pending', 'writer._closedPromiseState is pending');
  8487. writer._closedPromise_resolve(undefined);
  8488. writer._closedPromise_resolve = undefined;
  8489. writer._closedPromise_reject = undefined;
  8490. writer._closedPromiseState = 'resolved';
  8491. }
  8492. function defaultWriterReadyPromiseInitialize(writer) {
  8493. writer._readyPromise = new Promise(function (resolve, reject) {
  8494. writer._readyPromise_resolve = resolve;
  8495. writer._readyPromise_reject = reject;
  8496. });
  8497. writer._readyPromiseState = 'pending';
  8498. }
  8499. function defaultWriterReadyPromiseInitializeAsRejected(writer, reason) {
  8500. writer._readyPromise = Promise.reject(reason);
  8501. writer._readyPromise_resolve = undefined;
  8502. writer._readyPromise_reject = undefined;
  8503. writer._readyPromiseState = 'rejected';
  8504. }
  8505. function defaultWriterReadyPromiseInitializeAsResolved(writer) {
  8506. writer._readyPromise = Promise.resolve(undefined);
  8507. writer._readyPromise_resolve = undefined;
  8508. writer._readyPromise_reject = undefined;
  8509. writer._readyPromiseState = 'fulfilled';
  8510. }
  8511. function defaultWriterReadyPromiseReject(writer, reason) {
  8512. assert(writer._readyPromise_resolve !== undefined, 'writer._readyPromise_resolve !== undefined');
  8513. assert(writer._readyPromise_reject !== undefined, 'writer._readyPromise_reject !== undefined');
  8514. writer._readyPromise_reject(reason);
  8515. writer._readyPromise_resolve = undefined;
  8516. writer._readyPromise_reject = undefined;
  8517. writer._readyPromiseState = 'rejected';
  8518. }
  8519. function defaultWriterReadyPromiseReset(writer) {
  8520. assert(writer._readyPromise_resolve === undefined, 'writer._readyPromise_resolve === undefined');
  8521. assert(writer._readyPromise_reject === undefined, 'writer._readyPromise_reject === undefined');
  8522. writer._readyPromise = new Promise(function (resolve, reject) {
  8523. writer._readyPromise_resolve = resolve;
  8524. writer._readyPromise_reject = reject;
  8525. });
  8526. writer._readyPromiseState = 'pending';
  8527. }
  8528. function defaultWriterReadyPromiseResetToRejected(writer, reason) {
  8529. assert(writer._readyPromise_resolve === undefined, 'writer._readyPromise_resolve === undefined');
  8530. assert(writer._readyPromise_reject === undefined, 'writer._readyPromise_reject === undefined');
  8531. writer._readyPromise = Promise.reject(reason);
  8532. writer._readyPromiseState = 'rejected';
  8533. }
  8534. function defaultWriterReadyPromiseResolve(writer) {
  8535. assert(writer._readyPromise_resolve !== undefined, 'writer._readyPromise_resolve !== undefined');
  8536. assert(writer._readyPromise_reject !== undefined, 'writer._readyPromise_reject !== undefined');
  8537. writer._readyPromise_resolve(undefined);
  8538. writer._readyPromise_resolve = undefined;
  8539. writer._readyPromise_reject = undefined;
  8540. writer._readyPromiseState = 'fulfilled';
  8541. }
  8542. }, function (module, exports, __w_pdfjs_require__) {
  8543. "use strict";
  8544. var _require = __w_pdfjs_require__(0),
  8545. IsFiniteNonNegativeNumber = _require.IsFiniteNonNegativeNumber;
  8546. var _require2 = __w_pdfjs_require__(1),
  8547. assert = _require2.assert;
  8548. exports.DequeueValue = function (container) {
  8549. assert('_queue' in container && '_queueTotalSize' in container, 'Spec-level failure: DequeueValue should only be used on containers with [[queue]] and [[queueTotalSize]].');
  8550. assert(container._queue.length > 0, 'Spec-level failure: should never dequeue from an empty queue.');
  8551. var pair = container._queue.shift();
  8552. container._queueTotalSize -= pair.size;
  8553. if (container._queueTotalSize < 0) {
  8554. container._queueTotalSize = 0;
  8555. }
  8556. return pair.value;
  8557. };
  8558. exports.EnqueueValueWithSize = function (container, value, size) {
  8559. assert('_queue' in container && '_queueTotalSize' in container, 'Spec-level failure: EnqueueValueWithSize should only be used on containers with [[queue]] and ' + '[[queueTotalSize]].');
  8560. size = Number(size);
  8561. if (!IsFiniteNonNegativeNumber(size)) {
  8562. throw new RangeError('Size must be a finite, non-NaN, non-negative number.');
  8563. }
  8564. container._queue.push({
  8565. value: value,
  8566. size: size
  8567. });
  8568. container._queueTotalSize += size;
  8569. };
  8570. exports.PeekQueueValue = function (container) {
  8571. assert('_queue' in container && '_queueTotalSize' in container, 'Spec-level failure: PeekQueueValue should only be used on containers with [[queue]] and [[queueTotalSize]].');
  8572. assert(container._queue.length > 0, 'Spec-level failure: should never peek at an empty queue.');
  8573. var pair = container._queue[0];
  8574. return pair.value;
  8575. };
  8576. exports.ResetQueue = function (container) {
  8577. assert('_queue' in container && '_queueTotalSize' in container, 'Spec-level failure: ResetQueue should only be used on containers with [[queue]] and [[queueTotalSize]].');
  8578. container._queue = [];
  8579. container._queueTotalSize = 0;
  8580. };
  8581. }, function (module, exports, __w_pdfjs_require__) {
  8582. "use strict";
  8583. var _createClass = function () {
  8584. function defineProperties(target, props) {
  8585. for (var i = 0; i < props.length; i++) {
  8586. var descriptor = props[i];
  8587. descriptor.enumerable = descriptor.enumerable || false;
  8588. descriptor.configurable = true;
  8589. if ("value" in descriptor) descriptor.writable = true;
  8590. Object.defineProperty(target, descriptor.key, descriptor);
  8591. }
  8592. }
  8593. return function (Constructor, protoProps, staticProps) {
  8594. if (protoProps) defineProperties(Constructor.prototype, protoProps);
  8595. if (staticProps) defineProperties(Constructor, staticProps);
  8596. return Constructor;
  8597. };
  8598. }();
  8599. function _classCallCheck(instance, Constructor) {
  8600. if (!(instance instanceof Constructor)) {
  8601. throw new TypeError("Cannot call a class as a function");
  8602. }
  8603. }
  8604. var _require = __w_pdfjs_require__(0),
  8605. ArrayBufferCopy = _require.ArrayBufferCopy,
  8606. CreateIterResultObject = _require.CreateIterResultObject,
  8607. IsFiniteNonNegativeNumber = _require.IsFiniteNonNegativeNumber,
  8608. InvokeOrNoop = _require.InvokeOrNoop,
  8609. PromiseInvokeOrNoop = _require.PromiseInvokeOrNoop,
  8610. TransferArrayBuffer = _require.TransferArrayBuffer,
  8611. ValidateAndNormalizeQueuingStrategy = _require.ValidateAndNormalizeQueuingStrategy,
  8612. ValidateAndNormalizeHighWaterMark = _require.ValidateAndNormalizeHighWaterMark;
  8613. var _require2 = __w_pdfjs_require__(0),
  8614. createArrayFromList = _require2.createArrayFromList,
  8615. createDataProperty = _require2.createDataProperty,
  8616. typeIsObject = _require2.typeIsObject;
  8617. var _require3 = __w_pdfjs_require__(1),
  8618. assert = _require3.assert,
  8619. rethrowAssertionErrorRejection = _require3.rethrowAssertionErrorRejection;
  8620. var _require4 = __w_pdfjs_require__(3),
  8621. DequeueValue = _require4.DequeueValue,
  8622. EnqueueValueWithSize = _require4.EnqueueValueWithSize,
  8623. ResetQueue = _require4.ResetQueue;
  8624. var _require5 = __w_pdfjs_require__(2),
  8625. AcquireWritableStreamDefaultWriter = _require5.AcquireWritableStreamDefaultWriter,
  8626. IsWritableStream = _require5.IsWritableStream,
  8627. IsWritableStreamLocked = _require5.IsWritableStreamLocked,
  8628. WritableStreamAbort = _require5.WritableStreamAbort,
  8629. WritableStreamDefaultWriterCloseWithErrorPropagation = _require5.WritableStreamDefaultWriterCloseWithErrorPropagation,
  8630. WritableStreamDefaultWriterRelease = _require5.WritableStreamDefaultWriterRelease,
  8631. WritableStreamDefaultWriterWrite = _require5.WritableStreamDefaultWriterWrite,
  8632. WritableStreamCloseQueuedOrInFlight = _require5.WritableStreamCloseQueuedOrInFlight;
  8633. var ReadableStream = function () {
  8634. function ReadableStream() {
  8635. var underlyingSource = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  8636. var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
  8637. size = _ref.size,
  8638. highWaterMark = _ref.highWaterMark;
  8639. _classCallCheck(this, ReadableStream);
  8640. this._state = 'readable';
  8641. this._reader = undefined;
  8642. this._storedError = undefined;
  8643. this._disturbed = false;
  8644. this._readableStreamController = undefined;
  8645. var type = underlyingSource.type;
  8646. var typeString = String(type);
  8647. if (typeString === 'bytes') {
  8648. if (highWaterMark === undefined) {
  8649. highWaterMark = 0;
  8650. }
  8651. this._readableStreamController = new ReadableByteStreamController(this, underlyingSource, highWaterMark);
  8652. } else if (type === undefined) {
  8653. if (highWaterMark === undefined) {
  8654. highWaterMark = 1;
  8655. }
  8656. this._readableStreamController = new ReadableStreamDefaultController(this, underlyingSource, size, highWaterMark);
  8657. } else {
  8658. throw new RangeError('Invalid type is specified');
  8659. }
  8660. }
  8661. _createClass(ReadableStream, [{
  8662. key: 'cancel',
  8663. value: function cancel(reason) {
  8664. if (IsReadableStream(this) === false) {
  8665. return Promise.reject(streamBrandCheckException('cancel'));
  8666. }
  8667. if (IsReadableStreamLocked(this) === true) {
  8668. return Promise.reject(new TypeError('Cannot cancel a stream that already has a reader'));
  8669. }
  8670. return ReadableStreamCancel(this, reason);
  8671. }
  8672. }, {
  8673. key: 'getReader',
  8674. value: function getReader() {
  8675. var _ref2 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
  8676. mode = _ref2.mode;
  8677. if (IsReadableStream(this) === false) {
  8678. throw streamBrandCheckException('getReader');
  8679. }
  8680. if (mode === undefined) {
  8681. return AcquireReadableStreamDefaultReader(this);
  8682. }
  8683. mode = String(mode);
  8684. if (mode === 'byob') {
  8685. return AcquireReadableStreamBYOBReader(this);
  8686. }
  8687. throw new RangeError('Invalid mode is specified');
  8688. }
  8689. }, {
  8690. key: 'pipeThrough',
  8691. value: function pipeThrough(_ref3, options) {
  8692. var writable = _ref3.writable,
  8693. readable = _ref3.readable;
  8694. var promise = this.pipeTo(writable, options);
  8695. ifIsObjectAndHasAPromiseIsHandledInternalSlotSetPromiseIsHandledToTrue(promise);
  8696. return readable;
  8697. }
  8698. }, {
  8699. key: 'pipeTo',
  8700. value: function pipeTo(dest) {
  8701. var _this = this;
  8702. var _ref4 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
  8703. preventClose = _ref4.preventClose,
  8704. preventAbort = _ref4.preventAbort,
  8705. preventCancel = _ref4.preventCancel;
  8706. if (IsReadableStream(this) === false) {
  8707. return Promise.reject(streamBrandCheckException('pipeTo'));
  8708. }
  8709. if (IsWritableStream(dest) === false) {
  8710. return Promise.reject(new TypeError('ReadableStream.prototype.pipeTo\'s first argument must be a WritableStream'));
  8711. }
  8712. preventClose = Boolean(preventClose);
  8713. preventAbort = Boolean(preventAbort);
  8714. preventCancel = Boolean(preventCancel);
  8715. if (IsReadableStreamLocked(this) === true) {
  8716. return Promise.reject(new TypeError('ReadableStream.prototype.pipeTo cannot be used on a locked ReadableStream'));
  8717. }
  8718. if (IsWritableStreamLocked(dest) === true) {
  8719. return Promise.reject(new TypeError('ReadableStream.prototype.pipeTo cannot be used on a locked WritableStream'));
  8720. }
  8721. var reader = AcquireReadableStreamDefaultReader(this);
  8722. var writer = AcquireWritableStreamDefaultWriter(dest);
  8723. var shuttingDown = false;
  8724. var currentWrite = Promise.resolve();
  8725. return new Promise(function (resolve, reject) {
  8726. function pipeLoop() {
  8727. currentWrite = Promise.resolve();
  8728. if (shuttingDown === true) {
  8729. return Promise.resolve();
  8730. }
  8731. return writer._readyPromise.then(function () {
  8732. return ReadableStreamDefaultReaderRead(reader).then(function (_ref5) {
  8733. var value = _ref5.value,
  8734. done = _ref5.done;
  8735. if (done === true) {
  8736. return;
  8737. }
  8738. currentWrite = WritableStreamDefaultWriterWrite(writer, value).catch(function () {});
  8739. });
  8740. }).then(pipeLoop);
  8741. }
  8742. isOrBecomesErrored(_this, reader._closedPromise, function (storedError) {
  8743. if (preventAbort === false) {
  8744. shutdownWithAction(function () {
  8745. return WritableStreamAbort(dest, storedError);
  8746. }, true, storedError);
  8747. } else {
  8748. shutdown(true, storedError);
  8749. }
  8750. });
  8751. isOrBecomesErrored(dest, writer._closedPromise, function (storedError) {
  8752. if (preventCancel === false) {
  8753. shutdownWithAction(function () {
  8754. return ReadableStreamCancel(_this, storedError);
  8755. }, true, storedError);
  8756. } else {
  8757. shutdown(true, storedError);
  8758. }
  8759. });
  8760. isOrBecomesClosed(_this, reader._closedPromise, function () {
  8761. if (preventClose === false) {
  8762. shutdownWithAction(function () {
  8763. return WritableStreamDefaultWriterCloseWithErrorPropagation(writer);
  8764. });
  8765. } else {
  8766. shutdown();
  8767. }
  8768. });
  8769. if (WritableStreamCloseQueuedOrInFlight(dest) === true || dest._state === 'closed') {
  8770. var destClosed = new TypeError('the destination writable stream closed before all data could be piped to it');
  8771. if (preventCancel === false) {
  8772. shutdownWithAction(function () {
  8773. return ReadableStreamCancel(_this, destClosed);
  8774. }, true, destClosed);
  8775. } else {
  8776. shutdown(true, destClosed);
  8777. }
  8778. }
  8779. pipeLoop().catch(function (err) {
  8780. currentWrite = Promise.resolve();
  8781. rethrowAssertionErrorRejection(err);
  8782. });
  8783. function waitForWritesToFinish() {
  8784. var oldCurrentWrite = currentWrite;
  8785. return currentWrite.then(function () {
  8786. return oldCurrentWrite !== currentWrite ? waitForWritesToFinish() : undefined;
  8787. });
  8788. }
  8789. function isOrBecomesErrored(stream, promise, action) {
  8790. if (stream._state === 'errored') {
  8791. action(stream._storedError);
  8792. } else {
  8793. promise.catch(action).catch(rethrowAssertionErrorRejection);
  8794. }
  8795. }
  8796. function isOrBecomesClosed(stream, promise, action) {
  8797. if (stream._state === 'closed') {
  8798. action();
  8799. } else {
  8800. promise.then(action).catch(rethrowAssertionErrorRejection);
  8801. }
  8802. }
  8803. function shutdownWithAction(action, originalIsError, originalError) {
  8804. if (shuttingDown === true) {
  8805. return;
  8806. }
  8807. shuttingDown = true;
  8808. if (dest._state === 'writable' && WritableStreamCloseQueuedOrInFlight(dest) === false) {
  8809. waitForWritesToFinish().then(doTheRest);
  8810. } else {
  8811. doTheRest();
  8812. }
  8813. function doTheRest() {
  8814. action().then(function () {
  8815. return finalize(originalIsError, originalError);
  8816. }, function (newError) {
  8817. return finalize(true, newError);
  8818. }).catch(rethrowAssertionErrorRejection);
  8819. }
  8820. }
  8821. function shutdown(isError, error) {
  8822. if (shuttingDown === true) {
  8823. return;
  8824. }
  8825. shuttingDown = true;
  8826. if (dest._state === 'writable' && WritableStreamCloseQueuedOrInFlight(dest) === false) {
  8827. waitForWritesToFinish().then(function () {
  8828. return finalize(isError, error);
  8829. }).catch(rethrowAssertionErrorRejection);
  8830. } else {
  8831. finalize(isError, error);
  8832. }
  8833. }
  8834. function finalize(isError, error) {
  8835. WritableStreamDefaultWriterRelease(writer);
  8836. ReadableStreamReaderGenericRelease(reader);
  8837. if (isError) {
  8838. reject(error);
  8839. } else {
  8840. resolve(undefined);
  8841. }
  8842. }
  8843. });
  8844. }
  8845. }, {
  8846. key: 'tee',
  8847. value: function tee() {
  8848. if (IsReadableStream(this) === false) {
  8849. throw streamBrandCheckException('tee');
  8850. }
  8851. var branches = ReadableStreamTee(this, false);
  8852. return createArrayFromList(branches);
  8853. }
  8854. }, {
  8855. key: 'locked',
  8856. get: function get() {
  8857. if (IsReadableStream(this) === false) {
  8858. throw streamBrandCheckException('locked');
  8859. }
  8860. return IsReadableStreamLocked(this);
  8861. }
  8862. }]);
  8863. return ReadableStream;
  8864. }();
  8865. module.exports = {
  8866. ReadableStream: ReadableStream,
  8867. IsReadableStreamDisturbed: IsReadableStreamDisturbed,
  8868. ReadableStreamDefaultControllerClose: ReadableStreamDefaultControllerClose,
  8869. ReadableStreamDefaultControllerEnqueue: ReadableStreamDefaultControllerEnqueue,
  8870. ReadableStreamDefaultControllerError: ReadableStreamDefaultControllerError,
  8871. ReadableStreamDefaultControllerGetDesiredSize: ReadableStreamDefaultControllerGetDesiredSize
  8872. };
  8873. function AcquireReadableStreamBYOBReader(stream) {
  8874. return new ReadableStreamBYOBReader(stream);
  8875. }
  8876. function AcquireReadableStreamDefaultReader(stream) {
  8877. return new ReadableStreamDefaultReader(stream);
  8878. }
  8879. function IsReadableStream(x) {
  8880. if (!typeIsObject(x)) {
  8881. return false;
  8882. }
  8883. if (!Object.prototype.hasOwnProperty.call(x, '_readableStreamController')) {
  8884. return false;
  8885. }
  8886. return true;
  8887. }
  8888. function IsReadableStreamDisturbed(stream) {
  8889. assert(IsReadableStream(stream) === true, 'IsReadableStreamDisturbed should only be used on known readable streams');
  8890. return stream._disturbed;
  8891. }
  8892. function IsReadableStreamLocked(stream) {
  8893. assert(IsReadableStream(stream) === true, 'IsReadableStreamLocked should only be used on known readable streams');
  8894. if (stream._reader === undefined) {
  8895. return false;
  8896. }
  8897. return true;
  8898. }
  8899. function ReadableStreamTee(stream, cloneForBranch2) {
  8900. assert(IsReadableStream(stream) === true);
  8901. assert(typeof cloneForBranch2 === 'boolean');
  8902. var reader = AcquireReadableStreamDefaultReader(stream);
  8903. var teeState = {
  8904. closedOrErrored: false,
  8905. canceled1: false,
  8906. canceled2: false,
  8907. reason1: undefined,
  8908. reason2: undefined
  8909. };
  8910. teeState.promise = new Promise(function (resolve) {
  8911. teeState._resolve = resolve;
  8912. });
  8913. var pull = create_ReadableStreamTeePullFunction();
  8914. pull._reader = reader;
  8915. pull._teeState = teeState;
  8916. pull._cloneForBranch2 = cloneForBranch2;
  8917. var cancel1 = create_ReadableStreamTeeBranch1CancelFunction();
  8918. cancel1._stream = stream;
  8919. cancel1._teeState = teeState;
  8920. var cancel2 = create_ReadableStreamTeeBranch2CancelFunction();
  8921. cancel2._stream = stream;
  8922. cancel2._teeState = teeState;
  8923. var underlyingSource1 = Object.create(Object.prototype);
  8924. createDataProperty(underlyingSource1, 'pull', pull);
  8925. createDataProperty(underlyingSource1, 'cancel', cancel1);
  8926. var branch1Stream = new ReadableStream(underlyingSource1);
  8927. var underlyingSource2 = Object.create(Object.prototype);
  8928. createDataProperty(underlyingSource2, 'pull', pull);
  8929. createDataProperty(underlyingSource2, 'cancel', cancel2);
  8930. var branch2Stream = new ReadableStream(underlyingSource2);
  8931. pull._branch1 = branch1Stream._readableStreamController;
  8932. pull._branch2 = branch2Stream._readableStreamController;
  8933. reader._closedPromise.catch(function (r) {
  8934. if (teeState.closedOrErrored === true) {
  8935. return;
  8936. }
  8937. ReadableStreamDefaultControllerError(pull._branch1, r);
  8938. ReadableStreamDefaultControllerError(pull._branch2, r);
  8939. teeState.closedOrErrored = true;
  8940. });
  8941. return [branch1Stream, branch2Stream];
  8942. }
  8943. function create_ReadableStreamTeePullFunction() {
  8944. function f() {
  8945. var reader = f._reader,
  8946. branch1 = f._branch1,
  8947. branch2 = f._branch2,
  8948. teeState = f._teeState;
  8949. return ReadableStreamDefaultReaderRead(reader).then(function (result) {
  8950. assert(typeIsObject(result));
  8951. var value = result.value;
  8952. var done = result.done;
  8953. assert(typeof done === 'boolean');
  8954. if (done === true && teeState.closedOrErrored === false) {
  8955. if (teeState.canceled1 === false) {
  8956. ReadableStreamDefaultControllerClose(branch1);
  8957. }
  8958. if (teeState.canceled2 === false) {
  8959. ReadableStreamDefaultControllerClose(branch2);
  8960. }
  8961. teeState.closedOrErrored = true;
  8962. }
  8963. if (teeState.closedOrErrored === true) {
  8964. return;
  8965. }
  8966. var value1 = value;
  8967. var value2 = value;
  8968. if (teeState.canceled1 === false) {
  8969. ReadableStreamDefaultControllerEnqueue(branch1, value1);
  8970. }
  8971. if (teeState.canceled2 === false) {
  8972. ReadableStreamDefaultControllerEnqueue(branch2, value2);
  8973. }
  8974. });
  8975. }
  8976. return f;
  8977. }
  8978. function create_ReadableStreamTeeBranch1CancelFunction() {
  8979. function f(reason) {
  8980. var stream = f._stream,
  8981. teeState = f._teeState;
  8982. teeState.canceled1 = true;
  8983. teeState.reason1 = reason;
  8984. if (teeState.canceled2 === true) {
  8985. var compositeReason = createArrayFromList([teeState.reason1, teeState.reason2]);
  8986. var cancelResult = ReadableStreamCancel(stream, compositeReason);
  8987. teeState._resolve(cancelResult);
  8988. }
  8989. return teeState.promise;
  8990. }
  8991. return f;
  8992. }
  8993. function create_ReadableStreamTeeBranch2CancelFunction() {
  8994. function f(reason) {
  8995. var stream = f._stream,
  8996. teeState = f._teeState;
  8997. teeState.canceled2 = true;
  8998. teeState.reason2 = reason;
  8999. if (teeState.canceled1 === true) {
  9000. var compositeReason = createArrayFromList([teeState.reason1, teeState.reason2]);
  9001. var cancelResult = ReadableStreamCancel(stream, compositeReason);
  9002. teeState._resolve(cancelResult);
  9003. }
  9004. return teeState.promise;
  9005. }
  9006. return f;
  9007. }
  9008. function ReadableStreamAddReadIntoRequest(stream) {
  9009. assert(IsReadableStreamBYOBReader(stream._reader) === true);
  9010. assert(stream._state === 'readable' || stream._state === 'closed');
  9011. var promise = new Promise(function (resolve, reject) {
  9012. var readIntoRequest = {
  9013. _resolve: resolve,
  9014. _reject: reject
  9015. };
  9016. stream._reader._readIntoRequests.push(readIntoRequest);
  9017. });
  9018. return promise;
  9019. }
  9020. function ReadableStreamAddReadRequest(stream) {
  9021. assert(IsReadableStreamDefaultReader(stream._reader) === true);
  9022. assert(stream._state === 'readable');
  9023. var promise = new Promise(function (resolve, reject) {
  9024. var readRequest = {
  9025. _resolve: resolve,
  9026. _reject: reject
  9027. };
  9028. stream._reader._readRequests.push(readRequest);
  9029. });
  9030. return promise;
  9031. }
  9032. function ReadableStreamCancel(stream, reason) {
  9033. stream._disturbed = true;
  9034. if (stream._state === 'closed') {
  9035. return Promise.resolve(undefined);
  9036. }
  9037. if (stream._state === 'errored') {
  9038. return Promise.reject(stream._storedError);
  9039. }
  9040. ReadableStreamClose(stream);
  9041. var sourceCancelPromise = stream._readableStreamController.__cancelSteps(reason);
  9042. return sourceCancelPromise.then(function () {
  9043. return undefined;
  9044. });
  9045. }
  9046. function ReadableStreamClose(stream) {
  9047. assert(stream._state === 'readable');
  9048. stream._state = 'closed';
  9049. var reader = stream._reader;
  9050. if (reader === undefined) {
  9051. return undefined;
  9052. }
  9053. if (IsReadableStreamDefaultReader(reader) === true) {
  9054. for (var i = 0; i < reader._readRequests.length; i++) {
  9055. var _resolve = reader._readRequests[i]._resolve;
  9056. _resolve(CreateIterResultObject(undefined, true));
  9057. }
  9058. reader._readRequests = [];
  9059. }
  9060. defaultReaderClosedPromiseResolve(reader);
  9061. return undefined;
  9062. }
  9063. function ReadableStreamError(stream, e) {
  9064. assert(IsReadableStream(stream) === true, 'stream must be ReadableStream');
  9065. assert(stream._state === 'readable', 'state must be readable');
  9066. stream._state = 'errored';
  9067. stream._storedError = e;
  9068. var reader = stream._reader;
  9069. if (reader === undefined) {
  9070. return undefined;
  9071. }
  9072. if (IsReadableStreamDefaultReader(reader) === true) {
  9073. for (var i = 0; i < reader._readRequests.length; i++) {
  9074. var readRequest = reader._readRequests[i];
  9075. readRequest._reject(e);
  9076. }
  9077. reader._readRequests = [];
  9078. } else {
  9079. assert(IsReadableStreamBYOBReader(reader), 'reader must be ReadableStreamBYOBReader');
  9080. for (var _i = 0; _i < reader._readIntoRequests.length; _i++) {
  9081. var readIntoRequest = reader._readIntoRequests[_i];
  9082. readIntoRequest._reject(e);
  9083. }
  9084. reader._readIntoRequests = [];
  9085. }
  9086. defaultReaderClosedPromiseReject(reader, e);
  9087. reader._closedPromise.catch(function () {});
  9088. }
  9089. function ReadableStreamFulfillReadIntoRequest(stream, chunk, done) {
  9090. var reader = stream._reader;
  9091. assert(reader._readIntoRequests.length > 0);
  9092. var readIntoRequest = reader._readIntoRequests.shift();
  9093. readIntoRequest._resolve(CreateIterResultObject(chunk, done));
  9094. }
  9095. function ReadableStreamFulfillReadRequest(stream, chunk, done) {
  9096. var reader = stream._reader;
  9097. assert(reader._readRequests.length > 0);
  9098. var readRequest = reader._readRequests.shift();
  9099. readRequest._resolve(CreateIterResultObject(chunk, done));
  9100. }
  9101. function ReadableStreamGetNumReadIntoRequests(stream) {
  9102. return stream._reader._readIntoRequests.length;
  9103. }
  9104. function ReadableStreamGetNumReadRequests(stream) {
  9105. return stream._reader._readRequests.length;
  9106. }
  9107. function ReadableStreamHasBYOBReader(stream) {
  9108. var reader = stream._reader;
  9109. if (reader === undefined) {
  9110. return false;
  9111. }
  9112. if (IsReadableStreamBYOBReader(reader) === false) {
  9113. return false;
  9114. }
  9115. return true;
  9116. }
  9117. function ReadableStreamHasDefaultReader(stream) {
  9118. var reader = stream._reader;
  9119. if (reader === undefined) {
  9120. return false;
  9121. }
  9122. if (IsReadableStreamDefaultReader(reader) === false) {
  9123. return false;
  9124. }
  9125. return true;
  9126. }
  9127. var ReadableStreamDefaultReader = function () {
  9128. function ReadableStreamDefaultReader(stream) {
  9129. _classCallCheck(this, ReadableStreamDefaultReader);
  9130. if (IsReadableStream(stream) === false) {
  9131. throw new TypeError('ReadableStreamDefaultReader can only be constructed with a ReadableStream instance');
  9132. }
  9133. if (IsReadableStreamLocked(stream) === true) {
  9134. throw new TypeError('This stream has already been locked for exclusive reading by another reader');
  9135. }
  9136. ReadableStreamReaderGenericInitialize(this, stream);
  9137. this._readRequests = [];
  9138. }
  9139. _createClass(ReadableStreamDefaultReader, [{
  9140. key: 'cancel',
  9141. value: function cancel(reason) {
  9142. if (IsReadableStreamDefaultReader(this) === false) {
  9143. return Promise.reject(defaultReaderBrandCheckException('cancel'));
  9144. }
  9145. if (this._ownerReadableStream === undefined) {
  9146. return Promise.reject(readerLockException('cancel'));
  9147. }
  9148. return ReadableStreamReaderGenericCancel(this, reason);
  9149. }
  9150. }, {
  9151. key: 'read',
  9152. value: function read() {
  9153. if (IsReadableStreamDefaultReader(this) === false) {
  9154. return Promise.reject(defaultReaderBrandCheckException('read'));
  9155. }
  9156. if (this._ownerReadableStream === undefined) {
  9157. return Promise.reject(readerLockException('read from'));
  9158. }
  9159. return ReadableStreamDefaultReaderRead(this);
  9160. }
  9161. }, {
  9162. key: 'releaseLock',
  9163. value: function releaseLock() {
  9164. if (IsReadableStreamDefaultReader(this) === false) {
  9165. throw defaultReaderBrandCheckException('releaseLock');
  9166. }
  9167. if (this._ownerReadableStream === undefined) {
  9168. return;
  9169. }
  9170. if (this._readRequests.length > 0) {
  9171. throw new TypeError('Tried to release a reader lock when that reader has pending read() calls un-settled');
  9172. }
  9173. ReadableStreamReaderGenericRelease(this);
  9174. }
  9175. }, {
  9176. key: 'closed',
  9177. get: function get() {
  9178. if (IsReadableStreamDefaultReader(this) === false) {
  9179. return Promise.reject(defaultReaderBrandCheckException('closed'));
  9180. }
  9181. return this._closedPromise;
  9182. }
  9183. }]);
  9184. return ReadableStreamDefaultReader;
  9185. }();
  9186. var ReadableStreamBYOBReader = function () {
  9187. function ReadableStreamBYOBReader(stream) {
  9188. _classCallCheck(this, ReadableStreamBYOBReader);
  9189. if (!IsReadableStream(stream)) {
  9190. throw new TypeError('ReadableStreamBYOBReader can only be constructed with a ReadableStream instance given a ' + 'byte source');
  9191. }
  9192. if (IsReadableByteStreamController(stream._readableStreamController) === false) {
  9193. throw new TypeError('Cannot construct a ReadableStreamBYOBReader for a stream not constructed with a byte ' + 'source');
  9194. }
  9195. if (IsReadableStreamLocked(stream)) {
  9196. throw new TypeError('This stream has already been locked for exclusive reading by another reader');
  9197. }
  9198. ReadableStreamReaderGenericInitialize(this, stream);
  9199. this._readIntoRequests = [];
  9200. }
  9201. _createClass(ReadableStreamBYOBReader, [{
  9202. key: 'cancel',
  9203. value: function cancel(reason) {
  9204. if (!IsReadableStreamBYOBReader(this)) {
  9205. return Promise.reject(byobReaderBrandCheckException('cancel'));
  9206. }
  9207. if (this._ownerReadableStream === undefined) {
  9208. return Promise.reject(readerLockException('cancel'));
  9209. }
  9210. return ReadableStreamReaderGenericCancel(this, reason);
  9211. }
  9212. }, {
  9213. key: 'read',
  9214. value: function read(view) {
  9215. if (!IsReadableStreamBYOBReader(this)) {
  9216. return Promise.reject(byobReaderBrandCheckException('read'));
  9217. }
  9218. if (this._ownerReadableStream === undefined) {
  9219. return Promise.reject(readerLockException('read from'));
  9220. }
  9221. if (!ArrayBuffer.isView(view)) {
  9222. return Promise.reject(new TypeError('view must be an array buffer view'));
  9223. }
  9224. if (view.byteLength === 0) {
  9225. return Promise.reject(new TypeError('view must have non-zero byteLength'));
  9226. }
  9227. return ReadableStreamBYOBReaderRead(this, view);
  9228. }
  9229. }, {
  9230. key: 'releaseLock',
  9231. value: function releaseLock() {
  9232. if (!IsReadableStreamBYOBReader(this)) {
  9233. throw byobReaderBrandCheckException('releaseLock');
  9234. }
  9235. if (this._ownerReadableStream === undefined) {
  9236. return;
  9237. }
  9238. if (this._readIntoRequests.length > 0) {
  9239. throw new TypeError('Tried to release a reader lock when that reader has pending read() calls un-settled');
  9240. }
  9241. ReadableStreamReaderGenericRelease(this);
  9242. }
  9243. }, {
  9244. key: 'closed',
  9245. get: function get() {
  9246. if (!IsReadableStreamBYOBReader(this)) {
  9247. return Promise.reject(byobReaderBrandCheckException('closed'));
  9248. }
  9249. return this._closedPromise;
  9250. }
  9251. }]);
  9252. return ReadableStreamBYOBReader;
  9253. }();
  9254. function IsReadableStreamBYOBReader(x) {
  9255. if (!typeIsObject(x)) {
  9256. return false;
  9257. }
  9258. if (!Object.prototype.hasOwnProperty.call(x, '_readIntoRequests')) {
  9259. return false;
  9260. }
  9261. return true;
  9262. }
  9263. function IsReadableStreamDefaultReader(x) {
  9264. if (!typeIsObject(x)) {
  9265. return false;
  9266. }
  9267. if (!Object.prototype.hasOwnProperty.call(x, '_readRequests')) {
  9268. return false;
  9269. }
  9270. return true;
  9271. }
  9272. function ReadableStreamReaderGenericInitialize(reader, stream) {
  9273. reader._ownerReadableStream = stream;
  9274. stream._reader = reader;
  9275. if (stream._state === 'readable') {
  9276. defaultReaderClosedPromiseInitialize(reader);
  9277. } else if (stream._state === 'closed') {
  9278. defaultReaderClosedPromiseInitializeAsResolved(reader);
  9279. } else {
  9280. assert(stream._state === 'errored', 'state must be errored');
  9281. defaultReaderClosedPromiseInitializeAsRejected(reader, stream._storedError);
  9282. reader._closedPromise.catch(function () {});
  9283. }
  9284. }
  9285. function ReadableStreamReaderGenericCancel(reader, reason) {
  9286. var stream = reader._ownerReadableStream;
  9287. assert(stream !== undefined);
  9288. return ReadableStreamCancel(stream, reason);
  9289. }
  9290. function ReadableStreamReaderGenericRelease(reader) {
  9291. assert(reader._ownerReadableStream !== undefined);
  9292. assert(reader._ownerReadableStream._reader === reader);
  9293. if (reader._ownerReadableStream._state === 'readable') {
  9294. defaultReaderClosedPromiseReject(reader, new TypeError('Reader was released and can no longer be used to monitor the stream\'s closedness'));
  9295. } else {
  9296. defaultReaderClosedPromiseResetToRejected(reader, new TypeError('Reader was released and can no longer be used to monitor the stream\'s closedness'));
  9297. }
  9298. reader._closedPromise.catch(function () {});
  9299. reader._ownerReadableStream._reader = undefined;
  9300. reader._ownerReadableStream = undefined;
  9301. }
  9302. function ReadableStreamBYOBReaderRead(reader, view) {
  9303. var stream = reader._ownerReadableStream;
  9304. assert(stream !== undefined);
  9305. stream._disturbed = true;
  9306. if (stream._state === 'errored') {
  9307. return Promise.reject(stream._storedError);
  9308. }
  9309. return ReadableByteStreamControllerPullInto(stream._readableStreamController, view);
  9310. }
  9311. function ReadableStreamDefaultReaderRead(reader) {
  9312. var stream = reader._ownerReadableStream;
  9313. assert(stream !== undefined);
  9314. stream._disturbed = true;
  9315. if (stream._state === 'closed') {
  9316. return Promise.resolve(CreateIterResultObject(undefined, true));
  9317. }
  9318. if (stream._state === 'errored') {
  9319. return Promise.reject(stream._storedError);
  9320. }
  9321. assert(stream._state === 'readable');
  9322. return stream._readableStreamController.__pullSteps();
  9323. }
  9324. var ReadableStreamDefaultController = function () {
  9325. function ReadableStreamDefaultController(stream, underlyingSource, size, highWaterMark) {
  9326. _classCallCheck(this, ReadableStreamDefaultController);
  9327. if (IsReadableStream(stream) === false) {
  9328. throw new TypeError('ReadableStreamDefaultController can only be constructed with a ReadableStream instance');
  9329. }
  9330. if (stream._readableStreamController !== undefined) {
  9331. throw new TypeError('ReadableStreamDefaultController instances can only be created by the ReadableStream constructor');
  9332. }
  9333. this._controlledReadableStream = stream;
  9334. this._underlyingSource = underlyingSource;
  9335. this._queue = undefined;
  9336. this._queueTotalSize = undefined;
  9337. ResetQueue(this);
  9338. this._started = false;
  9339. this._closeRequested = false;
  9340. this._pullAgain = false;
  9341. this._pulling = false;
  9342. var normalizedStrategy = ValidateAndNormalizeQueuingStrategy(size, highWaterMark);
  9343. this._strategySize = normalizedStrategy.size;
  9344. this._strategyHWM = normalizedStrategy.highWaterMark;
  9345. var controller = this;
  9346. var startResult = InvokeOrNoop(underlyingSource, 'start', [this]);
  9347. Promise.resolve(startResult).then(function () {
  9348. controller._started = true;
  9349. assert(controller._pulling === false);
  9350. assert(controller._pullAgain === false);
  9351. ReadableStreamDefaultControllerCallPullIfNeeded(controller);
  9352. }, function (r) {
  9353. ReadableStreamDefaultControllerErrorIfNeeded(controller, r);
  9354. }).catch(rethrowAssertionErrorRejection);
  9355. }
  9356. _createClass(ReadableStreamDefaultController, [{
  9357. key: 'close',
  9358. value: function close() {
  9359. if (IsReadableStreamDefaultController(this) === false) {
  9360. throw defaultControllerBrandCheckException('close');
  9361. }
  9362. if (this._closeRequested === true) {
  9363. throw new TypeError('The stream has already been closed; do not close it again!');
  9364. }
  9365. var state = this._controlledReadableStream._state;
  9366. if (state !== 'readable') {
  9367. throw new TypeError('The stream (in ' + state + ' state) is not in the readable state and cannot be closed');
  9368. }
  9369. ReadableStreamDefaultControllerClose(this);
  9370. }
  9371. }, {
  9372. key: 'enqueue',
  9373. value: function enqueue(chunk) {
  9374. if (IsReadableStreamDefaultController(this) === false) {
  9375. throw defaultControllerBrandCheckException('enqueue');
  9376. }
  9377. if (this._closeRequested === true) {
  9378. throw new TypeError('stream is closed or draining');
  9379. }
  9380. var state = this._controlledReadableStream._state;
  9381. if (state !== 'readable') {
  9382. throw new TypeError('The stream (in ' + state + ' state) is not in the readable state and cannot be enqueued to');
  9383. }
  9384. return ReadableStreamDefaultControllerEnqueue(this, chunk);
  9385. }
  9386. }, {
  9387. key: 'error',
  9388. value: function error(e) {
  9389. if (IsReadableStreamDefaultController(this) === false) {
  9390. throw defaultControllerBrandCheckException('error');
  9391. }
  9392. var stream = this._controlledReadableStream;
  9393. if (stream._state !== 'readable') {
  9394. throw new TypeError('The stream is ' + stream._state + ' and so cannot be errored');
  9395. }
  9396. ReadableStreamDefaultControllerError(this, e);
  9397. }
  9398. }, {
  9399. key: '__cancelSteps',
  9400. value: function __cancelSteps(reason) {
  9401. ResetQueue(this);
  9402. return PromiseInvokeOrNoop(this._underlyingSource, 'cancel', [reason]);
  9403. }
  9404. }, {
  9405. key: '__pullSteps',
  9406. value: function __pullSteps() {
  9407. var stream = this._controlledReadableStream;
  9408. if (this._queue.length > 0) {
  9409. var chunk = DequeueValue(this);
  9410. if (this._closeRequested === true && this._queue.length === 0) {
  9411. ReadableStreamClose(stream);
  9412. } else {
  9413. ReadableStreamDefaultControllerCallPullIfNeeded(this);
  9414. }
  9415. return Promise.resolve(CreateIterResultObject(chunk, false));
  9416. }
  9417. var pendingPromise = ReadableStreamAddReadRequest(stream);
  9418. ReadableStreamDefaultControllerCallPullIfNeeded(this);
  9419. return pendingPromise;
  9420. }
  9421. }, {
  9422. key: 'desiredSize',
  9423. get: function get() {
  9424. if (IsReadableStreamDefaultController(this) === false) {
  9425. throw defaultControllerBrandCheckException('desiredSize');
  9426. }
  9427. return ReadableStreamDefaultControllerGetDesiredSize(this);
  9428. }
  9429. }]);
  9430. return ReadableStreamDefaultController;
  9431. }();
  9432. function IsReadableStreamDefaultController(x) {
  9433. if (!typeIsObject(x)) {
  9434. return false;
  9435. }
  9436. if (!Object.prototype.hasOwnProperty.call(x, '_underlyingSource')) {
  9437. return false;
  9438. }
  9439. return true;
  9440. }
  9441. function ReadableStreamDefaultControllerCallPullIfNeeded(controller) {
  9442. var shouldPull = ReadableStreamDefaultControllerShouldCallPull(controller);
  9443. if (shouldPull === false) {
  9444. return undefined;
  9445. }
  9446. if (controller._pulling === true) {
  9447. controller._pullAgain = true;
  9448. return undefined;
  9449. }
  9450. assert(controller._pullAgain === false);
  9451. controller._pulling = true;
  9452. var pullPromise = PromiseInvokeOrNoop(controller._underlyingSource, 'pull', [controller]);
  9453. pullPromise.then(function () {
  9454. controller._pulling = false;
  9455. if (controller._pullAgain === true) {
  9456. controller._pullAgain = false;
  9457. return ReadableStreamDefaultControllerCallPullIfNeeded(controller);
  9458. }
  9459. return undefined;
  9460. }, function (e) {
  9461. ReadableStreamDefaultControllerErrorIfNeeded(controller, e);
  9462. }).catch(rethrowAssertionErrorRejection);
  9463. return undefined;
  9464. }
  9465. function ReadableStreamDefaultControllerShouldCallPull(controller) {
  9466. var stream = controller._controlledReadableStream;
  9467. if (stream._state === 'closed' || stream._state === 'errored') {
  9468. return false;
  9469. }
  9470. if (controller._closeRequested === true) {
  9471. return false;
  9472. }
  9473. if (controller._started === false) {
  9474. return false;
  9475. }
  9476. if (IsReadableStreamLocked(stream) === true && ReadableStreamGetNumReadRequests(stream) > 0) {
  9477. return true;
  9478. }
  9479. var desiredSize = ReadableStreamDefaultControllerGetDesiredSize(controller);
  9480. if (desiredSize > 0) {
  9481. return true;
  9482. }
  9483. return false;
  9484. }
  9485. function ReadableStreamDefaultControllerClose(controller) {
  9486. var stream = controller._controlledReadableStream;
  9487. assert(controller._closeRequested === false);
  9488. assert(stream._state === 'readable');
  9489. controller._closeRequested = true;
  9490. if (controller._queue.length === 0) {
  9491. ReadableStreamClose(stream);
  9492. }
  9493. }
  9494. function ReadableStreamDefaultControllerEnqueue(controller, chunk) {
  9495. var stream = controller._controlledReadableStream;
  9496. assert(controller._closeRequested === false);
  9497. assert(stream._state === 'readable');
  9498. if (IsReadableStreamLocked(stream) === true && ReadableStreamGetNumReadRequests(stream) > 0) {
  9499. ReadableStreamFulfillReadRequest(stream, chunk, false);
  9500. } else {
  9501. var chunkSize = 1;
  9502. if (controller._strategySize !== undefined) {
  9503. var strategySize = controller._strategySize;
  9504. try {
  9505. chunkSize = strategySize(chunk);
  9506. } catch (chunkSizeE) {
  9507. ReadableStreamDefaultControllerErrorIfNeeded(controller, chunkSizeE);
  9508. throw chunkSizeE;
  9509. }
  9510. }
  9511. try {
  9512. EnqueueValueWithSize(controller, chunk, chunkSize);
  9513. } catch (enqueueE) {
  9514. ReadableStreamDefaultControllerErrorIfNeeded(controller, enqueueE);
  9515. throw enqueueE;
  9516. }
  9517. }
  9518. ReadableStreamDefaultControllerCallPullIfNeeded(controller);
  9519. return undefined;
  9520. }
  9521. function ReadableStreamDefaultControllerError(controller, e) {
  9522. var stream = controller._controlledReadableStream;
  9523. assert(stream._state === 'readable');
  9524. ResetQueue(controller);
  9525. ReadableStreamError(stream, e);
  9526. }
  9527. function ReadableStreamDefaultControllerErrorIfNeeded(controller, e) {
  9528. if (controller._controlledReadableStream._state === 'readable') {
  9529. ReadableStreamDefaultControllerError(controller, e);
  9530. }
  9531. }
  9532. function ReadableStreamDefaultControllerGetDesiredSize(controller) {
  9533. var stream = controller._controlledReadableStream;
  9534. var state = stream._state;
  9535. if (state === 'errored') {
  9536. return null;
  9537. }
  9538. if (state === 'closed') {
  9539. return 0;
  9540. }
  9541. return controller._strategyHWM - controller._queueTotalSize;
  9542. }
  9543. var ReadableStreamBYOBRequest = function () {
  9544. function ReadableStreamBYOBRequest(controller, view) {
  9545. _classCallCheck(this, ReadableStreamBYOBRequest);
  9546. this._associatedReadableByteStreamController = controller;
  9547. this._view = view;
  9548. }
  9549. _createClass(ReadableStreamBYOBRequest, [{
  9550. key: 'respond',
  9551. value: function respond(bytesWritten) {
  9552. if (IsReadableStreamBYOBRequest(this) === false) {
  9553. throw byobRequestBrandCheckException('respond');
  9554. }
  9555. if (this._associatedReadableByteStreamController === undefined) {
  9556. throw new TypeError('This BYOB request has been invalidated');
  9557. }
  9558. ReadableByteStreamControllerRespond(this._associatedReadableByteStreamController, bytesWritten);
  9559. }
  9560. }, {
  9561. key: 'respondWithNewView',
  9562. value: function respondWithNewView(view) {
  9563. if (IsReadableStreamBYOBRequest(this) === false) {
  9564. throw byobRequestBrandCheckException('respond');
  9565. }
  9566. if (this._associatedReadableByteStreamController === undefined) {
  9567. throw new TypeError('This BYOB request has been invalidated');
  9568. }
  9569. if (!ArrayBuffer.isView(view)) {
  9570. throw new TypeError('You can only respond with array buffer views');
  9571. }
  9572. ReadableByteStreamControllerRespondWithNewView(this._associatedReadableByteStreamController, view);
  9573. }
  9574. }, {
  9575. key: 'view',
  9576. get: function get() {
  9577. return this._view;
  9578. }
  9579. }]);
  9580. return ReadableStreamBYOBRequest;
  9581. }();
  9582. var ReadableByteStreamController = function () {
  9583. function ReadableByteStreamController(stream, underlyingByteSource, highWaterMark) {
  9584. _classCallCheck(this, ReadableByteStreamController);
  9585. if (IsReadableStream(stream) === false) {
  9586. throw new TypeError('ReadableByteStreamController can only be constructed with a ReadableStream instance given ' + 'a byte source');
  9587. }
  9588. if (stream._readableStreamController !== undefined) {
  9589. throw new TypeError('ReadableByteStreamController instances can only be created by the ReadableStream constructor given a byte ' + 'source');
  9590. }
  9591. this._controlledReadableStream = stream;
  9592. this._underlyingByteSource = underlyingByteSource;
  9593. this._pullAgain = false;
  9594. this._pulling = false;
  9595. ReadableByteStreamControllerClearPendingPullIntos(this);
  9596. this._queue = this._queueTotalSize = undefined;
  9597. ResetQueue(this);
  9598. this._closeRequested = false;
  9599. this._started = false;
  9600. this._strategyHWM = ValidateAndNormalizeHighWaterMark(highWaterMark);
  9601. var autoAllocateChunkSize = underlyingByteSource.autoAllocateChunkSize;
  9602. if (autoAllocateChunkSize !== undefined) {
  9603. if (Number.isInteger(autoAllocateChunkSize) === false || autoAllocateChunkSize <= 0) {
  9604. throw new RangeError('autoAllocateChunkSize must be a positive integer');
  9605. }
  9606. }
  9607. this._autoAllocateChunkSize = autoAllocateChunkSize;
  9608. this._pendingPullIntos = [];
  9609. var controller = this;
  9610. var startResult = InvokeOrNoop(underlyingByteSource, 'start', [this]);
  9611. Promise.resolve(startResult).then(function () {
  9612. controller._started = true;
  9613. assert(controller._pulling === false);
  9614. assert(controller._pullAgain === false);
  9615. ReadableByteStreamControllerCallPullIfNeeded(controller);
  9616. }, function (r) {
  9617. if (stream._state === 'readable') {
  9618. ReadableByteStreamControllerError(controller, r);
  9619. }
  9620. }).catch(rethrowAssertionErrorRejection);
  9621. }
  9622. _createClass(ReadableByteStreamController, [{
  9623. key: 'close',
  9624. value: function close() {
  9625. if (IsReadableByteStreamController(this) === false) {
  9626. throw byteStreamControllerBrandCheckException('close');
  9627. }
  9628. if (this._closeRequested === true) {
  9629. throw new TypeError('The stream has already been closed; do not close it again!');
  9630. }
  9631. var state = this._controlledReadableStream._state;
  9632. if (state !== 'readable') {
  9633. throw new TypeError('The stream (in ' + state + ' state) is not in the readable state and cannot be closed');
  9634. }
  9635. ReadableByteStreamControllerClose(this);
  9636. }
  9637. }, {
  9638. key: 'enqueue',
  9639. value: function enqueue(chunk) {
  9640. if (IsReadableByteStreamController(this) === false) {
  9641. throw byteStreamControllerBrandCheckException('enqueue');
  9642. }
  9643. if (this._closeRequested === true) {
  9644. throw new TypeError('stream is closed or draining');
  9645. }
  9646. var state = this._controlledReadableStream._state;
  9647. if (state !== 'readable') {
  9648. throw new TypeError('The stream (in ' + state + ' state) is not in the readable state and cannot be enqueued to');
  9649. }
  9650. if (!ArrayBuffer.isView(chunk)) {
  9651. throw new TypeError('You can only enqueue array buffer views when using a ReadableByteStreamController');
  9652. }
  9653. ReadableByteStreamControllerEnqueue(this, chunk);
  9654. }
  9655. }, {
  9656. key: 'error',
  9657. value: function error(e) {
  9658. if (IsReadableByteStreamController(this) === false) {
  9659. throw byteStreamControllerBrandCheckException('error');
  9660. }
  9661. var stream = this._controlledReadableStream;
  9662. if (stream._state !== 'readable') {
  9663. throw new TypeError('The stream is ' + stream._state + ' and so cannot be errored');
  9664. }
  9665. ReadableByteStreamControllerError(this, e);
  9666. }
  9667. }, {
  9668. key: '__cancelSteps',
  9669. value: function __cancelSteps(reason) {
  9670. if (this._pendingPullIntos.length > 0) {
  9671. var firstDescriptor = this._pendingPullIntos[0];
  9672. firstDescriptor.bytesFilled = 0;
  9673. }
  9674. ResetQueue(this);
  9675. return PromiseInvokeOrNoop(this._underlyingByteSource, 'cancel', [reason]);
  9676. }
  9677. }, {
  9678. key: '__pullSteps',
  9679. value: function __pullSteps() {
  9680. var stream = this._controlledReadableStream;
  9681. assert(ReadableStreamHasDefaultReader(stream) === true);
  9682. if (this._queueTotalSize > 0) {
  9683. assert(ReadableStreamGetNumReadRequests(stream) === 0);
  9684. var entry = this._queue.shift();
  9685. this._queueTotalSize -= entry.byteLength;
  9686. ReadableByteStreamControllerHandleQueueDrain(this);
  9687. var view = void 0;
  9688. try {
  9689. view = new Uint8Array(entry.buffer, entry.byteOffset, entry.byteLength);
  9690. } catch (viewE) {
  9691. return Promise.reject(viewE);
  9692. }
  9693. return Promise.resolve(CreateIterResultObject(view, false));
  9694. }
  9695. var autoAllocateChunkSize = this._autoAllocateChunkSize;
  9696. if (autoAllocateChunkSize !== undefined) {
  9697. var buffer = void 0;
  9698. try {
  9699. buffer = new ArrayBuffer(autoAllocateChunkSize);
  9700. } catch (bufferE) {
  9701. return Promise.reject(bufferE);
  9702. }
  9703. var pullIntoDescriptor = {
  9704. buffer: buffer,
  9705. byteOffset: 0,
  9706. byteLength: autoAllocateChunkSize,
  9707. bytesFilled: 0,
  9708. elementSize: 1,
  9709. ctor: Uint8Array,
  9710. readerType: 'default'
  9711. };
  9712. this._pendingPullIntos.push(pullIntoDescriptor);
  9713. }
  9714. var promise = ReadableStreamAddReadRequest(stream);
  9715. ReadableByteStreamControllerCallPullIfNeeded(this);
  9716. return promise;
  9717. }
  9718. }, {
  9719. key: 'byobRequest',
  9720. get: function get() {
  9721. if (IsReadableByteStreamController(this) === false) {
  9722. throw byteStreamControllerBrandCheckException('byobRequest');
  9723. }
  9724. if (this._byobRequest === undefined && this._pendingPullIntos.length > 0) {
  9725. var firstDescriptor = this._pendingPullIntos[0];
  9726. var view = new Uint8Array(firstDescriptor.buffer, firstDescriptor.byteOffset + firstDescriptor.bytesFilled, firstDescriptor.byteLength - firstDescriptor.bytesFilled);
  9727. this._byobRequest = new ReadableStreamBYOBRequest(this, view);
  9728. }
  9729. return this._byobRequest;
  9730. }
  9731. }, {
  9732. key: 'desiredSize',
  9733. get: function get() {
  9734. if (IsReadableByteStreamController(this) === false) {
  9735. throw byteStreamControllerBrandCheckException('desiredSize');
  9736. }
  9737. return ReadableByteStreamControllerGetDesiredSize(this);
  9738. }
  9739. }]);
  9740. return ReadableByteStreamController;
  9741. }();
  9742. function IsReadableByteStreamController(x) {
  9743. if (!typeIsObject(x)) {
  9744. return false;
  9745. }
  9746. if (!Object.prototype.hasOwnProperty.call(x, '_underlyingByteSource')) {
  9747. return false;
  9748. }
  9749. return true;
  9750. }
  9751. function IsReadableStreamBYOBRequest(x) {
  9752. if (!typeIsObject(x)) {
  9753. return false;
  9754. }
  9755. if (!Object.prototype.hasOwnProperty.call(x, '_associatedReadableByteStreamController')) {
  9756. return false;
  9757. }
  9758. return true;
  9759. }
  9760. function ReadableByteStreamControllerCallPullIfNeeded(controller) {
  9761. var shouldPull = ReadableByteStreamControllerShouldCallPull(controller);
  9762. if (shouldPull === false) {
  9763. return undefined;
  9764. }
  9765. if (controller._pulling === true) {
  9766. controller._pullAgain = true;
  9767. return undefined;
  9768. }
  9769. assert(controller._pullAgain === false);
  9770. controller._pulling = true;
  9771. var pullPromise = PromiseInvokeOrNoop(controller._underlyingByteSource, 'pull', [controller]);
  9772. pullPromise.then(function () {
  9773. controller._pulling = false;
  9774. if (controller._pullAgain === true) {
  9775. controller._pullAgain = false;
  9776. ReadableByteStreamControllerCallPullIfNeeded(controller);
  9777. }
  9778. }, function (e) {
  9779. if (controller._controlledReadableStream._state === 'readable') {
  9780. ReadableByteStreamControllerError(controller, e);
  9781. }
  9782. }).catch(rethrowAssertionErrorRejection);
  9783. return undefined;
  9784. }
  9785. function ReadableByteStreamControllerClearPendingPullIntos(controller) {
  9786. ReadableByteStreamControllerInvalidateBYOBRequest(controller);
  9787. controller._pendingPullIntos = [];
  9788. }
  9789. function ReadableByteStreamControllerCommitPullIntoDescriptor(stream, pullIntoDescriptor) {
  9790. assert(stream._state !== 'errored', 'state must not be errored');
  9791. var done = false;
  9792. if (stream._state === 'closed') {
  9793. assert(pullIntoDescriptor.bytesFilled === 0);
  9794. done = true;
  9795. }
  9796. var filledView = ReadableByteStreamControllerConvertPullIntoDescriptor(pullIntoDescriptor);
  9797. if (pullIntoDescriptor.readerType === 'default') {
  9798. ReadableStreamFulfillReadRequest(stream, filledView, done);
  9799. } else {
  9800. assert(pullIntoDescriptor.readerType === 'byob');
  9801. ReadableStreamFulfillReadIntoRequest(stream, filledView, done);
  9802. }
  9803. }
  9804. function ReadableByteStreamControllerConvertPullIntoDescriptor(pullIntoDescriptor) {
  9805. var bytesFilled = pullIntoDescriptor.bytesFilled;
  9806. var elementSize = pullIntoDescriptor.elementSize;
  9807. assert(bytesFilled <= pullIntoDescriptor.byteLength);
  9808. assert(bytesFilled % elementSize === 0);
  9809. return new pullIntoDescriptor.ctor(pullIntoDescriptor.buffer, pullIntoDescriptor.byteOffset, bytesFilled / elementSize);
  9810. }
  9811. function ReadableByteStreamControllerEnqueueChunkToQueue(controller, buffer, byteOffset, byteLength) {
  9812. controller._queue.push({
  9813. buffer: buffer,
  9814. byteOffset: byteOffset,
  9815. byteLength: byteLength
  9816. });
  9817. controller._queueTotalSize += byteLength;
  9818. }
  9819. function ReadableByteStreamControllerFillPullIntoDescriptorFromQueue(controller, pullIntoDescriptor) {
  9820. var elementSize = pullIntoDescriptor.elementSize;
  9821. var currentAlignedBytes = pullIntoDescriptor.bytesFilled - pullIntoDescriptor.bytesFilled % elementSize;
  9822. var maxBytesToCopy = Math.min(controller._queueTotalSize, pullIntoDescriptor.byteLength - pullIntoDescriptor.bytesFilled);
  9823. var maxBytesFilled = pullIntoDescriptor.bytesFilled + maxBytesToCopy;
  9824. var maxAlignedBytes = maxBytesFilled - maxBytesFilled % elementSize;
  9825. var totalBytesToCopyRemaining = maxBytesToCopy;
  9826. var ready = false;
  9827. if (maxAlignedBytes > currentAlignedBytes) {
  9828. totalBytesToCopyRemaining = maxAlignedBytes - pullIntoDescriptor.bytesFilled;
  9829. ready = true;
  9830. }
  9831. var queue = controller._queue;
  9832. while (totalBytesToCopyRemaining > 0) {
  9833. var headOfQueue = queue[0];
  9834. var bytesToCopy = Math.min(totalBytesToCopyRemaining, headOfQueue.byteLength);
  9835. var destStart = pullIntoDescriptor.byteOffset + pullIntoDescriptor.bytesFilled;
  9836. ArrayBufferCopy(pullIntoDescriptor.buffer, destStart, headOfQueue.buffer, headOfQueue.byteOffset, bytesToCopy);
  9837. if (headOfQueue.byteLength === bytesToCopy) {
  9838. queue.shift();
  9839. } else {
  9840. headOfQueue.byteOffset += bytesToCopy;
  9841. headOfQueue.byteLength -= bytesToCopy;
  9842. }
  9843. controller._queueTotalSize -= bytesToCopy;
  9844. ReadableByteStreamControllerFillHeadPullIntoDescriptor(controller, bytesToCopy, pullIntoDescriptor);
  9845. totalBytesToCopyRemaining -= bytesToCopy;
  9846. }
  9847. if (ready === false) {
  9848. assert(controller._queueTotalSize === 0, 'queue must be empty');
  9849. assert(pullIntoDescriptor.bytesFilled > 0);
  9850. assert(pullIntoDescriptor.bytesFilled < pullIntoDescriptor.elementSize);
  9851. }
  9852. return ready;
  9853. }
  9854. function ReadableByteStreamControllerFillHeadPullIntoDescriptor(controller, size, pullIntoDescriptor) {
  9855. assert(controller._pendingPullIntos.length === 0 || controller._pendingPullIntos[0] === pullIntoDescriptor);
  9856. ReadableByteStreamControllerInvalidateBYOBRequest(controller);
  9857. pullIntoDescriptor.bytesFilled += size;
  9858. }
  9859. function ReadableByteStreamControllerHandleQueueDrain(controller) {
  9860. assert(controller._controlledReadableStream._state === 'readable');
  9861. if (controller._queueTotalSize === 0 && controller._closeRequested === true) {
  9862. ReadableStreamClose(controller._controlledReadableStream);
  9863. } else {
  9864. ReadableByteStreamControllerCallPullIfNeeded(controller);
  9865. }
  9866. }
  9867. function ReadableByteStreamControllerInvalidateBYOBRequest(controller) {
  9868. if (controller._byobRequest === undefined) {
  9869. return;
  9870. }
  9871. controller._byobRequest._associatedReadableByteStreamController = undefined;
  9872. controller._byobRequest._view = undefined;
  9873. controller._byobRequest = undefined;
  9874. }
  9875. function ReadableByteStreamControllerProcessPullIntoDescriptorsUsingQueue(controller) {
  9876. assert(controller._closeRequested === false);
  9877. while (controller._pendingPullIntos.length > 0) {
  9878. if (controller._queueTotalSize === 0) {
  9879. return;
  9880. }
  9881. var pullIntoDescriptor = controller._pendingPullIntos[0];
  9882. if (ReadableByteStreamControllerFillPullIntoDescriptorFromQueue(controller, pullIntoDescriptor) === true) {
  9883. ReadableByteStreamControllerShiftPendingPullInto(controller);
  9884. ReadableByteStreamControllerCommitPullIntoDescriptor(controller._controlledReadableStream, pullIntoDescriptor);
  9885. }
  9886. }
  9887. }
  9888. function ReadableByteStreamControllerPullInto(controller, view) {
  9889. var stream = controller._controlledReadableStream;
  9890. var elementSize = 1;
  9891. if (view.constructor !== DataView) {
  9892. elementSize = view.constructor.BYTES_PER_ELEMENT;
  9893. }
  9894. var ctor = view.constructor;
  9895. var pullIntoDescriptor = {
  9896. buffer: view.buffer,
  9897. byteOffset: view.byteOffset,
  9898. byteLength: view.byteLength,
  9899. bytesFilled: 0,
  9900. elementSize: elementSize,
  9901. ctor: ctor,
  9902. readerType: 'byob'
  9903. };
  9904. if (controller._pendingPullIntos.length > 0) {
  9905. pullIntoDescriptor.buffer = TransferArrayBuffer(pullIntoDescriptor.buffer);
  9906. controller._pendingPullIntos.push(pullIntoDescriptor);
  9907. return ReadableStreamAddReadIntoRequest(stream);
  9908. }
  9909. if (stream._state === 'closed') {
  9910. var emptyView = new view.constructor(pullIntoDescriptor.buffer, pullIntoDescriptor.byteOffset, 0);
  9911. return Promise.resolve(CreateIterResultObject(emptyView, true));
  9912. }
  9913. if (controller._queueTotalSize > 0) {
  9914. if (ReadableByteStreamControllerFillPullIntoDescriptorFromQueue(controller, pullIntoDescriptor) === true) {
  9915. var filledView = ReadableByteStreamControllerConvertPullIntoDescriptor(pullIntoDescriptor);
  9916. ReadableByteStreamControllerHandleQueueDrain(controller);
  9917. return Promise.resolve(CreateIterResultObject(filledView, false));
  9918. }
  9919. if (controller._closeRequested === true) {
  9920. var e = new TypeError('Insufficient bytes to fill elements in the given buffer');
  9921. ReadableByteStreamControllerError(controller, e);
  9922. return Promise.reject(e);
  9923. }
  9924. }
  9925. pullIntoDescriptor.buffer = TransferArrayBuffer(pullIntoDescriptor.buffer);
  9926. controller._pendingPullIntos.push(pullIntoDescriptor);
  9927. var promise = ReadableStreamAddReadIntoRequest(stream);
  9928. ReadableByteStreamControllerCallPullIfNeeded(controller);
  9929. return promise;
  9930. }
  9931. function ReadableByteStreamControllerRespondInClosedState(controller, firstDescriptor) {
  9932. firstDescriptor.buffer = TransferArrayBuffer(firstDescriptor.buffer);
  9933. assert(firstDescriptor.bytesFilled === 0, 'bytesFilled must be 0');
  9934. var stream = controller._controlledReadableStream;
  9935. if (ReadableStreamHasBYOBReader(stream) === true) {
  9936. while (ReadableStreamGetNumReadIntoRequests(stream) > 0) {
  9937. var pullIntoDescriptor = ReadableByteStreamControllerShiftPendingPullInto(controller);
  9938. ReadableByteStreamControllerCommitPullIntoDescriptor(stream, pullIntoDescriptor);
  9939. }
  9940. }
  9941. }
  9942. function ReadableByteStreamControllerRespondInReadableState(controller, bytesWritten, pullIntoDescriptor) {
  9943. if (pullIntoDescriptor.bytesFilled + bytesWritten > pullIntoDescriptor.byteLength) {
  9944. throw new RangeError('bytesWritten out of range');
  9945. }
  9946. ReadableByteStreamControllerFillHeadPullIntoDescriptor(controller, bytesWritten, pullIntoDescriptor);
  9947. if (pullIntoDescriptor.bytesFilled < pullIntoDescriptor.elementSize) {
  9948. return;
  9949. }
  9950. ReadableByteStreamControllerShiftPendingPullInto(controller);
  9951. var remainderSize = pullIntoDescriptor.bytesFilled % pullIntoDescriptor.elementSize;
  9952. if (remainderSize > 0) {
  9953. var end = pullIntoDescriptor.byteOffset + pullIntoDescriptor.bytesFilled;
  9954. var remainder = pullIntoDescriptor.buffer.slice(end - remainderSize, end);
  9955. ReadableByteStreamControllerEnqueueChunkToQueue(controller, remainder, 0, remainder.byteLength);
  9956. }
  9957. pullIntoDescriptor.buffer = TransferArrayBuffer(pullIntoDescriptor.buffer);
  9958. pullIntoDescriptor.bytesFilled -= remainderSize;
  9959. ReadableByteStreamControllerCommitPullIntoDescriptor(controller._controlledReadableStream, pullIntoDescriptor);
  9960. ReadableByteStreamControllerProcessPullIntoDescriptorsUsingQueue(controller);
  9961. }
  9962. function ReadableByteStreamControllerRespondInternal(controller, bytesWritten) {
  9963. var firstDescriptor = controller._pendingPullIntos[0];
  9964. var stream = controller._controlledReadableStream;
  9965. if (stream._state === 'closed') {
  9966. if (bytesWritten !== 0) {
  9967. throw new TypeError('bytesWritten must be 0 when calling respond() on a closed stream');
  9968. }
  9969. ReadableByteStreamControllerRespondInClosedState(controller, firstDescriptor);
  9970. } else {
  9971. assert(stream._state === 'readable');
  9972. ReadableByteStreamControllerRespondInReadableState(controller, bytesWritten, firstDescriptor);
  9973. }
  9974. }
  9975. function ReadableByteStreamControllerShiftPendingPullInto(controller) {
  9976. var descriptor = controller._pendingPullIntos.shift();
  9977. ReadableByteStreamControllerInvalidateBYOBRequest(controller);
  9978. return descriptor;
  9979. }
  9980. function ReadableByteStreamControllerShouldCallPull(controller) {
  9981. var stream = controller._controlledReadableStream;
  9982. if (stream._state !== 'readable') {
  9983. return false;
  9984. }
  9985. if (controller._closeRequested === true) {
  9986. return false;
  9987. }
  9988. if (controller._started === false) {
  9989. return false;
  9990. }
  9991. if (ReadableStreamHasDefaultReader(stream) === true && ReadableStreamGetNumReadRequests(stream) > 0) {
  9992. return true;
  9993. }
  9994. if (ReadableStreamHasBYOBReader(stream) === true && ReadableStreamGetNumReadIntoRequests(stream) > 0) {
  9995. return true;
  9996. }
  9997. if (ReadableByteStreamControllerGetDesiredSize(controller) > 0) {
  9998. return true;
  9999. }
  10000. return false;
  10001. }
  10002. function ReadableByteStreamControllerClose(controller) {
  10003. var stream = controller._controlledReadableStream;
  10004. assert(controller._closeRequested === false);
  10005. assert(stream._state === 'readable');
  10006. if (controller._queueTotalSize > 0) {
  10007. controller._closeRequested = true;
  10008. return;
  10009. }
  10010. if (controller._pendingPullIntos.length > 0) {
  10011. var firstPendingPullInto = controller._pendingPullIntos[0];
  10012. if (firstPendingPullInto.bytesFilled > 0) {
  10013. var e = new TypeError('Insufficient bytes to fill elements in the given buffer');
  10014. ReadableByteStreamControllerError(controller, e);
  10015. throw e;
  10016. }
  10017. }
  10018. ReadableStreamClose(stream);
  10019. }
  10020. function ReadableByteStreamControllerEnqueue(controller, chunk) {
  10021. var stream = controller._controlledReadableStream;
  10022. assert(controller._closeRequested === false);
  10023. assert(stream._state === 'readable');
  10024. var buffer = chunk.buffer;
  10025. var byteOffset = chunk.byteOffset;
  10026. var byteLength = chunk.byteLength;
  10027. var transferredBuffer = TransferArrayBuffer(buffer);
  10028. if (ReadableStreamHasDefaultReader(stream) === true) {
  10029. if (ReadableStreamGetNumReadRequests(stream) === 0) {
  10030. ReadableByteStreamControllerEnqueueChunkToQueue(controller, transferredBuffer, byteOffset, byteLength);
  10031. } else {
  10032. assert(controller._queue.length === 0);
  10033. var transferredView = new Uint8Array(transferredBuffer, byteOffset, byteLength);
  10034. ReadableStreamFulfillReadRequest(stream, transferredView, false);
  10035. }
  10036. } else if (ReadableStreamHasBYOBReader(stream) === true) {
  10037. ReadableByteStreamControllerEnqueueChunkToQueue(controller, transferredBuffer, byteOffset, byteLength);
  10038. ReadableByteStreamControllerProcessPullIntoDescriptorsUsingQueue(controller);
  10039. } else {
  10040. assert(IsReadableStreamLocked(stream) === false, 'stream must not be locked');
  10041. ReadableByteStreamControllerEnqueueChunkToQueue(controller, transferredBuffer, byteOffset, byteLength);
  10042. }
  10043. }
  10044. function ReadableByteStreamControllerError(controller, e) {
  10045. var stream = controller._controlledReadableStream;
  10046. assert(stream._state === 'readable');
  10047. ReadableByteStreamControllerClearPendingPullIntos(controller);
  10048. ResetQueue(controller);
  10049. ReadableStreamError(stream, e);
  10050. }
  10051. function ReadableByteStreamControllerGetDesiredSize(controller) {
  10052. var stream = controller._controlledReadableStream;
  10053. var state = stream._state;
  10054. if (state === 'errored') {
  10055. return null;
  10056. }
  10057. if (state === 'closed') {
  10058. return 0;
  10059. }
  10060. return controller._strategyHWM - controller._queueTotalSize;
  10061. }
  10062. function ReadableByteStreamControllerRespond(controller, bytesWritten) {
  10063. bytesWritten = Number(bytesWritten);
  10064. if (IsFiniteNonNegativeNumber(bytesWritten) === false) {
  10065. throw new RangeError('bytesWritten must be a finite');
  10066. }
  10067. assert(controller._pendingPullIntos.length > 0);
  10068. ReadableByteStreamControllerRespondInternal(controller, bytesWritten);
  10069. }
  10070. function ReadableByteStreamControllerRespondWithNewView(controller, view) {
  10071. assert(controller._pendingPullIntos.length > 0);
  10072. var firstDescriptor = controller._pendingPullIntos[0];
  10073. if (firstDescriptor.byteOffset + firstDescriptor.bytesFilled !== view.byteOffset) {
  10074. throw new RangeError('The region specified by view does not match byobRequest');
  10075. }
  10076. if (firstDescriptor.byteLength !== view.byteLength) {
  10077. throw new RangeError('The buffer of view has different capacity than byobRequest');
  10078. }
  10079. firstDescriptor.buffer = view.buffer;
  10080. ReadableByteStreamControllerRespondInternal(controller, view.byteLength);
  10081. }
  10082. function streamBrandCheckException(name) {
  10083. return new TypeError('ReadableStream.prototype.' + name + ' can only be used on a ReadableStream');
  10084. }
  10085. function readerLockException(name) {
  10086. return new TypeError('Cannot ' + name + ' a stream using a released reader');
  10087. }
  10088. function defaultReaderBrandCheckException(name) {
  10089. return new TypeError('ReadableStreamDefaultReader.prototype.' + name + ' can only be used on a ReadableStreamDefaultReader');
  10090. }
  10091. function defaultReaderClosedPromiseInitialize(reader) {
  10092. reader._closedPromise = new Promise(function (resolve, reject) {
  10093. reader._closedPromise_resolve = resolve;
  10094. reader._closedPromise_reject = reject;
  10095. });
  10096. }
  10097. function defaultReaderClosedPromiseInitializeAsRejected(reader, reason) {
  10098. reader._closedPromise = Promise.reject(reason);
  10099. reader._closedPromise_resolve = undefined;
  10100. reader._closedPromise_reject = undefined;
  10101. }
  10102. function defaultReaderClosedPromiseInitializeAsResolved(reader) {
  10103. reader._closedPromise = Promise.resolve(undefined);
  10104. reader._closedPromise_resolve = undefined;
  10105. reader._closedPromise_reject = undefined;
  10106. }
  10107. function defaultReaderClosedPromiseReject(reader, reason) {
  10108. assert(reader._closedPromise_resolve !== undefined);
  10109. assert(reader._closedPromise_reject !== undefined);
  10110. reader._closedPromise_reject(reason);
  10111. reader._closedPromise_resolve = undefined;
  10112. reader._closedPromise_reject = undefined;
  10113. }
  10114. function defaultReaderClosedPromiseResetToRejected(reader, reason) {
  10115. assert(reader._closedPromise_resolve === undefined);
  10116. assert(reader._closedPromise_reject === undefined);
  10117. reader._closedPromise = Promise.reject(reason);
  10118. }
  10119. function defaultReaderClosedPromiseResolve(reader) {
  10120. assert(reader._closedPromise_resolve !== undefined);
  10121. assert(reader._closedPromise_reject !== undefined);
  10122. reader._closedPromise_resolve(undefined);
  10123. reader._closedPromise_resolve = undefined;
  10124. reader._closedPromise_reject = undefined;
  10125. }
  10126. function byobReaderBrandCheckException(name) {
  10127. return new TypeError('ReadableStreamBYOBReader.prototype.' + name + ' can only be used on a ReadableStreamBYOBReader');
  10128. }
  10129. function defaultControllerBrandCheckException(name) {
  10130. return new TypeError('ReadableStreamDefaultController.prototype.' + name + ' can only be used on a ReadableStreamDefaultController');
  10131. }
  10132. function byobRequestBrandCheckException(name) {
  10133. return new TypeError('ReadableStreamBYOBRequest.prototype.' + name + ' can only be used on a ReadableStreamBYOBRequest');
  10134. }
  10135. function byteStreamControllerBrandCheckException(name) {
  10136. return new TypeError('ReadableByteStreamController.prototype.' + name + ' can only be used on a ReadableByteStreamController');
  10137. }
  10138. function ifIsObjectAndHasAPromiseIsHandledInternalSlotSetPromiseIsHandledToTrue(promise) {
  10139. try {
  10140. Promise.prototype.then.call(promise, undefined, function () {});
  10141. } catch (e) {}
  10142. }
  10143. }, function (module, exports, __w_pdfjs_require__) {
  10144. "use strict";
  10145. var transformStream = __w_pdfjs_require__(6);
  10146. var readableStream = __w_pdfjs_require__(4);
  10147. var writableStream = __w_pdfjs_require__(2);
  10148. exports.TransformStream = transformStream.TransformStream;
  10149. exports.ReadableStream = readableStream.ReadableStream;
  10150. exports.IsReadableStreamDisturbed = readableStream.IsReadableStreamDisturbed;
  10151. exports.ReadableStreamDefaultControllerClose = readableStream.ReadableStreamDefaultControllerClose;
  10152. exports.ReadableStreamDefaultControllerEnqueue = readableStream.ReadableStreamDefaultControllerEnqueue;
  10153. exports.ReadableStreamDefaultControllerError = readableStream.ReadableStreamDefaultControllerError;
  10154. exports.ReadableStreamDefaultControllerGetDesiredSize = readableStream.ReadableStreamDefaultControllerGetDesiredSize;
  10155. exports.AcquireWritableStreamDefaultWriter = writableStream.AcquireWritableStreamDefaultWriter;
  10156. exports.IsWritableStream = writableStream.IsWritableStream;
  10157. exports.IsWritableStreamLocked = writableStream.IsWritableStreamLocked;
  10158. exports.WritableStream = writableStream.WritableStream;
  10159. exports.WritableStreamAbort = writableStream.WritableStreamAbort;
  10160. exports.WritableStreamDefaultControllerError = writableStream.WritableStreamDefaultControllerError;
  10161. exports.WritableStreamDefaultWriterCloseWithErrorPropagation = writableStream.WritableStreamDefaultWriterCloseWithErrorPropagation;
  10162. exports.WritableStreamDefaultWriterRelease = writableStream.WritableStreamDefaultWriterRelease;
  10163. exports.WritableStreamDefaultWriterWrite = writableStream.WritableStreamDefaultWriterWrite;
  10164. }, function (module, exports, __w_pdfjs_require__) {
  10165. "use strict";
  10166. var _createClass = function () {
  10167. function defineProperties(target, props) {
  10168. for (var i = 0; i < props.length; i++) {
  10169. var descriptor = props[i];
  10170. descriptor.enumerable = descriptor.enumerable || false;
  10171. descriptor.configurable = true;
  10172. if ("value" in descriptor) descriptor.writable = true;
  10173. Object.defineProperty(target, descriptor.key, descriptor);
  10174. }
  10175. }
  10176. return function (Constructor, protoProps, staticProps) {
  10177. if (protoProps) defineProperties(Constructor.prototype, protoProps);
  10178. if (staticProps) defineProperties(Constructor, staticProps);
  10179. return Constructor;
  10180. };
  10181. }();
  10182. function _classCallCheck(instance, Constructor) {
  10183. if (!(instance instanceof Constructor)) {
  10184. throw new TypeError("Cannot call a class as a function");
  10185. }
  10186. }
  10187. var _require = __w_pdfjs_require__(1),
  10188. assert = _require.assert;
  10189. var _require2 = __w_pdfjs_require__(0),
  10190. InvokeOrNoop = _require2.InvokeOrNoop,
  10191. PromiseInvokeOrPerformFallback = _require2.PromiseInvokeOrPerformFallback,
  10192. PromiseInvokeOrNoop = _require2.PromiseInvokeOrNoop,
  10193. typeIsObject = _require2.typeIsObject;
  10194. var _require3 = __w_pdfjs_require__(4),
  10195. ReadableStream = _require3.ReadableStream,
  10196. ReadableStreamDefaultControllerClose = _require3.ReadableStreamDefaultControllerClose,
  10197. ReadableStreamDefaultControllerEnqueue = _require3.ReadableStreamDefaultControllerEnqueue,
  10198. ReadableStreamDefaultControllerError = _require3.ReadableStreamDefaultControllerError,
  10199. ReadableStreamDefaultControllerGetDesiredSize = _require3.ReadableStreamDefaultControllerGetDesiredSize;
  10200. var _require4 = __w_pdfjs_require__(2),
  10201. WritableStream = _require4.WritableStream,
  10202. WritableStreamDefaultControllerError = _require4.WritableStreamDefaultControllerError;
  10203. function TransformStreamCloseReadable(transformStream) {
  10204. if (transformStream._errored === true) {
  10205. throw new TypeError('TransformStream is already errored');
  10206. }
  10207. if (transformStream._readableClosed === true) {
  10208. throw new TypeError('Readable side is already closed');
  10209. }
  10210. TransformStreamCloseReadableInternal(transformStream);
  10211. }
  10212. function TransformStreamEnqueueToReadable(transformStream, chunk) {
  10213. if (transformStream._errored === true) {
  10214. throw new TypeError('TransformStream is already errored');
  10215. }
  10216. if (transformStream._readableClosed === true) {
  10217. throw new TypeError('Readable side is already closed');
  10218. }
  10219. var controller = transformStream._readableController;
  10220. try {
  10221. ReadableStreamDefaultControllerEnqueue(controller, chunk);
  10222. } catch (e) {
  10223. transformStream._readableClosed = true;
  10224. TransformStreamErrorIfNeeded(transformStream, e);
  10225. throw transformStream._storedError;
  10226. }
  10227. var desiredSize = ReadableStreamDefaultControllerGetDesiredSize(controller);
  10228. var maybeBackpressure = desiredSize <= 0;
  10229. if (maybeBackpressure === true && transformStream._backpressure === false) {
  10230. TransformStreamSetBackpressure(transformStream, true);
  10231. }
  10232. }
  10233. function TransformStreamError(transformStream, e) {
  10234. if (transformStream._errored === true) {
  10235. throw new TypeError('TransformStream is already errored');
  10236. }
  10237. TransformStreamErrorInternal(transformStream, e);
  10238. }
  10239. function TransformStreamCloseReadableInternal(transformStream) {
  10240. assert(transformStream._errored === false);
  10241. assert(transformStream._readableClosed === false);
  10242. try {
  10243. ReadableStreamDefaultControllerClose(transformStream._readableController);
  10244. } catch (e) {
  10245. assert(false);
  10246. }
  10247. transformStream._readableClosed = true;
  10248. }
  10249. function TransformStreamErrorIfNeeded(transformStream, e) {
  10250. if (transformStream._errored === false) {
  10251. TransformStreamErrorInternal(transformStream, e);
  10252. }
  10253. }
  10254. function TransformStreamErrorInternal(transformStream, e) {
  10255. assert(transformStream._errored === false);
  10256. transformStream._errored = true;
  10257. transformStream._storedError = e;
  10258. if (transformStream._writableDone === false) {
  10259. WritableStreamDefaultControllerError(transformStream._writableController, e);
  10260. }
  10261. if (transformStream._readableClosed === false) {
  10262. ReadableStreamDefaultControllerError(transformStream._readableController, e);
  10263. }
  10264. }
  10265. function TransformStreamReadableReadyPromise(transformStream) {
  10266. assert(transformStream._backpressureChangePromise !== undefined, '_backpressureChangePromise should have been initialized');
  10267. if (transformStream._backpressure === false) {
  10268. return Promise.resolve();
  10269. }
  10270. assert(transformStream._backpressure === true, '_backpressure should have been initialized');
  10271. return transformStream._backpressureChangePromise;
  10272. }
  10273. function TransformStreamSetBackpressure(transformStream, backpressure) {
  10274. assert(transformStream._backpressure !== backpressure, 'TransformStreamSetBackpressure() should be called only when backpressure is changed');
  10275. if (transformStream._backpressureChangePromise !== undefined) {
  10276. transformStream._backpressureChangePromise_resolve(backpressure);
  10277. }
  10278. transformStream._backpressureChangePromise = new Promise(function (resolve) {
  10279. transformStream._backpressureChangePromise_resolve = resolve;
  10280. });
  10281. transformStream._backpressureChangePromise.then(function (resolution) {
  10282. assert(resolution !== backpressure, '_backpressureChangePromise should be fulfilled only when backpressure is changed');
  10283. });
  10284. transformStream._backpressure = backpressure;
  10285. }
  10286. function TransformStreamDefaultTransform(chunk, transformStreamController) {
  10287. var transformStream = transformStreamController._controlledTransformStream;
  10288. TransformStreamEnqueueToReadable(transformStream, chunk);
  10289. return Promise.resolve();
  10290. }
  10291. function TransformStreamTransform(transformStream, chunk) {
  10292. assert(transformStream._errored === false);
  10293. assert(transformStream._transforming === false);
  10294. assert(transformStream._backpressure === false);
  10295. transformStream._transforming = true;
  10296. var transformer = transformStream._transformer;
  10297. var controller = transformStream._transformStreamController;
  10298. var transformPromise = PromiseInvokeOrPerformFallback(transformer, 'transform', [chunk, controller], TransformStreamDefaultTransform, [chunk, controller]);
  10299. return transformPromise.then(function () {
  10300. transformStream._transforming = false;
  10301. return TransformStreamReadableReadyPromise(transformStream);
  10302. }, function (e) {
  10303. TransformStreamErrorIfNeeded(transformStream, e);
  10304. return Promise.reject(e);
  10305. });
  10306. }
  10307. function IsTransformStreamDefaultController(x) {
  10308. if (!typeIsObject(x)) {
  10309. return false;
  10310. }
  10311. if (!Object.prototype.hasOwnProperty.call(x, '_controlledTransformStream')) {
  10312. return false;
  10313. }
  10314. return true;
  10315. }
  10316. function IsTransformStream(x) {
  10317. if (!typeIsObject(x)) {
  10318. return false;
  10319. }
  10320. if (!Object.prototype.hasOwnProperty.call(x, '_transformStreamController')) {
  10321. return false;
  10322. }
  10323. return true;
  10324. }
  10325. var TransformStreamSink = function () {
  10326. function TransformStreamSink(transformStream, startPromise) {
  10327. _classCallCheck(this, TransformStreamSink);
  10328. this._transformStream = transformStream;
  10329. this._startPromise = startPromise;
  10330. }
  10331. _createClass(TransformStreamSink, [{
  10332. key: 'start',
  10333. value: function start(c) {
  10334. var transformStream = this._transformStream;
  10335. transformStream._writableController = c;
  10336. return this._startPromise.then(function () {
  10337. return TransformStreamReadableReadyPromise(transformStream);
  10338. });
  10339. }
  10340. }, {
  10341. key: 'write',
  10342. value: function write(chunk) {
  10343. var transformStream = this._transformStream;
  10344. return TransformStreamTransform(transformStream, chunk);
  10345. }
  10346. }, {
  10347. key: 'abort',
  10348. value: function abort() {
  10349. var transformStream = this._transformStream;
  10350. transformStream._writableDone = true;
  10351. TransformStreamErrorInternal(transformStream, new TypeError('Writable side aborted'));
  10352. }
  10353. }, {
  10354. key: 'close',
  10355. value: function close() {
  10356. var transformStream = this._transformStream;
  10357. assert(transformStream._transforming === false);
  10358. transformStream._writableDone = true;
  10359. var flushPromise = PromiseInvokeOrNoop(transformStream._transformer, 'flush', [transformStream._transformStreamController]);
  10360. return flushPromise.then(function () {
  10361. if (transformStream._errored === true) {
  10362. return Promise.reject(transformStream._storedError);
  10363. }
  10364. if (transformStream._readableClosed === false) {
  10365. TransformStreamCloseReadableInternal(transformStream);
  10366. }
  10367. return Promise.resolve();
  10368. }).catch(function (r) {
  10369. TransformStreamErrorIfNeeded(transformStream, r);
  10370. return Promise.reject(transformStream._storedError);
  10371. });
  10372. }
  10373. }]);
  10374. return TransformStreamSink;
  10375. }();
  10376. var TransformStreamSource = function () {
  10377. function TransformStreamSource(transformStream, startPromise) {
  10378. _classCallCheck(this, TransformStreamSource);
  10379. this._transformStream = transformStream;
  10380. this._startPromise = startPromise;
  10381. }
  10382. _createClass(TransformStreamSource, [{
  10383. key: 'start',
  10384. value: function start(c) {
  10385. var transformStream = this._transformStream;
  10386. transformStream._readableController = c;
  10387. return this._startPromise.then(function () {
  10388. assert(transformStream._backpressureChangePromise !== undefined, '_backpressureChangePromise should have been initialized');
  10389. if (transformStream._backpressure === true) {
  10390. return Promise.resolve();
  10391. }
  10392. assert(transformStream._backpressure === false, '_backpressure should have been initialized');
  10393. return transformStream._backpressureChangePromise;
  10394. });
  10395. }
  10396. }, {
  10397. key: 'pull',
  10398. value: function pull() {
  10399. var transformStream = this._transformStream;
  10400. assert(transformStream._backpressure === true, 'pull() should be never called while _backpressure is false');
  10401. assert(transformStream._backpressureChangePromise !== undefined, '_backpressureChangePromise should have been initialized');
  10402. TransformStreamSetBackpressure(transformStream, false);
  10403. return transformStream._backpressureChangePromise;
  10404. }
  10405. }, {
  10406. key: 'cancel',
  10407. value: function cancel() {
  10408. var transformStream = this._transformStream;
  10409. transformStream._readableClosed = true;
  10410. TransformStreamErrorInternal(transformStream, new TypeError('Readable side canceled'));
  10411. }
  10412. }]);
  10413. return TransformStreamSource;
  10414. }();
  10415. var TransformStreamDefaultController = function () {
  10416. function TransformStreamDefaultController(transformStream) {
  10417. _classCallCheck(this, TransformStreamDefaultController);
  10418. if (IsTransformStream(transformStream) === false) {
  10419. throw new TypeError('TransformStreamDefaultController can only be ' + 'constructed with a TransformStream instance');
  10420. }
  10421. if (transformStream._transformStreamController !== undefined) {
  10422. throw new TypeError('TransformStreamDefaultController instances can ' + 'only be created by the TransformStream constructor');
  10423. }
  10424. this._controlledTransformStream = transformStream;
  10425. }
  10426. _createClass(TransformStreamDefaultController, [{
  10427. key: 'enqueue',
  10428. value: function enqueue(chunk) {
  10429. if (IsTransformStreamDefaultController(this) === false) {
  10430. throw defaultControllerBrandCheckException('enqueue');
  10431. }
  10432. TransformStreamEnqueueToReadable(this._controlledTransformStream, chunk);
  10433. }
  10434. }, {
  10435. key: 'close',
  10436. value: function close() {
  10437. if (IsTransformStreamDefaultController(this) === false) {
  10438. throw defaultControllerBrandCheckException('close');
  10439. }
  10440. TransformStreamCloseReadable(this._controlledTransformStream);
  10441. }
  10442. }, {
  10443. key: 'error',
  10444. value: function error(reason) {
  10445. if (IsTransformStreamDefaultController(this) === false) {
  10446. throw defaultControllerBrandCheckException('error');
  10447. }
  10448. TransformStreamError(this._controlledTransformStream, reason);
  10449. }
  10450. }, {
  10451. key: 'desiredSize',
  10452. get: function get() {
  10453. if (IsTransformStreamDefaultController(this) === false) {
  10454. throw defaultControllerBrandCheckException('desiredSize');
  10455. }
  10456. var transformStream = this._controlledTransformStream;
  10457. var readableController = transformStream._readableController;
  10458. return ReadableStreamDefaultControllerGetDesiredSize(readableController);
  10459. }
  10460. }]);
  10461. return TransformStreamDefaultController;
  10462. }();
  10463. var TransformStream = function () {
  10464. function TransformStream() {
  10465. var transformer = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  10466. _classCallCheck(this, TransformStream);
  10467. this._transformer = transformer;
  10468. var readableStrategy = transformer.readableStrategy,
  10469. writableStrategy = transformer.writableStrategy;
  10470. this._transforming = false;
  10471. this._errored = false;
  10472. this._storedError = undefined;
  10473. this._writableController = undefined;
  10474. this._readableController = undefined;
  10475. this._transformStreamController = undefined;
  10476. this._writableDone = false;
  10477. this._readableClosed = false;
  10478. this._backpressure = undefined;
  10479. this._backpressureChangePromise = undefined;
  10480. this._backpressureChangePromise_resolve = undefined;
  10481. this._transformStreamController = new TransformStreamDefaultController(this);
  10482. var startPromise_resolve = void 0;
  10483. var startPromise = new Promise(function (resolve) {
  10484. startPromise_resolve = resolve;
  10485. });
  10486. var source = new TransformStreamSource(this, startPromise);
  10487. this._readable = new ReadableStream(source, readableStrategy);
  10488. var sink = new TransformStreamSink(this, startPromise);
  10489. this._writable = new WritableStream(sink, writableStrategy);
  10490. assert(this._writableController !== undefined);
  10491. assert(this._readableController !== undefined);
  10492. var desiredSize = ReadableStreamDefaultControllerGetDesiredSize(this._readableController);
  10493. TransformStreamSetBackpressure(this, desiredSize <= 0);
  10494. var transformStream = this;
  10495. var startResult = InvokeOrNoop(transformer, 'start', [transformStream._transformStreamController]);
  10496. startPromise_resolve(startResult);
  10497. startPromise.catch(function (e) {
  10498. if (transformStream._errored === false) {
  10499. transformStream._errored = true;
  10500. transformStream._storedError = e;
  10501. }
  10502. });
  10503. }
  10504. _createClass(TransformStream, [{
  10505. key: 'readable',
  10506. get: function get() {
  10507. if (IsTransformStream(this) === false) {
  10508. throw streamBrandCheckException('readable');
  10509. }
  10510. return this._readable;
  10511. }
  10512. }, {
  10513. key: 'writable',
  10514. get: function get() {
  10515. if (IsTransformStream(this) === false) {
  10516. throw streamBrandCheckException('writable');
  10517. }
  10518. return this._writable;
  10519. }
  10520. }]);
  10521. return TransformStream;
  10522. }();
  10523. module.exports = { TransformStream: TransformStream };
  10524. function defaultControllerBrandCheckException(name) {
  10525. return new TypeError('TransformStreamDefaultController.prototype.' + name + ' can only be used on a TransformStreamDefaultController');
  10526. }
  10527. function streamBrandCheckException(name) {
  10528. return new TypeError('TransformStream.prototype.' + name + ' can only be used on a TransformStream');
  10529. }
  10530. }, function (module, exports, __w_pdfjs_require__) {
  10531. module.exports = __w_pdfjs_require__(5);
  10532. }]));
  10533. /***/ }),
  10534. /* 58 */
  10535. /***/ (function(module, exports, __w_pdfjs_require__) {
  10536. "use strict";
  10537. __w_pdfjs_require__(81);
  10538. module.exports = __w_pdfjs_require__(16).Uint8ClampedArray;
  10539. /***/ }),
  10540. /* 59 */
  10541. /***/ (function(module, exports, __w_pdfjs_require__) {
  10542. "use strict";
  10543. var UNSCOPABLES = __w_pdfjs_require__(1)('unscopables');
  10544. var ArrayProto = Array.prototype;
  10545. if (ArrayProto[UNSCOPABLES] == undefined) __w_pdfjs_require__(4)(ArrayProto, UNSCOPABLES, {});
  10546. module.exports = function (key) {
  10547. ArrayProto[UNSCOPABLES][key] = true;
  10548. };
  10549. /***/ }),
  10550. /* 60 */
  10551. /***/ (function(module, exports, __w_pdfjs_require__) {
  10552. "use strict";
  10553. var toObject = __w_pdfjs_require__(12);
  10554. var toAbsoluteIndex = __w_pdfjs_require__(19);
  10555. var toLength = __w_pdfjs_require__(6);
  10556. module.exports = [].copyWithin || function copyWithin(target, start) {
  10557. var O = toObject(this);
  10558. var len = toLength(O.length);
  10559. var to = toAbsoluteIndex(target, len);
  10560. var from = toAbsoluteIndex(start, len);
  10561. var end = arguments.length > 2 ? arguments[2] : undefined;
  10562. var count = Math.min((end === undefined ? len : toAbsoluteIndex(end, len)) - from, len - to);
  10563. var inc = 1;
  10564. if (from < to && to < from + count) {
  10565. inc = -1;
  10566. from += count - 1;
  10567. to += count - 1;
  10568. }
  10569. while (count-- > 0) {
  10570. if (from in O) O[to] = O[from];else delete O[to];
  10571. to += inc;
  10572. from += inc;
  10573. }
  10574. return O;
  10575. };
  10576. /***/ }),
  10577. /* 61 */
  10578. /***/ (function(module, exports, __w_pdfjs_require__) {
  10579. "use strict";
  10580. var ctx = __w_pdfjs_require__(22);
  10581. var IObject = __w_pdfjs_require__(42);
  10582. var toObject = __w_pdfjs_require__(12);
  10583. var toLength = __w_pdfjs_require__(6);
  10584. var asc = __w_pdfjs_require__(63);
  10585. module.exports = function (TYPE, $create) {
  10586. var IS_MAP = TYPE == 1;
  10587. var IS_FILTER = TYPE == 2;
  10588. var IS_SOME = TYPE == 3;
  10589. var IS_EVERY = TYPE == 4;
  10590. var IS_FIND_INDEX = TYPE == 6;
  10591. var NO_HOLES = TYPE == 5 || IS_FIND_INDEX;
  10592. var create = $create || asc;
  10593. return function ($this, callbackfn, that) {
  10594. var O = toObject($this);
  10595. var self = IObject(O);
  10596. var f = ctx(callbackfn, that, 3);
  10597. var length = toLength(self.length);
  10598. var index = 0;
  10599. var result = IS_MAP ? create($this, length) : IS_FILTER ? create($this, 0) : undefined;
  10600. var val, res;
  10601. for (; length > index; index++) {
  10602. if (NO_HOLES || index in self) {
  10603. val = self[index];
  10604. res = f(val, index, O);
  10605. if (TYPE) {
  10606. if (IS_MAP) result[index] = res;else if (res) switch (TYPE) {
  10607. case 3:
  10608. return true;
  10609. case 5:
  10610. return val;
  10611. case 6:
  10612. return index;
  10613. case 2:
  10614. result.push(val);
  10615. } else if (IS_EVERY) return false;
  10616. }
  10617. }
  10618. }return IS_FIND_INDEX ? -1 : IS_SOME || IS_EVERY ? IS_EVERY : result;
  10619. };
  10620. };
  10621. /***/ }),
  10622. /* 62 */
  10623. /***/ (function(module, exports, __w_pdfjs_require__) {
  10624. "use strict";
  10625. var isObject = __w_pdfjs_require__(9);
  10626. var isArray = __w_pdfjs_require__(66);
  10627. var SPECIES = __w_pdfjs_require__(1)('species');
  10628. module.exports = function (original) {
  10629. var C;
  10630. if (isArray(original)) {
  10631. C = original.constructor;
  10632. if (typeof C == 'function' && (C === Array || isArray(C.prototype))) C = undefined;
  10633. if (isObject(C)) {
  10634. C = C[SPECIES];
  10635. if (C === null) C = undefined;
  10636. }
  10637. }
  10638. return C === undefined ? Array : C;
  10639. };
  10640. /***/ }),
  10641. /* 63 */
  10642. /***/ (function(module, exports, __w_pdfjs_require__) {
  10643. "use strict";
  10644. var speciesConstructor = __w_pdfjs_require__(62);
  10645. module.exports = function (original, length) {
  10646. return new (speciesConstructor(original))(length);
  10647. };
  10648. /***/ }),
  10649. /* 64 */
  10650. /***/ (function(module, exports, __w_pdfjs_require__) {
  10651. "use strict";
  10652. var document = __w_pdfjs_require__(2).document;
  10653. module.exports = document && document.documentElement;
  10654. /***/ }),
  10655. /* 65 */
  10656. /***/ (function(module, exports, __w_pdfjs_require__) {
  10657. "use strict";
  10658. var Iterators = __w_pdfjs_require__(10);
  10659. var ITERATOR = __w_pdfjs_require__(1)('iterator');
  10660. var ArrayProto = Array.prototype;
  10661. module.exports = function (it) {
  10662. return it !== undefined && (Iterators.Array === it || ArrayProto[ITERATOR] === it);
  10663. };
  10664. /***/ }),
  10665. /* 66 */
  10666. /***/ (function(module, exports, __w_pdfjs_require__) {
  10667. "use strict";
  10668. var cof = __w_pdfjs_require__(21);
  10669. module.exports = Array.isArray || function isArray(arg) {
  10670. return cof(arg) == 'Array';
  10671. };
  10672. /***/ }),
  10673. /* 67 */
  10674. /***/ (function(module, exports, __w_pdfjs_require__) {
  10675. "use strict";
  10676. var create = __w_pdfjs_require__(43);
  10677. var descriptor = __w_pdfjs_require__(18);
  10678. var setToStringTag = __w_pdfjs_require__(26);
  10679. var IteratorPrototype = {};
  10680. __w_pdfjs_require__(4)(IteratorPrototype, __w_pdfjs_require__(1)('iterator'), function () {
  10681. return this;
  10682. });
  10683. module.exports = function (Constructor, NAME, next) {
  10684. Constructor.prototype = create(IteratorPrototype, { next: descriptor(1, next) });
  10685. setToStringTag(Constructor, NAME + ' Iterator');
  10686. };
  10687. /***/ }),
  10688. /* 68 */
  10689. /***/ (function(module, exports, __w_pdfjs_require__) {
  10690. "use strict";
  10691. var LIBRARY = __w_pdfjs_require__(24);
  10692. var $export = __w_pdfjs_require__(40);
  10693. var redefine = __w_pdfjs_require__(25);
  10694. var hide = __w_pdfjs_require__(4);
  10695. var has = __w_pdfjs_require__(5);
  10696. var Iterators = __w_pdfjs_require__(10);
  10697. var $iterCreate = __w_pdfjs_require__(67);
  10698. var setToStringTag = __w_pdfjs_require__(26);
  10699. var getPrototypeOf = __w_pdfjs_require__(45);
  10700. var ITERATOR = __w_pdfjs_require__(1)('iterator');
  10701. var BUGGY = !([].keys && 'next' in [].keys());
  10702. var FF_ITERATOR = '@@iterator';
  10703. var KEYS = 'keys';
  10704. var VALUES = 'values';
  10705. var returnThis = function returnThis() {
  10706. return this;
  10707. };
  10708. module.exports = function (Base, NAME, Constructor, next, DEFAULT, IS_SET, FORCED) {
  10709. $iterCreate(Constructor, NAME, next);
  10710. var getMethod = function getMethod(kind) {
  10711. if (!BUGGY && kind in proto) return proto[kind];
  10712. switch (kind) {
  10713. case KEYS:
  10714. return function keys() {
  10715. return new Constructor(this, kind);
  10716. };
  10717. case VALUES:
  10718. return function values() {
  10719. return new Constructor(this, kind);
  10720. };
  10721. }
  10722. return function entries() {
  10723. return new Constructor(this, kind);
  10724. };
  10725. };
  10726. var TAG = NAME + ' Iterator';
  10727. var DEF_VALUES = DEFAULT == VALUES;
  10728. var VALUES_BUG = false;
  10729. var proto = Base.prototype;
  10730. var $native = proto[ITERATOR] || proto[FF_ITERATOR] || DEFAULT && proto[DEFAULT];
  10731. var $default = $native || getMethod(DEFAULT);
  10732. var $entries = DEFAULT ? !DEF_VALUES ? $default : getMethod('entries') : undefined;
  10733. var $anyNative = NAME == 'Array' ? proto.entries || $native : $native;
  10734. var methods, key, IteratorPrototype;
  10735. if ($anyNative) {
  10736. IteratorPrototype = getPrototypeOf($anyNative.call(new Base()));
  10737. if (IteratorPrototype !== Object.prototype && IteratorPrototype.next) {
  10738. setToStringTag(IteratorPrototype, TAG, true);
  10739. if (!LIBRARY && !has(IteratorPrototype, ITERATOR)) hide(IteratorPrototype, ITERATOR, returnThis);
  10740. }
  10741. }
  10742. if (DEF_VALUES && $native && $native.name !== VALUES) {
  10743. VALUES_BUG = true;
  10744. $default = function values() {
  10745. return $native.call(this);
  10746. };
  10747. }
  10748. if ((!LIBRARY || FORCED) && (BUGGY || VALUES_BUG || !proto[ITERATOR])) {
  10749. hide(proto, ITERATOR, $default);
  10750. }
  10751. Iterators[NAME] = $default;
  10752. Iterators[TAG] = returnThis;
  10753. if (DEFAULT) {
  10754. methods = {
  10755. values: DEF_VALUES ? $default : getMethod(VALUES),
  10756. keys: IS_SET ? $default : getMethod(KEYS),
  10757. entries: $entries
  10758. };
  10759. if (FORCED) for (key in methods) {
  10760. if (!(key in proto)) redefine(proto, key, methods[key]);
  10761. } else $export($export.P + $export.F * (BUGGY || VALUES_BUG), NAME, methods);
  10762. }
  10763. return methods;
  10764. };
  10765. /***/ }),
  10766. /* 69 */
  10767. /***/ (function(module, exports, __w_pdfjs_require__) {
  10768. "use strict";
  10769. var ITERATOR = __w_pdfjs_require__(1)('iterator');
  10770. var SAFE_CLOSING = false;
  10771. try {
  10772. var riter = [7][ITERATOR]();
  10773. riter['return'] = function () {
  10774. SAFE_CLOSING = true;
  10775. };
  10776. Array.from(riter, function () {
  10777. throw 2;
  10778. });
  10779. } catch (e) {}
  10780. module.exports = function (exec, skipClosing) {
  10781. if (!skipClosing && !SAFE_CLOSING) return false;
  10782. var safe = false;
  10783. try {
  10784. var arr = [7];
  10785. var iter = arr[ITERATOR]();
  10786. iter.next = function () {
  10787. return { done: safe = true };
  10788. };
  10789. arr[ITERATOR] = function () {
  10790. return iter;
  10791. };
  10792. exec(arr);
  10793. } catch (e) {}
  10794. return safe;
  10795. };
  10796. /***/ }),
  10797. /* 70 */
  10798. /***/ (function(module, exports, __w_pdfjs_require__) {
  10799. "use strict";
  10800. module.exports = function (done, value) {
  10801. return {
  10802. value: value,
  10803. done: !!done
  10804. };
  10805. };
  10806. /***/ }),
  10807. /* 71 */
  10808. /***/ (function(module, exports, __w_pdfjs_require__) {
  10809. "use strict";
  10810. var dP = __w_pdfjs_require__(8);
  10811. var anObject = __w_pdfjs_require__(15);
  10812. var getKeys = __w_pdfjs_require__(73);
  10813. module.exports = __w_pdfjs_require__(3) ? Object.defineProperties : function defineProperties(O, Properties) {
  10814. anObject(O);
  10815. var keys = getKeys(Properties);
  10816. var length = keys.length;
  10817. var i = 0;
  10818. var P;
  10819. while (length > i) {
  10820. dP.f(O, P = keys[i++], Properties[P]);
  10821. }return O;
  10822. };
  10823. /***/ }),
  10824. /* 72 */
  10825. /***/ (function(module, exports, __w_pdfjs_require__) {
  10826. "use strict";
  10827. var pIE = __w_pdfjs_require__(74);
  10828. var createDesc = __w_pdfjs_require__(18);
  10829. var toIObject = __w_pdfjs_require__(20);
  10830. var toPrimitive = __w_pdfjs_require__(28);
  10831. var has = __w_pdfjs_require__(5);
  10832. var IE8_DOM_DEFINE = __w_pdfjs_require__(41);
  10833. var gOPD = Object.getOwnPropertyDescriptor;
  10834. exports.f = __w_pdfjs_require__(3) ? gOPD : function getOwnPropertyDescriptor(O, P) {
  10835. O = toIObject(O);
  10836. P = toPrimitive(P, true);
  10837. if (IE8_DOM_DEFINE) try {
  10838. return gOPD(O, P);
  10839. } catch (e) {}
  10840. if (has(O, P)) return createDesc(!pIE.f.call(O, P), O[P]);
  10841. };
  10842. /***/ }),
  10843. /* 73 */
  10844. /***/ (function(module, exports, __w_pdfjs_require__) {
  10845. "use strict";
  10846. var $keys = __w_pdfjs_require__(46);
  10847. var enumBugKeys = __w_pdfjs_require__(23);
  10848. module.exports = Object.keys || function keys(O) {
  10849. return $keys(O, enumBugKeys);
  10850. };
  10851. /***/ }),
  10852. /* 74 */
  10853. /***/ (function(module, exports, __w_pdfjs_require__) {
  10854. "use strict";
  10855. exports.f = {}.propertyIsEnumerable;
  10856. /***/ }),
  10857. /* 75 */
  10858. /***/ (function(module, exports, __w_pdfjs_require__) {
  10859. "use strict";
  10860. var global = __w_pdfjs_require__(2);
  10861. var dP = __w_pdfjs_require__(8);
  10862. var DESCRIPTORS = __w_pdfjs_require__(3);
  10863. var SPECIES = __w_pdfjs_require__(1)('species');
  10864. module.exports = function (KEY) {
  10865. var C = global[KEY];
  10866. if (DESCRIPTORS && C && !C[SPECIES]) dP.f(C, SPECIES, {
  10867. configurable: true,
  10868. get: function get() {
  10869. return this;
  10870. }
  10871. });
  10872. };
  10873. /***/ }),
  10874. /* 76 */
  10875. /***/ (function(module, exports, __w_pdfjs_require__) {
  10876. "use strict";
  10877. var anObject = __w_pdfjs_require__(15);
  10878. var aFunction = __w_pdfjs_require__(33);
  10879. var SPECIES = __w_pdfjs_require__(1)('species');
  10880. module.exports = function (O, D) {
  10881. var C = anObject(O).constructor;
  10882. var S;
  10883. return C === undefined || (S = anObject(C)[SPECIES]) == undefined ? D : aFunction(S);
  10884. };
  10885. /***/ }),
  10886. /* 77 */
  10887. /***/ (function(module, exports, __w_pdfjs_require__) {
  10888. "use strict";
  10889. 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; };
  10890. if (__w_pdfjs_require__(3)) {
  10891. var LIBRARY = __w_pdfjs_require__(24);
  10892. var global = __w_pdfjs_require__(2);
  10893. var fails = __w_pdfjs_require__(17);
  10894. var $export = __w_pdfjs_require__(40);
  10895. var $typed = __w_pdfjs_require__(50);
  10896. var $buffer = __w_pdfjs_require__(78);
  10897. var ctx = __w_pdfjs_require__(22);
  10898. var anInstance = __w_pdfjs_require__(34);
  10899. var propertyDesc = __w_pdfjs_require__(18);
  10900. var hide = __w_pdfjs_require__(4);
  10901. var redefineAll = __w_pdfjs_require__(47);
  10902. var toInteger = __w_pdfjs_require__(11);
  10903. var toLength = __w_pdfjs_require__(6);
  10904. var toIndex = __w_pdfjs_require__(49);
  10905. var toAbsoluteIndex = __w_pdfjs_require__(19);
  10906. var toPrimitive = __w_pdfjs_require__(28);
  10907. var has = __w_pdfjs_require__(5);
  10908. var classof = __w_pdfjs_require__(37);
  10909. var isObject = __w_pdfjs_require__(9);
  10910. var toObject = __w_pdfjs_require__(12);
  10911. var isArrayIter = __w_pdfjs_require__(65);
  10912. var create = __w_pdfjs_require__(43);
  10913. var getPrototypeOf = __w_pdfjs_require__(45);
  10914. var gOPN = __w_pdfjs_require__(44).f;
  10915. var getIterFn = __w_pdfjs_require__(79);
  10916. var uid = __w_pdfjs_require__(13);
  10917. var wks = __w_pdfjs_require__(1);
  10918. var createArrayMethod = __w_pdfjs_require__(61);
  10919. var createArrayIncludes = __w_pdfjs_require__(36);
  10920. var speciesConstructor = __w_pdfjs_require__(76);
  10921. var ArrayIterators = __w_pdfjs_require__(80);
  10922. var Iterators = __w_pdfjs_require__(10);
  10923. var $iterDetect = __w_pdfjs_require__(69);
  10924. var setSpecies = __w_pdfjs_require__(75);
  10925. var arrayFill = __w_pdfjs_require__(35);
  10926. var arrayCopyWithin = __w_pdfjs_require__(60);
  10927. var $DP = __w_pdfjs_require__(8);
  10928. var $GOPD = __w_pdfjs_require__(72);
  10929. var dP = $DP.f;
  10930. var gOPD = $GOPD.f;
  10931. var RangeError = global.RangeError;
  10932. var TypeError = global.TypeError;
  10933. var Uint8Array = global.Uint8Array;
  10934. var ARRAY_BUFFER = 'ArrayBuffer';
  10935. var SHARED_BUFFER = 'Shared' + ARRAY_BUFFER;
  10936. var BYTES_PER_ELEMENT = 'BYTES_PER_ELEMENT';
  10937. var PROTOTYPE = 'prototype';
  10938. var ArrayProto = Array[PROTOTYPE];
  10939. var $ArrayBuffer = $buffer.ArrayBuffer;
  10940. var $DataView = $buffer.DataView;
  10941. var arrayForEach = createArrayMethod(0);
  10942. var arrayFilter = createArrayMethod(2);
  10943. var arraySome = createArrayMethod(3);
  10944. var arrayEvery = createArrayMethod(4);
  10945. var arrayFind = createArrayMethod(5);
  10946. var arrayFindIndex = createArrayMethod(6);
  10947. var arrayIncludes = createArrayIncludes(true);
  10948. var arrayIndexOf = createArrayIncludes(false);
  10949. var arrayValues = ArrayIterators.values;
  10950. var arrayKeys = ArrayIterators.keys;
  10951. var arrayEntries = ArrayIterators.entries;
  10952. var arrayLastIndexOf = ArrayProto.lastIndexOf;
  10953. var arrayReduce = ArrayProto.reduce;
  10954. var arrayReduceRight = ArrayProto.reduceRight;
  10955. var arrayJoin = ArrayProto.join;
  10956. var arraySort = ArrayProto.sort;
  10957. var arraySlice = ArrayProto.slice;
  10958. var arrayToString = ArrayProto.toString;
  10959. var arrayToLocaleString = ArrayProto.toLocaleString;
  10960. var ITERATOR = wks('iterator');
  10961. var TAG = wks('toStringTag');
  10962. var TYPED_CONSTRUCTOR = uid('typed_constructor');
  10963. var DEF_CONSTRUCTOR = uid('def_constructor');
  10964. var ALL_CONSTRUCTORS = $typed.CONSTR;
  10965. var TYPED_ARRAY = $typed.TYPED;
  10966. var VIEW = $typed.VIEW;
  10967. var WRONG_LENGTH = 'Wrong length!';
  10968. var $map = createArrayMethod(1, function (O, length) {
  10969. return allocate(speciesConstructor(O, O[DEF_CONSTRUCTOR]), length);
  10970. });
  10971. var LITTLE_ENDIAN = fails(function () {
  10972. return new Uint8Array(new Uint16Array([1]).buffer)[0] === 1;
  10973. });
  10974. var FORCED_SET = !!Uint8Array && !!Uint8Array[PROTOTYPE].set && fails(function () {
  10975. new Uint8Array(1).set({});
  10976. });
  10977. var toOffset = function toOffset(it, BYTES) {
  10978. var offset = toInteger(it);
  10979. if (offset < 0 || offset % BYTES) throw RangeError('Wrong offset!');
  10980. return offset;
  10981. };
  10982. var validate = function validate(it) {
  10983. if (isObject(it) && TYPED_ARRAY in it) return it;
  10984. throw TypeError(it + ' is not a typed array!');
  10985. };
  10986. var allocate = function allocate(C, length) {
  10987. if (!(isObject(C) && TYPED_CONSTRUCTOR in C)) {
  10988. throw TypeError('It is not a typed array constructor!');
  10989. }
  10990. return new C(length);
  10991. };
  10992. var speciesFromList = function speciesFromList(O, list) {
  10993. return fromList(speciesConstructor(O, O[DEF_CONSTRUCTOR]), list);
  10994. };
  10995. var fromList = function fromList(C, list) {
  10996. var index = 0;
  10997. var length = list.length;
  10998. var result = allocate(C, length);
  10999. while (length > index) {
  11000. result[index] = list[index++];
  11001. }return result;
  11002. };
  11003. var addGetter = function addGetter(it, key, internal) {
  11004. dP(it, key, {
  11005. get: function get() {
  11006. return this._d[internal];
  11007. }
  11008. });
  11009. };
  11010. var $from = function from(source) {
  11011. var O = toObject(source);
  11012. var aLen = arguments.length;
  11013. var mapfn = aLen > 1 ? arguments[1] : undefined;
  11014. var mapping = mapfn !== undefined;
  11015. var iterFn = getIterFn(O);
  11016. var i, length, values, result, step, iterator;
  11017. if (iterFn != undefined && !isArrayIter(iterFn)) {
  11018. for (iterator = iterFn.call(O), values = [], i = 0; !(step = iterator.next()).done; i++) {
  11019. values.push(step.value);
  11020. }
  11021. O = values;
  11022. }
  11023. if (mapping && aLen > 2) mapfn = ctx(mapfn, arguments[2], 2);
  11024. for (i = 0, length = toLength(O.length), result = allocate(this, length); length > i; i++) {
  11025. result[i] = mapping ? mapfn(O[i], i) : O[i];
  11026. }
  11027. return result;
  11028. };
  11029. var $of = function of() {
  11030. var index = 0;
  11031. var length = arguments.length;
  11032. var result = allocate(this, length);
  11033. while (length > index) {
  11034. result[index] = arguments[index++];
  11035. }return result;
  11036. };
  11037. var TO_LOCALE_BUG = !!Uint8Array && fails(function () {
  11038. arrayToLocaleString.call(new Uint8Array(1));
  11039. });
  11040. var $toLocaleString = function toLocaleString() {
  11041. return arrayToLocaleString.apply(TO_LOCALE_BUG ? arraySlice.call(validate(this)) : validate(this), arguments);
  11042. };
  11043. var proto = {
  11044. copyWithin: function copyWithin(target, start) {
  11045. return arrayCopyWithin.call(validate(this), target, start, arguments.length > 2 ? arguments[2] : undefined);
  11046. },
  11047. every: function every(callbackfn) {
  11048. return arrayEvery(validate(this), callbackfn, arguments.length > 1 ? arguments[1] : undefined);
  11049. },
  11050. fill: function fill(value) {
  11051. return arrayFill.apply(validate(this), arguments);
  11052. },
  11053. filter: function filter(callbackfn) {
  11054. return speciesFromList(this, arrayFilter(validate(this), callbackfn, arguments.length > 1 ? arguments[1] : undefined));
  11055. },
  11056. find: function find(predicate) {
  11057. return arrayFind(validate(this), predicate, arguments.length > 1 ? arguments[1] : undefined);
  11058. },
  11059. findIndex: function findIndex(predicate) {
  11060. return arrayFindIndex(validate(this), predicate, arguments.length > 1 ? arguments[1] : undefined);
  11061. },
  11062. forEach: function forEach(callbackfn) {
  11063. arrayForEach(validate(this), callbackfn, arguments.length > 1 ? arguments[1] : undefined);
  11064. },
  11065. indexOf: function indexOf(searchElement) {
  11066. return arrayIndexOf(validate(this), searchElement, arguments.length > 1 ? arguments[1] : undefined);
  11067. },
  11068. includes: function includes(searchElement) {
  11069. return arrayIncludes(validate(this), searchElement, arguments.length > 1 ? arguments[1] : undefined);
  11070. },
  11071. join: function join(separator) {
  11072. return arrayJoin.apply(validate(this), arguments);
  11073. },
  11074. lastIndexOf: function lastIndexOf(searchElement) {
  11075. return arrayLastIndexOf.apply(validate(this), arguments);
  11076. },
  11077. map: function map(mapfn) {
  11078. return $map(validate(this), mapfn, arguments.length > 1 ? arguments[1] : undefined);
  11079. },
  11080. reduce: function reduce(callbackfn) {
  11081. return arrayReduce.apply(validate(this), arguments);
  11082. },
  11083. reduceRight: function reduceRight(callbackfn) {
  11084. return arrayReduceRight.apply(validate(this), arguments);
  11085. },
  11086. reverse: function reverse() {
  11087. var that = this;
  11088. var length = validate(that).length;
  11089. var middle = Math.floor(length / 2);
  11090. var index = 0;
  11091. var value;
  11092. while (index < middle) {
  11093. value = that[index];
  11094. that[index++] = that[--length];
  11095. that[length] = value;
  11096. }
  11097. return that;
  11098. },
  11099. some: function some(callbackfn) {
  11100. return arraySome(validate(this), callbackfn, arguments.length > 1 ? arguments[1] : undefined);
  11101. },
  11102. sort: function sort(comparefn) {
  11103. return arraySort.call(validate(this), comparefn);
  11104. },
  11105. subarray: function subarray(begin, end) {
  11106. var O = validate(this);
  11107. var length = O.length;
  11108. var $begin = toAbsoluteIndex(begin, length);
  11109. return new (speciesConstructor(O, O[DEF_CONSTRUCTOR]))(O.buffer, O.byteOffset + $begin * O.BYTES_PER_ELEMENT, toLength((end === undefined ? length : toAbsoluteIndex(end, length)) - $begin));
  11110. }
  11111. };
  11112. var $slice = function slice(start, end) {
  11113. return speciesFromList(this, arraySlice.call(validate(this), start, end));
  11114. };
  11115. var $set = function set(arrayLike) {
  11116. validate(this);
  11117. var offset = toOffset(arguments[1], 1);
  11118. var length = this.length;
  11119. var src = toObject(arrayLike);
  11120. var len = toLength(src.length);
  11121. var index = 0;
  11122. if (len + offset > length) throw RangeError(WRONG_LENGTH);
  11123. while (index < len) {
  11124. this[offset + index] = src[index++];
  11125. }
  11126. };
  11127. var $iterators = {
  11128. entries: function entries() {
  11129. return arrayEntries.call(validate(this));
  11130. },
  11131. keys: function keys() {
  11132. return arrayKeys.call(validate(this));
  11133. },
  11134. values: function values() {
  11135. return arrayValues.call(validate(this));
  11136. }
  11137. };
  11138. var isTAIndex = function isTAIndex(target, key) {
  11139. return isObject(target) && target[TYPED_ARRAY] && (typeof key === 'undefined' ? 'undefined' : _typeof(key)) != 'symbol' && key in target && String(+key) == String(key);
  11140. };
  11141. var $getDesc = function getOwnPropertyDescriptor(target, key) {
  11142. return isTAIndex(target, key = toPrimitive(key, true)) ? propertyDesc(2, target[key]) : gOPD(target, key);
  11143. };
  11144. var $setDesc = function defineProperty(target, key, desc) {
  11145. if (isTAIndex(target, key = toPrimitive(key, true)) && isObject(desc) && has(desc, 'value') && !has(desc, 'get') && !has(desc, 'set') && !desc.configurable && (!has(desc, 'writable') || desc.writable) && (!has(desc, 'enumerable') || desc.enumerable)) {
  11146. target[key] = desc.value;
  11147. return target;
  11148. }
  11149. return dP(target, key, desc);
  11150. };
  11151. if (!ALL_CONSTRUCTORS) {
  11152. $GOPD.f = $getDesc;
  11153. $DP.f = $setDesc;
  11154. }
  11155. $export($export.S + $export.F * !ALL_CONSTRUCTORS, 'Object', {
  11156. getOwnPropertyDescriptor: $getDesc,
  11157. defineProperty: $setDesc
  11158. });
  11159. if (fails(function () {
  11160. arrayToString.call({});
  11161. })) {
  11162. arrayToString = arrayToLocaleString = function toString() {
  11163. return arrayJoin.call(this);
  11164. };
  11165. }
  11166. var $TypedArrayPrototype$ = redefineAll({}, proto);
  11167. redefineAll($TypedArrayPrototype$, $iterators);
  11168. hide($TypedArrayPrototype$, ITERATOR, $iterators.values);
  11169. redefineAll($TypedArrayPrototype$, {
  11170. slice: $slice,
  11171. set: $set,
  11172. constructor: function constructor() {},
  11173. toString: arrayToString,
  11174. toLocaleString: $toLocaleString
  11175. });
  11176. addGetter($TypedArrayPrototype$, 'buffer', 'b');
  11177. addGetter($TypedArrayPrototype$, 'byteOffset', 'o');
  11178. addGetter($TypedArrayPrototype$, 'byteLength', 'l');
  11179. addGetter($TypedArrayPrototype$, 'length', 'e');
  11180. dP($TypedArrayPrototype$, TAG, {
  11181. get: function get() {
  11182. return this[TYPED_ARRAY];
  11183. }
  11184. });
  11185. module.exports = function (KEY, BYTES, wrapper, CLAMPED) {
  11186. CLAMPED = !!CLAMPED;
  11187. var NAME = KEY + (CLAMPED ? 'Clamped' : '') + 'Array';
  11188. var GETTER = 'get' + KEY;
  11189. var SETTER = 'set' + KEY;
  11190. var TypedArray = global[NAME];
  11191. var Base = TypedArray || {};
  11192. var TAC = TypedArray && getPrototypeOf(TypedArray);
  11193. var FORCED = !TypedArray || !$typed.ABV;
  11194. var O = {};
  11195. var TypedArrayPrototype = TypedArray && TypedArray[PROTOTYPE];
  11196. var getter = function getter(that, index) {
  11197. var data = that._d;
  11198. return data.v[GETTER](index * BYTES + data.o, LITTLE_ENDIAN);
  11199. };
  11200. var setter = function setter(that, index, value) {
  11201. var data = that._d;
  11202. if (CLAMPED) value = (value = Math.round(value)) < 0 ? 0 : value > 0xff ? 0xff : value & 0xff;
  11203. data.v[SETTER](index * BYTES + data.o, value, LITTLE_ENDIAN);
  11204. };
  11205. var addElement = function addElement(that, index) {
  11206. dP(that, index, {
  11207. get: function get() {
  11208. return getter(this, index);
  11209. },
  11210. set: function set(value) {
  11211. return setter(this, index, value);
  11212. },
  11213. enumerable: true
  11214. });
  11215. };
  11216. if (FORCED) {
  11217. TypedArray = wrapper(function (that, data, $offset, $length) {
  11218. anInstance(that, TypedArray, NAME, '_d');
  11219. var index = 0;
  11220. var offset = 0;
  11221. var buffer, byteLength, length, klass;
  11222. if (!isObject(data)) {
  11223. length = toIndex(data);
  11224. byteLength = length * BYTES;
  11225. buffer = new $ArrayBuffer(byteLength);
  11226. } else if (data instanceof $ArrayBuffer || (klass = classof(data)) == ARRAY_BUFFER || klass == SHARED_BUFFER) {
  11227. buffer = data;
  11228. offset = toOffset($offset, BYTES);
  11229. var $len = data.byteLength;
  11230. if ($length === undefined) {
  11231. if ($len % BYTES) throw RangeError(WRONG_LENGTH);
  11232. byteLength = $len - offset;
  11233. if (byteLength < 0) throw RangeError(WRONG_LENGTH);
  11234. } else {
  11235. byteLength = toLength($length) * BYTES;
  11236. if (byteLength + offset > $len) throw RangeError(WRONG_LENGTH);
  11237. }
  11238. length = byteLength / BYTES;
  11239. } else if (TYPED_ARRAY in data) {
  11240. return fromList(TypedArray, data);
  11241. } else {
  11242. return $from.call(TypedArray, data);
  11243. }
  11244. hide(that, '_d', {
  11245. b: buffer,
  11246. o: offset,
  11247. l: byteLength,
  11248. e: length,
  11249. v: new $DataView(buffer)
  11250. });
  11251. while (index < length) {
  11252. addElement(that, index++);
  11253. }
  11254. });
  11255. TypedArrayPrototype = TypedArray[PROTOTYPE] = create($TypedArrayPrototype$);
  11256. hide(TypedArrayPrototype, 'constructor', TypedArray);
  11257. } else if (!fails(function () {
  11258. TypedArray(1);
  11259. }) || !fails(function () {
  11260. new TypedArray(-1);
  11261. }) || !$iterDetect(function (iter) {
  11262. new TypedArray();
  11263. new TypedArray(null);
  11264. new TypedArray(1.5);
  11265. new TypedArray(iter);
  11266. }, true)) {
  11267. TypedArray = wrapper(function (that, data, $offset, $length) {
  11268. anInstance(that, TypedArray, NAME);
  11269. var klass;
  11270. if (!isObject(data)) return new Base(toIndex(data));
  11271. if (data instanceof $ArrayBuffer || (klass = classof(data)) == ARRAY_BUFFER || klass == SHARED_BUFFER) {
  11272. return $length !== undefined ? new Base(data, toOffset($offset, BYTES), $length) : $offset !== undefined ? new Base(data, toOffset($offset, BYTES)) : new Base(data);
  11273. }
  11274. if (TYPED_ARRAY in data) return fromList(TypedArray, data);
  11275. return $from.call(TypedArray, data);
  11276. });
  11277. arrayForEach(TAC !== Function.prototype ? gOPN(Base).concat(gOPN(TAC)) : gOPN(Base), function (key) {
  11278. if (!(key in TypedArray)) hide(TypedArray, key, Base[key]);
  11279. });
  11280. TypedArray[PROTOTYPE] = TypedArrayPrototype;
  11281. if (!LIBRARY) TypedArrayPrototype.constructor = TypedArray;
  11282. }
  11283. var $nativeIterator = TypedArrayPrototype[ITERATOR];
  11284. var CORRECT_ITER_NAME = !!$nativeIterator && ($nativeIterator.name == 'values' || $nativeIterator.name == undefined);
  11285. var $iterator = $iterators.values;
  11286. hide(TypedArray, TYPED_CONSTRUCTOR, true);
  11287. hide(TypedArrayPrototype, TYPED_ARRAY, NAME);
  11288. hide(TypedArrayPrototype, VIEW, true);
  11289. hide(TypedArrayPrototype, DEF_CONSTRUCTOR, TypedArray);
  11290. if (CLAMPED ? new TypedArray(1)[TAG] != NAME : !(TAG in TypedArrayPrototype)) {
  11291. dP(TypedArrayPrototype, TAG, {
  11292. get: function get() {
  11293. return NAME;
  11294. }
  11295. });
  11296. }
  11297. O[NAME] = TypedArray;
  11298. $export($export.G + $export.W + $export.F * (TypedArray != Base), O);
  11299. $export($export.S, NAME, { BYTES_PER_ELEMENT: BYTES });
  11300. $export($export.S + $export.F * fails(function () {
  11301. Base.of.call(TypedArray, 1);
  11302. }), NAME, {
  11303. from: $from,
  11304. of: $of
  11305. });
  11306. if (!(BYTES_PER_ELEMENT in TypedArrayPrototype)) hide(TypedArrayPrototype, BYTES_PER_ELEMENT, BYTES);
  11307. $export($export.P, NAME, proto);
  11308. setSpecies(NAME);
  11309. $export($export.P + $export.F * FORCED_SET, NAME, { set: $set });
  11310. $export($export.P + $export.F * !CORRECT_ITER_NAME, NAME, $iterators);
  11311. if (!LIBRARY && TypedArrayPrototype.toString != arrayToString) TypedArrayPrototype.toString = arrayToString;
  11312. $export($export.P + $export.F * fails(function () {
  11313. new TypedArray(1).slice();
  11314. }), NAME, { slice: $slice });
  11315. $export($export.P + $export.F * (fails(function () {
  11316. return [1, 2].toLocaleString() != new TypedArray([1, 2]).toLocaleString();
  11317. }) || !fails(function () {
  11318. TypedArrayPrototype.toLocaleString.call([1, 2]);
  11319. })), NAME, { toLocaleString: $toLocaleString });
  11320. Iterators[NAME] = CORRECT_ITER_NAME ? $nativeIterator : $iterator;
  11321. if (!LIBRARY && !CORRECT_ITER_NAME) hide(TypedArrayPrototype, ITERATOR, $iterator);
  11322. };
  11323. } else module.exports = function () {};
  11324. /***/ }),
  11325. /* 78 */
  11326. /***/ (function(module, exports, __w_pdfjs_require__) {
  11327. "use strict";
  11328. var global = __w_pdfjs_require__(2);
  11329. var DESCRIPTORS = __w_pdfjs_require__(3);
  11330. var LIBRARY = __w_pdfjs_require__(24);
  11331. var $typed = __w_pdfjs_require__(50);
  11332. var hide = __w_pdfjs_require__(4);
  11333. var redefineAll = __w_pdfjs_require__(47);
  11334. var fails = __w_pdfjs_require__(17);
  11335. var anInstance = __w_pdfjs_require__(34);
  11336. var toInteger = __w_pdfjs_require__(11);
  11337. var toLength = __w_pdfjs_require__(6);
  11338. var toIndex = __w_pdfjs_require__(49);
  11339. var gOPN = __w_pdfjs_require__(44).f;
  11340. var dP = __w_pdfjs_require__(8).f;
  11341. var arrayFill = __w_pdfjs_require__(35);
  11342. var setToStringTag = __w_pdfjs_require__(26);
  11343. var ARRAY_BUFFER = 'ArrayBuffer';
  11344. var DATA_VIEW = 'DataView';
  11345. var PROTOTYPE = 'prototype';
  11346. var WRONG_LENGTH = 'Wrong length!';
  11347. var WRONG_INDEX = 'Wrong index!';
  11348. var $ArrayBuffer = global[ARRAY_BUFFER];
  11349. var $DataView = global[DATA_VIEW];
  11350. var Math = global.Math;
  11351. var RangeError = global.RangeError;
  11352. var Infinity = global.Infinity;
  11353. var BaseBuffer = $ArrayBuffer;
  11354. var abs = Math.abs;
  11355. var pow = Math.pow;
  11356. var floor = Math.floor;
  11357. var log = Math.log;
  11358. var LN2 = Math.LN2;
  11359. var BUFFER = 'buffer';
  11360. var BYTE_LENGTH = 'byteLength';
  11361. var BYTE_OFFSET = 'byteOffset';
  11362. var $BUFFER = DESCRIPTORS ? '_b' : BUFFER;
  11363. var $LENGTH = DESCRIPTORS ? '_l' : BYTE_LENGTH;
  11364. var $OFFSET = DESCRIPTORS ? '_o' : BYTE_OFFSET;
  11365. function packIEEE754(value, mLen, nBytes) {
  11366. var buffer = Array(nBytes);
  11367. var eLen = nBytes * 8 - mLen - 1;
  11368. var eMax = (1 << eLen) - 1;
  11369. var eBias = eMax >> 1;
  11370. var rt = mLen === 23 ? pow(2, -24) - pow(2, -77) : 0;
  11371. var i = 0;
  11372. var s = value < 0 || value === 0 && 1 / value < 0 ? 1 : 0;
  11373. var e, m, c;
  11374. value = abs(value);
  11375. if (value != value || value === Infinity) {
  11376. m = value != value ? 1 : 0;
  11377. e = eMax;
  11378. } else {
  11379. e = floor(log(value) / LN2);
  11380. if (value * (c = pow(2, -e)) < 1) {
  11381. e--;
  11382. c *= 2;
  11383. }
  11384. if (e + eBias >= 1) {
  11385. value += rt / c;
  11386. } else {
  11387. value += rt * pow(2, 1 - eBias);
  11388. }
  11389. if (value * c >= 2) {
  11390. e++;
  11391. c /= 2;
  11392. }
  11393. if (e + eBias >= eMax) {
  11394. m = 0;
  11395. e = eMax;
  11396. } else if (e + eBias >= 1) {
  11397. m = (value * c - 1) * pow(2, mLen);
  11398. e = e + eBias;
  11399. } else {
  11400. m = value * pow(2, eBias - 1) * pow(2, mLen);
  11401. e = 0;
  11402. }
  11403. }
  11404. for (; mLen >= 8; buffer[i++] = m & 255, m /= 256, mLen -= 8) {}
  11405. e = e << mLen | m;
  11406. eLen += mLen;
  11407. for (; eLen > 0; buffer[i++] = e & 255, e /= 256, eLen -= 8) {}
  11408. buffer[--i] |= s * 128;
  11409. return buffer;
  11410. }
  11411. function unpackIEEE754(buffer, mLen, nBytes) {
  11412. var eLen = nBytes * 8 - mLen - 1;
  11413. var eMax = (1 << eLen) - 1;
  11414. var eBias = eMax >> 1;
  11415. var nBits = eLen - 7;
  11416. var i = nBytes - 1;
  11417. var s = buffer[i--];
  11418. var e = s & 127;
  11419. var m;
  11420. s >>= 7;
  11421. for (; nBits > 0; e = e * 256 + buffer[i], i--, nBits -= 8) {}
  11422. m = e & (1 << -nBits) - 1;
  11423. e >>= -nBits;
  11424. nBits += mLen;
  11425. for (; nBits > 0; m = m * 256 + buffer[i], i--, nBits -= 8) {}
  11426. if (e === 0) {
  11427. e = 1 - eBias;
  11428. } else if (e === eMax) {
  11429. return m ? NaN : s ? -Infinity : Infinity;
  11430. } else {
  11431. m = m + pow(2, mLen);
  11432. e = e - eBias;
  11433. }
  11434. return (s ? -1 : 1) * m * pow(2, e - mLen);
  11435. }
  11436. function unpackI32(bytes) {
  11437. return bytes[3] << 24 | bytes[2] << 16 | bytes[1] << 8 | bytes[0];
  11438. }
  11439. function packI8(it) {
  11440. return [it & 0xff];
  11441. }
  11442. function packI16(it) {
  11443. return [it & 0xff, it >> 8 & 0xff];
  11444. }
  11445. function packI32(it) {
  11446. return [it & 0xff, it >> 8 & 0xff, it >> 16 & 0xff, it >> 24 & 0xff];
  11447. }
  11448. function packF64(it) {
  11449. return packIEEE754(it, 52, 8);
  11450. }
  11451. function packF32(it) {
  11452. return packIEEE754(it, 23, 4);
  11453. }
  11454. function addGetter(C, key, internal) {
  11455. dP(C[PROTOTYPE], key, {
  11456. get: function get() {
  11457. return this[internal];
  11458. }
  11459. });
  11460. }
  11461. function get(view, bytes, index, isLittleEndian) {
  11462. var numIndex = +index;
  11463. var intIndex = toIndex(numIndex);
  11464. if (intIndex + bytes > view[$LENGTH]) throw RangeError(WRONG_INDEX);
  11465. var store = view[$BUFFER]._b;
  11466. var start = intIndex + view[$OFFSET];
  11467. var pack = store.slice(start, start + bytes);
  11468. return isLittleEndian ? pack : pack.reverse();
  11469. }
  11470. function set(view, bytes, index, conversion, value, isLittleEndian) {
  11471. var numIndex = +index;
  11472. var intIndex = toIndex(numIndex);
  11473. if (intIndex + bytes > view[$LENGTH]) throw RangeError(WRONG_INDEX);
  11474. var store = view[$BUFFER]._b;
  11475. var start = intIndex + view[$OFFSET];
  11476. var pack = conversion(+value);
  11477. for (var i = 0; i < bytes; i++) {
  11478. store[start + i] = pack[isLittleEndian ? i : bytes - i - 1];
  11479. }
  11480. }
  11481. if (!$typed.ABV) {
  11482. $ArrayBuffer = function ArrayBuffer(length) {
  11483. anInstance(this, $ArrayBuffer, ARRAY_BUFFER);
  11484. var byteLength = toIndex(length);
  11485. this._b = arrayFill.call(Array(byteLength), 0);
  11486. this[$LENGTH] = byteLength;
  11487. };
  11488. $DataView = function DataView(buffer, byteOffset, byteLength) {
  11489. anInstance(this, $DataView, DATA_VIEW);
  11490. anInstance(buffer, $ArrayBuffer, DATA_VIEW);
  11491. var bufferLength = buffer[$LENGTH];
  11492. var offset = toInteger(byteOffset);
  11493. if (offset < 0 || offset > bufferLength) throw RangeError('Wrong offset!');
  11494. byteLength = byteLength === undefined ? bufferLength - offset : toLength(byteLength);
  11495. if (offset + byteLength > bufferLength) throw RangeError(WRONG_LENGTH);
  11496. this[$BUFFER] = buffer;
  11497. this[$OFFSET] = offset;
  11498. this[$LENGTH] = byteLength;
  11499. };
  11500. if (DESCRIPTORS) {
  11501. addGetter($ArrayBuffer, BYTE_LENGTH, '_l');
  11502. addGetter($DataView, BUFFER, '_b');
  11503. addGetter($DataView, BYTE_LENGTH, '_l');
  11504. addGetter($DataView, BYTE_OFFSET, '_o');
  11505. }
  11506. redefineAll($DataView[PROTOTYPE], {
  11507. getInt8: function getInt8(byteOffset) {
  11508. return get(this, 1, byteOffset)[0] << 24 >> 24;
  11509. },
  11510. getUint8: function getUint8(byteOffset) {
  11511. return get(this, 1, byteOffset)[0];
  11512. },
  11513. getInt16: function getInt16(byteOffset) {
  11514. var bytes = get(this, 2, byteOffset, arguments[1]);
  11515. return (bytes[1] << 8 | bytes[0]) << 16 >> 16;
  11516. },
  11517. getUint16: function getUint16(byteOffset) {
  11518. var bytes = get(this, 2, byteOffset, arguments[1]);
  11519. return bytes[1] << 8 | bytes[0];
  11520. },
  11521. getInt32: function getInt32(byteOffset) {
  11522. return unpackI32(get(this, 4, byteOffset, arguments[1]));
  11523. },
  11524. getUint32: function getUint32(byteOffset) {
  11525. return unpackI32(get(this, 4, byteOffset, arguments[1])) >>> 0;
  11526. },
  11527. getFloat32: function getFloat32(byteOffset) {
  11528. return unpackIEEE754(get(this, 4, byteOffset, arguments[1]), 23, 4);
  11529. },
  11530. getFloat64: function getFloat64(byteOffset) {
  11531. return unpackIEEE754(get(this, 8, byteOffset, arguments[1]), 52, 8);
  11532. },
  11533. setInt8: function setInt8(byteOffset, value) {
  11534. set(this, 1, byteOffset, packI8, value);
  11535. },
  11536. setUint8: function setUint8(byteOffset, value) {
  11537. set(this, 1, byteOffset, packI8, value);
  11538. },
  11539. setInt16: function setInt16(byteOffset, value) {
  11540. set(this, 2, byteOffset, packI16, value, arguments[2]);
  11541. },
  11542. setUint16: function setUint16(byteOffset, value) {
  11543. set(this, 2, byteOffset, packI16, value, arguments[2]);
  11544. },
  11545. setInt32: function setInt32(byteOffset, value) {
  11546. set(this, 4, byteOffset, packI32, value, arguments[2]);
  11547. },
  11548. setUint32: function setUint32(byteOffset, value) {
  11549. set(this, 4, byteOffset, packI32, value, arguments[2]);
  11550. },
  11551. setFloat32: function setFloat32(byteOffset, value) {
  11552. set(this, 4, byteOffset, packF32, value, arguments[2]);
  11553. },
  11554. setFloat64: function setFloat64(byteOffset, value) {
  11555. set(this, 8, byteOffset, packF64, value, arguments[2]);
  11556. }
  11557. });
  11558. } else {
  11559. if (!fails(function () {
  11560. $ArrayBuffer(1);
  11561. }) || !fails(function () {
  11562. new $ArrayBuffer(-1);
  11563. }) || fails(function () {
  11564. new $ArrayBuffer();
  11565. new $ArrayBuffer(1.5);
  11566. new $ArrayBuffer(NaN);
  11567. return $ArrayBuffer.name != ARRAY_BUFFER;
  11568. })) {
  11569. $ArrayBuffer = function ArrayBuffer(length) {
  11570. anInstance(this, $ArrayBuffer);
  11571. return new BaseBuffer(toIndex(length));
  11572. };
  11573. var ArrayBufferProto = $ArrayBuffer[PROTOTYPE] = BaseBuffer[PROTOTYPE];
  11574. for (var keys = gOPN(BaseBuffer), j = 0, key; keys.length > j;) {
  11575. if (!((key = keys[j++]) in $ArrayBuffer)) hide($ArrayBuffer, key, BaseBuffer[key]);
  11576. }
  11577. if (!LIBRARY) ArrayBufferProto.constructor = $ArrayBuffer;
  11578. }
  11579. var view = new $DataView(new $ArrayBuffer(2));
  11580. var $setInt8 = $DataView[PROTOTYPE].setInt8;
  11581. view.setInt8(0, 2147483648);
  11582. view.setInt8(1, 2147483649);
  11583. if (view.getInt8(0) || !view.getInt8(1)) redefineAll($DataView[PROTOTYPE], {
  11584. setInt8: function setInt8(byteOffset, value) {
  11585. $setInt8.call(this, byteOffset, value << 24 >> 24);
  11586. },
  11587. setUint8: function setUint8(byteOffset, value) {
  11588. $setInt8.call(this, byteOffset, value << 24 >> 24);
  11589. }
  11590. }, true);
  11591. }
  11592. setToStringTag($ArrayBuffer, ARRAY_BUFFER);
  11593. setToStringTag($DataView, DATA_VIEW);
  11594. hide($DataView[PROTOTYPE], $typed.VIEW, true);
  11595. exports[ARRAY_BUFFER] = $ArrayBuffer;
  11596. exports[DATA_VIEW] = $DataView;
  11597. /***/ }),
  11598. /* 79 */
  11599. /***/ (function(module, exports, __w_pdfjs_require__) {
  11600. "use strict";
  11601. var classof = __w_pdfjs_require__(37);
  11602. var ITERATOR = __w_pdfjs_require__(1)('iterator');
  11603. var Iterators = __w_pdfjs_require__(10);
  11604. module.exports = __w_pdfjs_require__(16).getIteratorMethod = function (it) {
  11605. if (it != undefined) return it[ITERATOR] || it['@@iterator'] || Iterators[classof(it)];
  11606. };
  11607. /***/ }),
  11608. /* 80 */
  11609. /***/ (function(module, exports, __w_pdfjs_require__) {
  11610. "use strict";
  11611. var addToUnscopables = __w_pdfjs_require__(59);
  11612. var step = __w_pdfjs_require__(70);
  11613. var Iterators = __w_pdfjs_require__(10);
  11614. var toIObject = __w_pdfjs_require__(20);
  11615. module.exports = __w_pdfjs_require__(68)(Array, 'Array', function (iterated, kind) {
  11616. this._t = toIObject(iterated);
  11617. this._i = 0;
  11618. this._k = kind;
  11619. }, function () {
  11620. var O = this._t;
  11621. var kind = this._k;
  11622. var index = this._i++;
  11623. if (!O || index >= O.length) {
  11624. this._t = undefined;
  11625. return step(1);
  11626. }
  11627. if (kind == 'keys') return step(0, index);
  11628. if (kind == 'values') return step(0, O[index]);
  11629. return step(0, [index, O[index]]);
  11630. }, 'values');
  11631. Iterators.Arguments = Iterators.Array;
  11632. addToUnscopables('keys');
  11633. addToUnscopables('values');
  11634. addToUnscopables('entries');
  11635. /***/ }),
  11636. /* 81 */
  11637. /***/ (function(module, exports, __w_pdfjs_require__) {
  11638. "use strict";
  11639. __w_pdfjs_require__(77)('Uint8', 1, function (init) {
  11640. return function Uint8ClampedArray(data, byteOffset, length) {
  11641. return init(this, data, byteOffset, length);
  11642. };
  11643. }, true);
  11644. /***/ }),
  11645. /* 82 */
  11646. /***/ (function(module, exports, __w_pdfjs_require__) {
  11647. "use strict";
  11648. Object.defineProperty(exports, "__esModule", {
  11649. value: true
  11650. });
  11651. exports.CanvasGraphics = undefined;
  11652. var _util = __w_pdfjs_require__(0);
  11653. var _pattern_helper = __w_pdfjs_require__(84);
  11654. var _webgl = __w_pdfjs_require__(53);
  11655. var MIN_FONT_SIZE = 16;
  11656. var MAX_FONT_SIZE = 100;
  11657. var MAX_GROUP_SIZE = 4096;
  11658. var MIN_WIDTH_FACTOR = 0.65;
  11659. var COMPILE_TYPE3_GLYPHS = true;
  11660. var MAX_SIZE_TO_COMPILE = 1000;
  11661. var FULL_CHUNK_HEIGHT = 16;
  11662. var IsLittleEndianCached = {
  11663. get value() {
  11664. return (0, _util.shadow)(IsLittleEndianCached, 'value', (0, _util.isLittleEndian)());
  11665. }
  11666. };
  11667. function addContextCurrentTransform(ctx) {
  11668. if (!ctx.mozCurrentTransform) {
  11669. ctx._originalSave = ctx.save;
  11670. ctx._originalRestore = ctx.restore;
  11671. ctx._originalRotate = ctx.rotate;
  11672. ctx._originalScale = ctx.scale;
  11673. ctx._originalTranslate = ctx.translate;
  11674. ctx._originalTransform = ctx.transform;
  11675. ctx._originalSetTransform = ctx.setTransform;
  11676. ctx._transformMatrix = ctx._transformMatrix || [1, 0, 0, 1, 0, 0];
  11677. ctx._transformStack = [];
  11678. Object.defineProperty(ctx, 'mozCurrentTransform', {
  11679. get: function getCurrentTransform() {
  11680. return this._transformMatrix;
  11681. }
  11682. });
  11683. Object.defineProperty(ctx, 'mozCurrentTransformInverse', {
  11684. get: function getCurrentTransformInverse() {
  11685. var m = this._transformMatrix;
  11686. var a = m[0],
  11687. b = m[1],
  11688. c = m[2],
  11689. d = m[3],
  11690. e = m[4],
  11691. f = m[5];
  11692. var ad_bc = a * d - b * c;
  11693. var bc_ad = b * c - a * d;
  11694. return [d / ad_bc, b / bc_ad, c / bc_ad, a / ad_bc, (d * e - c * f) / bc_ad, (b * e - a * f) / ad_bc];
  11695. }
  11696. });
  11697. ctx.save = function ctxSave() {
  11698. var old = this._transformMatrix;
  11699. this._transformStack.push(old);
  11700. this._transformMatrix = old.slice(0, 6);
  11701. this._originalSave();
  11702. };
  11703. ctx.restore = function ctxRestore() {
  11704. var prev = this._transformStack.pop();
  11705. if (prev) {
  11706. this._transformMatrix = prev;
  11707. this._originalRestore();
  11708. }
  11709. };
  11710. ctx.translate = function ctxTranslate(x, y) {
  11711. var m = this._transformMatrix;
  11712. m[4] = m[0] * x + m[2] * y + m[4];
  11713. m[5] = m[1] * x + m[3] * y + m[5];
  11714. this._originalTranslate(x, y);
  11715. };
  11716. ctx.scale = function ctxScale(x, y) {
  11717. var m = this._transformMatrix;
  11718. m[0] = m[0] * x;
  11719. m[1] = m[1] * x;
  11720. m[2] = m[2] * y;
  11721. m[3] = m[3] * y;
  11722. this._originalScale(x, y);
  11723. };
  11724. ctx.transform = function ctxTransform(a, b, c, d, e, f) {
  11725. var m = this._transformMatrix;
  11726. this._transformMatrix = [m[0] * a + m[2] * b, m[1] * a + m[3] * b, m[0] * c + m[2] * d, m[1] * c + m[3] * d, m[0] * e + m[2] * f + m[4], m[1] * e + m[3] * f + m[5]];
  11727. ctx._originalTransform(a, b, c, d, e, f);
  11728. };
  11729. ctx.setTransform = function ctxSetTransform(a, b, c, d, e, f) {
  11730. this._transformMatrix = [a, b, c, d, e, f];
  11731. ctx._originalSetTransform(a, b, c, d, e, f);
  11732. };
  11733. ctx.rotate = function ctxRotate(angle) {
  11734. var cosValue = Math.cos(angle);
  11735. var sinValue = Math.sin(angle);
  11736. var m = this._transformMatrix;
  11737. this._transformMatrix = [m[0] * cosValue + m[2] * sinValue, m[1] * cosValue + m[3] * sinValue, m[0] * -sinValue + m[2] * cosValue, m[1] * -sinValue + m[3] * cosValue, m[4], m[5]];
  11738. this._originalRotate(angle);
  11739. };
  11740. }
  11741. }
  11742. var CachedCanvases = function CachedCanvasesClosure() {
  11743. function CachedCanvases(canvasFactory) {
  11744. this.canvasFactory = canvasFactory;
  11745. this.cache = Object.create(null);
  11746. }
  11747. CachedCanvases.prototype = {
  11748. getCanvas: function CachedCanvases_getCanvas(id, width, height, trackTransform) {
  11749. var canvasEntry;
  11750. if (this.cache[id] !== undefined) {
  11751. canvasEntry = this.cache[id];
  11752. this.canvasFactory.reset(canvasEntry, width, height);
  11753. canvasEntry.context.setTransform(1, 0, 0, 1, 0, 0);
  11754. } else {
  11755. canvasEntry = this.canvasFactory.create(width, height);
  11756. this.cache[id] = canvasEntry;
  11757. }
  11758. if (trackTransform) {
  11759. addContextCurrentTransform(canvasEntry.context);
  11760. }
  11761. return canvasEntry;
  11762. },
  11763. clear: function clear() {
  11764. for (var id in this.cache) {
  11765. var canvasEntry = this.cache[id];
  11766. this.canvasFactory.destroy(canvasEntry);
  11767. delete this.cache[id];
  11768. }
  11769. }
  11770. };
  11771. return CachedCanvases;
  11772. }();
  11773. function compileType3Glyph(imgData) {
  11774. var POINT_TO_PROCESS_LIMIT = 1000;
  11775. var width = imgData.width,
  11776. height = imgData.height;
  11777. var i,
  11778. j,
  11779. j0,
  11780. width1 = width + 1;
  11781. var points = new Uint8Array(width1 * (height + 1));
  11782. var POINT_TYPES = new Uint8Array([0, 2, 4, 0, 1, 0, 5, 4, 8, 10, 0, 8, 0, 2, 1, 0]);
  11783. var lineSize = width + 7 & ~7,
  11784. data0 = imgData.data;
  11785. var data = new Uint8Array(lineSize * height),
  11786. pos = 0,
  11787. ii;
  11788. for (i = 0, ii = data0.length; i < ii; i++) {
  11789. var mask = 128,
  11790. elem = data0[i];
  11791. while (mask > 0) {
  11792. data[pos++] = elem & mask ? 0 : 255;
  11793. mask >>= 1;
  11794. }
  11795. }
  11796. var count = 0;
  11797. pos = 0;
  11798. if (data[pos] !== 0) {
  11799. points[0] = 1;
  11800. ++count;
  11801. }
  11802. for (j = 1; j < width; j++) {
  11803. if (data[pos] !== data[pos + 1]) {
  11804. points[j] = data[pos] ? 2 : 1;
  11805. ++count;
  11806. }
  11807. pos++;
  11808. }
  11809. if (data[pos] !== 0) {
  11810. points[j] = 2;
  11811. ++count;
  11812. }
  11813. for (i = 1; i < height; i++) {
  11814. pos = i * lineSize;
  11815. j0 = i * width1;
  11816. if (data[pos - lineSize] !== data[pos]) {
  11817. points[j0] = data[pos] ? 1 : 8;
  11818. ++count;
  11819. }
  11820. var sum = (data[pos] ? 4 : 0) + (data[pos - lineSize] ? 8 : 0);
  11821. for (j = 1; j < width; j++) {
  11822. sum = (sum >> 2) + (data[pos + 1] ? 4 : 0) + (data[pos - lineSize + 1] ? 8 : 0);
  11823. if (POINT_TYPES[sum]) {
  11824. points[j0 + j] = POINT_TYPES[sum];
  11825. ++count;
  11826. }
  11827. pos++;
  11828. }
  11829. if (data[pos - lineSize] !== data[pos]) {
  11830. points[j0 + j] = data[pos] ? 2 : 4;
  11831. ++count;
  11832. }
  11833. if (count > POINT_TO_PROCESS_LIMIT) {
  11834. return null;
  11835. }
  11836. }
  11837. pos = lineSize * (height - 1);
  11838. j0 = i * width1;
  11839. if (data[pos] !== 0) {
  11840. points[j0] = 8;
  11841. ++count;
  11842. }
  11843. for (j = 1; j < width; j++) {
  11844. if (data[pos] !== data[pos + 1]) {
  11845. points[j0 + j] = data[pos] ? 4 : 8;
  11846. ++count;
  11847. }
  11848. pos++;
  11849. }
  11850. if (data[pos] !== 0) {
  11851. points[j0 + j] = 4;
  11852. ++count;
  11853. }
  11854. if (count > POINT_TO_PROCESS_LIMIT) {
  11855. return null;
  11856. }
  11857. var steps = new Int32Array([0, width1, -1, 0, -width1, 0, 0, 0, 1]);
  11858. var outlines = [];
  11859. for (i = 0; count && i <= height; i++) {
  11860. var p = i * width1;
  11861. var end = p + width;
  11862. while (p < end && !points[p]) {
  11863. p++;
  11864. }
  11865. if (p === end) {
  11866. continue;
  11867. }
  11868. var coords = [p % width1, i];
  11869. var type = points[p],
  11870. p0 = p,
  11871. pp;
  11872. do {
  11873. var step = steps[type];
  11874. do {
  11875. p += step;
  11876. } while (!points[p]);
  11877. pp = points[p];
  11878. if (pp !== 5 && pp !== 10) {
  11879. type = pp;
  11880. points[p] = 0;
  11881. } else {
  11882. type = pp & 0x33 * type >> 4;
  11883. points[p] &= type >> 2 | type << 2;
  11884. }
  11885. coords.push(p % width1);
  11886. coords.push(p / width1 | 0);
  11887. --count;
  11888. } while (p0 !== p);
  11889. outlines.push(coords);
  11890. --i;
  11891. }
  11892. var drawOutline = function drawOutline(c) {
  11893. c.save();
  11894. c.scale(1 / width, -1 / height);
  11895. c.translate(0, -height);
  11896. c.beginPath();
  11897. for (var i = 0, ii = outlines.length; i < ii; i++) {
  11898. var o = outlines[i];
  11899. c.moveTo(o[0], o[1]);
  11900. for (var j = 2, jj = o.length; j < jj; j += 2) {
  11901. c.lineTo(o[j], o[j + 1]);
  11902. }
  11903. }
  11904. c.fill();
  11905. c.beginPath();
  11906. c.restore();
  11907. };
  11908. return drawOutline;
  11909. }
  11910. var CanvasExtraState = function CanvasExtraStateClosure() {
  11911. function CanvasExtraState() {
  11912. this.alphaIsShape = false;
  11913. this.fontSize = 0;
  11914. this.fontSizeScale = 1;
  11915. this.textMatrix = _util.IDENTITY_MATRIX;
  11916. this.textMatrixScale = 1;
  11917. this.fontMatrix = _util.FONT_IDENTITY_MATRIX;
  11918. this.leading = 0;
  11919. this.x = 0;
  11920. this.y = 0;
  11921. this.lineX = 0;
  11922. this.lineY = 0;
  11923. this.charSpacing = 0;
  11924. this.wordSpacing = 0;
  11925. this.textHScale = 1;
  11926. this.textRenderingMode = _util.TextRenderingMode.FILL;
  11927. this.textRise = 0;
  11928. this.fillColor = '#000000';
  11929. this.strokeColor = '#000000';
  11930. this.patternFill = false;
  11931. this.fillAlpha = 1;
  11932. this.strokeAlpha = 1;
  11933. this.lineWidth = 1;
  11934. this.activeSMask = null;
  11935. this.resumeSMaskCtx = null;
  11936. }
  11937. CanvasExtraState.prototype = {
  11938. clone: function CanvasExtraState_clone() {
  11939. return Object.create(this);
  11940. },
  11941. setCurrentPoint: function CanvasExtraState_setCurrentPoint(x, y) {
  11942. this.x = x;
  11943. this.y = y;
  11944. }
  11945. };
  11946. return CanvasExtraState;
  11947. }();
  11948. var CanvasGraphics = function CanvasGraphicsClosure() {
  11949. var EXECUTION_TIME = 15;
  11950. var EXECUTION_STEPS = 10;
  11951. function CanvasGraphics(canvasCtx, commonObjs, objs, canvasFactory, imageLayer) {
  11952. this.ctx = canvasCtx;
  11953. this.current = new CanvasExtraState();
  11954. this.stateStack = [];
  11955. this.pendingClip = null;
  11956. this.pendingEOFill = false;
  11957. this.res = null;
  11958. this.xobjs = null;
  11959. this.commonObjs = commonObjs;
  11960. this.objs = objs;
  11961. this.canvasFactory = canvasFactory;
  11962. this.imageLayer = imageLayer;
  11963. this.groupStack = [];
  11964. this.processingType3 = null;
  11965. this.baseTransform = null;
  11966. this.baseTransformStack = [];
  11967. this.groupLevel = 0;
  11968. this.smaskStack = [];
  11969. this.smaskCounter = 0;
  11970. this.tempSMask = null;
  11971. this.cachedCanvases = new CachedCanvases(this.canvasFactory);
  11972. if (canvasCtx) {
  11973. addContextCurrentTransform(canvasCtx);
  11974. }
  11975. this.cachedGetSinglePixelWidth = null;
  11976. }
  11977. function putBinaryImageData(ctx, imgData) {
  11978. if (typeof ImageData !== 'undefined' && imgData instanceof ImageData) {
  11979. ctx.putImageData(imgData, 0, 0);
  11980. return;
  11981. }
  11982. var height = imgData.height,
  11983. width = imgData.width;
  11984. var partialChunkHeight = height % FULL_CHUNK_HEIGHT;
  11985. var fullChunks = (height - partialChunkHeight) / FULL_CHUNK_HEIGHT;
  11986. var totalChunks = partialChunkHeight === 0 ? fullChunks : fullChunks + 1;
  11987. var chunkImgData = ctx.createImageData(width, FULL_CHUNK_HEIGHT);
  11988. var srcPos = 0,
  11989. destPos;
  11990. var src = imgData.data;
  11991. var dest = chunkImgData.data;
  11992. var i, j, thisChunkHeight, elemsInThisChunk;
  11993. if (imgData.kind === _util.ImageKind.GRAYSCALE_1BPP) {
  11994. var srcLength = src.byteLength;
  11995. var dest32 = new Uint32Array(dest.buffer, 0, dest.byteLength >> 2);
  11996. var dest32DataLength = dest32.length;
  11997. var fullSrcDiff = width + 7 >> 3;
  11998. var white = 0xFFFFFFFF;
  11999. var black = IsLittleEndianCached.value ? 0xFF000000 : 0x000000FF;
  12000. for (i = 0; i < totalChunks; i++) {
  12001. thisChunkHeight = i < fullChunks ? FULL_CHUNK_HEIGHT : partialChunkHeight;
  12002. destPos = 0;
  12003. for (j = 0; j < thisChunkHeight; j++) {
  12004. var srcDiff = srcLength - srcPos;
  12005. var k = 0;
  12006. var kEnd = srcDiff > fullSrcDiff ? width : srcDiff * 8 - 7;
  12007. var kEndUnrolled = kEnd & ~7;
  12008. var mask = 0;
  12009. var srcByte = 0;
  12010. for (; k < kEndUnrolled; k += 8) {
  12011. srcByte = src[srcPos++];
  12012. dest32[destPos++] = srcByte & 128 ? white : black;
  12013. dest32[destPos++] = srcByte & 64 ? white : black;
  12014. dest32[destPos++] = srcByte & 32 ? white : black;
  12015. dest32[destPos++] = srcByte & 16 ? white : black;
  12016. dest32[destPos++] = srcByte & 8 ? white : black;
  12017. dest32[destPos++] = srcByte & 4 ? white : black;
  12018. dest32[destPos++] = srcByte & 2 ? white : black;
  12019. dest32[destPos++] = srcByte & 1 ? white : black;
  12020. }
  12021. for (; k < kEnd; k++) {
  12022. if (mask === 0) {
  12023. srcByte = src[srcPos++];
  12024. mask = 128;
  12025. }
  12026. dest32[destPos++] = srcByte & mask ? white : black;
  12027. mask >>= 1;
  12028. }
  12029. }
  12030. while (destPos < dest32DataLength) {
  12031. dest32[destPos++] = 0;
  12032. }
  12033. ctx.putImageData(chunkImgData, 0, i * FULL_CHUNK_HEIGHT);
  12034. }
  12035. } else if (imgData.kind === _util.ImageKind.RGBA_32BPP) {
  12036. j = 0;
  12037. elemsInThisChunk = width * FULL_CHUNK_HEIGHT * 4;
  12038. for (i = 0; i < fullChunks; i++) {
  12039. dest.set(src.subarray(srcPos, srcPos + elemsInThisChunk));
  12040. srcPos += elemsInThisChunk;
  12041. ctx.putImageData(chunkImgData, 0, j);
  12042. j += FULL_CHUNK_HEIGHT;
  12043. }
  12044. if (i < totalChunks) {
  12045. elemsInThisChunk = width * partialChunkHeight * 4;
  12046. dest.set(src.subarray(srcPos, srcPos + elemsInThisChunk));
  12047. ctx.putImageData(chunkImgData, 0, j);
  12048. }
  12049. } else if (imgData.kind === _util.ImageKind.RGB_24BPP) {
  12050. thisChunkHeight = FULL_CHUNK_HEIGHT;
  12051. elemsInThisChunk = width * thisChunkHeight;
  12052. for (i = 0; i < totalChunks; i++) {
  12053. if (i >= fullChunks) {
  12054. thisChunkHeight = partialChunkHeight;
  12055. elemsInThisChunk = width * thisChunkHeight;
  12056. }
  12057. destPos = 0;
  12058. for (j = elemsInThisChunk; j--;) {
  12059. dest[destPos++] = src[srcPos++];
  12060. dest[destPos++] = src[srcPos++];
  12061. dest[destPos++] = src[srcPos++];
  12062. dest[destPos++] = 255;
  12063. }
  12064. ctx.putImageData(chunkImgData, 0, i * FULL_CHUNK_HEIGHT);
  12065. }
  12066. } else {
  12067. throw new Error('bad image kind: ' + imgData.kind);
  12068. }
  12069. }
  12070. function putBinaryImageMask(ctx, imgData) {
  12071. var height = imgData.height,
  12072. width = imgData.width;
  12073. var partialChunkHeight = height % FULL_CHUNK_HEIGHT;
  12074. var fullChunks = (height - partialChunkHeight) / FULL_CHUNK_HEIGHT;
  12075. var totalChunks = partialChunkHeight === 0 ? fullChunks : fullChunks + 1;
  12076. var chunkImgData = ctx.createImageData(width, FULL_CHUNK_HEIGHT);
  12077. var srcPos = 0;
  12078. var src = imgData.data;
  12079. var dest = chunkImgData.data;
  12080. for (var i = 0; i < totalChunks; i++) {
  12081. var thisChunkHeight = i < fullChunks ? FULL_CHUNK_HEIGHT : partialChunkHeight;
  12082. var destPos = 3;
  12083. for (var j = 0; j < thisChunkHeight; j++) {
  12084. var mask = 0;
  12085. for (var k = 0; k < width; k++) {
  12086. if (!mask) {
  12087. var elem = src[srcPos++];
  12088. mask = 128;
  12089. }
  12090. dest[destPos] = elem & mask ? 0 : 255;
  12091. destPos += 4;
  12092. mask >>= 1;
  12093. }
  12094. }
  12095. ctx.putImageData(chunkImgData, 0, i * FULL_CHUNK_HEIGHT);
  12096. }
  12097. }
  12098. function copyCtxState(sourceCtx, destCtx) {
  12099. var properties = ['strokeStyle', 'fillStyle', 'fillRule', 'globalAlpha', 'lineWidth', 'lineCap', 'lineJoin', 'miterLimit', 'globalCompositeOperation', 'font'];
  12100. for (var i = 0, ii = properties.length; i < ii; i++) {
  12101. var property = properties[i];
  12102. if (sourceCtx[property] !== undefined) {
  12103. destCtx[property] = sourceCtx[property];
  12104. }
  12105. }
  12106. if (sourceCtx.setLineDash !== undefined) {
  12107. destCtx.setLineDash(sourceCtx.getLineDash());
  12108. destCtx.lineDashOffset = sourceCtx.lineDashOffset;
  12109. }
  12110. }
  12111. function resetCtxToDefault(ctx) {
  12112. ctx.strokeStyle = '#000000';
  12113. ctx.fillStyle = '#000000';
  12114. ctx.fillRule = 'nonzero';
  12115. ctx.globalAlpha = 1;
  12116. ctx.lineWidth = 1;
  12117. ctx.lineCap = 'butt';
  12118. ctx.lineJoin = 'miter';
  12119. ctx.miterLimit = 10;
  12120. ctx.globalCompositeOperation = 'source-over';
  12121. ctx.font = '10px sans-serif';
  12122. if (ctx.setLineDash !== undefined) {
  12123. ctx.setLineDash([]);
  12124. ctx.lineDashOffset = 0;
  12125. }
  12126. }
  12127. function composeSMaskBackdrop(bytes, r0, g0, b0) {
  12128. var length = bytes.length;
  12129. for (var i = 3; i < length; i += 4) {
  12130. var alpha = bytes[i];
  12131. if (alpha === 0) {
  12132. bytes[i - 3] = r0;
  12133. bytes[i - 2] = g0;
  12134. bytes[i - 1] = b0;
  12135. } else if (alpha < 255) {
  12136. var alpha_ = 255 - alpha;
  12137. bytes[i - 3] = bytes[i - 3] * alpha + r0 * alpha_ >> 8;
  12138. bytes[i - 2] = bytes[i - 2] * alpha + g0 * alpha_ >> 8;
  12139. bytes[i - 1] = bytes[i - 1] * alpha + b0 * alpha_ >> 8;
  12140. }
  12141. }
  12142. }
  12143. function composeSMaskAlpha(maskData, layerData, transferMap) {
  12144. var length = maskData.length;
  12145. var scale = 1 / 255;
  12146. for (var i = 3; i < length; i += 4) {
  12147. var alpha = transferMap ? transferMap[maskData[i]] : maskData[i];
  12148. layerData[i] = layerData[i] * alpha * scale | 0;
  12149. }
  12150. }
  12151. function composeSMaskLuminosity(maskData, layerData, transferMap) {
  12152. var length = maskData.length;
  12153. for (var i = 3; i < length; i += 4) {
  12154. var y = maskData[i - 3] * 77 + maskData[i - 2] * 152 + maskData[i - 1] * 28;
  12155. layerData[i] = transferMap ? layerData[i] * transferMap[y >> 8] >> 8 : layerData[i] * y >> 16;
  12156. }
  12157. }
  12158. function genericComposeSMask(maskCtx, layerCtx, width, height, subtype, backdrop, transferMap) {
  12159. var hasBackdrop = !!backdrop;
  12160. var r0 = hasBackdrop ? backdrop[0] : 0;
  12161. var g0 = hasBackdrop ? backdrop[1] : 0;
  12162. var b0 = hasBackdrop ? backdrop[2] : 0;
  12163. var composeFn;
  12164. if (subtype === 'Luminosity') {
  12165. composeFn = composeSMaskLuminosity;
  12166. } else {
  12167. composeFn = composeSMaskAlpha;
  12168. }
  12169. var PIXELS_TO_PROCESS = 1048576;
  12170. var chunkSize = Math.min(height, Math.ceil(PIXELS_TO_PROCESS / width));
  12171. for (var row = 0; row < height; row += chunkSize) {
  12172. var chunkHeight = Math.min(chunkSize, height - row);
  12173. var maskData = maskCtx.getImageData(0, row, width, chunkHeight);
  12174. var layerData = layerCtx.getImageData(0, row, width, chunkHeight);
  12175. if (hasBackdrop) {
  12176. composeSMaskBackdrop(maskData.data, r0, g0, b0);
  12177. }
  12178. composeFn(maskData.data, layerData.data, transferMap);
  12179. maskCtx.putImageData(layerData, 0, row);
  12180. }
  12181. }
  12182. function composeSMask(ctx, smask, layerCtx) {
  12183. var mask = smask.canvas;
  12184. var maskCtx = smask.context;
  12185. ctx.setTransform(smask.scaleX, 0, 0, smask.scaleY, smask.offsetX, smask.offsetY);
  12186. var backdrop = smask.backdrop || null;
  12187. if (!smask.transferMap && _webgl.WebGLUtils.isEnabled) {
  12188. var composed = _webgl.WebGLUtils.composeSMask(layerCtx.canvas, mask, {
  12189. subtype: smask.subtype,
  12190. backdrop: backdrop
  12191. });
  12192. ctx.setTransform(1, 0, 0, 1, 0, 0);
  12193. ctx.drawImage(composed, smask.offsetX, smask.offsetY);
  12194. return;
  12195. }
  12196. genericComposeSMask(maskCtx, layerCtx, mask.width, mask.height, smask.subtype, backdrop, smask.transferMap);
  12197. ctx.drawImage(mask, 0, 0);
  12198. }
  12199. var LINE_CAP_STYLES = ['butt', 'round', 'square'];
  12200. var LINE_JOIN_STYLES = ['miter', 'round', 'bevel'];
  12201. var NORMAL_CLIP = {};
  12202. var EO_CLIP = {};
  12203. CanvasGraphics.prototype = {
  12204. beginDrawing: function beginDrawing(_ref) {
  12205. var transform = _ref.transform,
  12206. viewport = _ref.viewport,
  12207. transparency = _ref.transparency,
  12208. _ref$background = _ref.background,
  12209. background = _ref$background === undefined ? null : _ref$background;
  12210. var width = this.ctx.canvas.width;
  12211. var height = this.ctx.canvas.height;
  12212. this.ctx.save();
  12213. this.ctx.fillStyle = background || 'rgb(255, 255, 255)';
  12214. this.ctx.fillRect(0, 0, width, height);
  12215. this.ctx.restore();
  12216. if (transparency) {
  12217. var transparentCanvas = this.cachedCanvases.getCanvas('transparent', width, height, true);
  12218. this.compositeCtx = this.ctx;
  12219. this.transparentCanvas = transparentCanvas.canvas;
  12220. this.ctx = transparentCanvas.context;
  12221. this.ctx.save();
  12222. this.ctx.transform.apply(this.ctx, this.compositeCtx.mozCurrentTransform);
  12223. }
  12224. this.ctx.save();
  12225. resetCtxToDefault(this.ctx);
  12226. if (transform) {
  12227. this.ctx.transform.apply(this.ctx, transform);
  12228. }
  12229. this.ctx.transform.apply(this.ctx, viewport.transform);
  12230. this.baseTransform = this.ctx.mozCurrentTransform.slice();
  12231. if (this.imageLayer) {
  12232. this.imageLayer.beginLayout();
  12233. }
  12234. },
  12235. executeOperatorList: function CanvasGraphics_executeOperatorList(operatorList, executionStartIdx, continueCallback, stepper) {
  12236. var argsArray = operatorList.argsArray;
  12237. var fnArray = operatorList.fnArray;
  12238. var i = executionStartIdx || 0;
  12239. var argsArrayLen = argsArray.length;
  12240. if (argsArrayLen === i) {
  12241. return i;
  12242. }
  12243. var chunkOperations = argsArrayLen - i > EXECUTION_STEPS && typeof continueCallback === 'function';
  12244. var endTime = chunkOperations ? Date.now() + EXECUTION_TIME : 0;
  12245. var steps = 0;
  12246. var commonObjs = this.commonObjs;
  12247. var objs = this.objs;
  12248. var fnId;
  12249. while (true) {
  12250. if (stepper !== undefined && i === stepper.nextBreakPoint) {
  12251. stepper.breakIt(i, continueCallback);
  12252. return i;
  12253. }
  12254. fnId = fnArray[i];
  12255. if (fnId !== _util.OPS.dependency) {
  12256. this[fnId].apply(this, argsArray[i]);
  12257. } else {
  12258. var deps = argsArray[i];
  12259. for (var n = 0, nn = deps.length; n < nn; n++) {
  12260. var depObjId = deps[n];
  12261. var common = depObjId[0] === 'g' && depObjId[1] === '_';
  12262. var objsPool = common ? commonObjs : objs;
  12263. if (!objsPool.isResolved(depObjId)) {
  12264. objsPool.get(depObjId, continueCallback);
  12265. return i;
  12266. }
  12267. }
  12268. }
  12269. i++;
  12270. if (i === argsArrayLen) {
  12271. return i;
  12272. }
  12273. if (chunkOperations && ++steps > EXECUTION_STEPS) {
  12274. if (Date.now() > endTime) {
  12275. continueCallback();
  12276. return i;
  12277. }
  12278. steps = 0;
  12279. }
  12280. }
  12281. },
  12282. endDrawing: function CanvasGraphics_endDrawing() {
  12283. if (this.current.activeSMask !== null) {
  12284. this.endSMaskGroup();
  12285. }
  12286. this.ctx.restore();
  12287. if (this.transparentCanvas) {
  12288. this.ctx = this.compositeCtx;
  12289. this.ctx.save();
  12290. this.ctx.setTransform(1, 0, 0, 1, 0, 0);
  12291. this.ctx.drawImage(this.transparentCanvas, 0, 0);
  12292. this.ctx.restore();
  12293. this.transparentCanvas = null;
  12294. }
  12295. this.cachedCanvases.clear();
  12296. _webgl.WebGLUtils.clear();
  12297. if (this.imageLayer) {
  12298. this.imageLayer.endLayout();
  12299. }
  12300. },
  12301. setLineWidth: function CanvasGraphics_setLineWidth(width) {
  12302. this.current.lineWidth = width;
  12303. this.ctx.lineWidth = width;
  12304. },
  12305. setLineCap: function CanvasGraphics_setLineCap(style) {
  12306. this.ctx.lineCap = LINE_CAP_STYLES[style];
  12307. },
  12308. setLineJoin: function CanvasGraphics_setLineJoin(style) {
  12309. this.ctx.lineJoin = LINE_JOIN_STYLES[style];
  12310. },
  12311. setMiterLimit: function CanvasGraphics_setMiterLimit(limit) {
  12312. this.ctx.miterLimit = limit;
  12313. },
  12314. setDash: function CanvasGraphics_setDash(dashArray, dashPhase) {
  12315. var ctx = this.ctx;
  12316. if (ctx.setLineDash !== undefined) {
  12317. ctx.setLineDash(dashArray);
  12318. ctx.lineDashOffset = dashPhase;
  12319. }
  12320. },
  12321. setRenderingIntent: function CanvasGraphics_setRenderingIntent(intent) {},
  12322. setFlatness: function CanvasGraphics_setFlatness(flatness) {},
  12323. setGState: function CanvasGraphics_setGState(states) {
  12324. for (var i = 0, ii = states.length; i < ii; i++) {
  12325. var state = states[i];
  12326. var key = state[0];
  12327. var value = state[1];
  12328. switch (key) {
  12329. case 'LW':
  12330. this.setLineWidth(value);
  12331. break;
  12332. case 'LC':
  12333. this.setLineCap(value);
  12334. break;
  12335. case 'LJ':
  12336. this.setLineJoin(value);
  12337. break;
  12338. case 'ML':
  12339. this.setMiterLimit(value);
  12340. break;
  12341. case 'D':
  12342. this.setDash(value[0], value[1]);
  12343. break;
  12344. case 'RI':
  12345. this.setRenderingIntent(value);
  12346. break;
  12347. case 'FL':
  12348. this.setFlatness(value);
  12349. break;
  12350. case 'Font':
  12351. this.setFont(value[0], value[1]);
  12352. break;
  12353. case 'CA':
  12354. this.current.strokeAlpha = state[1];
  12355. break;
  12356. case 'ca':
  12357. this.current.fillAlpha = state[1];
  12358. this.ctx.globalAlpha = state[1];
  12359. break;
  12360. case 'BM':
  12361. this.ctx.globalCompositeOperation = value;
  12362. break;
  12363. case 'SMask':
  12364. if (this.current.activeSMask) {
  12365. if (this.stateStack.length > 0 && this.stateStack[this.stateStack.length - 1].activeSMask === this.current.activeSMask) {
  12366. this.suspendSMaskGroup();
  12367. } else {
  12368. this.endSMaskGroup();
  12369. }
  12370. }
  12371. this.current.activeSMask = value ? this.tempSMask : null;
  12372. if (this.current.activeSMask) {
  12373. this.beginSMaskGroup();
  12374. }
  12375. this.tempSMask = null;
  12376. break;
  12377. }
  12378. }
  12379. },
  12380. beginSMaskGroup: function CanvasGraphics_beginSMaskGroup() {
  12381. var activeSMask = this.current.activeSMask;
  12382. var drawnWidth = activeSMask.canvas.width;
  12383. var drawnHeight = activeSMask.canvas.height;
  12384. var cacheId = 'smaskGroupAt' + this.groupLevel;
  12385. var scratchCanvas = this.cachedCanvases.getCanvas(cacheId, drawnWidth, drawnHeight, true);
  12386. var currentCtx = this.ctx;
  12387. var currentTransform = currentCtx.mozCurrentTransform;
  12388. this.ctx.save();
  12389. var groupCtx = scratchCanvas.context;
  12390. groupCtx.scale(1 / activeSMask.scaleX, 1 / activeSMask.scaleY);
  12391. groupCtx.translate(-activeSMask.offsetX, -activeSMask.offsetY);
  12392. groupCtx.transform.apply(groupCtx, currentTransform);
  12393. activeSMask.startTransformInverse = groupCtx.mozCurrentTransformInverse;
  12394. copyCtxState(currentCtx, groupCtx);
  12395. this.ctx = groupCtx;
  12396. this.setGState([['BM', 'source-over'], ['ca', 1], ['CA', 1]]);
  12397. this.groupStack.push(currentCtx);
  12398. this.groupLevel++;
  12399. },
  12400. suspendSMaskGroup: function CanvasGraphics_endSMaskGroup() {
  12401. var groupCtx = this.ctx;
  12402. this.groupLevel--;
  12403. this.ctx = this.groupStack.pop();
  12404. composeSMask(this.ctx, this.current.activeSMask, groupCtx);
  12405. this.ctx.restore();
  12406. this.ctx.save();
  12407. copyCtxState(groupCtx, this.ctx);
  12408. this.current.resumeSMaskCtx = groupCtx;
  12409. var deltaTransform = _util.Util.transform(this.current.activeSMask.startTransformInverse, groupCtx.mozCurrentTransform);
  12410. this.ctx.transform.apply(this.ctx, deltaTransform);
  12411. groupCtx.save();
  12412. groupCtx.setTransform(1, 0, 0, 1, 0, 0);
  12413. groupCtx.clearRect(0, 0, groupCtx.canvas.width, groupCtx.canvas.height);
  12414. groupCtx.restore();
  12415. },
  12416. resumeSMaskGroup: function CanvasGraphics_endSMaskGroup() {
  12417. var groupCtx = this.current.resumeSMaskCtx;
  12418. var currentCtx = this.ctx;
  12419. this.ctx = groupCtx;
  12420. this.groupStack.push(currentCtx);
  12421. this.groupLevel++;
  12422. },
  12423. endSMaskGroup: function CanvasGraphics_endSMaskGroup() {
  12424. var groupCtx = this.ctx;
  12425. this.groupLevel--;
  12426. this.ctx = this.groupStack.pop();
  12427. composeSMask(this.ctx, this.current.activeSMask, groupCtx);
  12428. this.ctx.restore();
  12429. copyCtxState(groupCtx, this.ctx);
  12430. var deltaTransform = _util.Util.transform(this.current.activeSMask.startTransformInverse, groupCtx.mozCurrentTransform);
  12431. this.ctx.transform.apply(this.ctx, deltaTransform);
  12432. },
  12433. save: function CanvasGraphics_save() {
  12434. this.ctx.save();
  12435. var old = this.current;
  12436. this.stateStack.push(old);
  12437. this.current = old.clone();
  12438. this.current.resumeSMaskCtx = null;
  12439. },
  12440. restore: function CanvasGraphics_restore() {
  12441. if (this.current.resumeSMaskCtx) {
  12442. this.resumeSMaskGroup();
  12443. }
  12444. if (this.current.activeSMask !== null && (this.stateStack.length === 0 || this.stateStack[this.stateStack.length - 1].activeSMask !== this.current.activeSMask)) {
  12445. this.endSMaskGroup();
  12446. }
  12447. if (this.stateStack.length !== 0) {
  12448. this.current = this.stateStack.pop();
  12449. this.ctx.restore();
  12450. this.pendingClip = null;
  12451. this.cachedGetSinglePixelWidth = null;
  12452. }
  12453. },
  12454. transform: function CanvasGraphics_transform(a, b, c, d, e, f) {
  12455. this.ctx.transform(a, b, c, d, e, f);
  12456. this.cachedGetSinglePixelWidth = null;
  12457. },
  12458. constructPath: function CanvasGraphics_constructPath(ops, args) {
  12459. var ctx = this.ctx;
  12460. var current = this.current;
  12461. var x = current.x,
  12462. y = current.y;
  12463. for (var i = 0, j = 0, ii = ops.length; i < ii; i++) {
  12464. switch (ops[i] | 0) {
  12465. case _util.OPS.rectangle:
  12466. x = args[j++];
  12467. y = args[j++];
  12468. var width = args[j++];
  12469. var height = args[j++];
  12470. if (width === 0) {
  12471. width = this.getSinglePixelWidth();
  12472. }
  12473. if (height === 0) {
  12474. height = this.getSinglePixelWidth();
  12475. }
  12476. var xw = x + width;
  12477. var yh = y + height;
  12478. this.ctx.moveTo(x, y);
  12479. this.ctx.lineTo(xw, y);
  12480. this.ctx.lineTo(xw, yh);
  12481. this.ctx.lineTo(x, yh);
  12482. this.ctx.lineTo(x, y);
  12483. this.ctx.closePath();
  12484. break;
  12485. case _util.OPS.moveTo:
  12486. x = args[j++];
  12487. y = args[j++];
  12488. ctx.moveTo(x, y);
  12489. break;
  12490. case _util.OPS.lineTo:
  12491. x = args[j++];
  12492. y = args[j++];
  12493. ctx.lineTo(x, y);
  12494. break;
  12495. case _util.OPS.curveTo:
  12496. x = args[j + 4];
  12497. y = args[j + 5];
  12498. ctx.bezierCurveTo(args[j], args[j + 1], args[j + 2], args[j + 3], x, y);
  12499. j += 6;
  12500. break;
  12501. case _util.OPS.curveTo2:
  12502. ctx.bezierCurveTo(x, y, args[j], args[j + 1], args[j + 2], args[j + 3]);
  12503. x = args[j + 2];
  12504. y = args[j + 3];
  12505. j += 4;
  12506. break;
  12507. case _util.OPS.curveTo3:
  12508. x = args[j + 2];
  12509. y = args[j + 3];
  12510. ctx.bezierCurveTo(args[j], args[j + 1], x, y, x, y);
  12511. j += 4;
  12512. break;
  12513. case _util.OPS.closePath:
  12514. ctx.closePath();
  12515. break;
  12516. }
  12517. }
  12518. current.setCurrentPoint(x, y);
  12519. },
  12520. closePath: function CanvasGraphics_closePath() {
  12521. this.ctx.closePath();
  12522. },
  12523. stroke: function CanvasGraphics_stroke(consumePath) {
  12524. consumePath = typeof consumePath !== 'undefined' ? consumePath : true;
  12525. var ctx = this.ctx;
  12526. var strokeColor = this.current.strokeColor;
  12527. ctx.lineWidth = Math.max(this.getSinglePixelWidth() * MIN_WIDTH_FACTOR, this.current.lineWidth);
  12528. ctx.globalAlpha = this.current.strokeAlpha;
  12529. if (strokeColor && strokeColor.hasOwnProperty('type') && strokeColor.type === 'Pattern') {
  12530. ctx.save();
  12531. ctx.strokeStyle = strokeColor.getPattern(ctx, this);
  12532. ctx.stroke();
  12533. ctx.restore();
  12534. } else {
  12535. ctx.stroke();
  12536. }
  12537. if (consumePath) {
  12538. this.consumePath();
  12539. }
  12540. ctx.globalAlpha = this.current.fillAlpha;
  12541. },
  12542. closeStroke: function CanvasGraphics_closeStroke() {
  12543. this.closePath();
  12544. this.stroke();
  12545. },
  12546. fill: function CanvasGraphics_fill(consumePath) {
  12547. consumePath = typeof consumePath !== 'undefined' ? consumePath : true;
  12548. var ctx = this.ctx;
  12549. var fillColor = this.current.fillColor;
  12550. var isPatternFill = this.current.patternFill;
  12551. var needRestore = false;
  12552. if (isPatternFill) {
  12553. ctx.save();
  12554. if (this.baseTransform) {
  12555. ctx.setTransform.apply(ctx, this.baseTransform);
  12556. }
  12557. ctx.fillStyle = fillColor.getPattern(ctx, this);
  12558. needRestore = true;
  12559. }
  12560. if (this.pendingEOFill) {
  12561. ctx.fill('evenodd');
  12562. this.pendingEOFill = false;
  12563. } else {
  12564. ctx.fill();
  12565. }
  12566. if (needRestore) {
  12567. ctx.restore();
  12568. }
  12569. if (consumePath) {
  12570. this.consumePath();
  12571. }
  12572. },
  12573. eoFill: function CanvasGraphics_eoFill() {
  12574. this.pendingEOFill = true;
  12575. this.fill();
  12576. },
  12577. fillStroke: function CanvasGraphics_fillStroke() {
  12578. this.fill(false);
  12579. this.stroke(false);
  12580. this.consumePath();
  12581. },
  12582. eoFillStroke: function CanvasGraphics_eoFillStroke() {
  12583. this.pendingEOFill = true;
  12584. this.fillStroke();
  12585. },
  12586. closeFillStroke: function CanvasGraphics_closeFillStroke() {
  12587. this.closePath();
  12588. this.fillStroke();
  12589. },
  12590. closeEOFillStroke: function CanvasGraphics_closeEOFillStroke() {
  12591. this.pendingEOFill = true;
  12592. this.closePath();
  12593. this.fillStroke();
  12594. },
  12595. endPath: function CanvasGraphics_endPath() {
  12596. this.consumePath();
  12597. },
  12598. clip: function CanvasGraphics_clip() {
  12599. this.pendingClip = NORMAL_CLIP;
  12600. },
  12601. eoClip: function CanvasGraphics_eoClip() {
  12602. this.pendingClip = EO_CLIP;
  12603. },
  12604. beginText: function CanvasGraphics_beginText() {
  12605. this.current.textMatrix = _util.IDENTITY_MATRIX;
  12606. this.current.textMatrixScale = 1;
  12607. this.current.x = this.current.lineX = 0;
  12608. this.current.y = this.current.lineY = 0;
  12609. },
  12610. endText: function CanvasGraphics_endText() {
  12611. var paths = this.pendingTextPaths;
  12612. var ctx = this.ctx;
  12613. if (paths === undefined) {
  12614. ctx.beginPath();
  12615. return;
  12616. }
  12617. ctx.save();
  12618. ctx.beginPath();
  12619. for (var i = 0; i < paths.length; i++) {
  12620. var path = paths[i];
  12621. ctx.setTransform.apply(ctx, path.transform);
  12622. ctx.translate(path.x, path.y);
  12623. path.addToPath(ctx, path.fontSize);
  12624. }
  12625. ctx.restore();
  12626. ctx.clip();
  12627. ctx.beginPath();
  12628. delete this.pendingTextPaths;
  12629. },
  12630. setCharSpacing: function CanvasGraphics_setCharSpacing(spacing) {
  12631. this.current.charSpacing = spacing;
  12632. },
  12633. setWordSpacing: function CanvasGraphics_setWordSpacing(spacing) {
  12634. this.current.wordSpacing = spacing;
  12635. },
  12636. setHScale: function CanvasGraphics_setHScale(scale) {
  12637. this.current.textHScale = scale / 100;
  12638. },
  12639. setLeading: function CanvasGraphics_setLeading(leading) {
  12640. this.current.leading = -leading;
  12641. },
  12642. setFont: function CanvasGraphics_setFont(fontRefName, size) {
  12643. var fontObj = this.commonObjs.get(fontRefName);
  12644. var current = this.current;
  12645. if (!fontObj) {
  12646. throw new Error('Can\'t find font for ' + fontRefName);
  12647. }
  12648. current.fontMatrix = fontObj.fontMatrix ? fontObj.fontMatrix : _util.FONT_IDENTITY_MATRIX;
  12649. if (current.fontMatrix[0] === 0 || current.fontMatrix[3] === 0) {
  12650. (0, _util.warn)('Invalid font matrix for font ' + fontRefName);
  12651. }
  12652. if (size < 0) {
  12653. size = -size;
  12654. current.fontDirection = -1;
  12655. } else {
  12656. current.fontDirection = 1;
  12657. }
  12658. this.current.font = fontObj;
  12659. this.current.fontSize = size;
  12660. if (fontObj.isType3Font) {
  12661. return;
  12662. }
  12663. var name = fontObj.loadedName || 'sans-serif';
  12664. var bold = fontObj.black ? '900' : fontObj.bold ? 'bold' : 'normal';
  12665. var italic = fontObj.italic ? 'italic' : 'normal';
  12666. var typeface = '"' + name + '", ' + fontObj.fallbackName;
  12667. var browserFontSize = size < MIN_FONT_SIZE ? MIN_FONT_SIZE : size > MAX_FONT_SIZE ? MAX_FONT_SIZE : size;
  12668. this.current.fontSizeScale = size / browserFontSize;
  12669. var rule = italic + ' ' + bold + ' ' + browserFontSize + 'px ' + typeface;
  12670. this.ctx.font = rule;
  12671. },
  12672. setTextRenderingMode: function CanvasGraphics_setTextRenderingMode(mode) {
  12673. this.current.textRenderingMode = mode;
  12674. },
  12675. setTextRise: function CanvasGraphics_setTextRise(rise) {
  12676. this.current.textRise = rise;
  12677. },
  12678. moveText: function CanvasGraphics_moveText(x, y) {
  12679. this.current.x = this.current.lineX += x;
  12680. this.current.y = this.current.lineY += y;
  12681. },
  12682. setLeadingMoveText: function CanvasGraphics_setLeadingMoveText(x, y) {
  12683. this.setLeading(-y);
  12684. this.moveText(x, y);
  12685. },
  12686. setTextMatrix: function CanvasGraphics_setTextMatrix(a, b, c, d, e, f) {
  12687. this.current.textMatrix = [a, b, c, d, e, f];
  12688. this.current.textMatrixScale = Math.sqrt(a * a + b * b);
  12689. this.current.x = this.current.lineX = 0;
  12690. this.current.y = this.current.lineY = 0;
  12691. },
  12692. nextLine: function CanvasGraphics_nextLine() {
  12693. this.moveText(0, this.current.leading);
  12694. },
  12695. paintChar: function CanvasGraphics_paintChar(character, x, y) {
  12696. var ctx = this.ctx;
  12697. var current = this.current;
  12698. var font = current.font;
  12699. var textRenderingMode = current.textRenderingMode;
  12700. var fontSize = current.fontSize / current.fontSizeScale;
  12701. var fillStrokeMode = textRenderingMode & _util.TextRenderingMode.FILL_STROKE_MASK;
  12702. var isAddToPathSet = !!(textRenderingMode & _util.TextRenderingMode.ADD_TO_PATH_FLAG);
  12703. var addToPath;
  12704. if (font.disableFontFace || isAddToPathSet) {
  12705. addToPath = font.getPathGenerator(this.commonObjs, character);
  12706. }
  12707. if (font.disableFontFace) {
  12708. ctx.save();
  12709. ctx.translate(x, y);
  12710. ctx.beginPath();
  12711. addToPath(ctx, fontSize);
  12712. if (fillStrokeMode === _util.TextRenderingMode.FILL || fillStrokeMode === _util.TextRenderingMode.FILL_STROKE) {
  12713. ctx.fill();
  12714. }
  12715. if (fillStrokeMode === _util.TextRenderingMode.STROKE || fillStrokeMode === _util.TextRenderingMode.FILL_STROKE) {
  12716. ctx.stroke();
  12717. }
  12718. ctx.restore();
  12719. } else {
  12720. if (fillStrokeMode === _util.TextRenderingMode.FILL || fillStrokeMode === _util.TextRenderingMode.FILL_STROKE) {
  12721. ctx.fillText(character, x, y);
  12722. }
  12723. if (fillStrokeMode === _util.TextRenderingMode.STROKE || fillStrokeMode === _util.TextRenderingMode.FILL_STROKE) {
  12724. ctx.strokeText(character, x, y);
  12725. }
  12726. }
  12727. if (isAddToPathSet) {
  12728. var paths = this.pendingTextPaths || (this.pendingTextPaths = []);
  12729. paths.push({
  12730. transform: ctx.mozCurrentTransform,
  12731. x: x,
  12732. y: y,
  12733. fontSize: fontSize,
  12734. addToPath: addToPath
  12735. });
  12736. }
  12737. },
  12738. get isFontSubpixelAAEnabled() {
  12739. var ctx = this.canvasFactory.create(10, 10).context;
  12740. ctx.scale(1.5, 1);
  12741. ctx.fillText('I', 0, 10);
  12742. var data = ctx.getImageData(0, 0, 10, 10).data;
  12743. var enabled = false;
  12744. for (var i = 3; i < data.length; i += 4) {
  12745. if (data[i] > 0 && data[i] < 255) {
  12746. enabled = true;
  12747. break;
  12748. }
  12749. }
  12750. return (0, _util.shadow)(this, 'isFontSubpixelAAEnabled', enabled);
  12751. },
  12752. showText: function CanvasGraphics_showText(glyphs) {
  12753. var current = this.current;
  12754. var font = current.font;
  12755. if (font.isType3Font) {
  12756. return this.showType3Text(glyphs);
  12757. }
  12758. var fontSize = current.fontSize;
  12759. if (fontSize === 0) {
  12760. return;
  12761. }
  12762. var ctx = this.ctx;
  12763. var fontSizeScale = current.fontSizeScale;
  12764. var charSpacing = current.charSpacing;
  12765. var wordSpacing = current.wordSpacing;
  12766. var fontDirection = current.fontDirection;
  12767. var textHScale = current.textHScale * fontDirection;
  12768. var glyphsLength = glyphs.length;
  12769. var vertical = font.vertical;
  12770. var spacingDir = vertical ? 1 : -1;
  12771. var defaultVMetrics = font.defaultVMetrics;
  12772. var widthAdvanceScale = fontSize * current.fontMatrix[0];
  12773. var simpleFillText = current.textRenderingMode === _util.TextRenderingMode.FILL && !font.disableFontFace;
  12774. ctx.save();
  12775. ctx.transform.apply(ctx, current.textMatrix);
  12776. ctx.translate(current.x, current.y + current.textRise);
  12777. if (current.patternFill) {
  12778. ctx.fillStyle = current.fillColor.getPattern(ctx, this);
  12779. }
  12780. if (fontDirection > 0) {
  12781. ctx.scale(textHScale, -1);
  12782. } else {
  12783. ctx.scale(textHScale, 1);
  12784. }
  12785. var lineWidth = current.lineWidth;
  12786. var scale = current.textMatrixScale;
  12787. if (scale === 0 || lineWidth === 0) {
  12788. var fillStrokeMode = current.textRenderingMode & _util.TextRenderingMode.FILL_STROKE_MASK;
  12789. if (fillStrokeMode === _util.TextRenderingMode.STROKE || fillStrokeMode === _util.TextRenderingMode.FILL_STROKE) {
  12790. this.cachedGetSinglePixelWidth = null;
  12791. lineWidth = this.getSinglePixelWidth() * MIN_WIDTH_FACTOR;
  12792. }
  12793. } else {
  12794. lineWidth /= scale;
  12795. }
  12796. if (fontSizeScale !== 1.0) {
  12797. ctx.scale(fontSizeScale, fontSizeScale);
  12798. lineWidth /= fontSizeScale;
  12799. }
  12800. ctx.lineWidth = lineWidth;
  12801. var x = 0,
  12802. i;
  12803. for (i = 0; i < glyphsLength; ++i) {
  12804. var glyph = glyphs[i];
  12805. if ((0, _util.isNum)(glyph)) {
  12806. x += spacingDir * glyph * fontSize / 1000;
  12807. continue;
  12808. }
  12809. var restoreNeeded = false;
  12810. var spacing = (glyph.isSpace ? wordSpacing : 0) + charSpacing;
  12811. var character = glyph.fontChar;
  12812. var accent = glyph.accent;
  12813. var scaledX, scaledY, scaledAccentX, scaledAccentY;
  12814. var width = glyph.width;
  12815. if (vertical) {
  12816. var vmetric, vx, vy;
  12817. vmetric = glyph.vmetric || defaultVMetrics;
  12818. vx = glyph.vmetric ? vmetric[1] : width * 0.5;
  12819. vx = -vx * widthAdvanceScale;
  12820. vy = vmetric[2] * widthAdvanceScale;
  12821. width = vmetric ? -vmetric[0] : width;
  12822. scaledX = vx / fontSizeScale;
  12823. scaledY = (x + vy) / fontSizeScale;
  12824. } else {
  12825. scaledX = x / fontSizeScale;
  12826. scaledY = 0;
  12827. }
  12828. if (font.remeasure && width > 0) {
  12829. var measuredWidth = ctx.measureText(character).width * 1000 / fontSize * fontSizeScale;
  12830. if (width < measuredWidth && this.isFontSubpixelAAEnabled) {
  12831. var characterScaleX = width / measuredWidth;
  12832. restoreNeeded = true;
  12833. ctx.save();
  12834. ctx.scale(characterScaleX, 1);
  12835. scaledX /= characterScaleX;
  12836. } else if (width !== measuredWidth) {
  12837. scaledX += (width - measuredWidth) / 2000 * fontSize / fontSizeScale;
  12838. }
  12839. }
  12840. if (glyph.isInFont || font.missingFile) {
  12841. if (simpleFillText && !accent) {
  12842. ctx.fillText(character, scaledX, scaledY);
  12843. } else {
  12844. this.paintChar(character, scaledX, scaledY);
  12845. if (accent) {
  12846. scaledAccentX = scaledX + accent.offset.x / fontSizeScale;
  12847. scaledAccentY = scaledY - accent.offset.y / fontSizeScale;
  12848. this.paintChar(accent.fontChar, scaledAccentX, scaledAccentY);
  12849. }
  12850. }
  12851. }
  12852. var charWidth = width * widthAdvanceScale + spacing * fontDirection;
  12853. x += charWidth;
  12854. if (restoreNeeded) {
  12855. ctx.restore();
  12856. }
  12857. }
  12858. if (vertical) {
  12859. current.y -= x * textHScale;
  12860. } else {
  12861. current.x += x * textHScale;
  12862. }
  12863. ctx.restore();
  12864. },
  12865. showType3Text: function CanvasGraphics_showType3Text(glyphs) {
  12866. var ctx = this.ctx;
  12867. var current = this.current;
  12868. var font = current.font;
  12869. var fontSize = current.fontSize;
  12870. var fontDirection = current.fontDirection;
  12871. var spacingDir = font.vertical ? 1 : -1;
  12872. var charSpacing = current.charSpacing;
  12873. var wordSpacing = current.wordSpacing;
  12874. var textHScale = current.textHScale * fontDirection;
  12875. var fontMatrix = current.fontMatrix || _util.FONT_IDENTITY_MATRIX;
  12876. var glyphsLength = glyphs.length;
  12877. var isTextInvisible = current.textRenderingMode === _util.TextRenderingMode.INVISIBLE;
  12878. var i, glyph, width, spacingLength;
  12879. if (isTextInvisible || fontSize === 0) {
  12880. return;
  12881. }
  12882. this.cachedGetSinglePixelWidth = null;
  12883. ctx.save();
  12884. ctx.transform.apply(ctx, current.textMatrix);
  12885. ctx.translate(current.x, current.y);
  12886. ctx.scale(textHScale, fontDirection);
  12887. for (i = 0; i < glyphsLength; ++i) {
  12888. glyph = glyphs[i];
  12889. if ((0, _util.isNum)(glyph)) {
  12890. spacingLength = spacingDir * glyph * fontSize / 1000;
  12891. this.ctx.translate(spacingLength, 0);
  12892. current.x += spacingLength * textHScale;
  12893. continue;
  12894. }
  12895. var spacing = (glyph.isSpace ? wordSpacing : 0) + charSpacing;
  12896. var operatorList = font.charProcOperatorList[glyph.operatorListId];
  12897. if (!operatorList) {
  12898. (0, _util.warn)('Type3 character "' + glyph.operatorListId + '" is not available.');
  12899. continue;
  12900. }
  12901. this.processingType3 = glyph;
  12902. this.save();
  12903. ctx.scale(fontSize, fontSize);
  12904. ctx.transform.apply(ctx, fontMatrix);
  12905. this.executeOperatorList(operatorList);
  12906. this.restore();
  12907. var transformed = _util.Util.applyTransform([glyph.width, 0], fontMatrix);
  12908. width = transformed[0] * fontSize + spacing;
  12909. ctx.translate(width, 0);
  12910. current.x += width * textHScale;
  12911. }
  12912. ctx.restore();
  12913. this.processingType3 = null;
  12914. },
  12915. setCharWidth: function CanvasGraphics_setCharWidth(xWidth, yWidth) {},
  12916. setCharWidthAndBounds: function CanvasGraphics_setCharWidthAndBounds(xWidth, yWidth, llx, lly, urx, ury) {
  12917. this.ctx.rect(llx, lly, urx - llx, ury - lly);
  12918. this.clip();
  12919. this.endPath();
  12920. },
  12921. getColorN_Pattern: function CanvasGraphics_getColorN_Pattern(IR) {
  12922. var _this = this;
  12923. var pattern;
  12924. if (IR[0] === 'TilingPattern') {
  12925. var color = IR[1];
  12926. var baseTransform = this.baseTransform || this.ctx.mozCurrentTransform.slice();
  12927. var canvasGraphicsFactory = {
  12928. createCanvasGraphics: function createCanvasGraphics(ctx) {
  12929. return new CanvasGraphics(ctx, _this.commonObjs, _this.objs, _this.canvasFactory);
  12930. }
  12931. };
  12932. pattern = new _pattern_helper.TilingPattern(IR, color, this.ctx, canvasGraphicsFactory, baseTransform);
  12933. } else {
  12934. pattern = (0, _pattern_helper.getShadingPatternFromIR)(IR);
  12935. }
  12936. return pattern;
  12937. },
  12938. setStrokeColorN: function CanvasGraphics_setStrokeColorN() {
  12939. this.current.strokeColor = this.getColorN_Pattern(arguments);
  12940. },
  12941. setFillColorN: function CanvasGraphics_setFillColorN() {
  12942. this.current.fillColor = this.getColorN_Pattern(arguments);
  12943. this.current.patternFill = true;
  12944. },
  12945. setStrokeRGBColor: function CanvasGraphics_setStrokeRGBColor(r, g, b) {
  12946. var color = _util.Util.makeCssRgb(r, g, b);
  12947. this.ctx.strokeStyle = color;
  12948. this.current.strokeColor = color;
  12949. },
  12950. setFillRGBColor: function CanvasGraphics_setFillRGBColor(r, g, b) {
  12951. var color = _util.Util.makeCssRgb(r, g, b);
  12952. this.ctx.fillStyle = color;
  12953. this.current.fillColor = color;
  12954. this.current.patternFill = false;
  12955. },
  12956. shadingFill: function CanvasGraphics_shadingFill(patternIR) {
  12957. var ctx = this.ctx;
  12958. this.save();
  12959. var pattern = (0, _pattern_helper.getShadingPatternFromIR)(patternIR);
  12960. ctx.fillStyle = pattern.getPattern(ctx, this, true);
  12961. var inv = ctx.mozCurrentTransformInverse;
  12962. if (inv) {
  12963. var canvas = ctx.canvas;
  12964. var width = canvas.width;
  12965. var height = canvas.height;
  12966. var bl = _util.Util.applyTransform([0, 0], inv);
  12967. var br = _util.Util.applyTransform([0, height], inv);
  12968. var ul = _util.Util.applyTransform([width, 0], inv);
  12969. var ur = _util.Util.applyTransform([width, height], inv);
  12970. var x0 = Math.min(bl[0], br[0], ul[0], ur[0]);
  12971. var y0 = Math.min(bl[1], br[1], ul[1], ur[1]);
  12972. var x1 = Math.max(bl[0], br[0], ul[0], ur[0]);
  12973. var y1 = Math.max(bl[1], br[1], ul[1], ur[1]);
  12974. this.ctx.fillRect(x0, y0, x1 - x0, y1 - y0);
  12975. } else {
  12976. this.ctx.fillRect(-1e10, -1e10, 2e10, 2e10);
  12977. }
  12978. this.restore();
  12979. },
  12980. beginInlineImage: function CanvasGraphics_beginInlineImage() {
  12981. throw new Error('Should not call beginInlineImage');
  12982. },
  12983. beginImageData: function CanvasGraphics_beginImageData() {
  12984. throw new Error('Should not call beginImageData');
  12985. },
  12986. paintFormXObjectBegin: function CanvasGraphics_paintFormXObjectBegin(matrix, bbox) {
  12987. this.save();
  12988. this.baseTransformStack.push(this.baseTransform);
  12989. if ((0, _util.isArray)(matrix) && matrix.length === 6) {
  12990. this.transform.apply(this, matrix);
  12991. }
  12992. this.baseTransform = this.ctx.mozCurrentTransform;
  12993. if ((0, _util.isArray)(bbox) && bbox.length === 4) {
  12994. var width = bbox[2] - bbox[0];
  12995. var height = bbox[3] - bbox[1];
  12996. this.ctx.rect(bbox[0], bbox[1], width, height);
  12997. this.clip();
  12998. this.endPath();
  12999. }
  13000. },
  13001. paintFormXObjectEnd: function CanvasGraphics_paintFormXObjectEnd() {
  13002. this.restore();
  13003. this.baseTransform = this.baseTransformStack.pop();
  13004. },
  13005. beginGroup: function CanvasGraphics_beginGroup(group) {
  13006. this.save();
  13007. var currentCtx = this.ctx;
  13008. if (!group.isolated) {
  13009. (0, _util.info)('TODO: Support non-isolated groups.');
  13010. }
  13011. if (group.knockout) {
  13012. (0, _util.warn)('Knockout groups not supported.');
  13013. }
  13014. var currentTransform = currentCtx.mozCurrentTransform;
  13015. if (group.matrix) {
  13016. currentCtx.transform.apply(currentCtx, group.matrix);
  13017. }
  13018. if (!group.bbox) {
  13019. throw new Error('Bounding box is required.');
  13020. }
  13021. var bounds = _util.Util.getAxialAlignedBoundingBox(group.bbox, currentCtx.mozCurrentTransform);
  13022. var canvasBounds = [0, 0, currentCtx.canvas.width, currentCtx.canvas.height];
  13023. bounds = _util.Util.intersect(bounds, canvasBounds) || [0, 0, 0, 0];
  13024. var offsetX = Math.floor(bounds[0]);
  13025. var offsetY = Math.floor(bounds[1]);
  13026. var drawnWidth = Math.max(Math.ceil(bounds[2]) - offsetX, 1);
  13027. var drawnHeight = Math.max(Math.ceil(bounds[3]) - offsetY, 1);
  13028. var scaleX = 1,
  13029. scaleY = 1;
  13030. if (drawnWidth > MAX_GROUP_SIZE) {
  13031. scaleX = drawnWidth / MAX_GROUP_SIZE;
  13032. drawnWidth = MAX_GROUP_SIZE;
  13033. }
  13034. if (drawnHeight > MAX_GROUP_SIZE) {
  13035. scaleY = drawnHeight / MAX_GROUP_SIZE;
  13036. drawnHeight = MAX_GROUP_SIZE;
  13037. }
  13038. var cacheId = 'groupAt' + this.groupLevel;
  13039. if (group.smask) {
  13040. cacheId += '_smask_' + this.smaskCounter++ % 2;
  13041. }
  13042. var scratchCanvas = this.cachedCanvases.getCanvas(cacheId, drawnWidth, drawnHeight, true);
  13043. var groupCtx = scratchCanvas.context;
  13044. groupCtx.scale(1 / scaleX, 1 / scaleY);
  13045. groupCtx.translate(-offsetX, -offsetY);
  13046. groupCtx.transform.apply(groupCtx, currentTransform);
  13047. if (group.smask) {
  13048. this.smaskStack.push({
  13049. canvas: scratchCanvas.canvas,
  13050. context: groupCtx,
  13051. offsetX: offsetX,
  13052. offsetY: offsetY,
  13053. scaleX: scaleX,
  13054. scaleY: scaleY,
  13055. subtype: group.smask.subtype,
  13056. backdrop: group.smask.backdrop,
  13057. transferMap: group.smask.transferMap || null,
  13058. startTransformInverse: null
  13059. });
  13060. } else {
  13061. currentCtx.setTransform(1, 0, 0, 1, 0, 0);
  13062. currentCtx.translate(offsetX, offsetY);
  13063. currentCtx.scale(scaleX, scaleY);
  13064. }
  13065. copyCtxState(currentCtx, groupCtx);
  13066. this.ctx = groupCtx;
  13067. this.setGState([['BM', 'source-over'], ['ca', 1], ['CA', 1]]);
  13068. this.groupStack.push(currentCtx);
  13069. this.groupLevel++;
  13070. this.current.activeSMask = null;
  13071. },
  13072. endGroup: function CanvasGraphics_endGroup(group) {
  13073. this.groupLevel--;
  13074. var groupCtx = this.ctx;
  13075. this.ctx = this.groupStack.pop();
  13076. if (this.ctx.imageSmoothingEnabled !== undefined) {
  13077. this.ctx.imageSmoothingEnabled = false;
  13078. } else {
  13079. this.ctx.mozImageSmoothingEnabled = false;
  13080. }
  13081. if (group.smask) {
  13082. this.tempSMask = this.smaskStack.pop();
  13083. } else {
  13084. this.ctx.drawImage(groupCtx.canvas, 0, 0);
  13085. }
  13086. this.restore();
  13087. },
  13088. beginAnnotations: function CanvasGraphics_beginAnnotations() {
  13089. this.save();
  13090. if (this.baseTransform) {
  13091. this.ctx.setTransform.apply(this.ctx, this.baseTransform);
  13092. }
  13093. },
  13094. endAnnotations: function CanvasGraphics_endAnnotations() {
  13095. this.restore();
  13096. },
  13097. beginAnnotation: function CanvasGraphics_beginAnnotation(rect, transform, matrix) {
  13098. this.save();
  13099. resetCtxToDefault(this.ctx);
  13100. this.current = new CanvasExtraState();
  13101. if ((0, _util.isArray)(rect) && rect.length === 4) {
  13102. var width = rect[2] - rect[0];
  13103. var height = rect[3] - rect[1];
  13104. this.ctx.rect(rect[0], rect[1], width, height);
  13105. this.clip();
  13106. this.endPath();
  13107. }
  13108. this.transform.apply(this, transform);
  13109. this.transform.apply(this, matrix);
  13110. },
  13111. endAnnotation: function CanvasGraphics_endAnnotation() {
  13112. this.restore();
  13113. },
  13114. paintJpegXObject: function CanvasGraphics_paintJpegXObject(objId, w, h) {
  13115. var domImage = this.objs.get(objId);
  13116. if (!domImage) {
  13117. (0, _util.warn)('Dependent image isn\'t ready yet');
  13118. return;
  13119. }
  13120. this.save();
  13121. var ctx = this.ctx;
  13122. ctx.scale(1 / w, -1 / h);
  13123. ctx.drawImage(domImage, 0, 0, domImage.width, domImage.height, 0, -h, w, h);
  13124. if (this.imageLayer) {
  13125. var currentTransform = ctx.mozCurrentTransformInverse;
  13126. var position = this.getCanvasPosition(0, 0);
  13127. this.imageLayer.appendImage({
  13128. objId: objId,
  13129. left: position[0],
  13130. top: position[1],
  13131. width: w / currentTransform[0],
  13132. height: h / currentTransform[3]
  13133. });
  13134. }
  13135. this.restore();
  13136. },
  13137. paintImageMaskXObject: function CanvasGraphics_paintImageMaskXObject(img) {
  13138. var ctx = this.ctx;
  13139. var width = img.width,
  13140. height = img.height;
  13141. var fillColor = this.current.fillColor;
  13142. var isPatternFill = this.current.patternFill;
  13143. var glyph = this.processingType3;
  13144. if (COMPILE_TYPE3_GLYPHS && glyph && glyph.compiled === undefined) {
  13145. if (width <= MAX_SIZE_TO_COMPILE && height <= MAX_SIZE_TO_COMPILE) {
  13146. glyph.compiled = compileType3Glyph({
  13147. data: img.data,
  13148. width: width,
  13149. height: height
  13150. });
  13151. } else {
  13152. glyph.compiled = null;
  13153. }
  13154. }
  13155. if (glyph && glyph.compiled) {
  13156. glyph.compiled(ctx);
  13157. return;
  13158. }
  13159. var maskCanvas = this.cachedCanvases.getCanvas('maskCanvas', width, height);
  13160. var maskCtx = maskCanvas.context;
  13161. maskCtx.save();
  13162. putBinaryImageMask(maskCtx, img);
  13163. maskCtx.globalCompositeOperation = 'source-in';
  13164. maskCtx.fillStyle = isPatternFill ? fillColor.getPattern(maskCtx, this) : fillColor;
  13165. maskCtx.fillRect(0, 0, width, height);
  13166. maskCtx.restore();
  13167. this.paintInlineImageXObject(maskCanvas.canvas);
  13168. },
  13169. paintImageMaskXObjectRepeat: function CanvasGraphics_paintImageMaskXObjectRepeat(imgData, scaleX, scaleY, positions) {
  13170. var width = imgData.width;
  13171. var height = imgData.height;
  13172. var fillColor = this.current.fillColor;
  13173. var isPatternFill = this.current.patternFill;
  13174. var maskCanvas = this.cachedCanvases.getCanvas('maskCanvas', width, height);
  13175. var maskCtx = maskCanvas.context;
  13176. maskCtx.save();
  13177. putBinaryImageMask(maskCtx, imgData);
  13178. maskCtx.globalCompositeOperation = 'source-in';
  13179. maskCtx.fillStyle = isPatternFill ? fillColor.getPattern(maskCtx, this) : fillColor;
  13180. maskCtx.fillRect(0, 0, width, height);
  13181. maskCtx.restore();
  13182. var ctx = this.ctx;
  13183. for (var i = 0, ii = positions.length; i < ii; i += 2) {
  13184. ctx.save();
  13185. ctx.transform(scaleX, 0, 0, scaleY, positions[i], positions[i + 1]);
  13186. ctx.scale(1, -1);
  13187. ctx.drawImage(maskCanvas.canvas, 0, 0, width, height, 0, -1, 1, 1);
  13188. ctx.restore();
  13189. }
  13190. },
  13191. paintImageMaskXObjectGroup: function CanvasGraphics_paintImageMaskXObjectGroup(images) {
  13192. var ctx = this.ctx;
  13193. var fillColor = this.current.fillColor;
  13194. var isPatternFill = this.current.patternFill;
  13195. for (var i = 0, ii = images.length; i < ii; i++) {
  13196. var image = images[i];
  13197. var width = image.width,
  13198. height = image.height;
  13199. var maskCanvas = this.cachedCanvases.getCanvas('maskCanvas', width, height);
  13200. var maskCtx = maskCanvas.context;
  13201. maskCtx.save();
  13202. putBinaryImageMask(maskCtx, image);
  13203. maskCtx.globalCompositeOperation = 'source-in';
  13204. maskCtx.fillStyle = isPatternFill ? fillColor.getPattern(maskCtx, this) : fillColor;
  13205. maskCtx.fillRect(0, 0, width, height);
  13206. maskCtx.restore();
  13207. ctx.save();
  13208. ctx.transform.apply(ctx, image.transform);
  13209. ctx.scale(1, -1);
  13210. ctx.drawImage(maskCanvas.canvas, 0, 0, width, height, 0, -1, 1, 1);
  13211. ctx.restore();
  13212. }
  13213. },
  13214. paintImageXObject: function CanvasGraphics_paintImageXObject(objId) {
  13215. var imgData = this.objs.get(objId);
  13216. if (!imgData) {
  13217. (0, _util.warn)('Dependent image isn\'t ready yet');
  13218. return;
  13219. }
  13220. this.paintInlineImageXObject(imgData);
  13221. },
  13222. paintImageXObjectRepeat: function CanvasGraphics_paintImageXObjectRepeat(objId, scaleX, scaleY, positions) {
  13223. var imgData = this.objs.get(objId);
  13224. if (!imgData) {
  13225. (0, _util.warn)('Dependent image isn\'t ready yet');
  13226. return;
  13227. }
  13228. var width = imgData.width;
  13229. var height = imgData.height;
  13230. var map = [];
  13231. for (var i = 0, ii = positions.length; i < ii; i += 2) {
  13232. map.push({
  13233. transform: [scaleX, 0, 0, scaleY, positions[i], positions[i + 1]],
  13234. x: 0,
  13235. y: 0,
  13236. w: width,
  13237. h: height
  13238. });
  13239. }
  13240. this.paintInlineImageXObjectGroup(imgData, map);
  13241. },
  13242. paintInlineImageXObject: function CanvasGraphics_paintInlineImageXObject(imgData) {
  13243. var width = imgData.width;
  13244. var height = imgData.height;
  13245. var ctx = this.ctx;
  13246. this.save();
  13247. ctx.scale(1 / width, -1 / height);
  13248. var currentTransform = ctx.mozCurrentTransformInverse;
  13249. var a = currentTransform[0],
  13250. b = currentTransform[1];
  13251. var widthScale = Math.max(Math.sqrt(a * a + b * b), 1);
  13252. var c = currentTransform[2],
  13253. d = currentTransform[3];
  13254. var heightScale = Math.max(Math.sqrt(c * c + d * d), 1);
  13255. var imgToPaint, tmpCanvas;
  13256. if (imgData instanceof HTMLElement || !imgData.data) {
  13257. imgToPaint = imgData;
  13258. } else {
  13259. tmpCanvas = this.cachedCanvases.getCanvas('inlineImage', width, height);
  13260. var tmpCtx = tmpCanvas.context;
  13261. putBinaryImageData(tmpCtx, imgData);
  13262. imgToPaint = tmpCanvas.canvas;
  13263. }
  13264. var paintWidth = width,
  13265. paintHeight = height;
  13266. var tmpCanvasId = 'prescale1';
  13267. while (widthScale > 2 && paintWidth > 1 || heightScale > 2 && paintHeight > 1) {
  13268. var newWidth = paintWidth,
  13269. newHeight = paintHeight;
  13270. if (widthScale > 2 && paintWidth > 1) {
  13271. newWidth = Math.ceil(paintWidth / 2);
  13272. widthScale /= paintWidth / newWidth;
  13273. }
  13274. if (heightScale > 2 && paintHeight > 1) {
  13275. newHeight = Math.ceil(paintHeight / 2);
  13276. heightScale /= paintHeight / newHeight;
  13277. }
  13278. tmpCanvas = this.cachedCanvases.getCanvas(tmpCanvasId, newWidth, newHeight);
  13279. tmpCtx = tmpCanvas.context;
  13280. tmpCtx.clearRect(0, 0, newWidth, newHeight);
  13281. tmpCtx.drawImage(imgToPaint, 0, 0, paintWidth, paintHeight, 0, 0, newWidth, newHeight);
  13282. imgToPaint = tmpCanvas.canvas;
  13283. paintWidth = newWidth;
  13284. paintHeight = newHeight;
  13285. tmpCanvasId = tmpCanvasId === 'prescale1' ? 'prescale2' : 'prescale1';
  13286. }
  13287. ctx.drawImage(imgToPaint, 0, 0, paintWidth, paintHeight, 0, -height, width, height);
  13288. if (this.imageLayer) {
  13289. var position = this.getCanvasPosition(0, -height);
  13290. this.imageLayer.appendImage({
  13291. imgData: imgData,
  13292. left: position[0],
  13293. top: position[1],
  13294. width: width / currentTransform[0],
  13295. height: height / currentTransform[3]
  13296. });
  13297. }
  13298. this.restore();
  13299. },
  13300. paintInlineImageXObjectGroup: function CanvasGraphics_paintInlineImageXObjectGroup(imgData, map) {
  13301. var ctx = this.ctx;
  13302. var w = imgData.width;
  13303. var h = imgData.height;
  13304. var tmpCanvas = this.cachedCanvases.getCanvas('inlineImage', w, h);
  13305. var tmpCtx = tmpCanvas.context;
  13306. putBinaryImageData(tmpCtx, imgData);
  13307. for (var i = 0, ii = map.length; i < ii; i++) {
  13308. var entry = map[i];
  13309. ctx.save();
  13310. ctx.transform.apply(ctx, entry.transform);
  13311. ctx.scale(1, -1);
  13312. ctx.drawImage(tmpCanvas.canvas, entry.x, entry.y, entry.w, entry.h, 0, -1, 1, 1);
  13313. if (this.imageLayer) {
  13314. var position = this.getCanvasPosition(entry.x, entry.y);
  13315. this.imageLayer.appendImage({
  13316. imgData: imgData,
  13317. left: position[0],
  13318. top: position[1],
  13319. width: w,
  13320. height: h
  13321. });
  13322. }
  13323. ctx.restore();
  13324. }
  13325. },
  13326. paintSolidColorImageMask: function CanvasGraphics_paintSolidColorImageMask() {
  13327. this.ctx.fillRect(0, 0, 1, 1);
  13328. },
  13329. paintXObject: function CanvasGraphics_paintXObject() {
  13330. (0, _util.warn)('Unsupported \'paintXObject\' command.');
  13331. },
  13332. markPoint: function CanvasGraphics_markPoint(tag) {},
  13333. markPointProps: function CanvasGraphics_markPointProps(tag, properties) {},
  13334. beginMarkedContent: function CanvasGraphics_beginMarkedContent(tag) {},
  13335. beginMarkedContentProps: function CanvasGraphics_beginMarkedContentProps(tag, properties) {},
  13336. endMarkedContent: function CanvasGraphics_endMarkedContent() {},
  13337. beginCompat: function CanvasGraphics_beginCompat() {},
  13338. endCompat: function CanvasGraphics_endCompat() {},
  13339. consumePath: function CanvasGraphics_consumePath() {
  13340. var ctx = this.ctx;
  13341. if (this.pendingClip) {
  13342. if (this.pendingClip === EO_CLIP) {
  13343. ctx.clip('evenodd');
  13344. } else {
  13345. ctx.clip();
  13346. }
  13347. this.pendingClip = null;
  13348. }
  13349. ctx.beginPath();
  13350. },
  13351. getSinglePixelWidth: function CanvasGraphics_getSinglePixelWidth(scale) {
  13352. if (this.cachedGetSinglePixelWidth === null) {
  13353. this.ctx.save();
  13354. var inverse = this.ctx.mozCurrentTransformInverse;
  13355. this.ctx.restore();
  13356. this.cachedGetSinglePixelWidth = Math.sqrt(Math.max(inverse[0] * inverse[0] + inverse[1] * inverse[1], inverse[2] * inverse[2] + inverse[3] * inverse[3]));
  13357. }
  13358. return this.cachedGetSinglePixelWidth;
  13359. },
  13360. getCanvasPosition: function CanvasGraphics_getCanvasPosition(x, y) {
  13361. var transform = this.ctx.mozCurrentTransform;
  13362. return [transform[0] * x + transform[2] * y + transform[4], transform[1] * x + transform[3] * y + transform[5]];
  13363. }
  13364. };
  13365. for (var op in _util.OPS) {
  13366. CanvasGraphics.prototype[_util.OPS[op]] = CanvasGraphics.prototype[op];
  13367. }
  13368. return CanvasGraphics;
  13369. }();
  13370. exports.CanvasGraphics = CanvasGraphics;
  13371. /***/ }),
  13372. /* 83 */
  13373. /***/ (function(module, exports, __w_pdfjs_require__) {
  13374. "use strict";
  13375. Object.defineProperty(exports, "__esModule", {
  13376. value: true
  13377. });
  13378. exports.FontLoader = exports.FontFaceObject = undefined;
  13379. var _util = __w_pdfjs_require__(0);
  13380. function FontLoader(docId) {
  13381. this.docId = docId;
  13382. this.styleElement = null;
  13383. this.nativeFontFaces = [];
  13384. this.loadTestFontId = 0;
  13385. this.loadingContext = {
  13386. requests: [],
  13387. nextRequestId: 0
  13388. };
  13389. }
  13390. FontLoader.prototype = {
  13391. insertRule: function fontLoaderInsertRule(rule) {
  13392. var styleElement = this.styleElement;
  13393. if (!styleElement) {
  13394. styleElement = this.styleElement = document.createElement('style');
  13395. styleElement.id = 'PDFJS_FONT_STYLE_TAG_' + this.docId;
  13396. document.documentElement.getElementsByTagName('head')[0].appendChild(styleElement);
  13397. }
  13398. var styleSheet = styleElement.sheet;
  13399. styleSheet.insertRule(rule, styleSheet.cssRules.length);
  13400. },
  13401. clear: function fontLoaderClear() {
  13402. if (this.styleElement) {
  13403. this.styleElement.remove();
  13404. this.styleElement = null;
  13405. }
  13406. this.nativeFontFaces.forEach(function (nativeFontFace) {
  13407. document.fonts.delete(nativeFontFace);
  13408. });
  13409. this.nativeFontFaces.length = 0;
  13410. }
  13411. };
  13412. {
  13413. var getLoadTestFont = function getLoadTestFont() {
  13414. return atob('T1RUTwALAIAAAwAwQ0ZGIDHtZg4AAAOYAAAAgUZGVE1lkzZwAAAEHAAAABxHREVGABQAFQ' + 'AABDgAAAAeT1MvMlYNYwkAAAEgAAAAYGNtYXABDQLUAAACNAAAAUJoZWFk/xVFDQAAALwA' + 'AAA2aGhlYQdkA+oAAAD0AAAAJGhtdHgD6AAAAAAEWAAAAAZtYXhwAAJQAAAAARgAAAAGbm' + 'FtZVjmdH4AAAGAAAAAsXBvc3T/hgAzAAADeAAAACAAAQAAAAEAALZRFsRfDzz1AAsD6AAA' + 'AADOBOTLAAAAAM4KHDwAAAAAA+gDIQAAAAgAAgAAAAAAAAABAAADIQAAAFoD6AAAAAAD6A' + 'ABAAAAAAAAAAAAAAAAAAAAAQAAUAAAAgAAAAQD6AH0AAUAAAKKArwAAACMAooCvAAAAeAA' + 'MQECAAACAAYJAAAAAAAAAAAAAQAAAAAAAAAAAAAAAFBmRWQAwAAuAC4DIP84AFoDIQAAAA' + 'AAAQAAAAAAAAAAACAAIAABAAAADgCuAAEAAAAAAAAAAQAAAAEAAAAAAAEAAQAAAAEAAAAA' + 'AAIAAQAAAAEAAAAAAAMAAQAAAAEAAAAAAAQAAQAAAAEAAAAAAAUAAQAAAAEAAAAAAAYAAQ' + 'AAAAMAAQQJAAAAAgABAAMAAQQJAAEAAgABAAMAAQQJAAIAAgABAAMAAQQJAAMAAgABAAMA' + 'AQQJAAQAAgABAAMAAQQJAAUAAgABAAMAAQQJAAYAAgABWABYAAAAAAAAAwAAAAMAAAAcAA' + 'EAAAAAADwAAwABAAAAHAAEACAAAAAEAAQAAQAAAC7//wAAAC7////TAAEAAAAAAAABBgAA' + 'AQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAA' + 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA' + 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA' + 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA' + 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAA' + 'AAAAD/gwAyAAAAAQAAAAAAAAAAAAAAAAAAAAABAAQEAAEBAQJYAAEBASH4DwD4GwHEAvgc' + 'A/gXBIwMAYuL+nz5tQXkD5j3CBLnEQACAQEBIVhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWF' + 'hYWFhYWFhYAAABAQAADwACAQEEE/t3Dov6fAH6fAT+fPp8+nwHDosMCvm1Cvm1DAz6fBQA' + 'AAAAAAABAAAAAMmJbzEAAAAAzgTjFQAAAADOBOQpAAEAAAAAAAAADAAUAAQAAAABAAAAAg' + 'ABAAAAAAAAAAAD6AAAAAAAAA==');
  13415. };
  13416. Object.defineProperty(FontLoader.prototype, 'loadTestFont', {
  13417. get: function get() {
  13418. return (0, _util.shadow)(this, 'loadTestFont', getLoadTestFont());
  13419. },
  13420. configurable: true
  13421. });
  13422. FontLoader.prototype.addNativeFontFace = function fontLoader_addNativeFontFace(nativeFontFace) {
  13423. this.nativeFontFaces.push(nativeFontFace);
  13424. document.fonts.add(nativeFontFace);
  13425. };
  13426. FontLoader.prototype.bind = function fontLoaderBind(fonts, callback) {
  13427. var rules = [];
  13428. var fontsToLoad = [];
  13429. var fontLoadPromises = [];
  13430. var getNativeFontPromise = function getNativeFontPromise(nativeFontFace) {
  13431. return nativeFontFace.loaded.catch(function (e) {
  13432. (0, _util.warn)('Failed to load font "' + nativeFontFace.family + '": ' + e);
  13433. });
  13434. };
  13435. var isFontLoadingAPISupported = FontLoader.isFontLoadingAPISupported && !FontLoader.isSyncFontLoadingSupported;
  13436. for (var i = 0, ii = fonts.length; i < ii; i++) {
  13437. var font = fonts[i];
  13438. if (font.attached || font.loading === false) {
  13439. continue;
  13440. }
  13441. font.attached = true;
  13442. if (isFontLoadingAPISupported) {
  13443. var nativeFontFace = font.createNativeFontFace();
  13444. if (nativeFontFace) {
  13445. this.addNativeFontFace(nativeFontFace);
  13446. fontLoadPromises.push(getNativeFontPromise(nativeFontFace));
  13447. }
  13448. } else {
  13449. var rule = font.createFontFaceRule();
  13450. if (rule) {
  13451. this.insertRule(rule);
  13452. rules.push(rule);
  13453. fontsToLoad.push(font);
  13454. }
  13455. }
  13456. }
  13457. var request = this.queueLoadingCallback(callback);
  13458. if (isFontLoadingAPISupported) {
  13459. Promise.all(fontLoadPromises).then(function () {
  13460. request.complete();
  13461. });
  13462. } else if (rules.length > 0 && !FontLoader.isSyncFontLoadingSupported) {
  13463. this.prepareFontLoadEvent(rules, fontsToLoad, request);
  13464. } else {
  13465. request.complete();
  13466. }
  13467. };
  13468. FontLoader.prototype.queueLoadingCallback = function FontLoader_queueLoadingCallback(callback) {
  13469. function LoadLoader_completeRequest() {
  13470. (0, _util.assert)(!request.end, 'completeRequest() cannot be called twice');
  13471. request.end = Date.now();
  13472. while (context.requests.length > 0 && context.requests[0].end) {
  13473. var otherRequest = context.requests.shift();
  13474. setTimeout(otherRequest.callback, 0);
  13475. }
  13476. }
  13477. var context = this.loadingContext;
  13478. var requestId = 'pdfjs-font-loading-' + context.nextRequestId++;
  13479. var request = {
  13480. id: requestId,
  13481. complete: LoadLoader_completeRequest,
  13482. callback: callback,
  13483. started: Date.now()
  13484. };
  13485. context.requests.push(request);
  13486. return request;
  13487. };
  13488. FontLoader.prototype.prepareFontLoadEvent = function fontLoaderPrepareFontLoadEvent(rules, fonts, request) {
  13489. function int32(data, offset) {
  13490. return data.charCodeAt(offset) << 24 | data.charCodeAt(offset + 1) << 16 | data.charCodeAt(offset + 2) << 8 | data.charCodeAt(offset + 3) & 0xff;
  13491. }
  13492. function spliceString(s, offset, remove, insert) {
  13493. var chunk1 = s.substr(0, offset);
  13494. var chunk2 = s.substr(offset + remove);
  13495. return chunk1 + insert + chunk2;
  13496. }
  13497. var i, ii;
  13498. var canvas = document.createElement('canvas');
  13499. canvas.width = 1;
  13500. canvas.height = 1;
  13501. var ctx = canvas.getContext('2d');
  13502. var called = 0;
  13503. function isFontReady(name, callback) {
  13504. called++;
  13505. if (called > 30) {
  13506. (0, _util.warn)('Load test font never loaded.');
  13507. callback();
  13508. return;
  13509. }
  13510. ctx.font = '30px ' + name;
  13511. ctx.fillText('.', 0, 20);
  13512. var imageData = ctx.getImageData(0, 0, 1, 1);
  13513. if (imageData.data[3] > 0) {
  13514. callback();
  13515. return;
  13516. }
  13517. setTimeout(isFontReady.bind(null, name, callback));
  13518. }
  13519. var loadTestFontId = 'lt' + Date.now() + this.loadTestFontId++;
  13520. var data = this.loadTestFont;
  13521. var COMMENT_OFFSET = 976;
  13522. data = spliceString(data, COMMENT_OFFSET, loadTestFontId.length, loadTestFontId);
  13523. var CFF_CHECKSUM_OFFSET = 16;
  13524. var XXXX_VALUE = 0x58585858;
  13525. var checksum = int32(data, CFF_CHECKSUM_OFFSET);
  13526. for (i = 0, ii = loadTestFontId.length - 3; i < ii; i += 4) {
  13527. checksum = checksum - XXXX_VALUE + int32(loadTestFontId, i) | 0;
  13528. }
  13529. if (i < loadTestFontId.length) {
  13530. checksum = checksum - XXXX_VALUE + int32(loadTestFontId + 'XXX', i) | 0;
  13531. }
  13532. data = spliceString(data, CFF_CHECKSUM_OFFSET, 4, (0, _util.string32)(checksum));
  13533. var url = 'url(data:font/opentype;base64,' + btoa(data) + ');';
  13534. var rule = '@font-face { font-family:"' + loadTestFontId + '";src:' + url + '}';
  13535. this.insertRule(rule);
  13536. var names = [];
  13537. for (i = 0, ii = fonts.length; i < ii; i++) {
  13538. names.push(fonts[i].loadedName);
  13539. }
  13540. names.push(loadTestFontId);
  13541. var div = document.createElement('div');
  13542. div.setAttribute('style', 'visibility: hidden;' + 'width: 10px; height: 10px;' + 'position: absolute; top: 0px; left: 0px;');
  13543. for (i = 0, ii = names.length; i < ii; ++i) {
  13544. var span = document.createElement('span');
  13545. span.textContent = 'Hi';
  13546. span.style.fontFamily = names[i];
  13547. div.appendChild(span);
  13548. }
  13549. document.body.appendChild(div);
  13550. isFontReady(loadTestFontId, function () {
  13551. document.body.removeChild(div);
  13552. request.complete();
  13553. });
  13554. };
  13555. }
  13556. {
  13557. FontLoader.isFontLoadingAPISupported = typeof document !== 'undefined' && !!document.fonts;
  13558. }
  13559. {
  13560. var isSyncFontLoadingSupported = function isSyncFontLoadingSupported() {
  13561. if (typeof navigator === 'undefined') {
  13562. return true;
  13563. }
  13564. var supported = false;
  13565. var m = /Mozilla\/5.0.*?rv:(\d+).*? Gecko/.exec(navigator.userAgent);
  13566. if (m && m[1] >= 14) {
  13567. supported = true;
  13568. }
  13569. return supported;
  13570. };
  13571. Object.defineProperty(FontLoader, 'isSyncFontLoadingSupported', {
  13572. get: function get() {
  13573. return (0, _util.shadow)(FontLoader, 'isSyncFontLoadingSupported', isSyncFontLoadingSupported());
  13574. },
  13575. enumerable: true,
  13576. configurable: true
  13577. });
  13578. }
  13579. var IsEvalSupportedCached = {
  13580. get value() {
  13581. return (0, _util.shadow)(this, 'value', (0, _util.isEvalSupported)());
  13582. }
  13583. };
  13584. var FontFaceObject = function FontFaceObjectClosure() {
  13585. function FontFaceObject(translatedData, options) {
  13586. this.compiledGlyphs = Object.create(null);
  13587. for (var i in translatedData) {
  13588. this[i] = translatedData[i];
  13589. }
  13590. this.options = options;
  13591. }
  13592. FontFaceObject.prototype = {
  13593. createNativeFontFace: function FontFaceObject_createNativeFontFace() {
  13594. if (!this.data) {
  13595. return null;
  13596. }
  13597. if (this.options.disableFontFace) {
  13598. this.disableFontFace = true;
  13599. return null;
  13600. }
  13601. var nativeFontFace = new FontFace(this.loadedName, this.data, {});
  13602. if (this.options.fontRegistry) {
  13603. this.options.fontRegistry.registerFont(this);
  13604. }
  13605. return nativeFontFace;
  13606. },
  13607. createFontFaceRule: function FontFaceObject_createFontFaceRule() {
  13608. if (!this.data) {
  13609. return null;
  13610. }
  13611. if (this.options.disableFontFace) {
  13612. this.disableFontFace = true;
  13613. return null;
  13614. }
  13615. var data = (0, _util.bytesToString)(new Uint8Array(this.data));
  13616. var fontName = this.loadedName;
  13617. var url = 'url(data:' + this.mimetype + ';base64,' + btoa(data) + ');';
  13618. var rule = '@font-face { font-family:"' + fontName + '";src:' + url + '}';
  13619. if (this.options.fontRegistry) {
  13620. this.options.fontRegistry.registerFont(this, url);
  13621. }
  13622. return rule;
  13623. },
  13624. getPathGenerator: function FontFaceObject_getPathGenerator(objs, character) {
  13625. if (!(character in this.compiledGlyphs)) {
  13626. var cmds = objs.get(this.loadedName + '_path_' + character);
  13627. var current, i, len;
  13628. if (this.options.isEvalSupported && IsEvalSupportedCached.value) {
  13629. var args,
  13630. js = '';
  13631. for (i = 0, len = cmds.length; i < len; i++) {
  13632. current = cmds[i];
  13633. if (current.args !== undefined) {
  13634. args = current.args.join(',');
  13635. } else {
  13636. args = '';
  13637. }
  13638. js += 'c.' + current.cmd + '(' + args + ');\n';
  13639. }
  13640. this.compiledGlyphs[character] = new Function('c', 'size', js);
  13641. } else {
  13642. this.compiledGlyphs[character] = function (c, size) {
  13643. for (i = 0, len = cmds.length; i < len; i++) {
  13644. current = cmds[i];
  13645. if (current.cmd === 'scale') {
  13646. current.args = [size, -size];
  13647. }
  13648. c[current.cmd].apply(c, current.args);
  13649. }
  13650. };
  13651. }
  13652. }
  13653. return this.compiledGlyphs[character];
  13654. }
  13655. };
  13656. return FontFaceObject;
  13657. }();
  13658. exports.FontFaceObject = FontFaceObject;
  13659. exports.FontLoader = FontLoader;
  13660. /***/ }),
  13661. /* 84 */
  13662. /***/ (function(module, exports, __w_pdfjs_require__) {
  13663. "use strict";
  13664. Object.defineProperty(exports, "__esModule", {
  13665. value: true
  13666. });
  13667. exports.TilingPattern = exports.getShadingPatternFromIR = undefined;
  13668. var _util = __w_pdfjs_require__(0);
  13669. var _webgl = __w_pdfjs_require__(53);
  13670. var ShadingIRs = {};
  13671. ShadingIRs.RadialAxial = {
  13672. fromIR: function RadialAxial_fromIR(raw) {
  13673. var type = raw[1];
  13674. var colorStops = raw[2];
  13675. var p0 = raw[3];
  13676. var p1 = raw[4];
  13677. var r0 = raw[5];
  13678. var r1 = raw[6];
  13679. return {
  13680. type: 'Pattern',
  13681. getPattern: function RadialAxial_getPattern(ctx) {
  13682. var grad;
  13683. if (type === 'axial') {
  13684. grad = ctx.createLinearGradient(p0[0], p0[1], p1[0], p1[1]);
  13685. } else if (type === 'radial') {
  13686. grad = ctx.createRadialGradient(p0[0], p0[1], r0, p1[0], p1[1], r1);
  13687. }
  13688. for (var i = 0, ii = colorStops.length; i < ii; ++i) {
  13689. var c = colorStops[i];
  13690. grad.addColorStop(c[0], c[1]);
  13691. }
  13692. return grad;
  13693. }
  13694. };
  13695. }
  13696. };
  13697. var createMeshCanvas = function createMeshCanvasClosure() {
  13698. function drawTriangle(data, context, p1, p2, p3, c1, c2, c3) {
  13699. var coords = context.coords,
  13700. colors = context.colors;
  13701. var bytes = data.data,
  13702. rowSize = data.width * 4;
  13703. var tmp;
  13704. if (coords[p1 + 1] > coords[p2 + 1]) {
  13705. tmp = p1;
  13706. p1 = p2;
  13707. p2 = tmp;
  13708. tmp = c1;
  13709. c1 = c2;
  13710. c2 = tmp;
  13711. }
  13712. if (coords[p2 + 1] > coords[p3 + 1]) {
  13713. tmp = p2;
  13714. p2 = p3;
  13715. p3 = tmp;
  13716. tmp = c2;
  13717. c2 = c3;
  13718. c3 = tmp;
  13719. }
  13720. if (coords[p1 + 1] > coords[p2 + 1]) {
  13721. tmp = p1;
  13722. p1 = p2;
  13723. p2 = tmp;
  13724. tmp = c1;
  13725. c1 = c2;
  13726. c2 = tmp;
  13727. }
  13728. var x1 = (coords[p1] + context.offsetX) * context.scaleX;
  13729. var y1 = (coords[p1 + 1] + context.offsetY) * context.scaleY;
  13730. var x2 = (coords[p2] + context.offsetX) * context.scaleX;
  13731. var y2 = (coords[p2 + 1] + context.offsetY) * context.scaleY;
  13732. var x3 = (coords[p3] + context.offsetX) * context.scaleX;
  13733. var y3 = (coords[p3 + 1] + context.offsetY) * context.scaleY;
  13734. if (y1 >= y3) {
  13735. return;
  13736. }
  13737. var c1r = colors[c1],
  13738. c1g = colors[c1 + 1],
  13739. c1b = colors[c1 + 2];
  13740. var c2r = colors[c2],
  13741. c2g = colors[c2 + 1],
  13742. c2b = colors[c2 + 2];
  13743. var c3r = colors[c3],
  13744. c3g = colors[c3 + 1],
  13745. c3b = colors[c3 + 2];
  13746. var minY = Math.round(y1),
  13747. maxY = Math.round(y3);
  13748. var xa, car, cag, cab;
  13749. var xb, cbr, cbg, cbb;
  13750. var k;
  13751. for (var y = minY; y <= maxY; y++) {
  13752. if (y < y2) {
  13753. k = y < y1 ? 0 : y1 === y2 ? 1 : (y1 - y) / (y1 - y2);
  13754. xa = x1 - (x1 - x2) * k;
  13755. car = c1r - (c1r - c2r) * k;
  13756. cag = c1g - (c1g - c2g) * k;
  13757. cab = c1b - (c1b - c2b) * k;
  13758. } else {
  13759. k = y > y3 ? 1 : y2 === y3 ? 0 : (y2 - y) / (y2 - y3);
  13760. xa = x2 - (x2 - x3) * k;
  13761. car = c2r - (c2r - c3r) * k;
  13762. cag = c2g - (c2g - c3g) * k;
  13763. cab = c2b - (c2b - c3b) * k;
  13764. }
  13765. k = y < y1 ? 0 : y > y3 ? 1 : (y1 - y) / (y1 - y3);
  13766. xb = x1 - (x1 - x3) * k;
  13767. cbr = c1r - (c1r - c3r) * k;
  13768. cbg = c1g - (c1g - c3g) * k;
  13769. cbb = c1b - (c1b - c3b) * k;
  13770. var x1_ = Math.round(Math.min(xa, xb));
  13771. var x2_ = Math.round(Math.max(xa, xb));
  13772. var j = rowSize * y + x1_ * 4;
  13773. for (var x = x1_; x <= x2_; x++) {
  13774. k = (xa - x) / (xa - xb);
  13775. k = k < 0 ? 0 : k > 1 ? 1 : k;
  13776. bytes[j++] = car - (car - cbr) * k | 0;
  13777. bytes[j++] = cag - (cag - cbg) * k | 0;
  13778. bytes[j++] = cab - (cab - cbb) * k | 0;
  13779. bytes[j++] = 255;
  13780. }
  13781. }
  13782. }
  13783. function drawFigure(data, figure, context) {
  13784. var ps = figure.coords;
  13785. var cs = figure.colors;
  13786. var i, ii;
  13787. switch (figure.type) {
  13788. case 'lattice':
  13789. var verticesPerRow = figure.verticesPerRow;
  13790. var rows = Math.floor(ps.length / verticesPerRow) - 1;
  13791. var cols = verticesPerRow - 1;
  13792. for (i = 0; i < rows; i++) {
  13793. var q = i * verticesPerRow;
  13794. for (var j = 0; j < cols; j++, q++) {
  13795. drawTriangle(data, context, ps[q], ps[q + 1], ps[q + verticesPerRow], cs[q], cs[q + 1], cs[q + verticesPerRow]);
  13796. drawTriangle(data, context, ps[q + verticesPerRow + 1], ps[q + 1], ps[q + verticesPerRow], cs[q + verticesPerRow + 1], cs[q + 1], cs[q + verticesPerRow]);
  13797. }
  13798. }
  13799. break;
  13800. case 'triangles':
  13801. for (i = 0, ii = ps.length; i < ii; i += 3) {
  13802. drawTriangle(data, context, ps[i], ps[i + 1], ps[i + 2], cs[i], cs[i + 1], cs[i + 2]);
  13803. }
  13804. break;
  13805. default:
  13806. throw new Error('illegal figure');
  13807. }
  13808. }
  13809. function createMeshCanvas(bounds, combinesScale, coords, colors, figures, backgroundColor, cachedCanvases) {
  13810. var EXPECTED_SCALE = 1.1;
  13811. var MAX_PATTERN_SIZE = 3000;
  13812. var BORDER_SIZE = 2;
  13813. var offsetX = Math.floor(bounds[0]);
  13814. var offsetY = Math.floor(bounds[1]);
  13815. var boundsWidth = Math.ceil(bounds[2]) - offsetX;
  13816. var boundsHeight = Math.ceil(bounds[3]) - offsetY;
  13817. var width = Math.min(Math.ceil(Math.abs(boundsWidth * combinesScale[0] * EXPECTED_SCALE)), MAX_PATTERN_SIZE);
  13818. var height = Math.min(Math.ceil(Math.abs(boundsHeight * combinesScale[1] * EXPECTED_SCALE)), MAX_PATTERN_SIZE);
  13819. var scaleX = boundsWidth / width;
  13820. var scaleY = boundsHeight / height;
  13821. var context = {
  13822. coords: coords,
  13823. colors: colors,
  13824. offsetX: -offsetX,
  13825. offsetY: -offsetY,
  13826. scaleX: 1 / scaleX,
  13827. scaleY: 1 / scaleY
  13828. };
  13829. var paddedWidth = width + BORDER_SIZE * 2;
  13830. var paddedHeight = height + BORDER_SIZE * 2;
  13831. var canvas, tmpCanvas, i, ii;
  13832. if (_webgl.WebGLUtils.isEnabled) {
  13833. canvas = _webgl.WebGLUtils.drawFigures(width, height, backgroundColor, figures, context);
  13834. tmpCanvas = cachedCanvases.getCanvas('mesh', paddedWidth, paddedHeight, false);
  13835. tmpCanvas.context.drawImage(canvas, BORDER_SIZE, BORDER_SIZE);
  13836. canvas = tmpCanvas.canvas;
  13837. } else {
  13838. tmpCanvas = cachedCanvases.getCanvas('mesh', paddedWidth, paddedHeight, false);
  13839. var tmpCtx = tmpCanvas.context;
  13840. var data = tmpCtx.createImageData(width, height);
  13841. if (backgroundColor) {
  13842. var bytes = data.data;
  13843. for (i = 0, ii = bytes.length; i < ii; i += 4) {
  13844. bytes[i] = backgroundColor[0];
  13845. bytes[i + 1] = backgroundColor[1];
  13846. bytes[i + 2] = backgroundColor[2];
  13847. bytes[i + 3] = 255;
  13848. }
  13849. }
  13850. for (i = 0; i < figures.length; i++) {
  13851. drawFigure(data, figures[i], context);
  13852. }
  13853. tmpCtx.putImageData(data, BORDER_SIZE, BORDER_SIZE);
  13854. canvas = tmpCanvas.canvas;
  13855. }
  13856. return {
  13857. canvas: canvas,
  13858. offsetX: offsetX - BORDER_SIZE * scaleX,
  13859. offsetY: offsetY - BORDER_SIZE * scaleY,
  13860. scaleX: scaleX,
  13861. scaleY: scaleY
  13862. };
  13863. }
  13864. return createMeshCanvas;
  13865. }();
  13866. ShadingIRs.Mesh = {
  13867. fromIR: function Mesh_fromIR(raw) {
  13868. var coords = raw[2];
  13869. var colors = raw[3];
  13870. var figures = raw[4];
  13871. var bounds = raw[5];
  13872. var matrix = raw[6];
  13873. var background = raw[8];
  13874. return {
  13875. type: 'Pattern',
  13876. getPattern: function Mesh_getPattern(ctx, owner, shadingFill) {
  13877. var scale;
  13878. if (shadingFill) {
  13879. scale = _util.Util.singularValueDecompose2dScale(ctx.mozCurrentTransform);
  13880. } else {
  13881. scale = _util.Util.singularValueDecompose2dScale(owner.baseTransform);
  13882. if (matrix) {
  13883. var matrixScale = _util.Util.singularValueDecompose2dScale(matrix);
  13884. scale = [scale[0] * matrixScale[0], scale[1] * matrixScale[1]];
  13885. }
  13886. }
  13887. var temporaryPatternCanvas = createMeshCanvas(bounds, scale, coords, colors, figures, shadingFill ? null : background, owner.cachedCanvases);
  13888. if (!shadingFill) {
  13889. ctx.setTransform.apply(ctx, owner.baseTransform);
  13890. if (matrix) {
  13891. ctx.transform.apply(ctx, matrix);
  13892. }
  13893. }
  13894. ctx.translate(temporaryPatternCanvas.offsetX, temporaryPatternCanvas.offsetY);
  13895. ctx.scale(temporaryPatternCanvas.scaleX, temporaryPatternCanvas.scaleY);
  13896. return ctx.createPattern(temporaryPatternCanvas.canvas, 'no-repeat');
  13897. }
  13898. };
  13899. }
  13900. };
  13901. ShadingIRs.Dummy = {
  13902. fromIR: function Dummy_fromIR() {
  13903. return {
  13904. type: 'Pattern',
  13905. getPattern: function Dummy_fromIR_getPattern() {
  13906. return 'hotpink';
  13907. }
  13908. };
  13909. }
  13910. };
  13911. function getShadingPatternFromIR(raw) {
  13912. var shadingIR = ShadingIRs[raw[0]];
  13913. if (!shadingIR) {
  13914. throw new Error('Unknown IR type: ' + raw[0]);
  13915. }
  13916. return shadingIR.fromIR(raw);
  13917. }
  13918. var TilingPattern = function TilingPatternClosure() {
  13919. var PaintType = {
  13920. COLORED: 1,
  13921. UNCOLORED: 2
  13922. };
  13923. var MAX_PATTERN_SIZE = 3000;
  13924. function TilingPattern(IR, color, ctx, canvasGraphicsFactory, baseTransform) {
  13925. this.operatorList = IR[2];
  13926. this.matrix = IR[3] || [1, 0, 0, 1, 0, 0];
  13927. this.bbox = IR[4];
  13928. this.xstep = IR[5];
  13929. this.ystep = IR[6];
  13930. this.paintType = IR[7];
  13931. this.tilingType = IR[8];
  13932. this.color = color;
  13933. this.canvasGraphicsFactory = canvasGraphicsFactory;
  13934. this.baseTransform = baseTransform;
  13935. this.type = 'Pattern';
  13936. this.ctx = ctx;
  13937. }
  13938. TilingPattern.prototype = {
  13939. createPatternCanvas: function TilinPattern_createPatternCanvas(owner) {
  13940. var operatorList = this.operatorList;
  13941. var bbox = this.bbox;
  13942. var xstep = this.xstep;
  13943. var ystep = this.ystep;
  13944. var paintType = this.paintType;
  13945. var tilingType = this.tilingType;
  13946. var color = this.color;
  13947. var canvasGraphicsFactory = this.canvasGraphicsFactory;
  13948. (0, _util.info)('TilingType: ' + tilingType);
  13949. var x0 = bbox[0],
  13950. y0 = bbox[1],
  13951. x1 = bbox[2],
  13952. y1 = bbox[3];
  13953. var topLeft = [x0, y0];
  13954. var botRight = [x0 + xstep, y0 + ystep];
  13955. var width = botRight[0] - topLeft[0];
  13956. var height = botRight[1] - topLeft[1];
  13957. var matrixScale = _util.Util.singularValueDecompose2dScale(this.matrix);
  13958. var curMatrixScale = _util.Util.singularValueDecompose2dScale(this.baseTransform);
  13959. var combinedScale = [matrixScale[0] * curMatrixScale[0], matrixScale[1] * curMatrixScale[1]];
  13960. width = Math.min(Math.ceil(Math.abs(width * combinedScale[0])), MAX_PATTERN_SIZE);
  13961. height = Math.min(Math.ceil(Math.abs(height * combinedScale[1])), MAX_PATTERN_SIZE);
  13962. var tmpCanvas = owner.cachedCanvases.getCanvas('pattern', width, height, true);
  13963. var tmpCtx = tmpCanvas.context;
  13964. var graphics = canvasGraphicsFactory.createCanvasGraphics(tmpCtx);
  13965. graphics.groupLevel = owner.groupLevel;
  13966. this.setFillAndStrokeStyleToContext(tmpCtx, paintType, color);
  13967. this.setScale(width, height, xstep, ystep);
  13968. this.transformToScale(graphics);
  13969. var tmpTranslate = [1, 0, 0, 1, -topLeft[0], -topLeft[1]];
  13970. graphics.transform.apply(graphics, tmpTranslate);
  13971. this.clipBbox(graphics, bbox, x0, y0, x1, y1);
  13972. graphics.executeOperatorList(operatorList);
  13973. return tmpCanvas.canvas;
  13974. },
  13975. setScale: function TilingPattern_setScale(width, height, xstep, ystep) {
  13976. this.scale = [width / xstep, height / ystep];
  13977. },
  13978. transformToScale: function TilingPattern_transformToScale(graphics) {
  13979. var scale = this.scale;
  13980. var tmpScale = [scale[0], 0, 0, scale[1], 0, 0];
  13981. graphics.transform.apply(graphics, tmpScale);
  13982. },
  13983. scaleToContext: function TilingPattern_scaleToContext() {
  13984. var scale = this.scale;
  13985. this.ctx.scale(1 / scale[0], 1 / scale[1]);
  13986. },
  13987. clipBbox: function clipBbox(graphics, bbox, x0, y0, x1, y1) {
  13988. if ((0, _util.isArray)(bbox) && bbox.length === 4) {
  13989. var bboxWidth = x1 - x0;
  13990. var bboxHeight = y1 - y0;
  13991. graphics.ctx.rect(x0, y0, bboxWidth, bboxHeight);
  13992. graphics.clip();
  13993. graphics.endPath();
  13994. }
  13995. },
  13996. setFillAndStrokeStyleToContext: function setFillAndStrokeStyleToContext(context, paintType, color) {
  13997. switch (paintType) {
  13998. case PaintType.COLORED:
  13999. var ctx = this.ctx;
  14000. context.fillStyle = ctx.fillStyle;
  14001. context.strokeStyle = ctx.strokeStyle;
  14002. break;
  14003. case PaintType.UNCOLORED:
  14004. var cssColor = _util.Util.makeCssRgb(color[0], color[1], color[2]);
  14005. context.fillStyle = cssColor;
  14006. context.strokeStyle = cssColor;
  14007. break;
  14008. default:
  14009. throw new _util.FormatError('Unsupported paint type: ' + paintType);
  14010. }
  14011. },
  14012. getPattern: function TilingPattern_getPattern(ctx, owner) {
  14013. var temporaryPatternCanvas = this.createPatternCanvas(owner);
  14014. ctx = this.ctx;
  14015. ctx.setTransform.apply(ctx, this.baseTransform);
  14016. ctx.transform.apply(ctx, this.matrix);
  14017. this.scaleToContext();
  14018. return ctx.createPattern(temporaryPatternCanvas, 'repeat');
  14019. }
  14020. };
  14021. return TilingPattern;
  14022. }();
  14023. exports.getShadingPatternFromIR = getShadingPatternFromIR;
  14024. exports.TilingPattern = TilingPattern;
  14025. /***/ }),
  14026. /* 85 */
  14027. /***/ (function(module, exports, __w_pdfjs_require__) {
  14028. "use strict";
  14029. Object.defineProperty(exports, "__esModule", {
  14030. value: true
  14031. });
  14032. exports.PDFDataTransportStream = undefined;
  14033. var _util = __w_pdfjs_require__(0);
  14034. var PDFDataTransportStream = function PDFDataTransportStreamClosure() {
  14035. function PDFDataTransportStream(params, pdfDataRangeTransport) {
  14036. var _this = this;
  14037. (0, _util.assert)(pdfDataRangeTransport);
  14038. this._queuedChunks = [];
  14039. var initialData = params.initialData;
  14040. if (initialData && initialData.length > 0) {
  14041. var buffer = new Uint8Array(initialData).buffer;
  14042. this._queuedChunks.push(buffer);
  14043. }
  14044. this._pdfDataRangeTransport = pdfDataRangeTransport;
  14045. this._isRangeSupported = !params.disableRange;
  14046. this._isStreamingSupported = !params.disableStream;
  14047. this._contentLength = params.length;
  14048. this._fullRequestReader = null;
  14049. this._rangeReaders = [];
  14050. this._pdfDataRangeTransport.addRangeListener(function (begin, chunk) {
  14051. _this._onReceiveData({
  14052. begin: begin,
  14053. chunk: chunk
  14054. });
  14055. });
  14056. this._pdfDataRangeTransport.addProgressListener(function (loaded) {
  14057. _this._onProgress({ loaded: loaded });
  14058. });
  14059. this._pdfDataRangeTransport.addProgressiveReadListener(function (chunk) {
  14060. _this._onReceiveData({ chunk: chunk });
  14061. });
  14062. this._pdfDataRangeTransport.transportReady();
  14063. }
  14064. PDFDataTransportStream.prototype = {
  14065. _onReceiveData: function PDFDataTransportStream_onReceiveData(args) {
  14066. var buffer = new Uint8Array(args.chunk).buffer;
  14067. if (args.begin === undefined) {
  14068. if (this._fullRequestReader) {
  14069. this._fullRequestReader._enqueue(buffer);
  14070. } else {
  14071. this._queuedChunks.push(buffer);
  14072. }
  14073. } else {
  14074. var found = this._rangeReaders.some(function (rangeReader) {
  14075. if (rangeReader._begin !== args.begin) {
  14076. return false;
  14077. }
  14078. rangeReader._enqueue(buffer);
  14079. return true;
  14080. });
  14081. (0, _util.assert)(found);
  14082. }
  14083. },
  14084. _onProgress: function PDFDataTransportStream_onDataProgress(evt) {
  14085. if (this._rangeReaders.length > 0) {
  14086. var firstReader = this._rangeReaders[0];
  14087. if (firstReader.onProgress) {
  14088. firstReader.onProgress({ loaded: evt.loaded });
  14089. }
  14090. }
  14091. },
  14092. _removeRangeReader: function PDFDataTransportStream_removeRangeReader(reader) {
  14093. var i = this._rangeReaders.indexOf(reader);
  14094. if (i >= 0) {
  14095. this._rangeReaders.splice(i, 1);
  14096. }
  14097. },
  14098. getFullReader: function PDFDataTransportStream_getFullReader() {
  14099. (0, _util.assert)(!this._fullRequestReader);
  14100. var queuedChunks = this._queuedChunks;
  14101. this._queuedChunks = null;
  14102. return new PDFDataTransportStreamReader(this, queuedChunks);
  14103. },
  14104. getRangeReader: function PDFDataTransportStream_getRangeReader(begin, end) {
  14105. var reader = new PDFDataTransportStreamRangeReader(this, begin, end);
  14106. this._pdfDataRangeTransport.requestDataRange(begin, end);
  14107. this._rangeReaders.push(reader);
  14108. return reader;
  14109. },
  14110. cancelAllRequests: function PDFDataTransportStream_cancelAllRequests(reason) {
  14111. if (this._fullRequestReader) {
  14112. this._fullRequestReader.cancel(reason);
  14113. }
  14114. var readers = this._rangeReaders.slice(0);
  14115. readers.forEach(function (rangeReader) {
  14116. rangeReader.cancel(reason);
  14117. });
  14118. this._pdfDataRangeTransport.abort();
  14119. }
  14120. };
  14121. function PDFDataTransportStreamReader(stream, queuedChunks) {
  14122. this._stream = stream;
  14123. this._done = false;
  14124. this._queuedChunks = queuedChunks || [];
  14125. this._requests = [];
  14126. this._headersReady = Promise.resolve();
  14127. stream._fullRequestReader = this;
  14128. this.onProgress = null;
  14129. }
  14130. PDFDataTransportStreamReader.prototype = {
  14131. _enqueue: function PDFDataTransportStreamReader_enqueue(chunk) {
  14132. if (this._done) {
  14133. return;
  14134. }
  14135. if (this._requests.length > 0) {
  14136. var requestCapability = this._requests.shift();
  14137. requestCapability.resolve({
  14138. value: chunk,
  14139. done: false
  14140. });
  14141. return;
  14142. }
  14143. this._queuedChunks.push(chunk);
  14144. },
  14145. get headersReady() {
  14146. return this._headersReady;
  14147. },
  14148. get isRangeSupported() {
  14149. return this._stream._isRangeSupported;
  14150. },
  14151. get isStreamingSupported() {
  14152. return this._stream._isStreamingSupported;
  14153. },
  14154. get contentLength() {
  14155. return this._stream._contentLength;
  14156. },
  14157. read: function PDFDataTransportStreamReader_read() {
  14158. if (this._queuedChunks.length > 0) {
  14159. var chunk = this._queuedChunks.shift();
  14160. return Promise.resolve({
  14161. value: chunk,
  14162. done: false
  14163. });
  14164. }
  14165. if (this._done) {
  14166. return Promise.resolve({
  14167. value: undefined,
  14168. done: true
  14169. });
  14170. }
  14171. var requestCapability = (0, _util.createPromiseCapability)();
  14172. this._requests.push(requestCapability);
  14173. return requestCapability.promise;
  14174. },
  14175. cancel: function PDFDataTransportStreamReader_cancel(reason) {
  14176. this._done = true;
  14177. this._requests.forEach(function (requestCapability) {
  14178. requestCapability.resolve({
  14179. value: undefined,
  14180. done: true
  14181. });
  14182. });
  14183. this._requests = [];
  14184. }
  14185. };
  14186. function PDFDataTransportStreamRangeReader(stream, begin, end) {
  14187. this._stream = stream;
  14188. this._begin = begin;
  14189. this._end = end;
  14190. this._queuedChunk = null;
  14191. this._requests = [];
  14192. this._done = false;
  14193. this.onProgress = null;
  14194. }
  14195. PDFDataTransportStreamRangeReader.prototype = {
  14196. _enqueue: function PDFDataTransportStreamRangeReader_enqueue(chunk) {
  14197. if (this._done) {
  14198. return;
  14199. }
  14200. if (this._requests.length === 0) {
  14201. this._queuedChunk = chunk;
  14202. } else {
  14203. var requestsCapability = this._requests.shift();
  14204. requestsCapability.resolve({
  14205. value: chunk,
  14206. done: false
  14207. });
  14208. this._requests.forEach(function (requestCapability) {
  14209. requestCapability.resolve({
  14210. value: undefined,
  14211. done: true
  14212. });
  14213. });
  14214. this._requests = [];
  14215. }
  14216. this._done = true;
  14217. this._stream._removeRangeReader(this);
  14218. },
  14219. get isStreamingSupported() {
  14220. return false;
  14221. },
  14222. read: function PDFDataTransportStreamRangeReader_read() {
  14223. if (this._queuedChunk) {
  14224. var chunk = this._queuedChunk;
  14225. this._queuedChunk = null;
  14226. return Promise.resolve({
  14227. value: chunk,
  14228. done: false
  14229. });
  14230. }
  14231. if (this._done) {
  14232. return Promise.resolve({
  14233. value: undefined,
  14234. done: true
  14235. });
  14236. }
  14237. var requestCapability = (0, _util.createPromiseCapability)();
  14238. this._requests.push(requestCapability);
  14239. return requestCapability.promise;
  14240. },
  14241. cancel: function PDFDataTransportStreamRangeReader_cancel(reason) {
  14242. this._done = true;
  14243. this._requests.forEach(function (requestCapability) {
  14244. requestCapability.resolve({
  14245. value: undefined,
  14246. done: true
  14247. });
  14248. });
  14249. this._requests = [];
  14250. this._stream._removeRangeReader(this);
  14251. }
  14252. };
  14253. return PDFDataTransportStream;
  14254. }();
  14255. exports.PDFDataTransportStream = PDFDataTransportStream;
  14256. /***/ }),
  14257. /* 86 */
  14258. /***/ (function(module, exports, __w_pdfjs_require__) {
  14259. "use strict";
  14260. var pdfjsVersion = '1.9.478';
  14261. var pdfjsBuild = '798e46da';
  14262. var pdfjsSharedUtil = __w_pdfjs_require__(0);
  14263. var pdfjsDisplayGlobal = __w_pdfjs_require__(54);
  14264. var pdfjsDisplayAPI = __w_pdfjs_require__(30);
  14265. var pdfjsDisplayTextLayer = __w_pdfjs_require__(32);
  14266. var pdfjsDisplayAnnotationLayer = __w_pdfjs_require__(29);
  14267. var pdfjsDisplayDOMUtils = __w_pdfjs_require__(7);
  14268. var pdfjsDisplaySVG = __w_pdfjs_require__(31);
  14269. {
  14270. if (pdfjsSharedUtil.isNodeJS()) {
  14271. var PDFNodeStream = __w_pdfjs_require__(56).PDFNodeStream;
  14272. pdfjsDisplayAPI.setPDFNetworkStreamClass(PDFNodeStream);
  14273. } else {
  14274. var PDFNetworkStream = __w_pdfjs_require__(55).PDFNetworkStream;
  14275. pdfjsDisplayAPI.setPDFNetworkStreamClass(PDFNetworkStream);
  14276. }
  14277. }
  14278. exports.PDFJS = pdfjsDisplayGlobal.PDFJS;
  14279. exports.build = pdfjsDisplayAPI.build;
  14280. exports.version = pdfjsDisplayAPI.version;
  14281. exports.getDocument = pdfjsDisplayAPI.getDocument;
  14282. exports.LoopbackPort = pdfjsDisplayAPI.LoopbackPort;
  14283. exports.PDFDataRangeTransport = pdfjsDisplayAPI.PDFDataRangeTransport;
  14284. exports.PDFWorker = pdfjsDisplayAPI.PDFWorker;
  14285. exports.renderTextLayer = pdfjsDisplayTextLayer.renderTextLayer;
  14286. exports.AnnotationLayer = pdfjsDisplayAnnotationLayer.AnnotationLayer;
  14287. exports.CustomStyle = pdfjsDisplayDOMUtils.CustomStyle;
  14288. exports.createPromiseCapability = pdfjsSharedUtil.createPromiseCapability;
  14289. exports.PasswordResponses = pdfjsSharedUtil.PasswordResponses;
  14290. exports.InvalidPDFException = pdfjsSharedUtil.InvalidPDFException;
  14291. exports.MissingPDFException = pdfjsSharedUtil.MissingPDFException;
  14292. exports.SVGGraphics = pdfjsDisplaySVG.SVGGraphics;
  14293. exports.NativeImageDecoding = pdfjsSharedUtil.NativeImageDecoding;
  14294. exports.UnexpectedResponseException = pdfjsSharedUtil.UnexpectedResponseException;
  14295. exports.OPS = pdfjsSharedUtil.OPS;
  14296. exports.UNSUPPORTED_FEATURES = pdfjsSharedUtil.UNSUPPORTED_FEATURES;
  14297. exports.isValidUrl = pdfjsDisplayDOMUtils.isValidUrl;
  14298. exports.createValidAbsoluteUrl = pdfjsSharedUtil.createValidAbsoluteUrl;
  14299. exports.createObjectURL = pdfjsSharedUtil.createObjectURL;
  14300. exports.removeNullCharacters = pdfjsSharedUtil.removeNullCharacters;
  14301. exports.shadow = pdfjsSharedUtil.shadow;
  14302. exports.createBlob = pdfjsSharedUtil.createBlob;
  14303. exports.RenderingCancelledException = pdfjsDisplayDOMUtils.RenderingCancelledException;
  14304. exports.getFilenameFromUrl = pdfjsDisplayDOMUtils.getFilenameFromUrl;
  14305. exports.addLinkAttributes = pdfjsDisplayDOMUtils.addLinkAttributes;
  14306. exports.StatTimer = pdfjsSharedUtil.StatTimer;
  14307. /***/ }),
  14308. /* 87 */
  14309. /***/ (function(module, exports, __w_pdfjs_require__) {
  14310. "use strict";
  14311. 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; };
  14312. if (typeof PDFJS === 'undefined' || !PDFJS.compatibilityChecked) {
  14313. var globalScope = __w_pdfjs_require__(14);
  14314. var userAgent = typeof navigator !== 'undefined' && navigator.userAgent || '';
  14315. var isAndroid = /Android/.test(userAgent);
  14316. var isAndroidPre3 = /Android\s[0-2][^\d]/.test(userAgent);
  14317. var isAndroidPre5 = /Android\s[0-4][^\d]/.test(userAgent);
  14318. var isChrome = userAgent.indexOf('Chrom') >= 0;
  14319. var isChromeWithRangeBug = /Chrome\/(39|40)\./.test(userAgent);
  14320. var isIOSChrome = userAgent.indexOf('CriOS') >= 0;
  14321. var isIE = userAgent.indexOf('Trident') >= 0;
  14322. var isIOS = /\b(iPad|iPhone|iPod)(?=;)/.test(userAgent);
  14323. var isOpera = userAgent.indexOf('Opera') >= 0;
  14324. var isSafari = /Safari\//.test(userAgent) && !/(Chrome\/|Android\s)/.test(userAgent);
  14325. var hasDOM = (typeof window === 'undefined' ? 'undefined' : _typeof(window)) === 'object' && (typeof document === 'undefined' ? 'undefined' : _typeof(document)) === 'object';
  14326. if (typeof PDFJS === 'undefined') {
  14327. globalScope.PDFJS = {};
  14328. }
  14329. PDFJS.compatibilityChecked = true;
  14330. (function checkTypedArrayCompatibility() {
  14331. if (typeof Uint8ClampedArray === 'undefined') {
  14332. globalScope.Uint8ClampedArray = __w_pdfjs_require__(58);
  14333. }
  14334. if (typeof Uint8Array !== 'undefined') {
  14335. if (typeof Uint8Array.prototype.subarray === 'undefined') {
  14336. Uint8Array.prototype.subarray = function subarray(start, end) {
  14337. return new Uint8Array(this.slice(start, end));
  14338. };
  14339. Float32Array.prototype.subarray = function subarray(start, end) {
  14340. return new Float32Array(this.slice(start, end));
  14341. };
  14342. }
  14343. if (typeof Float64Array === 'undefined') {
  14344. globalScope.Float64Array = Float32Array;
  14345. }
  14346. return;
  14347. }
  14348. function subarray(start, end) {
  14349. return new TypedArray(this.slice(start, end));
  14350. }
  14351. function setArrayOffset(array, offset) {
  14352. if (arguments.length < 2) {
  14353. offset = 0;
  14354. }
  14355. for (var i = 0, n = array.length; i < n; ++i, ++offset) {
  14356. this[offset] = array[i] & 0xFF;
  14357. }
  14358. }
  14359. function Uint32ArrayView(buffer, length) {
  14360. this.buffer = buffer;
  14361. this.byteLength = buffer.length;
  14362. this.length = length;
  14363. ensureUint32ArrayViewProps(this.length);
  14364. }
  14365. Uint32ArrayView.prototype = Object.create(null);
  14366. var uint32ArrayViewSetters = 0;
  14367. function createUint32ArrayProp(index) {
  14368. return {
  14369. get: function get() {
  14370. var buffer = this.buffer,
  14371. offset = index << 2;
  14372. return (buffer[offset] | buffer[offset + 1] << 8 | buffer[offset + 2] << 16 | buffer[offset + 3] << 24) >>> 0;
  14373. },
  14374. set: function set(value) {
  14375. var buffer = this.buffer,
  14376. offset = index << 2;
  14377. buffer[offset] = value & 255;
  14378. buffer[offset + 1] = value >> 8 & 255;
  14379. buffer[offset + 2] = value >> 16 & 255;
  14380. buffer[offset + 3] = value >>> 24 & 255;
  14381. }
  14382. };
  14383. }
  14384. function ensureUint32ArrayViewProps(length) {
  14385. while (uint32ArrayViewSetters < length) {
  14386. Object.defineProperty(Uint32ArrayView.prototype, uint32ArrayViewSetters, createUint32ArrayProp(uint32ArrayViewSetters));
  14387. uint32ArrayViewSetters++;
  14388. }
  14389. }
  14390. function TypedArray(arg1) {
  14391. var result, i, n;
  14392. if (typeof arg1 === 'number') {
  14393. result = [];
  14394. for (i = 0; i < arg1; ++i) {
  14395. result[i] = 0;
  14396. }
  14397. } else if ('slice' in arg1) {
  14398. result = arg1.slice(0);
  14399. } else {
  14400. result = [];
  14401. for (i = 0, n = arg1.length; i < n; ++i) {
  14402. result[i] = arg1[i];
  14403. }
  14404. }
  14405. result.subarray = subarray;
  14406. result.buffer = result;
  14407. result.byteLength = result.length;
  14408. result.set = setArrayOffset;
  14409. if ((typeof arg1 === 'undefined' ? 'undefined' : _typeof(arg1)) === 'object' && arg1.buffer) {
  14410. result.buffer = arg1.buffer;
  14411. }
  14412. return result;
  14413. }
  14414. globalScope.Uint8Array = TypedArray;
  14415. globalScope.Int8Array = TypedArray;
  14416. globalScope.Int32Array = TypedArray;
  14417. globalScope.Uint16Array = TypedArray;
  14418. globalScope.Float32Array = TypedArray;
  14419. globalScope.Float64Array = TypedArray;
  14420. globalScope.Uint32Array = function () {
  14421. if (arguments.length === 3) {
  14422. if (arguments[1] !== 0) {
  14423. throw new Error('offset !== 0 is not supported');
  14424. }
  14425. return new Uint32ArrayView(arguments[0], arguments[2]);
  14426. }
  14427. return TypedArray.apply(this, arguments);
  14428. };
  14429. })();
  14430. (function canvasPixelArrayBuffer() {
  14431. if (!hasDOM || !window.CanvasPixelArray) {
  14432. return;
  14433. }
  14434. var cpaProto = window.CanvasPixelArray.prototype;
  14435. if ('buffer' in cpaProto) {
  14436. return;
  14437. }
  14438. Object.defineProperty(cpaProto, 'buffer', {
  14439. get: function get() {
  14440. return this;
  14441. },
  14442. enumerable: false,
  14443. configurable: true
  14444. });
  14445. Object.defineProperty(cpaProto, 'byteLength', {
  14446. get: function get() {
  14447. return this.length;
  14448. },
  14449. enumerable: false,
  14450. configurable: true
  14451. });
  14452. })();
  14453. (function normalizeURLObject() {
  14454. if (!globalScope.URL) {
  14455. globalScope.URL = globalScope.webkitURL;
  14456. }
  14457. })();
  14458. (function checkObjectDefinePropertyCompatibility() {
  14459. if (typeof Object.defineProperty !== 'undefined') {
  14460. var definePropertyPossible = true;
  14461. try {
  14462. if (hasDOM) {
  14463. Object.defineProperty(new Image(), 'id', { value: 'test' });
  14464. }
  14465. var Test = function Test() {};
  14466. Test.prototype = {
  14467. get id() {}
  14468. };
  14469. Object.defineProperty(new Test(), 'id', {
  14470. value: '',
  14471. configurable: true,
  14472. enumerable: true,
  14473. writable: false
  14474. });
  14475. } catch (e) {
  14476. definePropertyPossible = false;
  14477. }
  14478. if (definePropertyPossible) {
  14479. return;
  14480. }
  14481. }
  14482. Object.defineProperty = function objectDefineProperty(obj, name, def) {
  14483. delete obj[name];
  14484. if ('get' in def) {
  14485. obj.__defineGetter__(name, def['get']);
  14486. }
  14487. if ('set' in def) {
  14488. obj.__defineSetter__(name, def['set']);
  14489. }
  14490. if ('value' in def) {
  14491. obj.__defineSetter__(name, function objectDefinePropertySetter(value) {
  14492. this.__defineGetter__(name, function objectDefinePropertyGetter() {
  14493. return value;
  14494. });
  14495. return value;
  14496. });
  14497. obj[name] = def.value;
  14498. }
  14499. };
  14500. })();
  14501. (function checkXMLHttpRequestResponseCompatibility() {
  14502. if (typeof XMLHttpRequest === 'undefined') {
  14503. return;
  14504. }
  14505. var xhrPrototype = XMLHttpRequest.prototype;
  14506. var xhr = new XMLHttpRequest();
  14507. if (!('overrideMimeType' in xhr)) {
  14508. Object.defineProperty(xhrPrototype, 'overrideMimeType', {
  14509. value: function xmlHttpRequestOverrideMimeType(mimeType) {}
  14510. });
  14511. }
  14512. if ('responseType' in xhr) {
  14513. return;
  14514. }
  14515. Object.defineProperty(xhrPrototype, 'responseType', {
  14516. get: function xmlHttpRequestGetResponseType() {
  14517. return this._responseType || 'text';
  14518. },
  14519. set: function xmlHttpRequestSetResponseType(value) {
  14520. if (value === 'text' || value === 'arraybuffer') {
  14521. this._responseType = value;
  14522. if (value === 'arraybuffer' && typeof this.overrideMimeType === 'function') {
  14523. this.overrideMimeType('text/plain; charset=x-user-defined');
  14524. }
  14525. }
  14526. }
  14527. });
  14528. if (typeof VBArray !== 'undefined') {
  14529. Object.defineProperty(xhrPrototype, 'response', {
  14530. get: function xmlHttpRequestResponseGet() {
  14531. if (this.responseType === 'arraybuffer') {
  14532. return new Uint8Array(new VBArray(this.responseBody).toArray());
  14533. }
  14534. return this.responseText;
  14535. }
  14536. });
  14537. return;
  14538. }
  14539. Object.defineProperty(xhrPrototype, 'response', {
  14540. get: function xmlHttpRequestResponseGet() {
  14541. if (this.responseType !== 'arraybuffer') {
  14542. return this.responseText;
  14543. }
  14544. var text = this.responseText;
  14545. var i,
  14546. n = text.length;
  14547. var result = new Uint8Array(n);
  14548. for (i = 0; i < n; ++i) {
  14549. result[i] = text.charCodeAt(i) & 0xFF;
  14550. }
  14551. return result.buffer;
  14552. }
  14553. });
  14554. })();
  14555. (function checkWindowBtoaCompatibility() {
  14556. if ('btoa' in globalScope) {
  14557. return;
  14558. }
  14559. var digits = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
  14560. globalScope.btoa = function (chars) {
  14561. var buffer = '';
  14562. var i, n;
  14563. for (i = 0, n = chars.length; i < n; i += 3) {
  14564. var b1 = chars.charCodeAt(i) & 0xFF;
  14565. var b2 = chars.charCodeAt(i + 1) & 0xFF;
  14566. var b3 = chars.charCodeAt(i + 2) & 0xFF;
  14567. var d1 = b1 >> 2,
  14568. d2 = (b1 & 3) << 4 | b2 >> 4;
  14569. var d3 = i + 1 < n ? (b2 & 0xF) << 2 | b3 >> 6 : 64;
  14570. var d4 = i + 2 < n ? b3 & 0x3F : 64;
  14571. buffer += digits.charAt(d1) + digits.charAt(d2) + digits.charAt(d3) + digits.charAt(d4);
  14572. }
  14573. return buffer;
  14574. };
  14575. })();
  14576. (function checkWindowAtobCompatibility() {
  14577. if ('atob' in globalScope) {
  14578. return;
  14579. }
  14580. var digits = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
  14581. globalScope.atob = function (input) {
  14582. input = input.replace(/=+$/, '');
  14583. if (input.length % 4 === 1) {
  14584. throw new Error('bad atob input');
  14585. }
  14586. for (var bc = 0, bs, buffer, idx = 0, output = ''; buffer = input.charAt(idx++); ~buffer && (bs = bc % 4 ? bs * 64 + buffer : buffer, bc++ % 4) ? output += String.fromCharCode(255 & bs >> (-2 * bc & 6)) : 0) {
  14587. buffer = digits.indexOf(buffer);
  14588. }
  14589. return output;
  14590. };
  14591. })();
  14592. (function checkFunctionPrototypeBindCompatibility() {
  14593. if (typeof Function.prototype.bind !== 'undefined') {
  14594. return;
  14595. }
  14596. Function.prototype.bind = function functionPrototypeBind(obj) {
  14597. var fn = this,
  14598. headArgs = Array.prototype.slice.call(arguments, 1);
  14599. var bound = function functionPrototypeBindBound() {
  14600. var args = headArgs.concat(Array.prototype.slice.call(arguments));
  14601. return fn.apply(obj, args);
  14602. };
  14603. return bound;
  14604. };
  14605. })();
  14606. (function checkDatasetProperty() {
  14607. if (!hasDOM) {
  14608. return;
  14609. }
  14610. var div = document.createElement('div');
  14611. if ('dataset' in div) {
  14612. return;
  14613. }
  14614. Object.defineProperty(HTMLElement.prototype, 'dataset', {
  14615. get: function get() {
  14616. if (this._dataset) {
  14617. return this._dataset;
  14618. }
  14619. var dataset = {};
  14620. for (var j = 0, jj = this.attributes.length; j < jj; j++) {
  14621. var attribute = this.attributes[j];
  14622. if (attribute.name.substring(0, 5) !== 'data-') {
  14623. continue;
  14624. }
  14625. var key = attribute.name.substring(5).replace(/\-([a-z])/g, function (all, ch) {
  14626. return ch.toUpperCase();
  14627. });
  14628. dataset[key] = attribute.value;
  14629. }
  14630. Object.defineProperty(this, '_dataset', {
  14631. value: dataset,
  14632. writable: false,
  14633. enumerable: false
  14634. });
  14635. return dataset;
  14636. },
  14637. enumerable: true
  14638. });
  14639. })();
  14640. (function checkClassListProperty() {
  14641. function changeList(element, itemName, add, remove) {
  14642. var s = element.className || '';
  14643. var list = s.split(/\s+/g);
  14644. if (list[0] === '') {
  14645. list.shift();
  14646. }
  14647. var index = list.indexOf(itemName);
  14648. if (index < 0 && add) {
  14649. list.push(itemName);
  14650. }
  14651. if (index >= 0 && remove) {
  14652. list.splice(index, 1);
  14653. }
  14654. element.className = list.join(' ');
  14655. return index >= 0;
  14656. }
  14657. if (!hasDOM) {
  14658. return;
  14659. }
  14660. var div = document.createElement('div');
  14661. if ('classList' in div) {
  14662. return;
  14663. }
  14664. var classListPrototype = {
  14665. add: function add(name) {
  14666. changeList(this.element, name, true, false);
  14667. },
  14668. contains: function contains(name) {
  14669. return changeList(this.element, name, false, false);
  14670. },
  14671. remove: function remove(name) {
  14672. changeList(this.element, name, false, true);
  14673. },
  14674. toggle: function toggle(name) {
  14675. changeList(this.element, name, true, true);
  14676. }
  14677. };
  14678. Object.defineProperty(HTMLElement.prototype, 'classList', {
  14679. get: function get() {
  14680. if (this._classList) {
  14681. return this._classList;
  14682. }
  14683. var classList = Object.create(classListPrototype, {
  14684. element: {
  14685. value: this,
  14686. writable: false,
  14687. enumerable: true
  14688. }
  14689. });
  14690. Object.defineProperty(this, '_classList', {
  14691. value: classList,
  14692. writable: false,
  14693. enumerable: false
  14694. });
  14695. return classList;
  14696. },
  14697. enumerable: true
  14698. });
  14699. })();
  14700. (function checkWorkerConsoleCompatibility() {
  14701. if (typeof importScripts === 'undefined' || 'console' in globalScope) {
  14702. return;
  14703. }
  14704. var consoleTimer = {};
  14705. var workerConsole = {
  14706. log: function log() {
  14707. var args = Array.prototype.slice.call(arguments);
  14708. globalScope.postMessage({
  14709. targetName: 'main',
  14710. action: 'console_log',
  14711. data: args
  14712. });
  14713. },
  14714. error: function error() {
  14715. var args = Array.prototype.slice.call(arguments);
  14716. globalScope.postMessage({
  14717. targetName: 'main',
  14718. action: 'console_error',
  14719. data: args
  14720. });
  14721. },
  14722. time: function time(name) {
  14723. consoleTimer[name] = Date.now();
  14724. },
  14725. timeEnd: function timeEnd(name) {
  14726. var time = consoleTimer[name];
  14727. if (!time) {
  14728. throw new Error('Unknown timer name ' + name);
  14729. }
  14730. this.log('Timer:', name, Date.now() - time);
  14731. }
  14732. };
  14733. globalScope.console = workerConsole;
  14734. })();
  14735. (function checkConsoleCompatibility() {
  14736. if (!hasDOM) {
  14737. return;
  14738. }
  14739. if (!('console' in window)) {
  14740. window.console = {
  14741. log: function log() {},
  14742. error: function error() {},
  14743. warn: function warn() {}
  14744. };
  14745. return;
  14746. }
  14747. if (!('bind' in console.log)) {
  14748. console.log = function (fn) {
  14749. return function (msg) {
  14750. return fn(msg);
  14751. };
  14752. }(console.log);
  14753. console.error = function (fn) {
  14754. return function (msg) {
  14755. return fn(msg);
  14756. };
  14757. }(console.error);
  14758. console.warn = function (fn) {
  14759. return function (msg) {
  14760. return fn(msg);
  14761. };
  14762. }(console.warn);
  14763. return;
  14764. }
  14765. })();
  14766. (function checkOnClickCompatibility() {
  14767. function ignoreIfTargetDisabled(event) {
  14768. if (isDisabled(event.target)) {
  14769. event.stopPropagation();
  14770. }
  14771. }
  14772. function isDisabled(node) {
  14773. return node.disabled || node.parentNode && isDisabled(node.parentNode);
  14774. }
  14775. if (isOpera) {
  14776. document.addEventListener('click', ignoreIfTargetDisabled, true);
  14777. }
  14778. })();
  14779. (function checkOnBlobSupport() {
  14780. if (isIE || isIOSChrome) {
  14781. PDFJS.disableCreateObjectURL = true;
  14782. }
  14783. })();
  14784. (function checkNavigatorLanguage() {
  14785. if (typeof navigator === 'undefined') {
  14786. return;
  14787. }
  14788. if ('language' in navigator) {
  14789. return;
  14790. }
  14791. PDFJS.locale = navigator.userLanguage || 'en-US';
  14792. })();
  14793. (function checkRangeRequests() {
  14794. if (isSafari || isAndroidPre3 || isChromeWithRangeBug || isIOS) {
  14795. PDFJS.disableRange = true;
  14796. PDFJS.disableStream = true;
  14797. }
  14798. })();
  14799. (function checkHistoryManipulation() {
  14800. if (!hasDOM) {
  14801. return;
  14802. }
  14803. if (!history.pushState || isAndroidPre3) {
  14804. PDFJS.disableHistory = true;
  14805. }
  14806. })();
  14807. (function checkSetPresenceInImageData() {
  14808. if (!hasDOM) {
  14809. return;
  14810. }
  14811. if (window.CanvasPixelArray) {
  14812. if (typeof window.CanvasPixelArray.prototype.set !== 'function') {
  14813. window.CanvasPixelArray.prototype.set = function (arr) {
  14814. for (var i = 0, ii = this.length; i < ii; i++) {
  14815. this[i] = arr[i];
  14816. }
  14817. };
  14818. }
  14819. } else {
  14820. var polyfill = false,
  14821. versionMatch;
  14822. if (isChrome) {
  14823. versionMatch = userAgent.match(/Chrom(e|ium)\/([0-9]+)\./);
  14824. polyfill = versionMatch && parseInt(versionMatch[2]) < 21;
  14825. } else if (isAndroid) {
  14826. polyfill = isAndroidPre5;
  14827. } else if (isSafari) {
  14828. versionMatch = userAgent.match(/Version\/([0-9]+)\.([0-9]+)\.([0-9]+) Safari\//);
  14829. polyfill = versionMatch && parseInt(versionMatch[1]) < 6;
  14830. }
  14831. if (polyfill) {
  14832. var contextPrototype = window.CanvasRenderingContext2D.prototype;
  14833. var createImageData = contextPrototype.createImageData;
  14834. contextPrototype.createImageData = function (w, h) {
  14835. var imageData = createImageData.call(this, w, h);
  14836. imageData.data.set = function (arr) {
  14837. for (var i = 0, ii = this.length; i < ii; i++) {
  14838. this[i] = arr[i];
  14839. }
  14840. };
  14841. return imageData;
  14842. };
  14843. contextPrototype = null;
  14844. }
  14845. }
  14846. })();
  14847. (function checkRequestAnimationFrame() {
  14848. function installFakeAnimationFrameFunctions() {
  14849. window.requestAnimationFrame = function (callback) {
  14850. return window.setTimeout(callback, 20);
  14851. };
  14852. window.cancelAnimationFrame = function (timeoutID) {
  14853. window.clearTimeout(timeoutID);
  14854. };
  14855. }
  14856. if (!hasDOM) {
  14857. return;
  14858. }
  14859. if (isIOS) {
  14860. installFakeAnimationFrameFunctions();
  14861. return;
  14862. }
  14863. if ('requestAnimationFrame' in window) {
  14864. return;
  14865. }
  14866. window.requestAnimationFrame = window.mozRequestAnimationFrame || window.webkitRequestAnimationFrame;
  14867. if (window.requestAnimationFrame) {
  14868. return;
  14869. }
  14870. installFakeAnimationFrameFunctions();
  14871. })();
  14872. (function checkCanvasSizeLimitation() {
  14873. if (isIOS || isAndroid) {
  14874. PDFJS.maxCanvasPixels = 5242880;
  14875. }
  14876. })();
  14877. (function checkFullscreenSupport() {
  14878. if (!hasDOM) {
  14879. return;
  14880. }
  14881. if (isIE && window.parent !== window) {
  14882. PDFJS.disableFullscreen = true;
  14883. }
  14884. })();
  14885. (function checkCurrentScript() {
  14886. if (!hasDOM) {
  14887. return;
  14888. }
  14889. if ('currentScript' in document) {
  14890. return;
  14891. }
  14892. Object.defineProperty(document, 'currentScript', {
  14893. get: function get() {
  14894. var scripts = document.getElementsByTagName('script');
  14895. return scripts[scripts.length - 1];
  14896. },
  14897. enumerable: true,
  14898. configurable: true
  14899. });
  14900. })();
  14901. (function checkInputTypeNumberAssign() {
  14902. if (!hasDOM) {
  14903. return;
  14904. }
  14905. var el = document.createElement('input');
  14906. try {
  14907. el.type = 'number';
  14908. } catch (ex) {
  14909. var inputProto = el.constructor.prototype;
  14910. var typeProperty = Object.getOwnPropertyDescriptor(inputProto, 'type');
  14911. Object.defineProperty(inputProto, 'type', {
  14912. get: function get() {
  14913. return typeProperty.get.call(this);
  14914. },
  14915. set: function set(value) {
  14916. typeProperty.set.call(this, value === 'number' ? 'text' : value);
  14917. },
  14918. enumerable: true,
  14919. configurable: true
  14920. });
  14921. }
  14922. })();
  14923. (function checkDocumentReadyState() {
  14924. if (!hasDOM) {
  14925. return;
  14926. }
  14927. if (!document.attachEvent) {
  14928. return;
  14929. }
  14930. var documentProto = document.constructor.prototype;
  14931. var readyStateProto = Object.getOwnPropertyDescriptor(documentProto, 'readyState');
  14932. Object.defineProperty(documentProto, 'readyState', {
  14933. get: function get() {
  14934. var value = readyStateProto.get.call(this);
  14935. return value === 'interactive' ? 'loading' : value;
  14936. },
  14937. set: function set(value) {
  14938. readyStateProto.set.call(this, value);
  14939. },
  14940. enumerable: true,
  14941. configurable: true
  14942. });
  14943. })();
  14944. (function checkChildNodeRemove() {
  14945. if (!hasDOM) {
  14946. return;
  14947. }
  14948. if (typeof Element.prototype.remove !== 'undefined') {
  14949. return;
  14950. }
  14951. Element.prototype.remove = function () {
  14952. if (this.parentNode) {
  14953. this.parentNode.removeChild(this);
  14954. }
  14955. };
  14956. })();
  14957. (function checkNumberIsNaN() {
  14958. if (Number.isNaN) {
  14959. return;
  14960. }
  14961. Number.isNaN = function (value) {
  14962. return typeof value === 'number' && isNaN(value);
  14963. };
  14964. })();
  14965. (function checkNumberIsInteger() {
  14966. if (Number.isInteger) {
  14967. return;
  14968. }
  14969. Number.isInteger = function (value) {
  14970. return typeof value === 'number' && isFinite(value) && Math.floor(value) === value;
  14971. };
  14972. })();
  14973. (function checkPromise() {
  14974. if (globalScope.Promise) {
  14975. if (typeof globalScope.Promise.all !== 'function') {
  14976. globalScope.Promise.all = function (iterable) {
  14977. var count = 0,
  14978. results = [],
  14979. resolve,
  14980. reject;
  14981. var promise = new globalScope.Promise(function (resolve_, reject_) {
  14982. resolve = resolve_;
  14983. reject = reject_;
  14984. });
  14985. iterable.forEach(function (p, i) {
  14986. count++;
  14987. p.then(function (result) {
  14988. results[i] = result;
  14989. count--;
  14990. if (count === 0) {
  14991. resolve(results);
  14992. }
  14993. }, reject);
  14994. });
  14995. if (count === 0) {
  14996. resolve(results);
  14997. }
  14998. return promise;
  14999. };
  15000. }
  15001. if (typeof globalScope.Promise.resolve !== 'function') {
  15002. globalScope.Promise.resolve = function (value) {
  15003. return new globalScope.Promise(function (resolve) {
  15004. resolve(value);
  15005. });
  15006. };
  15007. }
  15008. if (typeof globalScope.Promise.reject !== 'function') {
  15009. globalScope.Promise.reject = function (reason) {
  15010. return new globalScope.Promise(function (resolve, reject) {
  15011. reject(reason);
  15012. });
  15013. };
  15014. }
  15015. if (typeof globalScope.Promise.prototype.catch !== 'function') {
  15016. globalScope.Promise.prototype.catch = function (onReject) {
  15017. return globalScope.Promise.prototype.then(undefined, onReject);
  15018. };
  15019. }
  15020. return;
  15021. }
  15022. var STATUS_PENDING = 0;
  15023. var STATUS_RESOLVED = 1;
  15024. var STATUS_REJECTED = 2;
  15025. var REJECTION_TIMEOUT = 500;
  15026. var HandlerManager = {
  15027. handlers: [],
  15028. running: false,
  15029. unhandledRejections: [],
  15030. pendingRejectionCheck: false,
  15031. scheduleHandlers: function scheduleHandlers(promise) {
  15032. if (promise._status === STATUS_PENDING) {
  15033. return;
  15034. }
  15035. this.handlers = this.handlers.concat(promise._handlers);
  15036. promise._handlers = [];
  15037. if (this.running) {
  15038. return;
  15039. }
  15040. this.running = true;
  15041. setTimeout(this.runHandlers.bind(this), 0);
  15042. },
  15043. runHandlers: function runHandlers() {
  15044. var RUN_TIMEOUT = 1;
  15045. var timeoutAt = Date.now() + RUN_TIMEOUT;
  15046. while (this.handlers.length > 0) {
  15047. var handler = this.handlers.shift();
  15048. var nextStatus = handler.thisPromise._status;
  15049. var nextValue = handler.thisPromise._value;
  15050. try {
  15051. if (nextStatus === STATUS_RESOLVED) {
  15052. if (typeof handler.onResolve === 'function') {
  15053. nextValue = handler.onResolve(nextValue);
  15054. }
  15055. } else if (typeof handler.onReject === 'function') {
  15056. nextValue = handler.onReject(nextValue);
  15057. nextStatus = STATUS_RESOLVED;
  15058. if (handler.thisPromise._unhandledRejection) {
  15059. this.removeUnhandeledRejection(handler.thisPromise);
  15060. }
  15061. }
  15062. } catch (ex) {
  15063. nextStatus = STATUS_REJECTED;
  15064. nextValue = ex;
  15065. }
  15066. handler.nextPromise._updateStatus(nextStatus, nextValue);
  15067. if (Date.now() >= timeoutAt) {
  15068. break;
  15069. }
  15070. }
  15071. if (this.handlers.length > 0) {
  15072. setTimeout(this.runHandlers.bind(this), 0);
  15073. return;
  15074. }
  15075. this.running = false;
  15076. },
  15077. addUnhandledRejection: function addUnhandledRejection(promise) {
  15078. this.unhandledRejections.push({
  15079. promise: promise,
  15080. time: Date.now()
  15081. });
  15082. this.scheduleRejectionCheck();
  15083. },
  15084. removeUnhandeledRejection: function removeUnhandeledRejection(promise) {
  15085. promise._unhandledRejection = false;
  15086. for (var i = 0; i < this.unhandledRejections.length; i++) {
  15087. if (this.unhandledRejections[i].promise === promise) {
  15088. this.unhandledRejections.splice(i);
  15089. i--;
  15090. }
  15091. }
  15092. },
  15093. scheduleRejectionCheck: function scheduleRejectionCheck() {
  15094. var _this = this;
  15095. if (this.pendingRejectionCheck) {
  15096. return;
  15097. }
  15098. this.pendingRejectionCheck = true;
  15099. setTimeout(function () {
  15100. _this.pendingRejectionCheck = false;
  15101. var now = Date.now();
  15102. for (var i = 0; i < _this.unhandledRejections.length; i++) {
  15103. if (now - _this.unhandledRejections[i].time > REJECTION_TIMEOUT) {
  15104. var unhandled = _this.unhandledRejections[i].promise._value;
  15105. var msg = 'Unhandled rejection: ' + unhandled;
  15106. if (unhandled.stack) {
  15107. msg += '\n' + unhandled.stack;
  15108. }
  15109. try {
  15110. throw new Error(msg);
  15111. } catch (_) {
  15112. console.warn(msg);
  15113. }
  15114. _this.unhandledRejections.splice(i);
  15115. i--;
  15116. }
  15117. }
  15118. if (_this.unhandledRejections.length) {
  15119. _this.scheduleRejectionCheck();
  15120. }
  15121. }, REJECTION_TIMEOUT);
  15122. }
  15123. };
  15124. var Promise = function Promise(resolver) {
  15125. this._status = STATUS_PENDING;
  15126. this._handlers = [];
  15127. try {
  15128. resolver.call(this, this._resolve.bind(this), this._reject.bind(this));
  15129. } catch (e) {
  15130. this._reject(e);
  15131. }
  15132. };
  15133. Promise.all = function Promise_all(promises) {
  15134. var resolveAll, rejectAll;
  15135. var deferred = new Promise(function (resolve, reject) {
  15136. resolveAll = resolve;
  15137. rejectAll = reject;
  15138. });
  15139. var unresolved = promises.length;
  15140. var results = [];
  15141. if (unresolved === 0) {
  15142. resolveAll(results);
  15143. return deferred;
  15144. }
  15145. function reject(reason) {
  15146. if (deferred._status === STATUS_REJECTED) {
  15147. return;
  15148. }
  15149. results = [];
  15150. rejectAll(reason);
  15151. }
  15152. for (var i = 0, ii = promises.length; i < ii; ++i) {
  15153. var promise = promises[i];
  15154. var resolve = function (i) {
  15155. return function (value) {
  15156. if (deferred._status === STATUS_REJECTED) {
  15157. return;
  15158. }
  15159. results[i] = value;
  15160. unresolved--;
  15161. if (unresolved === 0) {
  15162. resolveAll(results);
  15163. }
  15164. };
  15165. }(i);
  15166. if (Promise.isPromise(promise)) {
  15167. promise.then(resolve, reject);
  15168. } else {
  15169. resolve(promise);
  15170. }
  15171. }
  15172. return deferred;
  15173. };
  15174. Promise.isPromise = function Promise_isPromise(value) {
  15175. return value && typeof value.then === 'function';
  15176. };
  15177. Promise.resolve = function Promise_resolve(value) {
  15178. return new Promise(function (resolve) {
  15179. resolve(value);
  15180. });
  15181. };
  15182. Promise.reject = function Promise_reject(reason) {
  15183. return new Promise(function (resolve, reject) {
  15184. reject(reason);
  15185. });
  15186. };
  15187. Promise.prototype = {
  15188. _status: null,
  15189. _value: null,
  15190. _handlers: null,
  15191. _unhandledRejection: null,
  15192. _updateStatus: function Promise__updateStatus(status, value) {
  15193. if (this._status === STATUS_RESOLVED || this._status === STATUS_REJECTED) {
  15194. return;
  15195. }
  15196. if (status === STATUS_RESOLVED && Promise.isPromise(value)) {
  15197. value.then(this._updateStatus.bind(this, STATUS_RESOLVED), this._updateStatus.bind(this, STATUS_REJECTED));
  15198. return;
  15199. }
  15200. this._status = status;
  15201. this._value = value;
  15202. if (status === STATUS_REJECTED && this._handlers.length === 0) {
  15203. this._unhandledRejection = true;
  15204. HandlerManager.addUnhandledRejection(this);
  15205. }
  15206. HandlerManager.scheduleHandlers(this);
  15207. },
  15208. _resolve: function Promise_resolve(value) {
  15209. this._updateStatus(STATUS_RESOLVED, value);
  15210. },
  15211. _reject: function Promise_reject(reason) {
  15212. this._updateStatus(STATUS_REJECTED, reason);
  15213. },
  15214. then: function Promise_then(onResolve, onReject) {
  15215. var nextPromise = new Promise(function (resolve, reject) {
  15216. this.resolve = resolve;
  15217. this.reject = reject;
  15218. });
  15219. this._handlers.push({
  15220. thisPromise: this,
  15221. onResolve: onResolve,
  15222. onReject: onReject,
  15223. nextPromise: nextPromise
  15224. });
  15225. HandlerManager.scheduleHandlers(this);
  15226. return nextPromise;
  15227. },
  15228. catch: function Promise_catch(onReject) {
  15229. return this.then(undefined, onReject);
  15230. }
  15231. };
  15232. globalScope.Promise = Promise;
  15233. })();
  15234. (function checkWeakMap() {
  15235. if (globalScope.WeakMap) {
  15236. return;
  15237. }
  15238. var id = 0;
  15239. function WeakMap() {
  15240. this.id = '$weakmap' + id++;
  15241. }
  15242. WeakMap.prototype = {
  15243. has: function has(obj) {
  15244. if ((typeof obj === 'undefined' ? 'undefined' : _typeof(obj)) !== 'object' && typeof obj !== 'function' || obj === null) {
  15245. return false;
  15246. }
  15247. return !!Object.getOwnPropertyDescriptor(obj, this.id);
  15248. },
  15249. get: function get(obj) {
  15250. return this.has(obj) ? obj[this.id] : undefined;
  15251. },
  15252. set: function set(obj, value) {
  15253. Object.defineProperty(obj, this.id, {
  15254. value: value,
  15255. enumerable: false,
  15256. configurable: true
  15257. });
  15258. },
  15259. delete: function _delete(obj) {
  15260. delete obj[this.id];
  15261. }
  15262. };
  15263. globalScope.WeakMap = WeakMap;
  15264. })();
  15265. (function checkURLConstructor() {
  15266. var hasWorkingUrl = false;
  15267. try {
  15268. if (typeof URL === 'function' && _typeof(URL.prototype) === 'object' && 'origin' in URL.prototype) {
  15269. var u = new URL('b', 'http://a');
  15270. u.pathname = 'c%20d';
  15271. hasWorkingUrl = u.href === 'http://a/c%20d';
  15272. }
  15273. } catch (e) {}
  15274. if (hasWorkingUrl) {
  15275. return;
  15276. }
  15277. var relative = Object.create(null);
  15278. relative['ftp'] = 21;
  15279. relative['file'] = 0;
  15280. relative['gopher'] = 70;
  15281. relative['http'] = 80;
  15282. relative['https'] = 443;
  15283. relative['ws'] = 80;
  15284. relative['wss'] = 443;
  15285. var relativePathDotMapping = Object.create(null);
  15286. relativePathDotMapping['%2e'] = '.';
  15287. relativePathDotMapping['.%2e'] = '..';
  15288. relativePathDotMapping['%2e.'] = '..';
  15289. relativePathDotMapping['%2e%2e'] = '..';
  15290. function isRelativeScheme(scheme) {
  15291. return relative[scheme] !== undefined;
  15292. }
  15293. function invalid() {
  15294. clear.call(this);
  15295. this._isInvalid = true;
  15296. }
  15297. function IDNAToASCII(h) {
  15298. if (h === '') {
  15299. invalid.call(this);
  15300. }
  15301. return h.toLowerCase();
  15302. }
  15303. function percentEscape(c) {
  15304. var unicode = c.charCodeAt(0);
  15305. if (unicode > 0x20 && unicode < 0x7F && [0x22, 0x23, 0x3C, 0x3E, 0x3F, 0x60].indexOf(unicode) === -1) {
  15306. return c;
  15307. }
  15308. return encodeURIComponent(c);
  15309. }
  15310. function percentEscapeQuery(c) {
  15311. var unicode = c.charCodeAt(0);
  15312. if (unicode > 0x20 && unicode < 0x7F && [0x22, 0x23, 0x3C, 0x3E, 0x60].indexOf(unicode) === -1) {
  15313. return c;
  15314. }
  15315. return encodeURIComponent(c);
  15316. }
  15317. var EOF,
  15318. ALPHA = /[a-zA-Z]/,
  15319. ALPHANUMERIC = /[a-zA-Z0-9\+\-\.]/;
  15320. function parse(input, stateOverride, base) {
  15321. function err(message) {
  15322. errors.push(message);
  15323. }
  15324. var state = stateOverride || 'scheme start',
  15325. cursor = 0,
  15326. buffer = '',
  15327. seenAt = false,
  15328. seenBracket = false,
  15329. errors = [];
  15330. loop: while ((input[cursor - 1] !== EOF || cursor === 0) && !this._isInvalid) {
  15331. var c = input[cursor];
  15332. switch (state) {
  15333. case 'scheme start':
  15334. if (c && ALPHA.test(c)) {
  15335. buffer += c.toLowerCase();
  15336. state = 'scheme';
  15337. } else if (!stateOverride) {
  15338. buffer = '';
  15339. state = 'no scheme';
  15340. continue;
  15341. } else {
  15342. err('Invalid scheme.');
  15343. break loop;
  15344. }
  15345. break;
  15346. case 'scheme':
  15347. if (c && ALPHANUMERIC.test(c)) {
  15348. buffer += c.toLowerCase();
  15349. } else if (c === ':') {
  15350. this._scheme = buffer;
  15351. buffer = '';
  15352. if (stateOverride) {
  15353. break loop;
  15354. }
  15355. if (isRelativeScheme(this._scheme)) {
  15356. this._isRelative = true;
  15357. }
  15358. if (this._scheme === 'file') {
  15359. state = 'relative';
  15360. } else if (this._isRelative && base && base._scheme === this._scheme) {
  15361. state = 'relative or authority';
  15362. } else if (this._isRelative) {
  15363. state = 'authority first slash';
  15364. } else {
  15365. state = 'scheme data';
  15366. }
  15367. } else if (!stateOverride) {
  15368. buffer = '';
  15369. cursor = 0;
  15370. state = 'no scheme';
  15371. continue;
  15372. } else if (c === EOF) {
  15373. break loop;
  15374. } else {
  15375. err('Code point not allowed in scheme: ' + c);
  15376. break loop;
  15377. }
  15378. break;
  15379. case 'scheme data':
  15380. if (c === '?') {
  15381. this._query = '?';
  15382. state = 'query';
  15383. } else if (c === '#') {
  15384. this._fragment = '#';
  15385. state = 'fragment';
  15386. } else {
  15387. if (c !== EOF && c !== '\t' && c !== '\n' && c !== '\r') {
  15388. this._schemeData += percentEscape(c);
  15389. }
  15390. }
  15391. break;
  15392. case 'no scheme':
  15393. if (!base || !isRelativeScheme(base._scheme)) {
  15394. err('Missing scheme.');
  15395. invalid.call(this);
  15396. } else {
  15397. state = 'relative';
  15398. continue;
  15399. }
  15400. break;
  15401. case 'relative or authority':
  15402. if (c === '/' && input[cursor + 1] === '/') {
  15403. state = 'authority ignore slashes';
  15404. } else {
  15405. err('Expected /, got: ' + c);
  15406. state = 'relative';
  15407. continue;
  15408. }
  15409. break;
  15410. case 'relative':
  15411. this._isRelative = true;
  15412. if (this._scheme !== 'file') {
  15413. this._scheme = base._scheme;
  15414. }
  15415. if (c === EOF) {
  15416. this._host = base._host;
  15417. this._port = base._port;
  15418. this._path = base._path.slice();
  15419. this._query = base._query;
  15420. this._username = base._username;
  15421. this._password = base._password;
  15422. break loop;
  15423. } else if (c === '/' || c === '\\') {
  15424. if (c === '\\') {
  15425. err('\\ is an invalid code point.');
  15426. }
  15427. state = 'relative slash';
  15428. } else if (c === '?') {
  15429. this._host = base._host;
  15430. this._port = base._port;
  15431. this._path = base._path.slice();
  15432. this._query = '?';
  15433. this._username = base._username;
  15434. this._password = base._password;
  15435. state = 'query';
  15436. } else if (c === '#') {
  15437. this._host = base._host;
  15438. this._port = base._port;
  15439. this._path = base._path.slice();
  15440. this._query = base._query;
  15441. this._fragment = '#';
  15442. this._username = base._username;
  15443. this._password = base._password;
  15444. state = 'fragment';
  15445. } else {
  15446. var nextC = input[cursor + 1];
  15447. var nextNextC = input[cursor + 2];
  15448. if (this._scheme !== 'file' || !ALPHA.test(c) || nextC !== ':' && nextC !== '|' || nextNextC !== EOF && nextNextC !== '/' && nextNextC !== '\\' && nextNextC !== '?' && nextNextC !== '#') {
  15449. this._host = base._host;
  15450. this._port = base._port;
  15451. this._username = base._username;
  15452. this._password = base._password;
  15453. this._path = base._path.slice();
  15454. this._path.pop();
  15455. }
  15456. state = 'relative path';
  15457. continue;
  15458. }
  15459. break;
  15460. case 'relative slash':
  15461. if (c === '/' || c === '\\') {
  15462. if (c === '\\') {
  15463. err('\\ is an invalid code point.');
  15464. }
  15465. if (this._scheme === 'file') {
  15466. state = 'file host';
  15467. } else {
  15468. state = 'authority ignore slashes';
  15469. }
  15470. } else {
  15471. if (this._scheme !== 'file') {
  15472. this._host = base._host;
  15473. this._port = base._port;
  15474. this._username = base._username;
  15475. this._password = base._password;
  15476. }
  15477. state = 'relative path';
  15478. continue;
  15479. }
  15480. break;
  15481. case 'authority first slash':
  15482. if (c === '/') {
  15483. state = 'authority second slash';
  15484. } else {
  15485. err('Expected \'/\', got: ' + c);
  15486. state = 'authority ignore slashes';
  15487. continue;
  15488. }
  15489. break;
  15490. case 'authority second slash':
  15491. state = 'authority ignore slashes';
  15492. if (c !== '/') {
  15493. err('Expected \'/\', got: ' + c);
  15494. continue;
  15495. }
  15496. break;
  15497. case 'authority ignore slashes':
  15498. if (c !== '/' && c !== '\\') {
  15499. state = 'authority';
  15500. continue;
  15501. } else {
  15502. err('Expected authority, got: ' + c);
  15503. }
  15504. break;
  15505. case 'authority':
  15506. if (c === '@') {
  15507. if (seenAt) {
  15508. err('@ already seen.');
  15509. buffer += '%40';
  15510. }
  15511. seenAt = true;
  15512. for (var i = 0; i < buffer.length; i++) {
  15513. var cp = buffer[i];
  15514. if (cp === '\t' || cp === '\n' || cp === '\r') {
  15515. err('Invalid whitespace in authority.');
  15516. continue;
  15517. }
  15518. if (cp === ':' && this._password === null) {
  15519. this._password = '';
  15520. continue;
  15521. }
  15522. var tempC = percentEscape(cp);
  15523. if (this._password !== null) {
  15524. this._password += tempC;
  15525. } else {
  15526. this._username += tempC;
  15527. }
  15528. }
  15529. buffer = '';
  15530. } else if (c === EOF || c === '/' || c === '\\' || c === '?' || c === '#') {
  15531. cursor -= buffer.length;
  15532. buffer = '';
  15533. state = 'host';
  15534. continue;
  15535. } else {
  15536. buffer += c;
  15537. }
  15538. break;
  15539. case 'file host':
  15540. if (c === EOF || c === '/' || c === '\\' || c === '?' || c === '#') {
  15541. if (buffer.length === 2 && ALPHA.test(buffer[0]) && (buffer[1] === ':' || buffer[1] === '|')) {
  15542. state = 'relative path';
  15543. } else if (buffer.length === 0) {
  15544. state = 'relative path start';
  15545. } else {
  15546. this._host = IDNAToASCII.call(this, buffer);
  15547. buffer = '';
  15548. state = 'relative path start';
  15549. }
  15550. continue;
  15551. } else if (c === '\t' || c === '\n' || c === '\r') {
  15552. err('Invalid whitespace in file host.');
  15553. } else {
  15554. buffer += c;
  15555. }
  15556. break;
  15557. case 'host':
  15558. case 'hostname':
  15559. if (c === ':' && !seenBracket) {
  15560. this._host = IDNAToASCII.call(this, buffer);
  15561. buffer = '';
  15562. state = 'port';
  15563. if (stateOverride === 'hostname') {
  15564. break loop;
  15565. }
  15566. } else if (c === EOF || c === '/' || c === '\\' || c === '?' || c === '#') {
  15567. this._host = IDNAToASCII.call(this, buffer);
  15568. buffer = '';
  15569. state = 'relative path start';
  15570. if (stateOverride) {
  15571. break loop;
  15572. }
  15573. continue;
  15574. } else if (c !== '\t' && c !== '\n' && c !== '\r') {
  15575. if (c === '[') {
  15576. seenBracket = true;
  15577. } else if (c === ']') {
  15578. seenBracket = false;
  15579. }
  15580. buffer += c;
  15581. } else {
  15582. err('Invalid code point in host/hostname: ' + c);
  15583. }
  15584. break;
  15585. case 'port':
  15586. if (/[0-9]/.test(c)) {
  15587. buffer += c;
  15588. } else if (c === EOF || c === '/' || c === '\\' || c === '?' || c === '#' || stateOverride) {
  15589. if (buffer !== '') {
  15590. var temp = parseInt(buffer, 10);
  15591. if (temp !== relative[this._scheme]) {
  15592. this._port = temp + '';
  15593. }
  15594. buffer = '';
  15595. }
  15596. if (stateOverride) {
  15597. break loop;
  15598. }
  15599. state = 'relative path start';
  15600. continue;
  15601. } else if (c === '\t' || c === '\n' || c === '\r') {
  15602. err('Invalid code point in port: ' + c);
  15603. } else {
  15604. invalid.call(this);
  15605. }
  15606. break;
  15607. case 'relative path start':
  15608. if (c === '\\') {
  15609. err('\'\\\' not allowed in path.');
  15610. }
  15611. state = 'relative path';
  15612. if (c !== '/' && c !== '\\') {
  15613. continue;
  15614. }
  15615. break;
  15616. case 'relative path':
  15617. if (c === EOF || c === '/' || c === '\\' || !stateOverride && (c === '?' || c === '#')) {
  15618. if (c === '\\') {
  15619. err('\\ not allowed in relative path.');
  15620. }
  15621. var tmp;
  15622. if (tmp = relativePathDotMapping[buffer.toLowerCase()]) {
  15623. buffer = tmp;
  15624. }
  15625. if (buffer === '..') {
  15626. this._path.pop();
  15627. if (c !== '/' && c !== '\\') {
  15628. this._path.push('');
  15629. }
  15630. } else if (buffer === '.' && c !== '/' && c !== '\\') {
  15631. this._path.push('');
  15632. } else if (buffer !== '.') {
  15633. if (this._scheme === 'file' && this._path.length === 0 && buffer.length === 2 && ALPHA.test(buffer[0]) && buffer[1] === '|') {
  15634. buffer = buffer[0] + ':';
  15635. }
  15636. this._path.push(buffer);
  15637. }
  15638. buffer = '';
  15639. if (c === '?') {
  15640. this._query = '?';
  15641. state = 'query';
  15642. } else if (c === '#') {
  15643. this._fragment = '#';
  15644. state = 'fragment';
  15645. }
  15646. } else if (c !== '\t' && c !== '\n' && c !== '\r') {
  15647. buffer += percentEscape(c);
  15648. }
  15649. break;
  15650. case 'query':
  15651. if (!stateOverride && c === '#') {
  15652. this._fragment = '#';
  15653. state = 'fragment';
  15654. } else if (c !== EOF && c !== '\t' && c !== '\n' && c !== '\r') {
  15655. this._query += percentEscapeQuery(c);
  15656. }
  15657. break;
  15658. case 'fragment':
  15659. if (c !== EOF && c !== '\t' && c !== '\n' && c !== '\r') {
  15660. this._fragment += c;
  15661. }
  15662. break;
  15663. }
  15664. cursor++;
  15665. }
  15666. }
  15667. function clear() {
  15668. this._scheme = '';
  15669. this._schemeData = '';
  15670. this._username = '';
  15671. this._password = null;
  15672. this._host = '';
  15673. this._port = '';
  15674. this._path = [];
  15675. this._query = '';
  15676. this._fragment = '';
  15677. this._isInvalid = false;
  15678. this._isRelative = false;
  15679. }
  15680. function JURL(url, base) {
  15681. if (base !== undefined && !(base instanceof JURL)) {
  15682. base = new JURL(String(base));
  15683. }
  15684. this._url = url;
  15685. clear.call(this);
  15686. var input = url.replace(/^[ \t\r\n\f]+|[ \t\r\n\f]+$/g, '');
  15687. parse.call(this, input, null, base);
  15688. }
  15689. JURL.prototype = {
  15690. toString: function toString() {
  15691. return this.href;
  15692. },
  15693. get href() {
  15694. if (this._isInvalid) {
  15695. return this._url;
  15696. }
  15697. var authority = '';
  15698. if (this._username !== '' || this._password !== null) {
  15699. authority = this._username + (this._password !== null ? ':' + this._password : '') + '@';
  15700. }
  15701. return this.protocol + (this._isRelative ? '//' + authority + this.host : '') + this.pathname + this._query + this._fragment;
  15702. },
  15703. set href(value) {
  15704. clear.call(this);
  15705. parse.call(this, value);
  15706. },
  15707. get protocol() {
  15708. return this._scheme + ':';
  15709. },
  15710. set protocol(value) {
  15711. if (this._isInvalid) {
  15712. return;
  15713. }
  15714. parse.call(this, value + ':', 'scheme start');
  15715. },
  15716. get host() {
  15717. return this._isInvalid ? '' : this._port ? this._host + ':' + this._port : this._host;
  15718. },
  15719. set host(value) {
  15720. if (this._isInvalid || !this._isRelative) {
  15721. return;
  15722. }
  15723. parse.call(this, value, 'host');
  15724. },
  15725. get hostname() {
  15726. return this._host;
  15727. },
  15728. set hostname(value) {
  15729. if (this._isInvalid || !this._isRelative) {
  15730. return;
  15731. }
  15732. parse.call(this, value, 'hostname');
  15733. },
  15734. get port() {
  15735. return this._port;
  15736. },
  15737. set port(value) {
  15738. if (this._isInvalid || !this._isRelative) {
  15739. return;
  15740. }
  15741. parse.call(this, value, 'port');
  15742. },
  15743. get pathname() {
  15744. return this._isInvalid ? '' : this._isRelative ? '/' + this._path.join('/') : this._schemeData;
  15745. },
  15746. set pathname(value) {
  15747. if (this._isInvalid || !this._isRelative) {
  15748. return;
  15749. }
  15750. this._path = [];
  15751. parse.call(this, value, 'relative path start');
  15752. },
  15753. get search() {
  15754. return this._isInvalid || !this._query || this._query === '?' ? '' : this._query;
  15755. },
  15756. set search(value) {
  15757. if (this._isInvalid || !this._isRelative) {
  15758. return;
  15759. }
  15760. this._query = '?';
  15761. if (value[0] === '?') {
  15762. value = value.slice(1);
  15763. }
  15764. parse.call(this, value, 'query');
  15765. },
  15766. get hash() {
  15767. return this._isInvalid || !this._fragment || this._fragment === '#' ? '' : this._fragment;
  15768. },
  15769. set hash(value) {
  15770. if (this._isInvalid) {
  15771. return;
  15772. }
  15773. this._fragment = '#';
  15774. if (value[0] === '#') {
  15775. value = value.slice(1);
  15776. }
  15777. parse.call(this, value, 'fragment');
  15778. },
  15779. get origin() {
  15780. var host;
  15781. if (this._isInvalid || !this._scheme) {
  15782. return '';
  15783. }
  15784. switch (this._scheme) {
  15785. case 'data':
  15786. case 'file':
  15787. case 'javascript':
  15788. case 'mailto':
  15789. return 'null';
  15790. case 'blob':
  15791. try {
  15792. return new JURL(this._schemeData).origin || 'null';
  15793. } catch (_) {}
  15794. return 'null';
  15795. }
  15796. host = this.host;
  15797. if (!host) {
  15798. return '';
  15799. }
  15800. return this._scheme + '://' + host;
  15801. }
  15802. };
  15803. var OriginalURL = globalScope.URL;
  15804. if (OriginalURL) {
  15805. JURL.createObjectURL = function (blob) {
  15806. return OriginalURL.createObjectURL.apply(OriginalURL, arguments);
  15807. };
  15808. JURL.revokeObjectURL = function (url) {
  15809. OriginalURL.revokeObjectURL(url);
  15810. };
  15811. }
  15812. globalScope.URL = JURL;
  15813. })();
  15814. }
  15815. /***/ }),
  15816. /* 88 */
  15817. /***/ (function(module, exports, __w_pdfjs_require__) {
  15818. "use strict";
  15819. var isReadableStreamSupported = false;
  15820. if (typeof ReadableStream !== 'undefined') {
  15821. try {
  15822. new ReadableStream({
  15823. start: function start(controller) {
  15824. controller.close();
  15825. }
  15826. });
  15827. isReadableStreamSupported = true;
  15828. } catch (e) {}
  15829. }
  15830. if (isReadableStreamSupported) {
  15831. exports.ReadableStream = ReadableStream;
  15832. } else {
  15833. exports.ReadableStream = __w_pdfjs_require__(57).ReadableStream;
  15834. }
  15835. /***/ })
  15836. /******/ ]);
  15837. });
  15838. //# sourceMappingURL=pdf.js.map